1 |
4966
|
daigle
|
/*
|
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 |
4971
|
daigle
|
queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'tpcStatus\']/@value</returnfield>";
|
22 |
4966
|
daigle
|
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 |
4976
|
daigle
|
queryString += "<returnfield>/property[@name=\'WorkflowRun\']/property[@name=\'ReportInstance_pdf\']/@value</returnfield>";
|
27 |
4966
|
daigle
|
|
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 |
4971
|
daigle
|
/*
|
49 |
|
|
* Generate individual query terms for all the search input fields in a search
|
50 |
|
|
* form. There must be a case for each search field handle explicitly below.
|
51 |
|
|
* This assumes:
|
52 |
|
|
* -- search input fields have an ID that starts with sf-
|
53 |
|
|
* -- if there is a search mode dropdown for an input field in the form, it's ID
|
54 |
|
|
* should use the same convention as the input field, but start with sm-
|
55 |
|
|
* (i.e. the search mode input for the sf-firstname input would be sm-firstname)
|
56 |
|
|
*/
|
57 |
4966
|
daigle
|
function getQueryTerm(sfElement) {
|
58 |
|
|
var baseId = sfElement.id.substring(3, sfElement.id.length);
|
59 |
|
|
var searchMode = "contains";
|
60 |
|
|
var selector = document.getElementById("sm-" + baseId);
|
61 |
|
|
if (selector != null) {
|
62 |
|
|
searchMode = selector.value;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
var pathExpr = '';
|
66 |
|
|
if (sfElement.name == 'name') {
|
67 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
68 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
69 |
|
|
pathExpr += "<pathexpr>entity/@name</pathexpr>";
|
70 |
|
|
pathExpr += "</queryterm>";
|
71 |
|
|
} else if (sfElement.name == 'keyword') {
|
72 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
73 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
74 |
|
|
pathExpr += "<pathexpr>property/@value</pathexpr>";
|
75 |
|
|
pathExpr += "</queryterm>";
|
76 |
|
|
} else if (sfElement.name == 'creator') {
|
77 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
78 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
79 |
|
|
pathExpr += "<pathexpr>property/property/configure</pathexpr>";
|
80 |
|
|
pathExpr += "</queryterm>";
|
81 |
|
|
} else if (sfElement.name == 'description') {
|
82 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
83 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
84 |
|
|
pathExpr += "<pathexpr>property/property/configure</pathexpr>";
|
85 |
|
|
pathExpr += "</queryterm>";
|
86 |
|
|
} else if (sfElement.name == 'date-created') {
|
87 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
88 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
89 |
|
|
pathExpr += "<pathexpr>property/property/configure</pathexpr>";
|
90 |
|
|
pathExpr += "</queryterm>";
|
91 |
|
|
} else if (sfElement.name == 'date-executed') {
|
92 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
93 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
94 |
|
|
pathExpr += "<pathexpr>property/property/configure</pathexpr>";
|
95 |
|
|
pathExpr += "</queryterm>";
|
96 |
|
|
} else if (sfElement.name == 'workflow-id') {
|
97 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
98 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
99 |
|
|
pathExpr += "<pathexpr>property/property/configure</pathexpr>";
|
100 |
|
|
pathExpr += "</queryterm>";
|
101 |
|
|
} else if (sfElement.name == 'workflow-lsid') {
|
102 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
103 |
|
|
pathExpr += "<value>workflowLSID</value>";
|
104 |
|
|
pathExpr += "<pathexpr>property/property/@name</pathexpr>";
|
105 |
|
|
pathExpr += "</queryterm>";
|
106 |
4976
|
daigle
|
pathExpr += "<queryterm casesensitive='false' searchmode='starts-with'>";
|
107 |
|
|
var workflowId = sfElement.value;
|
108 |
|
|
var lastColonPos = workflowId.lastIndexOf(':');
|
109 |
|
|
var truncWorkflowId = workflowId.substring(0, lastColonPos);
|
110 |
|
|
pathExpr += "<value>" + truncWorkflowId + "</value>";
|
111 |
|
|
pathExpr += "<pathexpr>property/property/@value</pathexpr>";
|
112 |
|
|
pathExpr += "</queryterm>";
|
113 |
4966
|
daigle
|
} else if (sfElement.name == 'workflow-run-id') {
|
114 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
115 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
116 |
|
|
pathExpr += "<pathexpr>property/property/configure</pathexpr>";
|
117 |
|
|
pathExpr += "</queryterm>";
|
118 |
|
|
} else if (sfElement.name == 'status') {
|
119 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
120 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
121 |
|
|
pathExpr += "<pathexpr>property/property/configure</pathexpr>";
|
122 |
|
|
pathExpr += "</queryterm>";
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
//alert("returning path expression: " + pathExpr);
|
126 |
|
|
return pathExpr;
|
127 |
|
|
}
|
128 |
|
|
|