Project

General

Profile

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