http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
----------------------------------------------------------------------
diff --git 
a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
 
b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
deleted file mode 100644
index 69ada6d..0000000
--- 
a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
+++ /dev/null
@@ -1,824 +0,0 @@
-/*
- *
- * 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.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.persistance.registry.jpa.JPAConstants;
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.model.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.URI;
-
-
-public class Utils {
-    private final static Logger logger = LoggerFactory.getLogger(Utils.class);
-
-    public static String getJDBCFullURL(){
-               String jdbcUrl = getJDBCURL();
-               String jdbcUser = getJDBCUser();
-               String jdbcPassword = getJDBCPassword();
-        jdbcUrl = jdbcUrl + "?"  + "user=" + jdbcUser + "&" + "password=" + 
jdbcPassword;
-        return jdbcUrl;
-    }
-
-    public static String getJDBCURL(){
-       try {
-            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_URL);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static String getHost(){
-        try{
-            String jdbcURL = getJDBCURL();
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getHost();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static int getPort(){
-        try{
-            String jdbcURL = getJDBCURL();
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getPort();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-
-    public static int getJPACacheSize (){
-        try {
-            String cache = 
ServerSettings.getSetting(JPAConstants.JPA_CACHE_SIZE, "5000");
-            return Integer.parseInt(cache);
-        }catch (Exception e){
-            logger.error(e.getMessage(), e);
-            return -1;
-        }
-    }
-
-    public static String isCachingEnabled (){
-        try {
-            return ServerSettings.getSetting(JPAConstants.ENABLE_CACHING, 
"true");
-        }catch (Exception e){
-            logger.error(e.getMessage(), e);
-            return "true";
-        }
-    }
-
-    public static String getDBType(){
-        try{
-            String jdbcURL = getJDBCURL();
-            String cleanURI = jdbcURL.substring(5);
-            URI uri = URI.create(cleanURI);
-            return uri.getScheme();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            return null;
-        }
-    }
-
-    public static boolean isDerbyStartEnabled(){
-        try {
-            String s = 
ServerSettings.getSetting(JPAConstants.KEY_DERBY_START_ENABLE);
-            if("true".equals(s)){
-                return true;
-            }
-        } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return false;
-        }
-        return false;
-    }
-
-    public static String getJDBCUser(){
-       try {
-                   return 
ServerSettings.getSetting(JPAConstants.KEY_JDBC_USER);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-               }
-    }
-
-    public static String getValidationQuery(){
-       try {
-            return ServerSettings.getSetting(JPAConstants.VALIDATION_QUERY);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-               }
-    }
-
-    public static String getJDBCPassword(){
-       try {
-            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_PASSWORD);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-               }
-
-    }
-
-    public static String getJDBCDriver(){
-       try {
-            return ServerSettings.getSetting(JPAConstants.KEY_JDBC_DRIVER);
-               } catch (ApplicationSettingsException e) {
-            logger.error(e.getMessage(), e);
-            return null;
-               }
-    }
-
-    /**
-     *
-     * @param type model type
-     * @param o model type instance
-     * @return corresponding resource object
-     */
-    public static Resource getResource(ResourceType type, Object o) {
-        switch (type){
-            case GATEWAY:
-                if (o instanceof Gateway) {
-                    return createGateway((Gateway) o);
-                } else {
-                    logger.error("Object should be a Gateway.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
Gateway.");
-                }
-            case PROJECT:
-                if (o instanceof Project){
-                    return createProject((Project) o);
-                } else {
-                    logger.error("Object should be a Project.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
Project.");
-                }
-            case PROJECT_USER:
-                if (o instanceof  ProjectUser){
-                    return createProjectUser((ProjectUser)o);
-                }else {
-                    logger.error("Object should be a ProjectUser.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
ProjectUser.");
-                }
-            case CONFIGURATION:
-                if(o instanceof Configuration){
-                    return createConfiguration((Configuration) o);
-                }else {
-                    logger.error("Object should be a Configuration.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
Configuration.");
-                }
-            case USER:
-                if(o instanceof Users) {
-                    return createUser((Users) o);
-                }else {
-                    logger.error("Object should be a User.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
User.");
-                }
-            case GATEWAY_WORKER:
-                if (o instanceof Gateway_Worker){
-                    return createGatewayWorker((Gateway_Worker)o);
-                } else {
-                    logger.error("Object should be a Gateway Worker.", new 
IllegalArgumentException());
-                    throw  new IllegalArgumentException("Object should be a 
Gateway Worker.");
-                }
-            case EXPERIMENT:
-                if (o instanceof  Experiment){
-                    return createExperiment((Experiment)o);
-                }else {
-                    logger.error("Object should be a Experiment.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
Experiment.");
-                }
-            case NOTIFICATION_EMAIL:
-                if (o instanceof  Notification_Email){
-                    return createNotificationEmail((Notification_Email)o);
-                }else {
-                    logger.error("Object should be a Experiment.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
Experiment.");
-                }
-            case EXPERIMENT_INPUT:
-                if (o instanceof  Experiment_Input){
-                    return createExperimentInput((Experiment_Input)o);
-                }else {
-                    logger.error("Object should be a Experiment input data.", 
new IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
Experiment input data.");
-                }
-            case EXPERIMENT_OUTPUT:
-                if (o instanceof  Experiment_Output){
-                    return createExperimentOutput((Experiment_Output)o);
-                }else {
-                    logger.error("Object should be a Experiment output data.", 
new IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
Experiment output data.");
-                }
-            case WORKFLOW_NODE_DETAIL:
-                 if (o instanceof  WorkflowNodeDetail){
-                     return createWorkflowNodeDetail((WorkflowNodeDetail)o);
-                 }else {
-                     logger.error("Object should be a Workflow node data.", 
new IllegalArgumentException());
-                     throw new IllegalArgumentException("Object should be a 
Workflow node data.");
-                 }
-            case TASK_DETAIL:
-                if (o instanceof  TaskDetail){
-                    return createTaskDetail((TaskDetail)o);
-                }else {
-                    logger.error("Object should be a task detail data.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
task detail data.");
-                }
-            case ERROR_DETAIL:
-                if (o instanceof  ErrorDetail){
-                    return createErrorDetail((ErrorDetail)o);
-                }else {
-                    logger.error("Object should be a error detail data.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
error detail data.");
-                }
-            case APPLICATION_INPUT:
-                if (o instanceof  ApplicationInput){
-                    return createApplicationInput((ApplicationInput)o);
-                }else {
-                    logger.error("Object should be a application input data.", 
new IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
application input data.");
-                }
-            case APPLICATION_OUTPUT:
-                if (o instanceof  ApplicationOutput){
-                    return createApplicationOutput((ApplicationOutput)o);
-                }else {
-                    logger.error("Object should be a application output 
data.", new IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
application output data.");
-                }
-            case NODE_INPUT:
-                if (o instanceof  NodeInput){
-                    return createNodeInput((NodeInput)o);
-                }else {
-                    logger.error("Object should be a node input data.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
node input data.");
-                }
-            case NODE_OUTPUT:
-                if (o instanceof  NodeOutput){
-                    return createNodeOutput((NodeOutput)o);
-                }else {
-                    logger.error("Object should be a node output data.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
node output data.");
-                }
-            case JOB_DETAIL:
-                if (o instanceof  JobDetail){
-                    return createJobDetail((JobDetail)o);
-                }else {
-                    logger.error("Object should be a job detail data.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a job 
detail data.");
-                }
-            case DATA_TRANSFER_DETAIL:
-                if (o instanceof  DataTransferDetail){
-                    return createDataTransferResource((DataTransferDetail)o);
-                }else {
-                    logger.error("Object should be a data transfer detail 
data.", new IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
data transfer detail data.");
-                }
-            case STATUS:
-                if (o instanceof  Status){
-                    return createStatusResource((Status)o);
-                }else {
-                    logger.error("Object should be a status data.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be a 
status data.");
-                }
-            case CONFIG_DATA:
-                if (o instanceof  ExperimentConfigData){
-                    return createExConfigDataResource((ExperimentConfigData)o);
-                }else {
-                    logger.error("Object should be a experiment config data.", 
new IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be 
experiment config data.");
-                }
-            case COMPUTATIONAL_RESOURCE_SCHEDULING:
-                if (o instanceof  Computational_Resource_Scheduling){
-                    return 
createComputationalScheduling((Computational_Resource_Scheduling)o);
-                }else {
-                    logger.error("Object should be a scheduling resource 
data.", new IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be 
scheduling resource data.");
-                }
-            case ADVANCE_INPUT_DATA_HANDLING:
-                if (o instanceof  AdvancedInputDataHandling){
-                    return 
createAdvancedInputDataResource((AdvancedInputDataHandling)o);
-                }else {
-                    logger.error("Object should be a advanced input data 
handling data.", new IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be 
advanced input data handling data.");
-                }
-            case ADVANCE_OUTPUT_DATA_HANDLING:
-                if (o instanceof  AdvancedOutputDataHandling){
-                    return 
createAdvancedOutputDataResource((AdvancedOutputDataHandling)o);
-                }else {
-                    logger.error("Object should be a advanced output data 
handling data.", new IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be 
advanced output data handling data.");
-                }
-            case QOS_PARAM:
-                if (o instanceof  QosParam){
-                    return createQosParamResource((QosParam)o);
-                }else {
-                    logger.error("Object should be a QOSparam data.", new 
IllegalArgumentException());
-                    throw new IllegalArgumentException("Object should be 
QOSparam data.");
-                }
-            default:
-                logger.error("Illegal data type..", new 
IllegalArgumentException());
-                throw new IllegalArgumentException("Illegal data type..");
-        }
-    }
-
-    /**
-     *
-     * @param o  Gateway model object
-     * @return  GatewayResource object
-     */
-    private static Resource createGateway(Gateway o) {
-        GatewayResource gatewayResource = new GatewayResource();
-        gatewayResource.setGatewayName(o.getGateway_name());
-        gatewayResource.setGatewayId(o.getGateway_id());
-        gatewayResource.setDomain(o.getDomain());
-        gatewayResource.setEmailAddress(o.getEmailAddress());
-        return gatewayResource;
-    }
-
-    /**
-     *
-     * @param o Project model object
-     * @return ProjectResource object
-     */
-    private static Resource createProject(Project o) {
-        ProjectResource projectResource = new ProjectResource();
-        if (o != null){
-            projectResource.setId(o.getProject_id());
-            projectResource.setName(o.getProject_name());
-            GatewayResource gatewayResource = 
(GatewayResource)createGateway(o.getGateway());
-            projectResource.setGateway(gatewayResource);
-            Gateway_Worker gateway_worker = new Gateway_Worker();
-            gateway_worker.setGateway(o.getGateway());
-            gateway_worker.setUser(o.getUsers());
-            gateway_worker.setUser_name(o.getUsers().getUser_name());
-            WorkerResource workerResource = (WorkerResource) 
createGatewayWorker(gateway_worker);
-            projectResource.setWorker(workerResource);
-            projectResource.setDescription(o.getDescription());
-            projectResource.setCreationTime(o.getCreationTime());
-        }
-
-        return projectResource;
-    }
-
-    private static Resource createProjectUser(ProjectUser o) {
-        ProjectUserResource projectUserResource = new ProjectUserResource();
-        if (o != null){
-            projectUserResource.setUserName(o.getUser().getUser_name());
-            projectUserResource.setProjectId(o.getProjectId());
-        }
-        return projectUserResource;
-    }
-
-    /**
-     *
-     * @param o configuration model object
-     * @return configuration resource object
-     */
-    private static Resource createConfiguration (Configuration o){
-        ConfigurationResource configurationResource = new 
ConfigurationResource();
-        if (o != null){
-            configurationResource.setConfigKey(o.getConfig_key());
-            configurationResource.setConfigVal(o.getConfig_val());
-            configurationResource.setExpireDate(o.getExpire_date());
-            configurationResource.setCategoryID(o.getCategory_id());
-        }
-
-        return configurationResource;
-    }
-
-    /**
-     *
-     * @param o Gateway_Worker model object
-     * @return  Gateway_Worker resource object
-     */
-    private static Resource createGatewayWorker(Gateway_Worker o) {
-        if (o != null){
-            GatewayResource gatewayResource = new 
GatewayResource(o.getGateway().getGateway_id());
-            gatewayResource.setDomain(o.getGateway().getGateway_name());
-            gatewayResource.setDomain(o.getGateway().getDomain());
-            gatewayResource.setEmailAddress(o.getGateway().getEmailAddress());
-            return new WorkerResource(o.getUser_name(), gatewayResource);
-        }
-        return null;
-    }
-
-    /**
-     *
-     * @param o  Users model object
-     * @return  UserResource object
-     */
-    private static Resource createUser(Users o) {
-        UserResource userResource = new UserResource();
-        if (o != null){
-            userResource.setUserName(o.getUser_name());
-            userResource.setPassword(o.getPassword());
-        }
-
-        return userResource;
-    }
-
-    /**
-     * @param o Experiment model object
-     * @return  Experiment resource object
-     */
-    private static Resource createExperiment(Experiment o) {
-        ExperimentResource experimentResource = new ExperimentResource();
-        if (o != null){
-            GatewayResource gatewayResource = 
(GatewayResource)createGateway(o.getGateway());
-            experimentResource.setGateway(gatewayResource);
-            experimentResource.setExecutionUser(o.getExecutionUser());
-            if (o.getProject() != null){
-                ProjectResource projectResource = 
(ProjectResource)createProject(o.getProject());
-                experimentResource.setProject(projectResource);
-            }
-            experimentResource.setExpID(o.getExpId());
-            experimentResource.setExpName(o.getExpName());
-            experimentResource.setCreationTime(o.getCreationTime());
-            experimentResource.setDescription(o.getExpDesc());
-            experimentResource.setApplicationId(o.getApplicationId());
-            experimentResource.setApplicationVersion(o.getAppVersion());
-            
experimentResource.setWorkflowTemplateId(o.getWorkflowTemplateId());
-            
experimentResource.setWorkflowTemplateVersion(o.getWorkflowTemplateVersion());
-            
experimentResource.setWorkflowExecutionId(o.getWorkflowExecutionId());
-            
experimentResource.setEnableEmailNotifications(o.isAllowNotification());
-            
experimentResource.setGatewayExecutionId(o.getGatewayExecutionId());
-        }
-
-        return experimentResource;
-    }
-
-    private static Resource createNotificationEmail (Notification_Email o){
-        NotificationEmailResource emailResource = new 
NotificationEmailResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            emailResource.setExperimentResource(experimentResource);
-            TaskDetailResource taskDetailResource =  
(TaskDetailResource)createTaskDetail(o.getTaskDetail());
-            emailResource.setTaskDetailResource(taskDetailResource);
-            emailResource.setEmailAddress(o.getEmailAddress());
-        }
-        return emailResource;
-    }
-
-    private static Resource createExperimentInput (Experiment_Input o){
-        ExperimentInputResource eInputResource = new ExperimentInputResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            eInputResource.setExperimentResource(experimentResource);
-            eInputResource.setDataType(o.getDataType());
-            eInputResource.setMetadata(o.getMetadata());
-            eInputResource.setExperimentKey(o.getEx_key());
-            eInputResource.setAppArgument(o.getAppArgument());
-            eInputResource.setInputOrder(o.getInputOrder());
-            eInputResource.setStandardInput(o.isStandardInput());
-            eInputResource.setUserFriendlyDesc(o.getUserFriendlyDesc());
-            eInputResource.setRequired(o.isRequired());
-            eInputResource.setRequiredToCMD(o.isRequiredToCMD());
-            eInputResource.setDataStaged(o.isDataStaged());
-
-            if (o.getValue() != null){
-                eInputResource.setValue(new String(o.getValue()));
-            }
-
-        }
-        return eInputResource;
-    }
-
-    private static Resource createExperimentOutput (Experiment_Output o){
-        ExperimentOutputResource eOutputResource = new 
ExperimentOutputResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            eOutputResource.setExperimentResource(experimentResource);
-            eOutputResource.setExperimentKey(o.getEx_key());
-            if (o.getValue() != null){
-                eOutputResource.setValue(new String(o.getValue()));
-            }
-            eOutputResource.setDataType(o.getDataType());
-            eOutputResource.setRequired(o.isRequired());
-            eOutputResource.setRequiredToCMD(o.isRequiredToCMD());
-            eOutputResource.setDataMovement(o.isDataMovement());
-            eOutputResource.setDataNameLocation(o.getDataNameLocation());
-            eOutputResource.setSearchQuery(o.getSearchQuery());
-            eOutputResource.setAppArgument(o.getApplicationArgument());
-        }
-        return eOutputResource;
-    }
-
-    private static Resource createWorkflowNodeDetail (WorkflowNodeDetail o){
-        WorkflowNodeDetailResource nodeDetailResource = new 
WorkflowNodeDetailResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            nodeDetailResource.setExperimentResource(experimentResource);
-            nodeDetailResource.setCreationTime(o.getCreationTime());
-            nodeDetailResource.setNodeInstanceId(o.getNodeId());
-            nodeDetailResource.setNodeName(o.getNodeName());
-            nodeDetailResource.setExecutionUnit(o.getExecutionUnit());
-            nodeDetailResource.setExecutionUnitData(o.getExecutionUnitData());
-
-        }
-        return nodeDetailResource;
-    }
-
-    private static Resource createTaskDetail(TaskDetail o){
-        TaskDetailResource taskDetailResource = new TaskDetailResource();
-        if ( o != null){
-            WorkflowNodeDetailResource nodeDetailResource = 
(WorkflowNodeDetailResource)createWorkflowNodeDetail(o.getNodeDetail());
-            
taskDetailResource.setWorkflowNodeDetailResource(nodeDetailResource);
-            taskDetailResource.setCreationTime(o.getCreationTime());
-            taskDetailResource.setTaskId(o.getTaskId());
-            taskDetailResource.setApplicationId(o.getAppId());
-            taskDetailResource.setApplicationVersion(o.getAppVersion());
-            
taskDetailResource.setApplicationDeploymentId(o.getApplicationDeploymentId());
-            
taskDetailResource.setEnableEmailNotifications(o.isAllowNotification());
-        }
-        return taskDetailResource;
-    }
-
-    private static Resource createErrorDetail (ErrorDetail o){
-        ErrorDetailResource errorDetailResource = new ErrorDetailResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            errorDetailResource.setExperimentResource(experimentResource);
-            if (o.getTask() != null){
-                TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-                errorDetailResource.setTaskDetailResource(taskDetailResource);
-            }
-            if (o.getNodeDetails() != null){
-                WorkflowNodeDetailResource nodeDetailResource = 
(WorkflowNodeDetailResource)createWorkflowNodeDetail(o.getNodeDetails());
-                errorDetailResource.setNodeDetail(nodeDetailResource);
-            }
-            errorDetailResource.setErrorId(o.getErrorId());
-            errorDetailResource.setJobId(o.getJobId());
-            errorDetailResource.setCreationTime(o.getCreationTime());
-            if (o.getActualErrorMsg() != null){
-                errorDetailResource.setActualErrorMsg(new 
String(o.getActualErrorMsg()));
-            }
-            
errorDetailResource.setUserFriendlyErrorMsg(o.getUserFriendlyErrorMsg());
-            
errorDetailResource.setTransientPersistent(o.isTransientPersistent());
-            errorDetailResource.setErrorCategory(o.getErrorCategory());
-            errorDetailResource.setCorrectiveAction(o.getCorrectiveAction());
-            errorDetailResource.setActionableGroup(o.getActionableGroup());
-        }
-
-        return errorDetailResource;
-    }
-
-    private static Resource createApplicationInput (ApplicationInput o){
-        ApplicationInputResource inputResource = new 
ApplicationInputResource();
-        if (o != null){
-            TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-            inputResource.setTaskDetailResource(taskDetailResource);
-            inputResource.setInputKey(o.getInputKey());
-            inputResource.setDataType(o.getDataType());
-            inputResource.setAppArgument(o.getAppArgument());
-            inputResource.setInputOrder(o.getInputOrder());
-            inputResource.setStandardInput(o.isStandardInput());
-            inputResource.setUserFriendlyDesc(o.getUserFriendlyDesc());
-            inputResource.setRequired(o.isRequired());
-            inputResource.setRequiredToCMD(o.isRequiredToCMD());
-            inputResource.setDataStaged(o.isDataStaged());
-            if (o.getValue() != null){
-                inputResource.setValue(new String(o.getValue()));
-            }
-            inputResource.setMetadata(o.getMetadata());
-        }
-        return inputResource;
-    }
-
-    private static Resource createApplicationOutput (ApplicationOutput o){
-        ApplicationOutputResource outputResource = new 
ApplicationOutputResource();
-        if (o != null){
-            TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-            outputResource.setTaskDetailResource(taskDetailResource);
-            outputResource.setDataType(o.getDataType());
-            outputResource.setOutputKey(o.getOutputKey());
-            if (o.getValue() != null){
-                outputResource.setValue(new String(o.getValue()));
-            }
-            outputResource.setRequired(o.isRequired());
-            outputResource.setRequiredToCMD(o.isAddedToCmd());
-            outputResource.setDataMovement(o.isDataMovement());
-            outputResource.setDataNameLocation(o.getDataNameLocation());
-            outputResource.setSearchQuery(o.getSearchQuery());
-            outputResource.setAppArgument(o.getApplicationArgument());
-        }
-        return outputResource;
-    }
-
-    private static Resource createNodeInput (NodeInput o){
-        NodeInputResource inputResource = new NodeInputResource();
-        if (o != null){
-            WorkflowNodeDetailResource nodeDetailResource = 
(WorkflowNodeDetailResource)createWorkflowNodeDetail(o.getNodeDetails());
-            inputResource.setNodeDetailResource(nodeDetailResource);
-            inputResource.setInputKey(o.getInputKey());
-            inputResource.setDataType(o.getDataType());
-            inputResource.setValue(o.getValue());
-            inputResource.setMetadata(o.getMetadata());
-            inputResource.setAppArgument(o.getAppArgument());
-            inputResource.setInputOrder(o.getInputOrder());
-            inputResource.setStandardInput(o.isStandardInput());
-            inputResource.setUserFriendlyDesc(o.getUserFriendlyDesc());
-            inputResource.setRequired(o.getIsRequired());
-            inputResource.setRequiredToCMD(o.getRequiredToCMD());
-            inputResource.setDataStaged(o.isDataStaged());
-        }
-        return inputResource;
-    }
-
-    private static Resource createNodeOutput (NodeOutput o){
-        NodeOutputResource outputResource = new NodeOutputResource();
-        if (o != null){
-            WorkflowNodeDetailResource nodeDetailResource = 
(WorkflowNodeDetailResource)createWorkflowNodeDetail(o.getNode());
-            outputResource.setNodeDetailResource(nodeDetailResource);
-            outputResource.setDataType(o.getDataType());
-            outputResource.setOutputKey(o.getOutputKey());
-            outputResource.setValue(o.getValue());
-            outputResource.setRequired(o.isRequired());
-            outputResource.setRequiredToCMD(o.isRequiredToCMD());
-            outputResource.setDataMovement(o.isDataMovement());
-            outputResource.setDataNameLocation(o.getDataNameLocation());
-            outputResource.setSearchQuery(o.getSearchQuery());
-            outputResource.setAppArgument(o.getApplicationArgument());
-        }
-
-        return outputResource;
-    }
-
-    private static Resource createJobDetail (JobDetail o){
-        JobDetailResource jobDetailResource = new JobDetailResource();
-        if (o != null){
-            TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-            jobDetailResource.setTaskDetailResource(taskDetailResource);
-            if (o.getJobDescription() != null){
-                jobDetailResource.setJobDescription(new 
String(o.getJobDescription()));
-            }
-            jobDetailResource.setJobId(o.getJobId());
-            jobDetailResource.setCreationTime(o.getCreationTime());
-            
jobDetailResource.setComputeResourceConsumed(o.getComputeResourceConsumed());
-            jobDetailResource.setJobName(o.getJobName());
-            jobDetailResource.setWorkingDir(o.getWorkingDir());
-
-        }
-
-        return jobDetailResource;
-    }
-
-    private static Resource createDataTransferResource (DataTransferDetail o){
-        DataTransferDetailResource transferDetailResource = new 
DataTransferDetailResource();
-        if (o != null){
-            TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-            transferDetailResource.setTaskDetailResource(taskDetailResource);
-            transferDetailResource.setTransferId(o.getTransferId());
-            transferDetailResource.setCreationTime(o.getCreationTime());
-            if (o.getTransferDesc() != null){
-                transferDetailResource.setTransferDescription(new 
String(o.getTransferDesc()));
-            }
-
-        }
-        return transferDetailResource;
-    }
-
-    private static Resource createStatusResource (Status o){
-        StatusResource statusResource = new StatusResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            statusResource.setExperimentResource(experimentResource);
-            if (o.getTask() != null){
-                TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-                statusResource.setTaskDetailResource(taskDetailResource);
-            }
-            if (o.getNode() != null){
-                WorkflowNodeDetailResource nodeDetailResource = 
(WorkflowNodeDetailResource)createWorkflowNodeDetail(o.getNode());
-                statusResource.setWorkflowNodeDetail(nodeDetailResource);
-            }
-            if (o.getTransferDetail() != null){
-                DataTransferDetailResource transferDetailResource = 
(DataTransferDetailResource)createDataTransferResource(o.getTransferDetail());
-                statusResource.setDataTransferDetail(transferDetailResource);
-            }
-            statusResource.setStatusId(o.getStatusId());
-            statusResource.setJobId(o.getJobId());
-            statusResource.setState(o.getState());
-            statusResource.setStatusUpdateTime(o.getStatusUpdateTime());
-            statusResource.setStatusType(o.getStatusType());
-        }
-
-        return statusResource;
-    }
-
-    private static Resource createExConfigDataResource (ExperimentConfigData 
o){
-        ConfigDataResource configDataResource = new ConfigDataResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            configDataResource.setExperimentResource(experimentResource);
-            
configDataResource.setAiravataAutoSchedule(o.isAiravataAutoSchedule());
-            
configDataResource.setOverrideManualParams(o.isOverrideManualParams());
-            configDataResource.setShareExp(o.isShareExp());
-            configDataResource.setUserDn(o.getUserDn());
-            configDataResource.setGenerateCert(o.isGenerateCert());
-        }
-        return configDataResource;
-    }
-
-    private static Resource createComputationalScheduling 
(Computational_Resource_Scheduling o){
-        ComputationSchedulingResource schedulingResource = new 
ComputationSchedulingResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            schedulingResource.setExperimentResource(experimentResource);
-            if (o.getTask() != null){
-                TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-                schedulingResource.setTaskDetailResource(taskDetailResource);
-            }
-            schedulingResource.setSchedulingId(o.getSchedulingId());
-            schedulingResource.setResourceHostId(o.getResourceHostId());
-            schedulingResource.setCpuCount(o.getCpuCount());
-            schedulingResource.setNodeCount(o.getNodeCount());
-            schedulingResource.setNumberOfThreads(o.getNumberOfThreads());
-            schedulingResource.setQueueName(o.getQueueName());
-            schedulingResource.setWalltimeLimit(o.getWallTimeLimit());
-            schedulingResource.setJobStartTime(o.getJobStartTime());
-            schedulingResource.setPhysicalMemory(o.getTotalPhysicalmemory());
-            schedulingResource.setProjectName(o.getProjectName());
-            schedulingResource.setChessisName(o.getChessisName());
-        }
-
-        return schedulingResource;
-    }
-
-    private static Resource createAdvancedInputDataResource 
(AdvancedInputDataHandling o){
-        AdvanceInputDataHandlingResource dataHandlingResource = new 
AdvanceInputDataHandlingResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            dataHandlingResource.setExperimentResource(experimentResource);
-            if (o.getTask() != null){
-                TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-                dataHandlingResource.setTaskDetailResource(taskDetailResource);
-            }
-            dataHandlingResource.setDataHandlingId(o.getDataHandlingId());
-            dataHandlingResource.setWorkingDirParent(o.getParentWorkingDir());
-            dataHandlingResource.setWorkingDir(o.getWorkingDir());
-            
dataHandlingResource.setStageInputFiles(o.isStageInputsToWorkingDir());
-            dataHandlingResource.setCleanAfterJob(o.isCleanAfterJob());
-        }
-
-        return dataHandlingResource;
-    }
-
-    private static Resource createAdvancedOutputDataResource 
(AdvancedOutputDataHandling o){
-        AdvancedOutputDataHandlingResource dataHandlingResource = new 
AdvancedOutputDataHandlingResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            dataHandlingResource.setExperimentResource(experimentResource);
-            if (o.getTask() != null){
-                TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-                dataHandlingResource.setTaskDetailResource(taskDetailResource);
-            }
-            
dataHandlingResource.setOutputDataHandlingId(o.getOutputDataHandlingId());
-            dataHandlingResource.setOutputDataDir(o.getOutputDataDir());
-            dataHandlingResource.setDataRegUrl(o.getDataRegUrl());
-            dataHandlingResource.setPersistOutputData(o.isPersistOutputData());
-        }
-        return dataHandlingResource;
-    }
-
-    private static Resource createQosParamResource (QosParam o){
-        QosParamResource qosParamResource = new QosParamResource();
-        if (o != null){
-            ExperimentResource experimentResource = 
(ExperimentResource)createExperiment(o.getExperiment());
-            qosParamResource.setExperimentResource(experimentResource);
-            if (o.getTask() != null){
-                TaskDetailResource taskDetailResource = 
(TaskDetailResource)createTaskDetail(o.getTask());
-                qosParamResource.setTaskDetailResource(taskDetailResource);
-            }
-            qosParamResource.setQosId(o.getQosId());
-            qosParamResource.setExecuteBefore(o.getExecuteBefore());
-            qosParamResource.setStartExecutionAt(o.getStartExecutionAt());
-            qosParamResource.setNoOfRetries(o.getNoOfRetries());
-        }
-
-        return qosParamResource;
-    }
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
----------------------------------------------------------------------
diff --git 
a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
 
b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
deleted file mode 100644
index fbf7855..0000000
--- 
a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkerResource.java
+++ /dev/null
@@ -1,908 +0,0 @@
-/*
- *
- * 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.model.workspace.experiment.ExperimentState;
-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.ResultOrderType;
-import org.apache.airavata.registry.cpi.utils.Constants;
-import org.apache.airavata.registry.cpi.utils.StatusType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.airavata.registry.cpi.RegistryException;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-public class WorkerResource extends AbstractResource {
-    private final static Logger logger = 
LoggerFactory.getLogger(WorkerResource.class);
-    private String user;
-       private GatewayResource gateway;
-
-    /**
-     *
-     */
-    public WorkerResource() {
-    }
-
-    /**
-     *
-     * @param user username
-     * @param gateway  gatewayResource
-     */
-    public WorkerResource(String user, GatewayResource gateway) {
-               this.setUser(user);
-               this.gateway=gateway;
-       }
-
-    /**
-     * Gateway worker can create child data structures such as projects and 
user workflows
-     * @param type child resource type
-     * @return  child resource
-     */
-       public Resource create(ResourceType type) throws RegistryException{
-               Resource result = null;
-               switch (type) {
-                       case PROJECT:
-                               ProjectResource projectResource = new 
ProjectResource();
-                               projectResource.setWorker(this);
-                               projectResource.setGateway(gateway);
-                               result=projectResource;
-                               break;
-            case EXPERIMENT:
-                ExperimentResource experimentResource = new 
ExperimentResource();
-                experimentResource.setExecutionUser(user);
-                experimentResource.setGateway(gateway);
-                result = experimentResource;
-                break;
-                       default:
-                logger.error("Unsupported resource type for worker resource.", 
new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type 
for worker resource.");
-
-               }
-               return result;
-       }
-
-    /**
-     *
-     * @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();
-            Query q;
-            QueryGenerator generator;
-            switch (type) {
-                case PROJECT:
-                    generator = new QueryGenerator(PROJECT);
-                    generator.setParameter(ProjectConstants.PROJECT_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case EXPERIMENT:
-                    generator = new QueryGenerator(EXPERIMENT);
-                    generator.setParameter(ExperimentConstants.EXPERIMENT_ID, 
name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                default:
-                    logger.error("Unsupported resource type for worker 
resource.", new IllegalArgumentException());
-                    break;
-            }
-            em.getTransaction().commit();
-            em.close();
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RegistryException(e.getMessage());
-        } 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{
-        Resource result = null;
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            QueryGenerator generator;
-            Query q;
-            switch (type) {
-                case PROJECT:
-                    generator = new QueryGenerator(PROJECT);
-                    generator.setParameter(ProjectConstants.PROJECT_ID, name);
-                    q = generator.selectQuery(em);
-                    Project project = (Project) q.getSingleResult();
-                    result = Utils.getResource(ResourceType.PROJECT, project);
-                    break;
-                case EXPERIMENT:
-                    generator = new QueryGenerator(EXPERIMENT);
-                    generator.setParameter(ExperimentConstants.EXPERIMENT_ID, 
name);
-                    q = generator.selectQuery(em);
-                    Experiment experiment = (Experiment) q.getSingleResult();
-                    result = Utils.getResource(ResourceType.EXPERIMENT, 
experiment);
-                    break;
-                default:
-                    logger.error("Unsupported resource type for worker 
resource.", new IllegalArgumentException());
-                    break;
-            }
-            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 result;
-    }
-
-//     public List<GFacJobDataResource> getGFacJobs(String 
serviceDescriptionId, String hostDescriptionId, String 
applicationDescriptionId){
-//             List<GFacJobDataResource> result = new 
ArrayList<GFacJobDataResource>();
-//        EntityManager em = ResourceUtils.getEntityManager();
-//        em.getTransaction().begin();
-//        QueryGenerator generator;
-//        Query q;
-//        generator = new QueryGenerator(GFAC_JOB_DATA);
-//        generator.setParameter(GFacJobDataConstants.SERVICE_DESC_ID, 
serviceDescriptionId);
-//        generator.setParameter(GFacJobDataConstants.HOST_DESC_ID, 
hostDescriptionId);
-//        generator.setParameter(GFacJobDataConstants.APP_DESC_ID, 
applicationDescriptionId);
-//        q = generator.selectQuery(em);
-//        for (Object o : q.getResultList()) {
-//            GFac_Job_Data gFacJobData = (GFac_Job_Data)o;
-//            
result.add((GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA, 
gFacJobData));
-//        }
-//        em.getTransaction().commit();
-//        em.close();
-//             return result;
-//     }
-//
-//     public List<GFacJobStatusResource> getGFacJobStatuses(String jobId){
-//             List<GFacJobStatusResource> resourceList = new 
ArrayList<GFacJobStatusResource>();
-//        EntityManager em = ResourceUtils.getEntityManager();
-//        em.getTransaction().begin();
-//        QueryGenerator generator;
-//        Query q;
-//        generator = new QueryGenerator(GFAC_JOB_STATUS);
-//        generator.setParameter(GFacJobStatusConstants.LOCAL_JOB_ID, jobId);
-//        q = generator.selectQuery(em);
-//        for (Object result : q.getResultList()) {
-//            GFac_Job_Status gFacJobStatus = (GFac_Job_Status) result;
-//            GFacJobStatusResource gFacJobStatusResource =
-//                    
(GFacJobStatusResource)Utils.getResource(ResourceType.GFAC_JOB_STATUS, 
gFacJobStatus);
-//            resourceList.add(gFacJobStatusResource);
-//        }
-//        return resourceList;
-//     }
-
-    /**
-     * Method getExperiment all results of the given child resource type
-     *
-     * @param type child resource type
-     * @return list of child resources
-     */
-    public List<Resource> get(ResourceType type) throws RegistryException{
-        return get(type, -1, -1, null, null);
-    }
-
-    /**
-     * Method getExperiment all results of the given child resource type with 
paginaltion and ordering
-     *
-     * @param type child resource type
-     * @param limit
-     * @param offset
-     * @param orderByIdentifier
-     * @param resultOrderType
-     * @return list of child resources
-     * @throws RegistryException
-     */
-    public List<Resource> get(ResourceType type, int limit, int offset, Object 
orderByIdentifier,
-                              ResultOrderType resultOrderType) throws 
RegistryException{
-        List<Resource> result = new ArrayList<Resource>();
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            QueryGenerator generator;
-            Query q;
-            switch (type) {
-                case PROJECT:
-                    generator = new QueryGenerator(PROJECT);
-                    Users users = em.find(Users.class, getUser());
-                    Gateway gatewayModel = em.find(Gateway.class, 
gateway.getGatewayId());
-                    generator.setParameter("users", users);
-                    generator.setParameter("gateway", gatewayModel);
-
-                    //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);
-                    }
-
-                    for (Object o : q.getResultList()) {
-                        Project project = (Project) o;
-                        ProjectResource projectResource = (ProjectResource) 
Utils.getResource(ResourceType.PROJECT, project);
-                        result.add(projectResource);
-                    }
-                    break;
-                case EXPERIMENT:
-                    generator = new QueryGenerator(EXPERIMENT);
-                    generator.setParameter(ExperimentConstants.EXECUTION_USER, 
getUser());
-
-                    //ordering - only supported only by CREATION_TIME
-                    if(orderByIdentifier != null && resultOrderType != null
-                            && 
orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.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);
-                    }
-                    for (Object o : q.getResultList()) {
-                        Experiment experiment = (Experiment) o;
-                        ExperimentResource experimentResource = 
(ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                        result.add(experimentResource);
-                    }
-
-                    break;
-                default:
-                    logger.error("Unsupported resource type for worker 
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();
-            }
-        }
-        return result;
-    }
-
-    /**
-     * saveExperiment gateway worker to database
-     */
-       public void save() throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new 
Gateway_Worker_PK(gateway.getGatewayId(), user));
-            em.close();
-
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Gateway_Worker gatewayWorker = new Gateway_Worker();
-            Users existingUser = em.find(Users.class, this.user);
-            gatewayWorker.setUser(existingUser);
-            gatewayWorker.setUser_name(existingUser.getUser_name());
-            Gateway gatewaymodel = em.find(Gateway.class, 
gateway.getGatewayId());
-            gatewayWorker.setGateway(gatewaymodel);
-            gatewayWorker.setGateway_id(gatewaymodel.getGateway_id());
-            if (existingWorker != null) {
-                existingWorker.setUser_name(existingUser.getUser_name());
-                existingWorker.setUser(existingUser);
-                existingWorker.setGateway(gatewaymodel);
-                existingWorker.setGateway_id(gatewaymodel.getGateway_id());
-                gatewayWorker = em.merge(existingWorker);
-            } else {
-                em.persist(gatewayWorker);
-            }
-            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();
-            }
-        }
-    }
-
-    /**
-     *
-     * @return user name
-     */
-       public String getUser() {
-               return user;
-       }
-
-    /**
-     *
-     * @param user user name
-     */
-    public void setUser(String user) {
-               this.user = user;
-       }
-
-    /**
-     *
-     * @return gateway resource
-     */
-    public GatewayResource getGateway() {
-        return gateway;
-    }
-
-    /**
-     *
-     * @param gateway  gateway resource
-     */
-    public void setGateway(GatewayResource gateway) {
-        this.gateway = gateway;
-    }
-
-    /**
-     *
-     * @param id  project id
-     * @return whether the project is available under the user
-     */
-    public boolean isProjectExists(String id) throws RegistryException{
-               return isExists(ResourceType.PROJECT, id);
-       }
-
-    /**
-     *
-     * @param projectId project id
-     * @return project resource for the user
-     */
-       public ProjectResource createProject(String projectId) throws 
RegistryException{
-               ProjectResource 
project=(ProjectResource)create(ResourceType.PROJECT);
-        project.setId(projectId);
-               return project;
-       }
-
-    public String getProjectId(String projectName) {
-        String pro = projectName.replaceAll("\\s", "");
-        return pro + "_" + UUID.randomUUID();
-    }
-
-    /**
-     *
-     * @param id project id
-     * @return project resource
-     */
-       public ProjectResource getProject(String id) throws RegistryException{
-               return (ProjectResource)get(ResourceType.PROJECT, id);
-       }
-
-    /**
-     *
-     * @param id project id
-     */
-       public void removeProject(String id) throws RegistryException{
-               remove(ResourceType.PROJECT, id);
-       }
-
-    /**
-     * Get projects list of user
-     * @return  list of projects for the user
-     */
-    public List<ProjectResource> getProjects() throws RegistryException{
-               return getProjects(-1, -1, null, null);
-       }
-
-
-    /**
-     * Get projects list of user with pagination and ordering
-     *
-     * @return  list of projects for the user
-     */
-    public List<ProjectResource> getProjects(int limit, int offset, Object 
orderByIdentifier,
-                                             ResultOrderType resultOrderType) 
throws RegistryException{
-        List<ProjectResource> result=new ArrayList<ProjectResource>();
-        List<Resource> list = get(ResourceType.PROJECT, limit, offset, 
orderByIdentifier, resultOrderType);
-        for (Resource resource : list) {
-            result.add((ProjectResource) resource);
-        }
-        return result;
-    }
-
-    /**
-     *
-     * @param name experiment name
-     * @return whether experiment is already exist for the given user
-     */
-       public boolean isExperimentExists(String name) throws RegistryException{
-               return isExists(ResourceType.EXPERIMENT, name);
-       }
-       
-
-    /**
-     *
-     * @param name experiment name
-     * @return experiment resource
-     */
-    public ExperimentResource getExperiment(String name) throws 
RegistryException{
-               return (ExperimentResource)get(ResourceType.EXPERIMENT, name);
-       }
-//
-//    public GFacJobDataResource getGFacJob(String jobId){
-//     return 
(GFacJobDataResource)getExperiment(ResourceType.GFAC_JOB_DATA,jobId);
-//    }
-
-    /**
-     * Method to getExperiment list of expeirments of user
-     * @return list of experiments for the user
-     */
-       public List<ExperimentResource> getExperiments() throws 
RegistryException{
-               return getExperiments(-1, -1, null, null);
-       }
-
-    /**
-     * Method to getExperiment list of experiments of user with pagination and 
ordering
-     * @param limit
-     * @param offset
-     * @param orderByIdentifier
-     * @param resultOrderType
-     * @return
-     * @throws RegistryException
-     */
-    public List<ExperimentResource> getExperiments(int limit, int offset, 
Object orderByIdentifier,
-                                                   ResultOrderType 
resultOrderType) throws RegistryException{
-        List<ExperimentResource> result=new ArrayList<ExperimentResource>();
-        List<Resource> list = get(ResourceType.EXPERIMENT, limit, offset, 
orderByIdentifier, resultOrderType);
-        for (Resource resource : list) {
-            result.add((ExperimentResource) resource);
-        }
-        return result;
-    }
-
-    /**
-     *
-     * @param experimentId  experiment name
-     */
-       public void removeExperiment(String experimentId) throws 
RegistryException{
-               remove(ResourceType.EXPERIMENT, experimentId);
-       }
-
-    /**
-     * To search projects of user with the given filter criteria. All the 
matching results will be sent.
-     * Results are not ordered in any order
-     * @param filters
-     * @return
-     * @throws RegistryException
-     */
-    public List<ProjectResource> searchProjects (Map<String, String> filters) 
throws RegistryException{
-        return searchProjects(filters, -1, -1, null, null);
-    }
-
-    /**
-     * To search the projects of user with the given filter criteria and 
retrieve the results with
-     * pagination support. Results can be ordered based on an identifier (i.e 
column) either ASC or
-     * DESC. But in the current implementation ordering is only supported 
based on the project
-     * creation time
-     *
-     * @param filters
-     * @param limit
-     * @param offset
-     * @param orderByIdentifier
-     * @param resultOrderType
-     * @return
-     * @throws RegistryException
-     */
-    public List<ProjectResource> searchProjects(Map<String, String> filters, 
int limit,
-             int offset, Object orderByIdentifier, ResultOrderType 
resultOrderType) throws RegistryException {
-        List<ProjectResource> result = new ArrayList<ProjectResource>();
-        EntityManager em = null;
-        try {
-            String query = "SELECT p from Project p WHERE ";
-            if (filters != null && filters.size() != 0) {
-                for (String field : filters.keySet()) {
-                    String filterVal = filters.get(field);
-                    if (field.equals(ProjectConstants.USERNAME)) {
-                        query += "p." + field + "= '" + filterVal + "' AND ";
-                    }else if (field.equals(ProjectConstants.GATEWAY_ID)) {
-                        query += "p." + field + "= '" + filterVal + "' AND ";
-                    }else {
-                        if (filterVal.contains("*")){
-                            filterVal = filterVal.replaceAll("\\*", "");
-                        }
-                        query += "p." + field + " LIKE '%" + filterVal + "%' 
AND ";
-                    }
-                }
-            }
-            query = query.substring(0, query.length() - 5);
-
-            //ordering
-            if( orderByIdentifier != null && resultOrderType != null
-                    && 
orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)){
-                String order = (resultOrderType == ResultOrderType.ASC) ? 
"ASC" : "DESC";
-                query += " ORDER BY p." + ProjectConstants.CREATION_TIME + " " 
+ order;
-            }
-
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Query q;
-
-            //pagination
-            if(offset>=0 && limit >=0){
-                q = 
em.createQuery(query).setFirstResult(offset).setMaxResults(limit);
-            }else{
-                q = em.createQuery(query);
-            }
-
-            List resultList = q.getResultList();
-            for (Object o : resultList) {
-                Project project = (Project) o;
-                ProjectResource projectResource =
-                        (ProjectResource) 
Utils.getResource(ResourceType.PROJECT, project);
-                result.add(projectResource);
-            }
-            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();
-            }
-        }
-        return result;
-    }
-
-    /**
-     * To search experiments of user with the given filter criteria. All the 
matching results will be sent.
-     * Results are not ordered in any order
-     * @param filters
-     * @return
-     * @throws RegistryException
-     */
-    public List<ExperimentResource> searchExperiments (Map<String, String> 
filters) throws RegistryException{
-        return searchExperiments(filters, -1, -1, null, null);
-    }
-
-    /**
-     * To search the experiments of user with the given filter criteria and 
retrieve the results with
-     * pagination support. Results can be ordered based on an identifier (i.e 
column) either ASC or
-     * DESC. But in the current implementation ordering is only supported 
based on creationTime
-     *
-     * @param filters
-     * @param limit
-     * @param offset
-     * @param orderByIdentifier
-     * @param resultOrderType
-     * @return
-     * @throws RegistryException
-     */
-    public List<ExperimentResource> searchExperiments(Map<String, String> 
filters, int limit,
-                                                      int offset, Object 
orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
-
-        List<ExperimentResource> result = new ArrayList<ExperimentResource>();
-        EntityManager em = null;
-        try {
-            String query = "SELECT e from Experiment e WHERE ";
-            if (filters != null && filters.size() != 0) {
-                for (String field : filters.keySet()) {
-                    String filterVal = filters.get(field);
-                    if (field.equals(ExperimentConstants.EXECUTION_USER)) {
-                        query += "e." + field + "= '" + filterVal + "' AND ";
-                    }else if (field.equals(ExperimentConstants.GATEWAY_ID)) {
-                        query += "e." + field + "= '" + filterVal + "' AND ";
-                    } else if (field.equals(ExperimentConstants.PROJECT_ID)) {
-                        query += "e." + field + "= '" + filterVal + "' AND ";
-                    } else {
-                        if (filterVal.contains("*")){
-                            filterVal = filterVal.replaceAll("\\*", "");
-                        }
-                        query += "e." + field + " LIKE '%" + filterVal + "%' 
AND ";
-                    }
-                }
-            }
-            query = query.substring(0, query.length() - 5);
-
-            //ordering
-            if( orderByIdentifier != null && resultOrderType != null
-                    && 
orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)){
-                String order = (resultOrderType == ResultOrderType.ASC) ? 
"ASC" : "DESC";
-                query += " ORDER BY e." + ExperimentConstants.CREATION_TIME + 
" " + order;
-            }
-
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Query q;
-
-            //pagination
-            if(offset>=0 && limit >=0){
-                q = 
em.createQuery(query).setFirstResult(offset).setMaxResults(limit);
-            }else{
-                q = em.createQuery(query);
-            }
-
-            List resultList = q.getResultList();
-            for (Object o : resultList) {
-                Experiment experiment = (Experiment) o;
-                ExperimentResource experimentResource =
-                        (ExperimentResource) 
Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                result.add(experimentResource);
-            }
-            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();
-            }
-        }
-        return result;
-    }
-
-    /**
-     * Method to getExperiment experiments by state
-     * @param filters
-     * @return
-     * @throws RegistryException
-     */
-    public List<ExperimentResource> searchExperimentsByState (Map<String, 
String> filters) throws RegistryException{
-        return searchExperimentsByState(filters, -1, -1, null, null);
-    }
-
-    /**
-     * Method to getExperiment experiments of the given state with pagination 
and ordering
-     * @param filters
-     * @param limit
-     * @param offset
-     * @param orderByIdentifier
-     * @param resultOrderType
-     * @return
-     * @throws RegistryException
-     */
-    public List<ExperimentResource> searchExperimentsByState (Map<String, 
String> filters, int limit, int offset,
-            Object orderByIdentifier, ResultOrderType resultOrderType) throws 
RegistryException{
-        List<ExperimentResource> result = new ArrayList<ExperimentResource>();
-        EntityManager em = null;
-        try {
-            String experimentState = 
ExperimentState.valueOf(filters.get(StatusConstants.STATE)).toString();
-            String query = "SELECT e FROM Status s " +
-                    "JOIN s.experiment e " +
-                    "WHERE s.state='" + experimentState +  "' " +
-                    "AND s.statusType='" + StatusType.EXPERIMENT + "' AND ";
-
-            filters.remove(StatusConstants.STATE);
-            if (filters.size() != 0) {
-                for (String field : filters.keySet()) {
-                    String filterVal = filters.get(field);
-                    if (field.equals(ExperimentConstants.EXECUTION_USER)) {
-                        query += "e." + field + "= '" + filterVal + "' AND ";
-                    }else if (field.equals(ExperimentConstants.GATEWAY_ID)) {
-                        query += "e." + field + "= '" + filterVal + "' AND ";
-                    } else if (field.equals(ExperimentConstants.PROJECT_ID)) {
-                        query += "e." + field + "= '" + filterVal + "' AND ";
-                    } else {
-                        if (filterVal.contains("*")){
-                            filterVal = filterVal.replaceAll("\\*", "");
-                        }
-                        query += "e." + field + " LIKE '%" + filterVal + "%' 
AND ";
-                    }
-                }
-            }
-            query = query.substring(0, query.length() - 5);
-
-            //ordering
-            if( orderByIdentifier != null && resultOrderType != null
-                    && 
orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)){
-                String order = (resultOrderType == ResultOrderType.ASC) ? 
"ASC" : "DESC";
-                query += " ORDER BY e." + ExperimentConstants.CREATION_TIME + 
" " + order;
-            }
-
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Query q;
-
-            //pagination
-            if(offset>=0 && limit >=0){
-                q = 
em.createQuery(query).setFirstResult(offset).setMaxResults(limit);
-            }else{
-                q = em.createQuery(query);
-            }
-
-            List resultList = q.getResultList();
-            for (Object o : resultList) {
-                Experiment experiment = (Experiment) o;
-                ExperimentResource experimentResource = (ExperimentResource) 
Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                result.add(experimentResource);
-            }
-            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();
-            }
-        }
-        return result;
-    }
-
-    /**
-     * Search experiments from creation time between interval. Returns all 
results
-     * @param fromTime
-     * @param toTime
-     * @return
-     * @throws RegistryException
-     */
-    public List<ExperimentResource> searchExperimentsByCreationTime (Timestamp 
fromTime, Timestamp toTime) throws RegistryException{
-        return  searchExperimentsByCreationTime(fromTime, toTime, -1, -1, 
null, null);
-    }
-
-
-    /**
-     * Search experiments from creation time between interval. Results are 
ordered creation time DESC.
-     * Supports pagination
-     *
-     * @param fromTime
-     * @param toTime
-     * @param limit
-     * @param offset
-     * @param orderByIdentifier
-     * @param resultOrderType
-     * @return
-     * @throws RegistryException
-     */
-    public List<ExperimentResource> searchExperimentsByCreationTime(
-            Timestamp fromTime, Timestamp toTime, int limit, int offset, 
Object orderByIdentifier,
-            ResultOrderType resultOrderType) throws RegistryException{
-
-        List<ExperimentResource> result = new ArrayList<ExperimentResource>();
-        EntityManager em = null;
-        try {
-            String query = "SELECT e FROM Experiment e " +
-                    "WHERE e.creationTime > '" + fromTime +  "' " +
-                    "AND e.creationTime <'" + toTime + "'";
-
-            //ordering
-            if( orderByIdentifier != null && resultOrderType != null
-                    && 
orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)){
-                String order = (resultOrderType == ResultOrderType.ASC) ? 
"ASC" : "DESC";
-                query += " ORDER BY e." + ExperimentConstants.CREATION_TIME + 
" " + order;
-            }
-
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            Query q;
-
-            //pagination
-            if(offset>=0 && limit >=0){
-                q = 
em.createQuery(query).setFirstResult(offset).setMaxResults(limit);
-            }else{
-                q = em.createQuery(query);
-            }
-
-            List resultList = q.getResultList();
-            for (Object o : resultList) {
-                Experiment experiment = (Experiment) o;
-                ExperimentResource experimentResource = (ExperimentResource) 
Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                result.add(experimentResource);
-            }
-            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();
-            }
-        }
-        return result;
-    }
-
-    /**
-     *
-     * @return list of experiments for the user
-     */
-    public List<ExperimentResource> getExperimentsByCaching(String user) 
throws RegistryException{
-        List<ExperimentResource> result = new ArrayList<ExperimentResource>();
-        EntityManager em = null;
-        try {
-            String query = "SELECT e from Experiment e WHERE e.executionUser = 
'" + user + "'";
-            em = ResourceUtils.getEntityManager();
-//        OpenJPAEntityManagerFactory oemf = 
OpenJPAPersistence.cast(em.getEntityManagerFactory());
-//        QueryResultCache qcache = oemf.getQueryResultCache();
-            // qcache.evictAll(Experiment.class);
-            em.getTransaction().begin();
-            Query q = em.createQuery(query);
-            List resultList = q.getResultList();
-            for (Object o : resultList) {
-                Experiment experiment = (Experiment) o;
-                ExperimentResource experimentResource = (ExperimentResource) 
Utils.getResource(ResourceType.EXPERIMENT, experiment);
-                result.add(experimentResource);
-            }
-            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();
-            }
-        }
-        return result;
-    }
-}

Reply via email to