airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [13/44] airavata git commit: Adding mongo-registry WIP
Date Sun, 07 Jun 2015 17:00:54 GMT
http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
new file mode 100644
index 0000000..6e6d2ee
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/JobDetailResource.java
@@ -0,0 +1,361 @@
+/*
+ *
+ * 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.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.utils.StatusType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JobDetailResource extends AbstractResource {
+    private static final Logger logger = LoggerFactory.getLogger(JobDetailResource.class);
+    private String jobId;
+    private TaskDetailResource taskDetailResource;
+    private String jobDescription;
+    private Timestamp creationTime;
+    private String computeResourceConsumed;
+    private String jobName;
+    private String workingDir;
+
+    public String getJobName() {
+        return jobName;
+    }
+
+    public void setJobName(String jobName) {
+        this.jobName = jobName;
+    }
+
+    public String getWorkingDir() {
+        return workingDir;
+    }
+
+    public void setWorkingDir(String workingDir) {
+        this.workingDir = workingDir;
+    }
+
+    public String getJobId() {
+        return jobId;
+    }
+
+    public void setJobId(String jobId) {
+        this.jobId = jobId;
+    }
+
+    public TaskDetailResource getTaskDetailResource() {
+        return taskDetailResource;
+    }
+
+    public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
+        this.taskDetailResource = taskDetailResource;
+    }
+
+    public String getJobDescription() {
+        return jobDescription;
+    }
+
+    public void setJobDescription(String jobDescription) {
+        this.jobDescription = jobDescription;
+    }
+
+    public Timestamp getCreationTime() {
+        return creationTime;
+    }
+
+    public void setCreationTime(Timestamp creationTime) {
+        this.creationTime = creationTime;
+    }
+
+    public String getComputeResourceConsumed() {
+        return computeResourceConsumed;
+    }
+
+    public void setComputeResourceConsumed(String computeResourceConsumed) {
+        this.computeResourceConsumed = computeResourceConsumed;
+    }
+
+    
+    public Resource create(ResourceType type) throws RegistryException {
+        switch (type){
+            case STATUS:
+                StatusResource statusResource = new StatusResource();
+                statusResource.setJobId(jobId);
+                return statusResource;
+            case ERROR_DETAIL:
+                ErrorDetailResource errorDetailResource = new ErrorDetailResource();
+                errorDetailResource.setJobId(jobId);
+                return errorDetailResource;
+            default:
+                logger.error("Unsupported resource type for job details data resource.", new UnsupportedOperationException());
+                throw new UnsupportedOperationException();
+        }
+    }
+
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            switch (type) {
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.JOB_ID, name);
+                    generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.toString());
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(ErrorDetailConstants.JOB_ID, name);
+                    q = generator.deleteQuery(em);
+                    q.executeUpdate();
+                    break;
+                default:
+                    logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
+                    break;
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException {
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QueryGenerator generator;
+            Query q;
+            switch (type) {
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.JOB_ID, name);
+                    generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.toString());
+                    q = generator.selectQuery(em);
+                    Status status = (Status) q.getSingleResult();
+                    StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                    em.getTransaction().commit();
+                    em.close();
+                    return statusResource;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.JOB_ID, name);
+                    q = generator.selectQuery(em);
+                    ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
+                    ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                    em.getTransaction().commit();
+                    em.close();
+                    return errorDetailResource;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
+                    throw new IllegalArgumentException("Unsupported resource type for job details resource.");
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
+        List<Resource> resourceList = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Query q;
+            QueryGenerator generator;
+            List results;
+            switch (type) {
+                case STATUS:
+                    generator = new QueryGenerator(STATUS);
+                    generator.setParameter(StatusConstants.JOB_ID, jobId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            Status status = (Status) result;
+                            StatusResource statusResource =
+                                    (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+                            resourceList.add(statusResource);
+                        }
+                    }
+                    break;
+                case ERROR_DETAIL:
+                    generator = new QueryGenerator(ERROR_DETAIL);
+                    generator.setParameter(ErrorDetailConstants.JOB_ID, jobId);
+                    q = generator.selectQuery(em);
+                    results = q.getResultList();
+                    if (results.size() != 0) {
+                        for (Object result : results) {
+                            ErrorDetail errorDetail = (ErrorDetail) result;
+                            ErrorDetailResource errorDetailResource =
+                                    (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+                            resourceList.add(errorDetailResource);
+                        }
+                    }
+                    break;
+                default:
+                    em.getTransaction().commit();
+                    em.close();
+                    logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
+                    throw new UnsupportedOperationException();
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return resourceList;
+    }
+
+    
+    public void save()  throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            JobDetail existingJobDetail = em.find(JobDetail.class, new JobDetails_PK(jobId, taskDetailResource.getTaskId()));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            JobDetail jobDetail = new JobDetail();
+            TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+            jobDetail.setJobId(jobId);
+            jobDetail.setTask(taskDetail);
+            jobDetail.setTaskId(taskDetailResource.getTaskId());
+            jobDetail.setCreationTime(creationTime);
+            jobDetail.setJobName(jobName);
+            jobDetail.setWorkingDir(workingDir);
+            if (jobDescription != null) {
+                jobDetail.setJobDescription(jobDescription.toCharArray());
+            }
+            jobDetail.setComputeResourceConsumed(computeResourceConsumed);
+            if (existingJobDetail != null) {
+                existingJobDetail.setJobId(jobId);
+                existingJobDetail.setTask(taskDetail);
+                existingJobDetail.setTaskId(taskDetailResource.getTaskId());
+                existingJobDetail.setCreationTime(creationTime);
+                if (jobDescription != null) {
+                    existingJobDetail.setJobDescription(jobDescription.toCharArray());
+                }
+                existingJobDetail.setComputeResourceConsumed(computeResourceConsumed);
+                existingJobDetail.setJobName(jobName);
+                existingJobDetail.setWorkingDir(workingDir);
+                jobDetail = em.merge(existingJobDetail);
+            } else {
+                em.persist(jobDetail);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public StatusResource getJobStatus() throws RegistryException{
+        List<Resource> resources = get(ResourceType.STATUS);
+        for (Resource resource : resources) {
+            StatusResource jobStatus = (StatusResource) resource;
+            if(jobStatus.getStatusType().equals(StatusType.JOB.toString())){
+                if (jobStatus.getState() == null || jobStatus.getState().equals("") ){
+                    jobStatus.setState("UNKNOWN");
+                }
+                return jobStatus;
+            }
+        }
+        return null;
+    }
+
+    public StatusResource getApplicationStatus() throws RegistryException{
+        List<Resource> resources = get(ResourceType.STATUS);
+        for (Resource resource : resources) {
+            StatusResource appStatus = (StatusResource) resource;
+            if(appStatus.getStatusType().equals(StatusType.APPLICATION.toString())){
+                if (appStatus.getState() == null || appStatus.getState().equals("") ){
+                    appStatus.setState("UNKNOWN");
+                }
+                return appStatus;
+            }
+        }
+        return null;
+    }
+
+    public List<ErrorDetailResource> getErrorDetails () throws RegistryException{
+        List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
+        List<Resource> resources = get(ResourceType.ERROR_DETAIL);
+        for(Resource resource : resources){
+            errorDetailResources.add((ErrorDetailResource)resource);
+        }
+        return errorDetailResources;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
new file mode 100644
index 0000000..4efb8a4
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeInputResource.java
@@ -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.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.NodeInput;
+import org.apache.airavata.persistance.registry.jpa.model.NodeInput_PK;
+import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NodeInputResource extends AbstractResource {
+	private static final Logger logger = LoggerFactory.getLogger(NodeInputResource.class);
+
+    private WorkflowNodeDetailResource nodeDetailResource;
+    private String inputKey;
+    private String dataType;
+    private String metadata;
+    private String value;
+    private String appArgument;
+    private boolean standardInput;
+    private String userFriendlyDesc;
+    private int inputOrder;
+    private boolean isRequired;
+    private boolean requiredToCMD;
+    private boolean dataStaged;
+
+    public boolean getRequired() {
+        return isRequired;
+    }
+
+    public void setRequired(boolean required) {
+        this.isRequired = required;
+    }
+
+    public boolean getRequiredToCMD() {
+        return requiredToCMD;
+    }
+
+    public void setRequiredToCMD(boolean requiredToCMD) {
+        this.requiredToCMD = requiredToCMD;
+    }
+
+    public boolean isDataStaged() {
+        return dataStaged;
+    }
+
+    public void setDataStaged(boolean dataStaged) {
+        this.dataStaged = dataStaged;
+    }
+
+    public String getAppArgument() {
+        return appArgument;
+    }
+
+    public void setAppArgument(String appArgument) {
+        this.appArgument = appArgument;
+    }
+
+    public boolean isStandardInput() {
+        return standardInput;
+    }
+
+    public void setStandardInput(boolean standardInput) {
+        this.standardInput = standardInput;
+    }
+
+    public String getUserFriendlyDesc() {
+        return userFriendlyDesc;
+    }
+
+    public void setUserFriendlyDesc(String userFriendlyDesc) {
+        this.userFriendlyDesc = userFriendlyDesc;
+    }
+
+    public WorkflowNodeDetailResource getNodeDetailResource() {
+        return nodeDetailResource;
+    }
+
+    public void setNodeDetailResource(WorkflowNodeDetailResource nodeDetailResource) {
+        this.nodeDetailResource = nodeDetailResource;
+    }
+
+    public String getInputKey() {
+        return inputKey;
+    }
+
+    public void setInputKey(String inputKey) {
+        this.inputKey = inputKey;
+    }
+
+    public String getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(String dataType) {
+        this.dataType = dataType;
+    }
+
+    public String getMetadata() {
+        return metadata;
+    }
+
+    public void setMetadata(String metadata) {
+        this.metadata = metadata;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public int getInputOrder() {
+        return inputOrder;
+    }
+
+    public void setInputOrder(int inputOrder) {
+        this.inputOrder = inputOrder;
+    }
+
+    public Resource create(ResourceType type) throws RegistryException {
+        logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException {
+        logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public List<Resource> get(ResourceType type) throws RegistryException {
+        logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            NodeInput existingInput = em.find(NodeInput.class, new NodeInput_PK(inputKey, nodeDetailResource.getNodeInstanceId()));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            NodeInput nodeInput = new NodeInput();
+            WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, nodeDetailResource.getNodeInstanceId());
+            nodeInput.setNodeDetails(nodeDetail);
+            nodeInput.setNodeId(nodeDetail.getNodeId());
+            nodeInput.setInputKey(inputKey);
+            nodeInput.setDataType(dataType);
+            nodeInput.setValue(value);
+            nodeInput.setMetadata(metadata);
+            nodeInput.setAppArgument(appArgument);
+            nodeInput.setStandardInput(standardInput);
+            nodeInput.setUserFriendlyDesc(userFriendlyDesc);
+            nodeInput.setInputOrder(inputOrder);
+            nodeInput.setRequiredToCMD(requiredToCMD);
+            nodeInput.setIsRequired(isRequired);
+            nodeInput.setDataStaged(dataStaged);
+
+            if (existingInput != null){
+                existingInput.setNodeDetails(nodeDetail);
+                existingInput.setNodeId(nodeDetail.getNodeId());
+                existingInput.setInputKey(inputKey);
+                existingInput.setDataType(dataType);
+                existingInput.setValue(value);
+                existingInput.setMetadata(metadata);
+                existingInput.setAppArgument(appArgument);
+                existingInput.setStandardInput(standardInput);
+                existingInput.setUserFriendlyDesc(userFriendlyDesc);
+                existingInput.setInputOrder(inputOrder);
+                existingInput.setRequiredToCMD(requiredToCMD);
+                existingInput.setIsRequired(isRequired);
+                existingInput.setDataStaged(dataStaged);
+                nodeInput = em.merge(existingInput);
+            }else {
+                em.persist(nodeInput);
+            }
+            em.getTransaction().commit();
+            em.close();
+        }catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        }finally {
+            if (em != null && em.isOpen()){
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
new file mode 100644
index 0000000..ceb323b
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NodeOutputResource.java
@@ -0,0 +1,211 @@
+/*
+ *
+ * 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.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.NodeOutput;
+import org.apache.airavata.persistance.registry.jpa.model.NodeOutput_PK;
+import org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NodeOutputResource extends AbstractResource {
+	private static final Logger logger = LoggerFactory.getLogger(NodeOutputResource.class);
+	
+    private WorkflowNodeDetailResource nodeDetailResource;
+    private String outputKey;
+    private String dataType;
+    private String value;
+    private boolean isRequired;
+    private boolean dataMovement;
+    private String dataNameLocation;
+    private boolean requiredToCMD;
+    private String searchQuery;
+    private String appArgument;
+
+    public String getSearchQuery() {
+        return searchQuery;
+    }
+
+    public void setSearchQuery(String searchQuery) {
+        this.searchQuery = searchQuery;
+    }
+
+    public String getAppArgument() {
+        return appArgument;
+    }
+
+    public void setAppArgument(String appArgument) {
+        this.appArgument = appArgument;
+    }
+
+
+    public boolean getRequiredToCMD() {
+        return requiredToCMD;
+    }
+
+    public void setRequiredToCMD(boolean requiredToCMD) {
+        this.requiredToCMD = requiredToCMD;
+    }
+
+    public boolean getRequired() {
+        return isRequired;
+    }
+
+    public void setRequired(boolean required) {
+        this.isRequired = required;
+    }
+
+    public boolean isDataMovement() {
+        return dataMovement;
+    }
+
+    public void setDataMovement(boolean dataMovement) {
+        this.dataMovement = dataMovement;
+    }
+
+    public String getDataNameLocation() {
+        return dataNameLocation;
+    }
+
+    public void setDataNameLocation(String dataNameLocation) {
+        this.dataNameLocation = dataNameLocation;
+    }
+
+    public WorkflowNodeDetailResource getNodeDetailResource() {
+        return nodeDetailResource;
+    }
+
+    public void setNodeDetailResource(WorkflowNodeDetailResource nodeDetailResource) {
+        this.nodeDetailResource = nodeDetailResource;
+    }
+
+    public String getOutputKey() {
+        return outputKey;
+    }
+
+    public void setOutputKey(String outputKey) {
+        this.outputKey = outputKey;
+    }
+
+    public String getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(String dataType) {
+        this.dataType = dataType;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    
+    public Resource create(ResourceType type) throws RegistryException {
+        logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
+        logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            NodeOutput existingOutput = em.find(NodeOutput.class, new NodeOutput_PK(outputKey, nodeDetailResource.getNodeInstanceId()));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            NodeOutput nodeOutput = new NodeOutput();
+            WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, nodeDetailResource.getNodeInstanceId());
+            nodeOutput.setNode(nodeDetail);
+            nodeOutput.setNodeId(nodeDetail.getNodeId());
+            nodeOutput.setOutputKey(outputKey);
+            nodeOutput.setDataType(dataType);
+            nodeOutput.setValue(value);
+            nodeOutput.setRequired(isRequired);
+            nodeOutput.setRequiredToCMD(requiredToCMD);
+            nodeOutput.setDataMovement(dataMovement);
+            nodeOutput.setDataNameLocation(dataNameLocation);
+            nodeOutput.setApplicationArgument(appArgument);
+            nodeOutput.setSearchQuery(searchQuery);
+
+            if (existingOutput != null) {
+                existingOutput.setNode(nodeDetail);
+                existingOutput.setNodeId(nodeDetail.getNodeId());
+                existingOutput.setOutputKey(outputKey);
+                existingOutput.setDataType(dataType);
+                existingOutput.setValue(value);
+                existingOutput.setRequired(isRequired);
+                existingOutput.setRequiredToCMD(requiredToCMD);
+                existingOutput.setDataMovement(dataMovement);
+                existingOutput.setDataNameLocation(dataNameLocation);
+                existingOutput.setApplicationArgument(appArgument);
+                existingOutput.setSearchQuery(searchQuery);
+                nodeOutput = em.merge(existingOutput);
+            } else {
+                em.persist(nodeOutput);
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java
new file mode 100644
index 0000000..5ac864f
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java
@@ -0,0 +1,125 @@
+/*
+*
+* 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.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import java.util.List;
+
+public class NotificationEmailResource extends AbstractResource {
+    private static final Logger logger = LoggerFactory.getLogger(NotificationEmailResource.class);
+
+    private int emailId = 0;
+    private ExperimentResource experimentResource;
+    private TaskDetailResource taskDetailResource;
+    private String emailAddress;
+
+
+    public String getEmailAddress() {
+        return emailAddress;
+    }
+
+    public void setEmailAddress(String emailAddress) {
+        this.emailAddress = emailAddress;
+    }
+
+    public ExperimentResource getExperimentResource() {
+        return experimentResource;
+    }
+
+    public void setExperimentResource(ExperimentResource experimentResource) {
+        this.experimentResource = experimentResource;
+    }
+
+    public TaskDetailResource getTaskDetailResource() {
+        return taskDetailResource;
+    }
+
+    public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
+        this.taskDetailResource = taskDetailResource;
+    }
+
+    public Resource create(ResourceType type) throws RegistryException {
+        logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    public Resource get(ResourceType type, Object name) throws RegistryException {
+        logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    public List<Resource> get(ResourceType type) throws RegistryException {
+        logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Notification_Email notification_email;
+            if (emailId != 0 ){
+                notification_email  = em.find(Notification_Email.class, emailId);
+                notification_email.setEmailId(emailId);
+            }else {
+                notification_email = new Notification_Email();
+            }
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            notification_email.setExperiment(experiment);
+            notification_email.setExperiment_id(experiment.getExpId());
+            if (taskDetailResource != null){
+                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+                notification_email.setTaskDetail(taskDetail);
+                notification_email.setTaskId(taskDetail.getTaskId());
+            }
+            notification_email.setEmailAddress(emailAddress);
+            em.persist(notification_email);
+            emailId = notification_email.getEmailId();
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
new file mode 100644
index 0000000..9432067
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectResource.java
@@ -0,0 +1,531 @@
+/*
+ *
+ * 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.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.ResultOrderType;
+import org.apache.airavata.registry.cpi.utils.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ProjectResource extends AbstractResource {
+    private final static Logger logger = LoggerFactory.getLogger(ProjectResource.class);
+    private String name;
+    private String id;
+    private GatewayResource gateway;
+    private WorkerResource worker;
+    private String description;
+    private Timestamp creationTime;
+
+    /**
+     *
+     */
+    public ProjectResource() {
+    }
+
+    /**
+     *
+     * @param worker gateway worker
+     * @param gateway gateway
+     * @param projectId project name
+     */
+    public ProjectResource(WorkerResource worker, GatewayResource gateway, String projectId) {
+        this.setWorker(worker);
+        this.setGateway(gateway);
+        this.id = projectId;
+    }
+
+    /**
+     *
+     * @param type child resource type
+     * @return child resource
+     */
+    public Resource create(ResourceType type) throws RegistryException {
+        if (type == ResourceType.EXPERIMENT) {
+            ExperimentResource experimentResource = new ExperimentResource();
+            experimentResource.setGateway(getGateway());
+            experimentResource.setExecutionUser(worker.getUser());
+            experimentResource.setProject(this);
+            return experimentResource;
+        } else if (type == ResourceType.PROJECT_USER){
+            ProjectUserResource pr = new ProjectUserResource();
+            pr.setProjectId(id);
+            pr.setUserName(worker.getUser());
+            return pr;
+        }
+        else {
+            logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+            throw new IllegalArgumentException("Unsupported resource type for project resource.");
+        }
+    }
+
+    /**
+     *
+     * @param type child resource type
+     * @param name child resource name
+     */
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            if (type == ResourceType.EXPERIMENT) {
+                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+                Query q = generator.deleteQuery(em);
+                q.executeUpdate();
+            } else if (type == ResourceType.PROJECT_USER) {
+                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+                generator.setParameter(ProjectUserConstants.USERNAME, name);
+                generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
+                Query q = generator.deleteQuery(em);
+                q.executeUpdate();
+            } else {
+                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for project resource.");
+            }
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    /**
+     *
+     * @param type child resource type
+     * @param name child resource name
+     * @return child resource
+     */
+    public Resource get(ResourceType type, Object name) throws RegistryException {
+        EntityManager em = null;
+        try {
+            if (type == ResourceType.EXPERIMENT) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+                Query q = generator.selectQuery(em);
+                Experiment experiment = (Experiment) q.getSingleResult();
+                ExperimentResource experimentResource = (ExperimentResource)
+                        Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                em.getTransaction().commit();
+                em.close();
+                return experimentResource;
+            } else if (type == ResourceType.PROJECT_USER) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+                generator.setParameter(ProjectUserConstants.USERNAME, name);
+                generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
+                Query q = generator.selectQuery(em);
+                ProjectUser prUser = (ProjectUser) q.getSingleResult();
+                ExperimentResource experimentResource = (ExperimentResource)
+                        Utils.getResource(ResourceType.PROJECT_USER, prUser);
+                em.getTransaction().commit();
+                em.close();
+                return experimentResource;
+            } else {
+                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for project resource.");
+            }
+        } catch (Exception e) {
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    /**
+     *
+     * @param type child resource type
+     * @return list of child resources
+     */
+    @Override
+    public List<Resource> get(ResourceType type) throws RegistryException{
+        List<Resource> resourceList = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            if (type == ResourceType.EXPERIMENT) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+                generator.setParameter(ExperimentConstants.PROJECT_ID, id);
+                Query q = generator.selectQuery(em);
+                List<?> results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        Experiment experiment = (Experiment) result;
+                        ExperimentResource experimentResource = (ExperimentResource)
+                                Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                        resourceList.add(experimentResource);
+                    }
+                }
+                em.getTransaction().commit();
+                em.close();
+            } else if (type == ResourceType.PROJECT_USER) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+                generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
+                Query q = generator.selectQuery(em);
+                List<?> results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ProjectUser projectUser = (ProjectUser) result;
+                        ProjectUserResource pr = (ProjectUserResource)
+                                Utils.getResource(ResourceType.PROJECT_USER, projectUser);
+                        resourceList.add(pr);
+                    }
+                }
+                em.getTransaction().commit();
+                em.close();
+            } else {
+                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for project resource.");
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return resourceList;
+    }
+
+    /**
+     * Get results with pagination and ordering
+     *
+     * @param type
+     * @param limit
+     * @param offset
+     * @param orderByIdentifier
+     * @return
+     * @throws RegistryException
+     */
+    public List<Resource> get(ResourceType type, int limit, int offset, Object orderByIdentifier,
+                              ResultOrderType resultOrderType) throws RegistryException{
+        List<Resource> resourceList = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            if (type == ResourceType.EXPERIMENT) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+                generator.setParameter(ExperimentConstants.PROJECT_ID, id);
+                Query q;
+                //ordering - supported only by CREATION_TIME
+                if(orderByIdentifier != null && resultOrderType != null
+                        && orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)) {
+                    q = generator.selectQuery(em, ExperimentConstants.CREATION_TIME, resultOrderType);
+                }else{
+                    q = generator.selectQuery(em);
+                }
+
+                //pagination
+                if(limit>0 && offset>=0){
+                    q.setFirstResult(offset);
+                    q.setMaxResults(limit);
+                }
+                List<?> results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        Experiment experiment = (Experiment) result;
+                        ExperimentResource experimentResource = (ExperimentResource)
+                                Utils.getResource(ResourceType.EXPERIMENT, experiment);
+                        resourceList.add(experimentResource);
+                    }
+                }
+                em.getTransaction().commit();
+                em.close();
+            } else if (type == ResourceType.PROJECT_USER) {
+                em = ResourceUtils.getEntityManager();
+                em.getTransaction().begin();
+                QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+                generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
+                Query q;
+                //ordering - only supported only by CREATION_TIME
+                if(orderByIdentifier != null && resultOrderType != null
+                        && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
+                    q = generator.selectQuery(em, ProjectConstants.CREATION_TIME, resultOrderType);
+                }else{
+                    q = generator.selectQuery(em);
+                }
+
+                //pagination
+                if(limit>0 && offset>=0){
+                    q.setFirstResult(offset);
+                    q.setMaxResults(limit);
+                }
+                List<?> results = q.getResultList();
+                if (results.size() != 0) {
+                    for (Object result : results) {
+                        ProjectUser projectUser = (ProjectUser) result;
+                        ProjectUserResource pr = (ProjectUserResource)
+                                Utils.getResource(ResourceType.PROJECT_USER, projectUser);
+                        resourceList.add(pr);
+                    }
+                }
+                em.getTransaction().commit();
+                em.close();
+            } else {
+                logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported resource type for project resource.");
+            }
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+        return resourceList;
+    }
+
+    /**
+     * saveExperiment project to the database
+     */
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            Project existingProject = em.find(Project.class, id);
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Project project = new Project();
+            project.setProject_id(id);
+            project.setProject_name(name);
+            Gateway modelGateway = em.find(Gateway.class, gateway.getGatewayId());
+            project.setGateway(modelGateway);
+            project.setGateway_id(modelGateway.getGateway_id());
+            Users user = em.find(Users.class, worker.getUser());
+            project.setUsers(user);
+            project.setUser_name(user.getUser_name());
+            project.setDescription(description);
+            project.setCreationTime(creationTime);
+
+            if (existingProject != null) {
+                existingProject.setProject_name(name);
+                existingProject.setGateway(modelGateway);
+                existingProject.setGateway_id(modelGateway.getGateway_id());
+                existingProject.setUsers(user);
+                existingProject.setUser_name(user.getUser_name());
+                existingProject.setDescription(description);
+                existingProject.setCreationTime(creationTime);
+                project = em.merge(existingProject);
+            } else {
+                em.persist(project);
+            }
+
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    /**
+     *
+     * @return project name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     *
+     * @param name  project name
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     *
+     * @return gateway worker
+     */
+    public WorkerResource getWorker() {
+		return worker;
+	}
+
+    /**
+     *
+     * @param worker gateway worker
+     */
+    public void setWorker(WorkerResource worker) {
+		this.worker = worker;
+	}
+
+    /**
+     *
+     * @return gateway resource
+     */
+    public GatewayResource getGateway() {
+		return gateway;
+	}
+
+    /**
+     *
+     * @param gateway gateway resource
+     */
+    public void setGateway(GatewayResource gateway) {
+		this.gateway = gateway;
+	}
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Timestamp getCreationTime() {
+        return creationTime;
+    }
+
+    public void setCreationTime(Timestamp creationTime) {
+        this.creationTime = creationTime;
+    }
+
+    /**
+     *
+     * @param experimentId experiment ID
+     * @return whether the experiment exist
+     */
+    public boolean isExperimentExists(String experimentId) throws RegistryException{
+		return isExists(ResourceType.EXPERIMENT, experimentId);
+	}
+
+    /**
+     *
+     * @param experimentId experiment ID
+     * @return  experiment resource
+     */
+    public ExperimentResource createExperiment(String experimentId) throws RegistryException{
+		ExperimentResource experimentResource = (ExperimentResource)create(ResourceType.EXPERIMENT);
+		experimentResource.setExpID(experimentId);
+		return experimentResource;
+	}
+
+    /**
+     *
+     * @param experimentId experiment ID
+     * @return experiment resource
+     */
+	public ExperimentResource getExperiment(String experimentId) throws RegistryException{
+		return (ExperimentResource)get(ResourceType.EXPERIMENT,experimentId);
+	}
+
+    /**
+     *
+     * @return  list of experiments
+     */
+    public List<ExperimentResource> getExperiments() throws RegistryException{
+		List<Resource> list = get(ResourceType.EXPERIMENT);
+		List<ExperimentResource> result=new ArrayList<ExperimentResource>();
+		for (Resource resource : list) {
+			result.add((ExperimentResource) resource);
+		}
+		return result;
+	}
+
+    public List<ExperimentResource> getExperiments(int limit, int offset, Object orderByIdentifier,
+                                                   ResultOrderType resultOrderType) throws RegistryException{
+        List<Resource> list = get(ResourceType.EXPERIMENT, limit, offset, orderByIdentifier, resultOrderType);
+        List<ExperimentResource> result=new ArrayList<ExperimentResource>();
+        for (Resource resource : list) {
+            result.add((ExperimentResource) resource);
+        }
+        return result;
+    }
+
+    /**
+     *
+     * @param experimentId experiment ID
+     */
+    public void removeExperiment(String experimentId) throws RegistryException{
+		remove(ResourceType.EXPERIMENT, experimentId);
+	}
+
+    public List<ProjectUserResource> getProjectUserList () throws RegistryException{
+        List<Resource> resources = get(ResourceType.PROJECT_USER);
+        List<ProjectUserResource> projectUserResources = new ArrayList<ProjectUserResource>();
+        if (resources != null && !resources.isEmpty()){
+            for (Resource r : resources){
+                projectUserResources.add((ProjectUserResource)r);
+            }
+        }
+        return projectUserResources;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
new file mode 100644
index 0000000..336a9ee
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ProjectUserResource.java
@@ -0,0 +1,123 @@
+/*
+ *
+ * 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.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import java.util.List;
+
+public class ProjectUserResource extends AbstractResource {
+    private String projectId;
+    private String userName;
+
+    private static final Logger logger = LoggerFactory.getLogger(ProjectUserResource.class);
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    
+    public Resource create(ResourceType type) throws RegistryException {
+        logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
+        logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            ProjectUser existingPrUser = em.find(ProjectUser.class, new ProjectUser_PK(projectId, userName));
+            em.close();
+
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            ProjectUser prUser = new ProjectUser();
+            prUser.setProjectId(projectId);
+            prUser.setUserName(userName);
+            Users user = em.find(Users.class, userName);
+            prUser.setUser(user);
+            Project project = em.find(Project.class, projectId);
+            prUser.setProject(project);
+
+            if (existingPrUser != null) {
+                existingPrUser.setProjectId(projectId);
+                existingPrUser.setUserName(userName);
+                existingPrUser.setUser(user);
+                existingPrUser.setProject(project);
+                prUser = em.merge(existingPrUser);
+            } else {
+                em.persist(prUser);
+            }
+
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
new file mode 100644
index 0000000..6f906cd
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/QosParamResource.java
@@ -0,0 +1,152 @@
+/*
+ *
+ * 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.Experiment;
+import org.apache.airavata.persistance.registry.jpa.model.QosParam;
+import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
+
+import javax.persistence.EntityManager;
+import java.util.List;
+
+public class QosParamResource extends AbstractResource {
+    private static final Logger logger = LoggerFactory.getLogger(QosParamResource.class);
+    private int  qosId;
+    private ExperimentResource experimentResource;
+    private TaskDetailResource taskDetailResource;
+    private String startExecutionAt;
+    private String executeBefore;
+    private int noOfRetries;
+
+    public int getQosId() {
+        return qosId;
+    }
+
+    public void setQosId(int qosId) {
+        this.qosId = qosId;
+    }
+
+    public ExperimentResource getExperimentResource() {
+        return experimentResource;
+    }
+
+    public void setExperimentResource(ExperimentResource experimentResource) {
+        this.experimentResource = experimentResource;
+    }
+
+    public TaskDetailResource getTaskDetailResource() {
+        return taskDetailResource;
+    }
+
+    public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
+        this.taskDetailResource = taskDetailResource;
+    }
+
+    public String getStartExecutionAt() {
+        return startExecutionAt;
+    }
+
+    public void setStartExecutionAt(String startExecutionAt) {
+        this.startExecutionAt = startExecutionAt;
+    }
+
+    public String getExecuteBefore() {
+        return executeBefore;
+    }
+
+    public void setExecuteBefore(String executeBefore) {
+        this.executeBefore = executeBefore;
+    }
+
+    public int getNoOfRetries() {
+        return noOfRetries;
+    }
+
+    public void setNoOfRetries(int noOfRetries) {
+        this.noOfRetries = noOfRetries;
+    }
+
+    
+    public Resource create(ResourceType type) throws RegistryException{
+        logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
+        logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            QosParam qosParam = new QosParam();
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            if (taskDetailResource != null) {
+                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+                qosParam.setTaskId(taskDetailResource.getTaskId());
+                qosParam.setTask(taskDetail);
+            }
+            qosParam.setExpId(experimentResource.getExpID());
+            qosParam.setExperiment(experiment);
+            qosParam.setStartExecutionAt(startExecutionAt);
+            qosParam.setExecuteBefore(executeBefore);
+            qosParam.setNoOfRetries(noOfRetries);
+            em.persist(qosParam);
+            qosId = qosParam.getQosId();
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
new file mode 100644
index 0000000..169e1c7
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/StatusResource.java
@@ -0,0 +1,195 @@
+/*
+ *
+ * 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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
+
+import javax.persistence.EntityManager;
+import java.sql.Timestamp;
+import java.util.List;
+
+public class StatusResource extends AbstractResource {
+    private static final Logger logger = LoggerFactory.getLogger(StatusResource.class);
+    private int statusId = 0;
+    private ExperimentResource experimentResource;
+    private WorkflowNodeDetailResource workflowNodeDetail;
+    private DataTransferDetailResource dataTransferDetail;
+    private TaskDetailResource taskDetailResource;
+    private String jobId;
+    private String state;
+    private Timestamp statusUpdateTime;
+    private String statusType;
+
+    public int getStatusId() {
+        return statusId;
+    }
+
+    public void setStatusId(int statusId) {
+        this.statusId = statusId;
+    }
+
+    public ExperimentResource getExperimentResource() {
+        return experimentResource;
+    }
+
+    public void setExperimentResource(ExperimentResource experimentResource) {
+        this.experimentResource = experimentResource;
+    }
+
+    public WorkflowNodeDetailResource getWorkflowNodeDetail() {
+        return workflowNodeDetail;
+    }
+
+    public void setWorkflowNodeDetail(WorkflowNodeDetailResource workflowNodeDetail) {
+        this.workflowNodeDetail = workflowNodeDetail;
+    }
+
+    public DataTransferDetailResource getDataTransferDetail() {
+        return dataTransferDetail;
+    }
+
+    public void setDataTransferDetail(DataTransferDetailResource dataTransferDetail) {
+        this.dataTransferDetail = dataTransferDetail;
+    }
+
+    public TaskDetailResource getTaskDetailResource() {
+        return taskDetailResource;
+    }
+
+    public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
+        this.taskDetailResource = taskDetailResource;
+    }
+
+    public String getJobId() {
+        return jobId;
+    }
+
+    public void setJobId(String jobId) {
+        this.jobId = jobId;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public Timestamp getStatusUpdateTime() {
+        return statusUpdateTime;
+    }
+
+    public void setStatusUpdateTime(Timestamp statusUpdateTime) {
+        this.statusUpdateTime = statusUpdateTime;
+    }
+
+    public String getStatusType() {
+        return statusType;
+    }
+
+    public void setStatusType(String statusType) {
+        this.statusType = statusType;
+    }
+
+    
+    public Resource create(ResourceType type) throws RegistryException{
+        logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void remove(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public Resource get(ResourceType type, Object name) throws RegistryException{
+        logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public List<Resource> get(ResourceType type) throws RegistryException{
+        logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
+        throw new UnsupportedOperationException();
+    }
+
+    
+    public void save() throws RegistryException{
+        EntityManager em = null;
+        try {
+            em = ResourceUtils.getEntityManager();
+            em.getTransaction().begin();
+            Status status;
+            if (statusId != 0) {
+                status = em.find(Status.class, statusId);
+                status.setStatusId(statusId);
+            } else {
+                status = new Status();
+            }
+            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+            if (taskDetailResource != null) {
+                TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+                status.setTask(taskDetail);
+                status.setTaskId(taskDetailResource.getTaskId());
+            }
+            if (workflowNodeDetail != null) {
+                WorkflowNodeDetail nodeDetail = em.find(WorkflowNodeDetail.class, workflowNodeDetail.getNodeInstanceId());
+                status.setNode(nodeDetail);
+                status.setNodeId(workflowNodeDetail.getNodeInstanceId());
+            }
+            if (dataTransferDetail != null) {
+                DataTransferDetail transferDetail = em.find(DataTransferDetail.class, dataTransferDetail.getTransferId());
+                status.setTransferDetail(transferDetail);
+                status.setTransferId(dataTransferDetail.getTransferId());
+            }
+            status.setExperiment(experiment);
+            status.setJobId(jobId);
+            status.setExpId(experimentResource.getExpID());
+            status.setState(state);
+            status.setStatusUpdateTime(statusUpdateTime);
+            status.setStatusType(statusType);
+            em.persist(status);
+            statusId = status.getStatusId();
+            em.getTransaction().commit();
+            em.close();
+        } catch (Exception e) {
+            logger.error(e.getMessage(), e);
+            throw new RegistryException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+}


Mime
View raw message