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 |
5311
|
daigle
|
/*queryString += "<returndoctype>property</returndoctype>";
|
16 |
4966
|
daigle
|
queryString += "<returndoctype>-//UC Berkeley//DTD MoML 1//EN</returndoctype>";
|
17 |
5178
|
leinfelder
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'user\']/@value</returnfield>";
|
18 |
|
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'description\']/@value</returnfield>";
|
19 |
|
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'startTime\']/@value</returnfield>";
|
20 |
|
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'workflowLSID\']/@value</returnfield>";
|
21 |
|
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'tpcStatus\']/@value</returnfield>";
|
22 |
|
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'workflowName\']/@value</returnfield>";
|
23 |
|
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'pdfReport\']/@value</returnfield>";
|
24 |
|
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'htmlReport\']/@value</returnfield>";
|
25 |
|
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'karLSID\']/@value</returnfield>";
|
26 |
5311
|
daigle
|
queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'ReportInstance_pdf\']/@value</returnfield>";*/
|
27 |
4966
|
daigle
|
|
28 |
5311
|
daigle
|
queryString += "<returndoctype>kar</returndoctype>";
|
29 |
|
|
queryString += "<returnfield>/kar/karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'user\']/@value</returnfield>";
|
30 |
|
|
queryString += "<returnfield>/kar/karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'description\']/@value</returnfield>";
|
31 |
|
|
queryString += "<returnfield>/kar/karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'startTime\']/@value</returnfield>";
|
32 |
|
|
queryString += "<returnfield>/kar/karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'workflowLSID\']/@value</returnfield>";
|
33 |
|
|
queryString += "<returnfield>/kar/karEntry/karEntryAttributes/tpcStatus</returnfield>";
|
34 |
|
|
queryString += "<returnfield>/kar/karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'workflowName\']/@value</returnfield>";
|
35 |
|
|
queryString += "<returnfield>/kar/mainAttributes/lsid</returnfield>";
|
36 |
|
|
queryString += "<returnfield>/kar/karEntry/karEntryXML/property[@name=\'WorkflowRun\']/@class</returnfield>";
|
37 |
|
|
queryString += "<returnfield>/kar/karEntry/karEntryAttributes/Name</returnfield>";
|
38 |
|
|
|
39 |
4966
|
daigle
|
queryString += "<querygroup operator='INTERSECT'>";
|
40 |
|
|
|
41 |
|
|
var elementList = document.getElementById(formId).elements;
|
42 |
|
|
for(var i = 0; i < elementList.length; i++) {
|
43 |
|
|
//alert("form element: " + elementList[i].id);
|
44 |
|
|
if((elementList[i].id.indexOf("sf-") == 0) && (elementList[i].value != '')) {
|
45 |
|
|
queryString += getQueryTerm(elementList[i]);
|
46 |
|
|
}
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
queryString += "</querygroup>";
|
50 |
|
|
queryString += "</pathquery>";
|
51 |
|
|
|
52 |
|
|
//alert(queryString);
|
53 |
|
|
|
54 |
|
|
var queryField = document.getElementById("query");
|
55 |
|
|
|
56 |
|
|
queryField.value = queryString;
|
57 |
|
|
}
|
58 |
|
|
|
59 |
4971
|
daigle
|
/*
|
60 |
|
|
* Generate individual query terms for all the search input fields in a search
|
61 |
|
|
* form. There must be a case for each search field handle explicitly below.
|
62 |
|
|
* This assumes:
|
63 |
|
|
* -- search input fields have an ID that starts with sf-
|
64 |
|
|
* -- if there is a search mode dropdown for an input field in the form, it's ID
|
65 |
|
|
* should use the same convention as the input field, but start with sm-
|
66 |
|
|
* (i.e. the search mode input for the sf-firstname input would be sm-firstname)
|
67 |
|
|
*/
|
68 |
4966
|
daigle
|
function getQueryTerm(sfElement) {
|
69 |
|
|
var baseId = sfElement.id.substring(3, sfElement.id.length);
|
70 |
|
|
var searchMode = "contains";
|
71 |
|
|
var selector = document.getElementById("sm-" + baseId);
|
72 |
|
|
if (selector != null) {
|
73 |
|
|
searchMode = selector.value;
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
var pathExpr = '';
|
77 |
|
|
if (sfElement.name == 'name') {
|
78 |
5311
|
daigle
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
79 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
80 |
|
|
/*pathExpr += "<pathexpr>entity/@name</pathexpr>";*/
|
81 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/entity/@name</pathexpr>";
|
82 |
|
|
pathExpr += "</queryterm>";
|
83 |
|
|
} else if (sfElement.name == 'keyword') {
|
84 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
85 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
86 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/entity/property/@value</pathexpr>";
|
87 |
|
|
pathExpr += "</queryterm>";
|
88 |
|
|
} else if (sfElement.name == 'creator') {
|
89 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
90 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
91 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/entity/property/property/configure</pathexpr>";
|
92 |
|
|
pathExpr += "</queryterm>";
|
93 |
|
|
} else if (sfElement.name == 'description') {
|
94 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
95 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
96 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/entity/property/property/configure</pathexpr>";
|
97 |
|
|
pathExpr += "</queryterm>";
|
98 |
|
|
} else if (sfElement.name == 'date-created') {
|
99 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
100 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
101 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/entity/property/property/configure</pathexpr>";
|
102 |
|
|
pathExpr += "</queryterm>";
|
103 |
|
|
} else if (sfElement.name == 'date-executed') {
|
104 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
105 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
106 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/property/property/@value</pathexpr>";
|
107 |
|
|
pathExpr += "</queryterm>";
|
108 |
|
|
} else if (sfElement.name == 'workflow-lsid') {
|
109 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
110 |
|
|
pathExpr += "<value>entityId</value>";
|
111 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/entity/property/@name</pathexpr>";
|
112 |
|
|
pathExpr += "</queryterm>";
|
113 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
114 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
115 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/entity/property/@value</pathexpr>";
|
116 |
|
|
pathExpr += "</queryterm>";
|
117 |
|
|
}else if (sfElement.name == 'workflow-run-lsid') {
|
118 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
119 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
120 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/property/property/@value</pathexpr>";
|
121 |
|
|
pathExpr += "</queryterm>";
|
122 |
|
|
}else if (sfElement.name == 'status') {
|
123 |
|
|
pathExpr += "<queryterm casesensitive='false' searchmode='" + searchMode + "'>";
|
124 |
|
|
pathExpr += "<value>" + sfElement.value + "</value>";
|
125 |
|
|
pathExpr += "<pathexpr>/kar/karEntry/karEntryXML/property/property/@value</pathexpr>";
|
126 |
|
|
pathExpr += "</queryterm>";
|
127 |
|
|
}
|
128 |
4966
|
daigle
|
|
129 |
|
|
//alert("returning path expression: " + pathExpr);
|
130 |
|
|
return pathExpr;
|
131 |
|
|
}
|
132 |
|
|
|