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>entity</returndoctype>";
16
	queryString += "<returndoctype>-//UC Berkeley//DTD MoML 1//EN</returndoctype>";
17
	queryString += "<returnfield>/entity/@name</returnfield>";
18
	queryString += "<returnfield>property[@name=\'KeplerDocumentation\']/property[@name=\'author\']/configure</returnfield>";
19
	queryString += "<returnfield>property[@name=\'KeplerDocumentation\']/property[@name=\'description\']/configure</returnfield>";
20
	queryString += "<returnfield>property[@name=\'KeplerDocumentation\']/property[@name=\'createDate\']/configure</returnfield>";
21
	queryString += "<returnfield>property[@name=\'KeplerDocumentation\']/property[@name=\'workflowId\']/configure</returnfield>";
22
	queryString += "<returnfield>property[@name=\'KeplerDocumentation\']/property[@name=\'status\']/configure</returnfield>";
23
	queryString += "<returnfield>property[@name=\'KeplerDocumentation\']/property[@name=\'runDate\']/configure</returnfield>";
24
	queryString += "<returnfield>property[@name=\'KeplerDocumentation\']/property[@name=\'pdfReport\']/configure</returnfield>";
25
	queryString += "<returnfield>property[@name=\'KeplerDocumentation\']/property[@name=\'htmlReport\']/configure</returnfield>";
26
	queryString += "<returnfield>/entity/property[@name=\'karLSID\']/@value</returnfield>";				
27
	queryString += "<returnfield>/entity/property[@name=\'entityId\']/@value</returnfield>";
28
	
29
	queryString += "<querygroup operator='INTERSECT'>";	
30
	
31
	var elementList = document.getElementById(formId).elements;
32
	for(var i = 0; i < elementList.length; i++) {
33
	//alert("form element: " + elementList[i].id);
34
		if((elementList[i].id.indexOf("sf-") == 0) && (elementList[i].value != '')) {					
35
			queryString += getQueryTerm(elementList[i]);
36
		}
37
	} 
38
	
39
	queryString += "</querygroup>";	
40
	queryString += "</pathquery>";
41
	
42
	//alert(queryString);
43
	
44
	var queryField = document.getElementById("query");
45
	
46
	queryField.value = queryString;
47
}
48

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

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

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

    
128
	
(25-25/32)