[metcat] r189 committed - Indexed property retrieval methods added

1 view
Skip to first unread message

metcat.apach...@codespot.com

unread,
Aug 29, 2012, 2:57:37 AM8/29/12
to metca...@googlegroups.com
Revision: 189
Author: tobha...@gmail.com
Date: Tue Aug 28 23:57:17 2012
Log: Indexed property retrieval methods added
http://code.google.com/a/apache-extras.org/p/metcat/source/detail?r=189

Modified:

/trunk/metcatserver/src/main/java/org/apache/airavata/metcat/api/MetCatAPI.java

=======================================
---
/trunk/metcatserver/src/main/java/org/apache/airavata/metcat/api/MetCatAPI.java
Tue Aug 28 21:57:42 2012
+++
/trunk/metcatserver/src/main/java/org/apache/airavata/metcat/api/MetCatAPI.java
Tue Aug 28 23:57:17 2012
@@ -41,50 +41,63 @@
ModelCreator.datamodelImpl);
private static WorkflowStatus wfStatus = new WorkflowStatus(
ModelCreator.datamodelImpl);
- private static DataProductByWorkflow dpByWorkf = new
DataProductByWorkflow(ModelCreator.datamodelImpl);
- private static DataProductChanged dpChanged = new
DataProductChanged(ModelCreator.datamodelImpl);
- private static DataProductConsumed dpConsumed = new
DataProductConsumed(ModelCreator.datamodelImpl);
-
- @SuppressWarnings("unused")
+ private static DataProductByWorkflow dpByWorkf = new
DataProductByWorkflow(
+ ModelCreator.datamodelImpl);
+ private static DataProductChanged dpChanged = new DataProductChanged(
+ ModelCreator.datamodelImpl);
+ private static DataProductConsumed dpConsumed = new DataProductConsumed(
+ ModelCreator.datamodelImpl);
private static WorkflowIndex wfIndex = new WorkflowIndex(
ModelCreator.datamodelImpl);
private static WorkflowIO wfIOs = new
WorkflowIO(ModelCreator.datamodelImpl);
- private static WorkflowLogs wfLogs = new
WorkflowLogs(ModelCreator.datamodelImpl);
+ private static WorkflowLogs wfLogs = new WorkflowLogs(
+ ModelCreator.datamodelImpl);

- /**
- * echo service, which can be used to check to connection with MetCat
API
- * @param aString - any String
- * @return JSON Object string with a KEY "OK" and value with aString
- * @throws JSONException
- */
+ /**
+ * echo service, which can be used to check to connection with MetCat API
+ *
+ * @param aString
+ * - any String
+ * @return JSON Object string with a KEY "OK" and value with aString
+ * @throws JSONException
+ */
public String echoService(String aString) throws JSONException {
- JSONObject json = new JSONObject();
- json.put("OK", aString);
+ JSONObject json = new JSONObject();
+ json.put("OK", aString);
return json.toString();
}

- /**
- * Returns All workflows , which started between T1 and T2 timestamp
- * @param t1 Start timestamp
- * @param t2 End timestamp
- * @param showLatest which indicated get data from Last (Latest) or
from First (Old)
- * @param noRows size of the results
- * @return JSON Array String which contains JSON objects with values
TIMESTAMP (started), WORKFLOWID
- */
+ /**
+ * Returns All workflows , which started between T1 and T2 timestamp
+ *
+ * @param t1
+ * Start timestamp
+ * @param t2
+ * End timestamp
+ * @param showLatest
+ * which indicated get data from Last (Latest) or from First
+ * (Old)
+ * @param noRows
+ * size of the results
+ * @return JSON Array String which contains JSON objects with values
+ * TIMESTAMP (started), WORKFLOWID
+ */
public String searchWorkflowByTimeSpan(String t1, String t2,
String showLatest, int noRows) {
JSONArray array = new JSONArray();
Map<String, String> map = new LinkedHashMap<String, String>();
- JSONObject json;
- try {
- int dataCount =
wfIterator.CountColumnsInSingleRow("workflows", t1, t2);
- json = new JSONObject();
- json.put("TOTAL-RESULTS-FOUND", dataCount);
- array.put(json);
- } catch (Exception e) {
- e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }
- boolean isLatest = "last".equalsIgnoreCase(showLatest) ? true :
false;
+ JSONObject json;
+ try {
+ int dataCount = wfIterator.CountColumnsInSingleRow("workflows", t1,
+ t2);
+ json = new JSONObject();
+ json.put("TOTAL-RESULTS-FOUND", dataCount);
+ array.put(json);
+ } catch (Exception e) {
+ e.printStackTrace(); // To change body of catch statement use File |
+ // Settings | File Templates.
+ }
+ boolean isLatest = "last".equalsIgnoreCase(showLatest) ? true : false;
try {
map = wfIterator.getWorkflowAndTimestampForADurationWithPagination(
"workflows", t1, t2, noRows, !isLatest);
@@ -94,7 +107,9 @@
for (String key : map.keySet()) {
try {
json = new JSONObject();
- json.put("TIMESTAMP", key.split("_")[0]); // To avoid random number
part ( ex: _XXXX )
+ json.put("TIMESTAMP", key.split("_")[0]); // To avoid random
+ // number part ( ex:
+ // _XXXX )
json.put("WORKFLOWID", map.get(key));
array.put(json);
} catch (Exception e) {
@@ -104,13 +119,19 @@
return array.toString();
}

- /**
- * Returns All workflows currently in a given state. Valid states are
{active , initialized, paused, terminated, running ,failed}
- * @param state
- * @param showLatest which indicated get data from Last (Latest) or
from First (Old)
- * @param noRows size of the results
- * @return JSON Array String which contains JSON objects with values
TIMESTAMP (last update), WORKFLOWID
- */
+ /**
+ * Returns All workflows currently in a given state. Valid states are
+ * {active , initialized, paused, terminated, running ,failed}
+ *
+ * @param state
+ * @param showLatest
+ * which indicated get data from Last (Latest) or from First
+ * (Old)
+ * @param noRows
+ * size of the results
+ * @return JSON Array String which contains JSON objects with values
+ * TIMESTAMP (last update), WORKFLOWID
+ */
public String searchWorkflowByState(String state, String showLatest,
int noRows) {
Map<String, String> map = new LinkedHashMap<String, String>();
@@ -131,18 +152,20 @@
} else { // No Mapping
return "";
}
- JSONObject json;
- try {
- int dataCount = wfStatus.CountColumnsInSingleRow(stateEnum);
- json = new JSONObject();
- json.put("TOTAL-RESULTS-FOUND", dataCount);
- array.put(json);
- } catch (Exception e) {
- e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }
- boolean isLatest = "last".equalsIgnoreCase(showLatest) ? true :
false;
+ JSONObject json;
try {
- map =
wfStatus.getAllWorkflowsByStatusWithPagination(stateEnum,noRows,isLatest);
+ int dataCount = wfStatus.CountColumnsInSingleRow(stateEnum);
+ json = new JSONObject();
+ json.put("TOTAL-RESULTS-FOUND", dataCount);
+ array.put(json);
+ } catch (Exception e) {
+ e.printStackTrace(); // To change body of catch statement use File |
+ // Settings | File Templates.
+ }
+ boolean isLatest = "last".equalsIgnoreCase(showLatest) ? true : false;
+ try {
+ map = wfStatus.getAllWorkflowsByStatusWithPagination(stateEnum,
+ noRows, isLatest);
} catch (Exception e) {
e.printStackTrace();
}
@@ -159,31 +182,33 @@
return array.toString();
}

- /**
- * Returns All workflow summary details for a give ID..
- * @param workflowID
- * @return JSON Array String which contains JSON objects with values
- */
+ /**
+ * Returns All workflow summary details for a give ID..
+ *
+ * @param workflowID
+ * @return JSON Array String which contains JSON objects with values
+ */
public String getWorkflowSummary(String workflowID) {
Map<String, String> map = new LinkedHashMap<String, String>();
JSONArray array = new JSONArray();
- JSONObject json;
- try {
- String input = wfIOs.getWorkflowInputs(workflowID);
- String[] values = input.split(":_DELIMITER_:");
- json = new JSONObject();
- json.put("Workflow Input", values[0]);
- array.put(json);
+ JSONObject json;
+ try {
+ String input = wfIOs.getWorkflowInputs(workflowID);
+ String[] values = input.split(":_DELIMITER_:");
+ json = new JSONObject();
+ json.put("Workflow Input", values[0]);
+ array.put(json);

- String output = wfIOs.getWorkflowOutputs(workflowID);
- values = output.split(":_DELIMITER_:");
- json = new JSONObject();
- json.put("Workflow Output", values[0]);
- array.put(json);
- } catch (Exception e) {
- e.printStackTrace(); //To change body of catch statement use
File | Settings | File Templates.
- }
- try {
+ String output = wfIOs.getWorkflowOutputs(workflowID);
+ values = output.split(":_DELIMITER_:");
+ json = new JSONObject();
+ json.put("Workflow Output", values[0]);
+ array.put(json);
+ } catch (Exception e) {
+ e.printStackTrace(); // To change body of catch statement use File |
+ // Settings | File Templates.
+ }
+ try {
map = wfSummary.getWorkflowSummary(workflowID);
} catch (Exception e) {
e.printStackTrace();
@@ -201,11 +226,14 @@
return array.toString();
}

- /**
- * Returns workflow Progress for a give ID. Events list are sorted by
Timestamp
- * @param workflowID
- * @return JSON Array String which contains JSON objects with values
TIMESTAMP, EVENT, SERVICEID
- */
+ /**
+ * Returns workflow Progress for a give ID. Events list are sorted by
+ * Timestamp
+ *
+ * @param workflowID
+ * @return JSON Array String which contains JSON objects with values
+ * TIMESTAMP, EVENT, SERVICEID
+ */
public String getWorkflowProgress(String workflowID) {
Map<String, String> map = new LinkedHashMap<String, String>();
try {
@@ -233,11 +261,14 @@
return array.toString();
}

- /**
- * Return all workflow events data (Raw XML) for a given ID. Events
are not ordered.
- * @param workflowID
- * @return JSON Array String which contains JSON objects with values
EVENT, SERVICEID , TIMESTAMP XML
- */
+ /**
+ * Return all workflow events data (Raw XML) for a given ID. Events are
not
+ * ordered.
+ *
+ * @param workflowID
+ * @return JSON Array String which contains JSON objects with values
EVENT,
+ * SERVICEID , TIMESTAMP XML
+ */
public String getWorkflowEvents(String workflowID) {
Map<String, String> map = new LinkedHashMap<String, String>();
try {
@@ -251,7 +282,7 @@
for (String key : map.keySet()) {
try {
json = new JSONObject();
- vals = key.split("::");
+ vals = key.split("::");
json.put("EVENT", vals[0]);
json.put("SERVICEID", vals[1]);
json.put("TIMESTAMP", vals[2]);
@@ -263,12 +294,15 @@
}
return array.toString();
}
-
+
/**
- * Gets a set of produced/changed data products associated with a given
workflow.
+ * Gets a set of produced/changed data products associated with a given
+ * workflow.
*
- * @param workflowID workflow identification
- * @return JSON Array String which contains JSON objects with values
DATAPRODUCT and TIMESTAMP
+ * @param workflowID
+ * workflow identification
+ * @return JSON Array String which contains JSON objects with values
+ * DATAPRODUCT and TIMESTAMP
*/
public String getChangedDataProductsForWorkflow(String workflowID) {
Map<String, String> map = new LinkedHashMap<String, String>();
@@ -291,12 +325,14 @@
}
return array.toString();
}
-
+
/**
* Gets a set of consumed data products associated with a given workflow.
*
- * @param workflowID workflow identification
- * @return JSON Array String which contains JSON objects with values
DATAPRODUCT and TIMESTAMP
+ * @param workflowID
+ * workflow identification
+ * @return JSON Array String which contains JSON objects with values
+ * DATAPRODUCT and TIMESTAMP
*/
public String getConsumedDataProductsForWorkflow(String workflowID) {
Map<String, String> map = new LinkedHashMap<String, String>();
@@ -319,12 +355,14 @@
}
return array.toString();
}
-
+
/**
* Gets a set of workflows which has been consumed the given data product.
*
- * @param dataProduct data product identification
- * @return JSON Array String which contains JSON objects with values
WORKFLOWID and TIMESTAMP
+ * @param dataProduct
+ * data product identification
+ * @return JSON Array String which contains JSON objects with values
+ * WORKFLOWID and TIMESTAMP
*/
public String getConsumedWorkflowsForDataProduct(String dataProduct) {
Map<String, String> map = new LinkedHashMap<String, String>();
@@ -343,18 +381,20 @@
json.put("WORKFLOWID", map.get(key));
json.put("TIMESTAMP", vals[0]);
array.put(json);
- } catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
return array.toString();
}
-
- /**
- * Returns all Input data with its Node ID.
- * @param workflowID
- * @return JSON Array String which contains JSON objects with values
NODEID, TIMESTAMP , DESCRIPTION, XML
- */
+
+ /**
+ * Returns all Input data with its Node ID.
+ *
+ * @param workflowID
+ * @return JSON Array String which contains JSON objects with values
NODEID,
+ * TIMESTAMP , DESCRIPTION, XML
+ */
public String getNodesWithInputValues(String workflowID) {
Map<String, String> map = new LinkedHashMap<String, String>();
try {
@@ -383,12 +423,13 @@
return array.toString();
}

- /**
- * Returns all Output data with its Node ID.
- *
- * @param workflowID
- * @return JSON Array String which contains JSON objects with values
NODEID, TIMESTAMP , DESCRIPTION, XML
- */
+ /**
+ * Returns all Output data with its Node ID.
+ *
+ * @param workflowID
+ * @return JSON Array String which contains JSON objects with values
NODEID,
+ * TIMESTAMP , DESCRIPTION, XML
+ */
public String getNodesWithOutputValues(String workflowID) {
Map<String, String> map = new LinkedHashMap<String, String>();
try {
@@ -417,15 +458,14 @@
return array.toString();
}

- /**
- * Gets all log records for a given workflow or a experiment.
- *
- * @param workflowID
- * @return
- */
- public String getLogsForAWorkflow(String workflowID)
- {
- Map<String, String> map = new LinkedHashMap<String, String>();
+ /**
+ * Gets all log records for a given workflow or a experiment.
+ *
+ * @param Workflow ID
+ * @return Logs and timestamps in json array
+ */
+ public String getLogsForAWorkflow(String workflowID) {
+ Map<String, String> map = new LinkedHashMap<String, String>();
try {
map = wfLogs.getAllLogRecordsFor(workflowID);
} catch (Exception e) {
@@ -436,12 +476,117 @@
for (String key : map.keySet()) {
try {
json = new JSONObject();
- json.put(key,map.get(key));
+ json.put(key, map.get(key));
array.put(json);
} catch (Exception e) {
e.printStackTrace();
}
}
return array.toString();
- }
+ }
+
+ /**
+ * Gets all Workflow IDs for given Workflow Property and Value.
+ *
+ * @param Property
+ * Name
+ * @param Property
+ * Value
+ * @return Json Array String of Workflow IDs
+ */
+ public String getWorkflowIDsOfGivenWorkflowPropertyAndValue(
+ String propertyName, String propertyValue) {
+ List<String> list = new ArrayList<String>();
+ try {
+ list = wfIndex.getWorkflowIDsOfGivenWorkflowPropertyAndValue(
+ propertyName, propertyValue);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ JSONArray array = new JSONArray();
+ for (String value : list) {
+ try {
+ array.put(value);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return array.toString();
+ }
+
+ /**
+ * Gets all Event IDs for given Event Property and Value.
+ *
+ * @param Property
+ * Name
+ * @param Property
+ * Value
+ * @return Json Array String of Event IDs
+ */
+ public String getEventIDsOfGivenEventPropertyAndValue(String propertyName,
+ String propertyValue) {
+ List<String> list = new ArrayList<String>();
+ try {
+ list = wfIndex.getEventIDsOfGivenEventPropertyAndValue(
+ propertyName, propertyValue);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ JSONArray array = new JSONArray();
+ for (String value : list) {
+ try {
+ array.put(value);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return array.toString();
+ }
+
+ /**
+ * Gets all Workflow Properties.
+ *
+ * @return Json Array String of Workflow Property Names
+ */
+ public String getWorkflowPropertyNames() {
+ List<String> list = new ArrayList<String>();
+ try {
+ list = wfIndex.getWorkflowProperties();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ JSONArray array = new JSONArray();
+ for (String value : list) {
+ try {
+ array.put(value);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return array.toString();
+ }
+
+ /**
+ * Gets all Event Properties.
+ *
+ * @return Json Array String of Event Property Names
+ */
+ public String getEventPropertyNames() {
+ List<String> list = new ArrayList<String>();
+ try {
+ list = wfIndex.getEventProperties();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ JSONArray array = new JSONArray();
+ for (String value : list) {
+ try {
+ array.put(value);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return array.toString();
+ }
+
}
Reply all
Reply to author
Forward
0 new messages