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[@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
	queryString += "<returnfield>/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'ReportInstance_pdf\']/@value</returnfield>";*/
27
	
28
	/*queryString += "<returndoctype>kar</returndoctype>";*/
29
	queryString += "<returndoctype>http://www.kepler-project.org/kar-2.0.0</returndoctype>";
30
  queryString += "<returnfield>karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'user\']/@value</returnfield>";
31
  queryString += "<returnfield>karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'description\']/@value</returnfield>";
32
  queryString += "<returnfield>karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'startTime\']/@value</returnfield>";
33
  queryString += "<returnfield>karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'workflowLSID\']/@value</returnfield>";
34
  queryString += "<returnfield>karEntry/karEntryAttributes/tpcStatus</returnfield>";
35
  queryString += "<returnfield>karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'workflowName\']/@value</returnfield>";
36
  queryString += "<returnfield>mainAttributes/lsid</returnfield>";
37
  queryString += "<returnfield>karEntry/karEntryXML/property[@name=\'WorkflowRun\']/@class</returnfield>";
38
  queryString += "<returnfield>karEntry/karEntryAttributes/Name</returnfield>";
39
	
40
	queryString += "<querygroup operator='INTERSECT'>";	
41
	
42
	var elementList = document.getElementById(formId).elements;
43
	for(var i = 0; i < elementList.length; i++) {
44
	//alert("form element: " + elementList[i].id);
45
		if((elementList[i].id.indexOf("sf-") == 0) && (elementList[i].value != '')) {					
46
			queryString += getQueryTerm(elementList[i]);
47
		}
48
	} 
49
	
50
	queryString += "</querygroup>";	
51
	queryString += "</pathquery>";
52
	
53
	//alert(queryString);
54
	
55
	var queryField = document.getElementById("query");
56
	
57
	queryField.value = queryString;
58
}
59

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

    
134
	
(26-26/29)