You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2014/02/07 21:17:02 UTC

git commit: returning identifier from add method of registry CPI - AIRAVATA-1006

Updated Branches:
  refs/heads/master 8697b2dff -> 3833de545


returning identifier from add method of registry CPI - AIRAVATA-1006


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/3833de54
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/3833de54
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/3833de54

Branch: refs/heads/master
Commit: 3833de5454b2c1100dc6621fbc529477ced1e662
Parents: 8697b2d
Author: chathuri <ch...@apache.org>
Authored: Fri Feb 7 15:16:57 2014 -0500
Committer: chathuri <ch...@apache.org>
Committed: Fri Feb 7 15:16:57 2014 -0500

----------------------------------------------------------------------
 .../registry/jpa/impl/ExperimentRegistry.java   | 19 ++++++++++----
 .../registry/jpa/impl/RegistryImpl.java         | 26 +++++++++++++++++---
 .../apache/airavata/registry/cpi/Registry.java  |  3 ++-
 3 files changed, 38 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/3833de54/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
index 4028eed..f5ac5db 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java
@@ -37,14 +37,15 @@ import java.util.*;
 
 public class ExperimentRegistry {
     private GatewayRegistry gatewayRegistry;
-    private UserReg userRegistry;
     private final static Logger logger = LoggerFactory.getLogger(ExperimentRegistry.class);
 
-    public void add(BasicMetadata basicMetadata) {
+    public String add(BasicMetadata basicMetadata) {
+        String experimentID = "";
         try {
             gatewayRegistry = new GatewayRegistry();
             GatewayResource gateway = gatewayRegistry.getGateway();
-            ExperimentMetadataResource exBasicData = gateway.createBasicMetada(getExperimentID(basicMetadata.getExperimentName()));
+            experimentID = getExperimentID(basicMetadata.getExperimentName());
+            ExperimentMetadataResource exBasicData = gateway.createBasicMetada(experimentID);
             exBasicData.setExperimentName(basicMetadata.getExperimentName());
             exBasicData.setDescription(basicMetadata.getExperimentDescription());
             exBasicData.setExecutionUser(basicMetadata.getUserName());
@@ -54,6 +55,7 @@ public class ExperimentRegistry {
         } catch (ApplicationSettingsException e) {
             logger.error("Unable to read airavata-server properties", e.getMessage());
         }
+        return experimentID;
     }
 
     public void add(ConfigurationData configurationData, String experimentID) {
@@ -341,7 +343,7 @@ public class ExperimentRegistry {
             gatewayRegistry = new GatewayRegistry();
             GatewayResource gateway = gatewayRegistry.getGateway();
             if (fieldName.equals(Constants.FieldConstants.BasicMetadataConstants.USER_NAME)){
-                userRegistry = new UserReg();
+                UserReg userRegistry = new UserReg();
                 WorkerResource worker = userRegistry.getWorker(gateway.getGatewayName(), (String) value);
                 List<Resource> resources = worker.get(ResourceType.EXPERIMENT_METADATA);
                 for (Resource resource : resources){
@@ -382,7 +384,14 @@ public class ExperimentRegistry {
         return configDataList;
     }
 
-    public Object getValue(DependentDataType dataType, Object identifier, Object field) {
+    public Object getBasicMetaDataValues(String expId, String fieldName) {
+        if (fieldName.equals(Constants.FieldConstants.BasicMetadataConstants.USER_NAME)){
+
+        }
+        return null;
+    }
+
+    public Object getConfigDataValues(String expId, String fieldName) {
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/3833de54/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
index 2e0f40f..ba9f8f4 100644
--- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
+++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/RegistryImpl.java
@@ -37,11 +37,10 @@ public class RegistryImpl implements Registry {
     private final static Logger logger = LoggerFactory.getLogger(RegistryImpl.class);
     ExperimentRegistry experimentRegistry = new ExperimentRegistry();
 
-    public void add(TopLevelDataType dataType, Object newObjectToAdd) {
+    public Object add(TopLevelDataType dataType, Object newObjectToAdd) {
         switch (dataType){
             case EXPERIMENT_BASIC_DATA:
-                experimentRegistry.add((BasicMetadata)newObjectToAdd);
-                break;
+                return experimentRegistry.add((BasicMetadata) newObjectToAdd);
             default:
                 logger.error("Unsupported top level type..", new UnsupportedOperationException());
                 throw new UnsupportedOperationException();
@@ -132,9 +131,28 @@ public class RegistryImpl implements Registry {
         }
     }
 
+    /**
+     * This method is to retrieve a specific value for a given field.
+     * @param dataType Data type is a predefined type which the programmer should choose according to the object he
+     *                 is going to save in to registry
+     * @param identifier Identifier which will uniquely identify the data model. For example, in Experiment_Basic_Type,
+     *                   identifier will be generated experimentID
+     * @param field field that filtering should be done. For example, if we want to execution user for a given
+     *              experiment, field will be "userName"
+     * @return return the value for the specific field where data model is identified by the unique identifier that has
+     *         given
+     */
     @Override
     public Object getValue(DataType dataType, Object identifier, String field) {
-        return null;
+        switch (dataType){
+            case EXPERIMENT_BASIC_DATA:
+                return experimentRegistry.getBasicMetaDataValues((String)identifier, field);
+            case EXPERIMENT_CONFIGURATION_DATA:
+                return experimentRegistry.getConfigDataValues((String) identifier, field);
+            default:
+                logger.error("Unsupported data type...", new UnsupportedOperationException());
+                throw new UnsupportedOperationException();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/airavata/blob/3833de54/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java
index 2222ccc..5e3b5b6 100644
--- a/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java
+++ b/modules/registry/registry-cpi/src/main/java/org/apache/airavata/registry/cpi/Registry.java
@@ -17,8 +17,9 @@ public interface Registry {
      * @param newObjectToAdd Object which contains the fields that need to be saved in to registry. This object is a
      *                       thrift model object. In experiment case this object can be BasicMetadata, ConfigurationData
      *                       etc
+     * @return return the identifier to identify the object
      */
-    public void add(TopLevelDataType dataType, Object newObjectToAdd);
+    public Object add(TopLevelDataType dataType, Object newObjectToAdd);
 
     /**
      * This method is to add an object in to the registry