airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [31/44] airavata git commit: Mongo Registry WIP
Date Sun, 07 Jun 2015 17:01:12 GMT
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/WorkflowNodeDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
deleted file mode 100644
index 9d2869d..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/WorkflowNodeDetailResource.java
+++ /dev/null
@@ -1,473 +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.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.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;
-
-public class WorkflowNodeDetailResource extends AbstractResource {
-    private static final Logger logger = LoggerFactory.getLogger(WorkflowNodeDetailResource.class);
-    private ExperimentResource experimentResource;
-    private String nodeInstanceId;
-    private Timestamp creationTime;
-    private String nodeName;
-    private String executionUnit;
-    private String executionUnitData;
-
-    public ExperimentResource getExperimentResource() {
-        return experimentResource;
-    }
-
-    public void setExperimentResource(ExperimentResource experimentResource) {
-        this.experimentResource = experimentResource;
-    }
-
-    public String getNodeInstanceId() {
-        return nodeInstanceId;
-    }
-
-    public void setNodeInstanceId(String nodeInstanceId) {
-        this.nodeInstanceId = nodeInstanceId;
-    }
-
-    public Timestamp getCreationTime() {
-        return creationTime;
-    }
-
-    public void setCreationTime(Timestamp creationTime) {
-        this.creationTime = creationTime;
-    }
-
-    public String getNodeName() {
-        return nodeName;
-    }
-
-    public void setNodeName(String nodeName) {
-        this.nodeName = nodeName;
-    }
-
-    public Resource create(ResourceType type) throws RegistryException{
-        switch (type){
-            case TASK_DETAIL:
-                TaskDetailResource taskDetailResource = new TaskDetailResource();
-                taskDetailResource.setWorkflowNodeDetailResource(this);
-                return taskDetailResource;
-            case ERROR_DETAIL:
-                ErrorDetailResource errorDetailResource = new ErrorDetailResource();
-                errorDetailResource.setNodeDetail(this);
-                return errorDetailResource;
-            case NODE_INPUT:
-                NodeInputResource nodeInputResource = new NodeInputResource();
-                nodeInputResource.setNodeDetailResource(this);
-                return nodeInputResource;
-            case NODE_OUTPUT:
-                NodeOutputResource nodeOutputResource = new NodeOutputResource();
-                nodeOutputResource.setNodeDetailResource(this);
-                return nodeOutputResource;
-            case STATUS:
-                StatusResource statusResource = new StatusResource();
-                statusResource.setWorkflowNodeDetail(this);
-                return statusResource;
-            default:
-                logger.error("Unsupported resource type for workflow node detail resource.", new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported resource type for workflow node detail resource.");
-        }
-    }
-
-    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 TASK_DETAIL:
-                    generator = new QueryGenerator(TASK_DETAIL);
-                    generator.setParameter(TaskDetailConstants.TASK_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case ERROR_DETAIL:
-                    generator = new QueryGenerator(ERROR_DETAIL);
-                    generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case NODE_INPUT:
-                    generator = new QueryGenerator(NODE_INPUT);
-                    generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case NODE_OUTPUT:
-                    generator = new QueryGenerator(NODE_OUTPUT);
-                    generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                case STATUS:
-                    generator = new QueryGenerator(STATUS);
-                    generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
-                    generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.WORKFLOW_NODE.toString());
-                    q = generator.deleteQuery(em);
-                    q.executeUpdate();
-                    break;
-                default:
-                    logger.error("Unsupported resource type for experiment 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 TASK_DETAIL:
-                    generator = new QueryGenerator(TASK_DETAIL);
-                    generator.setParameter(TaskDetailConstants.TASK_ID, name);
-                    q = generator.selectQuery(em);
-                    TaskDetail taskDetail = (TaskDetail) q.getSingleResult();
-                    TaskDetailResource taskDetailResource = (TaskDetailResource) Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
-                    em.getTransaction().commit();
-                    em.close();
-                    return taskDetailResource;
-                case ERROR_DETAIL:
-                    generator = new QueryGenerator(ERROR_DETAIL);
-                    generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_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;
-                case NODE_INPUT:
-                    generator = new QueryGenerator(NODE_INPUT);
-                    generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
-                    q = generator.selectQuery(em);
-                    NodeInput nodeInput = (NodeInput) q.getSingleResult();
-                    NodeInputResource nodeInputResource = (NodeInputResource) Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
-                    em.getTransaction().commit();
-                    em.close();
-                    return nodeInputResource;
-                case NODE_OUTPUT:
-                    generator = new QueryGenerator(NODE_OUTPUT);
-                    generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
-                    q = generator.selectQuery(em);
-                    NodeOutput nodeOutput = (NodeOutput) q.getSingleResult();
-                    NodeOutputResource nodeOutputResource = (NodeOutputResource) Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
-                    em.getTransaction().commit();
-                    em.close();
-                    return nodeOutputResource;
-                case STATUS:
-                    generator = new QueryGenerator(STATUS);
-                    generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
-                    generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.WORKFLOW_NODE.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;
-                default:
-                    em.getTransaction().commit();
-                    em.close();
-                    logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
-                    throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
-            }
-        } catch (Exception 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 TASK_DETAIL:
-                    generator = new QueryGenerator(TASK_DETAIL);
-                    generator.setParameter(TaskDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            TaskDetail taskDetail = (TaskDetail) result;
-                            TaskDetailResource taskDetailResource =
-                                    (TaskDetailResource) Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
-                            resourceList.add(taskDetailResource);
-                        }
-                    }
-                    break;
-                case ERROR_DETAIL:
-                    generator = new QueryGenerator(ERROR_DETAIL);
-                    generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                    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;
-                case NODE_INPUT:
-                    generator = new QueryGenerator(NODE_INPUT);
-                    generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            NodeInput nodeInput = (NodeInput) result;
-                            NodeInputResource nodeInputResource =
-                                    (NodeInputResource) Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
-                            resourceList.add(nodeInputResource);
-                        }
-                    }
-                    break;
-                case NODE_OUTPUT:
-                    generator = new QueryGenerator(NODE_OUTPUT);
-                    generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                    q = generator.selectQuery(em);
-                    results = q.getResultList();
-                    if (results.size() != 0) {
-                        for (Object result : results) {
-                            NodeOutput nodeOutput = (NodeOutput) result;
-                            NodeOutputResource nodeOutputResource =
-                                    (NodeOutputResource) Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
-                            resourceList.add(nodeOutputResource);
-                        }
-                    }
-                    break;
-                case STATUS:
-                    generator = new QueryGenerator(STATUS);
-                    generator.setParameter(StatusConstants.NODE_INSTANCE_ID, nodeInstanceId);
-                    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;
-                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) {
-//            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;
-    }
-
-    public void save() throws RegistryException{
-        EntityManager em = null;
-        try {
-            em = ResourceUtils.getEntityManager();
-            WorkflowNodeDetail existingNode = em.find(WorkflowNodeDetail.class, nodeInstanceId);
-            em.close();
-
-            em = ResourceUtils.getEntityManager();
-            em.getTransaction().begin();
-            WorkflowNodeDetail workflowNodeDetail = new WorkflowNodeDetail();
-            workflowNodeDetail.setNodeId(nodeInstanceId);
-            Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
-            workflowNodeDetail.setExperiment(experiment);
-            workflowNodeDetail.setExpId(experimentResource.getExpID());
-            workflowNodeDetail.setCreationTime(creationTime);
-            workflowNodeDetail.setNodeName(nodeName);
-            workflowNodeDetail.setExecutionUnit(getExecutionUnit());
-            workflowNodeDetail.setExecutionUnitData(getExecutionUnitData());
-
-            if (existingNode != null) {
-                existingNode.setExperiment(experiment);
-                existingNode.setExpId(experimentResource.getExpID());
-                existingNode.setCreationTime(creationTime);
-                existingNode.setNodeName(nodeName);
-                existingNode.setExecutionUnit(getExecutionUnit());
-                existingNode.setExecutionUnitData(getExecutionUnitData());
-                workflowNodeDetail = em.merge(existingNode);
-            } else {
-                em.persist(workflowNodeDetail);
-            }
-            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 List<NodeInputResource> getNodeInputs() throws RegistryException{
-        List<NodeInputResource> nodeInputResourceList = new ArrayList<NodeInputResource>();
-        List<Resource> resources = get(ResourceType.NODE_INPUT);
-        for (Resource resource : resources) {
-            NodeInputResource nodeInputResource = (NodeInputResource) resource;
-            nodeInputResourceList.add(nodeInputResource);
-        }
-        return nodeInputResourceList;
-    }
-
-    public List<NodeOutputResource> getNodeOutputs() throws RegistryException{
-        List<NodeOutputResource> outputResources = new ArrayList<NodeOutputResource>();
-        List<Resource> resources = get(ResourceType.NODE_OUTPUT);
-        for (Resource resource : resources) {
-            NodeOutputResource nodeOutputResource = (NodeOutputResource) resource;
-            outputResources.add(nodeOutputResource);
-        }
-        return outputResources;
-    }
-
-    public StatusResource getWorkflowNodeStatus() throws RegistryException{
-        List<Resource> resources = get(ResourceType.STATUS);
-        for (Resource resource : resources) {
-            StatusResource nodeStatus = (StatusResource) resource;
-            if(nodeStatus.getStatusType().equals(StatusType.WORKFLOW_NODE.toString())){
-                if (nodeStatus.getState() == null || nodeStatus.getState().equals("") ){
-                    nodeStatus.setState("UNKNOWN");
-                }
-                return nodeStatus;
-            }
-        }
-        return null;
-    }
-
-    public StatusResource getTaskStatus(String taskId) throws RegistryException{
-        List<Resource> resources = get(ResourceType.STATUS);
-        for (Resource resource : resources) {
-            StatusResource taskStatus = (StatusResource) resource;
-            if(taskStatus.getStatusType().equals(StatusType.TASK.toString()) && taskStatus.getTaskDetailResource().getTaskId().equals(taskId)){
-                if (taskStatus.getState() == null || taskStatus.getState().equals("") ){
-                    taskStatus.setState("UNKNOWN");
-                }
-                return taskStatus;
-            } 
-        }
-        return null;
-    }
-
-    public List<TaskDetailResource> getTaskDetails() throws RegistryException{
-        List<TaskDetailResource> taskDetailResources = new ArrayList<TaskDetailResource>();
-        List<Resource> resources = get(ResourceType.TASK_DETAIL);
-        for (Resource resource : resources) {
-            TaskDetailResource taskDetailResource = (TaskDetailResource) resource;
-            taskDetailResources.add(taskDetailResource);
-        }
-        return taskDetailResources;
-    }
-
-    public List<ErrorDetailResource> getErrorDetails() throws RegistryException{
-        List<ErrorDetailResource> errorDetails = new ArrayList<ErrorDetailResource>();
-        List<Resource> resources = get(ResourceType.ERROR_DETAIL);
-        for (Resource resource : resources) {
-            ErrorDetailResource errorDetailResource = (ErrorDetailResource) resource;
-            errorDetails.add(errorDetailResource);
-        }
-        return errorDetails;
-    }
-
-    public TaskDetailResource getTaskDetail(String taskId) throws RegistryException{
-        return (TaskDetailResource)get(ResourceType.TASK_DETAIL, taskId);
-    }
-
-	public String getExecutionUnit() {
-		return executionUnit;
-	}
-
-	public void setExecutionUnit(String executionUnit) {
-		this.executionUnit = executionUnit;
-	}
-
-	public String getExecutionUnitData() {
-		return executionUnitData;
-	}
-
-	public void setExecutionUnitData(String executionUnitData) {
-		this.executionUnitData = executionUnitData;
-	}
-}

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/utils/QueryGenerator.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/QueryGenerator.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/QueryGenerator.java
deleted file mode 100644
index b0ebe45..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/QueryGenerator.java
+++ /dev/null
@@ -1,128 +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.utils;
-
-import org.apache.airavata.registry.cpi.ResultOrderType;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.HashMap;
-import java.util.Map;
-
-public class QueryGenerator {
-	private String tableName;
-	private Map<String,Object> matches=new HashMap<String, Object>();
-	private static final String SELECT_OBJ="p";
-	private static final String DELETE_OBJ="p";
-	private static final String TABLE_OBJ="p";
-//	
-//	public QueryGenerator(String tableName) {
-//		setTableName(tableName);
-//	}
-	
-	public QueryGenerator(String tableName, Object[]...params) {
-		setTableName(tableName);
-		for (Object[] param : params) {
-			addMatch(param[0].toString(), param[1]);
-		}
-	}
-	
-	public String getTableName() {
-		return tableName;
-	}
-	public void setTableName(String tableName) {
-		this.tableName = tableName;
-	}
-	public void addMatch(String colName, Object matchValue){
-		matches.put(colName, matchValue);
-	}
-	
-	public void setParameter(String colName, Object matchValue){
-		addMatch(colName, matchValue);
-	}
-
-    /**
-     * Select query
-     * @param entityManager
-     * @return
-     */
-	public Query selectQuery(EntityManager entityManager){
-        String queryString="SELECT "+ SELECT_OBJ + " FROM " +getTableName()+" "+TABLE_OBJ;
-        return generateQueryWithParameters(entityManager, queryString);
-    }
-
-    /**
-     * Select query with pagination
-     * @param entityManager
-     * @param orderByColumn
-     * @param resultOrderType
-     * @return
-     */
-    public Query selectQuery(EntityManager entityManager, String orderByColumn,
-                             ResultOrderType resultOrderType){
-        String order = (resultOrderType == ResultOrderType.ASC) ? "ASC" : "DESC";
-        String orderByClause = " ORDER BY " + SELECT_OBJ + "." + orderByColumn + " " + order;
-        String queryString="SELECT "+ SELECT_OBJ + " FROM " +getTableName()+" "+TABLE_OBJ;
-        return generateQueryWithParameters(entityManager, queryString, orderByClause);
-    }
-
-//    public Query countQuery(EntityManager entityManager){
-//        SELECT COUNT(p.host_descriptor_ID) FROM Host_Descriptor p WHERE p.gateway_name =:gate_ID and p.host_descriptor_ID =:host_desc_name")
-//        String queryString="SELECT COUNT("+ SELECT_OBJ + " FROM " +getTableName()+" "+TABLE_OBJ;
-//        return generateQueryWithParameters(entityManager, queryString);
-//    }
-	
-	public Query deleteQuery(EntityManager entityManager){
-		String queryString="Delete FROM "+getTableName()+" "+TABLE_OBJ;
-		return generateQueryWithParameters(entityManager, queryString);
-	}
-
-	private Query generateQueryWithParameters(EntityManager entityManager,
-			String queryString) {
-		return generateQueryWithParameters(entityManager, queryString, "");
-	}
-
-    private Query generateQueryWithParameters(EntityManager entityManager,
-                                              String queryString, String orderByClause) {
-        Map<String,Object> queryParameters=new HashMap<String, Object>();
-        if (matches.size()>0){
-            String matchString = "";
-            int paramCount=0;
-            for (String colName : matches.keySet()) {
-                String paramName="param"+paramCount;
-                queryParameters.put(paramName, matches.get(colName));
-                if (!matchString.equals("")){
-                    matchString+=" AND ";
-                }
-                matchString+=TABLE_OBJ+"."+colName+" =:"+paramName;
-                paramCount++;
-            }
-            queryString+=" WHERE "+matchString;
-        }
-        queryString += orderByClause;
-        Query query = entityManager.createQuery(queryString);
-        for (String paramName : queryParameters.keySet()) {
-            query.setParameter(paramName, queryParameters.get(paramName));
-        }
-        return query;
-    }
-}

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/utils/ThriftDataModelConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
deleted file mode 100644
index ef3152f..0000000
--- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java
+++ /dev/null
@@ -1,714 +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.utils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.airavata.common.utils.StringUtil;
-import org.apache.airavata.model.appcatalog.appinterface.*;
-import org.apache.airavata.model.workspace.Gateway;
-import org.apache.airavata.model.workspace.Project;
-import org.apache.airavata.model.workspace.experiment.ActionableGroup;
-import org.apache.airavata.model.workspace.experiment.AdvancedInputDataHandling;
-import org.apache.airavata.model.workspace.experiment.AdvancedOutputDataHandling;
-import org.apache.airavata.model.workspace.experiment.ApplicationStatus;
-import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling;
-import org.apache.airavata.model.workspace.experiment.CorrectiveAction;
-import org.apache.airavata.model.workspace.experiment.DataTransferDetails;
-import org.apache.airavata.model.workspace.experiment.ErrorCategory;
-import org.apache.airavata.model.workspace.experiment.ErrorDetails;
-import org.apache.airavata.model.workspace.experiment.ExecutionUnit;
-import org.apache.airavata.model.workspace.experiment.Experiment;
-import org.apache.airavata.model.workspace.experiment.ExperimentState;
-import org.apache.airavata.model.workspace.experiment.ExperimentStatus;
-import org.apache.airavata.model.workspace.experiment.ExperimentSummary;
-import org.apache.airavata.model.workspace.experiment.JobDetails;
-import org.apache.airavata.model.workspace.experiment.JobState;
-import org.apache.airavata.model.workspace.experiment.JobStatus;
-import org.apache.airavata.model.workspace.experiment.QualityOfServiceParams;
-import org.apache.airavata.model.workspace.experiment.TaskDetails;
-import org.apache.airavata.model.workspace.experiment.TaskState;
-import org.apache.airavata.model.workspace.experiment.TaskStatus;
-import org.apache.airavata.model.workspace.experiment.TransferState;
-import org.apache.airavata.model.workspace.experiment.TransferStatus;
-import org.apache.airavata.model.workspace.experiment.UserConfigurationData;
-import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
-import org.apache.airavata.model.workspace.experiment.WorkflowNodeState;
-import org.apache.airavata.model.workspace.experiment.WorkflowNodeStatus;
-import org.apache.airavata.persistance.registry.jpa.Resource;
-import org.apache.airavata.persistance.registry.jpa.ResourceType;
-import org.apache.airavata.persistance.registry.jpa.resources.*;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ThriftDataModelConversion {
-    private final static Logger logger = LoggerFactory.getLogger(ThriftDataModelConversion.class);
-
-    public static Project getProject (ProjectResource pr) throws RegistryException {
-        if (pr != null) {
-            Project project = new Project();
-            project.setProjectId(pr.getId());
-            project.setName(pr.getName());
-            if (pr.getCreationTime()!=null) {
-				project.setCreationTime(pr.getCreationTime().getTime());
-			}
-			project.setDescription(pr.getDescription());
-            project.setOwner(pr.getWorker().getUser());
-            List<ProjectUserResource> projectUserList = pr.getProjectUserList();
-            List<String> sharedUsers = new ArrayList<String>();
-            if (projectUserList != null && !projectUserList.isEmpty()){
-                for (ProjectUserResource resource : projectUserList){
-                    sharedUsers.add(resource.getUserName());
-                }
-            }
-            project.setSharedUsers(sharedUsers);
-            return project;
-        }
-        return null;
-    }
-
-    public static Gateway getGateway (GatewayResource resource){
-        Gateway gateway = new Gateway();
-        gateway.setGatewayId(resource.getGatewayId());
-        gateway.setGatewayName(resource.getGatewayName());
-        gateway.setDomain(resource.getDomain());
-        gateway.setEmailAddress(resource.getEmailAddress());
-        return gateway;
-    }
-
-    public static List<Gateway> getAllGateways (List<Resource> gatewayList){
-        List<Gateway> gateways = new ArrayList<Gateway>();
-        for (Resource resource : gatewayList){
-            gateways.add(getGateway((GatewayResource)resource));
-        }
-        return gateways;
-    }
-
-
-    public static Experiment getExperiment(ExperimentResource experimentResource) throws RegistryException {
-        if (experimentResource != null){
-            Experiment experiment = new Experiment();
-            if (experimentResource.getProject()!= null){
-                experiment.setProjectId(experimentResource.getProject().getId());
-            }
-            experiment.setExperimentId(experimentResource.getExpID());
-            experiment.setCreationTime(experimentResource.getCreationTime().getTime());
-            experiment.setUserName(experimentResource.getExecutionUser());
-            experiment.setName(experimentResource.getExpName());
-            experiment.setDescription(experimentResource.getDescription());
-            experiment.setApplicationId(experimentResource.getApplicationId());
-            experiment.setApplicationVersion(experimentResource.getApplicationVersion());
-            experiment.setWorkflowTemplateId(experimentResource.getWorkflowTemplateId());
-            experiment.setEnableEmailNotification(experimentResource.isEnableEmailNotifications());
-            experiment.setGatewayExecutionId(experimentResource.getGatewayExecutionId());
-            if (experiment.isEnableEmailNotification()){
-                List<NotificationEmailResource> notificationEmails = experimentResource.getNotificationEmails();
-                experiment.setEmailAddresses(getEmailAddresses(notificationEmails));
-            }
-            experiment.setWorkflowTemplateVersion(experimentResource.getWorkflowTemplateVersion());
-            experiment.setWorkflowExecutionInstanceId(experimentResource.getWorkflowExecutionId());
-            List<ExperimentInputResource> experimentInputs = experimentResource.getExperimentInputs();
-            experiment.setExperimentInputs(getExpInputs(experimentInputs));
-            List<ExperimentOutputResource> experimentOutputs = experimentResource.getExperimentOutputs();
-            experiment.setExperimentOutputs(getExpOutputs(experimentOutputs));
-            StatusResource experimentStatus = experimentResource.getExperimentStatus();
-            if (experimentStatus != null){
-                experiment.setExperimentStatus(getExperimentStatus(experimentStatus));
-            }
-            List<StatusResource> changeList = experimentResource.getWorkflowNodeStatuses();
-            if (changeList != null && !changeList.isEmpty()){
-                experiment.setStateChangeList(getWorkflowNodeStatusList(changeList));
-            }
-
-            List<WorkflowNodeDetailResource> workflowNodeDetails = experimentResource.getWorkflowNodeDetails();
-            if (workflowNodeDetails != null && !workflowNodeDetails.isEmpty()){
-                experiment.setWorkflowNodeDetailsList(getWfNodeList(workflowNodeDetails));
-            }
-            List<ErrorDetailResource> errorDetails = experimentResource.getErrorDetails();
-            if (errorDetails!= null && !errorDetails.isEmpty()){
-                experiment.setErrors(getErrorDetailList(errorDetails));
-            }
-            String expID = experimentResource.getExpID();
-            if (experimentResource.isExists(ResourceType.CONFIG_DATA, expID)){
-                ConfigDataResource userConfigData = experimentResource.getUserConfigData(expID);
-                experiment.setUserConfigurationData(getUserConfigData(userConfigData));
-            }
-            return experiment;
-        }
-        return null;
-    }
-
-    public static ExperimentSummary getExperimentSummary(ExperimentResource experimentResource) throws RegistryException {
-        if (experimentResource != null){
-            ExperimentSummary experimentSummary = new ExperimentSummary();
-            if (experimentResource.getProject()!= null){
-                experimentSummary.setProjectId(experimentResource.getProject().getId());
-            }
-            experimentSummary.setExperimentId(experimentResource.getExpID());
-            experimentSummary.setCreationTime(experimentResource.getCreationTime().getTime());
-            experimentSummary.setUserName(experimentResource.getExecutionUser());
-            experimentSummary.setName(experimentResource.getExpName());
-            experimentSummary.setDescription(experimentResource.getDescription());
-            experimentSummary.setApplicationId(experimentResource.getApplicationId());
-            StatusResource experimentStatus = experimentResource.getExperimentStatus();
-            if (experimentStatus != null){
-                experimentSummary.setExperimentStatus(getExperimentStatus(experimentStatus));
-            }
-            List<ErrorDetailResource> errorDetails = experimentResource.getErrorDetails();
-            if (errorDetails!= null && !errorDetails.isEmpty()){
-                experimentSummary.setErrors(getErrorDetailList(errorDetails));
-            }
-            return experimentSummary;
-        }
-        return null;
-    }
-
-    public static InputDataObjectType getInput(Object object){
-        if (object != null){
-            InputDataObjectType dataObjectType = new InputDataObjectType();
-            if (object instanceof  ExperimentInputResource){
-                ExperimentInputResource expInput = (ExperimentInputResource) object;
-                dataObjectType.setName(expInput.getExperimentKey());
-                dataObjectType.setValue(expInput.getValue());
-                if (expInput.getDataType() != null){
-                    dataObjectType.setType(DataType.valueOf(expInput.getDataType()));
-                }
-                dataObjectType.setMetaData(expInput.getMetadata());
-                dataObjectType.setApplicationArgument(expInput.getAppArgument());
-                dataObjectType.setStandardInput(expInput.isStandardInput());
-                dataObjectType.setUserFriendlyDescription(expInput.getUserFriendlyDesc());
-                dataObjectType.setInputOrder(expInput.getInputOrder());
-                dataObjectType.setIsRequired(expInput.getRequired());
-                dataObjectType.setRequiredToAddedToCommandLine(expInput.getRequiredToCMD());
-                dataObjectType.setDataStaged(expInput.isDataStaged());
-                return dataObjectType;
-            }else if (object instanceof NodeInputResource){
-                NodeInputResource nodeInputResource = (NodeInputResource)object;
-                dataObjectType.setName(nodeInputResource.getInputKey());
-                dataObjectType.setValue(nodeInputResource.getValue());
-                if (nodeInputResource.getDataType() != null){
-                    dataObjectType.setType(DataType.valueOf(nodeInputResource.getDataType()));
-                }
-                dataObjectType.setMetaData(nodeInputResource.getMetadata());
-                dataObjectType.setApplicationArgument(nodeInputResource.getAppArgument());
-                dataObjectType.setStandardInput(nodeInputResource.isStandardInput());
-                dataObjectType.setUserFriendlyDescription(nodeInputResource.getUserFriendlyDesc());
-                dataObjectType.setInputOrder(nodeInputResource.getInputOrder());
-                dataObjectType.setIsRequired(nodeInputResource.getRequired());
-                dataObjectType.setRequiredToAddedToCommandLine(nodeInputResource.getRequiredToCMD());
-                dataObjectType.setDataStaged(nodeInputResource.isDataStaged());
-                return dataObjectType;
-            }else if (object instanceof ApplicationInputResource){
-                ApplicationInputResource inputResource = (ApplicationInputResource)object;
-                dataObjectType.setName(inputResource.getInputKey());
-                dataObjectType.setValue(inputResource.getValue());
-                if (inputResource.getDataType() != null){
-                    dataObjectType.setType(DataType.valueOf(inputResource.getDataType()));
-                }
-                dataObjectType.setMetaData(inputResource.getMetadata());
-                dataObjectType.setApplicationArgument(inputResource.getAppArgument());
-                dataObjectType.setStandardInput(inputResource.isStandardInput());
-                dataObjectType.setUserFriendlyDescription(inputResource.getUserFriendlyDesc());
-                dataObjectType.setInputOrder(inputResource.getInputOrder());
-                dataObjectType.setIsRequired(inputResource.isRequired());
-                dataObjectType.setRequiredToAddedToCommandLine(inputResource.isRequiredToCMD());
-                dataObjectType.setDataStaged(inputResource.isDataStaged());
-                return dataObjectType;
-            }else {
-                return null;
-            }
-        }
-        return null;
-    }
-
-    public static OutputDataObjectType getOutput(Object object){
-        if (object != null){
-            OutputDataObjectType dataObjectType = new OutputDataObjectType();
-            if (object instanceof ExperimentOutputResource){
-                ExperimentOutputResource expOutput = (ExperimentOutputResource)object;
-                dataObjectType.setName(expOutput.getExperimentKey());
-                dataObjectType.setValue(expOutput.getValue());
-                if (expOutput.getDataType() != null){
-                    dataObjectType.setType(DataType.valueOf(expOutput.getDataType()));
-                }
-                dataObjectType.setIsRequired(expOutput.getRequired());
-                dataObjectType.setRequiredToAddedToCommandLine(expOutput.getRequiredToCMD());
-                dataObjectType.setDataMovement(expOutput.isDataMovement());
-                dataObjectType.setLocation(expOutput.getDataNameLocation());
-                dataObjectType.setSearchQuery(expOutput.getSearchQuery());
-                dataObjectType.setApplicationArgument(expOutput.getAppArgument());
-                return dataObjectType;
-            }else if (object instanceof NodeOutputResource){
-                NodeOutputResource nodeOutputResource = (NodeOutputResource)object;
-                dataObjectType.setName(nodeOutputResource.getOutputKey());
-                dataObjectType.setValue(nodeOutputResource.getValue());
-                if (nodeOutputResource.getDataType() != null){
-                    dataObjectType.setType(DataType.valueOf(nodeOutputResource.getDataType()));
-                }
-                dataObjectType.setIsRequired(nodeOutputResource.getRequired());
-                dataObjectType.setRequiredToAddedToCommandLine(nodeOutputResource.getRequiredToCMD());
-                dataObjectType.setDataMovement(nodeOutputResource.isDataMovement());
-                dataObjectType.setLocation(nodeOutputResource.getDataNameLocation());
-                dataObjectType.setSearchQuery(nodeOutputResource.getSearchQuery());
-                dataObjectType.setApplicationArgument(nodeOutputResource.getAppArgument());
-                return dataObjectType;
-            }else if (object instanceof ApplicationOutputResource){
-                ApplicationOutputResource outputResource = (ApplicationOutputResource)object;
-                dataObjectType.setName(outputResource.getOutputKey());
-                dataObjectType.setValue(outputResource.getValue());
-                dataObjectType.setIsRequired(outputResource.isRequired());
-                dataObjectType.setRequiredToAddedToCommandLine(outputResource.isRequiredToCMD());
-                if (outputResource.getDataType() != null){
-                    dataObjectType.setType(DataType.valueOf(outputResource.getDataType()));
-                }
-                dataObjectType.setDataMovement(outputResource.isDataMovement());
-                dataObjectType.setLocation(outputResource.getDataNameLocation());
-                dataObjectType.setSearchQuery(outputResource.getSearchQuery());
-                dataObjectType.setApplicationArgument(outputResource.getAppArgument());
-                return dataObjectType;
-            }else {
-                return null;
-            }
-        }
-        return null;
-    }
-
-    public static List<String> getEmailAddresses (List<NotificationEmailResource> resourceList){
-        List<String> emailAddresses = new ArrayList<String>();
-        if (resourceList != null && !resourceList.isEmpty()){
-            for (NotificationEmailResource emailResource : resourceList){
-                emailAddresses.add(emailResource.getEmailAddress());
-            }
-        }
-        return emailAddresses;
-    }
-
-    public static List<InputDataObjectType> getExpInputs (List<ExperimentInputResource> exInputList){
-        List<InputDataObjectType> expInputs = new ArrayList<InputDataObjectType>();
-        if (exInputList != null && !exInputList.isEmpty()){
-            for (ExperimentInputResource inputResource : exInputList){
-                InputDataObjectType exInput = getInput(inputResource);
-                expInputs.add(exInput);
-            }
-        }
-        return expInputs;
-    }
-
-    public static List<OutputDataObjectType> getExpOutputs (List<ExperimentOutputResource> experimentOutputResourceList){
-        List<OutputDataObjectType> exOutputs = new ArrayList<OutputDataObjectType>();
-        if (experimentOutputResourceList != null && !experimentOutputResourceList.isEmpty()){
-            for (ExperimentOutputResource outputResource : experimentOutputResourceList){
-                OutputDataObjectType output = getOutput(outputResource);
-                exOutputs.add(output);
-            }
-        }
-        return exOutputs;
-    }
-
-    public static List<InputDataObjectType> getNodeInputs (List<NodeInputResource> nodeInputResources){
-        List<InputDataObjectType> nodeInputs = new ArrayList<InputDataObjectType>();
-        if (nodeInputResources != null && !nodeInputResources.isEmpty()){
-            for (NodeInputResource inputResource : nodeInputResources){
-                InputDataObjectType nodeInput = getInput(inputResource);
-                nodeInputs.add(nodeInput);
-            }
-        }
-        return nodeInputs;
-    }
-
-    public static List<OutputDataObjectType> getNodeOutputs (List<NodeOutputResource> nodeOutputResourceList){
-        List<OutputDataObjectType> nodeOutputs = new ArrayList<OutputDataObjectType>();
-        if (nodeOutputResourceList != null && !nodeOutputResourceList.isEmpty()){
-            for (NodeOutputResource outputResource : nodeOutputResourceList){
-                OutputDataObjectType output = getOutput(outputResource);
-                nodeOutputs.add(output);
-            }
-        }
-        return nodeOutputs;
-    }
-
-    public static List<InputDataObjectType> getApplicationInputs (List<ApplicationInputResource> applicationInputResources){
-        List<InputDataObjectType> appInputs = new ArrayList<InputDataObjectType>();
-        if (applicationInputResources != null && !applicationInputResources.isEmpty()){
-            for (ApplicationInputResource inputResource : applicationInputResources){
-                InputDataObjectType appInput = getInput(inputResource);
-                appInputs.add(appInput);
-            }
-        }
-        return appInputs;
-    }
-
-    public static List<OutputDataObjectType> getApplicationOutputs (List<ApplicationOutputResource> outputResources){
-        List<OutputDataObjectType> appOutputs = new ArrayList<OutputDataObjectType>();
-        if (outputResources != null && !outputResources.isEmpty()){
-            for (ApplicationOutputResource outputResource : outputResources){
-                OutputDataObjectType output = getOutput(outputResource);
-                appOutputs.add(output);
-            }
-        }
-        return appOutputs;
-    }
-
-    public static ExperimentStatus getExperimentStatus(StatusResource status){
-        if (status != null){
-            ExperimentStatus experimentStatus = new ExperimentStatus();
-            if (status.getState() == null || status.getState().equals("")){
-                status.setState("UNKNOWN");
-            }
-            experimentStatus.setExperimentState(ExperimentState.valueOf(status.getState()));
-            experimentStatus.setTimeOfStateChange(status.getStatusUpdateTime().getTime());
-            return experimentStatus;
-        }
-        return null;
-    }
-
-    public static WorkflowNodeStatus getWorkflowNodeStatus (StatusResource status){
-        if (status != null){
-            WorkflowNodeStatus workflowNodeStatus = new WorkflowNodeStatus();
-            if (status.getState() == null || status.getState().equals("")){
-                status.setState("UNKNOWN");
-            }
-            workflowNodeStatus.setWorkflowNodeState(WorkflowNodeState.valueOf(status.getState()));
-            workflowNodeStatus.setTimeOfStateChange(status.getStatusUpdateTime().getTime());
-            return workflowNodeStatus;
-        }
-        return null;
-    }
-
-    public static TaskStatus getTaskStatus (StatusResource status){
-        if (status != null){
-            TaskStatus taskStatus = new TaskStatus();
-            if (status.getState() == null || status.getState().equals("")){
-                status.setState("UNKNOWN");
-            }
-            taskStatus.setExecutionState(TaskState.valueOf(status.getState()));
-            taskStatus.setTimeOfStateChange(status.getStatusUpdateTime().getTime());
-            return taskStatus;
-        }
-        return null;
-    }
-
-    public static JobStatus getJobStatus (StatusResource status){
-        if (status != null){
-            JobStatus jobStatus = new JobStatus();
-            if (status.getState() == null || status.getState().equals("")){
-                status.setState("UNKNOWN");
-            }
-            jobStatus.setJobState(JobState.valueOf(status.getState()));
-            jobStatus.setTimeOfStateChange(status.getStatusUpdateTime().getTime());
-            return jobStatus;
-        }
-        return null;
-    }
-
-    public static TransferStatus getTransferStatus (StatusResource status){
-        if (status != null){
-            TransferStatus transferStatus = new TransferStatus();
-            if (status.getState() == null || status.getState().equals("")){
-                status.setState("UNKNOWN");
-            }
-            transferStatus.setTransferState(TransferState.valueOf(status.getState()));
-            transferStatus.setTimeOfStateChange(status.getStatusUpdateTime().getTime());
-            return transferStatus;
-        }
-        return null;
-    }
-
-    public static ApplicationStatus getApplicationStatus (StatusResource status){
-        if (status != null){
-            ApplicationStatus applicationStatus = new ApplicationStatus();
-            if (status.getState() == null || status.getState().equals("")){
-                status.setState("UNKNOWN");
-            }
-            applicationStatus.setApplicationState(status.getState());
-            applicationStatus.setTimeOfStateChange(status.getStatusUpdateTime().getTime());
-            return applicationStatus;
-        }
-        return null;
-    }
-
-    public static List<WorkflowNodeStatus> getWorkflowNodeStatusList(List<StatusResource> statuses){
-        List<WorkflowNodeStatus> wfNodeStatuses = new ArrayList<WorkflowNodeStatus>();
-        if (statuses != null && !statuses.isEmpty()){
-            for (StatusResource statusResource : statuses){
-                wfNodeStatuses.add(getWorkflowNodeStatus(statusResource));
-            }
-        }
-        return wfNodeStatuses;
-    }
-
-    public static WorkflowNodeDetails getWorkflowNodeDetails(WorkflowNodeDetailResource nodeDetailResource) throws RegistryException {
-        if (nodeDetailResource != null){
-            WorkflowNodeDetails wfNode = new WorkflowNodeDetails();
-            wfNode.setNodeInstanceId(nodeDetailResource.getNodeInstanceId());
-            wfNode.setCreationTime(nodeDetailResource.getCreationTime().getTime());
-            wfNode.setNodeName(nodeDetailResource.getNodeName());
-            List<NodeInputResource> nodeInputs = nodeDetailResource.getNodeInputs();
-            wfNode.setNodeInputs(getNodeInputs(nodeInputs));
-            List<NodeOutputResource> nodeOutputs = nodeDetailResource.getNodeOutputs();
-            wfNode.setNodeOutputs(getNodeOutputs(nodeOutputs));
-            List<TaskDetailResource> taskDetails = nodeDetailResource.getTaskDetails();
-            wfNode.setTaskDetailsList(getTaskDetailsList(taskDetails));
-            wfNode.setWorkflowNodeStatus(getWorkflowNodeStatus(nodeDetailResource.getWorkflowNodeStatus()));
-            List<ErrorDetailResource> errorDetails = nodeDetailResource.getErrorDetails();
-            wfNode.setErrors(getErrorDetailList(errorDetails));
-            wfNode.setExecutionUnit(ExecutionUnit.valueOf(nodeDetailResource.getExecutionUnit()));
-            wfNode.setExecutionUnitData(nodeDetailResource.getExecutionUnitData());
-            return wfNode;
-        }
-        return null;
-    }
-
-    public static List<WorkflowNodeDetails> getWfNodeList (List<WorkflowNodeDetailResource> resources) throws RegistryException {
-        List<WorkflowNodeDetails> workflowNodeDetailsList = new ArrayList<WorkflowNodeDetails>();
-        if (resources != null && !resources.isEmpty()){
-            for (WorkflowNodeDetailResource resource : resources){
-                workflowNodeDetailsList.add(getWorkflowNodeDetails(resource));
-            }
-        }
-        return workflowNodeDetailsList;
-    }
-
-    public static TaskDetails getTaskDetail (TaskDetailResource taskDetailResource) throws RegistryException {
-        if (taskDetailResource != null){
-            TaskDetails taskDetails = new TaskDetails();
-            String taskId = taskDetailResource.getTaskId();
-            taskDetails.setTaskId(taskId);
-            taskDetails.setApplicationId(taskDetailResource.getApplicationId());
-            taskDetails.setApplicationVersion(taskDetailResource.getApplicationVersion());
-            List<ApplicationInputResource> applicationInputs = taskDetailResource.getApplicationInputs();
-            taskDetails.setApplicationInputs(getApplicationInputs(applicationInputs));
-            List<ApplicationOutputResource> applicationOutputs = taskDetailResource.getApplicationOutputs();
-            taskDetails.setApplicationOutputs(getApplicationOutputs(applicationOutputs));
-            taskDetails.setEnableEmailNotification(taskDetailResource.isEnableEmailNotifications());
-            if (taskDetails.isEnableEmailNotification()){
-                List<NotificationEmailResource> notificationEmails = taskDetailResource.getNotificationEmails();
-                taskDetails.setEmailAddresses(getEmailAddresses(notificationEmails));
-            }
-            taskDetails.setApplicationDeploymentId(taskDetailResource.getApplicationDeploymentId());
-            if (taskDetailResource.isExists(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, taskId)){
-                ComputationSchedulingResource computationScheduling = taskDetailResource.getComputationScheduling(taskId);
-                taskDetails.setTaskScheduling(getComputationalResourceScheduling(computationScheduling));
-            }
-
-            if (taskDetailResource.isExists(ResourceType.ADVANCE_INPUT_DATA_HANDLING, taskId)){
-                AdvanceInputDataHandlingResource inputDataHandling = taskDetailResource.getInputDataHandling(taskId);
-                taskDetails.setAdvancedInputDataHandling(getAdvanceInputDataHandling(inputDataHandling));
-            }
-
-            if (taskDetailResource.isExists(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, taskId)){
-                AdvancedOutputDataHandlingResource outputDataHandling = taskDetailResource.getOutputDataHandling(taskId);
-                taskDetails.setAdvancedOutputDataHandling(getAdvanceOutputDataHandling(outputDataHandling));
-            }
-
-            taskDetails.setTaskStatus(getTaskStatus(taskDetailResource.getTaskStatus()));
-            List<JobDetailResource> jobDetailList = taskDetailResource.getJobDetailList();
-            taskDetails.setJobDetailsList(getJobDetailsList(jobDetailList));
-            taskDetails.setErrors(getErrorDetailList(taskDetailResource.getErrorDetailList()));
-            taskDetails.setDataTransferDetailsList(getDataTransferlList(taskDetailResource.getDataTransferDetailList()));
-            return taskDetails;
-        }
-        return null;
-    }
-
-    public static List<TaskDetails> getTaskDetailsList (List<TaskDetailResource> resources) throws RegistryException {
-        List<TaskDetails> taskDetailsList = new ArrayList<TaskDetails>();
-        if (resources != null && !resources.isEmpty()){
-            for (TaskDetailResource resource : resources){
-                taskDetailsList.add(getTaskDetail(resource));
-            }
-        }
-        return taskDetailsList;
-    }
-
-    public static List<JobDetails> getJobDetailsList(List<JobDetailResource> jobs) throws RegistryException {
-        List<JobDetails> jobDetailsList = new ArrayList<JobDetails>();
-        if (jobs != null && !jobs.isEmpty()){
-            for (JobDetailResource resource : jobs){
-                jobDetailsList.add(getJobDetail(resource));
-            }
-        }
-        return jobDetailsList;
-    }
-
-
-    public static JobDetails getJobDetail(JobDetailResource jobDetailResource) throws RegistryException {
-        if (jobDetailResource != null){
-            JobDetails jobDetails = new JobDetails();
-            jobDetails.setJobId(jobDetailResource.getJobId());
-            jobDetails.setJobDescription(jobDetailResource.getJobDescription());
-            jobDetails.setCreationTime(jobDetailResource.getCreationTime().getTime());
-            StatusResource jobStatus = jobDetailResource.getJobStatus();
-            jobDetails.setJobStatus(getJobStatus(jobStatus));
-            jobDetails.setJobName(jobDetailResource.getJobName());
-            jobDetails.setWorkingDir(jobDetailResource.getWorkingDir());
-            StatusResource applicationStatus = jobDetailResource.getApplicationStatus();
-            jobDetails.setApplicationStatus(getApplicationStatus(applicationStatus));
-            List<ErrorDetailResource> errorDetails = jobDetailResource.getErrorDetails();
-            jobDetails.setErrors(getErrorDetailList(errorDetails));
-            jobDetails.setComputeResourceConsumed(jobDetailResource.getComputeResourceConsumed());
-            return jobDetails;
-        }
-        return null;
-    }
-
-    public static ErrorDetails getErrorDetails (ErrorDetailResource resource){
-        if (resource != null){
-            ErrorDetails errorDetails = new ErrorDetails();
-            errorDetails.setErrorId(String.valueOf(resource.getErrorId()));
-            errorDetails.setCreationTime(resource.getCreationTime().getTime());
-            errorDetails.setActualErrorMessage(resource.getActualErrorMsg());
-            errorDetails.setUserFriendlyMessage(resource.getUserFriendlyErrorMsg());
-            errorDetails.setErrorCategory(ErrorCategory.valueOf(resource.getErrorCategory()));
-            errorDetails.setTransientOrPersistent(resource.isTransientPersistent());
-            errorDetails.setCorrectiveAction(CorrectiveAction.valueOf(resource.getCorrectiveAction()));
-            errorDetails.setActionableGroup(ActionableGroup.valueOf(resource.getActionableGroup()));
-            return errorDetails;
-        }
-        return null;
-    }
-
-    public static List<ErrorDetails> getErrorDetailList (List<ErrorDetailResource> errorDetailResources){
-        List<ErrorDetails> errorDetailsList = new ArrayList<ErrorDetails>();
-        if (errorDetailResources != null && !errorDetailResources.isEmpty()){
-            for (ErrorDetailResource errorDetailResource : errorDetailResources){
-                errorDetailsList.add(getErrorDetails(errorDetailResource));
-            }
-        }
-        return errorDetailsList;
-    }
-
-    public static DataTransferDetails getDataTransferDetail (DataTransferDetailResource resource) throws RegistryException {
-        if (resource != null){
-            DataTransferDetails details = new DataTransferDetails();
-            details.setTransferId(resource.getTransferId());
-            details.setCreationTime(resource.getCreationTime().getTime());
-            details.setTransferDescription(resource.getTransferDescription());
-            details.setTransferStatus(getTransferStatus(resource.getDataTransferStatus()));
-            return details;
-        }
-        return null;
-    }
-
-    public static List<DataTransferDetails> getDataTransferlList (List<DataTransferDetailResource> resources) throws RegistryException {
-        List<DataTransferDetails> transferDetailsList = new ArrayList<DataTransferDetails>();
-        if (resources != null && !resources.isEmpty()){
-            for (DataTransferDetailResource resource : resources){
-                transferDetailsList.add(getDataTransferDetail(resource));
-            }
-        }
-        return transferDetailsList;
-    }
-
-
-    public static UserConfigurationData getUserConfigData (ConfigDataResource resource) throws RegistryException {
-        if (resource != null){
-            UserConfigurationData data = new UserConfigurationData();
-            data.setAiravataAutoSchedule(resource.isAiravataAutoSchedule());
-            data.setOverrideManualScheduledParams(resource.isOverrideManualParams());
-            data.setShareExperimentPublicly(resource.isShareExp());
-            data.setUserDn(resource.getUserDn());
-            data.setGenerateCert(resource.isGenerateCert());
-            ExperimentResource experimentResource = resource.getExperimentResource();
-            String expID = experimentResource.getExpID();
-            if (experimentResource.isExists(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, expID)){
-                ComputationSchedulingResource computationScheduling = experimentResource.getComputationScheduling(expID);
-                data.setComputationalResourceScheduling(getComputationalResourceScheduling(computationScheduling));
-            }
-
-            if (experimentResource.isExists(ResourceType.ADVANCE_INPUT_DATA_HANDLING, expID)){
-                AdvanceInputDataHandlingResource inputDataHandling = experimentResource.getInputDataHandling(expID);
-                data.setAdvanceInputDataHandling(getAdvanceInputDataHandling(inputDataHandling));
-            }
-
-            if (experimentResource.isExists(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, expID)){
-                AdvancedOutputDataHandlingResource outputDataHandling = experimentResource.getOutputDataHandling(expID);
-                data.setAdvanceOutputDataHandling(getAdvanceOutputDataHandling(outputDataHandling));
-            }
-
-            if (experimentResource.isExists(ResourceType.QOS_PARAM, expID)){
-                QosParamResource qoSparams = experimentResource.getQOSparams(expID);
-                data.setQosParams(getQOSParams(qoSparams));
-            }
-            return data;
-        }
-        return null;
-    }
-
-
-    public static ComputationalResourceScheduling getComputationalResourceScheduling (ComputationSchedulingResource csr){
-        if (csr != null){
-            ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
-            scheduling.setResourceHostId(csr.getResourceHostId());
-            scheduling.setTotalCpuCount(csr.getCpuCount());
-            scheduling.setNodeCount(csr.getNodeCount());
-            scheduling.setNumberOfThreads(csr.getNumberOfThreads());
-            scheduling.setQueueName(csr.getQueueName());
-            scheduling.setWallTimeLimit(csr.getWalltimeLimit());
-            scheduling.setJobStartTime((int)csr.getJobStartTime().getTime());
-            scheduling.setTotalPhysicalMemory(csr.getPhysicalMemory());
-            scheduling.setComputationalProjectAccount(csr.getProjectName());
-            scheduling.setChassisName(csr.getChessisName());
-            return scheduling;
-        }
-        return null;
-    }
-
-    public static AdvancedInputDataHandling getAdvanceInputDataHandling(AdvanceInputDataHandlingResource adhr){
-        if (adhr != null){
-            AdvancedInputDataHandling adih = new AdvancedInputDataHandling();
-            adih.setStageInputFilesToWorkingDir(adhr.isStageInputFiles());
-            adih.setParentWorkingDirectory(adhr.getWorkingDirParent());
-            adih.setUniqueWorkingDirectory(adhr.getWorkingDir());
-            adih.setCleanUpWorkingDirAfterJob(adhr.isCleanAfterJob());
-            return adih;
-        }
-        return null;
-    }
-
-    public static AdvancedOutputDataHandling getAdvanceOutputDataHandling(AdvancedOutputDataHandlingResource adodh){
-        if (adodh != null){
-            AdvancedOutputDataHandling outputDataHandling = new AdvancedOutputDataHandling();
-            outputDataHandling.setOutputDataDir(adodh.getOutputDataDir());
-            outputDataHandling.setDataRegistryURL(adodh.getDataRegUrl());
-            outputDataHandling.setPersistOutputData(adodh.isPersistOutputData());
-            return outputDataHandling;
-        }
-        return null;
-    }
-
-    public static QualityOfServiceParams getQOSParams (QosParamResource qos){
-        if (qos != null){
-            QualityOfServiceParams qosParams = new QualityOfServiceParams();
-            qosParams.setStartExecutionAt(qos.getStartExecutionAt());
-            qosParams.setExecuteBefore(qos.getExecuteBefore());
-            qosParams.setNumberofRetries(qos.getNoOfRetries());
-            return qosParams;
-        }
-        return null;
-    }
-
-
-
-}

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/Test.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/Test.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/Test.java
new file mode 100644
index 0000000..cb935e1
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/Test.java
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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.mongo;
+
+import org.apache.airavata.model.workspace.experiment.Experiment;
+import org.apache.airavata.persistance.registry.mongo.impl.RegistryFactory;
+import org.apache.airavata.persistance.registry.mongo.dao.ExperimentDao;
+import org.apache.airavata.persistance.registry.mongo.utils.MongoUtil;
+import org.apache.airavata.registry.cpi.Registry;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.RegistryModelType;
+import org.junit.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class Test {
+    private final static Logger logger = LoggerFactory.getLogger(Test.class);
+
+    public static void main(String[] args) throws RegistryException, IOException {
+        Registry registry = RegistryFactory.getDefaultRegistry();
+//        String experiemtnId = "SLM-Espresso-Stampede_45667ea8-aae3-4a8e-807d-a16312035c35";
+//        long time1 = System.currentTimeMillis();
+//        Experiment experiement = (Experiment) registry.getExperiment(RegistryModelType.EXPERIMENT, experiemtnId);
+//        long time2 = System.currentTimeMillis();
+//        System.out.println(time2-time1);
+//
+//        ExperimentDao experimentDao = new ExperimentDao();
+//        experimentDao.createExperiment(experiement);
+//        time1 = System.currentTimeMillis();
+//        Experiment persistedExperiment = experimentDao.getExperiment(experiement.getExperimentId());
+//        time2 = System.currentTimeMillis();
+//        System.out.println(time2-time1);
+//
+//        Assert.assertEquals(experiement, persistedExperiment);
+
+        MongoUtil.dropAiravataRegistry();
+
+        ExperimentDao experimentDao = new ExperimentDao();
+        BufferedReader reader = new BufferedReader(new FileReader("/home/supun/Downloads/EXPERIMENT.csv"));
+        String temp = reader.readLine();
+        int i = 1;
+        while(temp != null && !temp.isEmpty()){
+            try{
+                Experiment experiement = (Experiment) registry.get(RegistryModelType.EXPERIMENT, temp.trim());
+                experimentDao.createExperiment(experiement);
+                Experiment persistedExperiment = experimentDao.getExperiment(experiement.getExperimentId());
+                Assert.assertEquals(experiement, persistedExperiment);
+                System.out.println(i+" :"+experiement.getExperimentId());
+                i++;
+            }catch (Exception e){
+                System.out.println(temp);
+                e.printStackTrace();
+            }
+            temp = reader.readLine();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/conversion/AbstractThriftDeserializer.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/conversion/AbstractThriftDeserializer.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/conversion/AbstractThriftDeserializer.java
new file mode 100644
index 0000000..e6774d8
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/conversion/AbstractThriftDeserializer.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.mongo.conversion;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.node.JsonNodeType;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.google.common.base.CaseFormat;
+import org.apache.thrift.TBase;
+import org.apache.thrift.TException;
+import org.apache.thrift.TFieldIdEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This abstract class represents a generic de-serializer for converting JSON to Thrift-based entities.
+ *
+ * @param <E> An implementation of the {@link org.apache.thrift.TFieldIdEnum} interface.
+ * @param <T> An implementation of the {@link org.apache.thrift.TBase} interface.
+ */
+public abstract class AbstractThriftDeserializer<E extends TFieldIdEnum, T extends TBase<T, E>> extends JsonDeserializer<T> {
+
+    private static Logger log = LoggerFactory.getLogger(AbstractThriftDeserializer.class);
+
+    @Override
+    public T deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
+        final T instance = newInstance();
+        final ObjectMapper mapper = (ObjectMapper)jp.getCodec();
+        final ObjectNode rootNode = (ObjectNode)mapper.readTree(jp);
+        final Iterator<Map.Entry<String, JsonNode>> iterator = rootNode.fields();
+
+        while(iterator.hasNext()) {
+            final Map.Entry<String, JsonNode> currentField = iterator.next();
+            try {
+                /*
+                 * If the current node is not a null value, process it.  Otherwise,
+                 * skip it.  Jackson will treat the null as a 0 for primitive
+                 * number types, which in turn will make Thrift think the field
+                 * has been set. Also we ignore the MongoDB specific _id field
+                 */
+                if(!currentField.getKey().equalsIgnoreCase("_id")
+                        && currentField.getValue().getNodeType() != JsonNodeType.NULL) {
+                    final E field = getField(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_UNDERSCORE, currentField.getKey()));
+                    final JsonParser parser = currentField.getValue().traverse();
+                    parser.setCodec(mapper);
+                    final Object value = mapper.readValue(parser, generateValueType(instance, field));
+                    if(value != null) {
+                        log.debug(String.format("Field %s produced value %s of type %s.",
+                                currentField.getKey(), value, value.getClass().getName()));
+                        instance.setFieldValue(field, value);
+                    } else {
+                        log.debug("Field {} contains a null value.  Skipping...", currentField.getKey());
+                    }
+                } else {
+                    log.debug("Field {} contains a null value.  Skipping...", currentField.getKey());
+                }
+            } catch (final NoSuchFieldException | IllegalArgumentException e) {
+                log.error("Unable to de-serialize field '{}'.", currentField.getKey(), e);
+                ctxt.mappingException(e.getMessage());
+            }
+        }
+
+        try {
+            // Validate that the instance contains all required fields.
+            validate(instance);
+        } catch (final TException e) {
+            log.error(String.format("Unable to deserialize JSON '%s' to type '%s'.",
+                    jp.getValueAsString(), instance.getClass().getName(), e));
+            ctxt.mappingException(e.getMessage());
+        }
+
+        return instance;
+    }
+
+    /**
+     * Returns the {@code <E>} enumerated value that represents the target
+     * field in the Thrift entity referenced in the JSON document.
+     * @param fieldName The name of the Thrift entity target field.
+     * @return The {@code <E>} enumerated value that represents the target
+     *   field in the Thrift entity referenced in the JSON document.
+     */
+    protected abstract E getField(String fieldName);
+
+    /**
+     * Creates a new instance of the Thrift entity class represented by this deserializer.
+     * @return A new instance of the Thrift entity class represented by this deserializer.
+     */
+    protected abstract T newInstance();
+
+    /**
+     * Validates that the Thrift entity instance contains all required fields after deserialization.
+     * @param instance A Thrift entity instance.
+     * @throws org.apache.thrift.TException if unable to validate the instance.
+     */
+    protected abstract void validate(T instance) throws TException;
+
+    /**
+     * Generates a {@link JavaType} that matches the target Thrift field represented by the provided
+     * {@code <E>} enumerated value.  If the field's type includes generics, the generics will
+     * be added to the generated {@link JavaType} to support proper conversion.
+     * @param thriftInstance The Thrift-generated class instance that will be converted to/from JSON.
+     * @param field A {@code <E>} enumerated value that represents a field in a Thrift-based entity.
+     * @return The {@link JavaType} representation of the type associated with the field.
+     * @throws NoSuchFieldException if unable to determine the field's type.
+     * @throws SecurityException if unable to determine the field's type.
+     */
+    protected JavaType generateValueType(final T thriftInstance, final E field) throws NoSuchFieldException, SecurityException {
+        final TypeFactory typeFactory = TypeFactory.defaultInstance();
+
+        final Field declaredField = thriftInstance.getClass().getDeclaredField(field.getFieldName());
+        if(declaredField.getType().equals(declaredField.getGenericType())) {
+            log.debug("Generating JavaType for type '{}'.", declaredField.getType());
+            return typeFactory.constructType(declaredField.getType());
+        } else {
+            final ParameterizedType type = (ParameterizedType)declaredField.getGenericType();
+            final Class<?>[] parameterizedTypes = new Class<?>[type.getActualTypeArguments().length];
+            for(int i=0; i<type.getActualTypeArguments().length; i++) {
+                parameterizedTypes[i] = (Class<?>)type.getActualTypeArguments()[i];
+            }
+            log.debug("Generating JavaType for type '{}' with generics '{}'", declaredField.getType(), parameterizedTypes);
+            return typeFactory.constructParametricType(declaredField.getType(), parameterizedTypes);
+        }
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/conversion/AbstractThriftSerializer.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/conversion/AbstractThriftSerializer.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/conversion/AbstractThriftSerializer.java
new file mode 100644
index 0000000..54f491b
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/mongo/conversion/AbstractThriftSerializer.java
@@ -0,0 +1,122 @@
+/*
+ *
+ * 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.mongo.conversion;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.google.common.base.CaseFormat;
+import org.apache.thrift.TBase;
+import org.apache.thrift.TFieldIdEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ * This abstract class represents a generic serializer for converting Thrift-based entities
+ * to JSON.
+ *
+ * @param <E> An implementation of the {@link org.apache.thrift.TFieldIdEnum} interface.
+ * @param <T> An implementation of the {@link org.apache.thrift.TBase} interface.
+ */
+public abstract class AbstractThriftSerializer<E extends TFieldIdEnum, T extends TBase<T, E>>
+        extends JsonSerializer<T> {
+
+    private static final Logger log = LoggerFactory.getLogger(AbstractThriftSerializer.class);
+
+    @Override
+    public Class<T> handledType() {
+        return getThriftClass();
+    }
+
+    @Override
+    public void serialize(final T value, final JsonGenerator jgen, final SerializerProvider provider)
+            throws IOException, JsonProcessingException {
+        jgen.writeStartObject();
+        for(final E field : getFieldValues()) {
+            if(value.isSet(field)) {
+                final Object fieldValue = value.getFieldValue(field);
+                if(fieldValue != null) {
+                    log.debug("Adding field {} to the JSON string...",
+                            CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+                    );
+
+                    jgen.writeFieldName(CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName()));
+                    if(fieldValue instanceof Short) {
+                        jgen.writeNumber((Short)fieldValue);
+                    } else if(fieldValue instanceof Integer) {
+                        jgen.writeNumber((Integer)fieldValue);
+                    } else if(fieldValue instanceof Long) {
+                        jgen.writeNumber((Long)fieldValue);
+                    } else if(fieldValue instanceof Double) {
+                        jgen.writeNumber((Double)fieldValue);
+                    } else if(fieldValue instanceof Float) {
+                        jgen.writeNumber((Float)fieldValue);
+                    } else if(fieldValue instanceof Boolean) {
+                        jgen.writeBoolean((Boolean)fieldValue);
+                    } else if(fieldValue instanceof String) {
+                        jgen.writeString(fieldValue.toString());
+                    } else if(fieldValue instanceof Collection) {
+                        log.debug("Array opened for field {}.",
+                                CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+                        );
+                        jgen.writeStartArray();
+                        for(final Object arrayObject : (Collection<?>)fieldValue) {
+                                jgen.writeObject(arrayObject);
+                        }
+                        jgen.writeEndArray();
+                        log.debug("Array closed for field {}.",
+                                CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+                        );
+                    } else {
+                        jgen.writeObject(fieldValue);
+                    }
+                } else {
+                    log.debug("Skipping converting field {} to JSON:  value is null!",
+                            CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+                    );
+                }
+            } else {
+                log.debug("Skipping converting field {} to JSON:  field has not been set!",
+                        CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,field.getFieldName())
+                );
+            }
+        }
+        jgen.writeEndObject();
+    }
+
+    /**
+     * Returns an array of {@code <E>} enumerated values that represent the fields present in the
+     * Thrift class associated with this serializer.
+     * @return The array of {@code <E>} enumerated values that represent the fields present in the
+     *   Thrift class.
+     */
+    protected abstract E[] getFieldValues();
+
+    /**
+     * Returns the {@code <T>} implementation class associated with this serializer.
+     * @return The {@code <T>} implementation class
+     */
+    protected abstract Class<T> getThriftClass();
+}
\ No newline at end of file


Mime
View raw message