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/mongo/conversion/group/GroupSerializer.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/group/GroupSerializer.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/group/GroupSerializer.java deleted file mode 100644 index f28348a..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/group/GroupSerializer.java +++ /dev/null @@ -1,41 +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.mongo.conversion.group; - -import org.apache.airavata.model.workspace.Group; -import org.apache.airavata.persistance.registry.jpa.mongo.conversion.AbstractThriftSerializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GroupSerializer extends - AbstractThriftSerializer<Group._Fields, Group> { - private final static Logger logger = LoggerFactory.getLogger(GroupSerializer.class); - - @Override - protected Group._Fields[] getFieldValues() { - return Group._Fields.values(); - } - - @Override - protected Class<Group> getThriftClass() { - return null; - } -} \ 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/jpa/mongo/conversion/project/ProjectDeserializer.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/project/ProjectDeserializer.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/project/ProjectDeserializer.java deleted file mode 100644 index 5e5c5ea..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/project/ProjectDeserializer.java +++ /dev/null @@ -1,44 +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.mongo.conversion.project; - -import org.apache.airavata.model.workspace.Project; -import org.apache.airavata.persistance.registry.jpa.mongo.conversion.AbstractThriftDeserializer; -import org.apache.thrift.TException; - -public class ProjectDeserializer extends - AbstractThriftDeserializer<Project._Fields, Project> { - - @Override - protected Project._Fields getField(final String fieldName) { - return Project._Fields.valueOf(fieldName); - } - - @Override - protected Project newInstance() { - return new Project(); - } - - @Override - protected void validate(final Project instance) throws TException { - instance.validate(); - } -} \ 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/jpa/mongo/conversion/project/ProjectSerializer.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/project/ProjectSerializer.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/project/ProjectSerializer.java deleted file mode 100644 index 056ee66..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/project/ProjectSerializer.java +++ /dev/null @@ -1,40 +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.mongo.conversion.project; - -import org.apache.airavata.model.workspace.Project; -import org.apache.airavata.persistance.registry.jpa.mongo.conversion.AbstractThriftSerializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ProjectSerializer extends AbstractThriftSerializer<Project._Fields, Project> { - private final static Logger logger = LoggerFactory.getLogger(ProjectSerializer.class); - - @Override - protected Project._Fields[] getFieldValues() { - return Project._Fields.values(); - } - - @Override - protected Class<Project> getThriftClass() { - return null; - } -} \ 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/jpa/mongo/conversion/user/UserDeserializer.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/user/UserDeserializer.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/user/UserDeserializer.java deleted file mode 100644 index df595bf..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/user/UserDeserializer.java +++ /dev/null @@ -1,44 +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.mongo.conversion.user; - -import org.apache.airavata.model.workspace.User; -import org.apache.airavata.persistance.registry.jpa.mongo.conversion.AbstractThriftDeserializer; -import org.apache.thrift.TException; - -public class UserDeserializer extends - AbstractThriftDeserializer<User._Fields, User> { - - @Override - protected User._Fields getField(final String fieldName) { - return User._Fields.valueOf(fieldName); - } - - @Override - protected User newInstance() { - return new User(); - } - - @Override - protected void validate(final User instance) throws TException { - instance.validate(); - } -} \ 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/jpa/mongo/conversion/user/UserSerializer.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/user/UserSerializer.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/user/UserSerializer.java deleted file mode 100644 index a09aca2..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/conversion/user/UserSerializer.java +++ /dev/null @@ -1,40 +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.mongo.conversion.user; - -import org.apache.airavata.model.workspace.User; -import org.apache.airavata.persistance.registry.jpa.mongo.conversion.AbstractThriftSerializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class UserSerializer extends AbstractThriftSerializer<User._Fields, User> { - private final static Logger logger = LoggerFactory.getLogger(UserSerializer.class); - - @Override - protected User._Fields[] getFieldValues() { - return User._Fields.values(); - } - - @Override - protected Class<User> getThriftClass() { - return null; - } -} \ 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/jpa/mongo/dao/ExperimentDao.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/dao/ExperimentDao.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/dao/ExperimentDao.java deleted file mode 100644 index af15716..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/dao/ExperimentDao.java +++ /dev/null @@ -1,374 +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.mongo.dao; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.mongodb.*; -import com.mongodb.util.JSON; -import org.apache.airavata.model.workspace.experiment.Experiment; -import org.apache.airavata.model.workspace.experiment.TaskDetails; -import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails; -import org.apache.airavata.persistance.registry.jpa.mongo.conversion.ModelConversionHelper; -import org.apache.airavata.persistance.registry.jpa.mongo.utils.MongoUtil; -import org.apache.airavata.registry.cpi.RegistryException; -import org.apache.airavata.registry.cpi.ResultOrderType; -import org.apache.airavata.registry.cpi.utils.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class ExperimentDao{ - private final static Logger logger = LoggerFactory.getLogger(ExperimentDao.class); - - private static final String EXPERIMENTS_COLLECTION_NAME = "experiments"; - private DBCollection collection; - private ModelConversionHelper modelConversionHelper; - - private static final String EXPERIMENT_ID = "experiment_id"; - private static final String EXPERIMENT_NAME= "name"; - private static final String EXPERIMENT_DESCRIPTION = "description"; - private static final String USER_NAME = "user_name"; - private static final String GATEWAY = "gateway_execution_id"; - private static final String APPLICATION_ID = "application_id"; - private static final String EXPERIMENT_STATUS_STATE = "experiment_status.experiment_state"; - private static final String CREATION_TIME = "creation_time"; - - //Todo Nested Indexes - Its good if we can get rid of them - private static final String WORKFLOW_NODE_ID = "workflow_node_details_list.node_instance_id"; - private static final String TASK_ID = "workflow_node_details_list.task_details_list.task_id"; - - - public ExperimentDao(){ - collection = MongoUtil.getAiravataRegistry().getCollection(EXPERIMENTS_COLLECTION_NAME); - modelConversionHelper = new ModelConversionHelper(); - collection.dropIndexes(); - initIndexes(); - } - - /** - * If indexes are already defined this will simply ignore them - */ - private void initIndexes(){ - collection.createIndex(new BasicDBObject(EXPERIMENT_ID, 1), new BasicDBObject("unique", true)); - collection.createIndex(new BasicDBObject(WORKFLOW_NODE_ID, 1)); - collection.createIndex(new BasicDBObject(TASK_ID, 1)); - -// //Defining a full-text index on experiment name and experiment description -// BasicDBObject object = new BasicDBObject(); -// object.put(EXPERIMENT_NAME, "text"); -// object.put(EXPERIMENT_DESCRIPTION, "text"); -// collection.createIndex (object); - } - - public List<Experiment> getAllExperiments() throws RegistryException{ - List<Experiment> experimentList = new ArrayList<Experiment>(); - DBCursor cursor = collection.find(); - for(DBObject document: cursor){ - try { - experimentList.add((Experiment) modelConversionHelper.deserializeObject( - Experiment.class, document.toString())); - } catch (IOException e) { - throw new RegistryException(e); - } - } - return experimentList; - } - - public void createExperiment(Experiment experiment) throws RegistryException{ - try { - WriteResult result = collection.insert((DBObject) JSON.parse( - modelConversionHelper.serializeObject(experiment))); - logger.debug("No of inserted results "+ result.getN()); - } catch (JsonProcessingException e) { - throw new RegistryException(e); - } - } - - /** - * The following operation replaces the document with item equal to - * the given experiment id. The newly replaced document will only - * contain the the _id field and the fields in the replacement document. - * @param experiment - * @throws RegistryException - */ - public void updateExperiment(Experiment experiment) throws RegistryException{ - try { - DBObject query = BasicDBObjectBuilder.start().add( - EXPERIMENT_ID, experiment.getExperimentId()).get(); - WriteResult result = collection.update(query, (DBObject) JSON.parse( - modelConversionHelper.serializeObject(experiment))); - logger.debug("No of updated results "+ result.getN()); - } catch (JsonProcessingException e) { - throw new RegistryException(e); - } - } - - public void deleteExperiment(Experiment experiment) throws RegistryException{ - DBObject query = BasicDBObjectBuilder.start().add( - EXPERIMENT_ID, experiment.getExperimentId()).get(); - WriteResult result = collection.remove(query); - logger.debug("No of removed experiments " + result.getN()); - } - - - public Experiment getExperiment(String experimentId) throws RegistryException{ - try { - DBObject criteria = new BasicDBObject(EXPERIMENT_ID, experimentId); - DBObject doc = collection.findOne(criteria); - if(doc != null){ - String json = doc.toString(); - return (Experiment)modelConversionHelper.deserializeObject( - Experiment.class, json); - } - } catch (IOException e) { - throw new RegistryException(e); - } - return null; - } - - public List<Experiment> searchExperiments(Map<String, String> filters, int limit, - int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException{ - List<Experiment> experimentList = new ArrayList<Experiment>(); - BasicDBObjectBuilder queryBuilder = BasicDBObjectBuilder.start(); - for (String field : filters.keySet()) { - if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME)) { - queryBuilder.add(EXPERIMENT_NAME, new BasicDBObject( - "$regex", ".*" + filters.get(field) + ".*")); - } else if (field.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) { - queryBuilder.add(USER_NAME, filters.get(field)); - } else if (field.equals(Constants.FieldConstants.ExperimentConstants.GATEWAY)) { - queryBuilder.add(GATEWAY, filters.get(field)); - } else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_DESC)) { - queryBuilder.add(EXPERIMENT_DESCRIPTION, new BasicDBObject( - "$regex", ".*" + filters.get(field) + ".*")); - } else if (field.equals(Constants.FieldConstants.ExperimentConstants.APPLICATION_ID)) { - queryBuilder.add(APPLICATION_ID, filters.get(field)); - } else if (field.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS)) { - queryBuilder.add(EXPERIMENT_STATUS_STATE, filters.get(field)); - } else if (field.equals(Constants.FieldConstants.ExperimentConstants.FROM_DATE)) { - queryBuilder.add(CREATION_TIME,new BasicDBObject("$gte",filters.get(field))); - } else if (field.equals(Constants.FieldConstants.ExperimentConstants.TO_DATE)) { - queryBuilder.add(CREATION_TIME,new BasicDBObject("$lte",filters.get(field))); - } - } - - //handling pagination and ordering. ordering is allowed only on CREATION_TIME - DBCursor cursor; - if(limit > 0 && offset >= 0) { - if(orderByIdentifier != null && orderByIdentifier.equals( - Constants.FieldConstants.ExperimentConstants.CREATION_TIME)){ - if(resultOrderType.equals(ResultOrderType.ASC)) { - cursor = collection.find(queryBuilder.get()).sort(new BasicDBObject(CREATION_TIME, 1)) - .skip(offset).limit(limit); - }else{ - cursor = collection.find(queryBuilder.get()).sort(new BasicDBObject(CREATION_TIME, -1)) - .skip(offset).limit(limit); - } - }else { - cursor = collection.find(queryBuilder.get()).skip(offset).limit(limit); - } - }else{ - if(resultOrderType != null && resultOrderType.equals( - Constants.FieldConstants.ExperimentConstants.CREATION_TIME)){ - if(resultOrderType.equals(ResultOrderType.ASC)) { - cursor = collection.find(queryBuilder.get()).sort(new BasicDBObject(CREATION_TIME, 1)); - }else{ - cursor = collection.find(queryBuilder.get()).sort(new BasicDBObject(CREATION_TIME, -1)); - } - }else { - cursor = collection.find(queryBuilder.get()); - } - } - for(DBObject document: cursor){ - try { - experimentList.add((Experiment) modelConversionHelper.deserializeObject( - Experiment.class, document.toString())); - } catch (IOException e) { - throw new RegistryException(e); - } - } - return experimentList; - } - - public void createWFNode(String experimentId, WorkflowNodeDetails workflowNodeDetail) throws RegistryException{ - Experiment experiment = getExperiment(experimentId); - experiment.getWorkflowNodeDetailsList().add(workflowNodeDetail); - updateExperiment(experiment); - } - - public void updateWFNode(WorkflowNodeDetails workflowNodeDetail) throws RegistryException{ - Experiment experiment = getParentExperimentOfWFNode(workflowNodeDetail.getNodeInstanceId()); - for(WorkflowNodeDetails wfnd: experiment.getWorkflowNodeDetailsList()){ - if(wfnd.getNodeInstanceId().equals(workflowNodeDetail.getNodeInstanceId())){ - experiment.getWorkflowNodeDetailsList().remove(wfnd); - experiment.getWorkflowNodeDetailsList().add(workflowNodeDetail); - updateExperiment(experiment); - return; - } - } - } - - public void deleteWFNode(WorkflowNodeDetails workflowNodeDetail) throws RegistryException{ - Experiment experiment = getParentExperimentOfWFNode(workflowNodeDetail.getNodeInstanceId()); - for(WorkflowNodeDetails wfnd: experiment.getWorkflowNodeDetailsList()){ - if(wfnd.getNodeInstanceId().equals(workflowNodeDetail.getNodeInstanceId())){ - experiment.getWorkflowNodeDetailsList().remove(wfnd); - updateExperiment(experiment); - return; - } - } - } - - public WorkflowNodeDetails getWFNode(String nodeId) throws RegistryException{ - Experiment experiment = getParentExperimentOfWFNode(nodeId); - for(WorkflowNodeDetails wfnd: experiment.getWorkflowNodeDetailsList()){ - if(wfnd.getNodeInstanceId().equals(nodeId)){ - return wfnd; - } - } - return null; - } - - public void createTaskDetail(String nodeId, TaskDetails taskDetail) throws RegistryException{ - Experiment experiment = getParentExperimentOfWFNode(nodeId); - for(WorkflowNodeDetails wfnd: experiment.getWorkflowNodeDetailsList()){ - if(wfnd.getNodeInstanceId().equals(nodeId)){ - wfnd.getTaskDetailsList().add(taskDetail); - updateExperiment(experiment); - return; - } - } - } - - public void updateTaskDetail(TaskDetails taskDetail) throws RegistryException{ - Experiment experiment = getParentExperimentOfTask(taskDetail.getTaskId()); - for(WorkflowNodeDetails wfnd: experiment.getWorkflowNodeDetailsList()){ - for(TaskDetails taskDetails: wfnd.getTaskDetailsList()){ - if(taskDetails.getTaskId().equals(taskDetail)){ - wfnd.getTaskDetailsList().remove(taskDetail); - wfnd.getTaskDetailsList().add(taskDetail); - updateExperiment(experiment); - return; - } - } - } - } - - public void deleteTaskDetail(TaskDetails taskDetail) throws RegistryException{ - Experiment experiment = getParentExperimentOfTask(taskDetail.getTaskId()); - for(WorkflowNodeDetails wfnd: experiment.getWorkflowNodeDetailsList()){ - for(TaskDetails taskDetails: wfnd.getTaskDetailsList()){ - if(taskDetails.getTaskId().equals(taskDetail)){ - wfnd.getTaskDetailsList().remove(taskDetail); - updateExperiment(experiment); - return; - } - } - } - } - - public TaskDetails getTaskDetail(String taskId) throws RegistryException{ - Experiment experiment = getParentExperimentOfTask(taskId); - for(WorkflowNodeDetails wfnd: experiment.getWorkflowNodeDetailsList()){ - for(TaskDetails taskDetails: wfnd.getTaskDetailsList()){ - if(taskDetails.getTaskId().equals(taskId)){ - return taskDetails; - } - } - } - return null; - } - - - /** - * Method to get parent Experiment of the given workflow node instance id - * @param nodeInstanceId - * @return - * @throws RegistryException - */ - public Experiment getParentExperimentOfWFNode(String nodeInstanceId) throws RegistryException{ - try { - DBObject criteria = new BasicDBObject(WORKFLOW_NODE_ID, nodeInstanceId); - DBObject doc = collection.findOne(criteria); - if(doc != null){ - String json = doc.toString(); - return (Experiment)modelConversionHelper.deserializeObject( - Experiment.class, json); - } - } catch (IOException e) { - throw new RegistryException(e); - } - return null; - } - - /** - * Method to get the parent experiment of the given task id - * @param taskId - * @return - * @throws RegistryException - */ - public Experiment getParentExperimentOfTask(String taskId) throws RegistryException{ - try { - DBObject criteria = new BasicDBObject(TASK_ID, taskId); - DBObject doc = collection.findOne(criteria); - if(doc != null){ - String json = doc.toString(); - return (Experiment)modelConversionHelper.deserializeObject( - Experiment.class, json); - } - } catch (IOException e) { - throw new RegistryException(e); - } - return null; - } - - /** - * Method to get the parent workflow node of the given task id - * @param taskId - * @return - * @throws RegistryException - */ - public WorkflowNodeDetails getParentWFNodeOfTask(String taskId) throws RegistryException{ - try { - DBObject criteria = new BasicDBObject(TASK_ID, taskId); - DBObject doc = collection.findOne(criteria); - if(doc != null){ - String json = doc.toString(); - Experiment experiment = (Experiment)modelConversionHelper.deserializeObject( - Experiment.class, json); - for(WorkflowNodeDetails wfnd: experiment.getWorkflowNodeDetailsList()){ - for(TaskDetails taskDetails: wfnd.getTaskDetailsList()){ - if(taskDetails.getTaskId().equals(taskId)){ - return wfnd; - } - } - } - } - } catch (IOException e) { - throw new RegistryException(e); - } - return null; - } -} \ 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/jpa/mongo/dao/ProjectDao.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/dao/ProjectDao.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/dao/ProjectDao.java deleted file mode 100644 index e3ea7eb..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/dao/ProjectDao.java +++ /dev/null @@ -1,189 +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.mongo.dao; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.mongodb.*; -import com.mongodb.util.JSON; -import org.apache.airavata.model.workspace.Project; -import org.apache.airavata.persistance.registry.jpa.mongo.conversion.ModelConversionHelper; -import org.apache.airavata.persistance.registry.jpa.mongo.utils.MongoUtil; -import org.apache.airavata.registry.cpi.RegistryException; -import org.apache.airavata.registry.cpi.ResultOrderType; -import org.apache.airavata.registry.cpi.utils.Constants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class ProjectDao { - private final static Logger logger = LoggerFactory.getLogger(ProjectDao.class); - - private static final String PROJECTS_COLLECTION_NAME = "projects"; - private DBCollection collection; - private ModelConversionHelper modelConversionHelper; - - private static final String PROJECT_ID = "project_id"; - private static final String PROJECT_NAME = "name"; - private static final String PROJECT_DESCRIPTION = "description"; - private static final String PROJECT_OWNER = "owner"; - private static final String PROJECT_CREATION_TIME = "creation_time"; - - public ProjectDao(){ - collection = MongoUtil.getAiravataRegistry().getCollection(PROJECTS_COLLECTION_NAME); - modelConversionHelper = new ModelConversionHelper(); - collection.dropIndexes(); - initIndexes(); - } - - /** - * If indexes are already defined this will simply ignore them - */ - private void initIndexes(){ - collection.createIndex(new BasicDBObject(PROJECT_ID, 1), new BasicDBObject("unique", true)); - collection.createIndex(new BasicDBObject(PROJECT_NAME, 1)); - collection.createIndex(new BasicDBObject(PROJECT_OWNER, 1)); - collection.createIndex(new BasicDBObject(PROJECT_DESCRIPTION, 1)); - collection.createIndex(new BasicDBObject(PROJECT_CREATION_TIME, 1)); - } - - public List<Project> getAllProjects() throws RegistryException{ - List<Project> projectList = new ArrayList(); - DBCursor cursor = collection.find(); - for(DBObject document: cursor){ - try { - projectList.add((Project) modelConversionHelper.deserializeObject( - Project.class, document.toString())); - } catch (IOException e) { - throw new RegistryException(e); - } - } - return projectList; - } - - public void createProject(Project project) throws RegistryException{ - try { - WriteResult result = collection.insert((DBObject) JSON.parse( - modelConversionHelper.serializeObject(project))); - logger.debug("No of inserted results "+ result.getN()); - } catch (JsonProcessingException e) { - throw new RegistryException(e); - } - } - - /** - * The following operation replaces the document with item equal to - * the given project id. The newly replaced document will only - * contain the the _id field and the fields in the replacement document. - * @param project - * @throws org.apache.airavata.registry.cpi.RegistryException - */ - public void updateProject(Project project) throws RegistryException{ - try { - DBObject query = BasicDBObjectBuilder.start().add( - PROJECT_ID, project.getProjectId()).get(); - WriteResult result = collection.update(query, (DBObject) JSON.parse( - modelConversionHelper.serializeObject(project))); - logger.debug("No of updated results "+ result.getN()); - } catch (JsonProcessingException e) { - throw new RegistryException(e); - } - } - - public void deleteProject(Project project) throws RegistryException{ - DBObject query = BasicDBObjectBuilder.start().add( - PROJECT_ID, project.getProjectId()).get(); - WriteResult result = collection.remove(query); - logger.debug("No of removed experiments " + result.getN()); - } - - public Project getProject(String projectId) throws RegistryException{ - try { - DBObject criteria = new BasicDBObject(PROJECT_ID, projectId); - DBObject doc = collection.findOne(criteria); - if(doc != null){ - String json = doc.toString(); - return (Project)modelConversionHelper.deserializeObject( - Project.class, json); - } - } catch (IOException e) { - throw new RegistryException(e); - } - return null; - } - - public List<Project> searchProjects(Map<String, String> filters, int limit, - int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException{ - List<Project> projectList = new ArrayList(); - BasicDBObjectBuilder queryBuilder = BasicDBObjectBuilder.start(); - for (String field : filters.keySet()) { -// if (field.equals(Constants.FieldConstants.ProjectConstants.PROJECT_NAME)){ -// fil.put(AbstractResource.ProjectConstants.PROJECT_NAME, filters.get(field)); -// }else if (field.equals(Constants.FieldConstants.ProjectConstants.OWNER)){ -// fil.put(AbstractResource.ProjectConstants.USERNAME, filters.get(field)); -// }else if (field.equals(Constants.FieldConstants.ProjectConstants.DESCRIPTION)){ -// fil.put(AbstractResource.ProjectConstants.DESCRIPTION, filters.get(field)); -// }else if (field.equals(Constants.FieldConstants.ProjectConstants.GATEWAY_ID)){ -// fil.put(AbstractResource.ProjectConstants.GATEWAY_ID, filters.get(field)); -// } - } - - //handling pagination and ordering. ordering is allowed only on PROJECT_CREATION_TIME - DBCursor cursor; - if(limit > 0 && offset >= 0) { - if(orderByIdentifier != null && orderByIdentifier.equals( - Constants.FieldConstants.ProjectConstants.CREATION_TIME)){ - if(resultOrderType.equals(ResultOrderType.ASC)) { - cursor = collection.find(queryBuilder.get()).sort(new BasicDBObject(PROJECT_CREATION_TIME, 1)) - .skip(offset).limit(limit); - }else{ - cursor = collection.find(queryBuilder.get()).sort(new BasicDBObject(PROJECT_CREATION_TIME, -1)) - .skip(offset).limit(limit); - } - }else { - cursor = collection.find(queryBuilder.get()).skip(offset).limit(limit); - } - }else{ - if(resultOrderType != null && resultOrderType.equals( - Constants.FieldConstants.ProjectConstants.CREATION_TIME)){ - if(resultOrderType.equals(ResultOrderType.ASC)) { - cursor = collection.find(queryBuilder.get()).sort(new BasicDBObject(PROJECT_CREATION_TIME, 1)); - }else{ - cursor = collection.find(queryBuilder.get()).sort(new BasicDBObject(PROJECT_CREATION_TIME, -1)); - } - }else { - cursor = collection.find(queryBuilder.get()); - } - } - for(DBObject document: cursor){ - try { - projectList.add((Project) modelConversionHelper.deserializeObject( - Project.class, document.toString())); - } catch (IOException e) { - throw new RegistryException(e); - } - } - return projectList; - } -} \ 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/jpa/mongo/utils/MongoUtil.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/utils/MongoUtil.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/utils/MongoUtil.java deleted file mode 100644 index 4b7a2f9..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/mongo/utils/MongoUtil.java +++ /dev/null @@ -1,70 +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.mongo.utils; - -import com.mongodb.DB; -import com.mongodb.MongoClient; -import com.mongodb.MongoException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MongoUtil { - private final static Logger logger = LoggerFactory.getLogger(MongoUtil.class); - - private static final int port = 27017; - private static final String host = "localhost"; - private static MongoClient mongoClient = null; - private static DB airavataRegistry; - public static String AIRAVATA_REGISTRY_NAME = "airavata-registry"; - - public static MongoClient getMongoClient() { - if (mongoClient == null) { - try { - mongoClient = new MongoClient(host, port); - logger.debug("New Mongo Client created with [" + host + "] and [" - + port + "]"); - } catch (MongoException e) { - logger.error(e.getMessage()); - } - } - return mongoClient; - } - - public static DB getAiravataRegistry(){ - if (airavataRegistry == null) { - try { - airavataRegistry = getMongoClient().getDB(AIRAVATA_REGISTRY_NAME); - } catch (MongoException e) { - logger.error(e.getMessage()); - } - } - return airavataRegistry; - } - - public static void dropAiravataRegistry(){ - try { - getMongoClient().dropDatabase(AIRAVATA_REGISTRY_NAME); - logger.debug("Dropped Airavata Registry"); - } catch (MongoException e) { - logger.error(e.getMessage()); - } - } -} \ 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/jpa/resources/AbstractResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java deleted file mode 100644 index e05d59d..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java +++ /dev/null @@ -1,317 +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.registry.cpi.RegistryException; - -import java.util.ArrayList; -import java.util.List; - -public abstract class AbstractResource implements Resource { - // table names - public static final String GATEWAY = "Gateway"; - public static final String CONFIGURATION = "Configuration"; - public static final String USERS = "Users"; - public static final String GATEWAY_WORKER = "Gateway_Worker"; - public static final String PROJECT = "Project"; - public static final String PROJECT_USER = "ProjectUser"; - public static final String EXPERIMENT = "Experiment"; - public static final String NOTIFICATION_EMAIL = "Notification_Email"; - public static final String EXPERIMENT_CONFIG_DATA = "ExperimentConfigData"; - public static final String EXPERIMENT_INPUT = "Experiment_Input"; - public static final String EXPERIMENT_OUTPUT = "Experiment_Output"; - public static final String WORKFLOW_NODE_DETAIL = "WorkflowNodeDetail"; - public static final String TASK_DETAIL = "TaskDetail"; - public static final String ERROR_DETAIL = "ErrorDetail"; - public static final String APPLICATION_INPUT = "ApplicationInput"; - public static final String APPLICATION_OUTPUT = "ApplicationOutput"; - public static final String NODE_INPUT = "NodeInput"; - public static final String NODE_OUTPUT = "NodeOutput"; - public static final String JOB_DETAIL = "JobDetail"; - public static final String DATA_TRANSFER_DETAIL = "DataTransferDetail"; - public static final String STATUS = "Status"; - public static final String CONFIG_DATA = "ExperimentConfigData"; - public static final String COMPUTATIONAL_RESOURCE_SCHEDULING = "Computational_Resource_Scheduling"; - public static final String ADVANCE_INPUT_DATA_HANDLING = "AdvancedInputDataHandling"; - public static final String ADVANCE_OUTPUT_DATA_HANDLING = "AdvancedOutputDataHandling"; - public static final String QOS_PARAMS = "QosParam"; - - - // Gateway Table - public final class GatewayConstants { - public static final String GATEWAY_ID = "gateway_id"; - public static final String GATEWAY_NAME = "gateway_name"; - public static final String DOMAIN = "domain"; - public static final String EMAIL_ADDRESS = "emailAddress"; - } - - // Configuration Table - public final class ConfigurationConstants { - // public static final String CONFIG_ID = "config_ID"; - public static final String CONFIG_KEY = "config_key"; - public static final String CONFIG_VAL = "config_val"; - public static final String EXPIRE_DATE = "expire_date"; - public static final String CATEGORY_ID = "category_id"; - public static final String CATEGORY_ID_DEFAULT_VALUE = "SYSTEM"; - } - - // Users table - public final class UserConstants { - public static final String USERNAME = "user_name"; - public static final String PASSWORD = "password"; - } - - // Gateway_Worker table - public final class GatewayWorkerConstants { - public static final String USERNAME = "user_name"; - public static final String GATEWAY_ID = "gateway_id"; - } - - // Project table - public final class ProjectConstants { - public static final String GATEWAY_ID = "gateway_id"; - public static final String USERNAME = "user_name"; - public static final String PROJECT_NAME = "project_name"; - public static final String PROJECT_ID = "project_id"; - public static final String DESCRIPTION = "description"; - public static final String CREATION_TIME = "creationTime"; - } - - // Project table - public final class ProjectUserConstants { - public static final String USERNAME = "userName"; - public static final String PROJECT_ID = "projectID"; - } - - // Experiment table - public final class ExperimentConstants { - public static final String PROJECT_ID = "projectID"; - public static final String EXECUTION_USER = "executionUser"; - public static final String GATEWAY_ID = "gatewayId"; - public static final String EXPERIMENT_ID = "expId"; - public static final String EXPERIMENT_NAME = "expName"; - public static final String DESCRIPTION = "expDesc"; - public static final String CREATION_TIME = "creationTime"; - public static final String APPLICATION_ID = "applicationId"; - public static final String APPLICATION_VERSION = "appVersion"; - public static final String WORKFLOW_TEMPLATE_ID = "workflowTemplateId"; - public static final String WORKFLOW_TEMPLATE_VERSION = "workflowTemplateVersion"; - public static final String WORKFLOW_EXECUTION_ID = "workflowExecutionId"; - } - - // Experiment Configuration Data table - public final class ExperimentConfigurationDataConstants { - public static final String EXPERIMENT_ID = "expId"; - public static final String AIRAVATA_AUTO_SCHEDULE = "airavataAutoSchedule"; - public static final String OVERRIDE_MANUAL_SCHEDULE = "overrideManualParams"; - public static final String SHARE_EXPERIMENT = "shareExp"; - } - - public final class NotificationEmailConstants { - public static final String EXPERIMENT_ID = "experiment_id"; - public static final String TASK_ID = "taskId"; - public static final String EMAIL_ADDRESS = "emailAddress"; - } - - //Experiment Input table - public final class ExperimentInputConstants { - public static final String EXPERIMENT_ID = "experiment_id"; - public static final String EXPERIMENT_INPUT_KEY = "ex_key"; - public static final String EXPERIMENT_INPUT_VAL = "value"; - public static final String INPUT_TYPE = "inputType"; - public static final String METADATA = "metadata"; - } - - //Experiment Output table - public final class ExperimentOutputConstants { - public static final String EXPERIMENT_ID = "experiment_id"; - public static final String EXPERIMENT_OUTPUT_KEY = "ex_key"; - public static final String EXPERIMENT_OUTPUT_VAL = "value"; - public static final String OUTPUT_TYPE = "outputKeyType"; - public static final String METADATA = "metadata"; - } - - // Workflow_Data table - public final class WorkflowNodeDetailsConstants { - public static final String EXPERIMENT_ID = "expId"; - public static final String NODE_INSTANCE_ID = "nodeId"; - public static final String CREATION_TIME = "creationTime"; - public static final String NODE_NAME = "nodeName"; - } - - // TaskDetail table - public final class TaskDetailConstants { - public static final String TASK_ID = "taskId"; - public static final String NODE_INSTANCE_ID = "nodeId"; - public static final String CREATION_TIME = "creationTime"; - public static final String APPLICATION_ID = "appId"; - public static final String APPLICATION_VERSION = "appVersion"; - } - - // ErrorDetails table - public final class ErrorDetailConstants { - public static final String ERROR_ID = "errorID"; - public static final String EXPERIMENT_ID = "expId"; - public static final String TASK_ID = "taskId"; - public static final String JOB_ID = "jobId"; - public static final String NODE_INSTANCE_ID = "nodeId"; - public static final String CREATION_TIME = "creationTime"; - public static final String ACTUAL_ERROR_MESSAGE = "actualErrorMsg"; - public static final String USER_FRIEDNLY_ERROR_MSG = "userFriendlyErrorMsg"; - public static final String TRANSIENT_OR_PERSISTENT = "transientPersistent"; - public static final String ERROR_CATEGORY = "errorCategory"; - public static final String CORRECTIVE_ACTION = "correctiveAction"; - public static final String ACTIONABLE_GROUP = "actionableGroup"; - } - - // ApplicationInput table - public final class ApplicationInputConstants { - public static final String TASK_ID = "taskId"; - public static final String INPUT_KEY = "inputKey"; - public static final String INPUT_KEY_TYPE = "inputKeyType"; - public static final String METADATA = "metadata"; - public static final String VALUE = "value"; - } - - // ApplicationOutput table - public final class ApplicationOutputConstants { - public static final String TASK_ID = "taskId"; - public static final String OUTPUT_KEY = "outputKey"; - public static final String OUTPUT_KEY_TYPE = "outputKeyType"; - public static final String METADATA = "metadata"; - public static final String VALUE = "value"; - } - - // NodeInput table - public final class NodeInputConstants { - public static final String NODE_INSTANCE_ID = "nodeId"; - public static final String INPUT_KEY = "inputKey"; - public static final String INPUT_KEY_TYPE = "inputKeyType"; - public static final String METADATA = "metadata"; - public static final String VALUE = "value"; - } - - // NodeOutput table - public final class NodeOutputConstants { - public static final String NODE_INSTANCE_ID = "nodeId"; - public static final String OUTPUT_KEY = "outputKey"; - public static final String OUTPUT_KEY_TYPE = "outputKeyType"; - public static final String METADATA = "metadata"; - public static final String VALUE = "value"; - } - - // Job Details table constants - public final class JobDetailConstants{ - public static final String JOB_ID = "jobId"; - public static final String TASK_ID = "taskId"; - public static final String JOB_DESCRIPTION = "jobDescription"; - public static final String CREATION_TIME = "jobDescription"; - } - - // Data transfer Details table constants - public final class DataTransferDetailConstants{ - public static final String TRANSFER_ID = "transferId"; - public static final String TASK_ID = "taskId"; - public static final String TRANSFER_DESC = "transferDesc"; - public static final String CREATION_TIME = "creationTime"; - } - - // Status table constants - public final class StatusConstants { - public static final String STATUS_ID = "statusId"; - public static final String EXPERIMENT_ID = "expId"; - public static final String NODE_INSTANCE_ID = "nodeId"; - public static final String TRANSFER_ID = "transferId"; - public static final String TASK_ID = "taskId"; - public static final String JOB_ID = "jobId"; - public static final String STATE = "state"; - public static final String STATUS_UPDATE_TIME = "statusUpdateTime"; - public static final String STATUS_TYPE = "statusType"; - } - - public static final class ComputationalResourceSchedulingConstants{ - public static final String RESOURCE_SCHEDULING_ID = "schedulingId"; - public static final String EXPERIMENT_ID = "expId"; - public static final String TASK_ID = "taskId"; - public static final String RESOURCE_HOST_ID = "resourceHostId"; - public static final String CPU_COUNT = "cpuCount"; - public static final String NODE_COUNT = "nodeCount"; - public static final String NO_OF_THREADS = "numberOfThreads"; - public static final String QUEUE_NAME = "queueName"; - public static final String WALLTIME_LIMIT = "wallTimeLimit"; - public static final String JOB_START_TIME = "jobStartTime"; - public static final String TOTAL_PHYSICAL_MEMORY = "totalPhysicalmemory"; - public static final String COMPUTATIONAL_PROJECT_ACCOUNT = "projectName"; - } - - public static final class AdvancedInputDataHandlingConstants { - public static final String INPUT_DATA_HANDLING_ID = "dataHandlingId"; - public static final String EXPERIMENT_ID = "expId"; - public static final String TASK_ID = "taskId"; - public static final String WORKING_DIR_PARENT = "parentWorkingDir"; - public static final String UNIQUE_WORKING_DIR = "workingDir"; - public static final String STAGE_INPUT_FILES_TO_WORKING_DIR = "stageInputsToWorkingDir"; - public static final String CLEAN_AFTER_JOB = "cleanAfterJob"; - } - - public static final class AdvancedOutputDataHandlingConstants { - public static final String OUTPUT_DATA_HANDLING_ID = "outputDataHandlingId"; - public static final String EXPERIMENT_ID = "expId"; - public static final String TASK_ID = "taskId"; - public static final String OUTPUT_DATA_DIR = "outputDataDir"; - public static final String DATA_REG_URL = "dataRegUrl"; - public static final String PERSIST_OUTPUT_DATA = "persistOutputData"; - } - - public static final class QosParamsConstants { - public static final String QOS_ID = "qosId"; - public static final String EXPERIMENT_ID = "expId"; - public static final String TASK_ID = "taskId"; - public static final String START_EXECUTION_AT = "startExecutionAt"; - public static final String EXECUTE_BEFORE = "executeBefore"; - public static final String NO_OF_RETRIES = "noOfRetries"; - } - - - protected AbstractResource() { - } - - public boolean isExists(ResourceType type, Object name) throws RegistryException { - try { - return get(type, name) != null; - } catch (Exception e) { - return false; - } - } - - @SuppressWarnings("unchecked") - public static <T> List<T> getResourceList(List<Resource> resources, - Class<?> T) { - List<T> list = new ArrayList<T>(); - for (Resource o : resources) { - list.add((T) o); - } - return list; - } - -} 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/AdvanceInputDataHandlingResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvanceInputDataHandlingResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvanceInputDataHandlingResource.java deleted file mode 100644 index 4ad08e4..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvanceInputDataHandlingResource.java +++ /dev/null @@ -1,168 +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.AdvancedInputDataHandling; -import org.apache.airavata.persistance.registry.jpa.model.Experiment; -import org.apache.airavata.persistance.registry.jpa.model.TaskDetail; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import java.util.List; - -public class AdvanceInputDataHandlingResource extends AbstractResource { - private static final Logger logger = LoggerFactory.getLogger(AdvanceInputDataHandlingResource.class); - private int dataHandlingId = 0; - private ExperimentResource experimentResource; - private TaskDetailResource taskDetailResource; - private String workingDirParent; - private String workingDir; - private boolean stageInputFiles; - private boolean cleanAfterJob; - - public int getDataHandlingId() { - return dataHandlingId; - } - - public void setDataHandlingId(int dataHandlingId) { - this.dataHandlingId = dataHandlingId; - } - - public ExperimentResource getExperimentResource() { - return experimentResource; - } - - public void setExperimentResource(ExperimentResource experimentResource) { - this.experimentResource = experimentResource; - } - - public TaskDetailResource getTaskDetailResource() { - return taskDetailResource; - } - - public void setTaskDetailResource(TaskDetailResource taskDetailResource) { - this.taskDetailResource = taskDetailResource; - } - - public String getWorkingDirParent() { - return workingDirParent; - } - - public void setWorkingDirParent(String workingDirParent) { - this.workingDirParent = workingDirParent; - } - - public String getWorkingDir() { - return workingDir; - } - - public void setWorkingDir(String workingDir) { - this.workingDir = workingDir; - } - - public boolean isStageInputFiles() { - return stageInputFiles; - } - - public void setStageInputFiles(boolean stageInputFiles) { - this.stageInputFiles = stageInputFiles; - } - - public boolean isCleanAfterJob() { - return cleanAfterJob; - } - - public void setCleanAfterJob(boolean cleanAfterJob) { - this.cleanAfterJob = cleanAfterJob; - } - - - public Resource create(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void remove(ResourceType type, Object name) throws RegistryException { - logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public Resource get(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public List<Resource> get(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void save() throws RegistryException{ - EntityManager em = null; - try { - em = ResourceUtils.getEntityManager(); - em.getTransaction().begin(); - AdvancedInputDataHandling dataHandling; - if (dataHandlingId != 0) { - dataHandling = em.find(AdvancedInputDataHandling.class, dataHandlingId); - dataHandling.setDataHandlingId(dataHandlingId); - } else { - dataHandling = new AdvancedInputDataHandling(); - } - Experiment experiment = em.find(Experiment.class, experimentResource.getExpID()); - if (taskDetailResource != null) { - TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId()); - dataHandling.setTaskId(taskDetailResource.getTaskId()); - dataHandling.setTask(taskDetail); - } - dataHandling.setExpId(experimentResource.getExpID()); - dataHandling.setExperiment(experiment); - dataHandling.setWorkingDir(workingDir); - dataHandling.setParentWorkingDir(workingDirParent); - dataHandling.setStageInputsToWorkingDir(stageInputFiles); - dataHandling.setCleanAfterJob(cleanAfterJob); - em.persist(dataHandling); - dataHandlingId = dataHandling.getDataHandlingId(); - em.getTransaction().commit(); - em.close(); - }catch (Exception e){ - logger.error(e.getMessage(), e); - throw new RegistryException(e); - }finally { - if (em != null && em.isOpen()){ - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java deleted file mode 100644 index bb3cc80..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java +++ /dev/null @@ -1,159 +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.AdvancedOutputDataHandling; -import org.apache.airavata.persistance.registry.jpa.model.Experiment; -import org.apache.airavata.persistance.registry.jpa.model.TaskDetail; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.EntityManager; -import java.util.List; - -public class AdvancedOutputDataHandlingResource extends AbstractResource { - private static final Logger logger = LoggerFactory.getLogger(AdvancedOutputDataHandlingResource.class); - private int outputDataHandlingId = 0; - private ExperimentResource experimentResource; - private TaskDetailResource taskDetailResource; - private String outputDataDir; - private String dataRegUrl; - private boolean persistOutputData; - - public int getOutputDataHandlingId() { - return outputDataHandlingId; - } - - public void setOutputDataHandlingId(int outputDataHandlingId) { - this.outputDataHandlingId = outputDataHandlingId; - } - - public ExperimentResource getExperimentResource() { - return experimentResource; - } - - public void setExperimentResource(ExperimentResource experimentResource) { - this.experimentResource = experimentResource; - } - - public TaskDetailResource getTaskDetailResource() { - return taskDetailResource; - } - - public void setTaskDetailResource(TaskDetailResource taskDetailResource) { - this.taskDetailResource = taskDetailResource; - } - - public String getOutputDataDir() { - return outputDataDir; - } - - public void setOutputDataDir(String outputDataDir) { - this.outputDataDir = outputDataDir; - } - - public String getDataRegUrl() { - return dataRegUrl; - } - - public void setDataRegUrl(String dataRegUrl) { - this.dataRegUrl = dataRegUrl; - } - - public boolean isPersistOutputData() { - return persistOutputData; - } - - public void setPersistOutputData(boolean persistOutputData) { - this.persistOutputData = persistOutputData; - } - - - public Resource create(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void remove(ResourceType type, Object name) throws RegistryException { - logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public Resource get(ResourceType type, Object name) throws RegistryException { - logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public List<Resource> get(ResourceType type) throws RegistryException{ - logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void save() throws RegistryException { - EntityManager em = null; - try { - em = ResourceUtils.getEntityManager(); - em.getTransaction().begin(); - AdvancedOutputDataHandling dataHandling; - if (outputDataHandlingId != 0 ){ - dataHandling = em.find(AdvancedOutputDataHandling.class, outputDataHandlingId); - dataHandling.setOutputDataHandlingId(outputDataHandlingId); - }else { - dataHandling = new AdvancedOutputDataHandling(); - } - Experiment experiment = em.find(Experiment.class, experimentResource.getExpID()); - if (taskDetailResource !=null){ - TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId()); - dataHandling.setTaskId(taskDetailResource.getTaskId()); - dataHandling.setTask(taskDetail); - } - - dataHandling.setExpId(experimentResource.getExpID()); - dataHandling.setExperiment(experiment); - dataHandling.setDataRegUrl(dataRegUrl); - dataHandling.setOutputDataDir(outputDataDir); - dataHandling.setPersistOutputData(persistOutputData); - em.persist(dataHandling); - outputDataHandlingId = dataHandling.getOutputDataHandlingId(); - em.getTransaction().commit(); - em.close(); - }catch (Exception e){ - logger.error(e.getMessage(), e); - throw new RegistryException(e); - }finally { - if (em != null && em.isOpen()){ - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java deleted file mode 100644 index d04fc85..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java +++ /dev/null @@ -1,235 +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 java.util.List; - -import javax.persistence.EntityManager; - -import org.apache.airavata.persistance.registry.jpa.Resource; -import org.apache.airavata.persistance.registry.jpa.ResourceType; -import org.apache.airavata.persistance.registry.jpa.ResourceUtils; -import org.apache.airavata.persistance.registry.jpa.model.ApplicationInput; -import org.apache.airavata.persistance.registry.jpa.model.ApplicationInput_PK; -import org.apache.airavata.persistance.registry.jpa.model.TaskDetail; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ApplicationInputResource extends AbstractResource { - private static final Logger logger = LoggerFactory.getLogger(ApplicationInputResource.class); - private TaskDetailResource taskDetailResource; - private String inputKey; - private String dataType; - private String metadata; - private String value; - private String appArgument; - private boolean standardInput; - private String userFriendlyDesc; - private int inputOrder; - private boolean isRequired; - private boolean requiredToCMD; - private boolean dataStaged; - - public boolean isRequired() { - return isRequired; - } - - public void setRequired(boolean isRequired) { - this.isRequired = isRequired; - } - - public boolean isRequiredToCMD() { - return requiredToCMD; - } - - public void setRequiredToCMD(boolean requiredToCMD) { - this.requiredToCMD = requiredToCMD; - } - - public boolean isDataStaged() { - return dataStaged; - } - - public void setDataStaged(boolean dataStaged) { - this.dataStaged = dataStaged; - } - - public int getInputOrder() { - return inputOrder; - } - - public void setInputOrder(int inputOrder) { - this.inputOrder = inputOrder; - } - - public String getAppArgument() { - return appArgument; - } - - public void setAppArgument(String appArgument) { - this.appArgument = appArgument; - } - - public boolean isStandardInput() { - return standardInput; - } - - public void setStandardInput(boolean standardInput) { - this.standardInput = standardInput; - } - - public String getUserFriendlyDesc() { - return userFriendlyDesc; - } - - public void setUserFriendlyDesc(String userFriendlyDesc) { - this.userFriendlyDesc = userFriendlyDesc; - } - - public String getInputKey() { - return inputKey; - } - - public void setInputKey(String inputKey) { - this.inputKey = inputKey; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public String getMetadata() { - return metadata; - } - - public void setMetadata(String metadata) { - this.metadata = metadata; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public TaskDetailResource getTaskDetailResource() { - return taskDetailResource; - } - - public void setTaskDetailResource(TaskDetailResource taskDetailResource) { - this.taskDetailResource = taskDetailResource; - } - - - public Resource create(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void remove(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public Resource get(ResourceType type, Object name) throws RegistryException { - logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public List<Resource> get(ResourceType type) throws RegistryException{ - logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void save() throws RegistryException { - EntityManager em = null; - try { - em = ResourceUtils.getEntityManager(); - ApplicationInput existingInput = em.find(ApplicationInput.class, new ApplicationInput_PK(inputKey, taskDetailResource.getTaskId())); - em.close(); - - em = ResourceUtils.getEntityManager(); - em.getTransaction().begin(); - ApplicationInput applicationInput = new ApplicationInput(); - TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId()); - applicationInput.setTask(taskDetail); - applicationInput.setTaskId(taskDetail.getTaskId()); - applicationInput.setInputKey(inputKey); - applicationInput.setDataType(dataType); - applicationInput.setAppArgument(appArgument); - applicationInput.setStandardInput(standardInput); - applicationInput.setUserFriendlyDesc(userFriendlyDesc); - applicationInput.setInputOrder(inputOrder); - applicationInput.setRequiredToCMD(requiredToCMD); - applicationInput.setRequired(isRequired); - applicationInput.setDataStaged(dataStaged); - if (value != null){ - applicationInput.setValue(value.toCharArray()); - } - - applicationInput.setMetadata(metadata); - - if (existingInput != null) { - existingInput.setTask(taskDetail); - existingInput.setTaskId(taskDetail.getTaskId()); - existingInput.setInputKey(inputKey); - existingInput.setDataType(dataType); - existingInput.setAppArgument(appArgument); - existingInput.setStandardInput(standardInput); - existingInput.setUserFriendlyDesc(userFriendlyDesc); - existingInput.setInputOrder(inputOrder); - existingInput.setRequiredToCMD(requiredToCMD); - existingInput.setRequired(isRequired); - existingInput.setDataStaged(dataStaged); - if (value != null){ - existingInput.setValue(value.toCharArray()); - } - existingInput.setMetadata(metadata); - applicationInput = em.merge(existingInput); - } else { - em.persist(applicationInput); - } - em.getTransaction().commit(); - em.close(); - } catch (Exception e) { - throw new RegistryException(e.getMessage()); - } finally { - if (em != null && em.isOpen()) { - if (em.getTransaction().isActive()){ - em.getTransaction().rollback(); - } - em.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/801489bf/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java deleted file mode 100644 index c937df3..0000000 --- a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java +++ /dev/null @@ -1,213 +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 java.util.List; - -import javax.persistence.EntityManager; - -import org.apache.airavata.persistance.registry.jpa.Resource; -import org.apache.airavata.persistance.registry.jpa.ResourceType; -import org.apache.airavata.persistance.registry.jpa.ResourceUtils; -import org.apache.airavata.persistance.registry.jpa.model.ApplicationOutput; -import org.apache.airavata.persistance.registry.jpa.model.ApplicationOutput_PK; -import org.apache.airavata.persistance.registry.jpa.model.TaskDetail; -import org.apache.airavata.registry.cpi.RegistryException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ApplicationOutputResource extends AbstractResource { - private static final Logger logger = LoggerFactory.getLogger(ApplicationOutputResource.class); - private TaskDetailResource taskDetailResource; - private String outputKey; - private String dataType; - private String value; - private boolean isRequired; - private boolean dataMovement; - private String dataNameLocation; - private boolean requiredToCMD; - private String searchQuery; - private String appArgument; - - public String getSearchQuery() { - return searchQuery; - } - - public void setSearchQuery(String searchQuery) { - this.searchQuery = searchQuery; - } - - public String getAppArgument() { - return appArgument; - } - - public void setAppArgument(String appArgument) { - this.appArgument = appArgument; - } - - public boolean isRequired() { - return isRequired; - } - - public void setRequired(boolean isRequired) { - this.isRequired = isRequired; - } - - public boolean isRequiredToCMD() { - return requiredToCMD; - } - - public void setRequiredToCMD(boolean requiredToCMD) { - this.requiredToCMD = requiredToCMD; - } - - public boolean isDataMovement() { - return dataMovement; - } - - public void setDataMovement(boolean dataMovement) { - this.dataMovement = dataMovement; - } - - public String getDataNameLocation() { - return dataNameLocation; - } - - public void setDataNameLocation(String dataNameLocation) { - this.dataNameLocation = dataNameLocation; - } - - public String getOutputKey() { - return outputKey; - } - - public void setOutputKey(String outputKey) { - this.outputKey = outputKey; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public TaskDetailResource getTaskDetailResource() { - return taskDetailResource; - } - - public void setTaskDetailResource(TaskDetailResource taskDetailResource) { - this.taskDetailResource = taskDetailResource; - } - - - public Resource create(ResourceType type) throws RegistryException { - logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void remove(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public Resource get(ResourceType type, Object name) throws RegistryException{ - logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public List<Resource> get(ResourceType type) throws RegistryException{ - logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException()); - throw new UnsupportedOperationException(); - } - - - public void save() throws RegistryException { - EntityManager em = null; - try { - em = ResourceUtils.getEntityManager(); - ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey, taskDetailResource.getTaskId())); - em.close(); - - em = ResourceUtils.getEntityManager(); - em.getTransaction().begin(); - ApplicationOutput applicationOutput = new ApplicationOutput(); - TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId()); - applicationOutput.setTask(taskDetail); - applicationOutput.setTaskId(taskDetail.getTaskId()); - applicationOutput.setOutputKey(outputKey); - applicationOutput.setDataType(dataType); - applicationOutput.setRequired(isRequired); - applicationOutput.setAddedToCmd(requiredToCMD); - applicationOutput.setDataMovement(dataMovement); - applicationOutput.setDataNameLocation(dataNameLocation); - applicationOutput.setSearchQuery(searchQuery); - applicationOutput.setApplicationArgument(appArgument); - if (value != null){ - applicationOutput.setValue(value.toCharArray()); - } - - if (existingOutput != null) { - existingOutput.setTask(taskDetail); - existingOutput.setTaskId(taskDetail.getTaskId()); - existingOutput.setOutputKey(outputKey); - existingOutput.setDataType(dataType); - existingOutput.setRequired(isRequired); - existingOutput.setAddedToCmd(requiredToCMD); - existingOutput.setDataMovement(dataMovement); - existingOutput.setDataNameLocation(dataNameLocation); - existingOutput.setSearchQuery(searchQuery); - existingOutput.setApplicationArgument(appArgument); - if (value != null){ - existingOutput.setValue(value.toCharArray()); - } - applicationOutput = em.merge(existingOutput); - } else { - em.persist(applicationOutput); - } - 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(); - } - } - } -}
