You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sc...@apache.org on 2015/06/07 19:00:56 UTC
[15/44] airavata git commit: Adding mongo-registry WIP
http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/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
new file mode 100644
index 0000000..e05d59d
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
@@ -0,0 +1,317 @@
+/*
+ *
+ * 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/e13d90da/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
new file mode 100644
index 0000000..4ad08e4
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvanceInputDataHandlingResource.java
@@ -0,0 +1,168 @@
+/*
+ *
+ * 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/e13d90da/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
new file mode 100644
index 0000000..bb3cc80
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AdvancedOutputDataHandlingResource.java
@@ -0,0 +1,159 @@
+/*
+ *
+ * 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/e13d90da/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
new file mode 100644
index 0000000..d04fc85
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationInputResource.java
@@ -0,0 +1,235 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import java.util.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/e13d90da/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
new file mode 100644
index 0000000..c937df3
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationOutputResource.java
@@ -0,0 +1,213 @@
+/*
+ *
+ * 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();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ComputationSchedulingResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ComputationSchedulingResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ComputationSchedulingResource.java
new file mode 100644
index 0000000..7c0327f
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ComputationSchedulingResource.java
@@ -0,0 +1,229 @@
+/*
+ *
+ * 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.Computational_Resource_Scheduling;
+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.sql.Timestamp;
+import java.util.List;
+
+public class ComputationSchedulingResource extends AbstractResource {
+ private static final Logger logger = LoggerFactory.getLogger(ComputationSchedulingResource.class);
+ private int schedulingId = 0;
+ private ExperimentResource experimentResource;
+ private TaskDetailResource taskDetailResource;
+ private String resourceHostId;
+ private int cpuCount;
+ private int nodeCount;
+ private int numberOfThreads;
+ private String queueName;
+ private int walltimeLimit;
+ private Timestamp jobStartTime;
+ private int physicalMemory;
+ private String projectName;
+ private String chessisName;
+
+ public String getChessisName() {
+ return chessisName;
+ }
+
+ public void setChessisName(String chessisName) {
+ this.chessisName = chessisName;
+ }
+
+ public int getSchedulingId() {
+ return schedulingId;
+ }
+
+ public void setSchedulingId(int schedulingId) {
+ this.schedulingId = schedulingId;
+ }
+
+ 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 getResourceHostId() {
+ return resourceHostId;
+ }
+
+ public void setResourceHostId(String resourceHostId) {
+ this.resourceHostId = resourceHostId;
+ }
+
+ public int getCpuCount() {
+ return cpuCount;
+ }
+
+ public void setCpuCount(int cpuCount) {
+ this.cpuCount = cpuCount;
+ }
+
+ public int getNodeCount() {
+ return nodeCount;
+ }
+
+ public void setNodeCount(int nodeCount) {
+ this.nodeCount = nodeCount;
+ }
+
+ public int getNumberOfThreads() {
+ return numberOfThreads;
+ }
+
+ public void setNumberOfThreads(int numberOfThreads) {
+ this.numberOfThreads = numberOfThreads;
+ }
+
+ public String getQueueName() {
+ return queueName;
+ }
+
+ public void setQueueName(String queueName) {
+ this.queueName = queueName;
+ }
+
+ public int getWalltimeLimit() {
+ return walltimeLimit;
+ }
+
+ public void setWalltimeLimit(int walltimeLimit) {
+ this.walltimeLimit = walltimeLimit;
+ }
+
+ public Timestamp getJobStartTime() {
+ return jobStartTime;
+ }
+
+ public void setJobStartTime(Timestamp jobStartTime) {
+ this.jobStartTime = jobStartTime;
+ }
+
+ public int getPhysicalMemory() {
+ return physicalMemory;
+ }
+
+ public void setPhysicalMemory(int physicalMemory) {
+ this.physicalMemory = physicalMemory;
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+
+ public Resource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Resource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<Resource> get(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Computational_Resource_Scheduling scheduling;
+ if (schedulingId != 0) {
+ scheduling = em.find(Computational_Resource_Scheduling.class, schedulingId);
+ scheduling.setSchedulingId(schedulingId);
+ } else {
+ scheduling = new Computational_Resource_Scheduling();
+ }
+ Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+ if (taskDetailResource != null) {
+ TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+ scheduling.setTask(taskDetail);
+ scheduling.setTaskId(taskDetailResource.getTaskId());
+ }
+ scheduling.setExpId(experimentResource.getExpID());
+ scheduling.setExperiment(experiment);
+ scheduling.setResourceHostId(resourceHostId);
+ scheduling.setCpuCount(cpuCount);
+ scheduling.setNodeCount(nodeCount);
+ scheduling.setNumberOfThreads(numberOfThreads);
+ scheduling.setQueueName(queueName);
+ scheduling.setWallTimeLimit(walltimeLimit);
+ scheduling.setJobStartTime(jobStartTime);
+ scheduling.setTotalPhysicalmemory(physicalMemory);
+ scheduling.setProjectName(projectName);
+ scheduling.setChessisName(chessisName);
+ em.persist(scheduling);
+ schedulingId = scheduling.getSchedulingId();
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigDataResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigDataResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigDataResource.java
new file mode 100644
index 0000000..c45ba07
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigDataResource.java
@@ -0,0 +1,162 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
+import org.apache.airavata.persistance.registry.jpa.model.Experiment;
+import org.apache.airavata.persistance.registry.jpa.model.ExperimentConfigData;
+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 ConfigDataResource extends AbstractResource {
+ private static final Logger logger = LoggerFactory.getLogger(ConfigDataResource.class);
+ private ExperimentResource experimentResource;
+ private boolean airavataAutoSchedule;
+ private boolean overrideManualParams;
+ private boolean shareExp;
+ private String userDn;
+ private boolean generateCert;
+
+ public String getUserDn() {
+ return userDn;
+ }
+
+ public void setUserDn(String userDn) {
+ this.userDn = userDn;
+ }
+
+ public boolean isGenerateCert() {
+ return generateCert;
+ }
+
+ public void setGenerateCert(boolean generateCert) {
+ this.generateCert = generateCert;
+ }
+
+ public ExperimentResource getExperimentResource() {
+ return experimentResource;
+ }
+
+ public void setExperimentResource(ExperimentResource experimentResource) {
+ this.experimentResource = experimentResource;
+ }
+
+ public boolean isAiravataAutoSchedule() {
+ return airavataAutoSchedule;
+ }
+
+ public void setAiravataAutoSchedule(boolean airavataAutoSchedule) {
+ this.airavataAutoSchedule = airavataAutoSchedule;
+ }
+
+ public boolean isOverrideManualParams() {
+ return overrideManualParams;
+ }
+
+ public void setOverrideManualParams(boolean overrideManualParams) {
+ this.overrideManualParams = overrideManualParams;
+ }
+
+ public boolean isShareExp() {
+ return shareExp;
+ }
+
+ public void setShareExp(boolean shareExp) {
+ this.shareExp = shareExp;
+ }
+
+
+ public Resource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public Resource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<Resource> get(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ResourceUtils.getEntityManager();
+ ExperimentConfigData existingConfig = em.find(ExperimentConfigData.class, experimentResource.getExpID());
+ em.close();
+
+ em = ResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ ExperimentConfigData configData = new ExperimentConfigData();
+ Experiment experiment = em.find(Experiment.class, experimentResource.getExpID());
+ configData.setExpId(experimentResource.getExpID());
+ configData.setExperiment(experiment);
+ configData.setAiravataAutoSchedule(airavataAutoSchedule);
+ configData.setOverrideManualParams(overrideManualParams);
+ configData.setShareExp(shareExp);
+ configData.setUserDn(userDn);
+ configData.setGenerateCert(generateCert);
+ if (existingConfig != null) {
+ existingConfig.setExpId(experimentResource.getExpID());
+ existingConfig.setExperiment(experiment);
+ existingConfig.setAiravataAutoSchedule(airavataAutoSchedule);
+ existingConfig.setOverrideManualParams(overrideManualParams);
+ existingConfig.setShareExp(shareExp);
+ existingConfig.setUserDn(userDn);
+ existingConfig.setGenerateCert(generateCert);
+ configData = em.merge(existingConfig);
+ } else {
+ em.persist(configData);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java
new file mode 100644
index 0000000..1214e47
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ConfigurationResource.java
@@ -0,0 +1,208 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.persistance.registry.jpa.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.locks.Lock;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.persistance.registry.jpa.Resource;
+import org.apache.airavata.persistance.registry.jpa.ResourceType;
+import org.apache.airavata.persistance.registry.jpa.ResourceUtils;
+import org.apache.airavata.persistance.registry.jpa.model.Configuration;
+import org.apache.airavata.persistance.registry.jpa.model.Configuration_PK;
+import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConfigurationResource extends AbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ConfigurationResource.class);
+ private String configKey;
+ private String configVal;
+ private Timestamp expireDate;
+ private String categoryID = ConfigurationConstants.CATEGORY_ID_DEFAULT_VALUE;
+
+ public ConfigurationResource() {
+ }
+
+ /**
+ * @param configKey configuration key
+ * @param configVal configuration value
+ */
+ public ConfigurationResource(String configKey, String configVal) {
+ this.configKey = configKey;
+ this.configVal = configVal;
+ }
+
+ /**
+ * Since Configuration does not depend on any other data structures at the
+ * system, this method is not valid
+ *
+ * @param type child resource types
+ * @return UnsupportedOperationException
+ */
+ public Resource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported operation for configuration resource " +
+ "since there are no child resources generated by configuration resource.. ",
+ new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Since Configuration does not depend on any other data structures at the
+ * system, this method is not valid
+ *
+ * @param type child resource types
+ * @param name name of the child resource
+ * throws UnsupportedOperationException
+ */
+ public void remove(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported operation for configuration resource " +
+ "since there are no child resources generated by configuration resource.. ",
+ new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ /**
+ * Since Configuration does not depend on any other data structures at the
+ * system, this method is not valid
+ *
+ * @param type child resource types
+ * @param name name of the child resource
+ * @return UnsupportedOperationException
+ */
+ public Resource get(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported operation for configuration resource " +
+ "since there are no child resources generated by configuration resource.. ",
+ new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Since Configuration does not depend on any other data structures at the
+ * system, this method is not valid
+ *
+ * @param type child resource types
+ * @return UnsupportedOperationException
+ */
+ public List<Resource> get(ResourceType type) throws RegistryException {
+ logger.error("Unsupported operation for configuration resource " +
+ "since there are no child resources generated by configuration resource.. ",
+ new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @param expireDate expire date of the configuration
+ */
+ public void setExpireDate(Timestamp expireDate) {
+ this.expireDate = expireDate;
+ }
+
+ /**
+ * saveExperiment configuration to database
+ */
+ public synchronized void save() throws RegistryException {
+ EntityManager em = null;
+ try {
+ em = ResourceUtils.getEntityManager();
+ //whether existing
+ Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, categoryID));
+ em.close();
+ em = ResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Configuration configuration = new Configuration();
+ configuration.setConfig_key(configKey);
+ configuration.setConfig_val(configVal);
+ configuration.setExpire_date(expireDate);
+ configuration.setCategory_id(categoryID);
+ if (existing != null) {
+ existing.setExpire_date(expireDate);
+ existing.setCategory_id(categoryID);
+ configuration = em.merge(existing);
+ } else {
+ em.persist(configuration);
+ }
+ 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();
+ }
+ }
+ }
+
+ /**
+ * Since Configuration does not depend on any other data structures at the
+ * system, this method is not valid
+ *
+ * @param type child resource types
+ * @param name of the child resource
+ * @return UnsupportedOperationException
+ */
+ public boolean isExists(ResourceType type, Object name) {
+ logger.error("Unsupported operation for configuration resource " +
+ "since there are no child resources generated by configuration resource.. ",
+ new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @return configuration value
+ */
+ public String getConfigVal() {
+ return configVal;
+ }
+
+ /**
+ * @param configKey configuration key
+ */
+ public void setConfigKey(String configKey) {
+ this.configKey = configKey;
+ }
+
+ /**
+ * @param configVal configuration value
+ */
+ public void setConfigVal(String configVal) {
+ this.configVal = configVal;
+ }
+
+ public String getCategoryID() {
+ return categoryID;
+ }
+
+ public void setCategoryID(String categoryID) {
+ this.categoryID = categoryID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/e13d90da/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DataTransferDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DataTransferDetailResource.java b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DataTransferDetailResource.java
new file mode 100644
index 0000000..ab1b49e
--- /dev/null
+++ b/modules/registry/airavata-mongo-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/DataTransferDetailResource.java
@@ -0,0 +1,272 @@
+/*
+ *
+ * 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.DataTransferDetail;
+import org.apache.airavata.persistance.registry.jpa.model.Status;
+import org.apache.airavata.persistance.registry.jpa.model.TaskDetail;
+import org.apache.airavata.persistance.registry.jpa.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.utils.StatusType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class DataTransferDetailResource extends AbstractResource {
+ private static final Logger logger = LoggerFactory.getLogger(DataTransferDetailResource.class);
+ private String transferId;
+ private TaskDetailResource taskDetailResource;
+ private Timestamp creationTime;
+ private String transferDescription;
+
+ public String getTransferId() {
+ return transferId;
+ }
+
+ public void setTransferId(String transferId) {
+ this.transferId = transferId;
+ }
+
+ public TaskDetailResource getTaskDetailResource() {
+ return taskDetailResource;
+ }
+
+ public void setTaskDetailResource(TaskDetailResource taskDetailResource) {
+ this.taskDetailResource = taskDetailResource;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public String getTransferDescription() {
+ return transferDescription;
+ }
+
+ public void setTransferDescription(String transferDescription) {
+ this.transferDescription = transferDescription;
+ }
+
+
+ public Resource create(ResourceType type) throws RegistryException {
+ switch (type){
+ case STATUS:
+ StatusResource statusResource = new StatusResource();
+ statusResource.setDataTransferDetail(this);
+ return statusResource;
+ default:
+ logger.error("Unsupported resource type for data transfer details data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException {
+ EntityManager em = null;
+ try {
+ em = ResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ switch (type) {
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.TRANSFER_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.DATA_TRANSFER);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ default:
+ logger.error("Unsupported resource type for data transfer details resource.", new IllegalArgumentException());
+ break;
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+
+ public Resource get(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator;
+ Query q;
+ switch (type) {
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.TRANSFER_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.DATA_TRANSFER);
+ 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 data transfer details resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for data transfer details 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 STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.TRANSFER_ID, transferId);
+ 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();
+ DataTransferDetail existingDF = em.find(DataTransferDetail.class, transferId);
+ em.close();
+
+ em = ResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ DataTransferDetail dataTransferDetail = new DataTransferDetail();
+ TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId());
+ dataTransferDetail.setTransferId(transferId);
+ dataTransferDetail.setTask(taskDetail);
+ dataTransferDetail.setTaskId(taskDetailResource.getTaskId());
+ dataTransferDetail.setCreationTime(creationTime);
+ if (transferDescription != null) {
+ dataTransferDetail.setTransferDesc(transferDescription.toCharArray());
+ }
+ if (existingDF != null) {
+ existingDF.setTransferId(transferId);
+ existingDF.setTask(taskDetail);
+ existingDF.setTaskId(taskDetailResource.getTaskId());
+ existingDF.setCreationTime(creationTime);
+ if (transferDescription != null) {
+ existingDF.setTransferDesc(transferDescription.toCharArray());
+ }
+ dataTransferDetail = em.merge(existingDF);
+ } else {
+ em.persist(dataTransferDetail);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public StatusResource getDataTransferStatus () throws RegistryException{
+ List<Resource> resources = get(ResourceType.STATUS);
+ for (Resource resource : resources) {
+ StatusResource dataTransferStatus = (StatusResource) resource;
+ if(dataTransferStatus.getStatusType().equals(StatusType.DATA_TRANSFER.toString())){
+ if (dataTransferStatus.getState() == null || dataTransferStatus.getState().equals("") ){
+ dataTransferStatus.setState("UNKNOWN");
+ }
+ return dataTransferStatus;
+ }
+ }
+ return null;
+ }
+}