Project

General

Profile

1
/*
2
 * Generate a workflow query string.  this assumes that search fields meet the
3
 * following criteria in the web page:
4
 * -- search input fields have an ID that starts with sf_ 
5
 * -- the search input field name is the xpath of the value to search
6
 * -- if there is a search mode dropdown for an input field in the form, it's ID 
7
 *    should use the same convention as the input field, but start with sm_
8
 *    (i.e. the search mode input for the sf_firstname input would be sm_firstname) 
9
 * -- the value 
10
 */
11
 
12
function setWorkflowQueryFormField(formId) {
13
	var queryString = ""; 
14
	queryString += "<pathquery version='1.2'>";
15
	queryString += "<returndoctype>property</returndoctype>";
16
	queryString += "<returndoctype>-//UC Berkeley//DTD MoML 1//EN</returndoctype>";
17
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'user\']/@value</returnfield>";
18
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'description\']/@value</returnfield>";
19
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'startTime\']/@value</returnfield>";
20
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'workflowLSID\']/@value</returnfield>";
21
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'status\']/@value</returnfield>";
22
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'workflowName\']/@value</returnfield>";
23
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'pdfReport\']/@value</returnfield>";
24
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'htmlReport\']/@value</returnfield>";
25
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'karLSID\']/@value</returnfield>";
26
	queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'ReportInstance0\']/@value</returnfield>";
27
	
28
	queryString += "<querygroup operator='INTERSECT'>";	
29
	
30
	var elementList = document.getElementById(formId).elements;
31
	for(var i = 0; i < elementList.length; i++) {
32
	//alert("form element: " + elementList[i].id);
33
		if((elementList[i].id.indexOf("sf-") == 0) && (elementList[i].value != '')) {					
34
			queryString += getQueryTerm(elementList[i]);
35
		}
36
	} 
37
	
38
	queryString += "</querygroup>";	
39
	queryString += "</pathquery>";
40
	
41
	//alert(queryString);
42
	
43
	var queryField = document.getElementById("query");
44
	
45
	queryField.value = queryString;
46
}
47

    
48
function getQueryTerm(sfElement) {
49
	var baseId = sfElement.id.substring(3, sfElement.id.length);		
50
	var searchMode = "contains";
51
	var selector = document.getElementById("sm-" + baseId);
52
	if (selector != null) {
53
		searchMode = selector.value;
54
	}
55
	
56
	var pathExpr = '';
57
	if (sfElement.name == 'name') {
58
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
59
		pathExpr += "<value>" + sfElement.value + "</value>";
60
		pathExpr += "<pathexpr>entity/@name</pathexpr>";
61
		pathExpr += "</queryterm>"; 		
62
	} else if (sfElement.name == 'keyword') {
63
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
64
		pathExpr += "<value>" + sfElement.value + "</value>";
65
		pathExpr += "<pathexpr>property/@value</pathexpr>";
66
		pathExpr += "</queryterm>"; 		
67
	} else if (sfElement.name == 'creator') {
68
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
69
		pathExpr += "<value>" + sfElement.value + "</value>";
70
		pathExpr += "<pathexpr>property/property/configure</pathexpr>";
71
		pathExpr += "</queryterm>"; 		
72
	} else if (sfElement.name == 'description') {
73
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
74
		pathExpr += "<value>" + sfElement.value + "</value>";
75
		pathExpr += "<pathexpr>property/property/configure</pathexpr>";
76
		pathExpr += "</queryterm>"; 		
77
	} else if (sfElement.name == 'date-created') {
78
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
79
		pathExpr += "<value>" + sfElement.value + "</value>";
80
		pathExpr += "<pathexpr>property/property/configure</pathexpr>";
81
		pathExpr += "</queryterm>"; 		
82
	} else if (sfElement.name == 'date-executed') {
83
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
84
		pathExpr += "<value>" + sfElement.value + "</value>";
85
		pathExpr += "<pathexpr>property/property/configure</pathexpr>";
86
		pathExpr += "</queryterm>"; 		
87
	} else if (sfElement.name == 'workflow-id') {
88
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
89
		pathExpr += "<value>" + sfElement.value + "</value>";
90
		pathExpr += "<pathexpr>property/property/configure</pathexpr>";
91
		pathExpr += "</queryterm>"; 		
92
	} else if (sfElement.name == 'workflow-lsid') {
93
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
94
		pathExpr += "<value>workflowLSID</value>";
95
		pathExpr += "<pathexpr>property/property/@name</pathexpr>";
96
		pathExpr += "</queryterm>"; 
97
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
98
		pathExpr += "<value>" + sfElement.value + "</value>";
99
		pathExpr += "<pathexpr>property/property/@value</pathexpr>";
100
		pathExpr += "</queryterm>";		
101
	} else if (sfElement.name == 'workflow-run-id') {
102
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
103
		pathExpr += "<value>" + sfElement.value + "</value>";
104
		pathExpr += "<pathexpr>property/property/configure</pathexpr>";
105
		pathExpr += "</queryterm>"; 		
106
	} else if (sfElement.name == 'status') {
107
		pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
108
		pathExpr += "<value>" + sfElement.value + "</value>";
109
		pathExpr += "<pathexpr>property/property/configure</pathexpr>";
110
		pathExpr += "</queryterm>"; 		
111
	} 
112
	
113
	//alert("returning path expression: " + pathExpr);
114
	return pathExpr;
115
}
116

    
117
function getResultsSection(url, formId, divId) {
118
	var submitResults = submitFormIntoDiv(url, formId, divId);
119
}
120

    
121
function showWorkflowRuns(workflowId, workflowRunPage) {
122
	url = document.URL + '/../' + workflowRunPage + '?workflowid=' + workflowId;
123
	//alert('new url: ' + url);
124
	window.location = url;
125
}
126

    
127
	
(27-27/32)