You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2013/12/26 18:31:40 UTC

svn commit: r1553518 [4/15] - in /airavata/sandbox: orchestrator-service/ orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/ orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/context/ or...

Added: airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java?rev=1553518&view=auto
==============================================================================
--- airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java (added)
+++ airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java Thu Dec 26 17:31:35 2013
@@ -0,0 +1,235 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+
+public abstract class AbstractResource implements Resource {
+    //table names
+    public static final String GATEWAY = "Gateway";
+    public static final String CONFIGURATION = "Configuration";
+    public static final String USERS = "Users";
+    public static final String GATEWAY_WORKER = "Gateway_Worker";
+    public static final String PROJECT = "Project";
+    public static final String PUBLISHED_WORKFLOW = "Published_Workflow";
+    public static final String USER_WORKFLOW = "User_Workflow";
+    public static final String HOST_DESCRIPTOR = "Host_Descriptor";
+    public static final String SERVICE_DESCRIPTOR = "Service_Descriptor";
+    public static final String APPLICATION_DESCRIPTOR = "Application_Descriptor";
+    public static final String EXPERIMENT = "Experiment";
+    public static final String EXPERIMENT_DATA = "Experiment_Data";
+    public static final String WORKFLOW_DATA = "Workflow_Data";
+    public static final String EXPERIMENT_METADATA = "Experiment_Metadata";
+    public static final String EXECUTION_ERROR = "Execution_Error";
+    public static final String GFAC_JOB_DATA = "GFac_Job_Data";
+    public static final String GFAC_JOB_STATUS = "GFac_Job_Status";
+
+    //Gateway Table
+    public final class GatewayConstants {
+        public static final String GATEWAY_NAME = "gateway_name";
+        public static final String GATEWAY_OWNER = "owner";
+    }
+
+    //Configuration Table
+    public final class ConfigurationConstants {
+//        public static final String CONFIG_ID = "config_ID";
+        public static final String CONFIG_KEY = "config_key";
+        public static final String CONFIG_VAL = "config_val";
+        public static final String EXPIRE_DATE = "expire_date";
+        public static final String CATEGORY_ID = "category_id";
+        public static final String CATEGORY_ID_DEFAULT_VALUE = "SYSTEM";
+    }
+
+
+    //Users table
+    public final class UserConstants {
+        public static final String USERNAME = "user_name";
+        public static final String PASSWORD = "password";
+    }
+
+    //Gateway_Worker table
+    public final class GatewayWorkerConstants {
+        public static final String USERNAME = "user_name";
+        public static final String GATEWAY_NAME = "gateway_name";
+    }
+
+    //Project table
+    public final class ProjectConstants {
+        public static final String GATEWAY_NAME = "gateway_name";
+        public static final String USERNAME = "user_name";
+        public static final String PROJECT_NAME = "project_name";
+    }
+
+    //Published_Workflow table
+    public final class PublishedWorkflowConstants {
+        public static final String GATEWAY_NAME = "gateway_name";
+        public static final String CREATED_USER = "created_user";
+        public static final String PUBLISH_WORKFLOW_NAME = "publish_workflow_name";
+        public static final String VERSION = "version";
+        public static final String PUBLISHED_DATE = "published_date";
+        public static final String PATH = "path";
+        public static final String WORKFLOW_CONTENT = "workflow_content";
+    }
+
+    //User_Workflow table
+    public final class UserWorkflowConstants {
+        public static final String GATEWAY_NAME = "gateway_name";
+        public static final String OWNER = "owner";
+        public static final String TEMPLATE_NAME = "template_name";
+        public static final String LAST_UPDATED_DATE = "last_updated_date";
+        public static final String PATH = "path";
+        public static final String WORKFLOW_GRAPH = "workflow_graph";
+    }
+
+    //Host_Descriptor table
+    public final class HostDescriptorConstants {
+        public static final String GATEWAY_NAME = "gateway_name";
+        public static final String UPDATED_USER = "updated_user";
+        public static final String HOST_DESC_ID = "host_descriptor_ID";
+        public static final String HOST_DESC_XML = "host_descriptor_xml";
+    }
+
+    //Service_Descriptor table
+    public final class ServiceDescriptorConstants {
+        public static final String GATEWAY_NAME = "gateway_name";
+        public static final String UPDATED_USER = "updated_user";
+        public static final String SERVICE_DESC_ID = "service_descriptor_ID";
+        public static final String SERVICE_DESC_XML = "service_descriptor_xml";
+    }
+
+    //Application_Descriptor table
+    public final class ApplicationDescriptorConstants {
+        public static final String GATEWAY_NAME = "gateway_name";
+        public static final String UPDATED_USER = "updated_user";
+        public static final String APPLICATION_DESC_ID = "application_descriptor_ID";
+        public static final String HOST_DESC_ID = "host_descriptor_ID";
+        public static final String SERVICE_DESC_ID = "service_descriptor_ID";
+        public static final String APPLICATION_DESC_XML = "application_descriptor_xml";
+    }
+
+    //Experiment table
+    public final class ExperimentConstants {
+        public static final String PROJECT_NAME = "project_name";
+        public static final String USERNAME = "user_name";
+        public static final String GATEWAY_NAME = "gateway_name";
+        public static final String EXPERIMENT_ID = "experiment_ID";
+        public static final String SUBMITTED_DATE = "submitted_date";
+
+    }
+
+    //Experiment_Data table
+    public final class ExperimentDataConstants{
+        public static final String EXPERIMENT_ID="experiment_ID";
+        public static final String NAME = "name";
+        public static final String USERNAME = "username";
+        public static final String METADATA = "metadata";
+    }
+
+    //Workflow_Data table
+    public final class WorkflowDataConstants{
+        public static final String EXPERIMENT_ID="experiment_ID";
+        public static final String WORKFLOW_INSTANCE_ID = "workflow_instanceID";
+        public static final String TEMPLATE_NAME = "template_name";
+        public static final String STATUS = "status";
+        public static final String START_TIME = "start_time";
+        public static final String LAST_UPDATE_TIME = "last_update_time";
+    }
+
+    //Node_Data table
+    public final class NodeDataConstants{
+        public static final String WORKFLOW_INSTANCE_ID = "workflow_instanceID";
+        public static final String NODE_ID = "node_id";
+        public static final String NODE_TYPE = "node_type";
+        public static final String INPUTS = "inputs";
+        public static final String OUTPUTS = "outputs";
+        public static final String STATUS = "status";
+        public static final String START_TIME = "start_time";
+        public static final String LAST_UPDATE_TIME = "last_update_time";
+    }
+
+    //Gram_Data table
+    public final class GramDataConstants{
+        public static final String WORKFLOW_INSTANCE_ID = "workflow_instanceID";
+        public static final String NODE_ID = "node_id";
+        public static final String RSL = "rsl";
+        public static final String INVOKED_HOST = "invoked_host";
+        public static final String LOCAL_JOB_ID = "local_Job_ID";
+    }
+
+    public final class ExecutionErrorConstants {
+        public static final String ERROR_ID = "error_id";
+        public static final String EXPERIMENT_ID = "experiment_ID";
+        public static final String WORKFLOW_ID = "workflow_instanceID";
+        public static final String NODE_ID = "node_id";
+        public static final String GFAC_JOB_ID = "gfacJobID";
+        public static final String SOURCE_TYPE = "source_type";
+        public static final String ERROR_DATE = "error_date";
+        public static final String ERROR_MSG = "error_msg";
+        public static final String ERROR_DES = "error_des";
+        public static final String ERROR_CODE = "error_code";
+    }
+
+    public final class GFacJobDataConstants {
+        public static final String EXPERIMENT_ID = "experiment_ID";
+        public static final String WORKFLOW_INSTANCE_ID = "workflow_instanceID";
+        public static final String NODE_ID = "node_id";
+        public static final String APP_DESC_ID = "application_descriptor_ID";
+        public static final String HOST_DESC_ID = "host_descriptor_ID";
+        public static final String SERVICE_DESC_ID = "service_descriptor_ID";
+        public static final String JOB_DATA = "job_data";
+        public static final String LOCAL_JOB_ID = "local_Job_ID";
+        public static final String SUBMITTED_TIME = "submitted_time";
+        public static final String STATUS_UPDATE_TIME = "status_update_time";
+        public static final String STATUS = "status";
+        public static final String METADATA = "metadata";
+    }
+
+    public final class GFacJobStatusConstants {
+        public static final String LOCAL_JOB_ID = "local_Job_ID";
+        public static final String STATUS = "status";
+        public static final String STATUS_UPDATE_TIME = "status_update_time";
+    }
+
+    protected AbstractResource() {
+    }
+
+    public boolean isExists(ResourceType type, Object name) {
+        try {
+            return get(type, name) != null;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+	public static <T> List<T> getResourceList(List<Resource> resources, Class<?> T){
+    	List<T> list=new ArrayList<T>();
+    	for (Resource o : resources) {
+    		list.add((T) o);
+		}
+    	return list;
+    }
+
+}

Added: airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AiravataRegistryConnectionDataProviderImpl.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AiravataRegistryConnectionDataProviderImpl.java?rev=1553518&view=auto
==============================================================================
--- airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AiravataRegistryConnectionDataProviderImpl.java (added)
+++ airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AiravataRegistryConnectionDataProviderImpl.java Thu Dec 26 17:31:35 2013
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import org.apache.airavata.registry.api.AiravataRegistryConnectionDataProvider;
+import org.apache.airavata.registry.api.AiravataUser;
+import org.apache.airavata.registry.api.Gateway;
+import org.apache.airavata.registry.api.exception.RegistrySettingsException;
+import org.apache.airavata.registry.api.exception.UnknownRegistryConnectionDataException;
+import org.apache.airavata.registry.api.util.RegistrySettings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+public class AiravataRegistryConnectionDataProviderImpl implements AiravataRegistryConnectionDataProvider {
+
+    private final static Logger logger = LoggerFactory.getLogger(AiravataRegistryConnectionDataProviderImpl.class);
+
+    public void setIdentity(Gateway gateway, AiravataUser use) {
+    }
+
+    public Object getValue(String key) throws RegistrySettingsException {
+        return RegistrySettings.getSetting(key);
+    }
+}

Added: airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java?rev=1553518&view=auto
==============================================================================
--- airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java (added)
+++ airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java Thu Dec 26 17:31:35 2013
@@ -0,0 +1,296 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
+import org.apache.airavata.persistance.registry.jpa.model.*;
+import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ApplicationDescriptorResource extends AbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(ApplicationDescriptorResource.class);
+    private String name;
+    private String gatewayName;
+    private String updatedUser;
+    private String content;
+    private String hostDescName;
+    private String serviceDescName;
+
+    /**
+     *
+     * @param name application descriptor name
+     * @param gatewayName  gateway name
+     * returns ApplicationDescriptorResource
+     */
+    public ApplicationDescriptorResource(String name, String gatewayName) {
+        this.setName(name);
+        this.gatewayName = gatewayName;
+    }
+
+    /**
+     *
+     */
+    public ApplicationDescriptorResource() {
+    }
+
+    /**
+     *
+     * @return gateway name
+     */
+    public String getGatewayName() {
+        return gatewayName;
+    }
+
+    /**
+     *
+     * @param gatewayName gateway name
+     */
+    public void setGatewayName(String gatewayName) {
+        this.gatewayName = gatewayName;
+    }
+
+    /**
+     *
+     * @param updatedUser updated user
+     */
+    public void setUpdatedUser(String updatedUser) {
+        this.updatedUser = updatedUser;
+    }
+
+    /**
+     *
+     * @return name of the application descriptor
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     *
+     * @return content
+     */
+    public String getContent() {
+        return content;
+    }
+
+    /**
+     *
+     * @return  host descriptor name
+     */
+    public String getHostDescName() {
+        return hostDescName;
+    }
+
+    /**
+     *
+     * @return service descriptor name
+     */
+    public String getServiceDescName() {
+        return serviceDescName;
+    }
+
+    /**
+     *
+     * @param content content of the application descriptor
+     */
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    /**
+     *
+     * @param hostDescName host descriptor name
+     */
+    public void setHostDescName(String hostDescName) {
+        this.hostDescName = hostDescName;
+    }
+
+    /**
+     *
+     * @param serviceDescName  service descriptor name
+     */
+    public void setServiceDescName(String serviceDescName) {
+        this.serviceDescName = serviceDescName;
+    }
+
+    /**
+     * Since application descriptors are at the leaf level, this method is not
+     * valid for application descriptors
+     * @param type  child resource types
+     * @return UnsupportedOperationException
+     */
+    public Resource create(ResourceType type) {
+        logger.error("Unsupported operation for application descriptor resource " +
+                "since application descriptors could not create child resources.. ", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Since application descriptors are at the leaf level, this method is not
+     * valid for application descriptors
+     * @param type child resource types
+     * @param name name of the resource
+     */
+    public void remove(ResourceType type, Object name) {
+        logger.error("Unsupported operation for application descriptor resource " +
+                "since application descriptors could not remove child resources.. ", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * key should be gateway_name, application_descriptor_ID, host_descriptor_ID, service_descriptor_ID
+     *
+     * @param keys primary keys of the Application_descriptor table
+     */
+//    public void removeMe(Object[] keys) {
+//        EntityManager em = ResourceUtils.getEntityManager();
+//        em.getTransaction().begin();
+//        QueryGenerator queryGenerator = new QueryGenerator(APPLICATION_DESCRIPTOR);
+//        queryGenerator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, keys[0]);
+//        queryGenerator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, keys[1]);
+//        queryGenerator.setParameter(ApplicationDescriptorConstants.HOST_DESC_ID, keys[2]);
+//        queryGenerator.setParameter(ApplicationDescriptorConstants.SERVICE_DESC_ID, keys[3]);
+//        Query q = queryGenerator.deleteQuery(em);
+//        q.executeUpdate();
+//        em.getTransaction().commit();
+//        em.close();
+//    }
+
+    /**
+     *
+     * Since application descriptors are at the leaf level, this method is not
+     * valid for application descriptors
+     * @param type child resource types
+     * @param name name of the resource
+     * @return UnsupportedOperationException
+     */
+    public Resource get(ResourceType type, Object name) {
+        logger.error("Unsupported operation for application descriptor resource " +
+                "since there are no child resources generated by application descriptors.. ", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * keys should contain gateway_name, application_descriptor_ID, host_descriptor_ID, service_descriptor_ID
+     *
+     * @param keys names
+     * @return list of ApplicationDescriptorResources
+     */
+    public List<Resource> populate(Object[] keys) {
+        List<Resource> list = new ArrayList<Resource>();
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        QueryGenerator queryGenerator = new QueryGenerator(APPLICATION_DESCRIPTOR);
+        queryGenerator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, keys[0]);
+        queryGenerator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, keys[1]);
+        queryGenerator.setParameter(ApplicationDescriptorConstants.HOST_DESC_ID, keys[2]);
+        queryGenerator.setParameter(ApplicationDescriptorConstants.SERVICE_DESC_ID, keys[3]);
+        Query q = queryGenerator.selectQuery(em);
+        Application_Descriptor applicationDescriptor = (Application_Descriptor) q.getSingleResult();
+        ApplicationDescriptorResource applicationDescriptorResource =
+                (ApplicationDescriptorResource) Utils.getResource(
+                        ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
+        em.getTransaction().commit();
+        em.close();
+        list.add(applicationDescriptorResource);
+        return list;
+    }
+
+    /**
+     * Since application descriptors are at the leaf level, this method is not
+     * valid for application descriptors
+     * @param type child resource types
+     * @return UnsupportedOperationException
+     */
+    public List<Resource> get(ResourceType type) {
+        logger.error("Unsupported operation for application descriptor resource " +
+                "since there are no child resources generated by application descriptors.. ", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     *  save application descriptor to database
+     */
+    public void save() {
+        try{
+            EntityManager em = ResourceUtils.getEntityManager();
+            Application_Descriptor existingAppDesc = em.find(Application_Descriptor.class, new Application_Descriptor_PK(gatewayName, name));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Application_Descriptor applicationDescriptor = new Application_Descriptor();
+            applicationDescriptor.setApplication_descriptor_ID(getName());
+
+            Gateway gateway = em.find(Gateway.class, gatewayName);
+            Users user = em.find(Users.class, updatedUser);
+            applicationDescriptor.setGateway(gateway);
+            applicationDescriptor.setUser(user);
+            byte[] contentBytes = content.getBytes();
+            applicationDescriptor.setApplication_descriptor_xml(contentBytes);
+            applicationDescriptor.setService_descriptor_ID(serviceDescName);
+            applicationDescriptor.setHost_descriptor_ID(hostDescName);
+            if (existingAppDesc != null) {
+                existingAppDesc.setUser(user);
+                existingAppDesc.setApplication_descriptor_xml(contentBytes);
+                existingAppDesc.setHost_descriptor_ID(hostDescName);
+                existingAppDesc.setService_descriptor_ID(serviceDescName);
+                applicationDescriptor = em.merge(existingAppDesc);
+            } else {
+                em.persist(applicationDescriptor);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e){
+            e.printStackTrace();
+        }
+
+    }
+
+    /**
+     * Since application descriptors are at the leaf level, this method is not
+     * valid for application descriptors
+     * @param type child resource types
+     * @param name name of the resource
+     * @return UnsupportedOperationException
+     */
+    public boolean isExists(ResourceType type, Object name) {
+        logger.error("Unsupported operation for application descriptor resource " +
+                "since there are no child resources generated by application descriptors.. ", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     *
+     * @param name application descriptor name
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+}

Added: airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java?rev=1553518&view=auto
==============================================================================
--- airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java (added)
+++ airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java Thu Dec 26 17:31:35 2013
@@ -0,0 +1,231 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.locks.Lock;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
+import org.apache.airavata.persistance.registry.jpa.model.Configuration;
+import org.apache.airavata.persistance.registry.jpa.model.Configuration_PK;
+import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConfigurationResource extends AbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(ConfigurationResource.class);
+    private String configKey;
+    private String configVal;
+    private Timestamp expireDate;
+    private String categoryID = ConfigurationConstants.CATEGORY_ID_DEFAULT_VALUE;
+
+    public ConfigurationResource() {
+    }
+
+    /**
+     *
+     * @param configKey configuration key
+     * @param configVal configuration value
+     */
+    public ConfigurationResource(String configKey, String configVal) {
+        this.configKey = configKey;
+        this.configVal = configVal;
+    }
+
+    /**
+     * Since Configuration does not depend on any other data structures at the
+     * system, this method is not valid
+     * @param type child resource types
+     * @return UnsupportedOperationException
+     */
+    public Resource create(ResourceType type) {
+        logger.error("Unsupported operation for configuration resource " +
+                "since there are no child resources generated by configuration resource.. ",
+                new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Since Configuration does not depend on any other data structures at the
+     * system, this method is not valid
+     * @param type child resource types
+     * @param name  name of the child resource
+     * throws UnsupportedOperationException
+     */
+    public void remove(ResourceType type, Object name) {
+        logger.error("Unsupported operation for configuration resource " +
+                "since there are no child resources generated by configuration resource.. ",
+                new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+
+    /**
+     * Since Configuration does not depend on any other data structures at the
+     * system, this method is not valid
+     * @param type child resource types
+     * @param name  name of the child resource
+     * @return UnsupportedOperationException
+     */
+    public Resource get(ResourceType type, Object name) {
+        logger.error("Unsupported operation for configuration resource " +
+                "since there are no child resources generated by configuration resource.. ",
+                new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * key should be the configuration name
+     * @param keys names
+     * @return list of ConfigurationResources
+     */
+    public List<Resource> populate(Object[] keys) {
+        List<Resource> list = new ArrayList<Resource>();
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        QueryGenerator queryGenerator = new QueryGenerator(CONFIGURATION);
+        queryGenerator.setParameter(ConfigurationConstants.CONFIG_KEY, keys[0]);
+        Query q = queryGenerator.selectQuery(em);
+        List resultList = q.getResultList();
+        if (resultList.size() != 0) {
+            for (Object result : resultList) {
+                Configuration configuration = (Configuration) result;
+                ConfigurationResource configurationResource =
+                        (ConfigurationResource)Utils.getResource(ResourceType.CONFIGURATION, configuration);
+                list.add(configurationResource);
+            }
+        }
+        em.getTransaction().commit();
+        em.close();
+        return list;
+
+    }
+
+    /**
+     *
+     * Since Configuration does not depend on any other data structures at the
+     * system, this method is not valid
+     * @param type child resource types
+     * @return UnsupportedOperationException
+     */
+    public List<Resource> get(ResourceType type) {
+        logger.error("Unsupported operation for configuration resource " +
+                "since there are no child resources generated by configuration resource.. ",
+                new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     *
+     * @param expireDate expire date of the configuration
+     */
+    public void setExpireDate(Timestamp expireDate) {
+        this.expireDate = expireDate;
+    }
+
+    /**
+     *  save configuration to database
+     */
+    public synchronized void save() {
+        Lock lock = ResourceUtils.getLock();
+        lock.lock();
+        try {
+            EntityManager em = ResourceUtils.getEntityManager();
+            //whether existing
+            Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, categoryID));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Configuration configuration = new Configuration();
+            configuration.setConfig_key(configKey);
+            configuration.setConfig_val(configVal);
+            configuration.setExpire_date(expireDate);
+            configuration.setCategory_id(categoryID);
+            if (existing != null) {
+                existing.setExpire_date(expireDate);
+                existing.setCategory_id(categoryID);
+                configuration = em.merge(existing);
+            } else {
+                em.merge(configuration);
+            }
+
+            em.getTransaction().commit();
+            em.close();
+        }
+        finally {
+            lock.unlock();
+        }
+    }
+
+    /**
+     * Since Configuration does not depend on any other data structures at the
+     * system, this method is not valid
+     * @param type child resource types
+     * @param name of the child resource
+     * @return UnsupportedOperationException
+     */
+    public boolean isExists(ResourceType type, Object name) {
+        logger.error("Unsupported operation for configuration resource " +
+                "since there are no child resources generated by configuration resource.. ",
+                new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     *
+     * @return configuration value
+     */
+    public String getConfigVal() {
+        return configVal;
+    }
+
+    /**
+     *
+     * @param configKey configuration key
+     */
+    public void setConfigKey(String configKey) {
+        this.configKey = configKey;
+    }
+
+    /**
+     *
+     * @param configVal configuration value
+     */
+    public void setConfigVal(String configVal) {
+        this.configVal = configVal;
+    }
+
+    public String getCategoryID() {
+        return categoryID;
+    }
+
+    public void setCategoryID(String categoryID) {
+        this.categoryID = categoryID;
+    }
+}

Added: airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DBC.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DBC.java?rev=1553518&view=auto
==============================================================================
--- airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DBC.java (added)
+++ airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DBC.java Thu Dec 26 17:31:35 2013
@@ -0,0 +1,66 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+public class DBC {
+    public static final class ExperimentData{
+    	public static final String TABLE="Experiment_Data";
+        public static final String EXPERIMENT_ID = "experiment_ID";
+        public static final String EXPERIMENT_NAME = "name";
+        public static final String USER_NAME = "username";
+    }
+    
+    public static final class ExperimentMetadata{
+    	public static final String TABLE="Experiment_Metadata";
+        public static final String EXPERIMENT_ID = "experiment_ID";
+        public static final String METADATA = "metadata";
+    }
+    
+    public static final class WorkflowData {
+    	public static final String TABLE="Workflow_Data";
+        public static final String EXPERIMENT_ID = "experiment_ID";
+        public static final String INSTANCE_ID = "workflow_instanceID";
+        public static final String TEMPLATE_NAME = "template_name";
+        public static final String STATUS = "status";
+        public static final String START_TIME = "start_time";
+        public static final String LAST_UPDATED = "last_update_time";
+    }
+    public static final class NodeData {
+    	public static final String TABLE="Node_Data";
+        public static final String WORKFLOW_INSTANCE_ID = "workflow_instanceID";
+        public static final String NODE_ID = "node_id";
+        public static final String TYPE = "node_type";
+        public static final String INPUTS = "inputs";
+        public static final String OUTPUTS = "outputs";
+        public static final String STATUS = "status";
+        public static final String START_TIME = "start_time";
+        public static final String LAST_UPDATED = "last_update_time";
+    }
+    public static final class GramData {
+    	public static final String TABLE="Gram_Data";
+        public static final String WORKFLOW_INSTANCE_ID = "workflow_instanceID";
+        public static final String NODE_ID = "node_id";
+        public static final String RSL = "rsl";
+        public static final String INVOKED_HOST = "invoked_host";
+    }
+    
+}

Added: airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExecutionErrorResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExecutionErrorResource.java?rev=1553518&view=auto
==============================================================================
--- airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExecutionErrorResource.java (added)
+++ airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExecutionErrorResource.java Thu Dec 26 17:31:35 2013
@@ -0,0 +1,217 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
+import org.apache.airavata.persistance.registry.jpa.model.Execution_Error;
+import org.apache.airavata.persistance.registry.jpa.model.Experiment_Data;
+import org.apache.airavata.persistance.registry.jpa.model.Workflow_Data;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ExecutionErrorResource extends AbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(ExecutionErrorResource.class);
+    private ExperimentDataResource experimentDataResource;
+    private WorkflowDataResource workflowDataResource;
+    private String nodeID;
+    private String gfacJobID;
+    private String sourceType;
+    private Timestamp errorTime;
+    private String errorMsg;
+    private String errorDes;
+    private String errorCode;
+    private int errorID;
+    private String errorReporter;
+    private String errorLocation;
+    private String actionTaken;
+    private int errorReference;
+
+    @Override
+    public Resource create(ResourceType type) {
+        logger.error("Unsupported resource type for node error resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void remove(ResourceType type, Object name) {
+        logger.error("Unsupported resource type for node error resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public Resource get(ResourceType type, Object name) {
+        logger.error("Unsupported resource type for node error resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public List<Resource> get(ResourceType type) {
+        logger.error("Unsupported resource type for node error resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void save() {
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+
+        Execution_Error execution_error = new Execution_Error();
+        execution_error.setNode_id(nodeID);
+        Experiment_Data experiment_data = em.find(Experiment_Data.class, experimentDataResource.getExperimentID());
+        execution_error.setExperiment_data(experiment_data);
+        Workflow_Data workflow_data = em.find(Workflow_Data.class, workflowDataResource.getWorkflowInstanceID());
+        execution_error.setExperiment_ID(experiment_data.getExperiment_ID());
+        execution_error.setWorkflow_Data(workflow_data);
+        execution_error.setWorkflow_instanceID(workflow_data.getWorkflow_instanceID());
+        execution_error.setError_code(errorCode);
+        execution_error.setError_date(errorTime);
+        execution_error.setError_des(errorDes);
+        execution_error.setError_msg(errorMsg);
+        execution_error.setSource_type(sourceType);
+        execution_error.setGfacJobID(gfacJobID);
+        em.persist(execution_error);
+        errorID = execution_error.getError_id();
+        // System.out.println("Error ID : " + errorID);
+        em.getTransaction().commit();
+        em.close();
+
+    }
+
+    public ExperimentDataResource getExperimentDataResource() {
+        return experimentDataResource;
+    }
+
+    public WorkflowDataResource getWorkflowDataResource() {
+        return workflowDataResource;
+    }
+
+    public String getNodeID() {
+        return nodeID;
+    }
+
+    public String getGfacJobID() {
+        return gfacJobID;
+    }
+
+    public String getSourceType() {
+        return sourceType;
+    }
+
+    public Timestamp getErrorTime() {
+        return errorTime;
+    }
+
+    public String getErrorMsg() {
+        return errorMsg;
+    }
+
+    public String getErrorDes() {
+        return errorDes;
+    }
+
+    public String getErrorCode() {
+        return errorCode;
+    }
+
+    public void setExperimentDataResource(ExperimentDataResource experimentDataResource) {
+        this.experimentDataResource = experimentDataResource;
+    }
+
+    public void setWorkflowDataResource(WorkflowDataResource workflowDataResource) {
+        this.workflowDataResource = workflowDataResource;
+    }
+
+    public void setNodeID(String nodeID) {
+        this.nodeID = nodeID;
+    }
+
+    public void setGfacJobID(String gfacJobID) {
+        this.gfacJobID = gfacJobID;
+    }
+
+    public void setSourceType(String sourceType) {
+        this.sourceType = sourceType;
+    }
+
+    public void setErrorTime(Timestamp errorTime) {
+        this.errorTime = errorTime;
+    }
+
+    public void setErrorMsg(String errorMsg) {
+        this.errorMsg = errorMsg;
+    }
+
+    public void setErrorDes(String errorDes) {
+        this.errorDes = errorDes;
+    }
+
+    public void setErrorCode(String errorCode) {
+        this.errorCode = errorCode;
+    }
+
+    public int getErrorID() {
+        return errorID;
+    }
+
+    public void setErrorID(int errorID) {
+        this.errorID = errorID;
+    }
+
+    public String getErrorReporter() {
+        return errorReporter;
+    }
+
+    public String getErrorLocation() {
+        return errorLocation;
+    }
+
+    public String getActionTaken() {
+        return actionTaken;
+    }
+
+    public void setErrorReporter(String errorReporter) {
+        this.errorReporter = errorReporter;
+    }
+
+    public void setErrorLocation(String errorLocation) {
+        this.errorLocation = errorLocation;
+    }
+
+    public void setActionTaken(String actionTaken) {
+        this.actionTaken = actionTaken;
+    }
+
+    public int getErrorReference() {
+        return errorReference;
+    }
+
+    public void setErrorReference(int errorReference) {
+        this.errorReference = errorReference;
+    }
+}

Added: airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentDataResource.java
URL: http://svn.apache.org/viewvc/airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentDataResource.java?rev=1553518&view=auto
==============================================================================
--- airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentDataResource.java (added)
+++ airavata/sandbox/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentDataResource.java Thu Dec 26 17:31:35 2013
@@ -0,0 +1,355 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
+import org.apache.airavata.persistance.registry.jpa.model.*;
+import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ExperimentDataResource extends AbstractResource{
+
+    private final static Logger logger = LoggerFactory.getLogger(ExperimentDataResource.class);
+    private String experimentID;
+    private String expName;
+    private String userName;
+
+    public String getExperimentID() {
+        return experimentID;
+    }
+
+    public String getExpName() {
+        return expName;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setExperimentID(String experimentID) {
+        this.experimentID = experimentID;
+    }
+
+    public void setExpName(String expName) {
+        this.expName = expName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public Resource create(ResourceType type) {
+        switch (type){
+            case WORKFLOW_DATA:
+                WorkflowDataResource workflowDataResource = new WorkflowDataResource();
+                workflowDataResource.setExperimentID(experimentID);
+                return workflowDataResource;
+            case EXECUTION_ERROR:
+				ExecutionErrorResource executionErrorResource = new ExecutionErrorResource();
+				executionErrorResource.setExperimentDataResource(this);
+				return executionErrorResource;
+            case EXPERIMENT_METADATA:
+                ExperimentMetadataResource experimentMetadataResource = new ExperimentMetadataResource();
+                experimentMetadataResource.setExpID(experimentID);
+                return experimentMetadataResource;
+            case GFAC_JOB_DATA:
+                GFacJobDataResource gFacJobDataResource = new GFacJobDataResource();
+                gFacJobDataResource.setExperimentDataResource(this);
+                return gFacJobDataResource;
+            default:
+                logger.error("Unsupported resource type for experiment data resource... ", new UnsupportedOperationException());
+                throw new IllegalArgumentException("Unsupported resource type for experiment data resource.");
+        }
+
+    }
+
+    public void remove(ResourceType type, Object name) {
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Query q;
+        QueryGenerator generator;
+        switch (type){
+            case WORKFLOW_DATA:
+                generator = new QueryGenerator(WORKFLOW_DATA);
+//                generator.setParameter(WorkflowDataConstants.EXPERIMENT_ID, experimentID);
+                generator.setParameter(WorkflowDataConstants.WORKFLOW_INSTANCE_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case EXPERIMENT_METADATA:
+                generator = new QueryGenerator(EXPERIMENT_METADATA);
+                generator.setParameter(ExperimentDataConstants.EXPERIMENT_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name);
+                q = generator.deleteQuery(em);
+                q.executeUpdate();
+                break;
+            default:
+                break;
+        }
+        em.getTransaction().commit();
+        em.close();
+    }
+
+    public Resource get(ResourceType type, Object name) {
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        QueryGenerator generator;
+        Query q;
+        switch (type) {
+            case WORKFLOW_DATA:
+                generator = new QueryGenerator(WORKFLOW_DATA);
+//                generator.setParameter(WorkflowDataConstants.EXPERIMENT_ID, experimentID);
+                generator.setParameter(WorkflowDataConstants.WORKFLOW_INSTANCE_ID, name);
+                q = generator.selectQuery(em);
+                Workflow_Data eworkflowData = (Workflow_Data)q.getSingleResult();
+                WorkflowDataResource workflowDataResource = (WorkflowDataResource)Utils.getResource(ResourceType.WORKFLOW_DATA, eworkflowData);
+                em.getTransaction().commit();
+                em.close();
+                return workflowDataResource;
+            case EXPERIMENT_METADATA:
+                generator = new QueryGenerator(EXPERIMENT_METADATA);
+                generator.setParameter(ExperimentDataConstants.EXPERIMENT_ID, name);
+                q = generator.selectQuery(em);
+                Experiment_Metadata expMetadata = (Experiment_Metadata)q.getSingleResult();
+                ExperimentMetadataResource experimentMetadataResource = (ExperimentMetadataResource)Utils.getResource(ResourceType.EXPERIMENT_METADATA, expMetadata);
+                em.getTransaction().commit();
+                em.close();
+                return experimentMetadataResource;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.LOCAL_JOB_ID, name);
+                q = generator.selectQuery(em);
+                GFac_Job_Data gFacJobData = (GFac_Job_Data)q.getSingleResult();
+                GFacJobDataResource gFacJobDataResource = (GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA, gFacJobData);
+                em.getTransaction().commit();
+                em.close();
+                return gFacJobDataResource;
+            default:
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported resource type for experiment data resource... ", new UnsupportedOperationException());
+                throw new IllegalArgumentException("Unsupported resource type for experiment data resource.");
+        }
+    }
+
+    public List<Resource> get(ResourceType type) {
+        List<Resource> resourceList = new ArrayList<Resource>();
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Query q;
+        QueryGenerator generator;
+        List<?> results;
+        switch (type){
+            case WORKFLOW_DATA:
+                generator = new QueryGenerator(WORKFLOW_DATA);
+//                generator.setParameter(WorkflowDataConstants.EXPERIMENT_ID, experimentID);
+                Experiment_Data experiment_data = em.find(Experiment_Data.class, experimentID);
+                generator.setParameter("experiment_data", experiment_data);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        Workflow_Data workflowData = (Workflow_Data) result;
+                        WorkflowDataResource workflowDataResource = (WorkflowDataResource)Utils.getResource(ResourceType.WORKFLOW_DATA, workflowData);
+                        resourceList.add(workflowDataResource);
+                    }
+                }
+                break;
+            case EXPERIMENT_METADATA:
+                generator = new QueryGenerator(EXPERIMENT_METADATA);
+                generator.setParameter(ExperimentDataConstants.EXPERIMENT_ID, experimentID);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        Experiment_Metadata expMetadata = (Experiment_Metadata) result;
+                        ExperimentMetadataResource experimentMetadataResource = (ExperimentMetadataResource)Utils.getResource(ResourceType.EXPERIMENT_METADATA, expMetadata);
+                        resourceList.add(experimentMetadataResource);
+                    }
+                }
+                break;
+            case EXECUTION_ERROR:
+                generator = new QueryGenerator(EXECUTION_ERROR);
+                generator.setParameter(ExecutionErrorConstants.EXPERIMENT_ID, experimentID);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        Execution_Error executionError = (Execution_Error)result;
+                        ExecutionErrorResource executionErrorResource = (ExecutionErrorResource)Utils.getResource(ResourceType.EXECUTION_ERROR, executionError);
+                        resourceList.add(executionErrorResource);
+                    }
+                }
+                break;
+            case GFAC_JOB_DATA:
+                generator = new QueryGenerator(GFAC_JOB_DATA);
+                generator.setParameter(GFacJobDataConstants.EXPERIMENT_ID, experimentID);
+                q = generator.selectQuery(em);
+                results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        GFac_Job_Data gFacJobData = (GFac_Job_Data)result;
+                        GFacJobDataResource gFacJobDataResource = (GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA, gFacJobData);
+                        resourceList.add(gFacJobDataResource);
+                    }
+                }
+                break;
+            default:
+                em.getTransaction().commit();
+                em.close();
+                logger.error("Unsupported resource type for experiment data resource... ", new UnsupportedOperationException());
+                throw new IllegalArgumentException("Unsupported resource type for experiment data resource.");
+        }
+        em.getTransaction().commit();
+        em.close();
+        return resourceList;
+    }
+
+    public void save() {
+        EntityManager em = ResourceUtils.getEntityManager();
+        Experiment_Data existingExpData = em.find(Experiment_Data.class, experimentID);
+        em.close();
+
+        em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Experiment_Data experimentData = new Experiment_Data();
+        experimentData.setExperiment_ID(experimentID);
+        experimentData.setName(expName);
+        experimentData.setUsername(userName);
+        if(existingExpData != null){
+            existingExpData.setName(expName);
+            existingExpData.setUsername(userName);
+            experimentData = em.merge(existingExpData);
+        } else{
+            em.persist(experimentData);
+        }
+        em.getTransaction().commit();
+        em.close();
+
+    }
+    
+    public boolean isWorkflowInstancePresent(String workflowInstanceId){
+		return isExists(ResourceType.WORKFLOW_DATA, workflowInstanceId);
+    }
+    
+    public boolean isGFacJobPresent(String jobId){
+		return isExists(ResourceType.GFAC_JOB_DATA, jobId);
+    }
+    
+    public boolean isExperimentMetadataPresent(){
+		return isExists(ResourceType.EXPERIMENT_METADATA, getExperimentID());
+    }
+    
+    public WorkflowDataResource getWorkflowInstance(String workflowInstanceId){
+    	return (WorkflowDataResource)get(ResourceType.WORKFLOW_DATA, workflowInstanceId);
+    }
+    
+    public List<Resource> getGFacJobs(){
+    	return get(ResourceType.GFAC_JOB_DATA);
+    }
+    
+    public ExperimentMetadataResource getExperimentMetadata(){
+    	return (ExperimentMetadataResource)get(ResourceType.EXPERIMENT_METADATA,getExperimentID());
+    }
+    
+    public List<WorkflowDataResource> getWorkflowInstances(){
+    	return getResourceList(get(ResourceType.WORKFLOW_DATA),WorkflowDataResource.class);
+    }
+    
+    public WorkflowDataResource createWorkflowInstanceResource(String workflowInstanceID){
+    	WorkflowDataResource r=(WorkflowDataResource)create(ResourceType.WORKFLOW_DATA);
+    	r.setWorkflowInstanceID(workflowInstanceID);
+    	return r;
+    }
+    
+    public GFacJobDataResource createGFacJob(String jobID){
+    	GFacJobDataResource r=(GFacJobDataResource)create(ResourceType.GFAC_JOB_DATA);
+    	r.setLocalJobID(jobID);
+    	return r;
+    }
+    
+    public ExperimentMetadataResource createExperimentMetadata(){
+    	return (ExperimentMetadataResource)create(ResourceType.EXPERIMENT_METADATA);
+    }
+    
+    public ExecutionErrorResource createExecutionError(){
+    	return (ExecutionErrorResource) create(ResourceType.EXECUTION_ERROR);
+    }
+    
+    public void removeWorkflowInstance(String workflowInstanceId){
+    	remove(ResourceType.WORKFLOW_DATA, workflowInstanceId);
+    }
+    
+    public void removeExperimentMetadata(){
+    	remove(ResourceType.EXPERIMENT_METADATA,getExperimentID());
+    }
+    
+    public List<ExecutionErrorResource> getExecutionErrors(String type, String experimentId, String workflowInstanceId, String nodeId, String gfacJobId){
+    	List<ExecutionErrorResource> resourceList = new ArrayList<ExecutionErrorResource>();
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        Query q;
+        QueryGenerator generator;
+        List<?> results;
+    	generator = new QueryGenerator(EXECUTION_ERROR);
+        if (experimentId!=null){
+            generator.setParameter(ExecutionErrorConstants.EXPERIMENT_ID, experimentId);
+        }
+        if (type!=null){
+            generator.setParameter(ExecutionErrorConstants.SOURCE_TYPE, type);
+        }
+        if (workflowInstanceId!=null){
+        	generator.setParameter(ExecutionErrorConstants.WORKFLOW_ID, workflowInstanceId);	
+        }
+        if (nodeId!=null){
+        	generator.setParameter(ExecutionErrorConstants.NODE_ID, nodeId);	
+        }
+        if (gfacJobId!=null){
+        	generator.setParameter(ExecutionErrorConstants.GFAC_JOB_ID, gfacJobId);	
+        }
+        q = generator.selectQuery(em);
+        results = q.getResultList();
+        if (results.size() != 0) {
+            for (Object result : results) {
+                Execution_Error executionError = (Execution_Error)result;
+                ExecutionErrorResource executionErrorResource = (ExecutionErrorResource)Utils.getResource(ResourceType.EXECUTION_ERROR, executionError);
+                resourceList.add(executionErrorResource);
+            }
+        }
+        em.getTransaction().commit();
+        em.close();
+        return resourceList;
+    }
+}