Revision: 192
Author:
tobha...@gmail.com
Date: Wed Aug 29 00:42:00 2012
Log: Data product related methods added
http://code.google.com/a/apache-extras.org/p/metcat/source/detail?r=192
Modified:
/trunk/metcatserver/src/main/java/org/apache/airavata/metcat/api/MetCatAPI.java
/trunk/metcatserver/src/main/java/org/apache/airavata/metcat/db/model/DataProductInfo.java
=======================================
---
/trunk/metcatserver/src/main/java/org/apache/airavata/metcat/api/MetCatAPI.java
Tue Aug 28 23:57:17 2012
+++
/trunk/metcatserver/src/main/java/org/apache/airavata/metcat/api/MetCatAPI.java
Wed Aug 29 00:42:00 2012
@@ -52,6 +52,8 @@
private static WorkflowIO wfIOs = new
WorkflowIO(ModelCreator.datamodelImpl);
private static WorkflowLogs wfLogs = new WorkflowLogs(
ModelCreator.datamodelImpl);
+ private static DataProductInfo dpInfo = new DataProductInfo(
+ ModelCreator.datamodelImpl);
/**
* echo service, which can be used to check to connection with MetCat API
@@ -325,6 +327,132 @@
}
return array.toString();
}
+
+ /**
+ * Gets a set of data product properties and their values.
+ *
+ * @param dataProductID
+ * Data Product ID
+ * @return JSON Array String which contains JSON objects with values Data
+ * Product Property and its value
+ */
+ public String getDataProductInfo(String dataProductID) {
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ try {
+ map = dpInfo.getDataProductByID(dataProductID);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ JSONArray array = new JSONArray();
+ JSONObject json;
+ for (String key : map.keySet()) {
+ try {
+ json = new JSONObject();
+ json.put(key, map.get(key));
+ array.put(json);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return array.toString();
+ }
+
+ /**
+ * Gets all consumed data products.
+ *
+ * @return JSON Array String which contains JSON objects with values Data
+ * Product ID, timestamp, experiment ID
+ */
+ public String getAllConsumedDataProducts() {
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ try {
+ map = dpConsumed.getAllConsumedDataProducts();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ JSONArray array = new JSONArray();
+ JSONObject json;
+ String[] vals;
+ for (String key : map.keySet()) {
+ try {
+ json = new JSONObject();
+ json.put("DATAPRODUCTID", key);
+
+ vals = (map.get(key)).split(";");
+ json.put("TIMESTAMP", vals[0]);
+ json.put("EXPERIMENTID", vals[1]);
+ array.put(json);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return array.toString();
+ }
+
+ /**
+ * Get workflow Ids of which used a given workflow in the given time range
+ *
+ * @param Data
+ * Product ID
+ * @param Start
+ * Time
+ * @param End
+ * Time
+ * @return Json String of Workflow ID list
+ */
+ public String getWorkflowsConsumedIn(String dataProductID,
+ String startTime, String endTime) {
+ List<String> list = new ArrayList<String>();
+ try {
+ list = dpConsumed.getWorkflowsConsumedIn(dataProductID, startTime,
+ endTime);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ JSONArray array = new JSONArray();
+ JSONObject json;
+ for (String workflowID : list) {
+ try {
+ json = new JSONObject();
+ json.put("WORKFLOW_ID", workflowID);
+ array.put(json);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return array.toString();
+ }
+
+ /**
+ * Gets a set of data products that are consumed within a given time
range.
+ *
+ * @param startTime
+ * Starting timestamp
+ * @param endTime
+ * Ending timestamp
+ * @return JSON Array String which Data product IDs
+ */
+ public String getConsumedDataProductWithinATimeRange(String startTime,
+ String endTime) {
+ List<String> list = new ArrayList<String>();
+ try {
+ list = dpConsumed.getConsumedDataProducts(startTime, endTime);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ JSONArray array = new JSONArray();
+ JSONObject json;
+ for (String dpID : list) {
+ try {
+ json = new JSONObject();
+ json.put("DATAPRODUCTID", dpID);
+ array.put(json);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return array.toString();
+ }
/**
* Gets a set of consumed data products associated with a given workflow.
@@ -461,7 +589,8 @@
/**
* Gets all log records for a given workflow or a experiment.
*
- * @param Workflow ID
+ * @param Workflow
+ * ID
* @return Logs and timestamps in json array
*/
public String getLogsForAWorkflow(String workflowID) {
=======================================
---
/trunk/metcatserver/src/main/java/org/apache/airavata/metcat/db/model/DataProductInfo.java
Tue Aug 28 20:34:15 2012
+++
/trunk/metcatserver/src/main/java/org/apache/airavata/metcat/db/model/DataProductInfo.java
Wed Aug 29 00:42:00 2012
@@ -123,5 +123,16 @@
logger.info("Adding " + metadata.size() + " meta-data(s) for data
product [" + dataID + "]");
this.addNewDataProductInfo(mdatarows);
}
+
+ /**
+ * Returns data product properties
+ * @param Data Product ID
+ * @return Map of details of the given data product
+ * @throws Exception
+ */
+ public Map<String,String> getDataProductByID (String dataProductID)
throws Exception
+ {
+ return
this.datamodelImpl.getValuesInSingleRow(ModelConfig.DATAPRODUCT_INFO_COLUMN_FAMILY,dataProductID);
+ }
}