/*
* Generate a workflow query string. this assumes that search fields meet the
* following criteria in the web page:
* -- search input fields have an ID that starts with sf_
* -- the search input field name is the xpath of the value to search
* -- if there is a search mode dropdown for an input field in the form, it's ID
* should use the same convention as the input field, but start with sm_
* (i.e. the search mode input for the sf_firstname input would be sm_firstname)
* -- the value
*/
function setWorkflowQueryFormField(formId) {
var queryString = "";
queryString += "";
/*queryString += "property";
queryString += "-//UC Berkeley//DTD MoML 1//EN";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'user\']/@value";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'description\']/@value";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'startTime\']/@value";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'workflowLSID\']/@value";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'tpcStatus\']/@value";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'workflowName\']/@value";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'pdfReport\']/@value";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'htmlReport\']/@value";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'karLSID\']/@value";
queryString += "/property[@class=\'org.kepler.util.WorkflowRun\']/property[@name=\'ReportInstance_pdf\']/@value";*/
/*queryString += "kar";*/
queryString += "http://www.kepler-project.org/kar-2.0.0";
queryString += "http://www.kepler-project.org/kar-2.1.0";
queryString += "karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'user\']/@value";
queryString += "karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'description\']/@value";
queryString += "karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'startTime\']/@value";
queryString += "karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'workflowLSID\']/@value";
queryString += "karEntry/karEntryAttributes/tpcStatus";
queryString += "karEntry/karEntryXML/property[@name=\'WorkflowRun\']/property[@name=\'workflowName\']/@value";
queryString += "mainAttributes/lsid";
queryString += "karEntry/karEntryXML/property[@name=\'WorkflowRun\']/@class";
queryString += "karEntry/karEntryAttributes/Name";
queryString += "";
var elementList = document.getElementById(formId).elements;
for(var i = 0; i < elementList.length; i++) {
//alert("form element: " + elementList[i].id);
if((elementList[i].id.indexOf("sf-") == 0) && (elementList[i].value != '')) {
queryString += getQueryTerm(elementList[i]);
}
}
queryString += "";
queryString += "";
//alert(queryString);
var queryField = document.getElementById("query");
queryField.value = queryString;
}
/*
* Generate individual query terms for all the search input fields in a search
* form. There must be a case for each search field handle explicitly below.
* This assumes:
* -- search input fields have an ID that starts with sf-
* -- if there is a search mode dropdown for an input field in the form, it's ID
* should use the same convention as the input field, but start with sm-
* (i.e. the search mode input for the sf-firstname input would be sm-firstname)
*/
function getQueryTerm(sfElement) {
var baseId = sfElement.id.substring(3, sfElement.id.length);
var searchMode = "contains";
var selector = document.getElementById("sm-" + baseId);
if (selector != null) {
searchMode = selector.value;
}
var pathExpr = '';
if (sfElement.name == 'name') {
pathExpr += "";
pathExpr += "" + sfElement.value + "";
/*pathExpr += "entity/@name";*/
pathExpr += "karEntry/karEntryXML/entity/@name";
pathExpr += "";
} else if (sfElement.name == 'keyword') {
pathExpr += "";
pathExpr += "" + sfElement.value + "";
pathExpr += "karEntry/karEntryXML/entity/property/@value";
pathExpr += "";
} else if (sfElement.name == 'creator') {
pathExpr += "";
pathExpr += "" + sfElement.value + "";
pathExpr += "karEntry/karEntryXML/entity/property/property/configure";
pathExpr += "";
} else if (sfElement.name == 'description') {
pathExpr += "";
pathExpr += "" + sfElement.value + "";
pathExpr += "karEntry/karEntryXML/entity/property/property/configure";
pathExpr += "";
} else if (sfElement.name == 'date-created') {
pathExpr += "";
pathExpr += "" + sfElement.value + "";
pathExpr += "karEntry/karEntryXML/entity/property/property/configure";
pathExpr += "";
} else if (sfElement.name == 'date-executed') {
pathExpr += "";
pathExpr += "" + sfElement.value + "";
pathExpr += "karEntry/karEntryXML/property/property/@value";
pathExpr += "";
} else if (sfElement.name == 'workflow-lsid') {
pathExpr += "";
pathExpr += "entityId";
pathExpr += "karEntry/karEntryXML/entity/property/@name";
pathExpr += "";
pathExpr += "";
pathExpr += "" + sfElement.value + "";
pathExpr += "karEntry/karEntryXML/entity/property/@value";
pathExpr += "";
}else if (sfElement.name == 'workflow-run-lsid') {
pathExpr += "";
pathExpr += "" + sfElement.value + "";
pathExpr += "karEntry/karEntryXML/property/property/@value";
pathExpr += "";
}else if (sfElement.name == 'status') {
pathExpr += "";
pathExpr += "" + sfElement.value + "";
pathExpr += "karEntry/karEntryXML/property/property/@value";
pathExpr += "";
}
//alert("returning path expression: " + pathExpr);
return pathExpr;
}