You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ch...@apache.org on 2015/06/05 18:25:51 UTC
[01/30] airavata git commit: registry refactoring changes
Repository: airavata
Updated Branches:
refs/heads/master 093643ac3 -> 4045c0947
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentOutputExperimentCatResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentOutputExperimentCatResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentOutputExperimentCatResourceTest.java
deleted file mode 100644
index 7fd3d71..0000000
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentOutputExperimentCatResourceTest.java
+++ /dev/null
@@ -1,77 +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.registry.core.experiment.catalog;
-
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentOutputExperimentCatResource;
-import org.junit.After;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
-
-public class ExperimentOutputExperimentCatResourceTest extends AbstractResourceTest {
- private ExperimentExperimentCatResource experimentResource;
- private String experimentID = "testExpID";
- ExperimentOutputExperimentCatResource outputResource;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- experimentResource = (ExperimentExperimentCatResource) getGatewayResource().create(ResourceType.EXPERIMENT);
- experimentResource.setExpID(experimentID);
- experimentResource.setExecutionUser(getWorkerResource().getUser());
- experimentResource.setProjectId(getProjectResource().getId());
- experimentResource.setCreationTime(getCurrentTimestamp());
- experimentResource.setApplicationId("testApplication");
- experimentResource.setApplicationVersion("1.0");
- experimentResource.setDescription("Test Application");
- experimentResource.setExpName("TestExperiment");
- experimentResource.save();
-
- outputResource = (ExperimentOutputExperimentCatResource)experimentResource.create(ResourceType.EXPERIMENT_OUTPUT);
- outputResource.setExperimentId(experimentResource.getExpID());
- outputResource.setExperimentKey("testKey");
- outputResource.setValue("testValue");
- outputResource.setDataType("string");
- outputResource.save();
- }
-
- @Test
- public void testSave() throws Exception {
- assertTrue("Experiment output saved successfully", experimentResource.isExists(ResourceType.EXPERIMENT_OUTPUT, experimentID));
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGet () throws Exception {
- List<ExperimentOutputExperimentCatResource> outputs = experimentResource.getExperimentOutputs();
- System.out.println("output counts : " + outputs.size());
- assertTrue("Experiment output retrieved successfully...", outputs.size() > 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentOutputResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentOutputResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentOutputResourceTest.java
new file mode 100644
index 0000000..7e7ccde
--- /dev/null
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentOutputResourceTest.java
@@ -0,0 +1,77 @@
+/*
+*
+* 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.experiment.catalog;
+
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentOutputResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentResource;
+import org.junit.After;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class ExperimentOutputResourceTest extends AbstractResourceTest {
+ private ExperimentResource experimentResource;
+ private String experimentID = "testExpID";
+ ExperimentOutputResource outputResource;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ experimentResource = (ExperimentResource) getGatewayResource().create(ResourceType.EXPERIMENT);
+ experimentResource.setExpID(experimentID);
+ experimentResource.setExecutionUser(getWorkerResource().getUser());
+ experimentResource.setProjectId(getProjectResource().getId());
+ experimentResource.setCreationTime(getCurrentTimestamp());
+ experimentResource.setApplicationId("testApplication");
+ experimentResource.setApplicationVersion("1.0");
+ experimentResource.setDescription("Test Application");
+ experimentResource.setExpName("TestExperiment");
+ experimentResource.save();
+
+ outputResource = (ExperimentOutputResource)experimentResource.create(ResourceType.EXPERIMENT_OUTPUT);
+ outputResource.setExperimentId(experimentResource.getExpID());
+ outputResource.setExperimentKey("testKey");
+ outputResource.setValue("testValue");
+ outputResource.setDataType("string");
+ outputResource.save();
+ }
+
+ @Test
+ public void testSave() throws Exception {
+ assertTrue("Experiment output saved successfully", experimentResource.isExists(ResourceType.EXPERIMENT_OUTPUT, experimentID));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGet () throws Exception {
+ List<ExperimentOutputResource> outputs = experimentResource.getExperimentOutputs();
+ System.out.println("output counts : " + outputs.size());
+ assertTrue("Experiment output retrieved successfully...", outputs.size() > 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentResourceTest.java
new file mode 100644
index 0000000..0a24102
--- /dev/null
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentResourceTest.java
@@ -0,0 +1,78 @@
+/*
+*
+* 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.experiment.catalog;
+
+import static org.junit.Assert.*;
+
+import java.sql.Timestamp;
+import java.util.Date;
+
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentResource;
+import org.junit.After;
+import org.junit.Test;
+
+public class ExperimentResourceTest extends AbstractResourceTest {
+ private ExperimentResource experimentResource;
+ private String experimentID = "testExpID";
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ experimentResource = (ExperimentResource) getGatewayResource().create(ResourceType.EXPERIMENT);
+ experimentResource.setExpID(experimentID);
+ experimentResource.setExecutionUser(getWorkerResource().getUser());
+ experimentResource.setProjectId(getProjectResource().getId());
+ Timestamp currentDate = new Timestamp(new Date().getTime());
+ experimentResource.setCreationTime(currentDate);
+ experimentResource.setApplicationId("testApplication");
+ experimentResource.setApplicationVersion("1.0");
+ experimentResource.setDescription("Test Application");
+ experimentResource.setExpName("TestExperiment");
+ experimentResource.save();
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ assertNotNull("experiment data resource has being created ", experimentResource);
+ }
+
+ @Test
+ public void testSave() throws Exception {
+ assertTrue("experiment save successfully", getGatewayResource().isExists(ResourceType.EXPERIMENT, experimentID));
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ assertNotNull("experiment data retrieved successfully", getGatewayResource().get(ResourceType.EXPERIMENT, experimentID));
+ }
+
+ @Test
+ public void testRemove() throws Exception {
+ getGatewayResource().remove(ResourceType.EXPERIMENT, experimentID);
+ assertFalse("experiment data removed successfully", getGatewayResource().isExists(ResourceType.EXPERIMENT, experimentID));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentUseCaseTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentUseCaseTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentUseCaseTest.java
new file mode 100644
index 0000000..0a9ebff
--- /dev/null
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentUseCaseTest.java
@@ -0,0 +1,296 @@
+/*
+ *
+ * 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.experiment.catalog;
+
+import junit.framework.Assert;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.experiment.catalog.util.Initialize;
+import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
+import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
+import org.apache.airavata.model.workspace.Project;
+import org.apache.airavata.model.workspace.experiment.*;
+import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
+import org.apache.airavata.registry.cpi.*;
+import org.apache.airavata.registry.cpi.utils.Constants;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * This class contains test cases for the RegistryImpl class which is the default registry
+ * implementation. These test cases are written from the perspective of the Airavata API
+ * such as creating/updating/deleting/searching projects and experiments etc.
+ */
+public class ExperimentUseCaseTest {
+
+ private static ExperimentCatalog experimentCatalog;
+ private static Initialize initialize;
+
+ @BeforeClass
+ public static void setupBeforeClass() throws RegistryException, SQLException {
+ initialize = new Initialize("expcatalog-derby.sql");
+ initialize.initializeDB();
+ experimentCatalog = RegistryFactory.getDefaultRegistry();
+ }
+
+ @Test
+ public void testProject(){
+ try {
+ String TAG = System.currentTimeMillis() + "";
+
+ String gatewayId = ServerSettings.getDefaultUserGateway();
+
+ //testing the creation of a project
+ Project project = new Project();
+ project.setOwner("TestUser"+TAG);
+ project.setName("TestProject"+TAG);
+ project.setDescription("This is a test project"+TAG);
+ String projectId1 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
+ Assert.assertNotNull(projectId1);
+
+ //testing the update of a project
+ Project updatedProject = new Project();
+ updatedProject.setProjectID(projectId1);
+ updatedProject.setOwner("TestUser"+TAG);
+ updatedProject.setName("UpdatedTestProject"+TAG);
+ updatedProject.setDescription("This is an updated test project"+TAG);
+ experimentCatalog.update(ExperimentCatalogModelType.PROJECT, updatedProject, projectId1);
+
+ //testing project retrieval
+ Project retrievedProject = (Project) experimentCatalog.get(ExperimentCatalogModelType.PROJECT, projectId1);
+ Assert.assertEquals(updatedProject.getProjectID(), retrievedProject.getProjectID());
+ Assert.assertEquals(updatedProject.getOwner(), retrievedProject.getOwner());
+ Assert.assertEquals(updatedProject.getName(), retrievedProject.getName());
+ Assert.assertEquals(updatedProject.getDescription(), retrievedProject.getDescription());
+ Assert.assertNotNull(retrievedProject.getCreationTime());
+ //created user should be in the shared users list
+ Assert.assertTrue(retrievedProject.getSharedUsers().size()==1);
+
+ //creating more projects for the same user
+ project = new Project();
+ project.setOwner("TestUser"+TAG);
+ project.setName("Project Terrible"+TAG);
+ project.setDescription("This is a test project_2"+TAG);
+ String projectId2 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
+ Assert.assertNotNull(projectId2);
+
+ project = new Project();
+ project.setOwner("TestUser"+TAG);
+ project.setName("Project Funny"+TAG);
+ project.setDescription("This is a test project_3"+TAG);
+ String projectId3 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
+ Assert.assertNotNull(projectId3);
+
+ project = new Project();
+ project.setOwner("TestUser"+TAG);
+ project.setName("Project Stupid"+TAG);
+ project.setDescription("This is a test project_4"+TAG);
+ String projectId4 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
+ Assert.assertNotNull(projectId4);
+
+ project = new Project();
+ project.setOwner("TestUser"+TAG);
+ project.setName("Project Boring"+TAG);
+ project.setDescription("This is a test project_5"+TAG);
+ String projectId5 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
+ Assert.assertNotNull(projectId5);
+
+ //test get all projects created by the user
+ List<Object> list = experimentCatalog.get(ExperimentCatalogModelType.PROJECT,
+ Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+ Assert.assertTrue(list.size()==5);
+
+ //search project by project name
+ Map<String, String> filters = new HashMap<String, String>();
+ filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+ filters.put(Constants.FieldConstants.ProjectConstants.PROJECT_NAME, "Terrible"+TAG);
+ list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters);
+ Assert.assertTrue(list.size()==1);
+
+ //search project by project description
+ filters = new HashMap<String, String>();
+ filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+ filters.put(Constants.FieldConstants.ProjectConstants.DESCRIPTION, "test project_2"+TAG);
+ list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters);
+ Assert.assertTrue(list.size()==1);
+
+ //search project with only ownername
+ filters = new HashMap<String, String>();
+ filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+ list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters);
+ Assert.assertTrue(list.size()==5);
+
+ //search projects with pagination
+ filters = new HashMap<String, String>();
+ filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
+ list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters, 2, 2,
+ Constants.FieldConstants.ProjectConstants.CREATION_TIME, ResultOrderType.DESC);
+ Assert.assertTrue(list.size()==2);
+ Project project1 = (Project)list.get(0);
+ Project project2 = (Project)list.get(1);
+ Assert.assertTrue(project1.getCreationTime()-project2.getCreationTime() > 0);
+ } catch (RegistryException e) {
+ e.printStackTrace();
+ Assert.fail();
+ } catch (ApplicationSettingsException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testExperiment(){
+ try {
+ long time = System.currentTimeMillis();
+ String TAG = time + "";
+
+ String gatewayId = ServerSettings.getDefaultUserGateway();
+
+ //creating project
+ Project project = new Project();
+ project.setOwner("TestUser"+TAG);
+ project.setName("TestProject"+TAG);
+ project.setDescription("This is a test project"+TAG);
+ String projectId1 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
+ Assert.assertNotNull(projectId1);
+
+ //creating sample echo experiment. assumes echo application is already defined
+ InputDataObjectType inputDataObjectType = new InputDataObjectType();
+ inputDataObjectType.setName("Input_to_Echo");
+ inputDataObjectType.setValue("Hello World");
+
+ ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
+ scheduling.setResourceHostId(UUID.randomUUID().toString());
+ scheduling.setComputationalProjectAccount("TG-STA110014S");
+ scheduling.setTotalCPUCount(1);
+ scheduling.setNodeCount(1);
+ scheduling.setWallTimeLimit(15);
+ scheduling.setQueueName("normal");
+
+ UserConfigurationData userConfigurationData = new UserConfigurationData();
+ userConfigurationData.setAiravataAutoSchedule(false);
+ userConfigurationData.setOverrideManualScheduledParams(false);
+ userConfigurationData.setComputationalResourceScheduling(scheduling);
+
+ Experiment experiment = new Experiment();
+ experiment.setProjectID(projectId1);
+ experiment.setUserName("TestUser" + TAG);
+ experiment.setName("TestExperiment"+TAG);
+ experiment.setDescription("Test 1 experiment");
+ experiment.setApplicationId(UUID.randomUUID().toString());
+ experiment.setUserConfigurationData(userConfigurationData);
+ experiment.addToExperimentInputs(inputDataObjectType);
+
+ String experimentId1 = (String) experimentCatalog.add(ExpCatParentDataType.EXPERIMENT, experiment, gatewayId);
+ Assert.assertNotNull(experimentId1);
+
+ //retrieving the stored experiment
+ Experiment retrievedExperiment = (Experiment) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT,
+ experimentId1);
+ Assert.assertNotNull(retrievedExperiment);
+ Assert.assertEquals(retrievedExperiment.getProjectID(), experiment.getProjectID());
+ Assert.assertEquals(retrievedExperiment.getDescription(), experiment.getDescription());
+ Assert.assertEquals(retrievedExperiment.getName(), experiment.getName());
+ Assert.assertEquals(retrievedExperiment.getApplicationId(), experiment.getApplicationId());
+ Assert.assertNotNull(retrievedExperiment.getUserConfigurationData());
+ Assert.assertNotNull(retrievedExperiment.getExperimentInputs());
+
+ //updating an existing experiment
+ experiment.setName("NewExperimentName"+TAG);
+ OutputDataObjectType outputDataObjectType = new OutputDataObjectType();
+ outputDataObjectType.setName("Output_to_Echo");
+ outputDataObjectType.setValue("Hello World");
+ experiment.addToExperimentOutputs(outputDataObjectType);
+ experimentCatalog.update(ExperimentCatalogModelType.EXPERIMENT, experiment, experimentId1);
+
+ //creating more experiments
+ experiment = new Experiment();
+ experiment.setProjectID(projectId1);
+ experiment.setUserName("TestUser" + TAG);
+ experiment.setName("TestExperiment2" + TAG);
+ experiment.setDescription("Test 2 experiment");
+ experiment.setApplicationId(UUID.randomUUID().toString());
+ experiment.setUserConfigurationData(userConfigurationData);
+ experiment.addToExperimentInputs(inputDataObjectType);
+
+ String experimentId2 = (String) experimentCatalog.add(ExpCatParentDataType.EXPERIMENT, experiment, gatewayId);
+ Assert.assertNotNull(experimentId2);
+
+ experiment = new Experiment();
+ experiment.setProjectID(projectId1);
+ experiment.setUserName("TestUser" + TAG);
+ experiment.setName("TestExperiment3"+TAG);
+ experiment.setDescription("Test 3 experiment");
+ experiment.setApplicationId(UUID.randomUUID().toString());
+ experiment.setUserConfigurationData(userConfigurationData);
+ experiment.addToExperimentInputs(inputDataObjectType);
+
+ String experimentId3 = (String) experimentCatalog.add(ExpCatParentDataType.EXPERIMENT, experiment, gatewayId);
+ Assert.assertNotNull(experimentId3);
+
+ //searching experiments by
+ Map<String, String> filters = new HashMap<String, String>();
+ filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, "TestUser" + TAG);
+ filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
+ filters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME, "Experiment2");
+ filters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS, ExperimentState.CREATED.toString());
+ filters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, time - 999999999 + "");
+ filters.put(Constants.FieldConstants.ExperimentConstants.TO_DATE, time + 999999999 + "");
+ List<Object> results = experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT, filters);
+ Assert.assertTrue(results.size()==1);
+
+ //retrieving all experiments in project
+ List<Object> list = experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT,
+ Constants.FieldConstants.ExperimentConstants.PROJECT_ID, projectId1);
+ Assert.assertTrue(list.size()==3);
+
+ //searching all user experiments
+ filters = new HashMap();
+ filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, "TestUser" + TAG);
+ filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
+ list = experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT, filters);
+ Assert.assertTrue(list.size()==3);
+
+ //searching user experiments with pagination
+ filters = new HashMap();
+ filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, "TestUser" + TAG);
+ filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
+ list = experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT, filters, 2, 1,
+ Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
+ Assert.assertTrue(list.size()==2);
+ ExperimentSummary exp1 = (ExperimentSummary)list.get(0);
+ ExperimentSummary exp2 = (ExperimentSummary)list.get(1);
+ Assert.assertTrue(exp1.getCreationTime()-exp2.getCreationTime() > 0);
+
+ } catch (RegistryException e) {
+ e.printStackTrace();
+ Assert.fail();
+ } catch (ApplicationSettingsException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/GatewayExperimentCatResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/GatewayExperimentCatResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/GatewayExperimentCatResourceTest.java
deleted file mode 100644
index 6f8f92a..0000000
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/GatewayExperimentCatResourceTest.java
+++ /dev/null
@@ -1,122 +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.registry.core.experiment.catalog;
-
-import static org.junit.Assert.*;
-
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.*;
-import org.junit.After;
-import org.junit.Test;
-
-import java.sql.Timestamp;
-import java.util.Date;
-
-
-public class GatewayExperimentCatResourceTest extends AbstractResourceTest {
- private GatewayExperimentCatResource gatewayResource;
- private ProjectExperimentCatResource projectResource;
- private UserExperimentCatResource userResource;
- private WorkerExperimentCatResource workerResource;
- private ExperimentExperimentCatResource experimentResource;
-
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- Timestamp currentDate = new Timestamp(new Date().getTime());
-
- gatewayResource = super.getGatewayResource();
- workerResource = super.getWorkerResource();
- userResource = super.getUserResource();
- if (gatewayResource == null) {
- gatewayResource = (GatewayExperimentCatResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
- }
- projectResource = (ProjectExperimentCatResource) gatewayResource.create(ResourceType.PROJECT);
- projectResource.setId("testProject");
- projectResource.setName("testProject");
- projectResource.setWorker(workerResource);
- projectResource.save();
-
- experimentResource = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
-
- experimentResource.setExpID("testExpID");
- experimentResource.setExecutionUser(getWorkerResource().getUser());
- experimentResource.setProjectId(getProjectResource().getId());
- experimentResource.setCreationTime(currentDate);
- experimentResource.setApplicationId("testApplication");
- experimentResource.setApplicationVersion("1.0");
- experimentResource.setDescription("Test Application");
- experimentResource.setExpName("TestExperiment");
- experimentResource.save();
- }
- @Test
- public void testSave() throws Exception {
- gatewayResource.setDomain("owner1");
- gatewayResource.save();
-
- boolean gatewayExist = ExpCatResourceUtils.isGatewayExist(ServerSettings.getDefaultUserGateway());
- assertTrue("The gateway exisits", gatewayExist);
-
- }
-
- @Test
- public void testCreate() throws Exception {
- assertNotNull("project resource cannot be null", projectResource);
- assertNotNull("user resource cannot be null", userResource);
- assertNotNull("worker resource cannot be null", workerResource);
- assertNotNull("experiment resource cannot be null", experimentResource);
- }
-
- @Test
- public void testIsExists() throws Exception {
- assertTrue(gatewayResource.isExists(ResourceType.GATEWAY_WORKER, ServerSettings.getDefaultUser()));
- assertTrue(gatewayResource.isExists(ResourceType.EXPERIMENT, "testExpID"));
- }
-
- @Test
- public void testGet() throws Exception {
- assertNotNull(gatewayResource.get(ResourceType.GATEWAY_WORKER, ServerSettings.getDefaultUser()));
- assertNotNull(gatewayResource.get(ResourceType.EXPERIMENT, "testExpID"));
- }
-
- @Test
- public void testGetList() throws Exception {
- assertNotNull(gatewayResource.get(ResourceType.GATEWAY_WORKER));
- assertNotNull(gatewayResource.get(ResourceType.PROJECT));
- assertNotNull(gatewayResource.get(ResourceType.EXPERIMENT));
- }
-
- @Test
- public void testRemove() throws Exception {
-
- gatewayResource.remove(ResourceType.EXPERIMENT, "testExpID");
- assertFalse(gatewayResource.isExists(ResourceType.EXPERIMENT, "testExpID"));
-
- }
-
- @After
- public void tearDown() throws Exception {
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/GatewayResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/GatewayResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/GatewayResourceTest.java
new file mode 100644
index 0000000..cb2b792
--- /dev/null
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/GatewayResourceTest.java
@@ -0,0 +1,122 @@
+/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+
+package org.apache.airavata.experiment.catalog;
+
+import static org.junit.Assert.*;
+
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.resources.*;
+import org.junit.After;
+import org.junit.Test;
+
+import java.sql.Timestamp;
+import java.util.Date;
+
+
+public class GatewayResourceTest extends AbstractResourceTest {
+ private GatewayResource gatewayResource;
+ private ProjectResource projectResource;
+ private UserResource userResource;
+ private WorkerResource workerResource;
+ private ExperimentResource experimentResource;
+
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ Timestamp currentDate = new Timestamp(new Date().getTime());
+
+ gatewayResource = super.getGatewayResource();
+ workerResource = super.getWorkerResource();
+ userResource = super.getUserResource();
+ if (gatewayResource == null) {
+ gatewayResource = (GatewayResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
+ }
+ projectResource = (ProjectResource) gatewayResource.create(ResourceType.PROJECT);
+ projectResource.setId("testProject");
+ projectResource.setName("testProject");
+ projectResource.setWorker(workerResource);
+ projectResource.save();
+
+ experimentResource = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+
+ experimentResource.setExpID("testExpID");
+ experimentResource.setExecutionUser(getWorkerResource().getUser());
+ experimentResource.setProjectId(getProjectResource().getId());
+ experimentResource.setCreationTime(currentDate);
+ experimentResource.setApplicationId("testApplication");
+ experimentResource.setApplicationVersion("1.0");
+ experimentResource.setDescription("Test Application");
+ experimentResource.setExpName("TestExperiment");
+ experimentResource.save();
+ }
+ @Test
+ public void testSave() throws Exception {
+ gatewayResource.setDomain("owner1");
+ gatewayResource.save();
+
+ boolean gatewayExist = ExpCatResourceUtils.isGatewayExist(ServerSettings.getDefaultUserGateway());
+ assertTrue("The gateway exisits", gatewayExist);
+
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ assertNotNull("project resource cannot be null", projectResource);
+ assertNotNull("user resource cannot be null", userResource);
+ assertNotNull("worker resource cannot be null", workerResource);
+ assertNotNull("experiment resource cannot be null", experimentResource);
+ }
+
+ @Test
+ public void testIsExists() throws Exception {
+ assertTrue(gatewayResource.isExists(ResourceType.GATEWAY_WORKER, ServerSettings.getDefaultUser()));
+ assertTrue(gatewayResource.isExists(ResourceType.EXPERIMENT, "testExpID"));
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ assertNotNull(gatewayResource.get(ResourceType.GATEWAY_WORKER, ServerSettings.getDefaultUser()));
+ assertNotNull(gatewayResource.get(ResourceType.EXPERIMENT, "testExpID"));
+ }
+
+ @Test
+ public void testGetList() throws Exception {
+ assertNotNull(gatewayResource.get(ResourceType.GATEWAY_WORKER));
+ assertNotNull(gatewayResource.get(ResourceType.PROJECT));
+ assertNotNull(gatewayResource.get(ResourceType.EXPERIMENT));
+ }
+
+ @Test
+ public void testRemove() throws Exception {
+
+ gatewayResource.remove(ResourceType.EXPERIMENT, "testExpID");
+ assertFalse(gatewayResource.isExists(ResourceType.EXPERIMENT, "testExpID"));
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/TaskDetailExperimentCatResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/TaskDetailExperimentCatResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/TaskDetailExperimentCatResourceTest.java
deleted file mode 100644
index d1b7e6e..0000000
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/TaskDetailExperimentCatResourceTest.java
+++ /dev/null
@@ -1,94 +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.registry.core.experiment.catalog;
-
-import static org.junit.Assert.*;
-
-import java.sql.Timestamp;
-import java.util.Date;
-
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.TaskDetailExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.WorkflowNodeDetailExperimentCatResource;
-import org.junit.Before;
-import org.junit.Test;
-
-public class TaskDetailExperimentCatResourceTest extends AbstractResourceTest{
-
- private ExperimentExperimentCatResource experimentResource;
- private TaskDetailExperimentCatResource taskDetailResource;
- private WorkflowNodeDetailExperimentCatResource nodeDetailResource;
- private String experimentID = "testExpID";
- private String applicationID = "testAppID";
- private String taskID = "testTask";
- private String nodeID = "testNode";
-
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- Timestamp creationTime = new Timestamp(new Date().getTime());
-
- experimentResource = (ExperimentExperimentCatResource) getGatewayResource().create(ResourceType.EXPERIMENT);
- experimentResource.setExpID(experimentID);
- experimentResource.setExecutionUser(getWorkerResource().getUser());
- experimentResource.setProjectId(getProjectResource().getId());
- experimentResource.setCreationTime(creationTime);
- experimentResource.save();
-
- nodeDetailResource = (WorkflowNodeDetailExperimentCatResource) experimentResource.create(ResourceType.WORKFLOW_NODE_DETAIL);
- nodeDetailResource.setExperimentId(experimentResource.getExpID());
- nodeDetailResource.setNodeInstanceId(nodeID);
- nodeDetailResource.setNodeName(nodeID);
- nodeDetailResource.setCreationTime(creationTime);
- nodeDetailResource.save();
-
- taskDetailResource = (TaskDetailExperimentCatResource)nodeDetailResource.create(ResourceType.TASK_DETAIL);
- taskDetailResource.setNodeId(nodeDetailResource.getNodeInstanceId());
- taskDetailResource.setTaskId(taskID);
- taskDetailResource.setApplicationId(applicationID);
- taskDetailResource.setApplicationVersion("1.0");
- taskDetailResource.setCreationTime(creationTime);
- taskDetailResource.save();
- }
-
-
- @Test
- public void testCreate() throws Exception {
- assertNotNull("task data resource has being created ", taskDetailResource);
- }
-
- @Test
- public void testSave() throws Exception {
- assertTrue("task save successfully", nodeDetailResource.isExists(ResourceType.TASK_DETAIL, taskID));
- }
-
- @Test
- public void testGet() throws Exception {
- assertNotNull("task data retrieved successfully", nodeDetailResource.get(ResourceType.TASK_DETAIL, taskID));
- }
-
- @Test
- public void testRemove() throws Exception {
- nodeDetailResource.remove(ResourceType.TASK_DETAIL, taskID);
- assertFalse("task data removed successfully", nodeDetailResource.isExists(ResourceType.TASK_DETAIL, taskID));
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/TaskDetailResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/TaskDetailResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/TaskDetailResourceTest.java
new file mode 100644
index 0000000..e640f01
--- /dev/null
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/TaskDetailResourceTest.java
@@ -0,0 +1,97 @@
+/**
+ * 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.experiment.catalog;
+
+import static org.junit.Assert.*;
+
+import java.sql.Timestamp;
+import java.util.Date;
+
+import org.apache.airavata.model.workspace.experiment.ExecutionUnit;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.TaskDetailResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.WorkflowNodeDetailResource;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TaskDetailResourceTest extends AbstractResourceTest{
+
+ private ExperimentResource experimentResource;
+ private TaskDetailResource taskDetailResource;
+ private WorkflowNodeDetailResource nodeDetailResource;
+ private String experimentID = "testExpID";
+ private String applicationID = "testAppID";
+ private String taskID = "testTask";
+ private String nodeID = "testNode";
+
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ Timestamp creationTime = new Timestamp(new Date().getTime());
+
+ experimentResource = (ExperimentResource) getGatewayResource().create(ResourceType.EXPERIMENT);
+ experimentResource.setExpID(experimentID);
+ experimentResource.setExpName(experimentID);
+ experimentResource.setExecutionUser(getWorkerResource().getUser());
+ experimentResource.setProjectId(getProjectResource().getId());
+ experimentResource.setCreationTime(creationTime);
+ experimentResource.save();
+
+ nodeDetailResource = (WorkflowNodeDetailResource) experimentResource.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ nodeDetailResource.setExperimentId(experimentResource.getExpID());
+ nodeDetailResource.setNodeInstanceId(nodeID);
+ nodeDetailResource.setNodeName(nodeID);
+ nodeDetailResource.setCreationTime(creationTime);
+ nodeDetailResource.setExecutionUnit(ExecutionUnit.APPLICATION.toString());
+ nodeDetailResource.save();
+
+ taskDetailResource = (TaskDetailResource)nodeDetailResource.create(ResourceType.TASK_DETAIL);
+ taskDetailResource.setNodeId(nodeDetailResource.getNodeInstanceId());
+ taskDetailResource.setTaskId(taskID);
+ taskDetailResource.setApplicationId(applicationID);
+ taskDetailResource.setApplicationVersion("1.0");
+ taskDetailResource.setCreationTime(creationTime);
+ taskDetailResource.save();
+ }
+
+
+ @Test
+ public void testCreate() throws Exception {
+ assertNotNull("task data resource has being created ", taskDetailResource);
+ }
+
+ @Test
+ public void testSave() throws Exception {
+ assertTrue("task save successfully", nodeDetailResource.isExists(ResourceType.TASK_DETAIL, taskID));
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ assertNotNull("task data retrieved successfully", nodeDetailResource.get(ResourceType.TASK_DETAIL, taskID));
+ }
+
+ @Test
+ public void testRemove() throws Exception {
+ nodeDetailResource.remove(ResourceType.TASK_DETAIL, taskID);
+ assertFalse("task data removed successfully", nodeDetailResource.isExists(ResourceType.TASK_DETAIL, taskID));
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/UserExperimentCatResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/UserExperimentCatResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/UserExperimentCatResourceTest.java
deleted file mode 100644
index 102f6fa..0000000
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/UserExperimentCatResourceTest.java
+++ /dev/null
@@ -1,55 +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.registry.core.experiment.catalog;
-
-import static org.junit.Assert.*;
-
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.UserExperimentCatResource;
-import org.junit.After;
-import org.junit.Test;
-
-public class UserExperimentCatResourceTest extends AbstractResourceTest {
- private UserExperimentCatResource userResource;
- private GatewayExperimentCatResource gatewayResource;
- private String userName = "testUser";
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- gatewayResource = super.getGatewayResource();
- userResource = super.getUserResource();
- userResource.setUserName(userName);
- userResource.setPassword("testPassword");
- userResource.save();
- }
-
- @Test
- public void testSave() throws Exception {
- assertTrue("user resource saved successfully", gatewayResource.isExists(ResourceType.USER, "admin"));
- }
-
- @After
- public void tearDown() throws Exception {
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/UserResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/UserResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/UserResourceTest.java
new file mode 100644
index 0000000..54af124
--- /dev/null
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/UserResourceTest.java
@@ -0,0 +1,55 @@
+/*
+*
+* 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.experiment.catalog;
+
+import static org.junit.Assert.*;
+
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.UserResource;
+import org.junit.After;
+import org.junit.Test;
+
+public class UserResourceTest extends AbstractResourceTest {
+ private UserResource userResource;
+ private GatewayResource gatewayResource;
+ private String userName = "testUser";
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ gatewayResource = super.getGatewayResource();
+ userResource = super.getUserResource();
+ userResource.setUserName(userName);
+ userResource.setPassword("testPassword");
+ userResource.save();
+ }
+
+ @Test
+ public void testSave() throws Exception {
+ assertTrue("user resource saved successfully", gatewayResource.isExists(ResourceType.USER, "admin"));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/WorkflowNodeDetailExperimentCatResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/WorkflowNodeDetailExperimentCatResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/WorkflowNodeDetailExperimentCatResourceTest.java
deleted file mode 100644
index 887066b..0000000
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/WorkflowNodeDetailExperimentCatResourceTest.java
+++ /dev/null
@@ -1,86 +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.registry.core.experiment.catalog;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-import java.util.Date;
-
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.WorkflowNodeDetailExperimentCatResource;
-import org.junit.Before;
-import org.junit.Test;
-
-public class WorkflowNodeDetailExperimentCatResourceTest extends AbstractResourceTest {
-
- private ExperimentExperimentCatResource experimentResource;
- private WorkflowNodeDetailExperimentCatResource nodeDetailResource;
- private String experimentID = "testExpID";
- private String applicationID = "testAppID";
- private String nodeID = "testNode";
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- Timestamp creationTime = new Timestamp(new Date().getTime());
-
- experimentResource = (ExperimentExperimentCatResource) getGatewayResource().create(ResourceType.EXPERIMENT);
- experimentResource.setExpID(experimentID);
- experimentResource.setExecutionUser(getWorkerResource().getUser());
- experimentResource.setProjectId(getProjectResource().getId());
- experimentResource.setCreationTime(creationTime);
- experimentResource.setApplicationId(applicationID);
- experimentResource.save();
-
- nodeDetailResource = (WorkflowNodeDetailExperimentCatResource) experimentResource.create(ResourceType.WORKFLOW_NODE_DETAIL);
- nodeDetailResource.setExperimentId(experimentResource.getExpID());
- nodeDetailResource.setNodeInstanceId(nodeID);
- nodeDetailResource.setNodeName(nodeID);
- nodeDetailResource.setCreationTime(creationTime);
- nodeDetailResource.save();
-
- }
-
- @Test
- public void testCreate() throws Exception {
- assertNotNull("task data resource has being created ", nodeDetailResource);
- }
-
- @Test
- public void testSave() throws Exception {
- assertTrue("task save successfully", experimentResource.isExists(ResourceType.WORKFLOW_NODE_DETAIL, nodeID));
- }
-
- @Test
- public void testGet() throws Exception {
- assertNotNull("task data retrieved successfully", experimentResource.get(ResourceType.WORKFLOW_NODE_DETAIL, nodeID));
- }
-
- @Test
- public void testRemove() throws Exception {
- experimentResource.remove(ResourceType.WORKFLOW_NODE_DETAIL, nodeID);
- assertFalse("task data removed successfully", experimentResource.isExists(ResourceType.WORKFLOW_NODE_DETAIL, nodeID));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/WorkflowNodeDetailResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/WorkflowNodeDetailResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/WorkflowNodeDetailResourceTest.java
new file mode 100644
index 0000000..c55e872
--- /dev/null
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/WorkflowNodeDetailResourceTest.java
@@ -0,0 +1,88 @@
+/**
+ * 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.experiment.catalog;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Timestamp;
+import java.util.Date;
+
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.WorkflowNodeDetailResource;
+import org.junit.Before;
+import org.junit.Test;
+
+public class WorkflowNodeDetailResourceTest extends AbstractResourceTest {
+
+ private ExperimentResource experimentResource;
+ private WorkflowNodeDetailResource nodeDetailResource;
+ private String experimentID = "testExpID";
+ private String applicationID = "testAppID";
+ private String nodeID = "testNode";
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ Timestamp creationTime = new Timestamp(new Date().getTime());
+
+ experimentResource = (ExperimentResource) getGatewayResource().create(ResourceType.EXPERIMENT);
+ experimentResource.setExpID(experimentID);
+ experimentResource.setExpName(experimentID);
+ experimentResource.setExecutionUser(getWorkerResource().getUser());
+ experimentResource.setProjectId(getProjectResource().getId());
+ experimentResource.setCreationTime(creationTime);
+ experimentResource.setApplicationId(applicationID);
+ experimentResource.save();
+
+ nodeDetailResource = (WorkflowNodeDetailResource) experimentResource.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ nodeDetailResource.setExperimentId(experimentResource.getExpID());
+ nodeDetailResource.setNodeInstanceId(nodeID);
+ nodeDetailResource.setNodeName(nodeID);
+ nodeDetailResource.setCreationTime(creationTime);
+ nodeDetailResource.setExecutionUnit("workflow");
+ nodeDetailResource.save();
+
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ assertNotNull("task data resource has being created ", nodeDetailResource);
+ }
+
+ @Test
+ public void testSave() throws Exception {
+ assertTrue("task save successfully", experimentResource.isExists(ResourceType.WORKFLOW_NODE_DETAIL, nodeID));
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ assertNotNull("task data retrieved successfully", experimentResource.get(ResourceType.WORKFLOW_NODE_DETAIL, nodeID));
+ }
+
+ @Test
+ public void testRemove() throws Exception {
+ experimentResource.remove(ResourceType.WORKFLOW_NODE_DETAIL, nodeID);
+ assertFalse("task data removed successfully", experimentResource.isExists(ResourceType.WORKFLOW_NODE_DETAIL, nodeID));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/util/Initialize.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/util/Initialize.java
index 52b30aa..8dd7856 100644
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/util/Initialize.java
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/util/Initialize.java
@@ -19,7 +19,7 @@
*
*/
-package org.apache.airavata.registry.core.experiment.catalog.util;
+package org.apache.airavata.experiment.catalog.util;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.ServerSettings;
@@ -41,7 +41,7 @@ import java.util.StringTokenizer;
public class Initialize {
private static final Logger logger = LoggerFactory.getLogger(Initialize.class);
public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
- public String scriptName = "registry-derby.sql";
+ public String scriptName = "expcatalog-derby.sql";
private NetworkServerControl server;
private static final String delimiter = ";";
public static final String PERSISTANT_DATA = "Configuration";
@@ -134,23 +134,23 @@ public class Initialize {
}
try{
- GatewayExperimentCatResource gatewayResource = new GatewayExperimentCatResource();
+ GatewayResource gatewayResource = new GatewayResource();
gatewayResource.setGatewayId(ServerSettings.getSetting("default.registry.gateway"));
gatewayResource.setGatewayName(ServerSettings.getSetting("default.registry.gateway"));
gatewayResource.setDomain("test-domain");
gatewayResource.setEmailAddress("test-email");
gatewayResource.save();
- UserExperimentCatResource userResource = new UserExperimentCatResource();
+ UserResource userResource = new UserResource();
userResource.setUserName(ServerSettings.getSetting("default.registry.user"));
userResource.setPassword(ServerSettings.getSetting("default.registry.password"));
userResource.save();
- WorkerExperimentCatResource workerResource = (WorkerExperimentCatResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
+ WorkerResource workerResource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
workerResource.setUser(userResource.getUserName());
workerResource.save();
- ProjectExperimentCatResource projectResource = (ProjectExperimentCatResource)workerResource.create(ResourceType.PROJECT);
+ ProjectResource projectResource = (ProjectResource)workerResource.create(ResourceType.PROJECT);
projectResource.setGatewayId(gatewayResource.getGatewayId());
projectResource.setId("default");
projectResource.setName("default");
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/workflow-model/workflow-engine/pom.xml
----------------------------------------------------------------------
diff --git a/modules/workflow-model/workflow-engine/pom.xml b/modules/workflow-model/workflow-engine/pom.xml
index c115239..6189254 100644
--- a/modules/workflow-model/workflow-engine/pom.xml
+++ b/modules/workflow-model/workflow-engine/pom.xml
@@ -252,7 +252,7 @@
<!--</dependency>-->
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId.airavata.registry.core.experiment.catalog</artifactId>
+ <artifactId>airavata-registry-core</artifactId>
<version>${project.version}</version>
</dependency>
<!-- JCR Support -->
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/workflow/workflow-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/workflow/workflow-core/pom.xml b/modules/workflow/workflow-core/pom.xml
index 103ce93..80fa76d 100644
--- a/modules/workflow/workflow-core/pom.xml
+++ b/modules/workflow/workflow-core/pom.xml
@@ -27,7 +27,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId.airavata.registry.core.experiment.catalog</artifactId>
+ <artifactId>airavata-registry-core</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/xbaya-gui/pom.xml
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/pom.xml b/modules/xbaya-gui/pom.xml
index a1eeb7e..fa25025 100644
--- a/modules/xbaya-gui/pom.xml
+++ b/modules/xbaya-gui/pom.xml
@@ -221,7 +221,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId.airavata.registry.core.experiment.catalog</artifactId>
+ <artifactId>airavata-registry-core</artifactId>
<version>${project.version}</version>
</dependency>
[10/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputResource.java
new file mode 100644
index 0000000..04bb641
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputResource.java
@@ -0,0 +1,230 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationInput;
+import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationInput_PK;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ApplicationInputResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(ApplicationInputResource.class);
+ 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;
+ private String taskId;
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
+ ApplicationInput existingInput = em.find(ApplicationInput.class, new ApplicationInput_PK(inputKey, taskId));
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ ApplicationInput applicationInput = new ApplicationInput();
+ applicationInput.setTaskId(taskId);
+ 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.setTaskId(taskId);
+ 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputExperimentCatResource.java
deleted file mode 100644
index b059513..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputExperimentCatResource.java
+++ /dev/null
@@ -1,208 +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.registry.core.experiment.catalog.resources;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput;
-import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput_PK;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ApplicationOutputExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(ApplicationOutputExperimentCatResource.class);
- private String taskId;
- 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 String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
- ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey, taskId));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- ApplicationOutput applicationOutput = new ApplicationOutput();
- applicationOutput.setTaskId(taskId);
- 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.setTaskId(taskId);
- 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputResource.java
new file mode 100644
index 0000000..6443814
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationOutputResource.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.registry.core.experiment.catalog.resources;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput;
+import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput_PK;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ApplicationOutputResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(ApplicationOutputResource.class);
+ private String taskId;
+ 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 String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for application output data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
+ ApplicationOutput existingOutput = em.find(ApplicationOutput.class, new ApplicationOutput_PK(outputKey, taskId));
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ ApplicationOutput applicationOutput = new ApplicationOutput();
+ applicationOutput.setTaskId(taskId);
+ 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.setTaskId(taskId);
+ 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingExperimentCatResource.java
deleted file mode 100644
index 4ff5085..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingExperimentCatResource.java
+++ /dev/null
@@ -1,221 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.Computational_Resource_Scheduling;
-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 ComputationSchedulingExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(ComputationSchedulingExperimentCatResource.class);
- private int schedulingId = 0;
- private String experimentId;
- private String taskId;
- 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 String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> 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 = ExpCatResourceUtils.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();
- }
- scheduling.setExpId(experimentId);
- scheduling.setTaskId(taskId);
- 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingResource.java
new file mode 100644
index 0000000..c913f5c
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ComputationSchedulingResource.java
@@ -0,0 +1,221 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.Computational_Resource_Scheduling;
+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 AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(ComputationSchedulingResource.class);
+ private int schedulingId = 0;
+ private String experimentId;
+ private String taskId;
+ 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 String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for computational scheduling resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> 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 = ExpCatResourceUtils.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();
+ }
+ scheduling.setExpId(experimentId);
+ scheduling.setTaskId(taskId);
+ 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataExperimentCatResource.java
deleted file mode 100644
index bf218f8..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataExperimentCatResource.java
+++ /dev/null
@@ -1,194 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.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 ConfigDataExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(ConfigDataExperimentCatResource.class);
- private String experimentId;
- private boolean airavataAutoSchedule;
- private boolean overrideManualParams;
- private boolean shareExp;
- private String userDn;
- private boolean generateCert;
- private ComputationSchedulingExperimentCatResource computationSchedulingResource;
- private AdvanceInputDataHandlingExperimentCatResource advanceInputDataHandlingResource;
- private AdvancedOutputDataHandlingExperimentCatResource advancedOutputDataHandlingResource;
- private QosParamExperimentCatResource qosParamResource;
-
- public ComputationSchedulingExperimentCatResource getComputationSchedulingResource() {
- return computationSchedulingResource;
- }
-
- public void setComputationSchedulingResource(ComputationSchedulingExperimentCatResource computationSchedulingResource) {
- this.computationSchedulingResource = computationSchedulingResource;
- }
-
- public AdvanceInputDataHandlingExperimentCatResource getAdvanceInputDataHandlingResource() {
- return advanceInputDataHandlingResource;
- }
-
- public void setAdvanceInputDataHandlingResource(AdvanceInputDataHandlingExperimentCatResource advanceInputDataHandlingResource) {
- this.advanceInputDataHandlingResource = advanceInputDataHandlingResource;
- }
-
- public AdvancedOutputDataHandlingExperimentCatResource getAdvancedOutputDataHandlingResource() {
- return advancedOutputDataHandlingResource;
- }
-
- public void setAdvancedOutputDataHandlingResource(AdvancedOutputDataHandlingExperimentCatResource advancedOutputDataHandlingResource) {
- this.advancedOutputDataHandlingResource = advancedOutputDataHandlingResource;
- }
-
- public QosParamExperimentCatResource getQosParamResource() {
- return qosParamResource;
- }
-
- public void setQosParamResource(QosParamExperimentCatResource qosParamResource) {
- this.qosParamResource = qosParamResource;
- }
-
- 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 String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
- ExperimentConfigData existingConfig = em.find(ExperimentConfigData.class, experimentId);
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- ExperimentConfigData configData = new ExperimentConfigData();
- configData.setExpId(experimentId);
- configData.setAiravataAutoSchedule(airavataAutoSchedule);
- configData.setOverrideManualParams(overrideManualParams);
- configData.setShareExp(shareExp);
- configData.setUserDn(userDn);
- configData.setGenerateCert(generateCert);
- if (existingConfig != null) {
- existingConfig.setExpId(experimentId);
- 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataResource.java
new file mode 100644
index 0000000..289715b
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigDataResource.java
@@ -0,0 +1,194 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.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 AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(ConfigDataResource.class);
+ private String experimentId;
+ private boolean airavataAutoSchedule;
+ private boolean overrideManualParams;
+ private boolean shareExp;
+ private String userDn;
+ private boolean generateCert;
+ private ComputationSchedulingResource computationSchedulingResource;
+ private AdvanceInputDataHandlingResource advanceInputDataHandlingResource;
+ private AdvancedOutputDataHandlingResource advancedOutputDataHandlingResource;
+ private QosParamResource qosParamResource;
+
+ public ComputationSchedulingResource getComputationSchedulingResource() {
+ return computationSchedulingResource;
+ }
+
+ public void setComputationSchedulingResource(ComputationSchedulingResource computationSchedulingResource) {
+ this.computationSchedulingResource = computationSchedulingResource;
+ }
+
+ public AdvanceInputDataHandlingResource getAdvanceInputDataHandlingResource() {
+ return advanceInputDataHandlingResource;
+ }
+
+ public void setAdvanceInputDataHandlingResource(AdvanceInputDataHandlingResource advanceInputDataHandlingResource) {
+ this.advanceInputDataHandlingResource = advanceInputDataHandlingResource;
+ }
+
+ public AdvancedOutputDataHandlingResource getAdvancedOutputDataHandlingResource() {
+ return advancedOutputDataHandlingResource;
+ }
+
+ public void setAdvancedOutputDataHandlingResource(AdvancedOutputDataHandlingResource advancedOutputDataHandlingResource) {
+ this.advancedOutputDataHandlingResource = advancedOutputDataHandlingResource;
+ }
+
+ public QosParamResource getQosParamResource() {
+ return qosParamResource;
+ }
+
+ public void setQosParamResource(QosParamResource qosParamResource) {
+ this.qosParamResource = qosParamResource;
+ }
+
+ 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 String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for config data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
+ ExperimentConfigData existingConfig = em.find(ExperimentConfigData.class, experimentId);
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ ExperimentConfigData configData = new ExperimentConfigData();
+ configData.setExpId(experimentId);
+ configData.setAiravataAutoSchedule(airavataAutoSchedule);
+ configData.setOverrideManualParams(overrideManualParams);
+ configData.setShareExp(shareExp);
+ configData.setUserDn(userDn);
+ configData.setGenerateCert(generateCert);
+ if (existingConfig != null) {
+ existingConfig.setExpId(experimentId);
+ 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationExperimentCatResource.java
deleted file mode 100644
index a5015fd..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationExperimentCatResource.java
+++ /dev/null
@@ -1,204 +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.registry.core.experiment.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.Configuration;
-import org.apache.airavata.registry.core.experiment.catalog.model.Configuration_PK;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConfigurationExperimentCatResource extends AbstractExperimentCatResource {
- private final static Logger logger = LoggerFactory.getLogger(ConfigurationExperimentCatResource.class);
- private String configKey;
- private String configVal;
- private Timestamp expireDate;
- private String categoryID = ConfigurationConstants.CATEGORY_ID_DEFAULT_VALUE;
-
- public ConfigurationExperimentCatResource() {
- }
-
- /**
- * @param configKey configuration key
- * @param configVal configuration value
- */
- public ConfigurationExperimentCatResource(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 ExperimentCatResource 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 ExperimentCatResource 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<ExperimentCatResource> 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;
- }
-
- /**
- * save configuration to database
- */
- public synchronized void save() throws RegistryException {
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- //whether existing
- Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, categoryID));
- em.close();
- em = ExpCatResourceUtils.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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationResource.java
new file mode 100644
index 0000000..1a4227e
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ConfigurationResource.java
@@ -0,0 +1,204 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.Configuration;
+import org.apache.airavata.registry.core.experiment.catalog.model.Configuration_PK;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ConfigurationResource extends AbstractExpCatResource {
+ 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 ExperimentCatResource 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 ExperimentCatResource 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<ExperimentCatResource> 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;
+ }
+
+ /**
+ * save configuration to database
+ */
+ public synchronized void save() throws RegistryException {
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ //whether existing
+ Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, categoryID));
+ em.close();
+ em = ExpCatResourceUtils.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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailExperimentCatResource.java
deleted file mode 100644
index 39f4257..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailExperimentCatResource.java
+++ /dev/null
@@ -1,276 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.DataTransferDetail;
-import org.apache.airavata.registry.core.experiment.catalog.model.Status;
-import org.apache.airavata.registry.core.experiment.catalog.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 DataTransferDetailExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(DataTransferDetailExperimentCatResource.class);
- private String transferId;
- private String taskId;
- private Timestamp creationTime;
- private String transferDescription;
- private StatusExperimentCatResource datatransferStatus;
-
- public StatusExperimentCatResource getDatatransferStatus() {
- return datatransferStatus;
- }
-
- public void setDatatransferStatus(StatusExperimentCatResource datatransferStatus) {
- this.datatransferStatus = datatransferStatus;
- }
-
- public String getTransferId() {
- return transferId;
- }
-
- public void setTransferId(String transferId) {
- this.transferId = transferId;
- }
-
- 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 String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- switch (type){
- case STATUS:
- StatusExperimentCatResource statusResource = new StatusExperimentCatResource();
- statusResource.setTransferId(transferId);
- 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 = ExpCatResourceUtils.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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.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();
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) 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<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.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;
- StatusExperimentCatResource statusResource =
- (StatusExperimentCatResource) 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 = ExpCatResourceUtils.getEntityManager();
- DataTransferDetail existingDF = em.find(DataTransferDetail.class, transferId);
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- DataTransferDetail dataTransferDetail = new DataTransferDetail();
- dataTransferDetail.setTransferId(transferId);
- dataTransferDetail.setTaskId(taskId);
- dataTransferDetail.setCreationTime(creationTime);
- if (transferDescription != null) {
- dataTransferDetail.setTransferDesc(transferDescription.toCharArray());
- }
- if (existingDF != null) {
- existingDF.setTransferId(transferId);
- existingDF.setTaskId(taskId);
- 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 StatusExperimentCatResource getDataTransferStatus () throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusExperimentCatResource dataTransferStatus = (StatusExperimentCatResource) resource;
- if(dataTransferStatus.getStatusType().equals(StatusType.DATA_TRANSFER.toString())){
- if (dataTransferStatus.getState() == null || dataTransferStatus.getState().equals("") ){
- dataTransferStatus.setState("UNKNOWN");
- }
- return dataTransferStatus;
- }
- }
- return null;
- }
-}
[23/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemResource.java
new file mode 100644
index 0000000..7eb3232
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemResource.java
@@ -0,0 +1,307 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResourceFileSystem;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResourceFileSystem_PK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ComputeResourceFileSystemResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ComputeResourceFileSystemResource.class);
+ private String computeResourceId;
+ private ComputeResourceResource computeHostResource;
+ private String path;
+ private String fileSystem;
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_FILE_SYSTEM);
+ generator.setParameter(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID, ids.get(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID));
+ generator.setParameter(ComputeResourceFileSystemConstants.FILE_SYSTEM, ids.get(ComputeResourceFileSystemConstants.FILE_SYSTEM));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_FILE_SYSTEM);
+ generator.setParameter(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID, ids.get(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID));
+ generator.setParameter(ComputeResourceFileSystemConstants.FILE_SYSTEM, ids.get(ComputeResourceFileSystemConstants.FILE_SYSTEM));
+ Query q = generator.selectQuery(em);
+ ComputeResourceFileSystem computeResourceFileSystem = (ComputeResourceFileSystem) q.getSingleResult();
+ ComputeResourceFileSystemResource computeResourceFileSystemResource = (ComputeResourceFileSystemResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_FILE_SYSTEM, computeResourceFileSystem);
+ em.getTransaction().commit();
+ em.close();
+ return computeResourceFileSystemResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> computeResourceFileSystemResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_FILE_SYSTEM);
+ Query q;
+ if ((fieldName.equals(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(ComputeResourceFileSystemConstants.PATH)) || (fieldName.equals(ComputeResourceFileSystemConstants.FILE_SYSTEM))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ComputeResourceFileSystem computeResourceFileSystem = (ComputeResourceFileSystem) result;
+ ComputeResourceFileSystemResource computeResourceFileSystemResource = (ComputeResourceFileSystemResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_FILE_SYSTEM, computeResourceFileSystem);
+ computeResourceFileSystemResources.add(computeResourceFileSystemResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Compute Resource File System Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Compute Resource File System Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return computeResourceFileSystemResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> computeResourceFileSystemResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_FILE_SYSTEM);
+ Query q;
+ if ((fieldName.equals(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(ComputeResourceFileSystemConstants.PATH)) || (fieldName.equals(ComputeResourceFileSystemConstants.FILE_SYSTEM))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ComputeResourceFileSystem computeResourceFileSystem = (ComputeResourceFileSystem) result;
+ ComputeResourceFileSystemResource computeResourceFileSystemResource = (ComputeResourceFileSystemResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_FILE_SYSTEM, computeResourceFileSystem);
+ computeResourceFileSystemResourceIDs.add(computeResourceFileSystemResource.getComputeResourceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Compute Resource File System Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Compute Resource File System Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return computeResourceFileSystemResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ComputeResourceFileSystem existingComputeResourceFileSystem = em.find(ComputeResourceFileSystem.class, new ComputeResourceFileSystem_PK(computeResourceId, fileSystem));
+ em.close();
+ ComputeResourceFileSystem computeResourceFileSystem;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingComputeResourceFileSystem == null) {
+ computeResourceFileSystem = new ComputeResourceFileSystem();
+ } else {
+ computeResourceFileSystem = existingComputeResourceFileSystem;
+ }
+ computeResourceFileSystem.setComputeResourceId(getComputeResourceId());
+ ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
+ computeResourceFileSystem.setComputeResource(computeResource);
+ computeResourceFileSystem.setPath(getPath());
+ computeResourceFileSystem.setFileSystem(getFileSystem());
+ if (existingComputeResourceFileSystem == null) {
+ em.persist(computeResourceFileSystem);
+ } else {
+ em.merge(computeResourceFileSystem);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ComputeResourceFileSystem computeResourceFileSystem = em.find(ComputeResourceFileSystem.class, new ComputeResourceFileSystem_PK(ids.get(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID), ids.get(ComputeResourceFileSystemConstants.FILE_SYSTEM)));
+ em.close();
+ return computeResourceFileSystem != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getComputeResourceId() {
+ return computeResourceId;
+ }
+
+ public ComputeResourceResource getComputeHostResource() {
+ return computeHostResource;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getFileSystem() {
+ return fileSystem;
+ }
+
+ public void setComputeResourceId(String computeResourceId) {
+ this.computeResourceId=computeResourceId;
+ }
+
+ public void setComputeHostResource(ComputeResourceResource computeHostResource) {
+ this.computeHostResource=computeHostResource;
+ }
+
+ public void setPath(String path) {
+ this.path=path;
+ }
+
+ public void setFileSystem(String fileSystem) {
+ this.fileSystem=fileSystem;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceResource.java
new file mode 100644
index 0000000..956604f
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceResource.java
@@ -0,0 +1,351 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+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 ComputeResourceResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ComputeResourceResource.class);
+ private String resourceDescription;
+ private String resourceId;
+ private String hostName;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+ private int maxMemoryPerNode;
+
+ public int getMaxMemoryPerNode() {
+ return maxMemoryPerNode;
+ }
+
+ public void setMaxMemoryPerNode(int maxMemoryPerNode) {
+ this.maxMemoryPerNode = maxMemoryPerNode;
+ }
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
+ generator.setParameter(ComputeResourceConstants.RESOURCE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
+ generator.setParameter(ComputeResourceConstants.RESOURCE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ ComputeResource computeResource = (ComputeResource) q.getSingleResult();
+ ComputeResourceResource computeResourceResource = (ComputeResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE, computeResource);
+ em.getTransaction().commit();
+ em.close();
+ return computeResourceResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> computeResourceResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
+ Query q;
+ if ((fieldName.equals(ComputeResourceConstants.RESOURCE_DESCRIPTION)) || (fieldName.equals(ComputeResourceConstants.RESOURCE_ID)) || (fieldName.equals(ComputeResourceConstants.HOST_NAME))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ComputeResource computeResource = (ComputeResource) result;
+ ComputeResourceResource computeResourceResource = (ComputeResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE, computeResource);
+ computeResourceResources.add(computeResourceResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Compute Resource Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Compute Resource Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return computeResourceResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ List<AppCatalogResource> computeResourceResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
+ Query q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ComputeResource computeResource = (ComputeResource) result;
+ ComputeResourceResource computeResourceResource = (ComputeResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE, computeResource);
+ computeResourceResources.add(computeResourceResource);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return computeResourceResources;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ List<String> computeResourceResources = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
+ Query q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ComputeResource computeResource = (ComputeResource) result;
+ computeResourceResources.add(computeResource.getResourceId());
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return computeResourceResources;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> computeResourceResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
+ Query q;
+ if ((fieldName.equals(ComputeResourceConstants.RESOURCE_DESCRIPTION)) || (fieldName.equals(ComputeResourceConstants.RESOURCE_ID)) || (fieldName.equals(ComputeResourceConstants.HOST_NAME))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ComputeResource computeResource = (ComputeResource) result;
+ ComputeResourceResource computeResourceResource = (ComputeResourceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE, computeResource);
+ computeResourceResourceIDs.add(computeResourceResource.getResourceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Compute Resource Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Compute Resource Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return computeResourceResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ComputeResource existingComputeResource = em.find(ComputeResource.class, resourceId);
+ em.close();
+ ComputeResource computeResource;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingComputeResource == null) {
+ computeResource = new ComputeResource();
+ computeResource.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ computeResource = existingComputeResource;
+ computeResource.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ computeResource.setResourceDescription(getResourceDescription());
+ computeResource.setResourceId(getResourceId());
+ computeResource.setHostName(getHostName());
+ computeResource.setMaxMemoryPerNode(getMaxMemoryPerNode());
+ if (existingComputeResource == null) {
+ em.persist(computeResource);
+ } else {
+ em.merge(computeResource);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ComputeResource computeResource = em.find(ComputeResource.class, identifier);
+ em.close();
+ return computeResource != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getResourceDescription() {
+ return resourceDescription;
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public void setResourceDescription(String resourceDescription) {
+ this.resourceDescription=resourceDescription;
+ }
+
+ public void setResourceId(String resourceId) {
+ this.resourceId=resourceId;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName=hostName;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceAppCatalogResourceAppCat.java
deleted file mode 100644
index 3d24829..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,339 +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.registry.core.app.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.model.DataMovementInterface;
-import org.apache.airavata.registry.core.app.catalog.model.DataMovementInterface_PK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DataMovementInterfaceAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(DataMovementInterfaceAppCatalogResourceAppCat.class);
- private String computeResourceId;
- private ComputeResourceAppCatalogResourceAppCat computeHostResource;
- private String dataMovementProtocol;
- private String dataMovementInterfaceId;
- private int priorityOrder;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE);
- generator.setParameter(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID));
- generator.setParameter(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID, ids.get(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE);
- generator.setParameter(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID));
- generator.setParameter(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID, ids.get(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID));
- Query q = generator.selectQuery(em);
- DataMovementInterface dataMovementInterface = (DataMovementInterface) q.getSingleResult();
- DataMovementInterfaceAppCatalogResourceAppCat dataMovementInterfaceResource = (DataMovementInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_INTERFACE, dataMovementInterface);
- em.getTransaction().commit();
- em.close();
- return dataMovementInterfaceResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> dataMovementInterfaceResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE);
- Query q;
- if ((fieldName.equals(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(DataMovementInterfaceConstants.DATA_MOVEMENT_PROTOCOL)) || (fieldName.equals(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(DataMovementInterfaceConstants.PRIORITY_ORDER))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- DataMovementInterface dataMovementInterface = (DataMovementInterface) result;
- DataMovementInterfaceAppCatalogResourceAppCat dataMovementInterfaceResource = (DataMovementInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_INTERFACE, dataMovementInterface);
- dataMovementInterfaceResources.add(dataMovementInterfaceResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Data Movement Interface Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Data Movement Interface Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return dataMovementInterfaceResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> dataMovementInterfaceResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE);
- Query q;
- if ((fieldName.equals(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(DataMovementInterfaceConstants.DATA_MOVEMENT_PROTOCOL)) || (fieldName.equals(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(DataMovementInterfaceConstants.PRIORITY_ORDER))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- DataMovementInterface dataMovementInterface = (DataMovementInterface) result;
- DataMovementInterfaceAppCatalogResourceAppCat dataMovementInterfaceResource = (DataMovementInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_INTERFACE, dataMovementInterface);
- dataMovementInterfaceResourceIDs.add(dataMovementInterfaceResource.getComputeResourceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Data Movement Interface Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Data Movement Interface Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return dataMovementInterfaceResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- DataMovementInterface existingDataMovementInterface = em.find(DataMovementInterface.class, new DataMovementInterface_PK(computeResourceId, dataMovementInterfaceId));
- em.close();
- DataMovementInterface dataMovementInterface;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingDataMovementInterface == null) {
- dataMovementInterface = new DataMovementInterface();
- dataMovementInterface.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- dataMovementInterface = existingDataMovementInterface;
- dataMovementInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- dataMovementInterface.setComputeResourceId(getComputeResourceId());
- ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
- dataMovementInterface.setComputeResource(computeResource);
- dataMovementInterface.setDataMovementProtocol(getDataMovementProtocol());
- dataMovementInterface.setDataMovementInterfaceId(getDataMovementInterfaceId());
- dataMovementInterface.setPriorityOrder(getPriorityOrder());
- if (existingDataMovementInterface == null) {
- em.persist(dataMovementInterface);
- } else {
- em.merge(dataMovementInterface);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- DataMovementInterface dataMovementInterface = em.find(DataMovementInterface.class, new DataMovementInterface_PK(ids.get(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID), ids.get(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID)));
- em.close();
- return dataMovementInterface != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getComputeResourceId() {
- return computeResourceId;
- }
-
- public ComputeResourceAppCatalogResourceAppCat getComputeHostResource() {
- return computeHostResource;
- }
-
- public String getDataMovementProtocol() {
- return dataMovementProtocol;
- }
-
- public String getDataMovementInterfaceId() {
- return dataMovementInterfaceId;
- }
-
- public int getPriorityOrder() {
- return priorityOrder;
- }
-
- public void setComputeResourceId(String computeResourceId) {
- this.computeResourceId=computeResourceId;
- }
-
- public void setComputeHostResource(ComputeResourceAppCatalogResourceAppCat computeHostResource) {
- this.computeHostResource=computeHostResource;
- }
-
- public void setDataMovementProtocol(String dataMovementProtocol) {
- this.dataMovementProtocol=dataMovementProtocol;
- }
-
- public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
- this.dataMovementInterfaceId=dataMovementInterfaceId;
- }
-
- public void setPriorityOrder(int priorityOrder) {
- this.priorityOrder=priorityOrder;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceResource.java
new file mode 100644
index 0000000..9ebac56
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/DataMovementInterfaceResource.java
@@ -0,0 +1,339 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.model.DataMovementInterface;
+import org.apache.airavata.registry.core.app.catalog.model.DataMovementInterface_PK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataMovementInterfaceResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(DataMovementInterfaceResource.class);
+ private String computeResourceId;
+ private ComputeResourceResource computeHostResource;
+ private String dataMovementProtocol;
+ private String dataMovementInterfaceId;
+ private int priorityOrder;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE);
+ generator.setParameter(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID));
+ generator.setParameter(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID, ids.get(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE);
+ generator.setParameter(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID));
+ generator.setParameter(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID, ids.get(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID));
+ Query q = generator.selectQuery(em);
+ DataMovementInterface dataMovementInterface = (DataMovementInterface) q.getSingleResult();
+ DataMovementInterfaceResource dataMovementInterfaceResource = (DataMovementInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_INTERFACE, dataMovementInterface);
+ em.getTransaction().commit();
+ em.close();
+ return dataMovementInterfaceResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> dataMovementInterfaceResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE);
+ Query q;
+ if ((fieldName.equals(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(DataMovementInterfaceConstants.DATA_MOVEMENT_PROTOCOL)) || (fieldName.equals(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(DataMovementInterfaceConstants.PRIORITY_ORDER))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ DataMovementInterface dataMovementInterface = (DataMovementInterface) result;
+ DataMovementInterfaceResource dataMovementInterfaceResource = (DataMovementInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_INTERFACE, dataMovementInterface);
+ dataMovementInterfaceResources.add(dataMovementInterfaceResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Data Movement Interface Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Data Movement Interface Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return dataMovementInterfaceResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> dataMovementInterfaceResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(DATA_MOVEMENT_INTERFACE);
+ Query q;
+ if ((fieldName.equals(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(DataMovementInterfaceConstants.DATA_MOVEMENT_PROTOCOL)) || (fieldName.equals(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(DataMovementInterfaceConstants.PRIORITY_ORDER))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ DataMovementInterface dataMovementInterface = (DataMovementInterface) result;
+ DataMovementInterfaceResource dataMovementInterfaceResource = (DataMovementInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.DATA_MOVEMENT_INTERFACE, dataMovementInterface);
+ dataMovementInterfaceResourceIDs.add(dataMovementInterfaceResource.getComputeResourceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Data Movement Interface Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Data Movement Interface Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return dataMovementInterfaceResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ DataMovementInterface existingDataMovementInterface = em.find(DataMovementInterface.class, new DataMovementInterface_PK(computeResourceId, dataMovementInterfaceId));
+ em.close();
+ DataMovementInterface dataMovementInterface;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingDataMovementInterface == null) {
+ dataMovementInterface = new DataMovementInterface();
+ dataMovementInterface.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ dataMovementInterface = existingDataMovementInterface;
+ dataMovementInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ dataMovementInterface.setComputeResourceId(getComputeResourceId());
+ ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
+ dataMovementInterface.setComputeResource(computeResource);
+ dataMovementInterface.setDataMovementProtocol(getDataMovementProtocol());
+ dataMovementInterface.setDataMovementInterfaceId(getDataMovementInterfaceId());
+ dataMovementInterface.setPriorityOrder(getPriorityOrder());
+ if (existingDataMovementInterface == null) {
+ em.persist(dataMovementInterface);
+ } else {
+ em.merge(dataMovementInterface);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ DataMovementInterface dataMovementInterface = em.find(DataMovementInterface.class, new DataMovementInterface_PK(ids.get(DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID), ids.get(DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID)));
+ em.close();
+ return dataMovementInterface != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getComputeResourceId() {
+ return computeResourceId;
+ }
+
+ public ComputeResourceResource getComputeHostResource() {
+ return computeHostResource;
+ }
+
+ public String getDataMovementProtocol() {
+ return dataMovementProtocol;
+ }
+
+ public String getDataMovementInterfaceId() {
+ return dataMovementInterfaceId;
+ }
+
+ public int getPriorityOrder() {
+ return priorityOrder;
+ }
+
+ public void setComputeResourceId(String computeResourceId) {
+ this.computeResourceId=computeResourceId;
+ }
+
+ public void setComputeHostResource(ComputeResourceResource computeHostResource) {
+ this.computeHostResource=computeHostResource;
+ }
+
+ public void setDataMovementProtocol(String dataMovementProtocol) {
+ this.dataMovementProtocol=dataMovementProtocol;
+ }
+
+ public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
+ this.dataMovementInterfaceId=dataMovementInterfaceId;
+ }
+
+ public void setPriorityOrder(int priorityOrder) {
+ this.priorityOrder=priorityOrder;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportAppCatalogResourceAppCat.java
deleted file mode 100644
index a127311..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,324 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.GSISSHExport;
-import org.apache.airavata.registry.core.app.catalog.model.GSISSHExportPK;
-import org.apache.airavata.registry.core.app.catalog.model.GSISSHSubmission;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class GSISSHExportAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(GSISSHExportAppCatalogResourceAppCat.class);
-
- private String submissionID;
- private String export;
-
- private GSISSHSubmissionAppCatalogResourceAppCat gsisshSubmissionResource;
-
-
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
- generator.setParameter(GSISSHExportConstants.EXPORT, ids.get(GSISSHExportConstants.EXPORT));
- generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, ids.get(GSISSHExportConstants.SUBMISSION_ID));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
- generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, ids.get(GSISSHExportConstants.SUBMISSION_ID));
- generator.setParameter(GSISSHExportConstants.EXPORT, ids.get(GSISSHExportConstants.EXPORT));
- Query q = generator.selectQuery(em);
- GSISSHExport gsisshExport = (GSISSHExport) q.getSingleResult();
- GSISSHExportAppCatalogResourceAppCat gsisshExportResource =
- (GSISSHExportAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT
- , gsisshExport);
- em.getTransaction().commit();
- em.close();
- return gsisshExportResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> gsiSSHExportResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
- List results;
- if (fieldName.equals(GSISSHExportConstants.EXPORT)) {
- generator.setParameter(GSISSHExportConstants.EXPORT, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHExport gsisshExport = (GSISSHExport) result;
- GSISSHExportAppCatalogResourceAppCat gsisshExportResource =
- (GSISSHExportAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT, gsisshExport);
- gsiSSHExportResources.add(gsisshExportResource);
- }
- }
- } else if (fieldName.equals(GSISSHExportConstants.SUBMISSION_ID)) {
- generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHExport gsisshExport = (GSISSHExport) result;
- GSISSHExportAppCatalogResourceAppCat gsisshExportResource =
- (GSISSHExportAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT, gsisshExport);
- gsiSSHExportResources.add(gsisshExportResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for GSISSH Export Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for GSISSH Export Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gsiSSHExportResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> gsiSSHExportIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
- List results;
- if (fieldName.equals(GSISSHExportConstants.SUBMISSION_ID)) {
- generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHExport gsisshExport = (GSISSHExport) result;
- gsiSSHExportIDs.add(gsisshExport.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GSISSHExportConstants.EXPORT)) {
- generator.setParameter(GSISSHExportConstants.EXPORT, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHExport gsisshExport = (GSISSHExport) result;
- gsiSSHExportIDs.add(gsisshExport.getSubmissionID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for GSISSH Export resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for GSISSH Export Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gsiSSHExportIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GSISSHExport existingGSIExport = em.find(GSISSHExport.class, new GSISSHExportPK(submissionID, export));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- GSISSHSubmission gsisshSubmission = em.find(GSISSHSubmission.class, submissionID);
- if (existingGSIExport != null) {
- existingGSIExport.setSubmissionID(submissionID);
- existingGSIExport.setExport(export);
- existingGSIExport.setGsisshJobSubmission(gsisshSubmission);
- em.merge(existingGSIExport);
- } else {
- GSISSHExport gsisshExport = new GSISSHExport();
- gsisshExport.setSubmissionID(submissionID);
- gsisshExport.setExport(export);
- gsisshExport.setGsisshJobSubmission(gsisshSubmission);
- em.persist(gsisshExport);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GSISSHExport gsisshExport = em.find(GSISSHExport.class, new GSISSHExportPK(ids.get(GSISSHExportConstants.SUBMISSION_ID),
- ids.get(GSISSHExportConstants.EXPORT)));
-
- em.close();
- return gsisshExport != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- } }
-
- public String getSubmissionID() {
- return submissionID;
- }
-
- public void setSubmissionID(String submissionID) {
- this.submissionID = submissionID;
- }
-
- public String getExport() {
- return export;
- }
-
- public void setExport(String export) {
- this.export = export;
- }
-
- public GSISSHSubmissionAppCatalogResourceAppCat getGsisshSubmissionResource() {
- return gsisshSubmissionResource;
- }
-
- public void setGsisshSubmissionResource(GSISSHSubmissionAppCatalogResourceAppCat gsisshSubmissionResource) {
- this.gsisshSubmissionResource = gsisshSubmissionResource;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportResource.java
new file mode 100644
index 0000000..1261b39
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHExportResource.java
@@ -0,0 +1,324 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.GSISSHExport;
+import org.apache.airavata.registry.core.app.catalog.model.GSISSHExportPK;
+import org.apache.airavata.registry.core.app.catalog.model.GSISSHSubmission;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class GSISSHExportResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(GSISSHExportResource.class);
+
+ private String submissionID;
+ private String export;
+
+ private GSISSHSubmissionResource gsisshSubmissionResource;
+
+
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
+ generator.setParameter(GSISSHExportConstants.EXPORT, ids.get(GSISSHExportConstants.EXPORT));
+ generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, ids.get(GSISSHExportConstants.SUBMISSION_ID));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
+ generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, ids.get(GSISSHExportConstants.SUBMISSION_ID));
+ generator.setParameter(GSISSHExportConstants.EXPORT, ids.get(GSISSHExportConstants.EXPORT));
+ Query q = generator.selectQuery(em);
+ GSISSHExport gsisshExport = (GSISSHExport) q.getSingleResult();
+ GSISSHExportResource gsisshExportResource =
+ (GSISSHExportResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT
+ , gsisshExport);
+ em.getTransaction().commit();
+ em.close();
+ return gsisshExportResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> gsiSSHExportResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
+ List results;
+ if (fieldName.equals(GSISSHExportConstants.EXPORT)) {
+ generator.setParameter(GSISSHExportConstants.EXPORT, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHExport gsisshExport = (GSISSHExport) result;
+ GSISSHExportResource gsisshExportResource =
+ (GSISSHExportResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT, gsisshExport);
+ gsiSSHExportResources.add(gsisshExportResource);
+ }
+ }
+ } else if (fieldName.equals(GSISSHExportConstants.SUBMISSION_ID)) {
+ generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHExport gsisshExport = (GSISSHExport) result;
+ GSISSHExportResource gsisshExportResource =
+ (GSISSHExportResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_EXPORT, gsisshExport);
+ gsiSSHExportResources.add(gsisshExportResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for GSISSH Export Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for GSISSH Export Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gsiSSHExportResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> gsiSSHExportIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_EXPORT);
+ List results;
+ if (fieldName.equals(GSISSHExportConstants.SUBMISSION_ID)) {
+ generator.setParameter(GSISSHExportConstants.SUBMISSION_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHExport gsisshExport = (GSISSHExport) result;
+ gsiSSHExportIDs.add(gsisshExport.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GSISSHExportConstants.EXPORT)) {
+ generator.setParameter(GSISSHExportConstants.EXPORT, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHExport gsisshExport = (GSISSHExport) result;
+ gsiSSHExportIDs.add(gsisshExport.getSubmissionID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for GSISSH Export resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for GSISSH Export Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gsiSSHExportIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GSISSHExport existingGSIExport = em.find(GSISSHExport.class, new GSISSHExportPK(submissionID, export));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ GSISSHSubmission gsisshSubmission = em.find(GSISSHSubmission.class, submissionID);
+ if (existingGSIExport != null) {
+ existingGSIExport.setSubmissionID(submissionID);
+ existingGSIExport.setExport(export);
+ existingGSIExport.setGsisshJobSubmission(gsisshSubmission);
+ em.merge(existingGSIExport);
+ } else {
+ GSISSHExport gsisshExport = new GSISSHExport();
+ gsisshExport.setSubmissionID(submissionID);
+ gsisshExport.setExport(export);
+ gsisshExport.setGsisshJobSubmission(gsisshSubmission);
+ em.persist(gsisshExport);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GSISSHExport gsisshExport = em.find(GSISSHExport.class, new GSISSHExportPK(ids.get(GSISSHExportConstants.SUBMISSION_ID),
+ ids.get(GSISSHExportConstants.EXPORT)));
+
+ em.close();
+ return gsisshExport != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ } }
+
+ public String getSubmissionID() {
+ return submissionID;
+ }
+
+ public void setSubmissionID(String submissionID) {
+ this.submissionID = submissionID;
+ }
+
+ public String getExport() {
+ return export;
+ }
+
+ public void setExport(String export) {
+ this.export = export;
+ }
+
+ public GSISSHSubmissionResource getGsisshSubmissionResource() {
+ return gsisshSubmissionResource;
+ }
+
+ public void setGsisshSubmissionResource(GSISSHSubmissionResource gsisshSubmissionResource) {
+ this.gsisshSubmissionResource = gsisshSubmissionResource;
+ }
+}
[25/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputAppCatalogResourceAppCat.java
deleted file mode 100644
index e383c1c..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,433 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.AppOutput_PK;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationOutput;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ApplicationOutputAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(ApplicationOutputAppCatalogResourceAppCat.class);
-
- private String interfaceID;
- private String outputKey;
- private String outputVal;
- private String dataType;
- private boolean isRequired;
- private boolean dataMovement;
- private String dataNameLocation;
- private boolean requiredToCMD;
- private String searchQuery;
- private String appArgument;
-
- private AppInterfaceAppCatalogResourceAppCat appInterfaceResource;
-
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_OUTPUT);
- generator.setParameter(AppOutputConstants.INTERFACE_ID, ids.get(AppOutputConstants.INTERFACE_ID));
- if (ids.get(AppOutputConstants.OUTPUT_KEY) != null){
- generator.setParameter(AppOutputConstants.OUTPUT_KEY, ids.get(AppOutputConstants.OUTPUT_KEY));
- }
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
-
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_OUTPUT);
- generator.setParameter(AppOutputConstants.INTERFACE_ID, ids.get(AppOutputConstants.INTERFACE_ID));
- generator.setParameter(AppOutputConstants.OUTPUT_KEY, ids.get(AppOutputConstants.OUTPUT_KEY));
- Query q = generator.selectQuery(em);
- ApplicationOutput applicationOutput = (ApplicationOutput) q.getSingleResult();
- ApplicationOutputAppCatalogResourceAppCat applicationOutputResource =
- (ApplicationOutputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_OUTPUT
- , applicationOutput);
- em.getTransaction().commit();
- em.close();
- return applicationOutputResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> appInputResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_OUTPUT);
- List results;
- if (fieldName.equals(AppOutputConstants.INTERFACE_ID)) {
- generator.setParameter(AppOutputConstants.INTERFACE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationOutput applicationOutput = (ApplicationOutput) result;
- ApplicationOutputAppCatalogResourceAppCat applicationOutputResource =
- (ApplicationOutputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.APPLICATION_OUTPUT, applicationOutput);
- appInputResources.add(applicationOutputResource);
- }
- }
- } else if (fieldName.equals(AppOutputConstants.OUTPUT_KEY)) {
- generator.setParameter(AppOutputConstants.OUTPUT_KEY, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationOutput applicationOutput = (ApplicationOutput) result;
- ApplicationOutputAppCatalogResourceAppCat applicationOutputResource =
- (ApplicationOutputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.APPLICATION_OUTPUT, applicationOutput);
- appInputResources.add(applicationOutputResource);
- }
- }
- } else if (fieldName.equals(AppOutputConstants.DATA_TYPE)) {
- generator.setParameter(AppOutputConstants.DATA_TYPE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationOutput applicationOutput = (ApplicationOutput) result;
- ApplicationOutputAppCatalogResourceAppCat applicationOutputResource =
- (ApplicationOutputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.APPLICATION_OUTPUT, applicationOutput);
- appInputResources.add(applicationOutputResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for App Output Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for App Output Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appInputResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> appOutputResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_OUTPUT);
- List results;
- if (fieldName.equals(AppOutputConstants.INTERFACE_ID)) {
- generator.setParameter(AppOutputConstants.INTERFACE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationOutput applicationOutput = (ApplicationOutput) result;
- appOutputResourceIDs.add(applicationOutput.getInterfaceID());
- }
- }
- }
- if (fieldName.equals(AppOutputConstants.OUTPUT_KEY)) {
- generator.setParameter(AppOutputConstants.OUTPUT_KEY, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationOutput applicationOutput = (ApplicationOutput) result;
- appOutputResourceIDs.add(applicationOutput.getInterfaceID());
- }
- }
- } else if (fieldName.equals(AppOutputConstants.DATA_TYPE)) {
- generator.setParameter(AppOutputConstants.DATA_TYPE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationOutput applicationOutput = (ApplicationOutput) result;
- appOutputResourceIDs.add(applicationOutput.getInterfaceID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for App Output resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for App Output Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appOutputResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationOutput existingApplicationOutput = em.find(ApplicationOutput.class,
- new AppOutput_PK(interfaceID, outputKey));
- em.close();
-
- ApplicationOutput applicationOutput;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingApplicationOutput == null) {
- applicationOutput = new ApplicationOutput();
- } else {
- applicationOutput = existingApplicationOutput;
- }
- ApplicationInterface applicationInterface = em.find(ApplicationInterface.class, interfaceID);
- applicationOutput.setApplicationInterface(applicationInterface);
- applicationOutput.setInterfaceID(applicationInterface.getInterfaceID());
- applicationOutput.setDataType(dataType);
- applicationOutput.setOutputKey(outputKey);
- applicationOutput.setOutputVal(outputVal);
- applicationOutput.setRequired(isRequired);
- applicationOutput.setRequiredToCMD(requiredToCMD);
- applicationOutput.setDataMovement(dataMovement);
- applicationOutput.setDataNameLocation(dataNameLocation);
- applicationOutput.setSearchQuery(searchQuery);
- applicationOutput.setApplicationArgument(appArgument);
- em.merge(applicationOutput);
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationOutput applicationOutput = em.find(ApplicationOutput.class, new AppOutput_PK(
- ids.get(AppOutputConstants.INTERFACE_ID),
- ids.get(AppOutputConstants.OUTPUT_KEY)));
-
- em.close();
- return applicationOutput != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getInterfaceID() {
- return interfaceID;
- }
-
- public void setInterfaceID(String interfaceID) {
- this.interfaceID = interfaceID;
- }
-
- public String getOutputKey() {
- return outputKey;
- }
-
- public void setOutputKey(String outputKey) {
- this.outputKey = outputKey;
- }
-
- public String getOutputVal() {
- return outputVal;
- }
-
- public void setOutputVal(String outputVal) {
- this.outputVal = outputVal;
- }
-
- public String getDataType() {
- return dataType;
- }
-
- public void setDataType(String dataType) {
- this.dataType = dataType;
- }
-
- public AppInterfaceAppCatalogResourceAppCat getAppInterfaceResource() {
- return appInterfaceResource;
- }
-
- public void setAppInterfaceResource(AppInterfaceAppCatalogResourceAppCat appInterfaceResource) {
- this.appInterfaceResource = appInterfaceResource;
- }
-
- public boolean getRequired() {
- return isRequired;
- }
-
- public void setRequired(boolean required) {
- this.isRequired = required;
- }
-
- public boolean isDataMovement() {
- return dataMovement;
- }
-
- public void setDataMovement(boolean dataMovement) {
- this.dataMovement = dataMovement;
- }
-
- public String getDataNameLocation() {
- return dataNameLocation;
- }
-
- public void setDataNameLocation(String dataNameLocation) {
- this.dataNameLocation = dataNameLocation;
- }
-
- public boolean getRequiredToCMD() {
- return requiredToCMD;
- }
-
- public void setRequiredToCMD(boolean requiredToCMD) {
- this.requiredToCMD = requiredToCMD;
- }
-
- 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;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputResource.java
new file mode 100644
index 0000000..b78ed41
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationOutputResource.java
@@ -0,0 +1,433 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.AppOutput_PK;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationOutput;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ApplicationOutputResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ApplicationOutputResource.class);
+
+ private String interfaceID;
+ private String outputKey;
+ private String outputVal;
+ private String dataType;
+ private boolean isRequired;
+ private boolean dataMovement;
+ private String dataNameLocation;
+ private boolean requiredToCMD;
+ private String searchQuery;
+ private String appArgument;
+
+ private AppInterfaceResource appInterfaceResource;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_OUTPUT);
+ generator.setParameter(AppOutputConstants.INTERFACE_ID, ids.get(AppOutputConstants.INTERFACE_ID));
+ if (ids.get(AppOutputConstants.OUTPUT_KEY) != null){
+ generator.setParameter(AppOutputConstants.OUTPUT_KEY, ids.get(AppOutputConstants.OUTPUT_KEY));
+ }
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_OUTPUT);
+ generator.setParameter(AppOutputConstants.INTERFACE_ID, ids.get(AppOutputConstants.INTERFACE_ID));
+ generator.setParameter(AppOutputConstants.OUTPUT_KEY, ids.get(AppOutputConstants.OUTPUT_KEY));
+ Query q = generator.selectQuery(em);
+ ApplicationOutput applicationOutput = (ApplicationOutput) q.getSingleResult();
+ ApplicationOutputResource applicationOutputResource =
+ (ApplicationOutputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_OUTPUT
+ , applicationOutput);
+ em.getTransaction().commit();
+ em.close();
+ return applicationOutputResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> appInputResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_OUTPUT);
+ List results;
+ if (fieldName.equals(AppOutputConstants.INTERFACE_ID)) {
+ generator.setParameter(AppOutputConstants.INTERFACE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationOutput applicationOutput = (ApplicationOutput) result;
+ ApplicationOutputResource applicationOutputResource =
+ (ApplicationOutputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.APPLICATION_OUTPUT, applicationOutput);
+ appInputResources.add(applicationOutputResource);
+ }
+ }
+ } else if (fieldName.equals(AppOutputConstants.OUTPUT_KEY)) {
+ generator.setParameter(AppOutputConstants.OUTPUT_KEY, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationOutput applicationOutput = (ApplicationOutput) result;
+ ApplicationOutputResource applicationOutputResource =
+ (ApplicationOutputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.APPLICATION_OUTPUT, applicationOutput);
+ appInputResources.add(applicationOutputResource);
+ }
+ }
+ } else if (fieldName.equals(AppOutputConstants.DATA_TYPE)) {
+ generator.setParameter(AppOutputConstants.DATA_TYPE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationOutput applicationOutput = (ApplicationOutput) result;
+ ApplicationOutputResource applicationOutputResource =
+ (ApplicationOutputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.APPLICATION_OUTPUT, applicationOutput);
+ appInputResources.add(applicationOutputResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for App Output Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for App Output Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appInputResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> appOutputResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_OUTPUT);
+ List results;
+ if (fieldName.equals(AppOutputConstants.INTERFACE_ID)) {
+ generator.setParameter(AppOutputConstants.INTERFACE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationOutput applicationOutput = (ApplicationOutput) result;
+ appOutputResourceIDs.add(applicationOutput.getInterfaceID());
+ }
+ }
+ }
+ if (fieldName.equals(AppOutputConstants.OUTPUT_KEY)) {
+ generator.setParameter(AppOutputConstants.OUTPUT_KEY, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationOutput applicationOutput = (ApplicationOutput) result;
+ appOutputResourceIDs.add(applicationOutput.getInterfaceID());
+ }
+ }
+ } else if (fieldName.equals(AppOutputConstants.DATA_TYPE)) {
+ generator.setParameter(AppOutputConstants.DATA_TYPE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationOutput applicationOutput = (ApplicationOutput) result;
+ appOutputResourceIDs.add(applicationOutput.getInterfaceID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for App Output resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for App Output Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appOutputResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationOutput existingApplicationOutput = em.find(ApplicationOutput.class,
+ new AppOutput_PK(interfaceID, outputKey));
+ em.close();
+
+ ApplicationOutput applicationOutput;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingApplicationOutput == null) {
+ applicationOutput = new ApplicationOutput();
+ } else {
+ applicationOutput = existingApplicationOutput;
+ }
+ ApplicationInterface applicationInterface = em.find(ApplicationInterface.class, interfaceID);
+ applicationOutput.setApplicationInterface(applicationInterface);
+ applicationOutput.setInterfaceID(applicationInterface.getInterfaceID());
+ applicationOutput.setDataType(dataType);
+ applicationOutput.setOutputKey(outputKey);
+ applicationOutput.setOutputVal(outputVal);
+ applicationOutput.setRequired(isRequired);
+ applicationOutput.setRequiredToCMD(requiredToCMD);
+ applicationOutput.setDataMovement(dataMovement);
+ applicationOutput.setDataNameLocation(dataNameLocation);
+ applicationOutput.setSearchQuery(searchQuery);
+ applicationOutput.setApplicationArgument(appArgument);
+ em.merge(applicationOutput);
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationOutput applicationOutput = em.find(ApplicationOutput.class, new AppOutput_PK(
+ ids.get(AppOutputConstants.INTERFACE_ID),
+ ids.get(AppOutputConstants.OUTPUT_KEY)));
+
+ em.close();
+ return applicationOutput != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getInterfaceID() {
+ return interfaceID;
+ }
+
+ public void setInterfaceID(String interfaceID) {
+ this.interfaceID = interfaceID;
+ }
+
+ public String getOutputKey() {
+ return outputKey;
+ }
+
+ public void setOutputKey(String outputKey) {
+ this.outputKey = outputKey;
+ }
+
+ public String getOutputVal() {
+ return outputVal;
+ }
+
+ public void setOutputVal(String outputVal) {
+ this.outputVal = outputVal;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public AppInterfaceResource getAppInterfaceResource() {
+ return appInterfaceResource;
+ }
+
+ public void setAppInterfaceResource(AppInterfaceResource appInterfaceResource) {
+ this.appInterfaceResource = appInterfaceResource;
+ }
+
+ public boolean getRequired() {
+ return isRequired;
+ }
+
+ public void setRequired(boolean required) {
+ this.isRequired = required;
+ }
+
+ public boolean isDataMovement() {
+ return dataMovement;
+ }
+
+ public void setDataMovement(boolean dataMovement) {
+ this.dataMovement = dataMovement;
+ }
+
+ public String getDataNameLocation() {
+ return dataNameLocation;
+ }
+
+ public void setDataNameLocation(String dataNameLocation) {
+ this.dataNameLocation = dataNameLocation;
+ }
+
+ public boolean getRequiredToCMD() {
+ return requiredToCMD;
+ }
+
+ public void setRequiredToCMD(boolean requiredToCMD) {
+ this.requiredToCMD = requiredToCMD;
+ }
+
+ 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueAppCatalogResourceAppCat.java
deleted file mode 100644
index 6ba1762..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,357 +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.registry.core.app.catalog.resources;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.BatchQueue;
-import org.apache.airavata.registry.core.app.catalog.model.BatchQueue_PK;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class BatchQueueAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(BatchQueueAppCatalogResourceAppCat.class);
- private String computeResourceId;
- private ComputeResourceAppCatalogResourceAppCat computeHostResource;
- private int maxRuntime;
- private int maxJobInQueue;
- private String queueDescription;
- private String queueName;
- private int maxProcessors;
- private int maxNodes;
- private int maxMemory;
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(BATCH_QUEUE);
- generator.setParameter(BatchQueueConstants.COMPUTE_RESOURCE_ID, ids.get(BatchQueueConstants.COMPUTE_RESOURCE_ID));
- generator.setParameter(BatchQueueConstants.QUEUE_NAME, ids.get(BatchQueueConstants.QUEUE_NAME));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(BATCH_QUEUE);
- generator.setParameter(BatchQueueConstants.COMPUTE_RESOURCE_ID, ids.get(BatchQueueConstants.COMPUTE_RESOURCE_ID));
- generator.setParameter(BatchQueueConstants.QUEUE_NAME, ids.get(BatchQueueConstants.QUEUE_NAME));
- Query q = generator.selectQuery(em);
- BatchQueue batchQueue = (BatchQueue) q.getSingleResult();
- BatchQueueAppCatalogResourceAppCat batchQueueResource = (BatchQueueAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.BATCH_QUEUE, batchQueue);
- em.getTransaction().commit();
- em.close();
- return batchQueueResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> batchQueueResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(BATCH_QUEUE);
- Query q;
- if ((fieldName.equals(BatchQueueConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(BatchQueueConstants.MAX_RUNTIME)) || (fieldName.equals(BatchQueueConstants.MAX_JOB_IN_QUEUE)) || (fieldName.equals(BatchQueueConstants.QUEUE_DESCRIPTION)) || (fieldName.equals(BatchQueueConstants.QUEUE_NAME)) || (fieldName.equals(BatchQueueConstants.MAX_PROCESSORS)) || (fieldName.equals(BatchQueueConstants.MAX_NODES))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- BatchQueue batchQueue = (BatchQueue) result;
- BatchQueueAppCatalogResourceAppCat batchQueueResource = (BatchQueueAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.BATCH_QUEUE, batchQueue);
- batchQueueResources.add(batchQueueResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Batch Queue Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Batch Queue Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return batchQueueResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> batchQueueResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(BATCH_QUEUE);
- Query q;
- if ((fieldName.equals(BatchQueueConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(BatchQueueConstants.MAX_RUNTIME)) || (fieldName.equals(BatchQueueConstants.MAX_JOB_IN_QUEUE)) || (fieldName.equals(BatchQueueConstants.QUEUE_DESCRIPTION)) || (fieldName.equals(BatchQueueConstants.QUEUE_NAME)) || (fieldName.equals(BatchQueueConstants.MAX_PROCESSORS)) || (fieldName.equals(BatchQueueConstants.MAX_NODES))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- BatchQueue batchQueue = (BatchQueue) result;
- BatchQueueAppCatalogResourceAppCat batchQueueResource = (BatchQueueAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.BATCH_QUEUE, batchQueue);
- batchQueueResourceIDs.add(batchQueueResource.getComputeResourceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Batch Queue Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Batch Queue Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return batchQueueResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- BatchQueue existingBatchQueue = em.find(BatchQueue.class, new BatchQueue_PK(computeResourceId, queueName));
- em.close();
- BatchQueue batchQueue;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingBatchQueue == null) {
- batchQueue = new BatchQueue();
- } else {
- batchQueue = existingBatchQueue;
- }
- batchQueue.setComputeResourceId(getComputeResourceId());
- ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
- batchQueue.setComputeResource(computeResource);
- batchQueue.setMaxRuntime(getMaxRuntime());
- batchQueue.setMaxJobInQueue(getMaxJobInQueue());
- batchQueue.setQueueDescription(getQueueDescription());
- batchQueue.setQueueName(getQueueName());
- batchQueue.setMaxProcessors(getMaxProcessors());
- batchQueue.setMaxNodes(getMaxNodes());
- batchQueue.setMaxMemory(getMaxMemory());
- if (existingBatchQueue == null) {
- em.persist(batchQueue);
- } else {
- em.merge(batchQueue);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- BatchQueue batchQueue = em.find(BatchQueue.class, new BatchQueue_PK(ids.get(BatchQueueConstants.COMPUTE_RESOURCE_ID), ids.get(BatchQueueConstants.QUEUE_NAME)));
- em.close();
- return batchQueue != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getComputeResourceId() {
- return computeResourceId;
- }
-
- public ComputeResourceAppCatalogResourceAppCat getComputeHostResource() {
- return computeHostResource;
- }
-
- public int getMaxRuntime() {
- return maxRuntime;
- }
-
- public int getMaxJobInQueue() {
- return maxJobInQueue;
- }
-
- public String getQueueDescription() {
- return queueDescription;
- }
-
- public String getQueueName() {
- return queueName;
- }
-
- public int getMaxProcessors() {
- return maxProcessors;
- }
-
- public int getMaxNodes() {
- return maxNodes;
- }
-
- public void setComputeResourceId(String computeResourceId) {
- this.computeResourceId=computeResourceId;
- }
-
- public void setComputeHostResource(ComputeResourceAppCatalogResourceAppCat computeHostResource) {
- this.computeHostResource=computeHostResource;
- }
-
- public void setMaxRuntime(int maxRuntime) {
- this.maxRuntime=maxRuntime;
- }
-
- public void setMaxJobInQueue(int maxJobInQueue) {
- this.maxJobInQueue=maxJobInQueue;
- }
-
- public void setQueueDescription(String queueDescription) {
- this.queueDescription=queueDescription;
- }
-
- public void setQueueName(String queueName) {
- this.queueName=queueName;
- }
-
- public void setMaxProcessors(int maxProcessors) {
- this.maxProcessors=maxProcessors;
- }
-
- public void setMaxNodes(int maxNodes) {
- this.maxNodes=maxNodes;
- }
-
- public int getMaxMemory() {
- return maxMemory;
- }
-
- public void setMaxMemory(int maxMemory) {
- this.maxMemory = maxMemory;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueResource.java
new file mode 100644
index 0000000..56e088c
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/BatchQueueResource.java
@@ -0,0 +1,357 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.BatchQueue;
+import org.apache.airavata.registry.core.app.catalog.model.BatchQueue_PK;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BatchQueueResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(BatchQueueResource.class);
+ private String computeResourceId;
+ private ComputeResourceResource computeHostResource;
+ private int maxRuntime;
+ private int maxJobInQueue;
+ private String queueDescription;
+ private String queueName;
+ private int maxProcessors;
+ private int maxNodes;
+ private int maxMemory;
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(BATCH_QUEUE);
+ generator.setParameter(BatchQueueConstants.COMPUTE_RESOURCE_ID, ids.get(BatchQueueConstants.COMPUTE_RESOURCE_ID));
+ generator.setParameter(BatchQueueConstants.QUEUE_NAME, ids.get(BatchQueueConstants.QUEUE_NAME));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(BATCH_QUEUE);
+ generator.setParameter(BatchQueueConstants.COMPUTE_RESOURCE_ID, ids.get(BatchQueueConstants.COMPUTE_RESOURCE_ID));
+ generator.setParameter(BatchQueueConstants.QUEUE_NAME, ids.get(BatchQueueConstants.QUEUE_NAME));
+ Query q = generator.selectQuery(em);
+ BatchQueue batchQueue = (BatchQueue) q.getSingleResult();
+ BatchQueueResource batchQueueResource = (BatchQueueResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.BATCH_QUEUE, batchQueue);
+ em.getTransaction().commit();
+ em.close();
+ return batchQueueResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> batchQueueResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(BATCH_QUEUE);
+ Query q;
+ if ((fieldName.equals(BatchQueueConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(BatchQueueConstants.MAX_RUNTIME)) || (fieldName.equals(BatchQueueConstants.MAX_JOB_IN_QUEUE)) || (fieldName.equals(BatchQueueConstants.QUEUE_DESCRIPTION)) || (fieldName.equals(BatchQueueConstants.QUEUE_NAME)) || (fieldName.equals(BatchQueueConstants.MAX_PROCESSORS)) || (fieldName.equals(BatchQueueConstants.MAX_NODES))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ BatchQueue batchQueue = (BatchQueue) result;
+ BatchQueueResource batchQueueResource = (BatchQueueResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.BATCH_QUEUE, batchQueue);
+ batchQueueResources.add(batchQueueResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Batch Queue Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Batch Queue Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return batchQueueResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> batchQueueResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(BATCH_QUEUE);
+ Query q;
+ if ((fieldName.equals(BatchQueueConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(BatchQueueConstants.MAX_RUNTIME)) || (fieldName.equals(BatchQueueConstants.MAX_JOB_IN_QUEUE)) || (fieldName.equals(BatchQueueConstants.QUEUE_DESCRIPTION)) || (fieldName.equals(BatchQueueConstants.QUEUE_NAME)) || (fieldName.equals(BatchQueueConstants.MAX_PROCESSORS)) || (fieldName.equals(BatchQueueConstants.MAX_NODES))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ BatchQueue batchQueue = (BatchQueue) result;
+ BatchQueueResource batchQueueResource = (BatchQueueResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.BATCH_QUEUE, batchQueue);
+ batchQueueResourceIDs.add(batchQueueResource.getComputeResourceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Batch Queue Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Batch Queue Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return batchQueueResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ BatchQueue existingBatchQueue = em.find(BatchQueue.class, new BatchQueue_PK(computeResourceId, queueName));
+ em.close();
+ BatchQueue batchQueue;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingBatchQueue == null) {
+ batchQueue = new BatchQueue();
+ } else {
+ batchQueue = existingBatchQueue;
+ }
+ batchQueue.setComputeResourceId(getComputeResourceId());
+ ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
+ batchQueue.setComputeResource(computeResource);
+ batchQueue.setMaxRuntime(getMaxRuntime());
+ batchQueue.setMaxJobInQueue(getMaxJobInQueue());
+ batchQueue.setQueueDescription(getQueueDescription());
+ batchQueue.setQueueName(getQueueName());
+ batchQueue.setMaxProcessors(getMaxProcessors());
+ batchQueue.setMaxNodes(getMaxNodes());
+ batchQueue.setMaxMemory(getMaxMemory());
+ if (existingBatchQueue == null) {
+ em.persist(batchQueue);
+ } else {
+ em.merge(batchQueue);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ BatchQueue batchQueue = em.find(BatchQueue.class, new BatchQueue_PK(ids.get(BatchQueueConstants.COMPUTE_RESOURCE_ID), ids.get(BatchQueueConstants.QUEUE_NAME)));
+ em.close();
+ return batchQueue != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getComputeResourceId() {
+ return computeResourceId;
+ }
+
+ public ComputeResourceResource getComputeHostResource() {
+ return computeHostResource;
+ }
+
+ public int getMaxRuntime() {
+ return maxRuntime;
+ }
+
+ public int getMaxJobInQueue() {
+ return maxJobInQueue;
+ }
+
+ public String getQueueDescription() {
+ return queueDescription;
+ }
+
+ public String getQueueName() {
+ return queueName;
+ }
+
+ public int getMaxProcessors() {
+ return maxProcessors;
+ }
+
+ public int getMaxNodes() {
+ return maxNodes;
+ }
+
+ public void setComputeResourceId(String computeResourceId) {
+ this.computeResourceId=computeResourceId;
+ }
+
+ public void setComputeHostResource(ComputeResourceResource computeHostResource) {
+ this.computeHostResource=computeHostResource;
+ }
+
+ public void setMaxRuntime(int maxRuntime) {
+ this.maxRuntime=maxRuntime;
+ }
+
+ public void setMaxJobInQueue(int maxJobInQueue) {
+ this.maxJobInQueue=maxJobInQueue;
+ }
+
+ public void setQueueDescription(String queueDescription) {
+ this.queueDescription=queueDescription;
+ }
+
+ public void setQueueName(String queueName) {
+ this.queueName=queueName;
+ }
+
+ public void setMaxProcessors(int maxProcessors) {
+ this.maxProcessors=maxProcessors;
+ }
+
+ public void setMaxNodes(int maxNodes) {
+ this.maxNodes=maxNodes;
+ }
+
+ public int getMaxMemory() {
+ return maxMemory;
+ }
+
+ public void setMaxMemory(int maxMemory) {
+ this.maxMemory = maxMemory;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionAppCatalogResourceAppCat.java
deleted file mode 100644
index cb01e2a..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,298 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.CloudJobSubmission;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.List;
-
-public class CloudSubmissionAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(LocalSubmissionAppCatalogResourceAppCat.class);
- private String jobSubmissionInterfaceId;
- private String securityProtocol;
- private String nodeId;
- private String executableType;
- private String providerName;
- private String userAccountName;
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(CLOUD_JOB_SUBMISSION);
- generator.setParameter(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(CLOUD_JOB_SUBMISSION);
- generator.setParameter(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
- Query q = generator.selectQuery(em);
- CloudJobSubmission cloudJobSubmission = (CloudJobSubmission) q.getSingleResult();
- CloudSubmissionAppCatalogResourceAppCat localSubmissionResource = (CloudSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.ClOUD_SUBMISSION, cloudJobSubmission);
- em.getTransaction().commit();
- em.close();
- return localSubmissionResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> localSubmissionResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(CLOUD_JOB_SUBMISSION);
- Query q;
- if ((fieldName.equals(LocalSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- CloudJobSubmission localSubmission = (CloudJobSubmission) result;
- CloudSubmissionAppCatalogResourceAppCat localSubmissionResource = (CloudSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.ClOUD_SUBMISSION, localSubmission);
- localSubmissionResources.add(localSubmissionResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return localSubmissionResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> localSubmissionResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(CLOUD_JOB_SUBMISSION);
- Query q;
- if ((fieldName.equals(LocalSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- CloudJobSubmission localSubmission = (CloudJobSubmission) result;
- LocalSubmissionAppCatalogResourceAppCat localSubmissionResource = (LocalSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.ClOUD_SUBMISSION, localSubmission);
- localSubmissionResourceIDs.add(localSubmissionResource.getJobSubmissionInterfaceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return localSubmissionResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- CloudJobSubmission existingLocalSubmission = em.find(CloudJobSubmission.class, jobSubmissionInterfaceId);
- em.close();
- CloudJobSubmission cloudJobSubmission;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingLocalSubmission == null) {
- cloudJobSubmission = new CloudJobSubmission();
- } else {
- cloudJobSubmission = existingLocalSubmission;
- }
- cloudJobSubmission.setExecutableType(getExecutableType());
- cloudJobSubmission.setNodeId(getNodeId());
- cloudJobSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
- cloudJobSubmission.setSecurityProtocol(getSecurityProtocol());
- cloudJobSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
- cloudJobSubmission.setUserAccountName(getUserAccountName());
- cloudJobSubmission.setProviderName(getProviderName());
- if (existingLocalSubmission == null) {
- em.persist(cloudJobSubmission);
- } else {
- em.merge(cloudJobSubmission);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- CloudJobSubmission localSubmission = em.find(CloudJobSubmission.class, identifier);
- em.close();
- return localSubmission != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getJobSubmissionInterfaceId() {
- return jobSubmissionInterfaceId;
- }
-
- public String getSecurityProtocol() {
- return securityProtocol;
- }
-
- public void setSecurityProtocol(String securityProtocol) {
- this.securityProtocol = securityProtocol;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-
- public String getExecutableType() {
- return executableType;
- }
-
- public void setExecutableType(String executableType) {
- this.executableType = executableType;
- }
-
- public String getProviderName() {
- return providerName;
- }
-
- public void setProviderName(String providerName) {
- this.providerName = providerName;
- }
-
- public String getUserAccountName() {
- return userAccountName;
- }
-
- public void setUserAccountName(String userAccountName) {
- this.userAccountName = userAccountName;
- }
-
- public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
- this.jobSubmissionInterfaceId=jobSubmissionInterfaceId;
- }
-}
[07/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
new file mode 100644
index 0000000..a7d8544
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayResource.java
@@ -0,0 +1,437 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GatewayResource extends AbstractExpCatResource {
+ private final static Logger logger = LoggerFactory.getLogger(GatewayResource.class);
+
+ private String gatewayId;
+ private String gatewayName;
+ private String domain;
+ private String emailAddress;
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public String getEmailAddress() {
+ return emailAddress;
+ }
+
+ public void setEmailAddress(String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ /**
+ *
+ * @param gatewayId gateway name
+ */
+ public GatewayResource(String gatewayId) {
+ setGatewayId(gatewayId);
+ }
+
+ /**
+ *
+ */
+ public GatewayResource() {
+ }
+
+ /**
+ *
+ * @return gateway name
+ */
+ public String getGatewayName() {
+ return gatewayName;
+ }
+
+ /**
+ *
+ * @param gatewayName
+ */
+ public void setGatewayName(String gatewayName) {
+ this.gatewayName = gatewayName;
+ }
+
+ /**
+ *
+ * @return domain of the gateway
+ */
+ public String getDomain() {
+ return domain;
+ }
+
+ /**
+ *
+ * @param domain domain of the gateway
+ */
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+
+
+ /**
+ * Gateway is at the root level. So it can populate his child resources.
+ * Project, User, Published Workflows, User workflows, Host descriptors,
+ * Service Descriptors, Application descriptors and Experiments are all
+ * its children
+ * @param type resource type of the children
+ * @return specific child resource type
+ */
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ switch (type) {
+ case PROJECT:
+ ProjectResource projectResource = new ProjectResource();
+ projectResource.setGatewayId(gatewayId);
+ return projectResource;
+ case EXPERIMENT:
+ ExperimentResource experimentResource =new ExperimentResource();
+ experimentResource.setGatewayId(gatewayId);
+ return experimentResource;
+ case GATEWAY_WORKER:
+ WorkerResource workerResource = new WorkerResource();
+ workerResource.setGatewayId(gatewayId);
+ return workerResource;
+ default:
+ logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
+ }
+ }
+
+ /**
+ * Child resources can be removed from a gateway
+ * @param type child resource type
+ * @param name child resource name
+ */
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ switch (type) {
+ case USER:
+ generator = new QueryGenerator(USERS);
+ generator.setParameter(UserConstants.USERNAME, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case EXPERIMENT:
+ generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ default:
+ logger.error("Unsupported resource type for gateway 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();
+ }
+ }
+ }
+
+ /**
+ * Gateway can get information of his children
+ * @param type child resource type
+ * @param name child resource name
+ * @return specific child resource type
+ */
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator;
+ Query q;
+ switch (type) {
+ case GATEWAY_WORKER:
+ generator = new QueryGenerator(GATEWAY_WORKER);
+ generator.setParameter(GatewayWorkerConstants.USERNAME, name);
+ generator.setParameter(GatewayWorkerConstants.GATEWAY_ID, gatewayId);
+ q = generator.selectQuery(em);
+ Gateway_Worker worker = (Gateway_Worker) q.getSingleResult();
+ WorkerResource workerResource =
+ (WorkerResource) Utils.getResource(ResourceType.GATEWAY_WORKER, worker);
+ em.getTransaction().commit();
+ em.close();
+ return workerResource;
+ case USER:
+ generator = new QueryGenerator(USERS);
+ generator.setParameter(UserConstants.USERNAME, name);
+ q = generator.selectQuery(em);
+ Users user = (Users) q.getSingleResult();
+ UserResource userResource =
+ (UserResource) Utils.getResource(ResourceType.USER, user);
+ em.getTransaction().commit();
+ em.close();
+ return userResource;
+ case EXPERIMENT:
+ generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+ q = generator.selectQuery(em);
+ Experiment experiment = (Experiment) q.getSingleResult();
+ ExperimentResource experimentResource =
+ (ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
+ em.getTransaction().commit();
+ em.close();
+ return experimentResource;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @return list of child resources
+ */
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ List results;
+ switch (type) {
+ case PROJECT:
+ generator = new QueryGenerator(PROJECT);
+ Gateway gatewayModel = em.find(Gateway.class, gatewayId);
+ generator.setParameter("gateway", gatewayModel);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Project project = (Project) result;
+ ProjectResource projectResource =
+ (ProjectResource) Utils.getResource(ResourceType.PROJECT, project);
+ resourceList.add(projectResource);
+ }
+ }
+ break;
+ case GATEWAY_WORKER:
+ generator = new QueryGenerator(GATEWAY_WORKER);
+ generator.setParameter(GatewayWorkerConstants.GATEWAY_ID, gatewayId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Gateway_Worker gatewayWorker = (Gateway_Worker) result;
+ WorkerResource workerResource =
+ (WorkerResource) Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
+ resourceList.add(workerResource);
+ }
+ }
+ break;
+ case EXPERIMENT:
+ generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.GATEWAY_ID, gatewayId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Experiment experiment = (Experiment) result;
+ ExperimentResource experimentResource =
+ (ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
+ resourceList.add(experimentResource);
+ }
+ }
+ break;
+ case USER:
+ generator = new QueryGenerator(USERS);
+ q = generator.selectQuery(em);
+ for (Object o : q.getResultList()) {
+ Users user = (Users) o;
+ UserResource userResource =
+ (UserResource) Utils.getResource(ResourceType.USER, user);
+ resourceList.add(userResource);
+ }
+ break;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+ /**
+ * save the gateway to the database
+ */
+ public void save() throws RegistryException {
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ Gateway existingGateway = em.find(Gateway.class, gatewayId);
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Gateway gateway = new Gateway();
+ gateway.setGateway_name(gatewayName);
+ gateway.setGateway_id(gatewayId);
+ gateway.setDomain(domain);
+ gateway.setEmailAddress(emailAddress);
+ if (existingGateway != null) {
+ existingGateway.setDomain(domain);
+ existingGateway.setGateway_name(gatewayName);
+ existingGateway.setEmailAddress(emailAddress);
+ gateway = em.merge(existingGateway);
+ } else {
+ em.persist(gateway);
+ }
+ 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();
+ }
+ }
+
+ }
+
+ /**
+ * check whether child resource already exist in the database
+ * @param type child resource type
+ * @param name name of the child resource
+ * @return true or false
+ */
+ public boolean isExists(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ switch (type) {
+ case GATEWAY_WORKER:
+ em = ExpCatResourceUtils.getEntityManager();
+ Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayId, name.toString()));
+ em.close();
+ return existingWorker != null;
+ case USER:
+ em = ExpCatResourceUtils.getEntityManager();
+ Users existingUser = em.find(Users.class, name);
+ em.close();
+ return existingUser != null;
+ case EXPERIMENT:
+ em = ExpCatResourceUtils.getEntityManager();
+ Experiment existingExp = em.find(Experiment.class, name.toString());
+ em.close();
+ return existingExp != null;
+ default:
+ logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public ExperimentResource createExperiment (String experimentID) throws RegistryException{
+ ExperimentResource metadataResource = (ExperimentResource)create(ResourceType.EXPERIMENT);
+ metadataResource.setExpID(experimentID);
+ return metadataResource;
+ }
+
+ public ExperimentResource getExperiment (String expId) throws RegistryException{
+ return (ExperimentResource)get(ResourceType.EXPERIMENT, expId);
+ }
+
+ public List<ExperimentResource> getExperiments () throws RegistryException{
+ List<ExperimentResource> experiments = new ArrayList<ExperimentResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT);
+ for (ExperimentCatResource resource : resources){
+ experiments.add((ExperimentResource)resource);
+ }
+ return experiments;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailExperimentCatResource.java
deleted file mode 100644
index 1350f71..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailExperimentCatResource.java
+++ /dev/null
@@ -1,376 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.core.experiment.catalog.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 JobDetailExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(JobDetailExperimentCatResource.class);
- private String jobId;
- private String taskId;
- private String jobDescription;
- private Timestamp creationTime;
- private String computeResourceConsumed;
- private String jobName;
- private String workingDir;
- private StatusExperimentCatResource jobStatus;
- private List<ErrorDetailExperimentCatResource> errors;
-
- public void setJobStatus(StatusExperimentCatResource jobStatus) {
- this.jobStatus = jobStatus;
- }
-
- public List<ErrorDetailExperimentCatResource> getErrors() {
- return errors;
- }
-
- public void setErrors(List<ErrorDetailExperimentCatResource> errors) {
- this.errors = errors;
- }
-
- public String getJobName() {
- return jobName;
- }
-
- public void setJobName(String jobName) {
- this.jobName = jobName;
- }
-
- public String getWorkingDir() {
- return workingDir;
- }
-
- public void setWorkingDir(String workingDir) {
- this.workingDir = workingDir;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getJobDescription() {
- return jobDescription;
- }
-
- public void setJobDescription(String jobDescription) {
- this.jobDescription = jobDescription;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- public String getComputeResourceConsumed() {
- return computeResourceConsumed;
- }
-
- public void setComputeResourceConsumed(String computeResourceConsumed) {
- this.computeResourceConsumed = computeResourceConsumed;
- }
-
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- switch (type){
- case STATUS:
- StatusExperimentCatResource statusResource = new StatusExperimentCatResource();
- statusResource.setJobId(jobId);
- return statusResource;
- case ERROR_DETAIL:
- ErrorDetailExperimentCatResource errorDetailResource = new ErrorDetailExperimentCatResource();
- errorDetailResource.setJobId(jobId);
- return errorDetailResource;
- default:
- logger.error("Unsupported resource type for job details data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- switch (type) {
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.JOB_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.toString());
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(ErrorDetailConstants.JOB_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- default:
- logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
- break;
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator;
- Query q;
- switch (type) {
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.JOB_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.toString());
- q = generator.selectQuery(em);
- Status status = (Status) q.getSingleResult();
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) Utils.getResource(ResourceType.STATUS, status);
- em.getTransaction().commit();
- em.close();
- return statusResource;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.JOB_ID, name);
- q = generator.selectQuery(em);
- ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
- ErrorDetailExperimentCatResource errorDetailResource = (ErrorDetailExperimentCatResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- em.getTransaction().commit();
- em.close();
- return errorDetailResource;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for job details resource.");
- }
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- List results;
- switch (type) {
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.JOB_ID, jobId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Status status = (Status) result;
- StatusExperimentCatResource statusResource =
- (StatusExperimentCatResource) Utils.getResource(ResourceType.STATUS, status);
- resourceList.add(statusResource);
- }
- }
- break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.JOB_ID, jobId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ErrorDetail errorDetail = (ErrorDetail) result;
- ErrorDetailExperimentCatResource errorDetailResource =
- (ErrorDetailExperimentCatResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- resourceList.add(errorDetailResource);
- }
- }
- break;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- JobDetail existingJobDetail = em.find(JobDetail.class, new JobDetails_PK(jobId, taskId));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- JobDetail jobDetail = new JobDetail();
- jobDetail.setJobId(jobId);
- jobDetail.setTaskId(taskId);
- jobDetail.setCreationTime(creationTime);
- jobDetail.setJobName(jobName);
- jobDetail.setWorkingDir(workingDir);
- if (jobDescription != null) {
- jobDetail.setJobDescription(jobDescription.toCharArray());
- }
- jobDetail.setComputeResourceConsumed(computeResourceConsumed);
- if (existingJobDetail != null) {
- existingJobDetail.setJobId(jobId);
- existingJobDetail.setTaskId(taskId);
- existingJobDetail.setCreationTime(creationTime);
- if (jobDescription != null) {
- existingJobDetail.setJobDescription(jobDescription.toCharArray());
- }
- existingJobDetail.setComputeResourceConsumed(computeResourceConsumed);
- existingJobDetail.setJobName(jobName);
- existingJobDetail.setWorkingDir(workingDir);
- jobDetail = em.merge(existingJobDetail);
- } else {
- em.persist(jobDetail);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public StatusExperimentCatResource getJobStatus() {
- return jobStatus;
- }
-
- public StatusExperimentCatResource getJobStatus1() throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusExperimentCatResource jobStatus = (StatusExperimentCatResource) resource;
- if(jobStatus.getStatusType().equals(StatusType.JOB.toString())){
- if (jobStatus.getState() == null || jobStatus.getState().equals("") ){
- jobStatus.setState("UNKNOWN");
- }
- return jobStatus;
- }
- }
- return null;
- }
-
- public StatusExperimentCatResource getApplicationStatus() throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusExperimentCatResource appStatus = (StatusExperimentCatResource) resource;
- if(appStatus.getStatusType().equals(StatusType.APPLICATION.toString())){
- if (appStatus.getState() == null || appStatus.getState().equals("") ){
- appStatus.setState("UNKNOWN");
- }
- return appStatus;
- }
- }
- return null;
- }
-
- public List<ErrorDetailExperimentCatResource> getErrorDetails () throws RegistryException{
- List<ErrorDetailExperimentCatResource> errorDetailResources = new ArrayList<ErrorDetailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
- for(ExperimentCatResource resource : resources){
- errorDetailResources.add((ErrorDetailExperimentCatResource)resource);
- }
- return errorDetailResources;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailResource.java
new file mode 100644
index 0000000..0dffd8e
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobDetailResource.java
@@ -0,0 +1,376 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.utils.StatusType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JobDetailResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(JobDetailResource.class);
+ private String jobId;
+ private String taskId;
+ private String jobDescription;
+ private Timestamp creationTime;
+ private String computeResourceConsumed;
+ private String jobName;
+ private String workingDir;
+ private StatusResource jobStatus;
+ private List<ErrorDetailResource> errors;
+
+ public void setJobStatus(StatusResource jobStatus) {
+ this.jobStatus = jobStatus;
+ }
+
+ public List<ErrorDetailResource> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(List<ErrorDetailResource> errors) {
+ this.errors = errors;
+ }
+
+ public String getJobName() {
+ return jobName;
+ }
+
+ public void setJobName(String jobName) {
+ this.jobName = jobName;
+ }
+
+ public String getWorkingDir() {
+ return workingDir;
+ }
+
+ public void setWorkingDir(String workingDir) {
+ this.workingDir = workingDir;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getJobDescription() {
+ return jobDescription;
+ }
+
+ public void setJobDescription(String jobDescription) {
+ this.jobDescription = jobDescription;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public String getComputeResourceConsumed() {
+ return computeResourceConsumed;
+ }
+
+ public void setComputeResourceConsumed(String computeResourceConsumed) {
+ this.computeResourceConsumed = computeResourceConsumed;
+ }
+
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ switch (type){
+ case STATUS:
+ StatusResource statusResource = new StatusResource();
+ statusResource.setJobId(jobId);
+ return statusResource;
+ case ERROR_DETAIL:
+ ErrorDetailResource errorDetailResource = new ErrorDetailResource();
+ errorDetailResource.setJobId(jobId);
+ return errorDetailResource;
+ default:
+ logger.error("Unsupported resource type for job details data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ switch (type) {
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.JOB_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.toString());
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(ErrorDetailConstants.JOB_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ default:
+ logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
+ break;
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator;
+ Query q;
+ switch (type) {
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.JOB_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.JOB.toString());
+ q = generator.selectQuery(em);
+ Status status = (Status) q.getSingleResult();
+ StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+ em.getTransaction().commit();
+ em.close();
+ return statusResource;
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.JOB_ID, name);
+ q = generator.selectQuery(em);
+ ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
+ ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+ em.getTransaction().commit();
+ em.close();
+ return errorDetailResource;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported resource type for job details resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for job details resource.");
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ List results;
+ switch (type) {
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.JOB_ID, jobId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Status status = (Status) result;
+ StatusResource statusResource =
+ (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+ resourceList.add(statusResource);
+ }
+ }
+ break;
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.JOB_ID, jobId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ErrorDetail errorDetail = (ErrorDetail) result;
+ ErrorDetailResource errorDetailResource =
+ (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+ resourceList.add(errorDetailResource);
+ }
+ }
+ break;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ JobDetail existingJobDetail = em.find(JobDetail.class, new JobDetails_PK(jobId, taskId));
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ JobDetail jobDetail = new JobDetail();
+ jobDetail.setJobId(jobId);
+ jobDetail.setTaskId(taskId);
+ jobDetail.setCreationTime(creationTime);
+ jobDetail.setJobName(jobName);
+ jobDetail.setWorkingDir(workingDir);
+ if (jobDescription != null) {
+ jobDetail.setJobDescription(jobDescription.toCharArray());
+ }
+ jobDetail.setComputeResourceConsumed(computeResourceConsumed);
+ if (existingJobDetail != null) {
+ existingJobDetail.setJobId(jobId);
+ existingJobDetail.setTaskId(taskId);
+ existingJobDetail.setCreationTime(creationTime);
+ if (jobDescription != null) {
+ existingJobDetail.setJobDescription(jobDescription.toCharArray());
+ }
+ existingJobDetail.setComputeResourceConsumed(computeResourceConsumed);
+ existingJobDetail.setJobName(jobName);
+ existingJobDetail.setWorkingDir(workingDir);
+ jobDetail = em.merge(existingJobDetail);
+ } else {
+ em.persist(jobDetail);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public StatusResource getJobStatus() {
+ return jobStatus;
+ }
+
+ public StatusResource getJobStatus1() throws RegistryException{
+ List<ExperimentCatResource> resources = get(ResourceType.STATUS);
+ for (ExperimentCatResource resource : resources) {
+ StatusResource jobStatus = (StatusResource) resource;
+ if(jobStatus.getStatusType().equals(StatusType.JOB.toString())){
+ if (jobStatus.getState() == null || jobStatus.getState().equals("") ){
+ jobStatus.setState("UNKNOWN");
+ }
+ return jobStatus;
+ }
+ }
+ return null;
+ }
+
+ public StatusResource getApplicationStatus() throws RegistryException{
+ List<ExperimentCatResource> resources = get(ResourceType.STATUS);
+ for (ExperimentCatResource resource : resources) {
+ StatusResource appStatus = (StatusResource) resource;
+ if(appStatus.getStatusType().equals(StatusType.APPLICATION.toString())){
+ if (appStatus.getState() == null || appStatus.getState().equals("") ){
+ appStatus.setState("UNKNOWN");
+ }
+ return appStatus;
+ }
+ }
+ return null;
+ }
+
+ public List<ErrorDetailResource> getErrorDetails () throws RegistryException{
+ List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
+ for(ExperimentCatResource resource : resources){
+ errorDetailResources.add((ErrorDetailResource)resource);
+ }
+ return errorDetailResources;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeInputExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeInputExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeInputExperimentCatResource.java
deleted file mode 100644
index 0c7239a..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeInputExperimentCatResource.java
+++ /dev/null
@@ -1,227 +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.registry.core.experiment.catalog.resources;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.NodeInput;
-import org.apache.airavata.registry.core.experiment.catalog.model.NodeInput_PK;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NodeInputExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(NodeInputExperimentCatResource.class);
-
- private String nodeId;
- private String inputKey;
- private String dataType;
- private String metadata;
- private String value;
- private String appArgument;
- private boolean standardInput;
- private String userFriendlyDesc;
- private int inputOrder;
- private boolean isRequired;
- private boolean requiredToCMD;
- private boolean dataStaged;
-
- public boolean getRequired() {
- return isRequired;
- }
-
- public void setRequired(boolean required) {
- this.isRequired = required;
- }
-
- public boolean getRequiredToCMD() {
- return requiredToCMD;
- }
-
- public void setRequiredToCMD(boolean requiredToCMD) {
- this.requiredToCMD = requiredToCMD;
- }
-
- public boolean isDataStaged() {
- return dataStaged;
- }
-
- public void setDataStaged(boolean dataStaged) {
- this.dataStaged = dataStaged;
- }
-
- public String getAppArgument() {
- return appArgument;
- }
-
- public void setAppArgument(String appArgument) {
- this.appArgument = appArgument;
- }
-
- public boolean isStandardInput() {
- return standardInput;
- }
-
- public void setStandardInput(boolean standardInput) {
- this.standardInput = standardInput;
- }
-
- public String getUserFriendlyDesc() {
- return userFriendlyDesc;
- }
-
- public void setUserFriendlyDesc(String userFriendlyDesc) {
- this.userFriendlyDesc = userFriendlyDesc;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-
- public String getInputKey() {
- return inputKey;
- }
-
- public void setInputKey(String inputKey) {
- this.inputKey = inputKey;
- }
-
- public String getDataType() {
- return dataType;
- }
-
- public void setDataType(String dataType) {
- this.dataType = dataType;
- }
-
- public String getMetadata() {
- return metadata;
- }
-
- public void setMetadata(String metadata) {
- this.metadata = metadata;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public int getInputOrder() {
- return inputOrder;
- }
-
- public void setInputOrder(int inputOrder) {
- this.inputOrder = inputOrder;
- }
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- NodeInput existingInput = em.find(NodeInput.class, new NodeInput_PK(inputKey, nodeId));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- NodeInput nodeInput = new NodeInput();
- nodeInput.setNodeId(nodeId);
- nodeInput.setInputKey(inputKey);
- nodeInput.setDataType(dataType);
- nodeInput.setValue(value);
- nodeInput.setMetadata(metadata);
- nodeInput.setAppArgument(appArgument);
- nodeInput.setStandardInput(standardInput);
- nodeInput.setUserFriendlyDesc(userFriendlyDesc);
- nodeInput.setInputOrder(inputOrder);
- nodeInput.setRequiredToCMD(requiredToCMD);
- nodeInput.setIsRequired(isRequired);
- nodeInput.setDataStaged(dataStaged);
-
- if (existingInput != null){
- existingInput.setNodeId(nodeId);
- existingInput.setInputKey(inputKey);
- existingInput.setDataType(dataType);
- existingInput.setValue(value);
- existingInput.setMetadata(metadata);
- existingInput.setAppArgument(appArgument);
- existingInput.setStandardInput(standardInput);
- existingInput.setUserFriendlyDesc(userFriendlyDesc);
- existingInput.setInputOrder(inputOrder);
- existingInput.setRequiredToCMD(requiredToCMD);
- existingInput.setIsRequired(isRequired);
- existingInput.setDataStaged(dataStaged);
- nodeInput = em.merge(existingInput);
- }else {
- em.persist(nodeInput);
- }
- em.getTransaction().commit();
- em.close();
- }catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- }finally {
- if (em != null && em.isOpen()){
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeInputResource.java
new file mode 100644
index 0000000..5820b17
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeInputResource.java
@@ -0,0 +1,227 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.NodeInput;
+import org.apache.airavata.registry.core.experiment.catalog.model.NodeInput_PK;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NodeInputResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(NodeInputResource.class);
+
+ private String nodeId;
+ private String inputKey;
+ private String dataType;
+ private String metadata;
+ private String value;
+ private String appArgument;
+ private boolean standardInput;
+ private String userFriendlyDesc;
+ private int inputOrder;
+ private boolean isRequired;
+ private boolean requiredToCMD;
+ private boolean dataStaged;
+
+ public boolean getRequired() {
+ return isRequired;
+ }
+
+ public void setRequired(boolean required) {
+ this.isRequired = required;
+ }
+
+ public boolean getRequiredToCMD() {
+ return requiredToCMD;
+ }
+
+ public void setRequiredToCMD(boolean requiredToCMD) {
+ this.requiredToCMD = requiredToCMD;
+ }
+
+ public boolean isDataStaged() {
+ return dataStaged;
+ }
+
+ public void setDataStaged(boolean dataStaged) {
+ this.dataStaged = dataStaged;
+ }
+
+ public String getAppArgument() {
+ return appArgument;
+ }
+
+ public void setAppArgument(String appArgument) {
+ this.appArgument = appArgument;
+ }
+
+ public boolean isStandardInput() {
+ return standardInput;
+ }
+
+ public void setStandardInput(boolean standardInput) {
+ this.standardInput = standardInput;
+ }
+
+ public String getUserFriendlyDesc() {
+ return userFriendlyDesc;
+ }
+
+ public void setUserFriendlyDesc(String userFriendlyDesc) {
+ this.userFriendlyDesc = userFriendlyDesc;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public String getInputKey() {
+ return inputKey;
+ }
+
+ public void setInputKey(String inputKey) {
+ this.inputKey = inputKey;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public String getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(String metadata) {
+ this.metadata = metadata;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public int getInputOrder() {
+ return inputOrder;
+ }
+
+ public void setInputOrder(int inputOrder) {
+ this.inputOrder = inputOrder;
+ }
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for node input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ NodeInput existingInput = em.find(NodeInput.class, new NodeInput_PK(inputKey, nodeId));
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ NodeInput nodeInput = new NodeInput();
+ nodeInput.setNodeId(nodeId);
+ nodeInput.setInputKey(inputKey);
+ nodeInput.setDataType(dataType);
+ nodeInput.setValue(value);
+ nodeInput.setMetadata(metadata);
+ nodeInput.setAppArgument(appArgument);
+ nodeInput.setStandardInput(standardInput);
+ nodeInput.setUserFriendlyDesc(userFriendlyDesc);
+ nodeInput.setInputOrder(inputOrder);
+ nodeInput.setRequiredToCMD(requiredToCMD);
+ nodeInput.setIsRequired(isRequired);
+ nodeInput.setDataStaged(dataStaged);
+
+ if (existingInput != null){
+ existingInput.setNodeId(nodeId);
+ existingInput.setInputKey(inputKey);
+ existingInput.setDataType(dataType);
+ existingInput.setValue(value);
+ existingInput.setMetadata(metadata);
+ existingInput.setAppArgument(appArgument);
+ existingInput.setStandardInput(standardInput);
+ existingInput.setUserFriendlyDesc(userFriendlyDesc);
+ existingInput.setInputOrder(inputOrder);
+ existingInput.setRequiredToCMD(requiredToCMD);
+ existingInput.setIsRequired(isRequired);
+ existingInput.setDataStaged(dataStaged);
+ nodeInput = em.merge(existingInput);
+ }else {
+ em.persist(nodeInput);
+ }
+ em.getTransaction().commit();
+ em.close();
+ }catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ }finally {
+ if (em != null && em.isOpen()){
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeOutputExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeOutputExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeOutputExperimentCatResource.java
deleted file mode 100644
index defd2b9..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeOutputExperimentCatResource.java
+++ /dev/null
@@ -1,207 +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.registry.core.experiment.catalog.resources;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.NodeOutput;
-import org.apache.airavata.registry.core.experiment.catalog.model.NodeOutput_PK;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NodeOutputExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(NodeOutputExperimentCatResource.class);
-
- private String nodeId;
- private String outputKey;
- private String dataType;
- private String value;
- private boolean isRequired;
- private boolean dataMovement;
- private String dataNameLocation;
- private boolean requiredToCMD;
- private String searchQuery;
- private String appArgument;
-
- public String getSearchQuery() {
- return searchQuery;
- }
-
- public void setSearchQuery(String searchQuery) {
- this.searchQuery = searchQuery;
- }
-
- public String getAppArgument() {
- return appArgument;
- }
-
- public void setAppArgument(String appArgument) {
- this.appArgument = appArgument;
- }
-
-
- public boolean getRequiredToCMD() {
- return requiredToCMD;
- }
-
- public void setRequiredToCMD(boolean requiredToCMD) {
- this.requiredToCMD = requiredToCMD;
- }
-
- public boolean getRequired() {
- return isRequired;
- }
-
- public void setRequired(boolean required) {
- this.isRequired = required;
- }
-
- public boolean isDataMovement() {
- return dataMovement;
- }
-
- public void setDataMovement(boolean dataMovement) {
- this.dataMovement = dataMovement;
- }
-
- public String getDataNameLocation() {
- return dataNameLocation;
- }
-
- public void setDataNameLocation(String dataNameLocation) {
- this.dataNameLocation = dataNameLocation;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-
- 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 ExperimentCatResource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- NodeOutput existingOutput = em.find(NodeOutput.class, new NodeOutput_PK(outputKey, nodeId));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- NodeOutput nodeOutput = new NodeOutput();
- nodeOutput.setNodeId(nodeId);
- nodeOutput.setOutputKey(outputKey);
- nodeOutput.setDataType(dataType);
- nodeOutput.setValue(value);
- nodeOutput.setRequired(isRequired);
- nodeOutput.setRequiredToCMD(requiredToCMD);
- nodeOutput.setDataMovement(dataMovement);
- nodeOutput.setDataNameLocation(dataNameLocation);
- nodeOutput.setApplicationArgument(appArgument);
- nodeOutput.setSearchQuery(searchQuery);
-
- if (existingOutput != null) {
- existingOutput.setNodeId(nodeId);
- existingOutput.setOutputKey(outputKey);
- existingOutput.setDataType(dataType);
- existingOutput.setValue(value);
- existingOutput.setRequired(isRequired);
- existingOutput.setRequiredToCMD(requiredToCMD);
- existingOutput.setDataMovement(dataMovement);
- existingOutput.setDataNameLocation(dataNameLocation);
- existingOutput.setApplicationArgument(appArgument);
- existingOutput.setSearchQuery(searchQuery);
- nodeOutput = em.merge(existingOutput);
- } else {
- em.persist(nodeOutput);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeOutputResource.java
new file mode 100644
index 0000000..0c0cd63
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NodeOutputResource.java
@@ -0,0 +1,207 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.NodeOutput;
+import org.apache.airavata.registry.core.experiment.catalog.model.NodeOutput_PK;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NodeOutputResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(NodeOutputResource.class);
+
+ private String nodeId;
+ private String outputKey;
+ private String dataType;
+ private String value;
+ private boolean isRequired;
+ private boolean dataMovement;
+ private String dataNameLocation;
+ private boolean requiredToCMD;
+ private String searchQuery;
+ private String appArgument;
+
+ public String getSearchQuery() {
+ return searchQuery;
+ }
+
+ public void setSearchQuery(String searchQuery) {
+ this.searchQuery = searchQuery;
+ }
+
+ public String getAppArgument() {
+ return appArgument;
+ }
+
+ public void setAppArgument(String appArgument) {
+ this.appArgument = appArgument;
+ }
+
+
+ public boolean getRequiredToCMD() {
+ return requiredToCMD;
+ }
+
+ public void setRequiredToCMD(boolean requiredToCMD) {
+ this.requiredToCMD = requiredToCMD;
+ }
+
+ public boolean getRequired() {
+ return isRequired;
+ }
+
+ public void setRequired(boolean required) {
+ this.isRequired = required;
+ }
+
+ public boolean isDataMovement() {
+ return dataMovement;
+ }
+
+ public void setDataMovement(boolean dataMovement) {
+ this.dataMovement = dataMovement;
+ }
+
+ public String getDataNameLocation() {
+ return dataNameLocation;
+ }
+
+ public void setDataNameLocation(String dataNameLocation) {
+ this.dataNameLocation = dataNameLocation;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ 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 ExperimentCatResource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for node output data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ NodeOutput existingOutput = em.find(NodeOutput.class, new NodeOutput_PK(outputKey, nodeId));
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ NodeOutput nodeOutput = new NodeOutput();
+ nodeOutput.setNodeId(nodeId);
+ nodeOutput.setOutputKey(outputKey);
+ nodeOutput.setDataType(dataType);
+ nodeOutput.setValue(value);
+ nodeOutput.setRequired(isRequired);
+ nodeOutput.setRequiredToCMD(requiredToCMD);
+ nodeOutput.setDataMovement(dataMovement);
+ nodeOutput.setDataNameLocation(dataNameLocation);
+ nodeOutput.setApplicationArgument(appArgument);
+ nodeOutput.setSearchQuery(searchQuery);
+
+ if (existingOutput != null) {
+ existingOutput.setNodeId(nodeId);
+ existingOutput.setOutputKey(outputKey);
+ existingOutput.setDataType(dataType);
+ existingOutput.setValue(value);
+ existingOutput.setRequired(isRequired);
+ existingOutput.setRequiredToCMD(requiredToCMD);
+ existingOutput.setDataMovement(dataMovement);
+ existingOutput.setDataNameLocation(dataNameLocation);
+ existingOutput.setApplicationArgument(appArgument);
+ existingOutput.setSearchQuery(searchQuery);
+ nodeOutput = em.merge(existingOutput);
+ } else {
+ em.persist(nodeOutput);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NotificationEmailExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NotificationEmailExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NotificationEmailExperimentCatResource.java
deleted file mode 100644
index 833a1eb..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NotificationEmailExperimentCatResource.java
+++ /dev/null
@@ -1,119 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-
-public class NotificationEmailExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(NotificationEmailExperimentCatResource.class);
-
- private int emailId = 0;
- private String experimentId;
- private String taskId;
- private String emailAddress;
-
-
- public String getEmailAddress() {
- return emailAddress;
- }
-
- public void setEmailAddress(String emailAddress) {
- this.emailAddress = emailAddress;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Notification_Email notification_email;
- if (emailId != 0 ){
- notification_email = em.find(Notification_Email.class, emailId);
- notification_email.setEmailId(emailId);
- }else {
- notification_email = new Notification_Email();
- }
- notification_email.setExperiment_id(experimentId);
- notification_email.setTaskId(taskId);
- notification_email.setEmailAddress(emailAddress);
- em.persist(notification_email);
- emailId = notification_email.getEmailId();
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
[30/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
registry refactoring changes
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/4045c094
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/4045c094
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/4045c094
Branch: refs/heads/master
Commit: 4045c09473e11758e79aa2f02392181868017d94
Parents: 093643a
Author: Chathuri Wimalasena <ch...@apache.org>
Authored: Fri Jun 5 12:25:40 2015 -0400
Committer: Chathuri Wimalasena <ch...@apache.org>
Committed: Fri Jun 5 12:25:40 2015 -0400
----------------------------------------------------------------------
airavata-api/airavata-api-server/pom.xml | 2 +-
.../server/handler/AiravataServerHandler.java | 22 +-
.../api/server/util/DatabaseCreator.java | 4 +-
.../api/server/util/RegistryInitUtil.java | 14 +-
modules/gfac/gfac-core/pom.xml | 2 +-
modules/gfac/gfac-service/pom.xml | 2 +-
.../airavata/gfac/client/util/Initialize.java | 2 +-
.../src/test/resources/expcatalog-derby.sql | 391 +++++++++
.../src/test/resources/registry-derby.sql | 361 --------
modules/integration-tests/pom.xml | 2 +-
modules/orchestrator/orchestrator-core/pom.xml | 2 +-
.../orchestrator/core/util/Initialize.java | 6 +-
.../src/test/resources/expcatalog-derby.sql | 391 +++++++++
.../src/test/resources/registry-derby.sql | 361 --------
.../orchestrator/client/util/Initialize.java | 2 +-
.../src/test/resources/expcatalog-derby.sql | 391 +++++++++
...ies~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa | 26 -
.../src/test/resources/gsissh.properties~HEAD | 26 -
...ies~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa | 30 -
.../src/test/resources/monitor.properties~HEAD | 30 -
.../src/test/resources/registry-derby.sql | 361 --------
...sql~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa | 361 --------
.../src/test/resources/registry-derby.sql~HEAD | 361 --------
modules/registry/registry-core/pom.xml | 50 +-
.../catalog/impl/ApplicationDeploymentImpl.java | 72 +-
.../catalog/impl/ApplicationInterfaceImpl.java | 74 +-
.../app/catalog/impl/ComputeResourceImpl.java | 138 +--
.../catalog/impl/GwyResourceProfileImpl.java | 44 +-
.../app/catalog/impl/WorkflowCatalogImpl.java | 40 +-
.../AppDeploymentAppCatalogResourceAppCat.java | 446 ----------
.../resources/AppDeploymentResource.java | 446 ++++++++++
.../AppEnvironmentAppCatalogResourceAppCat.java | 293 -------
.../resources/AppEnvironmentResource.java | 293 +++++++
.../AppInterfaceAppCatalogResourceAppCat.java | 363 --------
.../catalog/resources/AppInterfaceResource.java | 363 ++++++++
.../AppModuleAppCatalogResourceAppCat.java | 344 --------
...ppModuleMappingAppCatalogResourceAppCat.java | 12 +-
.../catalog/resources/AppModuleResource.java | 344 ++++++++
...pplicationInputAppCatalogResourceAppCat.java | 454 ----------
.../resources/ApplicationInputResource.java | 454 ++++++++++
...plicationOutputAppCatalogResourceAppCat.java | 433 ----------
.../resources/ApplicationOutputResource.java | 433 ++++++++++
.../BatchQueueAppCatalogResourceAppCat.java | 357 --------
.../catalog/resources/BatchQueueResource.java | 357 ++++++++
...CloudSubmissionAppCatalogResourceAppCat.java | 298 -------
.../resources/CloudSubmissionResource.java | 298 +++++++
...eHostPreferenceAppCatalogResourceAppCat.java | 413 ---------
.../ComputeHostPreferenceResource.java | 413 +++++++++
...ComputeResourceAppCatalogResourceAppCat.java | 351 --------
...ourceFileSystemAppCatalogResourceAppCat.java | 307 -------
.../ComputeResourceFileSystemResource.java | 307 +++++++
.../resources/ComputeResourceResource.java | 351 ++++++++
...vementInterfaceAppCatalogResourceAppCat.java | 339 --------
.../DataMovementInterfaceResource.java | 339 ++++++++
.../GSISSHExportAppCatalogResourceAppCat.java | 324 --------
.../catalog/resources/GSISSHExportResource.java | 324 ++++++++
...SISSHSubmissionAppCatalogResourceAppCat.java | 373 ---------
.../resources/GSISSHSubmissionResource.java | 373 +++++++++
.../GatewayProfileAppCatalogResourceAppCat.java | 318 -------
.../resources/GatewayProfileResource.java | 318 +++++++
...lobusGKEndpointAppCatalogResourceAppCat.java | 323 -------
.../resources/GlobusGKEndpointResource.java | 323 +++++++
...usJobSubmissionAppCatalogResourceAppCat.java | 315 -------
.../resources/GlobusJobSubmissionResource.java | 315 +++++++
...ftpDataMovementAppCatalogResourceAppCat.java | 279 -------
.../resources/GridftpDataMovementResource.java | 279 +++++++
...GridftpEndpointAppCatalogResourceAppCat.java | 317 -------
.../resources/GridftpEndpointResource.java | 317 +++++++
.../HostAliasAppCatalogResourceAppCat.java | 317 -------
.../catalog/resources/HostAliasAppResource.java | 317 +++++++
.../HostIPAddressAppCatalogResourceAppCat.java | 318 -------
.../resources/HostIPAddressResource.java | 318 +++++++
...bManagerCommandAppCatalogResourceAppCat.java | 307 -------
.../resources/JobManagerCommandResource.java | 307 +++++++
...issionInterfaceAppCatalogResourceAppCat.java | 339 --------
.../JobSubmissionInterfaceResource.java | 339 ++++++++
...ibraryApendPathAppCatalogResourceAppCat.java | 292 -------
.../resources/LibraryApendPathResource.java | 292 +++++++
...raryPrepandPathAppCatalogResourceAppCat.java | 291 -------
.../resources/LibraryPrepandPathResource.java | 291 +++++++
...calDataMovementAppCatalogResourceAppCat.java | 249 ------
.../resources/LocalDataMovementResource.java | 249 ++++++
...LocalSubmissionAppCatalogResourceAppCat.java | 293 -------
.../resources/LocalSubmissionResource.java | 293 +++++++
.../ModuleLoadCmdAppCatalogResourceAppCat.java | 300 -------
.../resources/ModuleLoadCmdResource.java | 300 +++++++
.../PostJobCommandAppCatalogResourceAppCat.java | 333 --------
.../resources/PostJobCommandResource.java | 333 ++++++++
.../PreJobCommandAppCatalogResourceAppCat.java | 333 --------
.../resources/PreJobCommandResource.java | 333 ++++++++
...ourceJobManagerAppCatalogResourceAppCat.java | 301 -------
.../resources/ResourceJobManagerResource.java | 301 +++++++
...ScpDataMovementAppCatalogResourceAppCat.java | 308 -------
.../resources/ScpDataMovementResource.java | 308 +++++++
...shJobSubmissionAppCatalogResourceAppCat.java | 332 --------
.../resources/SshJobSubmissionResource.java | 332 ++++++++
...oreDataMovementAppCatalogResourceAppCat.java | 255 ------
.../resources/UnicoreDataMovementResource.java | 255 ++++++
...reJobSubmissionAppCatalogResourceAppCat.java | 328 --------
.../resources/UnicoreJobSubmissionResource.java | 328 ++++++++
.../WorkflowAppCatalogResourceAppCat.java | 382 ---------
.../WorkflowInputAppCatalogResourceAppCat.java | 451 ----------
.../resources/WorkflowInputResource.java | 451 ++++++++++
.../WorkflowOutputAppCatalogResourceAppCat.java | 410 ---------
.../resources/WorkflowOutputResource.java | 410 +++++++++
.../app/catalog/resources/WorkflowResource.java | 382 +++++++++
.../app/catalog/util/AppCatalogJPAUtils.java | 128 +--
.../util/AppCatalogThriftConversion.java | 192 ++---
.../experiment/catalog/ExpCatResourceUtils.java | 89 +-
.../catalog/impl/ExperimentCatalogImpl.java | 20 +-
.../catalog/impl/ExperimentRegistry.java | 806 +++++++++---------
.../catalog/impl/GatewayRegistry.java | 16 +-
.../catalog/impl/ProjectRegistry.java | 52 +-
.../catalog/impl/RegistryFactory.java | 2 +
.../core/experiment/catalog/impl/UserReg.java | 10 +-
.../resources/AbstractExpCatResource.java | 317 +++++++
.../AbstractExperimentCatResource.java | 317 -------
...eInputDataHandlingExperimentCatResource.java | 160 ----
.../AdvanceInputDataHandlingResource.java | 160 ++++
...OutputDataHandlingExperimentCatResource.java | 150 ----
.../AdvancedOutputDataHandlingResource.java | 150 ++++
.../ApplicationInputExperimentCatResource.java | 230 -----
.../resources/ApplicationInputResource.java | 230 +++++
.../ApplicationOutputExperimentCatResource.java | 208 -----
.../resources/ApplicationOutputResource.java | 208 +++++
...putationSchedulingExperimentCatResource.java | 221 -----
.../ComputationSchedulingResource.java | 221 +++++
.../ConfigDataExperimentCatResource.java | 194 -----
.../catalog/resources/ConfigDataResource.java | 194 +++++
.../ConfigurationExperimentCatResource.java | 204 -----
.../resources/ConfigurationResource.java | 204 +++++
...DataTransferDetailExperimentCatResource.java | 276 ------
.../resources/DataTransferDetailResource.java | 276 ++++++
.../ErrorDetailExperimentCatResource.java | 215 -----
.../catalog/resources/ErrorDetailResource.java | 215 +++++
.../ExperimentExperimentCatResource.java | 831 -------------------
.../ExperimentInputExperimentCatResource.java | 225 -----
.../resources/ExperimentInputResource.java | 225 +++++
.../ExperimentOutputExperimentCatResource.java | 204 -----
.../resources/ExperimentOutputResource.java | 204 +++++
.../catalog/resources/ExperimentResource.java | 831 +++++++++++++++++++
.../ExperimentSummaryExperimentCatResource.java | 134 ---
.../resources/ExperimentSummaryResource.java | 134 +++
.../resources/GatewayExperimentCatResource.java | 437 ----------
.../catalog/resources/GatewayResource.java | 437 ++++++++++
.../JobDetailExperimentCatResource.java | 376 ---------
.../catalog/resources/JobDetailResource.java | 376 +++++++++
.../NodeInputExperimentCatResource.java | 227 -----
.../catalog/resources/NodeInputResource.java | 227 +++++
.../NodeOutputExperimentCatResource.java | 207 -----
.../catalog/resources/NodeOutputResource.java | 207 +++++
.../NotificationEmailExperimentCatResource.java | 119 ---
.../resources/NotificationEmailResource.java | 119 +++
.../resources/ProjectExperimentCatResource.java | 508 ------------
.../catalog/resources/ProjectResource.java | 508 ++++++++++++
.../ProjectUserExperimentCatResource.java | 123 ---
.../catalog/resources/ProjectUserResource.java | 123 +++
.../QosParamExperimentCatResource.java | 144 ----
.../catalog/resources/QosParamResource.java | 144 ++++
.../resources/StatusExperimentCatResource.java | 181 ----
.../catalog/resources/StatusResource.java | 181 ++++
.../TaskDetailExperimentCatResource.java | 748 -----------------
.../catalog/resources/TaskDetailResource.java | 748 +++++++++++++++++
.../resources/UserExperimentCatResource.java | 186 -----
.../catalog/resources/UserResource.java | 186 +++++
.../experiment/catalog/resources/Utils.java | 162 ++--
.../resources/WorkerExperimentCatResource.java | 725 ----------------
.../catalog/resources/WorkerResource.java | 725 ++++++++++++++++
...WorkflowNodeDetailExperimentCatResource.java | 515 ------------
.../resources/WorkflowNodeDetailResource.java | 515 ++++++++++++
.../utils/ThriftDataModelConversion.java | 178 ++--
.../resources/META-INF/experiment-catalog.xml | 65 --
.../src/main/resources/META-INF/persistence.xml | 29 +
.../catalog/AbstractResourceTest.java | 34 +-
.../catalog/ComputationalSchedulingTest.java | 14 +-
.../ConfigurationExperimentCatResourceTest.java | 58 --
.../catalog/ConfigurationResourceTest.java | 58 ++
.../catalog/ExperimentCatalogUseCaseTest.java | 296 -------
.../ExperimentExperimentCatResourceTest.java | 78 --
...xperimentInputExperimentCatResourceTest.java | 77 --
.../catalog/ExperimentInputResourceTest.java | 77 ++
...perimentOutputExperimentCatResourceTest.java | 77 --
.../catalog/ExperimentOutputResourceTest.java | 77 ++
.../catalog/ExperimentResourceTest.java | 78 ++
.../catalog/ExperimentUseCaseTest.java | 296 +++++++
.../GatewayExperimentCatResourceTest.java | 122 ---
.../experiment/catalog/GatewayResourceTest.java | 122 +++
.../TaskDetailExperimentCatResourceTest.java | 94 ---
.../catalog/TaskDetailResourceTest.java | 97 +++
.../catalog/UserExperimentCatResourceTest.java | 55 --
.../experiment/catalog/UserResourceTest.java | 55 ++
...flowNodeDetailExperimentCatResourceTest.java | 86 --
.../catalog/WorkflowNodeDetailResourceTest.java | 88 ++
.../experiment/catalog/util/Initialize.java | 12 +-
modules/workflow-model/workflow-engine/pom.xml | 2 +-
modules/workflow/workflow-core/pom.xml | 2 +-
modules/xbaya-gui/pom.xml | 2 +-
197 files changed, 24120 insertions(+), 24868 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/airavata-api/airavata-api-server/pom.xml
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/pom.xml b/airavata-api/airavata-api-server/pom.xml
index 3f0537a..b30fbeb 100644
--- a/airavata-api/airavata-api-server/pom.xml
+++ b/airavata-api/airavata-api-server/pom.xml
@@ -48,7 +48,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId.airavata.registry.core.experiment.catalog</artifactId>
+ <artifactId>airavata-registry-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index 940210a..49e8a76 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -55,7 +55,7 @@ import org.apache.airavata.model.workspace.experiment.*;
import org.apache.airavata.orchestrator.client.OrchestratorClientFactory;
import org.apache.airavata.orchestrator.cpi.OrchestratorService;
import org.apache.airavata.orchestrator.cpi.OrchestratorService.Client;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
import org.apache.airavata.registry.cpi.*;
import org.apache.airavata.registry.cpi.utils.Constants;
@@ -362,7 +362,7 @@ public class AiravataServerHandler implements Airavata.Iface {
}
List<Project> projects = new ArrayList<Project>();
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -439,7 +439,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -515,7 +515,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -594,7 +594,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -672,7 +672,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -747,7 +747,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -822,7 +822,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -901,7 +901,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -960,7 +960,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
@@ -1112,7 +1112,7 @@ public class AiravataServerHandler implements Airavata.Iface {
throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
}
try {
- if (!ResourceUtils.isUserExist(userName)){
+ if (!ExpCatResourceUtils.isUserExist(userName)){
logger.error("User does not exist in the system. Please provide a valid user..");
AiravataSystemException exception = new AiravataSystemException();
exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java
index 3a62688..722ec96 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/DatabaseCreator.java
@@ -266,10 +266,10 @@ public class DatabaseCreator {
DatabaseType databaseType = DatabaseCreator.getDatabaseType(conn);
if(databaseType.equals(DatabaseType.derby)){
is = Thread.currentThread().getContextClassLoader()
- .getResourceAsStream("registry-core/src/main/resources/registry-derby.sql");
+ .getResourceAsStream("registry-core/src/main/resources/expcatalog-derby.sql");
}else if(databaseType.equals(DatabaseType.derby)){
is = Thread.currentThread().getContextClassLoader()
- .getResourceAsStream("registry-core/src/main/resources/registry-mysql.sql");
+ .getResourceAsStream("registry-core/src/main/resources/expcatalog-mysql.sql");
}
}
reader = new BufferedReader(new InputStreamReader(is));
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java
index 438bc6a..b540f41 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/util/RegistryInitUtil.java
@@ -29,8 +29,8 @@ import java.sql.SQLException;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource;
import org.apache.airavata.registry.core.experiment.catalog.resources.ProjectResource;
import org.apache.airavata.registry.core.experiment.catalog.resources.UserResource;
@@ -85,19 +85,19 @@ public class RegistryInitUtil {
}
try{
GatewayResource gateway;
- if (!ResourceUtils.isGatewayExist(ServerSettings.getDefaultUserGateway())){
- gateway = (GatewayResource)ResourceUtils.createGateway(ServerSettings.getDefaultUserGateway());
+ if (!ExpCatResourceUtils.isGatewayExist(ServerSettings.getDefaultUserGateway())){
+ gateway = (GatewayResource)ExpCatResourceUtils.createGateway(ServerSettings.getDefaultUserGateway());
gateway.save();
}else {
- gateway = (GatewayResource)ResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
+ gateway = (GatewayResource)ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
}
UserResource user;
- if (!ResourceUtils.isUserExist(ServerSettings.getDefaultUser())){
- user = ResourceUtils.createUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword());
+ if (!ExpCatResourceUtils.isUserExist(ServerSettings.getDefaultUser())){
+ user = ExpCatResourceUtils.createUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword());
user.save();
}else {
- user = (UserResource)ResourceUtils.getUser(ServerSettings.getDefaultUser());
+ user = (UserResource)ExpCatResourceUtils.getUser(ServerSettings.getDefaultUser());
}
WorkerResource workerResource;
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/gfac/gfac-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/pom.xml b/modules/gfac/gfac-core/pom.xml
index f1de99c..1004ba9 100644
--- a/modules/gfac/gfac-core/pom.xml
+++ b/modules/gfac/gfac-core/pom.xml
@@ -47,7 +47,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId.airavata.registry.core.experiment.catalog</artifactId>
+ <artifactId>airavata-registry-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/gfac/gfac-service/pom.xml
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-service/pom.xml b/modules/gfac/gfac-service/pom.xml
index f3b794b..f1d4d6c 100644
--- a/modules/gfac/gfac-service/pom.xml
+++ b/modules/gfac/gfac-service/pom.xml
@@ -52,7 +52,7 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId.airavata.registry.core.experiment.catalog</artifactId>
+ <artifactId>airavata-registry-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/gfac/gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java b/modules/gfac/gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java
index 548d4b5..e75bce1 100644
--- a/modules/gfac/gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java
+++ b/modules/gfac/gfac-service/src/test/java/org/apache/airavata/gfac/client/util/Initialize.java
@@ -41,7 +41,7 @@ import java.util.StringTokenizer;
public class Initialize {
private static final Logger logger = LoggerFactory.getLogger(Initialize.class);
public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
- public String scriptName = "registry-derby.sql";
+ public String scriptName = "expcatalog-derby.sql";
private NetworkServerControl server;
private static final String delimiter = ";";
public static final String PERSISTANT_DATA = "Configuration";
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/gfac/gfac-service/src/test/resources/expcatalog-derby.sql
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-service/src/test/resources/expcatalog-derby.sql b/modules/gfac/gfac-service/src/test/resources/expcatalog-derby.sql
new file mode 100644
index 0000000..7ab3755
--- /dev/null
+++ b/modules/gfac/gfac-service/src/test/resources/expcatalog-derby.sql
@@ -0,0 +1,391 @@
+/*
+ *
+ * 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.
+ *
+ */
+CREATE TABLE GATEWAY
+(
+ GATEWAY_ID VARCHAR (255),
+ GATEWAY_NAME VARCHAR(255),
+ DOMAIN VARCHAR(255),
+ EMAIL_ADDRESS VARCHAR(255),
+ PRIMARY KEY (GATEWAY_ID)
+);
+
+CREATE TABLE CONFIGURATION
+(
+ CONFIG_KEY VARCHAR(255),
+ CONFIG_VAL VARCHAR(255),
+ EXPIRE_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ CATEGORY_ID VARCHAR (255),
+ PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
+);
+
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version', '0.15', CURRENT_TIMESTAMP ,'SYSTEM');
+
+CREATE TABLE USERS
+(
+ USER_NAME VARCHAR(255),
+ PASSWORD VARCHAR(255),
+ PRIMARY KEY(USER_NAME)
+);
+
+CREATE TABLE GATEWAY_WORKER
+(
+ GATEWAY_ID VARCHAR(255),
+ USER_NAME VARCHAR(255),
+ PRIMARY KEY (GATEWAY_ID, USER_NAME),
+ FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE,
+ FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
+);
+
+CREATE TABLE PROJECT
+(
+ GATEWAY_ID VARCHAR(255),
+ USER_NAME VARCHAR(255) NOT NULL,
+ PROJECT_ID VARCHAR(255),
+ PROJECT_NAME VARCHAR(255) NOT NULL,
+ DESCRIPTION VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (PROJECT_ID),
+ FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE,
+ FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
+);
+
+CREATE TABLE PROJECT_USER
+(
+ PROJECT_ID VARCHAR(255),
+ USER_NAME VARCHAR(255),
+ PRIMARY KEY (PROJECT_ID,USER_NAME),
+ FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
+);
+
+CREATE TABLE EXPERIMENT
+(
+ EXPERIMENT_ID VARCHAR(255),
+ GATEWAY_ID VARCHAR(255),
+ EXECUTION_USER VARCHAR(255) NOT NULL,
+ PROJECT_ID VARCHAR(255) NOT NULL,
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ EXPERIMENT_NAME VARCHAR(255) NOT NULL,
+ EXPERIMENT_DESCRIPTION VARCHAR(255),
+ APPLICATION_ID VARCHAR(255),
+ APPLICATION_VERSION VARCHAR(255),
+ WORKFLOW_TEMPLATE_ID VARCHAR(255),
+ WORKFLOW_TEMPLATE_VERSION VARCHAR(255),
+ WORKFLOW_EXECUTION_ID VARCHAR(255),
+ ALLOW_NOTIFICATION SMALLINT,
+ GATEWAY_EXECUTION_ID VARCHAR(255),
+ PRIMARY KEY(EXPERIMENT_ID),
+ FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE,
+ FOREIGN KEY (EXECUTION_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE,
+ FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE EXPERIMENT_INPUT
+(
+ EXPERIMENT_ID VARCHAR(255),
+ INPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ METADATA VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ STANDARD_INPUT SMALLINT,
+ USER_FRIENDLY_DESC VARCHAR(255),
+ VALUE CLOB,
+ INPUT_ORDER INTEGER,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_STAGED SMALLINT,
+ PRIMARY KEY(EXPERIMENT_ID,INPUT_KEY),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE EXPERIMENT_OUTPUT
+(
+ EXPERIMENT_ID VARCHAR(255),
+ OUTPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ VALUE CLOB,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_MOVEMENT SMALLINT,
+ DATA_NAME_LOCATION VARCHAR(255),
+ SEARCH_QUERY VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ PRIMARY KEY(EXPERIMENT_ID,OUTPUT_KEY),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
+);
+
+
+CREATE TABLE WORKFLOW_NODE_DETAIL
+(
+ EXPERIMENT_ID VARCHAR(255) NOT NULL,
+ NODE_INSTANCE_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ NODE_NAME VARCHAR(255) NOT NULL,
+ EXECUTION_UNIT VARCHAR(255) NOT NULL,
+ EXECUTION_UNIT_DATA VARCHAR(255),
+ PRIMARY KEY(NODE_INSTANCE_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE TASK_DETAIL
+(
+ TASK_ID VARCHAR(255),
+ NODE_INSTANCE_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ APPLICATION_ID VARCHAR(255),
+ APPLICATION_VERSION VARCHAR(255),
+ APPLICATION_DEPLOYMENT_ID VARCHAR(255),
+ ALLOW_NOTIFICATION SMALLINT,
+ PRIMARY KEY(TASK_ID),
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE NOTIFICATION_EMAIL
+(
+ EMAIL_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ EMAIL_ADDRESS VARCHAR(255),
+ PRIMARY KEY(EMAIL_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE ERROR_DETAIL
+(
+ ERROR_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ NODE_INSTANCE_ID VARCHAR(255),
+ JOB_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ ACTUAL_ERROR_MESSAGE CLOB,
+ USER_FRIEDNLY_ERROR_MSG VARCHAR(255),
+ TRANSIENT_OR_PERSISTENT SMALLINT,
+ ERROR_CATEGORY VARCHAR(255),
+ CORRECTIVE_ACTION VARCHAR(255),
+ ACTIONABLE_GROUP VARCHAR(255),
+ PRIMARY KEY(ERROR_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE APPLICATION_INPUT
+(
+ TASK_ID VARCHAR(255),
+ INPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ METADATA VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ STANDARD_INPUT SMALLINT,
+ USER_FRIENDLY_DESC VARCHAR(255),
+ VALUE CLOB,
+ INPUT_ORDER INTEGER,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_STAGED SMALLINT,
+ PRIMARY KEY(TASK_ID,INPUT_KEY),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE APPLICATION_OUTPUT
+(
+ TASK_ID VARCHAR(255),
+ OUTPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ VALUE CLOB,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_MOVEMENT SMALLINT,
+ DATA_NAME_LOCATION VARCHAR(255),
+ SEARCH_QUERY VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ PRIMARY KEY(TASK_ID,OUTPUT_KEY),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE NODE_INPUT
+(
+ NODE_INSTANCE_ID VARCHAR(255),
+ INPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ METADATA VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ STANDARD_INPUT SMALLINT,
+ USER_FRIENDLY_DESC VARCHAR(255),
+ VALUE VARCHAR(255),
+ INPUT_ORDER INTEGER,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_STAGED SMALLINT,
+ PRIMARY KEY(NODE_INSTANCE_ID,INPUT_KEY),
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE NODE_OUTPUT
+(
+ NODE_INSTANCE_ID VARCHAR(255),
+ OUTPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ VALUE VARCHAR(255),
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_MOVEMENT SMALLINT,
+ DATA_NAME_LOCATION VARCHAR(255),
+ SEARCH_QUERY VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ PRIMARY KEY(NODE_INSTANCE_ID,OUTPUT_KEY),
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE JOB_DETAIL
+(
+ JOB_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ JOB_DESCRIPTION CLOB NOT NULL,
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ COMPUTE_RESOURCE_CONSUMED VARCHAR(255),
+ JOBNAME VARCHAR (255),
+ WORKING_DIR VARCHAR(255),
+ PRIMARY KEY (TASK_ID, JOB_ID),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE DATA_TRANSFER_DETAIL
+(
+ TRANSFER_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ TRANSFER_DESC VARCHAR(255) NOT NULL,
+ PRIMARY KEY(TRANSFER_ID),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE STATUS
+(
+ STATUS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ NODE_INSTANCE_ID VARCHAR(255),
+ TRANSFER_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ JOB_ID VARCHAR(255),
+ STATE VARCHAR(255),
+ STATUS_UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ STATUS_TYPE VARCHAR(255),
+ PRIMARY KEY(STATUS_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TRANSFER_ID) REFERENCES DATA_TRANSFER_DETAIL(TRANSFER_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE CONFIG_DATA
+(
+ EXPERIMENT_ID VARCHAR(255),
+ AIRAVATA_AUTO_SCHEDULE SMALLINT NOT NULL,
+ OVERRIDE_MANUAL_SCHEDULE_PARAMS SMALLINT NOT NULL,
+ SHARE_EXPERIMENT SMALLINT,
+ USER_DN VARCHAR(255),
+ GENERATE_CERT SMALLINT,
+ PRIMARY KEY(EXPERIMENT_ID)
+);
+
+CREATE TABLE COMPUTATIONAL_RESOURCE_SCHEDULING
+(
+ RESOURCE_SCHEDULING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ RESOURCE_HOST_ID VARCHAR(255),
+ CPU_COUNT INTEGER,
+ NODE_COUNT INTEGER,
+ NO_OF_THREADS INTEGER,
+ QUEUE_NAME VARCHAR(255),
+ WALLTIME_LIMIT INTEGER,
+ JOB_START_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ TOTAL_PHYSICAL_MEMORY INTEGER,
+ COMPUTATIONAL_PROJECT_ACCOUNT VARCHAR(255),
+ CHESSIS_NAME VARCHAR(255),
+ PRIMARY KEY(RESOURCE_SCHEDULING_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE ADVANCE_INPUT_DATA_HANDLING
+(
+ INPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ WORKING_DIR_PARENT VARCHAR(255),
+ UNIQUE_WORKING_DIR VARCHAR(255),
+ STAGE_INPUT_FILES_TO_WORKING_DIR SMALLINT,
+ CLEAN_AFTER_JOB SMALLINT,
+ PRIMARY KEY(INPUT_DATA_HANDLING_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE ADVANCE_OUTPUT_DATA_HANDLING
+(
+ OUTPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ OUTPUT_DATA_DIR VARCHAR(255),
+ DATA_REG_URL VARCHAR (255),
+ PERSIST_OUTPUT_DATA SMALLINT,
+ PRIMARY KEY(OUTPUT_DATA_HANDLING_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE QOS_PARAM
+(
+ QOS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ START_EXECUTION_AT VARCHAR(255),
+ EXECUTE_BEFORE VARCHAR(255),
+ NO_OF_RETRIES INTEGER,
+ PRIMARY KEY(QOS_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE COMMUNITY_USER
+(
+ GATEWAY_ID VARCHAR(256) NOT NULL,
+ COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
+ TOKEN_ID VARCHAR(256) NOT NULL,
+ COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
+ PRIMARY KEY (GATEWAY_ID, COMMUNITY_USER_NAME, TOKEN_ID)
+);
+
+CREATE TABLE CREDENTIALS
+(
+ GATEWAY_ID VARCHAR(256) NOT NULL,
+ TOKEN_ID VARCHAR(256) NOT NULL,
+ CREDENTIAL BLOB NOT NULL,
+ PORTAL_USER_ID VARCHAR(256) NOT NULL,
+ TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
+);
+
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/gfac/gfac-service/src/test/resources/registry-derby.sql
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-service/src/test/resources/registry-derby.sql b/modules/gfac/gfac-service/src/test/resources/registry-derby.sql
deleted file mode 100644
index 9ed5ca9..0000000
--- a/modules/gfac/gfac-service/src/test/resources/registry-derby.sql
+++ /dev/null
@@ -1,361 +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.
- *
- */
-CREATE TABLE GATEWAY
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME)
-);
-
-CREATE TABLE CONFIGURATION
-(
- CONFIG_KEY VARCHAR(255),
- CONFIG_VAL VARCHAR(255),
- EXPIRE_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- CATEGORY_ID VARCHAR (255),
- PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
-);
-
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version', '0.12', CURRENT_TIMESTAMP ,'SYSTEM');
-
-CREATE TABLE USERS
-(
- USER_NAME VARCHAR(255),
- PASSWORD VARCHAR(255),
- PRIMARY KEY(USER_NAME)
-);
-
-CREATE TABLE GATEWAY_WORKER
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME, USER_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255),
- PROJECT_NAME VARCHAR(255) NOT NULL,
- DESCRIPTION VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (PROJECT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT_USER
-(
- PROJECT_ID VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (PROJECT_ID,USER_NAME),
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PUBLISHED_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- CREATED_USER VARCHAR(255),
- PUBLISH_WORKFLOW_NAME VARCHAR(255),
- VERSION VARCHAR(255),
- PUBLISHED_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- PATH VARCHAR (255),
- WORKFLOW_CONTENT BLOB,
- PRIMARY KEY(GATEWAY_NAME, PUBLISH_WORKFLOW_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (CREATED_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE USER_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- TEMPLATE_NAME VARCHAR(255),
- LAST_UPDATED_TIME TIMESTAMP DEFAULT CURRENT TIMESTAMP,
- PATH VARCHAR (255),
- WORKFLOW_GRAPH BLOB,
- PRIMARY KEY(GATEWAY_NAME, OWNER, TEMPLATE_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (OWNER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT
-(
- EXPERIMENT_ID VARCHAR(255),
- GATEWAY_NAME VARCHAR(255),
- EXECUTION_USER VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255) NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- EXPERIMENT_NAME VARCHAR(255) NOT NULL,
- EXPERIMENT_DESCRIPTION VARCHAR(255),
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- WORKFLOW_TEMPLATE_ID VARCHAR(255),
- WORKFLOW_TEMPLATE_VERSION VARCHAR(255),
- WORKFLOW_EXECUTION_ID VARCHAR(255),
- PRIMARY KEY(EXPERIMENT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (EXECUTION_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE,
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_INPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,INPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_OUTPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,OUTPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-
-CREATE TABLE WORKFLOW_NODE_DETAIL
-(
- EXPERIMENT_ID VARCHAR(255) NOT NULL,
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- NODE_NAME VARCHAR(255) NOT NULL,
- EXECUTION_UNIT VARCHAR(255) NOT NULL,
- EXECUTION_UNIT_DATA VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE TASK_DETAIL
-(
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- APPLICATION_DEPLOYMENT_ID VARCHAR(255),
- PRIMARY KEY(TASK_ID),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ERROR_DETAIL
-(
- ERROR_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- ACTUAL_ERROR_MESSAGE CLOB,
- USER_FRIEDNLY_ERROR_MSG VARCHAR(255),
- TRANSIENT_OR_PERSISTENT SMALLINT,
- ERROR_CATEGORY VARCHAR(255),
- CORRECTIVE_ACTION VARCHAR(255),
- ACTIONABLE_GROUP VARCHAR(255),
- PRIMARY KEY(ERROR_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_INPUT
-(
- TASK_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,INPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_OUTPUT
-(
- TASK_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,OUTPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_INPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,INPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_OUTPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,OUTPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE JOB_DETAIL
-(
- JOB_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_DESCRIPTION CLOB NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- COMPUTE_RESOURCE_CONSUMED VARCHAR(255),
- PRIMARY KEY (TASK_ID, JOB_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE DATA_TRANSFER_DETAIL
-(
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- TRANSFER_DESC CLOB NOT NULL,
- PRIMARY KEY(TRANSFER_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE STATUS
-(
- STATUS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- STATE VARCHAR(255),
- STATUS_UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- STATUS_TYPE VARCHAR(255),
- PRIMARY KEY(STATUS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE,
- FOREIGN KEY (TRANSFER_ID) REFERENCES DATA_TRANSFER_DETAIL(TRANSFER_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE CONFIG_DATA
-(
- EXPERIMENT_ID VARCHAR(255),
- AIRAVATA_AUTO_SCHEDULE SMALLINT NOT NULL,
- OVERRIDE_MANUAL_SCHEDULE_PARAMS SMALLINT NOT NULL,
- SHARE_EXPERIMENT SMALLINT,
- PRIMARY KEY(EXPERIMENT_ID)
-);
-
-CREATE TABLE COMPUTATIONAL_RESOURCE_SCHEDULING
-(
- RESOURCE_SCHEDULING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- RESOURCE_HOST_ID VARCHAR(255),
- CPU_COUNT INTEGER,
- NODE_COUNT INTEGER,
- NO_OF_THREADS INTEGER,
- QUEUE_NAME VARCHAR(255),
- WALLTIME_LIMIT INTEGER,
- JOB_START_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- TOTAL_PHYSICAL_MEMORY INTEGER,
- COMPUTATIONAL_PROJECT_ACCOUNT VARCHAR(255),
- PRIMARY KEY(RESOURCE_SCHEDULING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_INPUT_DATA_HANDLING
-(
- INPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- WORKING_DIR_PARENT VARCHAR(255),
- UNIQUE_WORKING_DIR VARCHAR(255),
- STAGE_INPUT_FILES_TO_WORKING_DIR SMALLINT,
- CLEAN_AFTER_JOB SMALLINT,
- PRIMARY KEY(INPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_OUTPUT_DATA_HANDLING
-(
- OUTPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- OUTPUT_DATA_DIR VARCHAR(255),
- DATA_REG_URL VARCHAR (255),
- PERSIST_OUTPUT_DATA SMALLINT,
- PRIMARY KEY(OUTPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE QOS_PARAM
-(
- QOS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- START_EXECUTION_AT VARCHAR(255),
- EXECUTE_BEFORE VARCHAR(255),
- NO_OF_RETRIES INTEGER,
- PRIMARY KEY(QOS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE COMMUNITY_USER
-(
- GATEWAY_NAME VARCHAR(256) NOT NULL,
- COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
- PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME, TOKEN_ID)
-);
-
-CREATE TABLE CREDENTIALS
-(
- GATEWAY_ID VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- CREDENTIAL BLOB NOT NULL,
- PORTAL_USER_ID VARCHAR(256) NOT NULL,
- TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
-);
-
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration-tests/pom.xml b/modules/integration-tests/pom.xml
index b4700ec..bbc4d9c 100644
--- a/modules/integration-tests/pom.xml
+++ b/modules/integration-tests/pom.xml
@@ -182,7 +182,7 @@
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId.airavata.registry.core.experiment.catalog</artifactId>
+ <artifactId>airavata-registry-core</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/pom.xml b/modules/orchestrator/orchestrator-core/pom.xml
index 4882e58..f0bbafb 100644
--- a/modules/orchestrator/orchestrator-core/pom.xml
+++ b/modules/orchestrator/orchestrator-core/pom.xml
@@ -36,7 +36,7 @@ the License. -->
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId.airavata.registry.core.experiment.catalog</artifactId>
+ <artifactId>airavata-registry-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java
index 5b0247f..4c5c219 100644
--- a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java
+++ b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/Initialize.java
@@ -23,8 +23,8 @@ package org.apache.airavata.orchestrator.core.util;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.*;
+import org.apache.airavata.experiment.catalog.ResourceType;
+import org.apache.airavata.experiment.catalog.resources.*;
import org.apache.airavata.registry.cpi.RegistryException;
import org.apache.derby.drda.NetworkServerControl;
import org.slf4j.Logger;
@@ -41,7 +41,7 @@ import java.util.StringTokenizer;
public class Initialize {
private static final Logger logger = LoggerFactory.getLogger(Initialize.class);
public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
- public String scriptName = "registry-derby.sql";
+ public String scriptName = "expcatalog-derby.sql";
private NetworkServerControl server;
private static final String delimiter = ";";
public static final String PERSISTANT_DATA = "Configuration";
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-core/src/test/resources/expcatalog-derby.sql
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/test/resources/expcatalog-derby.sql b/modules/orchestrator/orchestrator-core/src/test/resources/expcatalog-derby.sql
new file mode 100644
index 0000000..7ab3755
--- /dev/null
+++ b/modules/orchestrator/orchestrator-core/src/test/resources/expcatalog-derby.sql
@@ -0,0 +1,391 @@
+/*
+ *
+ * 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.
+ *
+ */
+CREATE TABLE GATEWAY
+(
+ GATEWAY_ID VARCHAR (255),
+ GATEWAY_NAME VARCHAR(255),
+ DOMAIN VARCHAR(255),
+ EMAIL_ADDRESS VARCHAR(255),
+ PRIMARY KEY (GATEWAY_ID)
+);
+
+CREATE TABLE CONFIGURATION
+(
+ CONFIG_KEY VARCHAR(255),
+ CONFIG_VAL VARCHAR(255),
+ EXPIRE_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ CATEGORY_ID VARCHAR (255),
+ PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
+);
+
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version', '0.15', CURRENT_TIMESTAMP ,'SYSTEM');
+
+CREATE TABLE USERS
+(
+ USER_NAME VARCHAR(255),
+ PASSWORD VARCHAR(255),
+ PRIMARY KEY(USER_NAME)
+);
+
+CREATE TABLE GATEWAY_WORKER
+(
+ GATEWAY_ID VARCHAR(255),
+ USER_NAME VARCHAR(255),
+ PRIMARY KEY (GATEWAY_ID, USER_NAME),
+ FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE,
+ FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
+);
+
+CREATE TABLE PROJECT
+(
+ GATEWAY_ID VARCHAR(255),
+ USER_NAME VARCHAR(255) NOT NULL,
+ PROJECT_ID VARCHAR(255),
+ PROJECT_NAME VARCHAR(255) NOT NULL,
+ DESCRIPTION VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (PROJECT_ID),
+ FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE,
+ FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
+);
+
+CREATE TABLE PROJECT_USER
+(
+ PROJECT_ID VARCHAR(255),
+ USER_NAME VARCHAR(255),
+ PRIMARY KEY (PROJECT_ID,USER_NAME),
+ FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
+);
+
+CREATE TABLE EXPERIMENT
+(
+ EXPERIMENT_ID VARCHAR(255),
+ GATEWAY_ID VARCHAR(255),
+ EXECUTION_USER VARCHAR(255) NOT NULL,
+ PROJECT_ID VARCHAR(255) NOT NULL,
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ EXPERIMENT_NAME VARCHAR(255) NOT NULL,
+ EXPERIMENT_DESCRIPTION VARCHAR(255),
+ APPLICATION_ID VARCHAR(255),
+ APPLICATION_VERSION VARCHAR(255),
+ WORKFLOW_TEMPLATE_ID VARCHAR(255),
+ WORKFLOW_TEMPLATE_VERSION VARCHAR(255),
+ WORKFLOW_EXECUTION_ID VARCHAR(255),
+ ALLOW_NOTIFICATION SMALLINT,
+ GATEWAY_EXECUTION_ID VARCHAR(255),
+ PRIMARY KEY(EXPERIMENT_ID),
+ FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE,
+ FOREIGN KEY (EXECUTION_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE,
+ FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE EXPERIMENT_INPUT
+(
+ EXPERIMENT_ID VARCHAR(255),
+ INPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ METADATA VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ STANDARD_INPUT SMALLINT,
+ USER_FRIENDLY_DESC VARCHAR(255),
+ VALUE CLOB,
+ INPUT_ORDER INTEGER,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_STAGED SMALLINT,
+ PRIMARY KEY(EXPERIMENT_ID,INPUT_KEY),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE EXPERIMENT_OUTPUT
+(
+ EXPERIMENT_ID VARCHAR(255),
+ OUTPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ VALUE CLOB,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_MOVEMENT SMALLINT,
+ DATA_NAME_LOCATION VARCHAR(255),
+ SEARCH_QUERY VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ PRIMARY KEY(EXPERIMENT_ID,OUTPUT_KEY),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
+);
+
+
+CREATE TABLE WORKFLOW_NODE_DETAIL
+(
+ EXPERIMENT_ID VARCHAR(255) NOT NULL,
+ NODE_INSTANCE_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ NODE_NAME VARCHAR(255) NOT NULL,
+ EXECUTION_UNIT VARCHAR(255) NOT NULL,
+ EXECUTION_UNIT_DATA VARCHAR(255),
+ PRIMARY KEY(NODE_INSTANCE_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE TASK_DETAIL
+(
+ TASK_ID VARCHAR(255),
+ NODE_INSTANCE_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ APPLICATION_ID VARCHAR(255),
+ APPLICATION_VERSION VARCHAR(255),
+ APPLICATION_DEPLOYMENT_ID VARCHAR(255),
+ ALLOW_NOTIFICATION SMALLINT,
+ PRIMARY KEY(TASK_ID),
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE NOTIFICATION_EMAIL
+(
+ EMAIL_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ EMAIL_ADDRESS VARCHAR(255),
+ PRIMARY KEY(EMAIL_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE ERROR_DETAIL
+(
+ ERROR_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ NODE_INSTANCE_ID VARCHAR(255),
+ JOB_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ ACTUAL_ERROR_MESSAGE CLOB,
+ USER_FRIEDNLY_ERROR_MSG VARCHAR(255),
+ TRANSIENT_OR_PERSISTENT SMALLINT,
+ ERROR_CATEGORY VARCHAR(255),
+ CORRECTIVE_ACTION VARCHAR(255),
+ ACTIONABLE_GROUP VARCHAR(255),
+ PRIMARY KEY(ERROR_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE APPLICATION_INPUT
+(
+ TASK_ID VARCHAR(255),
+ INPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ METADATA VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ STANDARD_INPUT SMALLINT,
+ USER_FRIENDLY_DESC VARCHAR(255),
+ VALUE CLOB,
+ INPUT_ORDER INTEGER,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_STAGED SMALLINT,
+ PRIMARY KEY(TASK_ID,INPUT_KEY),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE APPLICATION_OUTPUT
+(
+ TASK_ID VARCHAR(255),
+ OUTPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ VALUE CLOB,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_MOVEMENT SMALLINT,
+ DATA_NAME_LOCATION VARCHAR(255),
+ SEARCH_QUERY VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ PRIMARY KEY(TASK_ID,OUTPUT_KEY),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE NODE_INPUT
+(
+ NODE_INSTANCE_ID VARCHAR(255),
+ INPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ METADATA VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ STANDARD_INPUT SMALLINT,
+ USER_FRIENDLY_DESC VARCHAR(255),
+ VALUE VARCHAR(255),
+ INPUT_ORDER INTEGER,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_STAGED SMALLINT,
+ PRIMARY KEY(NODE_INSTANCE_ID,INPUT_KEY),
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE NODE_OUTPUT
+(
+ NODE_INSTANCE_ID VARCHAR(255),
+ OUTPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ VALUE VARCHAR(255),
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_MOVEMENT SMALLINT,
+ DATA_NAME_LOCATION VARCHAR(255),
+ SEARCH_QUERY VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ PRIMARY KEY(NODE_INSTANCE_ID,OUTPUT_KEY),
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE JOB_DETAIL
+(
+ JOB_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ JOB_DESCRIPTION CLOB NOT NULL,
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ COMPUTE_RESOURCE_CONSUMED VARCHAR(255),
+ JOBNAME VARCHAR (255),
+ WORKING_DIR VARCHAR(255),
+ PRIMARY KEY (TASK_ID, JOB_ID),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE DATA_TRANSFER_DETAIL
+(
+ TRANSFER_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ TRANSFER_DESC VARCHAR(255) NOT NULL,
+ PRIMARY KEY(TRANSFER_ID),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE STATUS
+(
+ STATUS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ NODE_INSTANCE_ID VARCHAR(255),
+ TRANSFER_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ JOB_ID VARCHAR(255),
+ STATE VARCHAR(255),
+ STATUS_UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ STATUS_TYPE VARCHAR(255),
+ PRIMARY KEY(STATUS_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TRANSFER_ID) REFERENCES DATA_TRANSFER_DETAIL(TRANSFER_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE CONFIG_DATA
+(
+ EXPERIMENT_ID VARCHAR(255),
+ AIRAVATA_AUTO_SCHEDULE SMALLINT NOT NULL,
+ OVERRIDE_MANUAL_SCHEDULE_PARAMS SMALLINT NOT NULL,
+ SHARE_EXPERIMENT SMALLINT,
+ USER_DN VARCHAR(255),
+ GENERATE_CERT SMALLINT,
+ PRIMARY KEY(EXPERIMENT_ID)
+);
+
+CREATE TABLE COMPUTATIONAL_RESOURCE_SCHEDULING
+(
+ RESOURCE_SCHEDULING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ RESOURCE_HOST_ID VARCHAR(255),
+ CPU_COUNT INTEGER,
+ NODE_COUNT INTEGER,
+ NO_OF_THREADS INTEGER,
+ QUEUE_NAME VARCHAR(255),
+ WALLTIME_LIMIT INTEGER,
+ JOB_START_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ TOTAL_PHYSICAL_MEMORY INTEGER,
+ COMPUTATIONAL_PROJECT_ACCOUNT VARCHAR(255),
+ CHESSIS_NAME VARCHAR(255),
+ PRIMARY KEY(RESOURCE_SCHEDULING_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE ADVANCE_INPUT_DATA_HANDLING
+(
+ INPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ WORKING_DIR_PARENT VARCHAR(255),
+ UNIQUE_WORKING_DIR VARCHAR(255),
+ STAGE_INPUT_FILES_TO_WORKING_DIR SMALLINT,
+ CLEAN_AFTER_JOB SMALLINT,
+ PRIMARY KEY(INPUT_DATA_HANDLING_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE ADVANCE_OUTPUT_DATA_HANDLING
+(
+ OUTPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ OUTPUT_DATA_DIR VARCHAR(255),
+ DATA_REG_URL VARCHAR (255),
+ PERSIST_OUTPUT_DATA SMALLINT,
+ PRIMARY KEY(OUTPUT_DATA_HANDLING_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE QOS_PARAM
+(
+ QOS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ START_EXECUTION_AT VARCHAR(255),
+ EXECUTE_BEFORE VARCHAR(255),
+ NO_OF_RETRIES INTEGER,
+ PRIMARY KEY(QOS_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE COMMUNITY_USER
+(
+ GATEWAY_ID VARCHAR(256) NOT NULL,
+ COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
+ TOKEN_ID VARCHAR(256) NOT NULL,
+ COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
+ PRIMARY KEY (GATEWAY_ID, COMMUNITY_USER_NAME, TOKEN_ID)
+);
+
+CREATE TABLE CREDENTIALS
+(
+ GATEWAY_ID VARCHAR(256) NOT NULL,
+ TOKEN_ID VARCHAR(256) NOT NULL,
+ CREDENTIAL BLOB NOT NULL,
+ PORTAL_USER_ID VARCHAR(256) NOT NULL,
+ TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
+);
+
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-core/src/test/resources/registry-derby.sql
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/test/resources/registry-derby.sql b/modules/orchestrator/orchestrator-core/src/test/resources/registry-derby.sql
deleted file mode 100644
index 9ed5ca9..0000000
--- a/modules/orchestrator/orchestrator-core/src/test/resources/registry-derby.sql
+++ /dev/null
@@ -1,361 +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.
- *
- */
-CREATE TABLE GATEWAY
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME)
-);
-
-CREATE TABLE CONFIGURATION
-(
- CONFIG_KEY VARCHAR(255),
- CONFIG_VAL VARCHAR(255),
- EXPIRE_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- CATEGORY_ID VARCHAR (255),
- PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
-);
-
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version', '0.12', CURRENT_TIMESTAMP ,'SYSTEM');
-
-CREATE TABLE USERS
-(
- USER_NAME VARCHAR(255),
- PASSWORD VARCHAR(255),
- PRIMARY KEY(USER_NAME)
-);
-
-CREATE TABLE GATEWAY_WORKER
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME, USER_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255),
- PROJECT_NAME VARCHAR(255) NOT NULL,
- DESCRIPTION VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (PROJECT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT_USER
-(
- PROJECT_ID VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (PROJECT_ID,USER_NAME),
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PUBLISHED_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- CREATED_USER VARCHAR(255),
- PUBLISH_WORKFLOW_NAME VARCHAR(255),
- VERSION VARCHAR(255),
- PUBLISHED_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- PATH VARCHAR (255),
- WORKFLOW_CONTENT BLOB,
- PRIMARY KEY(GATEWAY_NAME, PUBLISH_WORKFLOW_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (CREATED_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE USER_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- TEMPLATE_NAME VARCHAR(255),
- LAST_UPDATED_TIME TIMESTAMP DEFAULT CURRENT TIMESTAMP,
- PATH VARCHAR (255),
- WORKFLOW_GRAPH BLOB,
- PRIMARY KEY(GATEWAY_NAME, OWNER, TEMPLATE_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (OWNER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT
-(
- EXPERIMENT_ID VARCHAR(255),
- GATEWAY_NAME VARCHAR(255),
- EXECUTION_USER VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255) NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- EXPERIMENT_NAME VARCHAR(255) NOT NULL,
- EXPERIMENT_DESCRIPTION VARCHAR(255),
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- WORKFLOW_TEMPLATE_ID VARCHAR(255),
- WORKFLOW_TEMPLATE_VERSION VARCHAR(255),
- WORKFLOW_EXECUTION_ID VARCHAR(255),
- PRIMARY KEY(EXPERIMENT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (EXECUTION_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE,
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_INPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,INPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_OUTPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,OUTPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-
-CREATE TABLE WORKFLOW_NODE_DETAIL
-(
- EXPERIMENT_ID VARCHAR(255) NOT NULL,
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- NODE_NAME VARCHAR(255) NOT NULL,
- EXECUTION_UNIT VARCHAR(255) NOT NULL,
- EXECUTION_UNIT_DATA VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE TASK_DETAIL
-(
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- APPLICATION_DEPLOYMENT_ID VARCHAR(255),
- PRIMARY KEY(TASK_ID),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ERROR_DETAIL
-(
- ERROR_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- ACTUAL_ERROR_MESSAGE CLOB,
- USER_FRIEDNLY_ERROR_MSG VARCHAR(255),
- TRANSIENT_OR_PERSISTENT SMALLINT,
- ERROR_CATEGORY VARCHAR(255),
- CORRECTIVE_ACTION VARCHAR(255),
- ACTIONABLE_GROUP VARCHAR(255),
- PRIMARY KEY(ERROR_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_INPUT
-(
- TASK_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,INPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_OUTPUT
-(
- TASK_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,OUTPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_INPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,INPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_OUTPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,OUTPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE JOB_DETAIL
-(
- JOB_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_DESCRIPTION CLOB NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- COMPUTE_RESOURCE_CONSUMED VARCHAR(255),
- PRIMARY KEY (TASK_ID, JOB_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE DATA_TRANSFER_DETAIL
-(
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- TRANSFER_DESC CLOB NOT NULL,
- PRIMARY KEY(TRANSFER_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE STATUS
-(
- STATUS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- STATE VARCHAR(255),
- STATUS_UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- STATUS_TYPE VARCHAR(255),
- PRIMARY KEY(STATUS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE,
- FOREIGN KEY (TRANSFER_ID) REFERENCES DATA_TRANSFER_DETAIL(TRANSFER_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE CONFIG_DATA
-(
- EXPERIMENT_ID VARCHAR(255),
- AIRAVATA_AUTO_SCHEDULE SMALLINT NOT NULL,
- OVERRIDE_MANUAL_SCHEDULE_PARAMS SMALLINT NOT NULL,
- SHARE_EXPERIMENT SMALLINT,
- PRIMARY KEY(EXPERIMENT_ID)
-);
-
-CREATE TABLE COMPUTATIONAL_RESOURCE_SCHEDULING
-(
- RESOURCE_SCHEDULING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- RESOURCE_HOST_ID VARCHAR(255),
- CPU_COUNT INTEGER,
- NODE_COUNT INTEGER,
- NO_OF_THREADS INTEGER,
- QUEUE_NAME VARCHAR(255),
- WALLTIME_LIMIT INTEGER,
- JOB_START_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- TOTAL_PHYSICAL_MEMORY INTEGER,
- COMPUTATIONAL_PROJECT_ACCOUNT VARCHAR(255),
- PRIMARY KEY(RESOURCE_SCHEDULING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_INPUT_DATA_HANDLING
-(
- INPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- WORKING_DIR_PARENT VARCHAR(255),
- UNIQUE_WORKING_DIR VARCHAR(255),
- STAGE_INPUT_FILES_TO_WORKING_DIR SMALLINT,
- CLEAN_AFTER_JOB SMALLINT,
- PRIMARY KEY(INPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_OUTPUT_DATA_HANDLING
-(
- OUTPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- OUTPUT_DATA_DIR VARCHAR(255),
- DATA_REG_URL VARCHAR (255),
- PERSIST_OUTPUT_DATA SMALLINT,
- PRIMARY KEY(OUTPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE QOS_PARAM
-(
- QOS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- START_EXECUTION_AT VARCHAR(255),
- EXECUTE_BEFORE VARCHAR(255),
- NO_OF_RETRIES INTEGER,
- PRIMARY KEY(QOS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE COMMUNITY_USER
-(
- GATEWAY_NAME VARCHAR(256) NOT NULL,
- COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
- PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME, TOKEN_ID)
-);
-
-CREATE TABLE CREDENTIALS
-(
- GATEWAY_ID VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- CREDENTIAL BLOB NOT NULL,
- PORTAL_USER_ID VARCHAR(256) NOT NULL,
- TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
-);
-
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java b/modules/orchestrator/orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java
index c5197a8..89df6f1 100644
--- a/modules/orchestrator/orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java
+++ b/modules/orchestrator/orchestrator-service/src/test/java/org/apache/airavata/orchestrator/client/util/Initialize.java
@@ -41,7 +41,7 @@ import java.util.StringTokenizer;
public class Initialize {
private static final Logger logger = LoggerFactory.getLogger(Initialize.class);
public static final String DERBY_SERVER_MODE_SYS_PROPERTY = "derby.drda.startNetworkServer";
- public String scriptName = "registry-derby.sql";
+ public String scriptName = "expcatalog-derby.sql";
private NetworkServerControl server;
private static final String delimiter = ";";
public static final String PERSISTANT_DATA = "Configuration";
[20/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointResource.java
new file mode 100644
index 0000000..8f3e806
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointResource.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.registry.core.app.catalog.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.GridftpDataMovement;
+import org.apache.airavata.registry.core.app.catalog.model.GridftpEndpoint;
+import org.apache.airavata.registry.core.app.catalog.model.GridftpEndpoint_PK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GridftpEndpointResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(GridftpEndpointResource.class);
+ private String endpoint;
+ private String dataMovementInterfaceId;
+ private GridftpDataMovementResource gridftpDataMovementResource;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_ENDPOINT);
+ generator.setParameter(GridftpEndpointConstants.ENDPOINT, ids.get(GridftpEndpointConstants.ENDPOINT));
+ generator.setParameter(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID, ids.get(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_ENDPOINT);
+ generator.setParameter(GridftpEndpointConstants.ENDPOINT, ids.get(GridftpEndpointConstants.ENDPOINT));
+ generator.setParameter(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID, ids.get(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID));
+ Query q = generator.selectQuery(em);
+ GridftpEndpoint gridftpEndpoint = (GridftpEndpoint) q.getSingleResult();
+ GridftpEndpointResource gridftpEndpointResource = (GridftpEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_ENDPOINT, gridftpEndpoint);
+ em.getTransaction().commit();
+ em.close();
+ return gridftpEndpointResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> gridftpEndpointResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_ENDPOINT);
+ Query q;
+ if ((fieldName.equals(GridftpEndpointConstants.ENDPOINT)) || (fieldName.equals(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ GridftpEndpoint gridftpEndpoint = (GridftpEndpoint) result;
+ GridftpEndpointResource gridftpEndpointResource = (GridftpEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_ENDPOINT, gridftpEndpoint);
+ gridftpEndpointResources.add(gridftpEndpointResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Gridftp Endpoint Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Gridftp Endpoint Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gridftpEndpointResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> gridftpEndpointResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_ENDPOINT);
+ Query q;
+ if ((fieldName.equals(GridftpEndpointConstants.ENDPOINT)) || (fieldName.equals(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ GridftpEndpoint gridftpEndpoint = (GridftpEndpoint) result;
+ GridftpEndpointResource gridftpEndpointResource = (GridftpEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_ENDPOINT, gridftpEndpoint);
+ gridftpEndpointResourceIDs.add(gridftpEndpointResource.getDataMovementInterfaceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Gridftp Endpoint Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Gridftp Endpoint Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gridftpEndpointResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GridftpEndpoint existingGridftpEndpoint = em.find(GridftpEndpoint.class, new GridftpEndpoint_PK(endpoint, dataMovementInterfaceId));
+ em.close();
+ GridftpEndpoint gridftpEndpoint;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingGridftpEndpoint == null) {
+ gridftpEndpoint = new GridftpEndpoint();
+ gridftpEndpoint.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ gridftpEndpoint = existingGridftpEndpoint;
+ gridftpEndpoint.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ gridftpEndpoint.setEndpoint(getEndpoint());
+ gridftpEndpoint.setDataMovementInterfaceId(getDataMovementInterfaceId());
+ GridftpDataMovement gridftpDataMovement = em.find(GridftpDataMovement.class, getDataMovementInterfaceId());
+ gridftpEndpoint.setGridftpDataMovement(gridftpDataMovement);
+ if (existingGridftpEndpoint == null) {
+ em.persist(gridftpEndpoint);
+ } else {
+ em.merge(gridftpEndpoint);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GridftpEndpoint gridftpEndpoint = em.find(GridftpEndpoint.class, new GridftpEndpoint_PK(ids.get(GridftpEndpointConstants.ENDPOINT), ids.get(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID)));
+ em.close();
+ return gridftpEndpoint != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getEndpoint() {
+ return endpoint;
+ }
+
+ public String getDataMovementInterfaceId() {
+ return dataMovementInterfaceId;
+ }
+
+ public GridftpDataMovementResource getGridftpDataMovementResource() {
+ return gridftpDataMovementResource;
+ }
+
+ public void setEndpoint(String endpoint) {
+ this.endpoint=endpoint;
+ }
+
+ public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
+ this.dataMovementInterfaceId=dataMovementInterfaceId;
+ }
+
+ public void setGridftpDataMovementResource(GridftpDataMovementResource gridftpDataMovementResource) {
+ this.gridftpDataMovementResource=gridftpDataMovementResource;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppCatalogResourceAppCat.java
deleted file mode 100644
index 936b6c6..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppCatalogResourceAppCat.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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.model.HostAlias;
-import org.apache.airavata.registry.core.app.catalog.model.HostAliasPK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.*;
-
-public class HostAliasAppCatalogResourceAppCat extends AppCatAbstractResource {
-
- private final static Logger logger = LoggerFactory.getLogger(HostAliasAppCatalogResourceAppCat.class);
-
- private String resourceID;
- private String alias;
- private ComputeResourceAppCatalogResourceAppCat computeHostResource;
-
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(HOST_ALIAS);
- generator.setParameter(HostAliasConstants.RESOURCE_ID, (String)identifier);
-// generator.setParameter(HostAliasConstants.ALIAS, ids.get(HostAliasConstants.ALIAS));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_ALIAS);
- generator.setParameter(HostAliasConstants.RESOURCE_ID, ids.get(HostAliasConstants.RESOURCE_ID));
- generator.setParameter(HostAliasConstants.ALIAS, ids.get(HostAliasConstants.ALIAS));
- Query q = generator.selectQuery(em);
- HostAlias hostAlias = (HostAlias) q.getSingleResult();
- HostAliasAppCatalogResourceAppCat hostAliasResource =
- (HostAliasAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_ALIAS, hostAlias);
- em.getTransaction().commit();
- em.close();
- return hostAliasResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
-
- List<AppCatalogResource> hostAliasResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_ALIAS);
- List results;
- if (fieldName.equals(HostAliasConstants.ALIAS)) {
- generator.setParameter(HostAliasConstants.ALIAS, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- HostAlias hostAlias = (HostAlias) result;
- HostAliasAppCatalogResourceAppCat hostAliasResource =
- (HostAliasAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_ALIAS, hostAlias);
- hostAliasResources.add(hostAliasResource);
- }
- }
- } else if (fieldName.equals(HostAliasConstants.RESOURCE_ID)) {
- generator.setParameter(HostAliasConstants.RESOURCE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- HostAlias hostAlias = (HostAlias) result;
- HostAliasAppCatalogResourceAppCat hostAliasResource =
- (HostAliasAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_ALIAS, hostAlias);
- hostAliasResources.add(hostAliasResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Host Alias Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Host Alias Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return hostAliasResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
-
- List<String> hostAliasResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_ALIAS);
- List results;
- if (fieldName.equals(HostAliasConstants.ALIAS)) {
- generator.setParameter(HostAliasConstants.ALIAS, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- HostAlias hostAlias = (HostAlias) result;
- hostAliasResourceIDs.add(hostAlias.getResourceID());
- }
- }
- } else if (fieldName.equals(HostAliasConstants.RESOURCE_ID)) {
- generator.setParameter(HostAliasConstants.RESOURCE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- HostAlias hostAlias = (HostAlias) result;
- hostAliasResourceIDs.add(hostAlias.getResourceID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Host Alias resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Host Alias Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return hostAliasResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- HostAlias existingHostAlias = em.find(HostAlias.class, new HostAliasPK(resourceID, alias));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
- if (existingHostAlias != null){
- existingHostAlias.setAlias(alias);
- existingHostAlias.setComputeResource(computeResource);
- existingHostAlias.setResourceID(resourceID);
- em.merge(existingHostAlias);
- }else {
- HostAlias hostAlias = new HostAlias();
- hostAlias.setAlias(alias);
- hostAlias.setResourceID(resourceID);
- hostAlias.setComputeResource(computeResource);
-
- em.persist(hostAlias);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
-
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- HostAlias hostAlias = em.find(HostAlias.class, new HostAliasPK(ids.get(HostAliasConstants.RESOURCE_ID),
- ids.get(HostAliasConstants.ALIAS)));
-
- em.close();
- return hostAlias != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
-
- }
-
- public String getResourceID() {
- return resourceID;
- }
-
- public void setResourceID(String resourceID) {
- this.resourceID = resourceID;
- }
-
- public String getAlias() {
- return alias;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
- public ComputeResourceAppCatalogResourceAppCat getComputeHostResource() {
- return computeHostResource;
- }
-
- public void setComputeHostResource(ComputeResourceAppCatalogResourceAppCat computeHostResource) {
- this.computeHostResource = computeHostResource;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppResource.java
new file mode 100644
index 0000000..8f9a752
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostAliasAppResource.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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.model.HostAlias;
+import org.apache.airavata.registry.core.app.catalog.model.HostAliasPK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.*;
+
+public class HostAliasAppResource extends AppCatAbstractResource {
+
+ private final static Logger logger = LoggerFactory.getLogger(HostAliasAppResource.class);
+
+ private String resourceID;
+ private String alias;
+ private ComputeResourceResource computeHostResource;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(HOST_ALIAS);
+ generator.setParameter(HostAliasConstants.RESOURCE_ID, (String)identifier);
+// generator.setParameter(HostAliasConstants.ALIAS, ids.get(HostAliasConstants.ALIAS));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_ALIAS);
+ generator.setParameter(HostAliasConstants.RESOURCE_ID, ids.get(HostAliasConstants.RESOURCE_ID));
+ generator.setParameter(HostAliasConstants.ALIAS, ids.get(HostAliasConstants.ALIAS));
+ Query q = generator.selectQuery(em);
+ HostAlias hostAlias = (HostAlias) q.getSingleResult();
+ HostAliasAppResource hostAliasResource =
+ (HostAliasAppResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_ALIAS, hostAlias);
+ em.getTransaction().commit();
+ em.close();
+ return hostAliasResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+
+ List<AppCatalogResource> hostAliasResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_ALIAS);
+ List results;
+ if (fieldName.equals(HostAliasConstants.ALIAS)) {
+ generator.setParameter(HostAliasConstants.ALIAS, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ HostAlias hostAlias = (HostAlias) result;
+ HostAliasAppResource hostAliasResource =
+ (HostAliasAppResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_ALIAS, hostAlias);
+ hostAliasResources.add(hostAliasResource);
+ }
+ }
+ } else if (fieldName.equals(HostAliasConstants.RESOURCE_ID)) {
+ generator.setParameter(HostAliasConstants.RESOURCE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ HostAlias hostAlias = (HostAlias) result;
+ HostAliasAppResource hostAliasResource =
+ (HostAliasAppResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_ALIAS, hostAlias);
+ hostAliasResources.add(hostAliasResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Host Alias Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Host Alias Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return hostAliasResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+
+ List<String> hostAliasResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_ALIAS);
+ List results;
+ if (fieldName.equals(HostAliasConstants.ALIAS)) {
+ generator.setParameter(HostAliasConstants.ALIAS, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ HostAlias hostAlias = (HostAlias) result;
+ hostAliasResourceIDs.add(hostAlias.getResourceID());
+ }
+ }
+ } else if (fieldName.equals(HostAliasConstants.RESOURCE_ID)) {
+ generator.setParameter(HostAliasConstants.RESOURCE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ HostAlias hostAlias = (HostAlias) result;
+ hostAliasResourceIDs.add(hostAlias.getResourceID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Host Alias resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Host Alias Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return hostAliasResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ HostAlias existingHostAlias = em.find(HostAlias.class, new HostAliasPK(resourceID, alias));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
+ if (existingHostAlias != null){
+ existingHostAlias.setAlias(alias);
+ existingHostAlias.setComputeResource(computeResource);
+ existingHostAlias.setResourceID(resourceID);
+ em.merge(existingHostAlias);
+ }else {
+ HostAlias hostAlias = new HostAlias();
+ hostAlias.setAlias(alias);
+ hostAlias.setResourceID(resourceID);
+ hostAlias.setComputeResource(computeResource);
+
+ em.persist(hostAlias);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ HostAlias hostAlias = em.find(HostAlias.class, new HostAliasPK(ids.get(HostAliasConstants.RESOURCE_ID),
+ ids.get(HostAliasConstants.ALIAS)));
+
+ em.close();
+ return hostAlias != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+
+ }
+
+ public String getResourceID() {
+ return resourceID;
+ }
+
+ public void setResourceID(String resourceID) {
+ this.resourceID = resourceID;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public ComputeResourceResource getComputeHostResource() {
+ return computeHostResource;
+ }
+
+ public void setComputeHostResource(ComputeResourceResource computeHostResource) {
+ this.computeHostResource = computeHostResource;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressAppCatalogResourceAppCat.java
deleted file mode 100644
index e32fc36..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,318 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.model.HostIPAddress;
-import org.apache.airavata.registry.core.app.catalog.model.HostIPAddressPK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class HostIPAddressAppCatalogResourceAppCat extends AppCatAbstractResource {
-
- private final static Logger logger = LoggerFactory.getLogger(HostIPAddressAppCatalogResourceAppCat.class);
-
- private String resourceID;
- private String ipaddress;
- private ComputeResourceAppCatalogResourceAppCat computeHostResource;
-
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(HOST_IPADDRESS);
- generator.setParameter(HostIPAddressConstants.RESOURCE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
-
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_IPADDRESS);
- generator.setParameter(HostIPAddressConstants.RESOURCE_ID, ids.get(HostIPAddressConstants.RESOURCE_ID));
- generator.setParameter(HostIPAddressConstants.IP_ADDRESS, ids.get(HostIPAddressConstants.IP_ADDRESS));
- Query q = generator.selectQuery(em);
- HostIPAddress hostIPAddress = (HostIPAddress) q.getSingleResult();
- HostIPAddressAppCatalogResourceAppCat hostIPAddressResource =
- (HostIPAddressAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_IPADDRESS, hostIPAddress);
- em.getTransaction().commit();
- em.close();
- return hostIPAddressResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
-
- List<AppCatalogResource> hostIPAddressResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_IPADDRESS);
- List results;
- if (fieldName.equals(HostIPAddressConstants.IP_ADDRESS)) {
- generator.setParameter(HostIPAddressConstants.IP_ADDRESS, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- HostIPAddress hostIPAddress = (HostIPAddress) result;
- HostIPAddressAppCatalogResourceAppCat hostIPAddressResource =
- (HostIPAddressAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_IPADDRESS, hostIPAddress);
- hostIPAddressResources.add(hostIPAddressResource);
- }
- }
- } else if (fieldName.equals(HostIPAddressConstants.RESOURCE_ID)) {
- generator.setParameter(HostIPAddressConstants.RESOURCE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- HostIPAddress hostIPAddress = (HostIPAddress) result;
- HostIPAddressAppCatalogResourceAppCat hostIPAddressResource =
- (HostIPAddressAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_IPADDRESS, hostIPAddress);
- hostIPAddressResources.add(hostIPAddressResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Host IPAddress Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Host IPAddress Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return hostIPAddressResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
-
- List<String> hostIPAddressResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_IPADDRESS);
- List results;
- if (fieldName.equals(HostIPAddressConstants.IP_ADDRESS)) {
- generator.setParameter(HostIPAddressConstants.IP_ADDRESS, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- HostIPAddress hostIPAddress = (HostIPAddress) result;
- hostIPAddressResourceIDs.add(hostIPAddress.getResourceID());
- }
- }
- } else if (fieldName.equals(HostIPAddressConstants.RESOURCE_ID)) {
- generator.setParameter(HostIPAddressConstants.RESOURCE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- HostIPAddress hostIPAddress = (HostIPAddress) result;
- hostIPAddressResourceIDs.add(hostIPAddress.getResourceID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Host IP Address resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Host IPAddress Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return hostIPAddressResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- HostIPAddress existingHostIP = em.find(HostIPAddress.class, new HostIPAddressPK(resourceID,ipaddress));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
- if (existingHostIP != null){
- existingHostIP.setIpaddress(ipaddress);
- existingHostIP.setResourceID(resourceID);
- existingHostIP.setComputeResource(computeResource);
- em.merge(existingHostIP);
- }else {
- HostIPAddress hostIPAddress = new HostIPAddress();
- hostIPAddress.setIpaddress(ipaddress);
- hostIPAddress.setResourceID(resourceID);
- hostIPAddress.setComputeResource(computeResource);
- em.persist(hostIPAddress);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
-
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- HostIPAddress hostIPAddress = em.find(HostIPAddress.class, new HostIPAddressPK(ids.get(HostIPAddressConstants.RESOURCE_ID),
- ids.get(HostIPAddressConstants.IP_ADDRESS)));
-
- em.close();
- return hostIPAddress != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getResourceID() {
- return resourceID;
- }
-
- public void setResourceID(String resourceID) {
- this.resourceID = resourceID;
- }
-
- public String getIpaddress() {
- return ipaddress;
- }
-
- public void setIpaddress(String ipaddress) {
- this.ipaddress = ipaddress;
- }
-
- public ComputeResourceAppCatalogResourceAppCat getComputeHostResource() {
- return computeHostResource;
- }
-
- public void setComputeHostResource(ComputeResourceAppCatalogResourceAppCat computeHostResource) {
- this.computeHostResource = computeHostResource;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressResource.java
new file mode 100644
index 0000000..3bd4c11
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/HostIPAddressResource.java
@@ -0,0 +1,318 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.model.HostIPAddress;
+import org.apache.airavata.registry.core.app.catalog.model.HostIPAddressPK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class HostIPAddressResource extends AppCatAbstractResource {
+
+ private final static Logger logger = LoggerFactory.getLogger(HostIPAddressResource.class);
+
+ private String resourceID;
+ private String ipaddress;
+ private ComputeResourceResource computeHostResource;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(HOST_IPADDRESS);
+ generator.setParameter(HostIPAddressConstants.RESOURCE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_IPADDRESS);
+ generator.setParameter(HostIPAddressConstants.RESOURCE_ID, ids.get(HostIPAddressConstants.RESOURCE_ID));
+ generator.setParameter(HostIPAddressConstants.IP_ADDRESS, ids.get(HostIPAddressConstants.IP_ADDRESS));
+ Query q = generator.selectQuery(em);
+ HostIPAddress hostIPAddress = (HostIPAddress) q.getSingleResult();
+ HostIPAddressResource hostIPAddressResource =
+ (HostIPAddressResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_IPADDRESS, hostIPAddress);
+ em.getTransaction().commit();
+ em.close();
+ return hostIPAddressResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+
+ List<AppCatalogResource> hostIPAddressResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_IPADDRESS);
+ List results;
+ if (fieldName.equals(HostIPAddressConstants.IP_ADDRESS)) {
+ generator.setParameter(HostIPAddressConstants.IP_ADDRESS, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ HostIPAddress hostIPAddress = (HostIPAddress) result;
+ HostIPAddressResource hostIPAddressResource =
+ (HostIPAddressResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_IPADDRESS, hostIPAddress);
+ hostIPAddressResources.add(hostIPAddressResource);
+ }
+ }
+ } else if (fieldName.equals(HostIPAddressConstants.RESOURCE_ID)) {
+ generator.setParameter(HostIPAddressConstants.RESOURCE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ HostIPAddress hostIPAddress = (HostIPAddress) result;
+ HostIPAddressResource hostIPAddressResource =
+ (HostIPAddressResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.HOST_IPADDRESS, hostIPAddress);
+ hostIPAddressResources.add(hostIPAddressResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Host IPAddress Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Host IPAddress Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return hostIPAddressResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+
+ List<String> hostIPAddressResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(HOST_IPADDRESS);
+ List results;
+ if (fieldName.equals(HostIPAddressConstants.IP_ADDRESS)) {
+ generator.setParameter(HostIPAddressConstants.IP_ADDRESS, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ HostIPAddress hostIPAddress = (HostIPAddress) result;
+ hostIPAddressResourceIDs.add(hostIPAddress.getResourceID());
+ }
+ }
+ } else if (fieldName.equals(HostIPAddressConstants.RESOURCE_ID)) {
+ generator.setParameter(HostIPAddressConstants.RESOURCE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ HostIPAddress hostIPAddress = (HostIPAddress) result;
+ hostIPAddressResourceIDs.add(hostIPAddress.getResourceID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Host IP Address resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Host IPAddress Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return hostIPAddressResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ HostIPAddress existingHostIP = em.find(HostIPAddress.class, new HostIPAddressPK(resourceID,ipaddress));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ ComputeResource computeResource = em.find(ComputeResource.class, resourceID);
+ if (existingHostIP != null){
+ existingHostIP.setIpaddress(ipaddress);
+ existingHostIP.setResourceID(resourceID);
+ existingHostIP.setComputeResource(computeResource);
+ em.merge(existingHostIP);
+ }else {
+ HostIPAddress hostIPAddress = new HostIPAddress();
+ hostIPAddress.setIpaddress(ipaddress);
+ hostIPAddress.setResourceID(resourceID);
+ hostIPAddress.setComputeResource(computeResource);
+ em.persist(hostIPAddress);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ HostIPAddress hostIPAddress = em.find(HostIPAddress.class, new HostIPAddressPK(ids.get(HostIPAddressConstants.RESOURCE_ID),
+ ids.get(HostIPAddressConstants.IP_ADDRESS)));
+
+ em.close();
+ return hostIPAddress != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getResourceID() {
+ return resourceID;
+ }
+
+ public void setResourceID(String resourceID) {
+ this.resourceID = resourceID;
+ }
+
+ public String getIpaddress() {
+ return ipaddress;
+ }
+
+ public void setIpaddress(String ipaddress) {
+ this.ipaddress = ipaddress;
+ }
+
+ public ComputeResourceResource getComputeHostResource() {
+ return computeHostResource;
+ }
+
+ public void setComputeHostResource(ComputeResourceResource computeHostResource) {
+ this.computeHostResource = computeHostResource;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandAppCatalogResourceAppCat.java
deleted file mode 100644
index a3c5e8f..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,307 +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.registry.core.app.catalog.resources;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.JobManagerCommand;
-import org.apache.airavata.registry.core.app.catalog.model.JobManagerCommand_PK;
-import org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JobManagerCommandAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(JobManagerCommandAppCatalogResourceAppCat.class);
- private String resourceJobManagerId;
- private ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource;
- private String commandType;
- private String command;
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND);
- generator.setParameter(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID));
- generator.setParameter(JobManagerCommandConstants.COMMAND_TYPE, ids.get(JobManagerCommandConstants.COMMAND_TYPE));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND);
- generator.setParameter(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID));
- generator.setParameter(JobManagerCommandConstants.COMMAND_TYPE, ids.get(JobManagerCommandConstants.COMMAND_TYPE));
- Query q = generator.selectQuery(em);
- JobManagerCommand jobManagerCommand = (JobManagerCommand) q.getSingleResult();
- JobManagerCommandAppCatalogResourceAppCat jobManagerCommandResource = (JobManagerCommandAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand);
- em.getTransaction().commit();
- em.close();
- return jobManagerCommandResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> jobManagerCommandResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND);
- Query q;
- if ((fieldName.equals(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(JobManagerCommandConstants.COMMAND_TYPE)) || (fieldName.equals(JobManagerCommandConstants.COMMAND))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- JobManagerCommand jobManagerCommand = (JobManagerCommand) result;
- JobManagerCommandAppCatalogResourceAppCat jobManagerCommandResource = (JobManagerCommandAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand);
- jobManagerCommandResources.add(jobManagerCommandResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Job Manager Command Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Job Manager Command Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return jobManagerCommandResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> jobManagerCommandResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND);
- Query q;
- if ((fieldName.equals(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(JobManagerCommandConstants.COMMAND_TYPE)) || (fieldName.equals(JobManagerCommandConstants.COMMAND))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- JobManagerCommand jobManagerCommand = (JobManagerCommand) result;
- JobManagerCommandAppCatalogResourceAppCat jobManagerCommandResource = (JobManagerCommandAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand);
- jobManagerCommandResourceIDs.add(jobManagerCommandResource.getResourceJobManagerId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Job Manager Command Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Job Manager Command Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return jobManagerCommandResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- JobManagerCommand existingJobManagerCommand = em.find(JobManagerCommand.class, new JobManagerCommand_PK(resourceJobManagerId, commandType));
- em.close();
- JobManagerCommand jobManagerCommand;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingJobManagerCommand == null) {
- jobManagerCommand = new JobManagerCommand();
- } else {
- jobManagerCommand = existingJobManagerCommand;
- }
- jobManagerCommand.setResourceJobManagerId(getResourceJobManagerId());
- ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
- jobManagerCommand.setResourceJobManager(resourceJobManager);
- jobManagerCommand.setCommandType(getCommandType());
- jobManagerCommand.setCommand(getCommand());
- if (existingJobManagerCommand == null) {
- em.persist(jobManagerCommand);
- } else {
- em.merge(jobManagerCommand);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- JobManagerCommand jobManagerCommand = em.find(JobManagerCommand.class, new JobManagerCommand_PK(ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID), ids.get(JobManagerCommandConstants.COMMAND_TYPE)));
- em.close();
- return jobManagerCommand != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getResourceJobManagerId() {
- return resourceJobManagerId;
- }
-
- public ResourceJobManagerAppCatalogResourceAppCat getResourceJobManagerResource() {
- return resourceJobManagerResource;
- }
-
- public String getCommandType() {
- return commandType;
- }
-
- public String getCommand() {
- return command;
- }
-
- public void setResourceJobManagerId(String resourceJobManagerId) {
- this.resourceJobManagerId=resourceJobManagerId;
- }
-
- public void setResourceJobManagerResource(ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource) {
- this.resourceJobManagerResource=resourceJobManagerResource;
- }
-
- public void setCommandType(String commandType) {
- this.commandType=commandType;
- }
-
- public void setCommand(String command) {
- this.command=command;
- }
-}
[18/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathResource.java
new file mode 100644
index 0000000..fa77b2c
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathResource.java
@@ -0,0 +1,291 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
+import org.apache.airavata.registry.core.app.catalog.model.LibraryPrepandPath;
+import org.apache.airavata.registry.core.app.catalog.model.LibraryPrepandPath_PK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class LibraryPrepandPathResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(LibraryPrepandPathResource.class);
+ private String deploymentId;
+ private String name;
+ private String value;
+ private AppDeploymentResource appDeploymentResource;
+
+ public String getDeploymentId() {
+ return deploymentId;
+ }
+
+ public void setDeploymentId(String deploymentId) {
+ this.deploymentId = deploymentId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public AppDeploymentResource getAppDeploymentResource() {
+ return appDeploymentResource;
+ }
+
+ public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) {
+ this.appDeploymentResource = appDeploymentResource;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH);
+ generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID));
+ if (ids.get(LibraryPrepandPathConstants.NAME) != null){
+ generator.setParameter(LibraryPrepandPathConstants.NAME, ids.get(LibraryPrepandPathConstants.NAME));
+ }
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH);
+ generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID));
+ generator.setParameter(LibraryPrepandPathConstants.NAME, ids.get(LibraryPrepandPathConstants.NAME));
+ Query q = generator.selectQuery(em);
+ LibraryPrepandPath libraryPrepandPath = (LibraryPrepandPath) q.getSingleResult();
+ LibraryPrepandPathResource resource =
+ (LibraryPrepandPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, libraryPrepandPath);
+ em.getTransaction().commit();
+ em.close();
+ return resource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> libPrepPathList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH);
+ List results;
+ if (fieldName.equals(LibraryPrepandPathConstants.DEPLOYMENT_ID)) {
+ generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ LibraryPrepandPath prepandPath = (LibraryPrepandPath) result;
+ LibraryPrepandPathResource resource =
+ (LibraryPrepandPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, prepandPath);
+ libPrepPathList.add(resource);
+ }
+ }
+ } else if (fieldName.equals(LibraryPrepandPathConstants.NAME)) {
+ generator.setParameter(LibraryPrepandPathConstants.NAME, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ LibraryPrepandPath prepandPath = (LibraryPrepandPath) result;
+ LibraryPrepandPathResource resource =
+ (LibraryPrepandPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, prepandPath);
+ libPrepPathList.add(resource);
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for libraryPrepandPath resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for libraryPrepandPath resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return libPrepPathList;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ logger.error("Unsupported for objects with a composite identifier");
+ throw new AppCatalogException("Unsupported for objects with a composite identifier");
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ LibraryPrepandPath existigPrepPath = em.find(LibraryPrepandPath.class, new LibraryPrepandPath_PK(deploymentId, name));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId);
+ if (existigPrepPath != null){
+ existigPrepPath.setValue(value);
+ existigPrepPath.setApplicationDeployment(deployment);
+ em.merge(existigPrepPath);
+ }else {
+ LibraryPrepandPath prepandPath = new LibraryPrepandPath();
+ prepandPath.setDeploymentID(deploymentId);
+ prepandPath.setName(name);
+ prepandPath.setValue(value);
+ prepandPath.setApplicationDeployment(deployment);
+ em.persist(prepandPath);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ LibraryPrepandPath prepandPath = em.find(LibraryPrepandPath.class,
+ new LibraryPrepandPath_PK(ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID),
+ ids.get(LibraryPrepandPathConstants.NAME)));
+ em.close();
+ return prepandPath != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementAppCatalogResourceAppCat.java
deleted file mode 100644
index 7d71abf..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,249 +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.registry.core.app.catalog.resources;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.LocalDataMovement;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LocalDataMovementAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(LocalDataMovementAppCatalogResourceAppCat.class);
- private String dataMovementInterfaceId;
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_DATA_MOVEMENT);
- generator.setParameter(LocalDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_DATA_MOVEMENT);
- generator.setParameter(LocalDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
- Query q = generator.selectQuery(em);
- LocalDataMovement localDataMovement = (LocalDataMovement) q.getSingleResult();
- LocalDataMovementAppCatalogResourceAppCat localDataMovementResource = (LocalDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_DATA_MOVEMENT, localDataMovement);
- em.getTransaction().commit();
- em.close();
- return localDataMovementResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> localDataMovementResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_DATA_MOVEMENT);
- Query q;
- if ((fieldName.equals(LocalDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- LocalDataMovement localDataMovement = (LocalDataMovement) result;
- LocalDataMovementAppCatalogResourceAppCat localDataMovementResource = (LocalDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_DATA_MOVEMENT, localDataMovement);
- localDataMovementResources.add(localDataMovementResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Local Data Movement Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Local Data Movement Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return localDataMovementResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> localDataMovementResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_DATA_MOVEMENT);
- Query q;
- if ((fieldName.equals(LocalDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- LocalDataMovement localDataMovement = (LocalDataMovement) result;
- LocalDataMovementAppCatalogResourceAppCat localDataMovementResource = (LocalDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_DATA_MOVEMENT, localDataMovement);
- localDataMovementResourceIDs.add(localDataMovementResource.getDataMovementInterfaceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Local Data Movement Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Local Data Movement Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return localDataMovementResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- LocalDataMovement existingLocalDataMovement = em.find(LocalDataMovement.class, dataMovementInterfaceId);
- em.close();
- LocalDataMovement localDataMovement;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingLocalDataMovement == null) {
- localDataMovement = new LocalDataMovement();
- } else {
- localDataMovement = existingLocalDataMovement;
- }
- localDataMovement.setDataMovementInterfaceId(getDataMovementInterfaceId());
- if (existingLocalDataMovement == null) {
- em.persist(localDataMovement);
- } else {
- em.merge(localDataMovement);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- LocalDataMovement localDataMovement = em.find(LocalDataMovement.class, identifier);
- em.close();
- return localDataMovement != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getDataMovementInterfaceId() {
- return dataMovementInterfaceId;
- }
-
- public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
- this.dataMovementInterfaceId=dataMovementInterfaceId;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementResource.java
new file mode 100644
index 0000000..11cb089
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalDataMovementResource.java
@@ -0,0 +1,249 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.LocalDataMovement;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LocalDataMovementResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(LocalDataMovementResource.class);
+ private String dataMovementInterfaceId;
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_DATA_MOVEMENT);
+ generator.setParameter(LocalDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_DATA_MOVEMENT);
+ generator.setParameter(LocalDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ LocalDataMovement localDataMovement = (LocalDataMovement) q.getSingleResult();
+ LocalDataMovementResource localDataMovementResource = (LocalDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_DATA_MOVEMENT, localDataMovement);
+ em.getTransaction().commit();
+ em.close();
+ return localDataMovementResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> localDataMovementResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_DATA_MOVEMENT);
+ Query q;
+ if ((fieldName.equals(LocalDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ LocalDataMovement localDataMovement = (LocalDataMovement) result;
+ LocalDataMovementResource localDataMovementResource = (LocalDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_DATA_MOVEMENT, localDataMovement);
+ localDataMovementResources.add(localDataMovementResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Local Data Movement Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Local Data Movement Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return localDataMovementResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> localDataMovementResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_DATA_MOVEMENT);
+ Query q;
+ if ((fieldName.equals(LocalDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ LocalDataMovement localDataMovement = (LocalDataMovement) result;
+ LocalDataMovementResource localDataMovementResource = (LocalDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_DATA_MOVEMENT, localDataMovement);
+ localDataMovementResourceIDs.add(localDataMovementResource.getDataMovementInterfaceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Local Data Movement Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Local Data Movement Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return localDataMovementResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ LocalDataMovement existingLocalDataMovement = em.find(LocalDataMovement.class, dataMovementInterfaceId);
+ em.close();
+ LocalDataMovement localDataMovement;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingLocalDataMovement == null) {
+ localDataMovement = new LocalDataMovement();
+ } else {
+ localDataMovement = existingLocalDataMovement;
+ }
+ localDataMovement.setDataMovementInterfaceId(getDataMovementInterfaceId());
+ if (existingLocalDataMovement == null) {
+ em.persist(localDataMovement);
+ } else {
+ em.merge(localDataMovement);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ LocalDataMovement localDataMovement = em.find(LocalDataMovement.class, identifier);
+ em.close();
+ return localDataMovement != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getDataMovementInterfaceId() {
+ return dataMovementInterfaceId;
+ }
+
+ public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
+ this.dataMovementInterfaceId=dataMovementInterfaceId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionAppCatalogResourceAppCat.java
deleted file mode 100644
index ec03223..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,293 +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.registry.core.app.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.LocalSubmission;
-import org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LocalSubmissionAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(LocalSubmissionAppCatalogResourceAppCat.class);
- private String resourceJobManagerId;
- private ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource;
- private String jobSubmissionInterfaceId;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_SUBMISSION);
- generator.setParameter(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_SUBMISSION);
- generator.setParameter(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
- Query q = generator.selectQuery(em);
- LocalSubmission localSubmission = (LocalSubmission) q.getSingleResult();
- LocalSubmissionAppCatalogResourceAppCat localSubmissionResource = (LocalSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_SUBMISSION, localSubmission);
- em.getTransaction().commit();
- em.close();
- return localSubmissionResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> localSubmissionResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_SUBMISSION);
- Query q;
- if ((fieldName.equals(LocalSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- LocalSubmission localSubmission = (LocalSubmission) result;
- LocalSubmissionAppCatalogResourceAppCat localSubmissionResource = (LocalSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_SUBMISSION, localSubmission);
- localSubmissionResources.add(localSubmissionResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return localSubmissionResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> localSubmissionResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_SUBMISSION);
- Query q;
- if ((fieldName.equals(LocalSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- LocalSubmission localSubmission = (LocalSubmission) result;
- LocalSubmissionAppCatalogResourceAppCat localSubmissionResource = (LocalSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_SUBMISSION, localSubmission);
- localSubmissionResourceIDs.add(localSubmissionResource.getJobSubmissionInterfaceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return localSubmissionResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- LocalSubmission existingLocalSubmission = em.find(LocalSubmission.class, jobSubmissionInterfaceId);
- em.close();
- LocalSubmission localSubmission;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingLocalSubmission == null) {
- localSubmission = new LocalSubmission();
- localSubmission.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- localSubmission = existingLocalSubmission;
- localSubmission.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- localSubmission.setResourceJobManagerId(getResourceJobManagerId());
- ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
- localSubmission.setResourceJobManager(resourceJobManager);
- localSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
- if (existingLocalSubmission == null) {
- em.persist(localSubmission);
- } else {
- em.merge(localSubmission);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- LocalSubmission localSubmission = em.find(LocalSubmission.class, identifier);
- em.close();
- return localSubmission != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getResourceJobManagerId() {
- return resourceJobManagerId;
- }
-
- public ResourceJobManagerAppCatalogResourceAppCat getResourceJobManagerResource() {
- return resourceJobManagerResource;
- }
-
- public String getJobSubmissionInterfaceId() {
- return jobSubmissionInterfaceId;
- }
-
- public void setResourceJobManagerId(String resourceJobManagerId) {
- this.resourceJobManagerId=resourceJobManagerId;
- }
-
- public void setResourceJobManagerResource(ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource) {
- this.resourceJobManagerResource=resourceJobManagerResource;
- }
-
- public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
- this.jobSubmissionInterfaceId=jobSubmissionInterfaceId;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionResource.java
new file mode 100644
index 0000000..ab0113e
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LocalSubmissionResource.java
@@ -0,0 +1,293 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.LocalSubmission;
+import org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LocalSubmissionResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(LocalSubmissionResource.class);
+ private String resourceJobManagerId;
+ private ResourceJobManagerResource resourceJobManagerResource;
+ private String jobSubmissionInterfaceId;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_SUBMISSION);
+ generator.setParameter(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_SUBMISSION);
+ generator.setParameter(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ LocalSubmission localSubmission = (LocalSubmission) q.getSingleResult();
+ LocalSubmissionResource localSubmissionResource = (LocalSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_SUBMISSION, localSubmission);
+ em.getTransaction().commit();
+ em.close();
+ return localSubmissionResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> localSubmissionResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_SUBMISSION);
+ Query q;
+ if ((fieldName.equals(LocalSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ LocalSubmission localSubmission = (LocalSubmission) result;
+ LocalSubmissionResource localSubmissionResource = (LocalSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_SUBMISSION, localSubmission);
+ localSubmissionResources.add(localSubmissionResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return localSubmissionResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> localSubmissionResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LOCAL_SUBMISSION);
+ Query q;
+ if ((fieldName.equals(LocalSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ LocalSubmission localSubmission = (LocalSubmission) result;
+ LocalSubmissionResource localSubmissionResource = (LocalSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LOCAL_SUBMISSION, localSubmission);
+ localSubmissionResourceIDs.add(localSubmissionResource.getJobSubmissionInterfaceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return localSubmissionResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ LocalSubmission existingLocalSubmission = em.find(LocalSubmission.class, jobSubmissionInterfaceId);
+ em.close();
+ LocalSubmission localSubmission;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingLocalSubmission == null) {
+ localSubmission = new LocalSubmission();
+ localSubmission.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ localSubmission = existingLocalSubmission;
+ localSubmission.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ localSubmission.setResourceJobManagerId(getResourceJobManagerId());
+ ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
+ localSubmission.setResourceJobManager(resourceJobManager);
+ localSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
+ if (existingLocalSubmission == null) {
+ em.persist(localSubmission);
+ } else {
+ em.merge(localSubmission);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ LocalSubmission localSubmission = em.find(LocalSubmission.class, identifier);
+ em.close();
+ return localSubmission != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getResourceJobManagerId() {
+ return resourceJobManagerId;
+ }
+
+ public ResourceJobManagerResource getResourceJobManagerResource() {
+ return resourceJobManagerResource;
+ }
+
+ public String getJobSubmissionInterfaceId() {
+ return jobSubmissionInterfaceId;
+ }
+
+ public void setResourceJobManagerId(String resourceJobManagerId) {
+ this.resourceJobManagerId=resourceJobManagerId;
+ }
+
+ public void setResourceJobManagerResource(ResourceJobManagerResource resourceJobManagerResource) {
+ this.resourceJobManagerResource=resourceJobManagerResource;
+ }
+
+ public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
+ this.jobSubmissionInterfaceId=jobSubmissionInterfaceId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdAppCatalogResourceAppCat.java
deleted file mode 100644
index 0cc2bde..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,300 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
-import org.apache.airavata.registry.core.app.catalog.model.ModuleLoadCmd;
-import org.apache.airavata.registry.core.app.catalog.model.ModuleLoadCmd_PK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ModuleLoadCmdAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(ModuleLoadCmdAppCatalogResourceAppCat.class);
- private String cmd;
- private String appDeploymentId;
- private AppDeploymentAppCatalogResourceAppCat appDeploymentResource;
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(MODULE_LOAD_CMD);
- generator.setParameter(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, ids.get(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID));
- if (ids.get(ModuleLoadCmdConstants.CMD) != null){
- generator.setParameter(ModuleLoadCmdConstants.CMD, ids.get(ModuleLoadCmdConstants.CMD));
- }
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(MODULE_LOAD_CMD);
- generator.setParameter(ModuleLoadCmdConstants.CMD, ids.get(ModuleLoadCmdConstants.CMD));
- generator.setParameter(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, ids.get(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID));
- Query q = generator.selectQuery(em);
- ModuleLoadCmd moduleLoadCmd = (ModuleLoadCmd) q.getSingleResult();
- ModuleLoadCmdAppCatalogResourceAppCat moduleLoadCmdResource = (ModuleLoadCmdAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.MODULE_LOAD_CMD, moduleLoadCmd);
- em.getTransaction().commit();
- em.close();
- return moduleLoadCmdResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> moduleLoadCmdResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(MODULE_LOAD_CMD);
- Query q;
- if ((fieldName.equals(ModuleLoadCmdConstants.CMD)) || (fieldName.equals(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ModuleLoadCmd moduleLoadCmd = (ModuleLoadCmd) result;
- ModuleLoadCmdAppCatalogResourceAppCat moduleLoadCmdResource = (ModuleLoadCmdAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.MODULE_LOAD_CMD, moduleLoadCmd);
- moduleLoadCmdResources.add(moduleLoadCmdResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Module Load Cmd Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Module Load Cmd Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return moduleLoadCmdResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> moduleLoadCmdResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(MODULE_LOAD_CMD);
- Query q;
- if ((fieldName.equals(ModuleLoadCmdConstants.CMD)) || (fieldName.equals(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ModuleLoadCmd moduleLoadCmd = (ModuleLoadCmd) result;
- ModuleLoadCmdAppCatalogResourceAppCat moduleLoadCmdResource = (ModuleLoadCmdAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.MODULE_LOAD_CMD, moduleLoadCmd);
- moduleLoadCmdResourceIDs.add(moduleLoadCmdResource.getAppDeploymentId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Module Load Cmd Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Module Load Cmd Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return moduleLoadCmdResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ModuleLoadCmd existingModuleLoadCmd = em.find(ModuleLoadCmd.class, new ModuleLoadCmd_PK(cmd, appDeploymentId));
- em.close();
- ModuleLoadCmd moduleLoadCmd;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingModuleLoadCmd == null) {
- moduleLoadCmd = new ModuleLoadCmd();
- } else {
- moduleLoadCmd = existingModuleLoadCmd;
- }
- moduleLoadCmd.setCmd(getCmd());
- moduleLoadCmd.setAppDeploymentId(getAppDeploymentId());
- ApplicationDeployment applicationDeployment = em.find(ApplicationDeployment.class, getAppDeploymentId());
- moduleLoadCmd.setApplicationDeployment(applicationDeployment);
- if (existingModuleLoadCmd == null) {
- em.persist(moduleLoadCmd);
- } else {
- em.merge(moduleLoadCmd);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ModuleLoadCmd moduleLoadCmd = em.find(ModuleLoadCmd.class, new ModuleLoadCmd_PK(ids.get(ModuleLoadCmdConstants.CMD), ids.get(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID)));
- em.close();
- return moduleLoadCmd != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getCmd() {
- return cmd;
- }
-
- public String getAppDeploymentId() {
- return appDeploymentId;
- }
-
- public AppDeploymentAppCatalogResourceAppCat getAppDeploymentResource() {
- return appDeploymentResource;
- }
-
- public void setCmd(String cmd) {
- this.cmd=cmd;
- }
-
- public void setAppDeploymentId(String appDeploymentId) {
- this.appDeploymentId=appDeploymentId;
- }
-
- public void setAppDeploymentResource(AppDeploymentAppCatalogResourceAppCat appDeploymentResource) {
- this.appDeploymentResource=appDeploymentResource;
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
new file mode 100644
index 0000000..43c6106
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
@@ -0,0 +1,300 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
+import org.apache.airavata.registry.core.app.catalog.model.ModuleLoadCmd;
+import org.apache.airavata.registry.core.app.catalog.model.ModuleLoadCmd_PK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ModuleLoadCmdResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ModuleLoadCmdResource.class);
+ private String cmd;
+ private String appDeploymentId;
+ private AppDeploymentResource appDeploymentResource;
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(MODULE_LOAD_CMD);
+ generator.setParameter(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, ids.get(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID));
+ if (ids.get(ModuleLoadCmdConstants.CMD) != null){
+ generator.setParameter(ModuleLoadCmdConstants.CMD, ids.get(ModuleLoadCmdConstants.CMD));
+ }
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(MODULE_LOAD_CMD);
+ generator.setParameter(ModuleLoadCmdConstants.CMD, ids.get(ModuleLoadCmdConstants.CMD));
+ generator.setParameter(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, ids.get(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID));
+ Query q = generator.selectQuery(em);
+ ModuleLoadCmd moduleLoadCmd = (ModuleLoadCmd) q.getSingleResult();
+ ModuleLoadCmdResource moduleLoadCmdResource = (ModuleLoadCmdResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.MODULE_LOAD_CMD, moduleLoadCmd);
+ em.getTransaction().commit();
+ em.close();
+ return moduleLoadCmdResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> moduleLoadCmdResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(MODULE_LOAD_CMD);
+ Query q;
+ if ((fieldName.equals(ModuleLoadCmdConstants.CMD)) || (fieldName.equals(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ModuleLoadCmd moduleLoadCmd = (ModuleLoadCmd) result;
+ ModuleLoadCmdResource moduleLoadCmdResource = (ModuleLoadCmdResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.MODULE_LOAD_CMD, moduleLoadCmd);
+ moduleLoadCmdResources.add(moduleLoadCmdResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Module Load Cmd Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Module Load Cmd Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return moduleLoadCmdResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> moduleLoadCmdResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(MODULE_LOAD_CMD);
+ Query q;
+ if ((fieldName.equals(ModuleLoadCmdConstants.CMD)) || (fieldName.equals(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ModuleLoadCmd moduleLoadCmd = (ModuleLoadCmd) result;
+ ModuleLoadCmdResource moduleLoadCmdResource = (ModuleLoadCmdResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.MODULE_LOAD_CMD, moduleLoadCmd);
+ moduleLoadCmdResourceIDs.add(moduleLoadCmdResource.getAppDeploymentId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Module Load Cmd Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Module Load Cmd Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return moduleLoadCmdResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ModuleLoadCmd existingModuleLoadCmd = em.find(ModuleLoadCmd.class, new ModuleLoadCmd_PK(cmd, appDeploymentId));
+ em.close();
+ ModuleLoadCmd moduleLoadCmd;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingModuleLoadCmd == null) {
+ moduleLoadCmd = new ModuleLoadCmd();
+ } else {
+ moduleLoadCmd = existingModuleLoadCmd;
+ }
+ moduleLoadCmd.setCmd(getCmd());
+ moduleLoadCmd.setAppDeploymentId(getAppDeploymentId());
+ ApplicationDeployment applicationDeployment = em.find(ApplicationDeployment.class, getAppDeploymentId());
+ moduleLoadCmd.setApplicationDeployment(applicationDeployment);
+ if (existingModuleLoadCmd == null) {
+ em.persist(moduleLoadCmd);
+ } else {
+ em.merge(moduleLoadCmd);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ModuleLoadCmd moduleLoadCmd = em.find(ModuleLoadCmd.class, new ModuleLoadCmd_PK(ids.get(ModuleLoadCmdConstants.CMD), ids.get(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID)));
+ em.close();
+ return moduleLoadCmd != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getCmd() {
+ return cmd;
+ }
+
+ public String getAppDeploymentId() {
+ return appDeploymentId;
+ }
+
+ public AppDeploymentResource getAppDeploymentResource() {
+ return appDeploymentResource;
+ }
+
+ public void setCmd(String cmd) {
+ this.cmd=cmd;
+ }
+
+ public void setAppDeploymentId(String appDeploymentId) {
+ this.appDeploymentId=appDeploymentId;
+ }
+
+ public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) {
+ this.appDeploymentResource=appDeploymentResource;
+ }
+}
+
+
[17/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandAppCatalogResourceAppCat.java
deleted file mode 100644
index 201b45b..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,333 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
-import org.apache.airavata.registry.core.app.catalog.model.PostJobCommand;
-import org.apache.airavata.registry.core.app.catalog.model.PostJobCommandPK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class PostJobCommandAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(PostJobCommandAppCatalogResourceAppCat.class);
-
- private String appDeploymentId;
- private String command;
-
- private AppDeploymentAppCatalogResourceAppCat appDeploymentResource;
-
-
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(POST_JOBCOMMAND);
- generator.setParameter(PostJobCommandConstants.DEPLOYMENT_ID,
- ids.get(PostJobCommandConstants.DEPLOYMENT_ID));
- if (ids.get(PostJobCommandConstants.COMMAND) != null){
- generator.setParameter(PostJobCommandConstants.COMMAND, ids.get(PostJobCommandConstants.COMMAND));
- }
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(POST_JOBCOMMAND);
- generator.setParameter(PostJobCommandConstants.DEPLOYMENT_ID,
- ids.get(PostJobCommandConstants.DEPLOYMENT_ID));
- generator.setParameter(PostJobCommandConstants.COMMAND, ids.get(PostJobCommandConstants.COMMAND));
- Query q = generator.selectQuery(em);
- PostJobCommand postJobCommand = (PostJobCommand) q.getSingleResult();
- PostJobCommandAppCatalogResourceAppCat postJobCommandResource =
- (PostJobCommandAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.POST_JOBCOMMAND, postJobCommand);
- em.getTransaction().commit();
- em.close();
- return postJobCommandResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> gsiSSHPostJobCommandResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(POST_JOBCOMMAND);
- List results;
- if (fieldName.equals(PostJobCommandConstants.DEPLOYMENT_ID)) {
- generator.setParameter(PostJobCommandConstants.DEPLOYMENT_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- PostJobCommand postJobCommand = (PostJobCommand) result;
- PostJobCommandAppCatalogResourceAppCat postJobCommandResource =
- (PostJobCommandAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.POST_JOBCOMMAND, postJobCommand);
- gsiSSHPostJobCommandResources.add(postJobCommandResource);
- }
- }
- } else if (fieldName.equals(PostJobCommandConstants.COMMAND)) {
- generator.setParameter(PostJobCommandConstants.COMMAND, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- PostJobCommand postJobCommand = (PostJobCommand) result;
- PostJobCommandAppCatalogResourceAppCat postJobCommandResource =
- (PostJobCommandAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.POST_JOBCOMMAND, postJobCommand);
- gsiSSHPostJobCommandResources.add(postJobCommandResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for GSISSH Post Job Command Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for GSISSH Post Job Command Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gsiSSHPostJobCommandResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> gsiSSHPostJobResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(POST_JOBCOMMAND);
- List results;
- if (fieldName.equals(PostJobCommandConstants.DEPLOYMENT_ID)) {
- generator.setParameter(PostJobCommandConstants.DEPLOYMENT_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- PostJobCommand postJobCommand = (PostJobCommand) result;
- gsiSSHPostJobResourceIDs.add(postJobCommand.getDeploymentId());
- }
- }
- } else if (fieldName.equals(PostJobCommandConstants.COMMAND)) {
- generator.setParameter(PostJobCommandConstants.COMMAND, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- PostJobCommand postJobCommand = (PostJobCommand) result;
- gsiSSHPostJobResourceIDs.add(postJobCommand.getDeploymentId());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for GSISSH Post Job resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for GSISSH Post JOb Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gsiSSHPostJobResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- PostJobCommand existingPostJobCommand = em.find(PostJobCommand.class,
- new PostJobCommandPK(appDeploymentId, command));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- ApplicationDeployment deployment = em.find(ApplicationDeployment.class, appDeploymentId);
- if (existingPostJobCommand != null){
- existingPostJobCommand.setDeploymentId(appDeploymentId);
- existingPostJobCommand.setCommand(command);
- existingPostJobCommand.setDeployment(deployment);
- em.merge(existingPostJobCommand);
- }else {
- PostJobCommand postJobCommand = new PostJobCommand();
- postJobCommand.setDeploymentId(appDeploymentId);
- postJobCommand.setCommand(command);
- postJobCommand.setDeployment(deployment);
- em.persist(postJobCommand);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- PostJobCommand postJobCommand = em.find(PostJobCommand.class, new PostJobCommandPK(
- ids.get(PostJobCommandConstants.DEPLOYMENT_ID),
- ids.get(PostJobCommandConstants.COMMAND)));
-
- em.close();
- return postJobCommand != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getAppDeploymentId() {
- return appDeploymentId;
- }
-
- public void setAppDeploymentId(String appDeploymentId) {
- this.appDeploymentId = appDeploymentId;
- }
-
- public String getCommand() {
- return command;
- }
-
- public void setCommand(String command) {
- this.command = command;
- }
-
- public AppDeploymentAppCatalogResourceAppCat getAppDeploymentResource() {
- return appDeploymentResource;
- }
-
- public void setAppDeploymentResource(AppDeploymentAppCatalogResourceAppCat appDeploymentResource) {
- this.appDeploymentResource = appDeploymentResource;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
new file mode 100644
index 0000000..e9d770b
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
@@ -0,0 +1,333 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
+import org.apache.airavata.registry.core.app.catalog.model.PostJobCommand;
+import org.apache.airavata.registry.core.app.catalog.model.PostJobCommandPK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class PostJobCommandResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(PostJobCommandResource.class);
+
+ private String appDeploymentId;
+ private String command;
+
+ private AppDeploymentResource appDeploymentResource;
+
+
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(POST_JOBCOMMAND);
+ generator.setParameter(PostJobCommandConstants.DEPLOYMENT_ID,
+ ids.get(PostJobCommandConstants.DEPLOYMENT_ID));
+ if (ids.get(PostJobCommandConstants.COMMAND) != null){
+ generator.setParameter(PostJobCommandConstants.COMMAND, ids.get(PostJobCommandConstants.COMMAND));
+ }
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(POST_JOBCOMMAND);
+ generator.setParameter(PostJobCommandConstants.DEPLOYMENT_ID,
+ ids.get(PostJobCommandConstants.DEPLOYMENT_ID));
+ generator.setParameter(PostJobCommandConstants.COMMAND, ids.get(PostJobCommandConstants.COMMAND));
+ Query q = generator.selectQuery(em);
+ PostJobCommand postJobCommand = (PostJobCommand) q.getSingleResult();
+ PostJobCommandResource postJobCommandResource =
+ (PostJobCommandResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.POST_JOBCOMMAND, postJobCommand);
+ em.getTransaction().commit();
+ em.close();
+ return postJobCommandResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> gsiSSHPostJobCommandResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(POST_JOBCOMMAND);
+ List results;
+ if (fieldName.equals(PostJobCommandConstants.DEPLOYMENT_ID)) {
+ generator.setParameter(PostJobCommandConstants.DEPLOYMENT_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ PostJobCommand postJobCommand = (PostJobCommand) result;
+ PostJobCommandResource postJobCommandResource =
+ (PostJobCommandResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.POST_JOBCOMMAND, postJobCommand);
+ gsiSSHPostJobCommandResources.add(postJobCommandResource);
+ }
+ }
+ } else if (fieldName.equals(PostJobCommandConstants.COMMAND)) {
+ generator.setParameter(PostJobCommandConstants.COMMAND, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ PostJobCommand postJobCommand = (PostJobCommand) result;
+ PostJobCommandResource postJobCommandResource =
+ (PostJobCommandResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.POST_JOBCOMMAND, postJobCommand);
+ gsiSSHPostJobCommandResources.add(postJobCommandResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for GSISSH Post Job Command Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for GSISSH Post Job Command Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gsiSSHPostJobCommandResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> gsiSSHPostJobResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(POST_JOBCOMMAND);
+ List results;
+ if (fieldName.equals(PostJobCommandConstants.DEPLOYMENT_ID)) {
+ generator.setParameter(PostJobCommandConstants.DEPLOYMENT_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ PostJobCommand postJobCommand = (PostJobCommand) result;
+ gsiSSHPostJobResourceIDs.add(postJobCommand.getDeploymentId());
+ }
+ }
+ } else if (fieldName.equals(PostJobCommandConstants.COMMAND)) {
+ generator.setParameter(PostJobCommandConstants.COMMAND, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ PostJobCommand postJobCommand = (PostJobCommand) result;
+ gsiSSHPostJobResourceIDs.add(postJobCommand.getDeploymentId());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for GSISSH Post Job resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for GSISSH Post JOb Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gsiSSHPostJobResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ PostJobCommand existingPostJobCommand = em.find(PostJobCommand.class,
+ new PostJobCommandPK(appDeploymentId, command));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ ApplicationDeployment deployment = em.find(ApplicationDeployment.class, appDeploymentId);
+ if (existingPostJobCommand != null){
+ existingPostJobCommand.setDeploymentId(appDeploymentId);
+ existingPostJobCommand.setCommand(command);
+ existingPostJobCommand.setDeployment(deployment);
+ em.merge(existingPostJobCommand);
+ }else {
+ PostJobCommand postJobCommand = new PostJobCommand();
+ postJobCommand.setDeploymentId(appDeploymentId);
+ postJobCommand.setCommand(command);
+ postJobCommand.setDeployment(deployment);
+ em.persist(postJobCommand);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ PostJobCommand postJobCommand = em.find(PostJobCommand.class, new PostJobCommandPK(
+ ids.get(PostJobCommandConstants.DEPLOYMENT_ID),
+ ids.get(PostJobCommandConstants.COMMAND)));
+
+ em.close();
+ return postJobCommand != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getAppDeploymentId() {
+ return appDeploymentId;
+ }
+
+ public void setAppDeploymentId(String appDeploymentId) {
+ this.appDeploymentId = appDeploymentId;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ public AppDeploymentResource getAppDeploymentResource() {
+ return appDeploymentResource;
+ }
+
+ public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) {
+ this.appDeploymentResource = appDeploymentResource;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandAppCatalogResourceAppCat.java
deleted file mode 100644
index 6fe515e..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,333 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
-import org.apache.airavata.registry.core.app.catalog.model.PreJobCommand;
-import org.apache.airavata.registry.core.app.catalog.model.PreJobCommandPK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class PreJobCommandAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(PreJobCommandAppCatalogResourceAppCat.class);
-
- private String appDeploymentId;
- private String command;
-
- private AppDeploymentAppCatalogResourceAppCat appDeploymentResource;
-
-
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
- generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID,
- ids.get(PreJobCommandConstants.DEPLOYMENT_ID));
- if (ids.get(PreJobCommandConstants.COMMAND) != null){
- generator.setParameter(PreJobCommandConstants.COMMAND, ids.get(PreJobCommandConstants.COMMAND));
- }
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
- generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID,
- ids.get(PreJobCommandConstants.DEPLOYMENT_ID));
- generator.setParameter(PreJobCommandConstants.COMMAND, ids.get(PreJobCommandConstants.COMMAND));
- Query q = generator.selectQuery(em);
- PreJobCommand preJobCommand = (PreJobCommand) q.getSingleResult();
- PreJobCommandAppCatalogResourceAppCat preJobCommandResource =
- (PreJobCommandAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.PRE_JOBCOMMAND, preJobCommand);
- em.getTransaction().commit();
- em.close();
- return preJobCommandResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> gsiSSHPreJobResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
- List results;
- if (fieldName.equals(PreJobCommandConstants.DEPLOYMENT_ID)) {
- generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- PreJobCommand preJobCommand = (PreJobCommand) result;
- PreJobCommandAppCatalogResourceAppCat preJobCommandResource =
- (PreJobCommandAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.PRE_JOBCOMMAND, preJobCommand);
- gsiSSHPreJobResources.add(preJobCommandResource);
- }
- }
- } else if (fieldName.equals(PreJobCommandConstants.COMMAND)) {
- generator.setParameter(PreJobCommandConstants.COMMAND, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- PreJobCommand preJobCommand = (PreJobCommand) result;
- PreJobCommandAppCatalogResourceAppCat preJobCommandResource =
- (PreJobCommandAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.PRE_JOBCOMMAND, preJobCommand);
- gsiSSHPreJobResources.add(preJobCommandResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for GSISSH Pre Job Command Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for GSISSH Pre Job Command Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gsiSSHPreJobResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> gsiSSHPreJobResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
- List results;
- if (fieldName.equals(PreJobCommandConstants.DEPLOYMENT_ID)) {
- generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- PreJobCommand preJobCommand = (PreJobCommand) result;
- gsiSSHPreJobResourceIDs.add(preJobCommand.getDeploymentId());
- }
- }
- } else if (fieldName.equals(PreJobCommandConstants.COMMAND)) {
- generator.setParameter(PreJobCommandConstants.COMMAND, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- PreJobCommand preJobCommand = (PreJobCommand) result;
- gsiSSHPreJobResourceIDs.add(preJobCommand.getDeploymentId());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for GSISSH Pre Job resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for GSISSH Pre JOb Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gsiSSHPreJobResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- PreJobCommand existingGSIsshPreJobCommand = em.find(PreJobCommand.class,
- new PreJobCommandPK(appDeploymentId, command));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- ApplicationDeployment deployment = em.find(ApplicationDeployment.class, appDeploymentId);
- if (existingGSIsshPreJobCommand != null){
- existingGSIsshPreJobCommand.setDeploymentId(appDeploymentId);
- existingGSIsshPreJobCommand.setCommand(command);
- existingGSIsshPreJobCommand.setApplicationDeployment(deployment);
- em.merge(existingGSIsshPreJobCommand);
- }else {
- PreJobCommand preJobCommand = new PreJobCommand();
- preJobCommand.setDeploymentId(appDeploymentId);
- preJobCommand.setCommand(command);
- preJobCommand.setApplicationDeployment(deployment);
- em.persist(preJobCommand);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- PreJobCommand preJobCommand = em.find(PreJobCommand.class, new PreJobCommandPK(
- ids.get(PreJobCommandConstants.DEPLOYMENT_ID),
- ids.get(PreJobCommandConstants.COMMAND)));
-
- em.close();
- return preJobCommand != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getAppDeploymentId() {
- return appDeploymentId;
- }
-
- public void setAppDeploymentId(String appDeploymentId) {
- this.appDeploymentId = appDeploymentId;
- }
-
- public String getCommand() {
- return command;
- }
-
- public void setCommand(String command) {
- this.command = command;
- }
-
- public AppDeploymentAppCatalogResourceAppCat getAppDeploymentResource() {
- return appDeploymentResource;
- }
-
- public void setAppDeploymentResource(AppDeploymentAppCatalogResourceAppCat appDeploymentResource) {
- this.appDeploymentResource = appDeploymentResource;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
new file mode 100644
index 0000000..fcd494b
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
@@ -0,0 +1,333 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
+import org.apache.airavata.registry.core.app.catalog.model.PreJobCommand;
+import org.apache.airavata.registry.core.app.catalog.model.PreJobCommandPK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class PreJobCommandResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(PreJobCommandResource.class);
+
+ private String appDeploymentId;
+ private String command;
+
+ private AppDeploymentResource appDeploymentResource;
+
+
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
+ generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID,
+ ids.get(PreJobCommandConstants.DEPLOYMENT_ID));
+ if (ids.get(PreJobCommandConstants.COMMAND) != null){
+ generator.setParameter(PreJobCommandConstants.COMMAND, ids.get(PreJobCommandConstants.COMMAND));
+ }
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
+ generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID,
+ ids.get(PreJobCommandConstants.DEPLOYMENT_ID));
+ generator.setParameter(PreJobCommandConstants.COMMAND, ids.get(PreJobCommandConstants.COMMAND));
+ Query q = generator.selectQuery(em);
+ PreJobCommand preJobCommand = (PreJobCommand) q.getSingleResult();
+ PreJobCommandResource preJobCommandResource =
+ (PreJobCommandResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.PRE_JOBCOMMAND, preJobCommand);
+ em.getTransaction().commit();
+ em.close();
+ return preJobCommandResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> gsiSSHPreJobResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
+ List results;
+ if (fieldName.equals(PreJobCommandConstants.DEPLOYMENT_ID)) {
+ generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ PreJobCommand preJobCommand = (PreJobCommand) result;
+ PreJobCommandResource preJobCommandResource =
+ (PreJobCommandResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.PRE_JOBCOMMAND, preJobCommand);
+ gsiSSHPreJobResources.add(preJobCommandResource);
+ }
+ }
+ } else if (fieldName.equals(PreJobCommandConstants.COMMAND)) {
+ generator.setParameter(PreJobCommandConstants.COMMAND, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ PreJobCommand preJobCommand = (PreJobCommand) result;
+ PreJobCommandResource preJobCommandResource =
+ (PreJobCommandResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.PRE_JOBCOMMAND, preJobCommand);
+ gsiSSHPreJobResources.add(preJobCommandResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for GSISSH Pre Job Command Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for GSISSH Pre Job Command Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gsiSSHPreJobResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> gsiSSHPreJobResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
+ List results;
+ if (fieldName.equals(PreJobCommandConstants.DEPLOYMENT_ID)) {
+ generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ PreJobCommand preJobCommand = (PreJobCommand) result;
+ gsiSSHPreJobResourceIDs.add(preJobCommand.getDeploymentId());
+ }
+ }
+ } else if (fieldName.equals(PreJobCommandConstants.COMMAND)) {
+ generator.setParameter(PreJobCommandConstants.COMMAND, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ PreJobCommand preJobCommand = (PreJobCommand) result;
+ gsiSSHPreJobResourceIDs.add(preJobCommand.getDeploymentId());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for GSISSH Pre Job resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for GSISSH Pre JOb Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gsiSSHPreJobResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ PreJobCommand existingGSIsshPreJobCommand = em.find(PreJobCommand.class,
+ new PreJobCommandPK(appDeploymentId, command));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ ApplicationDeployment deployment = em.find(ApplicationDeployment.class, appDeploymentId);
+ if (existingGSIsshPreJobCommand != null){
+ existingGSIsshPreJobCommand.setDeploymentId(appDeploymentId);
+ existingGSIsshPreJobCommand.setCommand(command);
+ existingGSIsshPreJobCommand.setApplicationDeployment(deployment);
+ em.merge(existingGSIsshPreJobCommand);
+ }else {
+ PreJobCommand preJobCommand = new PreJobCommand();
+ preJobCommand.setDeploymentId(appDeploymentId);
+ preJobCommand.setCommand(command);
+ preJobCommand.setApplicationDeployment(deployment);
+ em.persist(preJobCommand);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ PreJobCommand preJobCommand = em.find(PreJobCommand.class, new PreJobCommandPK(
+ ids.get(PreJobCommandConstants.DEPLOYMENT_ID),
+ ids.get(PreJobCommandConstants.COMMAND)));
+
+ em.close();
+ return preJobCommand != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getAppDeploymentId() {
+ return appDeploymentId;
+ }
+
+ public void setAppDeploymentId(String appDeploymentId) {
+ this.appDeploymentId = appDeploymentId;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setCommand(String command) {
+ this.command = command;
+ }
+
+ public AppDeploymentResource getAppDeploymentResource() {
+ return appDeploymentResource;
+ }
+
+ public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) {
+ this.appDeploymentResource = appDeploymentResource;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerAppCatalogResourceAppCat.java
deleted file mode 100644
index 19e65a3..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,301 +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.registry.core.app.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ResourceJobManagerAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(ResourceJobManagerAppCatalogResourceAppCat.class);
- private String resourceJobManagerId;
- private String pushMonitoringEndpoint;
- private String jobManagerBinPath;
- private String resourceJobManagerType;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
- generator.setParameter(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
- generator.setParameter(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID, identifier);
- Query q = generator.selectQuery(em);
- ResourceJobManager resourceJobManager = (ResourceJobManager) q.getSingleResult();
- ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource = (ResourceJobManagerAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.RESOURCE_JOB_MANAGER, resourceJobManager);
- em.getTransaction().commit();
- em.close();
- return resourceJobManagerResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> resourceJobManagerResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
- Query q;
- if ((fieldName.equals(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(ResourceJobManagerConstants.PUSH_MONITORING_ENDPOINT)) || (fieldName.equals(ResourceJobManagerConstants.JOB_MANAGER_BIN_PATH)) || (fieldName.equals(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_TYPE))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ResourceJobManager resourceJobManager = (ResourceJobManager) result;
- ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource = (ResourceJobManagerAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.RESOURCE_JOB_MANAGER, resourceJobManager);
- resourceJobManagerResources.add(resourceJobManagerResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Resource Job Manager Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Resource Job Manager Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceJobManagerResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> resourceJobManagerResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
- Query q;
- if ((fieldName.equals(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(ResourceJobManagerConstants.PUSH_MONITORING_ENDPOINT)) || (fieldName.equals(ResourceJobManagerConstants.JOB_MANAGER_BIN_PATH)) || (fieldName.equals(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_TYPE))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ResourceJobManager resourceJobManager = (ResourceJobManager) result;
- ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource = (ResourceJobManagerAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.RESOURCE_JOB_MANAGER, resourceJobManager);
- resourceJobManagerResourceIDs.add(resourceJobManagerResource.getResourceJobManagerId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Resource Job Manager Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Resource Job Manager Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceJobManagerResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ResourceJobManager existingResourceJobManager = em.find(ResourceJobManager.class, resourceJobManagerId);
- em.close();
- ResourceJobManager resourceJobManager;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingResourceJobManager == null) {
- resourceJobManager = new ResourceJobManager();
- resourceJobManager.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- resourceJobManager = existingResourceJobManager;
- resourceJobManager.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- resourceJobManager.setResourceJobManagerId(getResourceJobManagerId());
- resourceJobManager.setPushMonitoringEndpoint(getPushMonitoringEndpoint());
- resourceJobManager.setJobManagerBinPath(getJobManagerBinPath());
- resourceJobManager.setResourceJobManagerType(getResourceJobManagerType());
- if (existingResourceJobManager == null) {
- em.persist(resourceJobManager);
- } else {
- em.merge(resourceJobManager);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, identifier);
- em.close();
- return resourceJobManager != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getResourceJobManagerId() {
- return resourceJobManagerId;
- }
-
- public String getPushMonitoringEndpoint() {
- return pushMonitoringEndpoint;
- }
-
- public String getJobManagerBinPath() {
- return jobManagerBinPath;
- }
-
- public String getResourceJobManagerType() {
- return resourceJobManagerType;
- }
-
- public void setResourceJobManagerId(String resourceJobManagerId) {
- this.resourceJobManagerId=resourceJobManagerId;
- }
-
- public void setPushMonitoringEndpoint(String pushMonitoringEndpoint) {
- this.pushMonitoringEndpoint=pushMonitoringEndpoint;
- }
-
- public void setJobManagerBinPath(String jobManagerBinPath) {
- this.jobManagerBinPath=jobManagerBinPath;
- }
-
- public void setResourceJobManagerType(String resourceJobManagerType) {
- this.resourceJobManagerType=resourceJobManagerType;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerResource.java
new file mode 100644
index 0000000..e84506c
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ResourceJobManagerResource.java
@@ -0,0 +1,301 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ResourceJobManagerResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ResourceJobManagerResource.class);
+ private String resourceJobManagerId;
+ private String pushMonitoringEndpoint;
+ private String jobManagerBinPath;
+ private String resourceJobManagerType;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
+ generator.setParameter(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
+ generator.setParameter(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID, identifier);
+ Query q = generator.selectQuery(em);
+ ResourceJobManager resourceJobManager = (ResourceJobManager) q.getSingleResult();
+ ResourceJobManagerResource resourceJobManagerResource = (ResourceJobManagerResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.RESOURCE_JOB_MANAGER, resourceJobManager);
+ em.getTransaction().commit();
+ em.close();
+ return resourceJobManagerResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> resourceJobManagerResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
+ Query q;
+ if ((fieldName.equals(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(ResourceJobManagerConstants.PUSH_MONITORING_ENDPOINT)) || (fieldName.equals(ResourceJobManagerConstants.JOB_MANAGER_BIN_PATH)) || (fieldName.equals(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_TYPE))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ResourceJobManager resourceJobManager = (ResourceJobManager) result;
+ ResourceJobManagerResource resourceJobManagerResource = (ResourceJobManagerResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.RESOURCE_JOB_MANAGER, resourceJobManager);
+ resourceJobManagerResources.add(resourceJobManagerResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Resource Job Manager Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Resource Job Manager Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceJobManagerResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> resourceJobManagerResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(RESOURCE_JOB_MANAGER);
+ Query q;
+ if ((fieldName.equals(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(ResourceJobManagerConstants.PUSH_MONITORING_ENDPOINT)) || (fieldName.equals(ResourceJobManagerConstants.JOB_MANAGER_BIN_PATH)) || (fieldName.equals(ResourceJobManagerConstants.RESOURCE_JOB_MANAGER_TYPE))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ResourceJobManager resourceJobManager = (ResourceJobManager) result;
+ ResourceJobManagerResource resourceJobManagerResource = (ResourceJobManagerResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.RESOURCE_JOB_MANAGER, resourceJobManager);
+ resourceJobManagerResourceIDs.add(resourceJobManagerResource.getResourceJobManagerId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Resource Job Manager Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Resource Job Manager Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceJobManagerResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ResourceJobManager existingResourceJobManager = em.find(ResourceJobManager.class, resourceJobManagerId);
+ em.close();
+ ResourceJobManager resourceJobManager;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingResourceJobManager == null) {
+ resourceJobManager = new ResourceJobManager();
+ resourceJobManager.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ resourceJobManager = existingResourceJobManager;
+ resourceJobManager.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ resourceJobManager.setResourceJobManagerId(getResourceJobManagerId());
+ resourceJobManager.setPushMonitoringEndpoint(getPushMonitoringEndpoint());
+ resourceJobManager.setJobManagerBinPath(getJobManagerBinPath());
+ resourceJobManager.setResourceJobManagerType(getResourceJobManagerType());
+ if (existingResourceJobManager == null) {
+ em.persist(resourceJobManager);
+ } else {
+ em.merge(resourceJobManager);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, identifier);
+ em.close();
+ return resourceJobManager != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getResourceJobManagerId() {
+ return resourceJobManagerId;
+ }
+
+ public String getPushMonitoringEndpoint() {
+ return pushMonitoringEndpoint;
+ }
+
+ public String getJobManagerBinPath() {
+ return jobManagerBinPath;
+ }
+
+ public String getResourceJobManagerType() {
+ return resourceJobManagerType;
+ }
+
+ public void setResourceJobManagerId(String resourceJobManagerId) {
+ this.resourceJobManagerId=resourceJobManagerId;
+ }
+
+ public void setPushMonitoringEndpoint(String pushMonitoringEndpoint) {
+ this.pushMonitoringEndpoint=pushMonitoringEndpoint;
+ }
+
+ public void setJobManagerBinPath(String jobManagerBinPath) {
+ this.jobManagerBinPath=jobManagerBinPath;
+ }
+
+ public void setResourceJobManagerType(String resourceJobManagerType) {
+ this.resourceJobManagerType=resourceJobManagerType;
+ }
+}
[29/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-service/src/test/resources/expcatalog-derby.sql
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/test/resources/expcatalog-derby.sql b/modules/orchestrator/orchestrator-service/src/test/resources/expcatalog-derby.sql
new file mode 100644
index 0000000..7ab3755
--- /dev/null
+++ b/modules/orchestrator/orchestrator-service/src/test/resources/expcatalog-derby.sql
@@ -0,0 +1,391 @@
+/*
+ *
+ * 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.
+ *
+ */
+CREATE TABLE GATEWAY
+(
+ GATEWAY_ID VARCHAR (255),
+ GATEWAY_NAME VARCHAR(255),
+ DOMAIN VARCHAR(255),
+ EMAIL_ADDRESS VARCHAR(255),
+ PRIMARY KEY (GATEWAY_ID)
+);
+
+CREATE TABLE CONFIGURATION
+(
+ CONFIG_KEY VARCHAR(255),
+ CONFIG_VAL VARCHAR(255),
+ EXPIRE_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ CATEGORY_ID VARCHAR (255),
+ PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
+);
+
+INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version', '0.15', CURRENT_TIMESTAMP ,'SYSTEM');
+
+CREATE TABLE USERS
+(
+ USER_NAME VARCHAR(255),
+ PASSWORD VARCHAR(255),
+ PRIMARY KEY(USER_NAME)
+);
+
+CREATE TABLE GATEWAY_WORKER
+(
+ GATEWAY_ID VARCHAR(255),
+ USER_NAME VARCHAR(255),
+ PRIMARY KEY (GATEWAY_ID, USER_NAME),
+ FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE,
+ FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
+);
+
+CREATE TABLE PROJECT
+(
+ GATEWAY_ID VARCHAR(255),
+ USER_NAME VARCHAR(255) NOT NULL,
+ PROJECT_ID VARCHAR(255),
+ PROJECT_NAME VARCHAR(255) NOT NULL,
+ DESCRIPTION VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (PROJECT_ID),
+ FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE,
+ FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
+);
+
+CREATE TABLE PROJECT_USER
+(
+ PROJECT_ID VARCHAR(255),
+ USER_NAME VARCHAR(255),
+ PRIMARY KEY (PROJECT_ID,USER_NAME),
+ FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
+);
+
+CREATE TABLE EXPERIMENT
+(
+ EXPERIMENT_ID VARCHAR(255),
+ GATEWAY_ID VARCHAR(255),
+ EXECUTION_USER VARCHAR(255) NOT NULL,
+ PROJECT_ID VARCHAR(255) NOT NULL,
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ EXPERIMENT_NAME VARCHAR(255) NOT NULL,
+ EXPERIMENT_DESCRIPTION VARCHAR(255),
+ APPLICATION_ID VARCHAR(255),
+ APPLICATION_VERSION VARCHAR(255),
+ WORKFLOW_TEMPLATE_ID VARCHAR(255),
+ WORKFLOW_TEMPLATE_VERSION VARCHAR(255),
+ WORKFLOW_EXECUTION_ID VARCHAR(255),
+ ALLOW_NOTIFICATION SMALLINT,
+ GATEWAY_EXECUTION_ID VARCHAR(255),
+ PRIMARY KEY(EXPERIMENT_ID),
+ FOREIGN KEY (GATEWAY_ID) REFERENCES GATEWAY(GATEWAY_ID) ON DELETE CASCADE,
+ FOREIGN KEY (EXECUTION_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE,
+ FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE EXPERIMENT_INPUT
+(
+ EXPERIMENT_ID VARCHAR(255),
+ INPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ METADATA VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ STANDARD_INPUT SMALLINT,
+ USER_FRIENDLY_DESC VARCHAR(255),
+ VALUE CLOB,
+ INPUT_ORDER INTEGER,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_STAGED SMALLINT,
+ PRIMARY KEY(EXPERIMENT_ID,INPUT_KEY),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE EXPERIMENT_OUTPUT
+(
+ EXPERIMENT_ID VARCHAR(255),
+ OUTPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ VALUE CLOB,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_MOVEMENT SMALLINT,
+ DATA_NAME_LOCATION VARCHAR(255),
+ SEARCH_QUERY VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ PRIMARY KEY(EXPERIMENT_ID,OUTPUT_KEY),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
+);
+
+
+CREATE TABLE WORKFLOW_NODE_DETAIL
+(
+ EXPERIMENT_ID VARCHAR(255) NOT NULL,
+ NODE_INSTANCE_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ NODE_NAME VARCHAR(255) NOT NULL,
+ EXECUTION_UNIT VARCHAR(255) NOT NULL,
+ EXECUTION_UNIT_DATA VARCHAR(255),
+ PRIMARY KEY(NODE_INSTANCE_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE TASK_DETAIL
+(
+ TASK_ID VARCHAR(255),
+ NODE_INSTANCE_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ APPLICATION_ID VARCHAR(255),
+ APPLICATION_VERSION VARCHAR(255),
+ APPLICATION_DEPLOYMENT_ID VARCHAR(255),
+ ALLOW_NOTIFICATION SMALLINT,
+ PRIMARY KEY(TASK_ID),
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE NOTIFICATION_EMAIL
+(
+ EMAIL_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ EMAIL_ADDRESS VARCHAR(255),
+ PRIMARY KEY(EMAIL_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE ERROR_DETAIL
+(
+ ERROR_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ NODE_INSTANCE_ID VARCHAR(255),
+ JOB_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ ACTUAL_ERROR_MESSAGE CLOB,
+ USER_FRIEDNLY_ERROR_MSG VARCHAR(255),
+ TRANSIENT_OR_PERSISTENT SMALLINT,
+ ERROR_CATEGORY VARCHAR(255),
+ CORRECTIVE_ACTION VARCHAR(255),
+ ACTIONABLE_GROUP VARCHAR(255),
+ PRIMARY KEY(ERROR_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE APPLICATION_INPUT
+(
+ TASK_ID VARCHAR(255),
+ INPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ METADATA VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ STANDARD_INPUT SMALLINT,
+ USER_FRIENDLY_DESC VARCHAR(255),
+ VALUE CLOB,
+ INPUT_ORDER INTEGER,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_STAGED SMALLINT,
+ PRIMARY KEY(TASK_ID,INPUT_KEY),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE APPLICATION_OUTPUT
+(
+ TASK_ID VARCHAR(255),
+ OUTPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ VALUE CLOB,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_MOVEMENT SMALLINT,
+ DATA_NAME_LOCATION VARCHAR(255),
+ SEARCH_QUERY VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ PRIMARY KEY(TASK_ID,OUTPUT_KEY),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE NODE_INPUT
+(
+ NODE_INSTANCE_ID VARCHAR(255),
+ INPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ METADATA VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ STANDARD_INPUT SMALLINT,
+ USER_FRIENDLY_DESC VARCHAR(255),
+ VALUE VARCHAR(255),
+ INPUT_ORDER INTEGER,
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_STAGED SMALLINT,
+ PRIMARY KEY(NODE_INSTANCE_ID,INPUT_KEY),
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE NODE_OUTPUT
+(
+ NODE_INSTANCE_ID VARCHAR(255),
+ OUTPUT_KEY VARCHAR(255) NOT NULL,
+ DATA_TYPE VARCHAR(255),
+ VALUE VARCHAR(255),
+ IS_REQUIRED SMALLINT,
+ REQUIRED_TO_COMMANDLINE SMALLINT,
+ DATA_MOVEMENT SMALLINT,
+ DATA_NAME_LOCATION VARCHAR(255),
+ SEARCH_QUERY VARCHAR(255),
+ APP_ARGUMENT VARCHAR(255),
+ PRIMARY KEY(NODE_INSTANCE_ID,OUTPUT_KEY),
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE JOB_DETAIL
+(
+ JOB_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ JOB_DESCRIPTION CLOB NOT NULL,
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ COMPUTE_RESOURCE_CONSUMED VARCHAR(255),
+ JOBNAME VARCHAR (255),
+ WORKING_DIR VARCHAR(255),
+ PRIMARY KEY (TASK_ID, JOB_ID),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE DATA_TRANSFER_DETAIL
+(
+ TRANSFER_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ TRANSFER_DESC VARCHAR(255) NOT NULL,
+ PRIMARY KEY(TRANSFER_ID),
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE STATUS
+(
+ STATUS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ NODE_INSTANCE_ID VARCHAR(255),
+ TRANSFER_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ JOB_ID VARCHAR(255),
+ STATE VARCHAR(255),
+ STATUS_UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ STATUS_TYPE VARCHAR(255),
+ PRIMARY KEY(STATUS_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
+ FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TRANSFER_ID) REFERENCES DATA_TRANSFER_DETAIL(TRANSFER_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE CONFIG_DATA
+(
+ EXPERIMENT_ID VARCHAR(255),
+ AIRAVATA_AUTO_SCHEDULE SMALLINT NOT NULL,
+ OVERRIDE_MANUAL_SCHEDULE_PARAMS SMALLINT NOT NULL,
+ SHARE_EXPERIMENT SMALLINT,
+ USER_DN VARCHAR(255),
+ GENERATE_CERT SMALLINT,
+ PRIMARY KEY(EXPERIMENT_ID)
+);
+
+CREATE TABLE COMPUTATIONAL_RESOURCE_SCHEDULING
+(
+ RESOURCE_SCHEDULING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ RESOURCE_HOST_ID VARCHAR(255),
+ CPU_COUNT INTEGER,
+ NODE_COUNT INTEGER,
+ NO_OF_THREADS INTEGER,
+ QUEUE_NAME VARCHAR(255),
+ WALLTIME_LIMIT INTEGER,
+ JOB_START_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
+ TOTAL_PHYSICAL_MEMORY INTEGER,
+ COMPUTATIONAL_PROJECT_ACCOUNT VARCHAR(255),
+ CHESSIS_NAME VARCHAR(255),
+ PRIMARY KEY(RESOURCE_SCHEDULING_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE ADVANCE_INPUT_DATA_HANDLING
+(
+ INPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ WORKING_DIR_PARENT VARCHAR(255),
+ UNIQUE_WORKING_DIR VARCHAR(255),
+ STAGE_INPUT_FILES_TO_WORKING_DIR SMALLINT,
+ CLEAN_AFTER_JOB SMALLINT,
+ PRIMARY KEY(INPUT_DATA_HANDLING_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE ADVANCE_OUTPUT_DATA_HANDLING
+(
+ OUTPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ OUTPUT_DATA_DIR VARCHAR(255),
+ DATA_REG_URL VARCHAR (255),
+ PERSIST_OUTPUT_DATA SMALLINT,
+ PRIMARY KEY(OUTPUT_DATA_HANDLING_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE QOS_PARAM
+(
+ QOS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ EXPERIMENT_ID VARCHAR(255),
+ TASK_ID VARCHAR(255),
+ START_EXECUTION_AT VARCHAR(255),
+ EXECUTE_BEFORE VARCHAR(255),
+ NO_OF_RETRIES INTEGER,
+ PRIMARY KEY(QOS_ID),
+ FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
+ FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
+);
+
+CREATE TABLE COMMUNITY_USER
+(
+ GATEWAY_ID VARCHAR(256) NOT NULL,
+ COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
+ TOKEN_ID VARCHAR(256) NOT NULL,
+ COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
+ PRIMARY KEY (GATEWAY_ID, COMMUNITY_USER_NAME, TOKEN_ID)
+);
+
+CREATE TABLE CREDENTIALS
+(
+ GATEWAY_ID VARCHAR(256) NOT NULL,
+ TOKEN_ID VARCHAR(256) NOT NULL,
+ CREDENTIAL BLOB NOT NULL,
+ PORTAL_USER_ID VARCHAR(256) NOT NULL,
+ TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
+);
+
+
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-service/src/test/resources/gsissh.properties~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/test/resources/gsissh.properties~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa b/modules/orchestrator/orchestrator-service/src/test/resources/gsissh.properties~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa
deleted file mode 100644
index 3fdf76d..0000000
--- a/modules/orchestrator/orchestrator-service/src/test/resources/gsissh.properties~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa
+++ /dev/null
@@ -1,26 +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.
-#
-
-###########################################################################
-# Specifies system level configurations as a key/value pairs.
-###########################################################################
-
-StrictHostKeyChecking=no
-ssh.session.timeout=360000
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-service/src/test/resources/gsissh.properties~HEAD
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/test/resources/gsissh.properties~HEAD b/modules/orchestrator/orchestrator-service/src/test/resources/gsissh.properties~HEAD
deleted file mode 100644
index 3fdf76d..0000000
--- a/modules/orchestrator/orchestrator-service/src/test/resources/gsissh.properties~HEAD
+++ /dev/null
@@ -1,26 +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.
-#
-
-###########################################################################
-# Specifies system level configurations as a key/value pairs.
-###########################################################################
-
-StrictHostKeyChecking=no
-ssh.session.timeout=360000
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-service/src/test/resources/monitor.properties~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/test/resources/monitor.properties~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa b/modules/orchestrator/orchestrator-service/src/test/resources/monitor.properties~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa
deleted file mode 100644
index 7f0299a..0000000
--- a/modules/orchestrator/orchestrator-service/src/test/resources/monitor.properties~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa
+++ /dev/null
@@ -1,30 +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.
-#
-
-primaryMonitor=org.apache.airavata.gfac.monitor.impl.push.amqp.AMQPMonitor
-secondaryMonitor=org.apache.airavata.gfac.monitor.impl.pull.qstat.QstatMonitor
-amqp.hosts=info1.dyn.teragrid.org,info2.dyn.teragrid.org
-connection.name=xsede_private
-trusted.certificate.location=/Users/chathuri/dev/airavata/cert/certificates
-certificate.path=/Users/chathuri/dev/airavata/cert/certificates
-myproxy.server=myproxy.teragrid.org
-myproxy.user=ogce
-myproxy.password=
-myproxy.life=3600
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-service/src/test/resources/monitor.properties~HEAD
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/test/resources/monitor.properties~HEAD b/modules/orchestrator/orchestrator-service/src/test/resources/monitor.properties~HEAD
deleted file mode 100644
index 7f0299a..0000000
--- a/modules/orchestrator/orchestrator-service/src/test/resources/monitor.properties~HEAD
+++ /dev/null
@@ -1,30 +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.
-#
-
-primaryMonitor=org.apache.airavata.gfac.monitor.impl.push.amqp.AMQPMonitor
-secondaryMonitor=org.apache.airavata.gfac.monitor.impl.pull.qstat.QstatMonitor
-amqp.hosts=info1.dyn.teragrid.org,info2.dyn.teragrid.org
-connection.name=xsede_private
-trusted.certificate.location=/Users/chathuri/dev/airavata/cert/certificates
-certificate.path=/Users/chathuri/dev/airavata/cert/certificates
-myproxy.server=myproxy.teragrid.org
-myproxy.user=ogce
-myproxy.password=
-myproxy.life=3600
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql b/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql
deleted file mode 100644
index 9ed5ca9..0000000
--- a/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql
+++ /dev/null
@@ -1,361 +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.
- *
- */
-CREATE TABLE GATEWAY
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME)
-);
-
-CREATE TABLE CONFIGURATION
-(
- CONFIG_KEY VARCHAR(255),
- CONFIG_VAL VARCHAR(255),
- EXPIRE_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- CATEGORY_ID VARCHAR (255),
- PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
-);
-
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version', '0.12', CURRENT_TIMESTAMP ,'SYSTEM');
-
-CREATE TABLE USERS
-(
- USER_NAME VARCHAR(255),
- PASSWORD VARCHAR(255),
- PRIMARY KEY(USER_NAME)
-);
-
-CREATE TABLE GATEWAY_WORKER
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME, USER_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255),
- PROJECT_NAME VARCHAR(255) NOT NULL,
- DESCRIPTION VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (PROJECT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT_USER
-(
- PROJECT_ID VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (PROJECT_ID,USER_NAME),
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PUBLISHED_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- CREATED_USER VARCHAR(255),
- PUBLISH_WORKFLOW_NAME VARCHAR(255),
- VERSION VARCHAR(255),
- PUBLISHED_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- PATH VARCHAR (255),
- WORKFLOW_CONTENT BLOB,
- PRIMARY KEY(GATEWAY_NAME, PUBLISH_WORKFLOW_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (CREATED_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE USER_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- TEMPLATE_NAME VARCHAR(255),
- LAST_UPDATED_TIME TIMESTAMP DEFAULT CURRENT TIMESTAMP,
- PATH VARCHAR (255),
- WORKFLOW_GRAPH BLOB,
- PRIMARY KEY(GATEWAY_NAME, OWNER, TEMPLATE_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (OWNER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT
-(
- EXPERIMENT_ID VARCHAR(255),
- GATEWAY_NAME VARCHAR(255),
- EXECUTION_USER VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255) NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- EXPERIMENT_NAME VARCHAR(255) NOT NULL,
- EXPERIMENT_DESCRIPTION VARCHAR(255),
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- WORKFLOW_TEMPLATE_ID VARCHAR(255),
- WORKFLOW_TEMPLATE_VERSION VARCHAR(255),
- WORKFLOW_EXECUTION_ID VARCHAR(255),
- PRIMARY KEY(EXPERIMENT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (EXECUTION_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE,
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_INPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,INPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_OUTPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,OUTPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-
-CREATE TABLE WORKFLOW_NODE_DETAIL
-(
- EXPERIMENT_ID VARCHAR(255) NOT NULL,
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- NODE_NAME VARCHAR(255) NOT NULL,
- EXECUTION_UNIT VARCHAR(255) NOT NULL,
- EXECUTION_UNIT_DATA VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE TASK_DETAIL
-(
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- APPLICATION_DEPLOYMENT_ID VARCHAR(255),
- PRIMARY KEY(TASK_ID),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ERROR_DETAIL
-(
- ERROR_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- ACTUAL_ERROR_MESSAGE CLOB,
- USER_FRIEDNLY_ERROR_MSG VARCHAR(255),
- TRANSIENT_OR_PERSISTENT SMALLINT,
- ERROR_CATEGORY VARCHAR(255),
- CORRECTIVE_ACTION VARCHAR(255),
- ACTIONABLE_GROUP VARCHAR(255),
- PRIMARY KEY(ERROR_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_INPUT
-(
- TASK_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,INPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_OUTPUT
-(
- TASK_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,OUTPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_INPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,INPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_OUTPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,OUTPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE JOB_DETAIL
-(
- JOB_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_DESCRIPTION CLOB NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- COMPUTE_RESOURCE_CONSUMED VARCHAR(255),
- PRIMARY KEY (TASK_ID, JOB_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE DATA_TRANSFER_DETAIL
-(
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- TRANSFER_DESC CLOB NOT NULL,
- PRIMARY KEY(TRANSFER_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE STATUS
-(
- STATUS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- STATE VARCHAR(255),
- STATUS_UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- STATUS_TYPE VARCHAR(255),
- PRIMARY KEY(STATUS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE,
- FOREIGN KEY (TRANSFER_ID) REFERENCES DATA_TRANSFER_DETAIL(TRANSFER_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE CONFIG_DATA
-(
- EXPERIMENT_ID VARCHAR(255),
- AIRAVATA_AUTO_SCHEDULE SMALLINT NOT NULL,
- OVERRIDE_MANUAL_SCHEDULE_PARAMS SMALLINT NOT NULL,
- SHARE_EXPERIMENT SMALLINT,
- PRIMARY KEY(EXPERIMENT_ID)
-);
-
-CREATE TABLE COMPUTATIONAL_RESOURCE_SCHEDULING
-(
- RESOURCE_SCHEDULING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- RESOURCE_HOST_ID VARCHAR(255),
- CPU_COUNT INTEGER,
- NODE_COUNT INTEGER,
- NO_OF_THREADS INTEGER,
- QUEUE_NAME VARCHAR(255),
- WALLTIME_LIMIT INTEGER,
- JOB_START_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- TOTAL_PHYSICAL_MEMORY INTEGER,
- COMPUTATIONAL_PROJECT_ACCOUNT VARCHAR(255),
- PRIMARY KEY(RESOURCE_SCHEDULING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_INPUT_DATA_HANDLING
-(
- INPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- WORKING_DIR_PARENT VARCHAR(255),
- UNIQUE_WORKING_DIR VARCHAR(255),
- STAGE_INPUT_FILES_TO_WORKING_DIR SMALLINT,
- CLEAN_AFTER_JOB SMALLINT,
- PRIMARY KEY(INPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_OUTPUT_DATA_HANDLING
-(
- OUTPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- OUTPUT_DATA_DIR VARCHAR(255),
- DATA_REG_URL VARCHAR (255),
- PERSIST_OUTPUT_DATA SMALLINT,
- PRIMARY KEY(OUTPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE QOS_PARAM
-(
- QOS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- START_EXECUTION_AT VARCHAR(255),
- EXECUTE_BEFORE VARCHAR(255),
- NO_OF_RETRIES INTEGER,
- PRIMARY KEY(QOS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE COMMUNITY_USER
-(
- GATEWAY_NAME VARCHAR(256) NOT NULL,
- COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
- PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME, TOKEN_ID)
-);
-
-CREATE TABLE CREDENTIALS
-(
- GATEWAY_ID VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- CREDENTIAL BLOB NOT NULL,
- PORTAL_USER_ID VARCHAR(256) NOT NULL,
- TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
-);
-
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa b/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa
deleted file mode 100644
index 9ed5ca9..0000000
--- a/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql~30f9d70adbd9ee7dd6f7d3eccbfca4baf19b09fa
+++ /dev/null
@@ -1,361 +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.
- *
- */
-CREATE TABLE GATEWAY
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME)
-);
-
-CREATE TABLE CONFIGURATION
-(
- CONFIG_KEY VARCHAR(255),
- CONFIG_VAL VARCHAR(255),
- EXPIRE_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- CATEGORY_ID VARCHAR (255),
- PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
-);
-
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version', '0.12', CURRENT_TIMESTAMP ,'SYSTEM');
-
-CREATE TABLE USERS
-(
- USER_NAME VARCHAR(255),
- PASSWORD VARCHAR(255),
- PRIMARY KEY(USER_NAME)
-);
-
-CREATE TABLE GATEWAY_WORKER
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME, USER_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255),
- PROJECT_NAME VARCHAR(255) NOT NULL,
- DESCRIPTION VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (PROJECT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT_USER
-(
- PROJECT_ID VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (PROJECT_ID,USER_NAME),
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PUBLISHED_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- CREATED_USER VARCHAR(255),
- PUBLISH_WORKFLOW_NAME VARCHAR(255),
- VERSION VARCHAR(255),
- PUBLISHED_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- PATH VARCHAR (255),
- WORKFLOW_CONTENT BLOB,
- PRIMARY KEY(GATEWAY_NAME, PUBLISH_WORKFLOW_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (CREATED_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE USER_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- TEMPLATE_NAME VARCHAR(255),
- LAST_UPDATED_TIME TIMESTAMP DEFAULT CURRENT TIMESTAMP,
- PATH VARCHAR (255),
- WORKFLOW_GRAPH BLOB,
- PRIMARY KEY(GATEWAY_NAME, OWNER, TEMPLATE_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (OWNER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT
-(
- EXPERIMENT_ID VARCHAR(255),
- GATEWAY_NAME VARCHAR(255),
- EXECUTION_USER VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255) NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- EXPERIMENT_NAME VARCHAR(255) NOT NULL,
- EXPERIMENT_DESCRIPTION VARCHAR(255),
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- WORKFLOW_TEMPLATE_ID VARCHAR(255),
- WORKFLOW_TEMPLATE_VERSION VARCHAR(255),
- WORKFLOW_EXECUTION_ID VARCHAR(255),
- PRIMARY KEY(EXPERIMENT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (EXECUTION_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE,
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_INPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,INPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_OUTPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,OUTPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-
-CREATE TABLE WORKFLOW_NODE_DETAIL
-(
- EXPERIMENT_ID VARCHAR(255) NOT NULL,
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- NODE_NAME VARCHAR(255) NOT NULL,
- EXECUTION_UNIT VARCHAR(255) NOT NULL,
- EXECUTION_UNIT_DATA VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE TASK_DETAIL
-(
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- APPLICATION_DEPLOYMENT_ID VARCHAR(255),
- PRIMARY KEY(TASK_ID),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ERROR_DETAIL
-(
- ERROR_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- ACTUAL_ERROR_MESSAGE CLOB,
- USER_FRIEDNLY_ERROR_MSG VARCHAR(255),
- TRANSIENT_OR_PERSISTENT SMALLINT,
- ERROR_CATEGORY VARCHAR(255),
- CORRECTIVE_ACTION VARCHAR(255),
- ACTIONABLE_GROUP VARCHAR(255),
- PRIMARY KEY(ERROR_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_INPUT
-(
- TASK_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,INPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_OUTPUT
-(
- TASK_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,OUTPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_INPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,INPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_OUTPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,OUTPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE JOB_DETAIL
-(
- JOB_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_DESCRIPTION CLOB NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- COMPUTE_RESOURCE_CONSUMED VARCHAR(255),
- PRIMARY KEY (TASK_ID, JOB_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE DATA_TRANSFER_DETAIL
-(
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- TRANSFER_DESC CLOB NOT NULL,
- PRIMARY KEY(TRANSFER_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE STATUS
-(
- STATUS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- STATE VARCHAR(255),
- STATUS_UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- STATUS_TYPE VARCHAR(255),
- PRIMARY KEY(STATUS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE,
- FOREIGN KEY (TRANSFER_ID) REFERENCES DATA_TRANSFER_DETAIL(TRANSFER_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE CONFIG_DATA
-(
- EXPERIMENT_ID VARCHAR(255),
- AIRAVATA_AUTO_SCHEDULE SMALLINT NOT NULL,
- OVERRIDE_MANUAL_SCHEDULE_PARAMS SMALLINT NOT NULL,
- SHARE_EXPERIMENT SMALLINT,
- PRIMARY KEY(EXPERIMENT_ID)
-);
-
-CREATE TABLE COMPUTATIONAL_RESOURCE_SCHEDULING
-(
- RESOURCE_SCHEDULING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- RESOURCE_HOST_ID VARCHAR(255),
- CPU_COUNT INTEGER,
- NODE_COUNT INTEGER,
- NO_OF_THREADS INTEGER,
- QUEUE_NAME VARCHAR(255),
- WALLTIME_LIMIT INTEGER,
- JOB_START_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- TOTAL_PHYSICAL_MEMORY INTEGER,
- COMPUTATIONAL_PROJECT_ACCOUNT VARCHAR(255),
- PRIMARY KEY(RESOURCE_SCHEDULING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_INPUT_DATA_HANDLING
-(
- INPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- WORKING_DIR_PARENT VARCHAR(255),
- UNIQUE_WORKING_DIR VARCHAR(255),
- STAGE_INPUT_FILES_TO_WORKING_DIR SMALLINT,
- CLEAN_AFTER_JOB SMALLINT,
- PRIMARY KEY(INPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_OUTPUT_DATA_HANDLING
-(
- OUTPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- OUTPUT_DATA_DIR VARCHAR(255),
- DATA_REG_URL VARCHAR (255),
- PERSIST_OUTPUT_DATA SMALLINT,
- PRIMARY KEY(OUTPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE QOS_PARAM
-(
- QOS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- START_EXECUTION_AT VARCHAR(255),
- EXECUTE_BEFORE VARCHAR(255),
- NO_OF_RETRIES INTEGER,
- PRIMARY KEY(QOS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE COMMUNITY_USER
-(
- GATEWAY_NAME VARCHAR(256) NOT NULL,
- COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
- PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME, TOKEN_ID)
-);
-
-CREATE TABLE CREDENTIALS
-(
- GATEWAY_ID VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- CREDENTIAL BLOB NOT NULL,
- PORTAL_USER_ID VARCHAR(256) NOT NULL,
- TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
-);
-
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql~HEAD
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql~HEAD b/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql~HEAD
deleted file mode 100644
index 9ed5ca9..0000000
--- a/modules/orchestrator/orchestrator-service/src/test/resources/registry-derby.sql~HEAD
+++ /dev/null
@@ -1,361 +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.
- *
- */
-CREATE TABLE GATEWAY
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME)
-);
-
-CREATE TABLE CONFIGURATION
-(
- CONFIG_KEY VARCHAR(255),
- CONFIG_VAL VARCHAR(255),
- EXPIRE_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- CATEGORY_ID VARCHAR (255),
- PRIMARY KEY(CONFIG_KEY, CONFIG_VAL, CATEGORY_ID)
-);
-
-INSERT INTO CONFIGURATION (CONFIG_KEY, CONFIG_VAL, EXPIRE_DATE, CATEGORY_ID) VALUES('registry.version', '0.12', CURRENT_TIMESTAMP ,'SYSTEM');
-
-CREATE TABLE USERS
-(
- USER_NAME VARCHAR(255),
- PASSWORD VARCHAR(255),
- PRIMARY KEY(USER_NAME)
-);
-
-CREATE TABLE GATEWAY_WORKER
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (GATEWAY_NAME, USER_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT
-(
- GATEWAY_NAME VARCHAR(255),
- USER_NAME VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255),
- PROJECT_NAME VARCHAR(255) NOT NULL,
- DESCRIPTION VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (PROJECT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PROJECT_USER
-(
- PROJECT_ID VARCHAR(255),
- USER_NAME VARCHAR(255),
- PRIMARY KEY (PROJECT_ID,USER_NAME),
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE,
- FOREIGN KEY (USER_NAME) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE PUBLISHED_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- CREATED_USER VARCHAR(255),
- PUBLISH_WORKFLOW_NAME VARCHAR(255),
- VERSION VARCHAR(255),
- PUBLISHED_DATE TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- PATH VARCHAR (255),
- WORKFLOW_CONTENT BLOB,
- PRIMARY KEY(GATEWAY_NAME, PUBLISH_WORKFLOW_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (CREATED_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE USER_WORKFLOW
-(
- GATEWAY_NAME VARCHAR(255),
- OWNER VARCHAR(255),
- TEMPLATE_NAME VARCHAR(255),
- LAST_UPDATED_TIME TIMESTAMP DEFAULT CURRENT TIMESTAMP,
- PATH VARCHAR (255),
- WORKFLOW_GRAPH BLOB,
- PRIMARY KEY(GATEWAY_NAME, OWNER, TEMPLATE_NAME),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (OWNER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT
-(
- EXPERIMENT_ID VARCHAR(255),
- GATEWAY_NAME VARCHAR(255),
- EXECUTION_USER VARCHAR(255) NOT NULL,
- PROJECT_ID VARCHAR(255) NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- EXPERIMENT_NAME VARCHAR(255) NOT NULL,
- EXPERIMENT_DESCRIPTION VARCHAR(255),
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- WORKFLOW_TEMPLATE_ID VARCHAR(255),
- WORKFLOW_TEMPLATE_VERSION VARCHAR(255),
- WORKFLOW_EXECUTION_ID VARCHAR(255),
- PRIMARY KEY(EXPERIMENT_ID),
- FOREIGN KEY (GATEWAY_NAME) REFERENCES GATEWAY(GATEWAY_NAME) ON DELETE CASCADE,
- FOREIGN KEY (EXECUTION_USER) REFERENCES USERS(USER_NAME) ON DELETE CASCADE,
- FOREIGN KEY (PROJECT_ID) REFERENCES PROJECT(PROJECT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_INPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,INPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE EXPERIMENT_OUTPUT
-(
- EXPERIMENT_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(EXPERIMENT_ID,OUTPUT_KEY),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-
-CREATE TABLE WORKFLOW_NODE_DETAIL
-(
- EXPERIMENT_ID VARCHAR(255) NOT NULL,
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- NODE_NAME VARCHAR(255) NOT NULL,
- EXECUTION_UNIT VARCHAR(255) NOT NULL,
- EXECUTION_UNIT_DATA VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE TASK_DETAIL
-(
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- APPLICATION_ID VARCHAR(255),
- APPLICATION_VERSION VARCHAR(255),
- APPLICATION_DEPLOYMENT_ID VARCHAR(255),
- PRIMARY KEY(TASK_ID),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ERROR_DETAIL
-(
- ERROR_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- ACTUAL_ERROR_MESSAGE CLOB,
- USER_FRIEDNLY_ERROR_MSG VARCHAR(255),
- TRANSIENT_OR_PERSISTENT SMALLINT,
- ERROR_CATEGORY VARCHAR(255),
- CORRECTIVE_ACTION VARCHAR(255),
- ACTIONABLE_GROUP VARCHAR(255),
- PRIMARY KEY(ERROR_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_INPUT
-(
- TASK_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,INPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE APPLICATION_OUTPUT
-(
- TASK_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE CLOB,
- PRIMARY KEY(TASK_ID,OUTPUT_KEY),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_INPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- INPUT_KEY VARCHAR(255) NOT NULL,
- INPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,INPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE NODE_OUTPUT
-(
- NODE_INSTANCE_ID VARCHAR(255),
- OUTPUT_KEY VARCHAR(255) NOT NULL,
- OUTPUT_KEY_TYPE VARCHAR(255),
- METADATA VARCHAR(255),
- VALUE VARCHAR(255),
- PRIMARY KEY(NODE_INSTANCE_ID,OUTPUT_KEY),
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE JOB_DETAIL
-(
- JOB_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_DESCRIPTION CLOB NOT NULL,
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- COMPUTE_RESOURCE_CONSUMED VARCHAR(255),
- PRIMARY KEY (TASK_ID, JOB_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE DATA_TRANSFER_DETAIL
-(
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- TRANSFER_DESC CLOB NOT NULL,
- PRIMARY KEY(TRANSFER_ID),
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE STATUS
-(
- STATUS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- NODE_INSTANCE_ID VARCHAR(255),
- TRANSFER_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- JOB_ID VARCHAR(255),
- STATE VARCHAR(255),
- STATUS_UPDATE_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- STATUS_TYPE VARCHAR(255),
- PRIMARY KEY(STATUS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE,
- FOREIGN KEY (NODE_INSTANCE_ID) REFERENCES WORKFLOW_NODE_DETAIL(NODE_INSTANCE_ID) ON DELETE CASCADE,
- FOREIGN KEY (TRANSFER_ID) REFERENCES DATA_TRANSFER_DETAIL(TRANSFER_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE CONFIG_DATA
-(
- EXPERIMENT_ID VARCHAR(255),
- AIRAVATA_AUTO_SCHEDULE SMALLINT NOT NULL,
- OVERRIDE_MANUAL_SCHEDULE_PARAMS SMALLINT NOT NULL,
- SHARE_EXPERIMENT SMALLINT,
- PRIMARY KEY(EXPERIMENT_ID)
-);
-
-CREATE TABLE COMPUTATIONAL_RESOURCE_SCHEDULING
-(
- RESOURCE_SCHEDULING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- RESOURCE_HOST_ID VARCHAR(255),
- CPU_COUNT INTEGER,
- NODE_COUNT INTEGER,
- NO_OF_THREADS INTEGER,
- QUEUE_NAME VARCHAR(255),
- WALLTIME_LIMIT INTEGER,
- JOB_START_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
- TOTAL_PHYSICAL_MEMORY INTEGER,
- COMPUTATIONAL_PROJECT_ACCOUNT VARCHAR(255),
- PRIMARY KEY(RESOURCE_SCHEDULING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_INPUT_DATA_HANDLING
-(
- INPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- WORKING_DIR_PARENT VARCHAR(255),
- UNIQUE_WORKING_DIR VARCHAR(255),
- STAGE_INPUT_FILES_TO_WORKING_DIR SMALLINT,
- CLEAN_AFTER_JOB SMALLINT,
- PRIMARY KEY(INPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE ADVANCE_OUTPUT_DATA_HANDLING
-(
- OUTPUT_DATA_HANDLING_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- OUTPUT_DATA_DIR VARCHAR(255),
- DATA_REG_URL VARCHAR (255),
- PERSIST_OUTPUT_DATA SMALLINT,
- PRIMARY KEY(OUTPUT_DATA_HANDLING_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE QOS_PARAM
-(
- QOS_ID INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY,
- EXPERIMENT_ID VARCHAR(255),
- TASK_ID VARCHAR(255),
- START_EXECUTION_AT VARCHAR(255),
- EXECUTE_BEFORE VARCHAR(255),
- NO_OF_RETRIES INTEGER,
- PRIMARY KEY(QOS_ID),
- FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE,
- FOREIGN KEY (TASK_ID) REFERENCES TASK_DETAIL(TASK_ID) ON DELETE CASCADE
-);
-
-CREATE TABLE COMMUNITY_USER
-(
- GATEWAY_NAME VARCHAR(256) NOT NULL,
- COMMUNITY_USER_NAME VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- COMMUNITY_USER_EMAIL VARCHAR(256) NOT NULL,
- PRIMARY KEY (GATEWAY_NAME, COMMUNITY_USER_NAME, TOKEN_ID)
-);
-
-CREATE TABLE CREDENTIALS
-(
- GATEWAY_ID VARCHAR(256) NOT NULL,
- TOKEN_ID VARCHAR(256) NOT NULL,
- CREDENTIAL BLOB NOT NULL,
- PORTAL_USER_ID VARCHAR(256) NOT NULL,
- TIME_PERSISTED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (GATEWAY_ID, TOKEN_ID)
-);
-
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/pom.xml b/modules/registry/registry-core/pom.xml
index b18c93c..80e54b1 100644
--- a/modules/registry/registry-core/pom.xml
+++ b/modules/registry/registry-core/pom.xml
@@ -108,26 +108,52 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>${antrun.version}</version>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-maven-plugin</artifactId>
+ <version>2.2.0</version>
<executions>
<execution>
+ <id>enhancer</id>
<phase>process-classes</phase>
- <configuration>
- <tasks>
- <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="maven.compile.classpath" />
- <openjpac>
- <classpath refid="maven.compile.classpath" />
- </openjpac>
- </tasks>
- </configuration>
<goals>
- <goal>run</goal>
+ <goal>enhance</goal>
</goals>
</execution>
</executions>
+ <configuration>
+ <addDefaultConstructor>true</addDefaultConstructor>
+ <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
+ <persistenceXmlFile>${project.basedir}/src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa</artifactId>
+ <version>2.2.0</version>
+ </dependency>
+ </dependencies>
</plugin>
+ <!--<plugin>-->
+ <!--<groupId>org.apache.maven.plugins</groupId>-->
+ <!--<artifactId>maven-antrun-plugin</artifactId>-->
+ <!--<version>${antrun.version}</version>-->
+ <!--<executions>-->
+ <!--<execution>-->
+ <!--<phase>process-classes</phase>-->
+ <!--<configuration>-->
+ <!--<tasks>-->
+ <!--<taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="maven.compile.classpath" />-->
+ <!--<openjpac>-->
+ <!--<classpath refid="maven.compile.classpath" />-->
+ <!--</openjpac>-->
+ <!--</tasks>-->
+ <!--</configuration>-->
+ <!--<goals>-->
+ <!--<goal>run</goal>-->
+ <!--</goals>-->
+ <!--</execution>-->
+ <!--</executions>-->
+ <!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java
index cd9ccae..3a5d5cc 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java
@@ -42,9 +42,9 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
@Override
public String addApplicationDeployment(ApplicationDeploymentDescription deploymentDescription, String gatewayId) throws AppCatalogException {
try {
- AppDeploymentAppCatalogResourceAppCat deploymentResource = new AppDeploymentAppCatalogResourceAppCat();
- ComputeResourceAppCatalogResourceAppCat computeHostResource = new ComputeResourceAppCatalogResourceAppCat();
- AppModuleAppCatalogResourceAppCat moduleResource = new AppModuleAppCatalogResourceAppCat();
+ AppDeploymentResource deploymentResource = new AppDeploymentResource();
+ ComputeResourceResource computeHostResource = new ComputeResourceResource();
+ AppModuleResource moduleResource = new AppModuleResource();
if (!computeHostResource.isExists(deploymentDescription.getComputeHostId())){
logger.error("Compute host does not exist in the system. Please create a Compute host first...");
throw new AppCatalogException("Compute host does not exist in the system. Please create a Compute host first...");
@@ -53,8 +53,8 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
logger.error("Application module does not exist in the system. Please create an application module first...");
throw new AppCatalogException("Application module does not exist in the system. Please create an application module first...");
}
- AppModuleAppCatalogResourceAppCat module = (AppModuleAppCatalogResourceAppCat)moduleResource.get(deploymentDescription.getAppModuleId());
- ComputeResourceAppCatalogResourceAppCat hostResource = (ComputeResourceAppCatalogResourceAppCat) computeHostResource.get(deploymentDescription.getComputeHostId());
+ AppModuleResource module = (AppModuleResource)moduleResource.get(deploymentDescription.getAppModuleId());
+ ComputeResourceResource hostResource = (ComputeResourceResource) computeHostResource.get(deploymentDescription.getComputeHostId());
deploymentResource.setDeploymentId(hostResource.getHostName() + "_" + deploymentDescription.getAppModuleId());
deploymentResource.setAppModuleId(deploymentDescription.getAppModuleId());
deploymentResource.setModuleResource(module);
@@ -73,7 +73,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
List<String> moduleLoadCmds = deploymentDescription.getModuleLoadCmds();
if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()){
for (String cmd : moduleLoadCmds){
- ModuleLoadCmdAppCatalogResourceAppCat cmdResource = new ModuleLoadCmdAppCatalogResourceAppCat();
+ ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId());
cmdResource.setCmd(cmd);
cmdResource.save();
@@ -83,7 +83,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
List<String> preJobCommands = deploymentDescription.getPreJobCommands();
if (preJobCommands != null && !preJobCommands.isEmpty()){
for (String cmd : preJobCommands){
- PreJobCommandAppCatalogResourceAppCat cmdResource = new PreJobCommandAppCatalogResourceAppCat();
+ PreJobCommandResource cmdResource = new PreJobCommandResource();
cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId());
cmdResource.setCommand(cmd);
cmdResource.save();
@@ -93,7 +93,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
List<String> postJobCommands = deploymentDescription.getPostJobCommands();
if (postJobCommands != null && !postJobCommands.isEmpty()){
for (String cmd : postJobCommands){
- PostJobCommandAppCatalogResourceAppCat cmdResource = new PostJobCommandAppCatalogResourceAppCat();
+ PostJobCommandResource cmdResource = new PostJobCommandResource();
cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId());
cmdResource.setCommand(cmd);
cmdResource.save();
@@ -103,7 +103,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
List<SetEnvPaths> libPrependPaths = deploymentDescription.getLibPrependPaths();
if (libPrependPaths != null && !libPrependPaths.isEmpty()){
for (SetEnvPaths path : libPrependPaths){
- LibraryPrepandPathAppCatalogResourceAppCat prepandPathResource = new LibraryPrepandPathAppCatalogResourceAppCat();
+ LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
prepandPathResource.setAppDeploymentResource(deploymentResource);
prepandPathResource.setName(path.getName());
prepandPathResource.setValue(path.getValue());
@@ -115,7 +115,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
List<SetEnvPaths> libApendPaths = deploymentDescription.getLibAppendPaths();
if (libApendPaths != null && !libApendPaths.isEmpty()){
for (SetEnvPaths path : libApendPaths){
- LibraryApendPathAppCatalogResourceAppCat apendPathResource = new LibraryApendPathAppCatalogResourceAppCat();
+ LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
apendPathResource.setAppDeploymentResource(deploymentResource);
apendPathResource.setName(path.getName());
apendPathResource.setValue(path.getValue());
@@ -126,7 +126,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
List<SetEnvPaths> setEnvironment = deploymentDescription.getSetEnvironment();
if (setEnvironment != null && !setEnvironment.isEmpty()){
for (SetEnvPaths path : setEnvironment){
- AppEnvironmentAppCatalogResourceAppCat environmentResource = new AppEnvironmentAppCatalogResourceAppCat();
+ AppEnvironmentResource environmentResource = new AppEnvironmentResource();
environmentResource.setAppDeploymentResource(deploymentResource);
environmentResource.setName(path.getName());
environmentResource.setValue(path.getValue());
@@ -144,10 +144,10 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
@Override
public void updateApplicationDeployment(String deploymentId, ApplicationDeploymentDescription updatedDeployment) throws AppCatalogException {
try {
- AppDeploymentAppCatalogResourceAppCat deploymentResource = new AppDeploymentAppCatalogResourceAppCat();
- AppDeploymentAppCatalogResourceAppCat existingDep = (AppDeploymentAppCatalogResourceAppCat)deploymentResource.get(deploymentId);
- ComputeResourceAppCatalogResourceAppCat computeHostResource = new ComputeResourceAppCatalogResourceAppCat();
- AppModuleAppCatalogResourceAppCat moduleResource = new AppModuleAppCatalogResourceAppCat();
+ AppDeploymentResource deploymentResource = new AppDeploymentResource();
+ AppDeploymentResource existingDep = (AppDeploymentResource)deploymentResource.get(deploymentId);
+ ComputeResourceResource computeHostResource = new ComputeResourceResource();
+ AppModuleResource moduleResource = new AppModuleResource();
if (!computeHostResource.isExists(updatedDeployment.getComputeHostId())){
logger.error("Compute host does not exist in the system. Please create a Compute host first...");
throw new AppCatalogException("Compute host does not exist in the system. Please create a Compute host first...");
@@ -156,11 +156,11 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
logger.error("Application module does not exist in the system. Please create an application module first...");
throw new AppCatalogException("Application module does not exist in the system. Please create an application module first...");
}
- AppModuleAppCatalogResourceAppCat module = (AppModuleAppCatalogResourceAppCat)moduleResource.get(updatedDeployment.getAppModuleId());
+ AppModuleResource module = (AppModuleResource)moduleResource.get(updatedDeployment.getAppModuleId());
existingDep.setAppModuleId(updatedDeployment.getAppModuleId());
existingDep.setModuleResource(module);
existingDep.setHostId(updatedDeployment.getComputeHostId());
- existingDep.setHostResource((ComputeResourceAppCatalogResourceAppCat)computeHostResource.get(updatedDeployment.getComputeHostId()));
+ existingDep.setHostResource((ComputeResourceResource)computeHostResource.get(updatedDeployment.getComputeHostId()));
existingDep.setAppDes(updatedDeployment.getAppDeploymentDescription());
existingDep.setExecutablePath(updatedDeployment.getExecutablePath());
if (updatedDeployment.getParallelism() != null){
@@ -170,7 +170,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
existingDep.save();
// remove existing module load commands
- ModuleLoadCmdAppCatalogResourceAppCat cmdResource = new ModuleLoadCmdAppCatalogResourceAppCat();
+ ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId);
cmdResource.remove(ids);
@@ -181,7 +181,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.CMD, cmd);
if (cmdResource.isExists(ids)){
- cmdResource = (ModuleLoadCmdAppCatalogResourceAppCat)cmdResource.get(ids);
+ cmdResource = (ModuleLoadCmdResource)cmdResource.get(ids);
}
cmdResource.setCmd(cmd);
cmdResource.setAppDeploymentResource(existingDep);
@@ -190,7 +190,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
}
}
- PreJobCommandAppCatalogResourceAppCat preJobCommandResource = new PreJobCommandAppCatalogResourceAppCat();
+ PreJobCommandResource preJobCommandResource = new PreJobCommandResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, deploymentId);
preJobCommandResource.remove(ids);
@@ -201,7 +201,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
ids.put(AppCatAbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.PreJobCommandConstants.COMMAND, cmd);
if (preJobCommandResource.isExists(ids)){
- preJobCommandResource = (PreJobCommandAppCatalogResourceAppCat)preJobCommandResource.get(ids);
+ preJobCommandResource = (PreJobCommandResource)preJobCommandResource.get(ids);
}
preJobCommandResource.setCommand(cmd);
preJobCommandResource.setAppDeploymentResource(existingDep);
@@ -210,7 +210,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
}
}
- PostJobCommandAppCatalogResourceAppCat postJobCommandResource = new PostJobCommandAppCatalogResourceAppCat();
+ PostJobCommandResource postJobCommandResource = new PostJobCommandResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, deploymentId);
postJobCommandResource.remove(ids);
@@ -221,7 +221,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
ids.put(AppCatAbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.PostJobCommandConstants.COMMAND, cmd);
if (postJobCommandResource.isExists(ids)){
- postJobCommandResource = (PostJobCommandAppCatalogResourceAppCat)postJobCommandResource.get(ids);
+ postJobCommandResource = (PostJobCommandResource)postJobCommandResource.get(ids);
}
postJobCommandResource.setCommand(cmd);
postJobCommandResource.setAppDeploymentResource(existingDep);
@@ -231,7 +231,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
}
// remove existing lib prepand paths
- LibraryPrepandPathAppCatalogResourceAppCat prepandPathResource = new LibraryPrepandPathAppCatalogResourceAppCat();
+ LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId);
prepandPathResource.remove(ids);
@@ -242,7 +242,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
ids.put(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.LibraryPrepandPathConstants.NAME, path.getName());
if (prepandPathResource.isExists(ids)){
- prepandPathResource = (LibraryPrepandPathAppCatalogResourceAppCat)prepandPathResource.get(ids);
+ prepandPathResource = (LibraryPrepandPathResource)prepandPathResource.get(ids);
}
prepandPathResource.setAppDeploymentResource(existingDep);
prepandPathResource.setName(path.getName());
@@ -254,7 +254,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
List<SetEnvPaths> libApendPaths = updatedDeployment.getLibAppendPaths();
// remove lib append paths
- LibraryApendPathAppCatalogResourceAppCat apendPathResource = new LibraryApendPathAppCatalogResourceAppCat();
+ LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId);
apendPathResource.remove(ids);
@@ -264,7 +264,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
ids.put(AppCatAbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.LibraryApendPathConstants.NAME, path.getName());
if (apendPathResource.isExists(ids)){
- apendPathResource = (LibraryApendPathAppCatalogResourceAppCat)apendPathResource.get(ids);
+ apendPathResource = (LibraryApendPathResource)apendPathResource.get(ids);
}
apendPathResource.setAppDeploymentResource(existingDep);
apendPathResource.setName(path.getName());
@@ -276,7 +276,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
List<SetEnvPaths> setEnvironment = updatedDeployment.getSetEnvironment();
// remove existing setEnvPaths
- AppEnvironmentAppCatalogResourceAppCat environmentResource = new AppEnvironmentAppCatalogResourceAppCat();
+ AppEnvironmentResource environmentResource = new AppEnvironmentResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId);
environmentResource.remove(ids);
@@ -286,7 +286,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
ids.put(AppCatAbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId);
ids.put(AppCatAbstractResource.AppEnvironmentConstants.NAME, path.getName());
if (environmentResource.isExists(ids)){
- environmentResource = (AppEnvironmentAppCatalogResourceAppCat)environmentResource.get(ids);
+ environmentResource = (AppEnvironmentResource)environmentResource.get(ids);
}
environmentResource.setAppDeploymentResource(existingDep);
environmentResource.setName(path.getName());
@@ -304,8 +304,8 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
@Override
public ApplicationDeploymentDescription getApplicationDeployement(String deploymentId) throws AppCatalogException {
try {
- AppDeploymentAppCatalogResourceAppCat deploymentResource = new AppDeploymentAppCatalogResourceAppCat();
- AppDeploymentAppCatalogResourceAppCat appDep = (AppDeploymentAppCatalogResourceAppCat)deploymentResource.get(deploymentId);
+ AppDeploymentResource deploymentResource = new AppDeploymentResource();
+ AppDeploymentResource appDep = (AppDeploymentResource)deploymentResource.get(deploymentId);
return AppCatalogThriftConversion.getApplicationDeploymentDescription(appDep);
}catch (Exception e) {
logger.error("Error while retrieving application deployment...", e);
@@ -317,7 +317,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
public List<ApplicationDeploymentDescription> getApplicationDeployements(Map<String, String> filters) throws AppCatalogException {
List<ApplicationDeploymentDescription> deploymentDescriptions = new ArrayList<ApplicationDeploymentDescription>();
try {
- AppDeploymentAppCatalogResourceAppCat resource = new AppDeploymentAppCatalogResourceAppCat();
+ AppDeploymentResource resource = new AppDeploymentResource();
boolean firstTry=true;
for (String fieldName : filters.keySet() ){
List<ApplicationDeploymentDescription> tmpDescriptions = new ArrayList<ApplicationDeploymentDescription>();
@@ -364,7 +364,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
public List<ApplicationDeploymentDescription> getAllApplicationDeployements(String gatewayId) throws AppCatalogException {
List<ApplicationDeploymentDescription> deploymentDescriptions = new ArrayList<ApplicationDeploymentDescription>();
try {
- AppDeploymentAppCatalogResourceAppCat resource = new AppDeploymentAppCatalogResourceAppCat();
+ AppDeploymentResource resource = new AppDeploymentResource();
resource.setGatewayId(gatewayId);
List<AppCatalogResource> resources = resource.getAll();
if (resources != null && !resources.isEmpty()){
@@ -381,7 +381,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
@Override
public List<String> getAllApplicationDeployementIds() throws AppCatalogException {
try {
- AppDeploymentAppCatalogResourceAppCat resource = new AppDeploymentAppCatalogResourceAppCat();
+ AppDeploymentResource resource = new AppDeploymentResource();
return resource.getAllIds();
}catch (Exception e){
logger.error("Error while retrieving app deployment list...", e);
@@ -392,7 +392,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
@Override
public boolean isAppDeploymentExists(String deploymentId) throws AppCatalogException {
try {
- AppDeploymentAppCatalogResourceAppCat deploymentResource = new AppDeploymentAppCatalogResourceAppCat();
+ AppDeploymentResource deploymentResource = new AppDeploymentResource();
return deploymentResource.isExists(deploymentId);
}catch (Exception e){
logger.error("Error while retrieving app deployment...", e);
@@ -403,7 +403,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment {
@Override
public void removeAppDeployment(String deploymentId) throws AppCatalogException {
try {
- AppDeploymentAppCatalogResourceAppCat deploymentResource = new AppDeploymentAppCatalogResourceAppCat();
+ AppDeploymentResource deploymentResource = new AppDeploymentResource();
deploymentResource.remove(deploymentId);
}catch (Exception e){
logger.error("Error while deleting app deployment...", e);
[21/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointResource.java
new file mode 100644
index 0000000..1fda19f
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointResource.java
@@ -0,0 +1,323 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.GlobusGKEndPointPK;
+import org.apache.airavata.registry.core.app.catalog.model.GlobusGKEndpoint;
+import org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class GlobusGKEndpointResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(GlobusGKEndpointResource.class);
+
+ private String submissionID;
+ private String endpoint;
+
+ private GlobusJobSubmissionResource globusJobSubmissionResource;
+
+
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
+ generator.setParameter(GlobusEPConstants.ENDPOINT, ids.get(GlobusEPConstants.ENDPOINT));
+ generator.setParameter(GlobusEPConstants.SUBMISSION_ID, ids.get(GlobusEPConstants.SUBMISSION_ID));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
+ generator.setParameter(GlobusEPConstants.SUBMISSION_ID, ids.get(GlobusEPConstants.SUBMISSION_ID));
+ generator.setParameter(GlobusEPConstants.ENDPOINT, ids.get(GlobusEPConstants.ENDPOINT));
+ Query q = generator.selectQuery(em);
+ GlobusGKEndpoint gkEndpoint = (GlobusGKEndpoint) q.getSingleResult();
+ GlobusGKEndpointResource gkEndpointResource =
+ (GlobusGKEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, gkEndpoint);
+ em.getTransaction().commit();
+ em.close();
+ return gkEndpointResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> resources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
+ List results;
+ if (fieldName.equals(GlobusEPConstants.ENDPOINT)) {
+ generator.setParameter(GlobusEPConstants.ENDPOINT, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusGKEndpoint gkEndpoint = (GlobusGKEndpoint) result;
+ GlobusGKEndpointResource gkEndpointResource =
+ (GlobusGKEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, gkEndpoint);
+ resources.add(gkEndpointResource);
+ }
+ }
+ } else if (fieldName.equals(GlobusEPConstants.SUBMISSION_ID)) {
+ generator.setParameter(GlobusEPConstants.SUBMISSION_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusGKEndpoint globusGKEndpoint = (GlobusGKEndpoint) result;
+ GlobusGKEndpointResource gkEndpointResource =
+ (GlobusGKEndpointResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, globusGKEndpoint);
+ resources.add(gkEndpointResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Globus Endpoint Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Globus Endpoint Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> list = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
+ List results;
+ if (fieldName.equals(GlobusEPConstants.SUBMISSION_ID)) {
+ generator.setParameter(GlobusEPConstants.SUBMISSION_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusGKEndpoint globusGKEndpoint = (GlobusGKEndpoint) result;
+ list.add(globusGKEndpoint.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GlobusEPConstants.ENDPOINT)) {
+ generator.setParameter(GlobusEPConstants.ENDPOINT, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusGKEndpoint globusGKEndpoint = (GlobusGKEndpoint) result;
+ list.add(globusGKEndpoint.getSubmissionID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Globus EP resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Globus EP Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return list;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GlobusGKEndpoint existingGlobusEP = em.find(GlobusGKEndpoint.class, new GlobusGKEndPointPK(submissionID, endpoint));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ GlobusJobSubmission globusJobSubmission = em.find(GlobusJobSubmission.class, submissionID);
+ if (existingGlobusEP != null) {
+ existingGlobusEP.setSubmissionID(submissionID);
+ existingGlobusEP.setEndpoint(endpoint);
+ existingGlobusEP.setGlobusSubmission(globusJobSubmission);
+ em.merge(existingGlobusEP);
+ } else {
+ GlobusGKEndpoint globusGKEndpoint = new GlobusGKEndpoint();
+ globusGKEndpoint.setSubmissionID(submissionID);
+ globusGKEndpoint.setEndpoint(endpoint);
+ globusGKEndpoint.setGlobusSubmission(globusJobSubmission);
+ em.persist(globusGKEndpoint);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GlobusGKEndpoint gkEndpoint = em.find(GlobusGKEndpoint.class, new GlobusGKEndPointPK(ids.get(GlobusEPConstants.SUBMISSION_ID),
+ ids.get(GlobusEPConstants.ENDPOINT)));
+
+ em.close();
+ return gkEndpoint != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ } }
+
+ public String getSubmissionID() {
+ return submissionID;
+ }
+
+ public void setSubmissionID(String submissionID) {
+ this.submissionID = submissionID;
+ }
+
+ public String getEndpoint() {
+ return endpoint;
+ }
+
+ public void setEndpoint(String endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ public GlobusJobSubmissionResource getGlobusJobSubmissionResource() {
+ return globusJobSubmissionResource;
+ }
+
+ public void setGlobusJobSubmissionResource(GlobusJobSubmissionResource globusJobSubmissionResource) {
+ this.globusJobSubmissionResource = globusJobSubmissionResource;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionAppCatalogResourceAppCat.java
deleted file mode 100644
index b473905..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,315 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.List;
-
-public class GlobusJobSubmissionAppCatalogResourceAppCat extends AppCatAbstractResource {
-
- private final static Logger logger = LoggerFactory.getLogger(GlobusJobSubmissionAppCatalogResourceAppCat.class);
-
- private String submissionID;
- private String resourceJobManager;
- private String securityProtocol;
-
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
- generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
- generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, identifier);
- Query q = generator.selectQuery(em);
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) q.getSingleResult();
- GlobusJobSubmissionAppCatalogResourceAppCat globusJobSubmissionResource =
- (GlobusJobSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.GLOBUS_SUBMISSION, globusJobSubmission);
- em.getTransaction().commit();
- em.close();
- return globusJobSubmissionResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> globusSubmissionResourceList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
- List results;
- if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER)) {
- generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- GlobusJobSubmissionAppCatalogResourceAppCat globusJobSubmissionResource =
- (GlobusJobSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.GLOBUS_SUBMISSION, globusJobSubmission);
- globusSubmissionResourceList.add(globusJobSubmissionResource);
- }
- }
- } else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
- generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- GlobusJobSubmissionAppCatalogResourceAppCat globusJobSubmissionResource =
- (GlobusJobSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.GLOBUS_SUBMISSION, globusJobSubmission);
- globusSubmissionResourceList.add(globusJobSubmissionResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Globus submission resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Globus Submission resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return globusSubmissionResourceList;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> globusSubmissionResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
- List results;
- if (fieldName.equals(GlobusJobSubmissionConstants.SUBMISSION_ID)) {
- generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP)) {
- generator.setParameter(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
- }
- }
- }
- else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
- generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER)) {
- generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Globus Submission resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Globus Submission resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return globusSubmissionResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GlobusJobSubmission existingGlobusSubmission = em.find(GlobusJobSubmission.class, submissionID);
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingGlobusSubmission != null) {
- existingGlobusSubmission.setSubmissionID(submissionID);
- existingGlobusSubmission.setResourceJobManager(resourceJobManager);
- existingGlobusSubmission.setSecurityProtocol(securityProtocol);
- em.merge(existingGlobusSubmission);
- } else {
- GlobusJobSubmission globusJobSubmission = new GlobusJobSubmission();
- globusJobSubmission.setSubmissionID(submissionID);
- globusJobSubmission.setSecurityProtocol(securityProtocol);
- globusJobSubmission.setResourceJobManager(resourceJobManager);
- em.persist(globusJobSubmission);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GlobusJobSubmission globusJobSubmission = em.find(GlobusJobSubmission.class, identifier);
- em.close();
- return globusJobSubmission != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getSubmissionID() {
- return submissionID;
- }
-
- public void setSubmissionID(String submissionID) {
- this.submissionID = submissionID;
- }
-
- public String getResourceJobManager() {
- return resourceJobManager;
- }
-
- public void setResourceJobManager(String resourceJobManager) {
- this.resourceJobManager = resourceJobManager;
- }
-
- public String getSecurityProtocol() {
- return securityProtocol;
- }
-
- public void setSecurityProtocol(String securityProtocol) {
- this.securityProtocol = securityProtocol;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionResource.java
new file mode 100644
index 0000000..483c730
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusJobSubmissionResource.java
@@ -0,0 +1,315 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+
+public class GlobusJobSubmissionResource extends AppCatAbstractResource {
+
+ private final static Logger logger = LoggerFactory.getLogger(GlobusJobSubmissionResource.class);
+
+ private String submissionID;
+ private String resourceJobManager;
+ private String securityProtocol;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
+ generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
+ generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, identifier);
+ Query q = generator.selectQuery(em);
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) q.getSingleResult();
+ GlobusJobSubmissionResource globusJobSubmissionResource =
+ (GlobusJobSubmissionResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.GLOBUS_SUBMISSION, globusJobSubmission);
+ em.getTransaction().commit();
+ em.close();
+ return globusJobSubmissionResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> globusSubmissionResourceList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
+ List results;
+ if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER)) {
+ generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ GlobusJobSubmissionResource globusJobSubmissionResource =
+ (GlobusJobSubmissionResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.GLOBUS_SUBMISSION, globusJobSubmission);
+ globusSubmissionResourceList.add(globusJobSubmissionResource);
+ }
+ }
+ } else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
+ generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ GlobusJobSubmissionResource globusJobSubmissionResource =
+ (GlobusJobSubmissionResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.GLOBUS_SUBMISSION, globusJobSubmission);
+ globusSubmissionResourceList.add(globusJobSubmissionResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Globus submission resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Globus Submission resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return globusSubmissionResourceList;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> globusSubmissionResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
+ List results;
+ if (fieldName.equals(GlobusJobSubmissionConstants.SUBMISSION_ID)) {
+ generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP)) {
+ generator.setParameter(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+ }
+ }
+ }
+ else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
+ generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER)) {
+ generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Globus Submission resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Globus Submission resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return globusSubmissionResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GlobusJobSubmission existingGlobusSubmission = em.find(GlobusJobSubmission.class, submissionID);
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingGlobusSubmission != null) {
+ existingGlobusSubmission.setSubmissionID(submissionID);
+ existingGlobusSubmission.setResourceJobManager(resourceJobManager);
+ existingGlobusSubmission.setSecurityProtocol(securityProtocol);
+ em.merge(existingGlobusSubmission);
+ } else {
+ GlobusJobSubmission globusJobSubmission = new GlobusJobSubmission();
+ globusJobSubmission.setSubmissionID(submissionID);
+ globusJobSubmission.setSecurityProtocol(securityProtocol);
+ globusJobSubmission.setResourceJobManager(resourceJobManager);
+ em.persist(globusJobSubmission);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GlobusJobSubmission globusJobSubmission = em.find(GlobusJobSubmission.class, identifier);
+ em.close();
+ return globusJobSubmission != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getSubmissionID() {
+ return submissionID;
+ }
+
+ public void setSubmissionID(String submissionID) {
+ this.submissionID = submissionID;
+ }
+
+ public String getResourceJobManager() {
+ return resourceJobManager;
+ }
+
+ public void setResourceJobManager(String resourceJobManager) {
+ this.resourceJobManager = resourceJobManager;
+ }
+
+ public String getSecurityProtocol() {
+ return securityProtocol;
+ }
+
+ public void setSecurityProtocol(String securityProtocol) {
+ this.securityProtocol = securityProtocol;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementAppCatalogResourceAppCat.java
deleted file mode 100644
index 4b55e20..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,279 +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.registry.core.app.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.GridftpDataMovement;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GridftpDataMovementAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(GridftpDataMovementAppCatalogResourceAppCat.class);
- private String dataMovementInterfaceId;
- private String securityProtocol;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_DATA_MOVEMENT);
- generator.setParameter(GridftpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_DATA_MOVEMENT);
- generator.setParameter(GridftpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
- Query q = generator.selectQuery(em);
- GridftpDataMovement gridftpDataMovement = (GridftpDataMovement) q.getSingleResult();
- GridftpDataMovementAppCatalogResourceAppCat gridftpDataMovementResource = (GridftpDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_DATA_MOVEMENT, gridftpDataMovement);
- em.getTransaction().commit();
- em.close();
- return gridftpDataMovementResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> gridftpDataMovementResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_DATA_MOVEMENT);
- Query q;
- if ((fieldName.equals(GridftpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(GridftpDataMovementConstants.SECURITY_PROTOCOL))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- GridftpDataMovement gridftpDataMovement = (GridftpDataMovement) result;
- GridftpDataMovementAppCatalogResourceAppCat gridftpDataMovementResource = (GridftpDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_DATA_MOVEMENT, gridftpDataMovement);
- gridftpDataMovementResources.add(gridftpDataMovementResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Gridftp Data Movement Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Gridftp Data Movement Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gridftpDataMovementResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> gridftpDataMovementResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_DATA_MOVEMENT);
- Query q;
- if ((fieldName.equals(GridftpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(GridftpDataMovementConstants.SECURITY_PROTOCOL))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- GridftpDataMovement gridftpDataMovement = (GridftpDataMovement) result;
- GridftpDataMovementAppCatalogResourceAppCat gridftpDataMovementResource = (GridftpDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_DATA_MOVEMENT, gridftpDataMovement);
- gridftpDataMovementResourceIDs.add(gridftpDataMovementResource.getDataMovementInterfaceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Gridftp Data Movement Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Gridftp Data Movement Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gridftpDataMovementResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GridftpDataMovement existingGridftpDataMovement = em.find(GridftpDataMovement.class, dataMovementInterfaceId);
- em.close();
- GridftpDataMovement gridftpDataMovement;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingGridftpDataMovement == null) {
- gridftpDataMovement = new GridftpDataMovement();
- gridftpDataMovement.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- gridftpDataMovement = existingGridftpDataMovement;
- gridftpDataMovement.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- gridftpDataMovement.setDataMovementInterfaceId(getDataMovementInterfaceId());
- gridftpDataMovement.setSecurityProtocol(getSecurityProtocol());
- if (existingGridftpDataMovement == null) {
- em.persist(gridftpDataMovement);
- } else {
- em.merge(gridftpDataMovement);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GridftpDataMovement gridftpDataMovement = em.find(GridftpDataMovement.class, identifier);
- em.close();
- return gridftpDataMovement != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getDataMovementInterfaceId() {
- return dataMovementInterfaceId;
- }
-
- public String getSecurityProtocol() {
- return securityProtocol;
- }
-
- public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
- this.dataMovementInterfaceId=dataMovementInterfaceId;
- }
-
- public void setSecurityProtocol(String securityProtocol) {
- this.securityProtocol=securityProtocol;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementResource.java
new file mode 100644
index 0000000..ebfc241
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpDataMovementResource.java
@@ -0,0 +1,279 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.GridftpDataMovement;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GridftpDataMovementResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(GridftpDataMovementResource.class);
+ private String dataMovementInterfaceId;
+ private String securityProtocol;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_DATA_MOVEMENT);
+ generator.setParameter(GridftpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_DATA_MOVEMENT);
+ generator.setParameter(GridftpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ GridftpDataMovement gridftpDataMovement = (GridftpDataMovement) q.getSingleResult();
+ GridftpDataMovementResource gridftpDataMovementResource = (GridftpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_DATA_MOVEMENT, gridftpDataMovement);
+ em.getTransaction().commit();
+ em.close();
+ return gridftpDataMovementResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> gridftpDataMovementResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_DATA_MOVEMENT);
+ Query q;
+ if ((fieldName.equals(GridftpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(GridftpDataMovementConstants.SECURITY_PROTOCOL))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ GridftpDataMovement gridftpDataMovement = (GridftpDataMovement) result;
+ GridftpDataMovementResource gridftpDataMovementResource = (GridftpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_DATA_MOVEMENT, gridftpDataMovement);
+ gridftpDataMovementResources.add(gridftpDataMovementResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Gridftp Data Movement Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Gridftp Data Movement Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gridftpDataMovementResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> gridftpDataMovementResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_DATA_MOVEMENT);
+ Query q;
+ if ((fieldName.equals(GridftpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(GridftpDataMovementConstants.SECURITY_PROTOCOL))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ GridftpDataMovement gridftpDataMovement = (GridftpDataMovement) result;
+ GridftpDataMovementResource gridftpDataMovementResource = (GridftpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_DATA_MOVEMENT, gridftpDataMovement);
+ gridftpDataMovementResourceIDs.add(gridftpDataMovementResource.getDataMovementInterfaceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Gridftp Data Movement Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Gridftp Data Movement Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gridftpDataMovementResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GridftpDataMovement existingGridftpDataMovement = em.find(GridftpDataMovement.class, dataMovementInterfaceId);
+ em.close();
+ GridftpDataMovement gridftpDataMovement;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingGridftpDataMovement == null) {
+ gridftpDataMovement = new GridftpDataMovement();
+ gridftpDataMovement.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ gridftpDataMovement = existingGridftpDataMovement;
+ gridftpDataMovement.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ gridftpDataMovement.setDataMovementInterfaceId(getDataMovementInterfaceId());
+ gridftpDataMovement.setSecurityProtocol(getSecurityProtocol());
+ if (existingGridftpDataMovement == null) {
+ em.persist(gridftpDataMovement);
+ } else {
+ em.merge(gridftpDataMovement);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GridftpDataMovement gridftpDataMovement = em.find(GridftpDataMovement.class, identifier);
+ em.close();
+ return gridftpDataMovement != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getDataMovementInterfaceId() {
+ return dataMovementInterfaceId;
+ }
+
+ public String getSecurityProtocol() {
+ return securityProtocol;
+ }
+
+ public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
+ this.dataMovementInterfaceId=dataMovementInterfaceId;
+ }
+
+ public void setSecurityProtocol(String securityProtocol) {
+ this.securityProtocol=securityProtocol;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointAppCatalogResourceAppCat.java
deleted file mode 100644
index 6d04b6c..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GridftpEndpointAppCatalogResourceAppCat.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.registry.core.app.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.GridftpDataMovement;
-import org.apache.airavata.registry.core.app.catalog.model.GridftpEndpoint;
-import org.apache.airavata.registry.core.app.catalog.model.GridftpEndpoint_PK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GridftpEndpointAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(GridftpEndpointAppCatalogResourceAppCat.class);
- private String endpoint;
- private String dataMovementInterfaceId;
- private GridftpDataMovementAppCatalogResourceAppCat gridftpDataMovementResource;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_ENDPOINT);
- generator.setParameter(GridftpEndpointConstants.ENDPOINT, ids.get(GridftpEndpointConstants.ENDPOINT));
- generator.setParameter(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID, ids.get(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_ENDPOINT);
- generator.setParameter(GridftpEndpointConstants.ENDPOINT, ids.get(GridftpEndpointConstants.ENDPOINT));
- generator.setParameter(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID, ids.get(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID));
- Query q = generator.selectQuery(em);
- GridftpEndpoint gridftpEndpoint = (GridftpEndpoint) q.getSingleResult();
- GridftpEndpointAppCatalogResourceAppCat gridftpEndpointResource = (GridftpEndpointAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_ENDPOINT, gridftpEndpoint);
- em.getTransaction().commit();
- em.close();
- return gridftpEndpointResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> gridftpEndpointResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_ENDPOINT);
- Query q;
- if ((fieldName.equals(GridftpEndpointConstants.ENDPOINT)) || (fieldName.equals(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- GridftpEndpoint gridftpEndpoint = (GridftpEndpoint) result;
- GridftpEndpointAppCatalogResourceAppCat gridftpEndpointResource = (GridftpEndpointAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_ENDPOINT, gridftpEndpoint);
- gridftpEndpointResources.add(gridftpEndpointResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Gridftp Endpoint Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Gridftp Endpoint Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gridftpEndpointResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> gridftpEndpointResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GRIDFTP_ENDPOINT);
- Query q;
- if ((fieldName.equals(GridftpEndpointConstants.ENDPOINT)) || (fieldName.equals(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- GridftpEndpoint gridftpEndpoint = (GridftpEndpoint) result;
- GridftpEndpointAppCatalogResourceAppCat gridftpEndpointResource = (GridftpEndpointAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GRIDFTP_ENDPOINT, gridftpEndpoint);
- gridftpEndpointResourceIDs.add(gridftpEndpointResource.getDataMovementInterfaceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Gridftp Endpoint Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Gridftp Endpoint Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gridftpEndpointResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GridftpEndpoint existingGridftpEndpoint = em.find(GridftpEndpoint.class, new GridftpEndpoint_PK(endpoint, dataMovementInterfaceId));
- em.close();
- GridftpEndpoint gridftpEndpoint;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingGridftpEndpoint == null) {
- gridftpEndpoint = new GridftpEndpoint();
- gridftpEndpoint.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- gridftpEndpoint = existingGridftpEndpoint;
- gridftpEndpoint.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- gridftpEndpoint.setEndpoint(getEndpoint());
- gridftpEndpoint.setDataMovementInterfaceId(getDataMovementInterfaceId());
- GridftpDataMovement gridftpDataMovement = em.find(GridftpDataMovement.class, getDataMovementInterfaceId());
- gridftpEndpoint.setGridftpDataMovement(gridftpDataMovement);
- if (existingGridftpEndpoint == null) {
- em.persist(gridftpEndpoint);
- } else {
- em.merge(gridftpEndpoint);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GridftpEndpoint gridftpEndpoint = em.find(GridftpEndpoint.class, new GridftpEndpoint_PK(ids.get(GridftpEndpointConstants.ENDPOINT), ids.get(GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID)));
- em.close();
- return gridftpEndpoint != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getEndpoint() {
- return endpoint;
- }
-
- public String getDataMovementInterfaceId() {
- return dataMovementInterfaceId;
- }
-
- public GridftpDataMovementAppCatalogResourceAppCat getGridftpDataMovementResource() {
- return gridftpDataMovementResource;
- }
-
- public void setEndpoint(String endpoint) {
- this.endpoint=endpoint;
- }
-
- public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
- this.dataMovementInterfaceId=dataMovementInterfaceId;
- }
-
- public void setGridftpDataMovementResource(GridftpDataMovementAppCatalogResourceAppCat gridftpDataMovementResource) {
- this.gridftpDataMovementResource=gridftpDataMovementResource;
- }
-}
\ No newline at end of file
[06/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NotificationEmailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NotificationEmailResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NotificationEmailResource.java
new file mode 100644
index 0000000..47c8d83
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/NotificationEmailResource.java
@@ -0,0 +1,119 @@
+/*
+*
+* 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import java.util.List;
+
+public class NotificationEmailResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(NotificationEmailResource.class);
+
+ private int emailId = 0;
+ private String experimentId;
+ private String taskId;
+ private String emailAddress;
+
+
+ public String getEmailAddress() {
+ return emailAddress;
+ }
+
+ public void setEmailAddress(String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Notification_Email notification_email;
+ if (emailId != 0 ){
+ notification_email = em.find(Notification_Email.class, emailId);
+ notification_email.setEmailId(emailId);
+ }else {
+ notification_email = new Notification_Email();
+ }
+ notification_email.setExperiment_id(experimentId);
+ notification_email.setTaskId(taskId);
+ notification_email.setEmailAddress(emailAddress);
+ em.persist(notification_email);
+ emailId = notification_email.getEmailId();
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectExperimentCatResource.java
deleted file mode 100644
index ebfc799..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectExperimentCatResource.java
+++ /dev/null
@@ -1,508 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.ResultOrderType;
-import org.apache.airavata.registry.cpi.utils.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ProjectExperimentCatResource extends AbstractExperimentCatResource {
- private final static Logger logger = LoggerFactory.getLogger(ProjectExperimentCatResource.class);
- private String name;
- private String id;
- private String gatewayId;
- private WorkerExperimentCatResource worker;
- private String description;
- private Timestamp creationTime;
-
- /**
- *
- */
- public ProjectExperimentCatResource() {
- }
-
- /**
- *
- * @param type child resource type
- * @return child resource
- */
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- if (type == ResourceType.EXPERIMENT) {
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
- experimentResource.setGatewayId(gatewayId);
- experimentResource.setExecutionUser(worker.getUser());
- experimentResource.setProjectId(id);
- return experimentResource;
- } else if (type == ResourceType.PROJECT_USER){
- ProjectUserExperimentCatResource pr = new ProjectUserExperimentCatResource();
- pr.setProjectId(id);
- pr.setUserName(worker.getUser());
- return pr;
- }
- else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- }
-
- /**
- *
- * @param type child resource type
- * @param name child resource name
- */
- public void remove(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- if (type == ResourceType.EXPERIMENT) {
- QueryGenerator generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- } else if (type == ResourceType.PROJECT_USER) {
- QueryGenerator generator = new QueryGenerator(PROJECT_USER);
- generator.setParameter(ProjectUserConstants.USERNAME, name);
- generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- } else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @param type child resource type
- * @param name child resource name
- * @return child resource
- */
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- EntityManager em = null;
- try {
- if (type == ResourceType.EXPERIMENT) {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
- Query q = generator.selectQuery(em);
- Experiment experiment = (Experiment) q.getSingleResult();
- ExperimentExperimentCatResource experimentResource = (ExperimentExperimentCatResource)
- Utils.getResource(ResourceType.EXPERIMENT, experiment);
- em.getTransaction().commit();
- em.close();
- return experimentResource;
- } else if (type == ResourceType.PROJECT_USER) {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(PROJECT_USER);
- generator.setParameter(ProjectUserConstants.USERNAME, name);
- generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
- Query q = generator.selectQuery(em);
- ProjectUser prUser = (ProjectUser) q.getSingleResult();
- ExperimentExperimentCatResource experimentResource = (ExperimentExperimentCatResource)
- Utils.getResource(ResourceType.PROJECT_USER, prUser);
- em.getTransaction().commit();
- em.close();
- return experimentResource;
- } else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- } catch (Exception e) {
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @param type child resource type
- * @return list of child resources
- */
- @Override
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- if (type == ResourceType.EXPERIMENT) {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.PROJECT_ID, id);
- Query q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Experiment experiment = (Experiment) result;
- ExperimentExperimentCatResource experimentResource = (ExperimentExperimentCatResource)
- Utils.getResource(ResourceType.EXPERIMENT, experiment);
- resourceList.add(experimentResource);
- }
- }
- em.getTransaction().commit();
- em.close();
- } else if (type == ResourceType.PROJECT_USER) {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(PROJECT_USER);
- generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
- Query q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ProjectUser projectUser = (ProjectUser) result;
- ProjectUserExperimentCatResource pr = (ProjectUserExperimentCatResource)
- Utils.getResource(ResourceType.PROJECT_USER, projectUser);
- resourceList.add(pr);
- }
- }
- em.getTransaction().commit();
- em.close();
- } else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- /**
- * Get results with pagination and ordering
- *
- * @param type
- * @param limit
- * @param offset
- * @param orderByIdentifier
- * @return
- * @throws RegistryException
- */
- public List<ExperimentCatResource> get(ResourceType type, int limit, int offset, Object orderByIdentifier,
- ResultOrderType resultOrderType) throws RegistryException{
- List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- if (type == ResourceType.EXPERIMENT) {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.PROJECT_ID, id);
- Query q;
- //ordering - supported only by CREATION_TIME
- if(orderByIdentifier != null && resultOrderType != null
- && orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)) {
- q = generator.selectQuery(em, ExperimentConstants.CREATION_TIME, resultOrderType);
- }else{
- q = generator.selectQuery(em);
- }
-
- //pagination
- if(limit>0 && offset>=0){
- q.setFirstResult(offset);
- q.setMaxResults(limit);
- }
- List<?> results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Experiment experiment = (Experiment) result;
- ExperimentExperimentCatResource experimentResource = (ExperimentExperimentCatResource)
- Utils.getResource(ResourceType.EXPERIMENT, experiment);
- resourceList.add(experimentResource);
- }
- }
- em.getTransaction().commit();
- em.close();
- } else if (type == ResourceType.PROJECT_USER) {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(PROJECT_USER);
- generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
- Query q;
- //ordering - only supported only by CREATION_TIME
- if(orderByIdentifier != null && resultOrderType != null
- && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
- q = generator.selectQuery(em, ProjectConstants.CREATION_TIME, resultOrderType);
- }else{
- q = generator.selectQuery(em);
- }
-
- //pagination
- if(limit>0 && offset>=0){
- q.setFirstResult(offset);
- q.setMaxResults(limit);
- }
- List<?> results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ProjectUser projectUser = (ProjectUser) result;
- ProjectUserExperimentCatResource pr = (ProjectUserExperimentCatResource)
- Utils.getResource(ResourceType.PROJECT_USER, projectUser);
- resourceList.add(pr);
- }
- }
- em.getTransaction().commit();
- em.close();
- } else {
- logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for project resource.");
- }
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- /**
- * save project to the database
- */
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- Project existingProject = em.find(Project.class, id);
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Project project = new Project();
- project.setProject_id(id);
- project.setProject_name(name);
- project.setGateway_id(gatewayId);
- Users user = em.find(Users.class, worker.getUser());
- project.setUsers(user);
- project.setUser_name(user.getUser_name());
- project.setDescription(description);
- project.setCreationTime(creationTime);
-
- if (existingProject != null) {
- existingProject.setProject_name(name);
- existingProject.setGateway_id(gatewayId);
- existingProject.setUsers(user);
- existingProject.setUser_name(user.getUser_name());
- existingProject.setDescription(description);
- existingProject.setCreationTime(creationTime);
- project = em.merge(existingProject);
- } else {
- em.persist(project);
- }
-
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- /**
- *
- * @return project name
- */
- public String getName() {
- return name;
- }
-
- /**
- *
- * @param name project name
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- *
- * @return gateway worker
- */
- public WorkerExperimentCatResource getWorker() {
- return worker;
- }
-
- /**
- *
- * @param worker gateway worker
- */
- public void setWorker(WorkerExperimentCatResource worker) {
- this.worker = worker;
- }
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- /**
- *
- * @param experimentId experiment ID
- * @return whether the experiment exist
- */
- public boolean isExperimentExists(String experimentId) throws RegistryException{
- return isExists(ResourceType.EXPERIMENT, experimentId);
- }
-
- /**
- *
- * @param experimentId experiment ID
- * @return experiment resource
- */
- public ExperimentExperimentCatResource createExperiment(String experimentId) throws RegistryException{
- ExperimentExperimentCatResource experimentResource = (ExperimentExperimentCatResource)create(ResourceType.EXPERIMENT);
- experimentResource.setExpID(experimentId);
- return experimentResource;
- }
-
- /**
- *
- * @param experimentId experiment ID
- * @return experiment resource
- */
- public ExperimentExperimentCatResource getExperiment(String experimentId) throws RegistryException{
- return (ExperimentExperimentCatResource)get(ResourceType.EXPERIMENT,experimentId);
- }
-
- /**
- *
- * @return list of experiments
- */
- public List<ExperimentExperimentCatResource> getExperiments() throws RegistryException{
- List<ExperimentCatResource> list = get(ResourceType.EXPERIMENT);
- List<ExperimentExperimentCatResource> result=new ArrayList<ExperimentExperimentCatResource>();
- for (ExperimentCatResource resource : list) {
- result.add((ExperimentExperimentCatResource) resource);
- }
- return result;
- }
-
- public List<ExperimentExperimentCatResource> getExperiments(int limit, int offset, Object orderByIdentifier,
- ResultOrderType resultOrderType) throws RegistryException{
- List<ExperimentCatResource> list = get(ResourceType.EXPERIMENT, limit, offset, orderByIdentifier, resultOrderType);
- List<ExperimentExperimentCatResource> result=new ArrayList<ExperimentExperimentCatResource>();
- for (ExperimentCatResource resource : list) {
- result.add((ExperimentExperimentCatResource) resource);
- }
- return result;
- }
-
- /**
- *
- * @param experimentId experiment ID
- */
- public void removeExperiment(String experimentId) throws RegistryException{
- remove(ResourceType.EXPERIMENT, experimentId);
- }
-
- public List<ProjectUserExperimentCatResource> getProjectUserList () throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.PROJECT_USER);
- List<ProjectUserExperimentCatResource> projectUserResources = new ArrayList<ProjectUserExperimentCatResource>();
- if (resources != null && !resources.isEmpty()){
- for (ExperimentCatResource r : resources){
- projectUserResources.add((ProjectUserExperimentCatResource)r);
- }
- }
- return projectUserResources;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectResource.java
new file mode 100644
index 0000000..f67b1b4
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectResource.java
@@ -0,0 +1,508 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.ResultOrderType;
+import org.apache.airavata.registry.cpi.utils.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ProjectResource extends AbstractExpCatResource {
+ private final static Logger logger = LoggerFactory.getLogger(ProjectResource.class);
+ private String name;
+ private String id;
+ private String gatewayId;
+ private WorkerResource worker;
+ private String description;
+ private Timestamp creationTime;
+
+ /**
+ *
+ */
+ public ProjectResource() {
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @return child resource
+ */
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ if (type == ResourceType.EXPERIMENT) {
+ ExperimentResource experimentResource = new ExperimentResource();
+ experimentResource.setGatewayId(gatewayId);
+ experimentResource.setExecutionUser(worker.getUser());
+ experimentResource.setProjectId(id);
+ return experimentResource;
+ } else if (type == ResourceType.PROJECT_USER){
+ ProjectUserResource pr = new ProjectUserResource();
+ pr.setProjectId(id);
+ pr.setUserName(worker.getUser());
+ return pr;
+ }
+ else {
+ logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for project resource.");
+ }
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @param name child resource name
+ */
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (type == ResourceType.EXPERIMENT) {
+ QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ } else if (type == ResourceType.PROJECT_USER) {
+ QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+ generator.setParameter(ProjectUserConstants.USERNAME, name);
+ generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ } else {
+ logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for project resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @param name child resource name
+ * @return child resource
+ */
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ EntityManager em = null;
+ try {
+ if (type == ResourceType.EXPERIMENT) {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+ Query q = generator.selectQuery(em);
+ Experiment experiment = (Experiment) q.getSingleResult();
+ ExperimentResource experimentResource = (ExperimentResource)
+ Utils.getResource(ResourceType.EXPERIMENT, experiment);
+ em.getTransaction().commit();
+ em.close();
+ return experimentResource;
+ } else if (type == ResourceType.PROJECT_USER) {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+ generator.setParameter(ProjectUserConstants.USERNAME, name);
+ generator.setParameter(ProjectUserConstants.PROJECT_ID, this.id);
+ Query q = generator.selectQuery(em);
+ ProjectUser prUser = (ProjectUser) q.getSingleResult();
+ ExperimentResource experimentResource = (ExperimentResource)
+ Utils.getResource(ResourceType.PROJECT_USER, prUser);
+ em.getTransaction().commit();
+ em.close();
+ return experimentResource;
+ } else {
+ logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for project resource.");
+ }
+ } catch (Exception e) {
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @return list of child resources
+ */
+ @Override
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ if (type == ResourceType.EXPERIMENT) {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.PROJECT_ID, id);
+ Query q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Experiment experiment = (Experiment) result;
+ ExperimentResource experimentResource = (ExperimentResource)
+ Utils.getResource(ResourceType.EXPERIMENT, experiment);
+ resourceList.add(experimentResource);
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } else if (type == ResourceType.PROJECT_USER) {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+ generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
+ Query q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ProjectUser projectUser = (ProjectUser) result;
+ ProjectUserResource pr = (ProjectUserResource)
+ Utils.getResource(ResourceType.PROJECT_USER, projectUser);
+ resourceList.add(pr);
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } else {
+ logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for project resource.");
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+ /**
+ * Get results with pagination and ordering
+ *
+ * @param type
+ * @param limit
+ * @param offset
+ * @param orderByIdentifier
+ * @return
+ * @throws RegistryException
+ */
+ public List<ExperimentCatResource> get(ResourceType type, int limit, int offset, Object orderByIdentifier,
+ ResultOrderType resultOrderType) throws RegistryException{
+ List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ if (type == ResourceType.EXPERIMENT) {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.PROJECT_ID, id);
+ Query q;
+ //ordering - supported only by CREATION_TIME
+ if(orderByIdentifier != null && resultOrderType != null
+ && orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)) {
+ q = generator.selectQuery(em, ExperimentConstants.CREATION_TIME, resultOrderType);
+ }else{
+ q = generator.selectQuery(em);
+ }
+
+ //pagination
+ if(limit>0 && offset>=0){
+ q.setFirstResult(offset);
+ q.setMaxResults(limit);
+ }
+ List<?> results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Experiment experiment = (Experiment) result;
+ ExperimentResource experimentResource = (ExperimentResource)
+ Utils.getResource(ResourceType.EXPERIMENT, experiment);
+ resourceList.add(experimentResource);
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } else if (type == ResourceType.PROJECT_USER) {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator = new QueryGenerator(PROJECT_USER);
+ generator.setParameter(ProjectUserConstants.PROJECT_ID, id);
+ Query q;
+ //ordering - only supported only by CREATION_TIME
+ if(orderByIdentifier != null && resultOrderType != null
+ && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
+ q = generator.selectQuery(em, ProjectConstants.CREATION_TIME, resultOrderType);
+ }else{
+ q = generator.selectQuery(em);
+ }
+
+ //pagination
+ if(limit>0 && offset>=0){
+ q.setFirstResult(offset);
+ q.setMaxResults(limit);
+ }
+ List<?> results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ProjectUser projectUser = (ProjectUser) result;
+ ProjectUserResource pr = (ProjectUserResource)
+ Utils.getResource(ResourceType.PROJECT_USER, projectUser);
+ resourceList.add(pr);
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } else {
+ logger.error("Unsupported resource type for project resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for project resource.");
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+ /**
+ * save project to the database
+ */
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ Project existingProject = em.find(Project.class, id);
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Project project = new Project();
+ project.setProject_id(id);
+ project.setProject_name(name);
+ project.setGateway_id(gatewayId);
+ Users user = em.find(Users.class, worker.getUser());
+ project.setUsers(user);
+ project.setUser_name(user.getUser_name());
+ project.setDescription(description);
+ project.setCreationTime(creationTime);
+
+ if (existingProject != null) {
+ existingProject.setProject_name(name);
+ existingProject.setGateway_id(gatewayId);
+ existingProject.setUsers(user);
+ existingProject.setUser_name(user.getUser_name());
+ existingProject.setDescription(description);
+ existingProject.setCreationTime(creationTime);
+ project = em.merge(existingProject);
+ } else {
+ em.persist(project);
+ }
+
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ *
+ * @return project name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ *
+ * @param name project name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ *
+ * @return gateway worker
+ */
+ public WorkerResource getWorker() {
+ return worker;
+ }
+
+ /**
+ *
+ * @param worker gateway worker
+ */
+ public void setWorker(WorkerResource worker) {
+ this.worker = worker;
+ }
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ /**
+ *
+ * @param experimentId experiment ID
+ * @return whether the experiment exist
+ */
+ public boolean isExperimentExists(String experimentId) throws RegistryException{
+ return isExists(ResourceType.EXPERIMENT, experimentId);
+ }
+
+ /**
+ *
+ * @param experimentId experiment ID
+ * @return experiment resource
+ */
+ public ExperimentResource createExperiment(String experimentId) throws RegistryException{
+ ExperimentResource experimentResource = (ExperimentResource)create(ResourceType.EXPERIMENT);
+ experimentResource.setExpID(experimentId);
+ return experimentResource;
+ }
+
+ /**
+ *
+ * @param experimentId experiment ID
+ * @return experiment resource
+ */
+ public ExperimentResource getExperiment(String experimentId) throws RegistryException{
+ return (ExperimentResource)get(ResourceType.EXPERIMENT,experimentId);
+ }
+
+ /**
+ *
+ * @return list of experiments
+ */
+ public List<ExperimentResource> getExperiments() throws RegistryException{
+ List<ExperimentCatResource> list = get(ResourceType.EXPERIMENT);
+ List<ExperimentResource> result=new ArrayList<ExperimentResource>();
+ for (ExperimentCatResource resource : list) {
+ result.add((ExperimentResource) resource);
+ }
+ return result;
+ }
+
+ public List<ExperimentResource> getExperiments(int limit, int offset, Object orderByIdentifier,
+ ResultOrderType resultOrderType) throws RegistryException{
+ List<ExperimentCatResource> list = get(ResourceType.EXPERIMENT, limit, offset, orderByIdentifier, resultOrderType);
+ List<ExperimentResource> result=new ArrayList<ExperimentResource>();
+ for (ExperimentCatResource resource : list) {
+ result.add((ExperimentResource) resource);
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @param experimentId experiment ID
+ */
+ public void removeExperiment(String experimentId) throws RegistryException{
+ remove(ResourceType.EXPERIMENT, experimentId);
+ }
+
+ public List<ProjectUserResource> getProjectUserList () throws RegistryException{
+ List<ExperimentCatResource> resources = get(ResourceType.PROJECT_USER);
+ List<ProjectUserResource> projectUserResources = new ArrayList<ProjectUserResource>();
+ if (resources != null && !resources.isEmpty()){
+ for (ExperimentCatResource r : resources){
+ projectUserResources.add((ProjectUserResource)r);
+ }
+ }
+ return projectUserResources;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectUserExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectUserExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectUserExperimentCatResource.java
deleted file mode 100644
index fca844a..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectUserExperimentCatResource.java
+++ /dev/null
@@ -1,123 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-
-public class ProjectUserExperimentCatResource extends AbstractExperimentCatResource {
- private String projectId;
- private String userName;
-
- private static final Logger logger = LoggerFactory.getLogger(ProjectUserExperimentCatResource.class);
-
- public String getProjectId() {
- return projectId;
- }
-
- public void setProjectId(String projectId) {
- this.projectId = projectId;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- ProjectUser existingPrUser = em.find(ProjectUser.class, new ProjectUser_PK(projectId, userName));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- ProjectUser prUser = new ProjectUser();
- prUser.setProjectID(projectId);
- prUser.setUserName(userName);
- Users user = em.find(Users.class, userName);
- prUser.setUser(user);
- Project project = em.find(Project.class, projectId);
- prUser.setProject(project);
-
- if (existingPrUser != null) {
- existingPrUser.setProjectID(projectId);
- existingPrUser.setUserName(userName);
- existingPrUser.setUser(user);
- existingPrUser.setProject(project);
- prUser = em.merge(existingPrUser);
- } else {
- em.persist(prUser);
- }
-
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectUserResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectUserResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectUserResource.java
new file mode 100644
index 0000000..3063990
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProjectUserResource.java
@@ -0,0 +1,123 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import java.util.List;
+
+public class ProjectUserResource extends AbstractExpCatResource {
+ private String projectId;
+ private String userName;
+
+ private static final Logger logger = LoggerFactory.getLogger(ProjectUserResource.class);
+
+ public String getProjectId() {
+ return projectId;
+ }
+
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for project resource data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ ProjectUser existingPrUser = em.find(ProjectUser.class, new ProjectUser_PK(projectId, userName));
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ ProjectUser prUser = new ProjectUser();
+ prUser.setProjectID(projectId);
+ prUser.setUserName(userName);
+ Users user = em.find(Users.class, userName);
+ prUser.setUser(user);
+ Project project = em.find(Project.class, projectId);
+ prUser.setProject(project);
+
+ if (existingPrUser != null) {
+ existingPrUser.setProjectID(projectId);
+ existingPrUser.setUserName(userName);
+ existingPrUser.setUser(user);
+ existingPrUser.setProject(project);
+ prUser = em.merge(existingPrUser);
+ } else {
+ em.persist(prUser);
+ }
+
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/QosParamExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/QosParamExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/QosParamExperimentCatResource.java
deleted file mode 100644
index 5d78249..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/QosParamExperimentCatResource.java
+++ /dev/null
@@ -1,144 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.QosParam;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.airavata.registry.cpi.RegistryException;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-
-public class QosParamExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(QosParamExperimentCatResource.class);
- private int qosId;
- private String experimentId;
- private String taskId;
- private String startExecutionAt;
- private String executeBefore;
- private int noOfRetries;
-
- public int getQosId() {
- return qosId;
- }
-
- public void setQosId(int qosId) {
- this.qosId = qosId;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getStartExecutionAt() {
- return startExecutionAt;
- }
-
- public void setStartExecutionAt(String startExecutionAt) {
- this.startExecutionAt = startExecutionAt;
- }
-
- public String getExecuteBefore() {
- return executeBefore;
- }
-
- public void setExecuteBefore(String executeBefore) {
- this.executeBefore = executeBefore;
- }
-
- public int getNoOfRetries() {
- return noOfRetries;
- }
-
- public void setNoOfRetries(int noOfRetries) {
- this.noOfRetries = noOfRetries;
- }
-
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QosParam qosParam = new QosParam();
- qosParam.setTaskId(taskId);
- qosParam.setExpId(experimentId);
- qosParam.setStartExecutionAt(startExecutionAt);
- qosParam.setExecuteBefore(executeBefore);
- qosParam.setNoOfRetries(noOfRetries);
- em.persist(qosParam);
- qosId = qosParam.getQosId();
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/QosParamResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/QosParamResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/QosParamResource.java
new file mode 100644
index 0000000..5cb45bf
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/QosParamResource.java
@@ -0,0 +1,144 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.QosParam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
+
+import javax.persistence.EntityManager;
+import java.util.List;
+
+public class QosParamResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(QosParamResource.class);
+ private int qosId;
+ private String experimentId;
+ private String taskId;
+ private String startExecutionAt;
+ private String executeBefore;
+ private int noOfRetries;
+
+ public int getQosId() {
+ return qosId;
+ }
+
+ public void setQosId(int qosId) {
+ this.qosId = qosId;
+ }
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getStartExecutionAt() {
+ return startExecutionAt;
+ }
+
+ public void setStartExecutionAt(String startExecutionAt) {
+ this.startExecutionAt = startExecutionAt;
+ }
+
+ public String getExecuteBefore() {
+ return executeBefore;
+ }
+
+ public void setExecuteBefore(String executeBefore) {
+ this.executeBefore = executeBefore;
+ }
+
+ public int getNoOfRetries() {
+ return noOfRetries;
+ }
+
+ public void setNoOfRetries(int noOfRetries) {
+ this.noOfRetries = noOfRetries;
+ }
+
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for qos params resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QosParam qosParam = new QosParam();
+ qosParam.setTaskId(taskId);
+ qosParam.setExpId(experimentId);
+ qosParam.setStartExecutionAt(startExecutionAt);
+ qosParam.setExecuteBefore(executeBefore);
+ qosParam.setNoOfRetries(noOfRetries);
+ em.persist(qosParam);
+ qosId = qosParam.getQosId();
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/StatusExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/StatusExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/StatusExperimentCatResource.java
deleted file mode 100644
index 1ed225a..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/StatusExperimentCatResource.java
+++ /dev/null
@@ -1,181 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.airavata.registry.cpi.RegistryException;
-
-import javax.persistence.EntityManager;
-import java.sql.Timestamp;
-import java.util.List;
-
-public class StatusExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(StatusExperimentCatResource.class);
- private int statusId = 0;
- private String experimentId;
- private String nodeId;
- private String transferId;
- private String taskId;
- private String jobId;
- private String state;
- private Timestamp statusUpdateTime;
- private String statusType;
-
- public int getStatusId() {
- return statusId;
- }
-
- public void setStatusId(int statusId) {
- this.statusId = statusId;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-
- public String getTransferId() {
- return transferId;
- }
-
- public void setTransferId(String transferId) {
- this.transferId = transferId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- public Timestamp getStatusUpdateTime() {
- return statusUpdateTime;
- }
-
- public void setStatusUpdateTime(Timestamp statusUpdateTime) {
- this.statusUpdateTime = statusUpdateTime;
- }
-
- public String getStatusType() {
- return statusType;
- }
-
- public void setStatusType(String statusType) {
- this.statusType = statusType;
- }
-
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Status status;
- if (statusId != 0) {
- status = em.find(Status.class, statusId);
- status.setStatusId(statusId);
- } else {
- status = new Status();
- }
- status.setExpId(experimentId);
- status.setTaskId(taskId);
- status.setNodeId(nodeId);
- status.setTransferId(transferId);
- status.setJobId(jobId);
- status.setState(state);
- status.setStatusUpdateTime(statusUpdateTime);
- status.setStatusType(statusType);
- em.persist(status);
- statusId = status.getStatusId();
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/StatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/StatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/StatusResource.java
new file mode 100644
index 0000000..f5553cc
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/StatusResource.java
@@ -0,0 +1,181 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
+
+import javax.persistence.EntityManager;
+import java.sql.Timestamp;
+import java.util.List;
+
+public class StatusResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(StatusResource.class);
+ private int statusId = 0;
+ private String experimentId;
+ private String nodeId;
+ private String transferId;
+ private String taskId;
+ private String jobId;
+ private String state;
+ private Timestamp statusUpdateTime;
+ private String statusType;
+
+ public int getStatusId() {
+ return statusId;
+ }
+
+ public void setStatusId(int statusId) {
+ this.statusId = statusId;
+ }
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public String getTransferId() {
+ return transferId;
+ }
+
+ public void setTransferId(String transferId) {
+ this.transferId = transferId;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public Timestamp getStatusUpdateTime() {
+ return statusUpdateTime;
+ }
+
+ public void setStatusUpdateTime(Timestamp statusUpdateTime) {
+ this.statusUpdateTime = statusUpdateTime;
+ }
+
+ public String getStatusType() {
+ return statusType;
+ }
+
+ public void setStatusType(String statusType) {
+ this.statusType = statusType;
+ }
+
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for status resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Status status;
+ if (statusId != 0) {
+ status = em.find(Status.class, statusId);
+ status.setStatusId(statusId);
+ } else {
+ status = new Status();
+ }
+ status.setExpId(experimentId);
+ status.setTaskId(taskId);
+ status.setNodeId(nodeId);
+ status.setTransferId(transferId);
+ status.setJobId(jobId);
+ status.setState(state);
+ status.setStatusUpdateTime(statusUpdateTime);
+ status.setStatusType(statusType);
+ em.persist(status);
+ statusId = status.getStatusId();
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
[22/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionAppCatalogResourceAppCat.java
deleted file mode 100644
index f2c5d5b..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,373 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.GSISSHSubmission;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.List;
-
-public class GSISSHSubmissionAppCatalogResourceAppCat extends AppCatAbstractResource {
-
- private final static Logger logger = LoggerFactory.getLogger(GSISSHSubmissionAppCatalogResourceAppCat.class);
-
- private String submissionID;
- private String resourceJobManager;
- private int sshPort;
- private String installedPath;
- private String monitorMode;
-
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
- generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
- generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, identifier);
- Query q = generator.selectQuery(em);
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) q.getSingleResult();
- GSISSHSubmissionAppCatalogResourceAppCat gsisshSubmissionResource =
- (GSISSHSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_SUBMISSION
- , gsisshSubmission);
- em.getTransaction().commit();
- em.close();
- return gsisshSubmissionResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> gsiSSHSubmissionResourceList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
- List results;
- if (fieldName.equals(GSISSHSubmissionConstants.MONITOR_MODE)) {
- generator.setParameter(GSISSHSubmissionConstants.MONITOR_MODE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
- GSISSHSubmissionAppCatalogResourceAppCat gsisshSubmissionResource =
- (GSISSHSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
- gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
- }
- }
- } else if (fieldName.equals(GSISSHSubmissionConstants.INSTALLED_PATH)) {
- generator.setParameter(GSISSHSubmissionConstants.INSTALLED_PATH, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
- GSISSHSubmissionAppCatalogResourceAppCat gsisshSubmissionResource =
- (GSISSHSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
- gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
- }
- }
- } else if (fieldName.equals(GSISSHSubmissionConstants.SSH_PORT)) {
- generator.setParameter(GSISSHSubmissionConstants.SSH_PORT, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
- GSISSHSubmissionAppCatalogResourceAppCat gsisshSubmissionResource =
- (GSISSHSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
- gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
- }
- }
- } else if (fieldName.equals(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER)) {
- generator.setParameter(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
- GSISSHSubmissionAppCatalogResourceAppCat gsisshSubmissionResource =
- (GSISSHSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
- gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for GSISSH submission resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for GSISSH Submission resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gsiSSHSubmissionResourceList;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> gsiSSHSubmissionResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
- List results;
- if (fieldName.equals(GSISSHSubmissionConstants.SUBMISSION_ID)) {
- generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
- gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GSISSHSubmissionConstants.SSH_PORT)) {
- generator.setParameter(GSISSHSubmissionConstants.SSH_PORT, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
- gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GSISSHSubmissionConstants.MONITOR_MODE)) {
- generator.setParameter(GSISSHSubmissionConstants.MONITOR_MODE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
- gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER)) {
- generator.setParameter(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
- gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GSISSHSubmissionConstants.INSTALLED_PATH)) {
- generator.setParameter(GSISSHSubmissionConstants.INSTALLED_PATH, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
- gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for GSISSH Submission resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for GSISSH Submission resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gsiSSHSubmissionResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GSISSHSubmission existingGSISSHSubmission = em.find(GSISSHSubmission.class, submissionID);
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingGSISSHSubmission != null) {
- existingGSISSHSubmission.setSubmissionID(submissionID);
- existingGSISSHSubmission.setSshPort(sshPort);
- existingGSISSHSubmission.setResourceJobManager(resourceJobManager);
- existingGSISSHSubmission.setInstalledPath(installedPath);
- existingGSISSHSubmission.setMonitorMode(monitorMode);
- em.merge(existingGSISSHSubmission);
- } else {
- GSISSHSubmission gsisshSubmission = new GSISSHSubmission();
- gsisshSubmission.setSubmissionID(submissionID);
- gsisshSubmission.setSshPort(sshPort);
- gsisshSubmission.setResourceJobManager(resourceJobManager);
- gsisshSubmission.setInstalledPath(installedPath);
- gsisshSubmission.setMonitorMode(monitorMode);
- em.persist(gsisshSubmission);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
-
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GSISSHSubmission gsisshSubmission = em.find(GSISSHSubmission.class, identifier);
- em.close();
- return gsisshSubmission != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getSubmissionID() {
- return submissionID;
- }
-
- public void setSubmissionID(String submissionID) {
- this.submissionID = submissionID;
- }
-
- public String getResourceJobManager() {
- return resourceJobManager;
- }
-
- public void setResourceJobManager(String resourceJobManager) {
- this.resourceJobManager = resourceJobManager;
- }
-
- public int getSshPort() {
- return sshPort;
- }
-
- public void setSshPort(int sshPort) {
- this.sshPort = sshPort;
- }
-
- public String getInstalledPath() {
- return installedPath;
- }
-
- public void setInstalledPath(String installedPath) {
- this.installedPath = installedPath;
- }
-
- public String getMonitorMode() {
- return monitorMode;
- }
-
- public void setMonitorMode(String monitorMode) {
- this.monitorMode = monitorMode;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionResource.java
new file mode 100644
index 0000000..29fc5c5
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GSISSHSubmissionResource.java
@@ -0,0 +1,373 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.GSISSHSubmission;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+
+public class GSISSHSubmissionResource extends AppCatAbstractResource {
+
+ private final static Logger logger = LoggerFactory.getLogger(GSISSHSubmissionResource.class);
+
+ private String submissionID;
+ private String resourceJobManager;
+ private int sshPort;
+ private String installedPath;
+ private String monitorMode;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
+ generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
+ generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, identifier);
+ Query q = generator.selectQuery(em);
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) q.getSingleResult();
+ GSISSHSubmissionResource gsisshSubmissionResource =
+ (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GSISSH_SUBMISSION
+ , gsisshSubmission);
+ em.getTransaction().commit();
+ em.close();
+ return gsisshSubmissionResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> gsiSSHSubmissionResourceList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
+ List results;
+ if (fieldName.equals(GSISSHSubmissionConstants.MONITOR_MODE)) {
+ generator.setParameter(GSISSHSubmissionConstants.MONITOR_MODE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+ GSISSHSubmissionResource gsisshSubmissionResource =
+ (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+ gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+ }
+ }
+ } else if (fieldName.equals(GSISSHSubmissionConstants.INSTALLED_PATH)) {
+ generator.setParameter(GSISSHSubmissionConstants.INSTALLED_PATH, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+ GSISSHSubmissionResource gsisshSubmissionResource =
+ (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+ gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+ }
+ }
+ } else if (fieldName.equals(GSISSHSubmissionConstants.SSH_PORT)) {
+ generator.setParameter(GSISSHSubmissionConstants.SSH_PORT, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+ GSISSHSubmissionResource gsisshSubmissionResource =
+ (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+ gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+ }
+ }
+ } else if (fieldName.equals(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER)) {
+ generator.setParameter(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+ GSISSHSubmissionResource gsisshSubmissionResource =
+ (GSISSHSubmissionResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.GSISSH_SUBMISSION, gsisshSubmission);
+ gsiSSHSubmissionResourceList.add(gsisshSubmissionResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for GSISSH submission resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for GSISSH Submission resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gsiSSHSubmissionResourceList;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> gsiSSHSubmissionResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GSISSH_SUBMISSION);
+ List results;
+ if (fieldName.equals(GSISSHSubmissionConstants.SUBMISSION_ID)) {
+ generator.setParameter(GSISSHSubmissionConstants.SUBMISSION_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+ gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GSISSHSubmissionConstants.SSH_PORT)) {
+ generator.setParameter(GSISSHSubmissionConstants.SSH_PORT, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+ gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GSISSHSubmissionConstants.MONITOR_MODE)) {
+ generator.setParameter(GSISSHSubmissionConstants.MONITOR_MODE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+ gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER)) {
+ generator.setParameter(GSISSHSubmissionConstants.RESOURCE_JOB_MANAGER, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+ gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GSISSHSubmissionConstants.INSTALLED_PATH)) {
+ generator.setParameter(GSISSHSubmissionConstants.INSTALLED_PATH, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GSISSHSubmission gsisshSubmission = (GSISSHSubmission) result;
+ gsiSSHSubmissionResourceIDs.add(gsisshSubmission.getSubmissionID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for GSISSH Submission resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for GSISSH Submission resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gsiSSHSubmissionResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GSISSHSubmission existingGSISSHSubmission = em.find(GSISSHSubmission.class, submissionID);
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingGSISSHSubmission != null) {
+ existingGSISSHSubmission.setSubmissionID(submissionID);
+ existingGSISSHSubmission.setSshPort(sshPort);
+ existingGSISSHSubmission.setResourceJobManager(resourceJobManager);
+ existingGSISSHSubmission.setInstalledPath(installedPath);
+ existingGSISSHSubmission.setMonitorMode(monitorMode);
+ em.merge(existingGSISSHSubmission);
+ } else {
+ GSISSHSubmission gsisshSubmission = new GSISSHSubmission();
+ gsisshSubmission.setSubmissionID(submissionID);
+ gsisshSubmission.setSshPort(sshPort);
+ gsisshSubmission.setResourceJobManager(resourceJobManager);
+ gsisshSubmission.setInstalledPath(installedPath);
+ gsisshSubmission.setMonitorMode(monitorMode);
+ em.persist(gsisshSubmission);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GSISSHSubmission gsisshSubmission = em.find(GSISSHSubmission.class, identifier);
+ em.close();
+ return gsisshSubmission != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getSubmissionID() {
+ return submissionID;
+ }
+
+ public void setSubmissionID(String submissionID) {
+ this.submissionID = submissionID;
+ }
+
+ public String getResourceJobManager() {
+ return resourceJobManager;
+ }
+
+ public void setResourceJobManager(String resourceJobManager) {
+ this.resourceJobManager = resourceJobManager;
+ }
+
+ public int getSshPort() {
+ return sshPort;
+ }
+
+ public void setSshPort(int sshPort) {
+ this.sshPort = sshPort;
+ }
+
+ public String getInstalledPath() {
+ return installedPath;
+ }
+
+ public void setInstalledPath(String installedPath) {
+ this.installedPath = installedPath;
+ }
+
+ public String getMonitorMode() {
+ return monitorMode;
+ }
+
+ public void setMonitorMode(String monitorMode) {
+ this.monitorMode = monitorMode;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileAppCatalogResourceAppCat.java
deleted file mode 100644
index d5eaec8..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,318 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.GatewayProfile;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-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 GatewayProfileAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(GatewayProfileAppCatalogResourceAppCat.class);
-
- private String gatewayID;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
- generator.setParameter(GatewayProfileConstants.GATEWAY_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
- generator.setParameter(GatewayProfileConstants.GATEWAY_ID, identifier);
- Query q = generator.selectQuery(em);
- GatewayProfile gatewayProfile = (GatewayProfile) q.getSingleResult();
- GatewayProfileAppCatalogResourceAppCat gatewayProfileResource =
- (GatewayProfileAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
- em.getTransaction().commit();
- em.close();
- return gatewayProfileResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> gatewayProfileResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
- List results;
- if (fieldName.equals(GatewayProfileConstants.GATEWAY_ID)) {
- generator.setParameter(GatewayProfileConstants.GATEWAY_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GatewayProfile gatewayProfile = (GatewayProfile) result;
- GatewayProfileAppCatalogResourceAppCat gatewayProfileResource =
- (GatewayProfileAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
- gatewayProfileResources.add(gatewayProfileResource);
- }
- }
- } else if (fieldName.equals(GatewayProfileConstants.GATEWAY_ID)) {
- generator.setParameter(GatewayProfileConstants.GATEWAY_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GatewayProfile gatewayProfile = (GatewayProfile) result;
- GatewayProfileAppCatalogResourceAppCat gatewayProfileResource =
- (GatewayProfileAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
- gatewayProfileResources.add(gatewayProfileResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Gateway Profile resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Gateway Profile resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gatewayProfileResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- List<AppCatalogResource> resourceList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
- Query q = generator.selectQuery(em);
- List results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GatewayProfile gatewayProfile = (GatewayProfile) result;
- GatewayProfileAppCatalogResourceAppCat gatewayProfileResource =
- (GatewayProfileAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
- resourceList.add(gatewayProfileResource);
- }
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> gatewayProfileResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
- List results;
- if (fieldName.equals(GatewayProfileConstants.GATEWAY_ID)) {
- generator.setParameter(GatewayProfileConstants.GATEWAY_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GatewayProfile gatewayProfile = (GatewayProfile) result;
- gatewayProfileResourceIDs.add(gatewayProfile.getGatewayID());
- }
- }
- } else if (fieldName.equals(GatewayProfileConstants.GATEWAY_ID)) {
- generator.setParameter(GatewayProfileConstants.GATEWAY_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GatewayProfile gatewayProfile = (GatewayProfile) result;
- gatewayProfileResourceIDs.add(gatewayProfile.getGatewayID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Gateway Profile resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Gateway Profile resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return gatewayProfileResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GatewayProfile existingGatewayProfile = em.find(GatewayProfile.class, gatewayID);
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingGatewayProfile != null) {
- existingGatewayProfile.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- em.merge(existingGatewayProfile);
- } else {
- GatewayProfile gatewayProfile = new GatewayProfile();
- gatewayProfile.setGatewayID(gatewayID);
- gatewayProfile.setCreationTime(AiravataUtils.getCurrentTimestamp());
- em.persist(gatewayProfile);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GatewayProfile gatewayProfile = em.find(GatewayProfile.class, identifier);
- em.close();
- return gatewayProfile != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getGatewayID() {
- return gatewayID;
- }
-
- public void setGatewayID(String gatewayID) {
- this.gatewayID = gatewayID;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
new file mode 100644
index 0000000..be24822
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GatewayProfileResource.java
@@ -0,0 +1,318 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.GatewayProfile;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+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 GatewayProfileResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(GatewayProfileResource.class);
+
+ private String gatewayID;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
+ generator.setParameter(GatewayProfileConstants.GATEWAY_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
+ generator.setParameter(GatewayProfileConstants.GATEWAY_ID, identifier);
+ Query q = generator.selectQuery(em);
+ GatewayProfile gatewayProfile = (GatewayProfile) q.getSingleResult();
+ GatewayProfileResource gatewayProfileResource =
+ (GatewayProfileResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
+ em.getTransaction().commit();
+ em.close();
+ return gatewayProfileResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> gatewayProfileResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
+ List results;
+ if (fieldName.equals(GatewayProfileConstants.GATEWAY_ID)) {
+ generator.setParameter(GatewayProfileConstants.GATEWAY_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GatewayProfile gatewayProfile = (GatewayProfile) result;
+ GatewayProfileResource gatewayProfileResource =
+ (GatewayProfileResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
+ gatewayProfileResources.add(gatewayProfileResource);
+ }
+ }
+ } else if (fieldName.equals(GatewayProfileConstants.GATEWAY_ID)) {
+ generator.setParameter(GatewayProfileConstants.GATEWAY_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GatewayProfile gatewayProfile = (GatewayProfile) result;
+ GatewayProfileResource gatewayProfileResource =
+ (GatewayProfileResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
+ gatewayProfileResources.add(gatewayProfileResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Gateway Profile resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Gateway Profile resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gatewayProfileResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ List<AppCatalogResource> resourceList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
+ Query q = generator.selectQuery(em);
+ List results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GatewayProfile gatewayProfile = (GatewayProfile) result;
+ GatewayProfileResource gatewayProfileResource =
+ (GatewayProfileResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GATEWAY_PROFILE, gatewayProfile);
+ resourceList.add(gatewayProfileResource);
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> gatewayProfileResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GATEWAY_PROFILE);
+ List results;
+ if (fieldName.equals(GatewayProfileConstants.GATEWAY_ID)) {
+ generator.setParameter(GatewayProfileConstants.GATEWAY_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GatewayProfile gatewayProfile = (GatewayProfile) result;
+ gatewayProfileResourceIDs.add(gatewayProfile.getGatewayID());
+ }
+ }
+ } else if (fieldName.equals(GatewayProfileConstants.GATEWAY_ID)) {
+ generator.setParameter(GatewayProfileConstants.GATEWAY_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GatewayProfile gatewayProfile = (GatewayProfile) result;
+ gatewayProfileResourceIDs.add(gatewayProfile.getGatewayID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Gateway Profile resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Gateway Profile resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return gatewayProfileResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GatewayProfile existingGatewayProfile = em.find(GatewayProfile.class, gatewayID);
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingGatewayProfile != null) {
+ existingGatewayProfile.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ em.merge(existingGatewayProfile);
+ } else {
+ GatewayProfile gatewayProfile = new GatewayProfile();
+ gatewayProfile.setGatewayID(gatewayID);
+ gatewayProfile.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ em.persist(gatewayProfile);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ GatewayProfile gatewayProfile = em.find(GatewayProfile.class, identifier);
+ em.close();
+ return gatewayProfile != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getGatewayID() {
+ return gatewayID;
+ }
+
+ public void setGatewayID(String gatewayID) {
+ this.gatewayID = gatewayID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointAppCatalogResourceAppCat.java
deleted file mode 100644
index 2902f89..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/GlobusGKEndpointAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,323 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.GlobusGKEndPointPK;
-import org.apache.airavata.registry.core.app.catalog.model.GlobusGKEndpoint;
-import org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class GlobusGKEndpointAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(GlobusGKEndpointAppCatalogResourceAppCat.class);
-
- private String submissionID;
- private String endpoint;
-
- private GlobusJobSubmissionAppCatalogResourceAppCat globusJobSubmissionResource;
-
-
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
- generator.setParameter(GlobusEPConstants.ENDPOINT, ids.get(GlobusEPConstants.ENDPOINT));
- generator.setParameter(GlobusEPConstants.SUBMISSION_ID, ids.get(GlobusEPConstants.SUBMISSION_ID));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
- generator.setParameter(GlobusEPConstants.SUBMISSION_ID, ids.get(GlobusEPConstants.SUBMISSION_ID));
- generator.setParameter(GlobusEPConstants.ENDPOINT, ids.get(GlobusEPConstants.ENDPOINT));
- Query q = generator.selectQuery(em);
- GlobusGKEndpoint gkEndpoint = (GlobusGKEndpoint) q.getSingleResult();
- GlobusGKEndpointAppCatalogResourceAppCat gkEndpointResource =
- (GlobusGKEndpointAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, gkEndpoint);
- em.getTransaction().commit();
- em.close();
- return gkEndpointResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> resources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
- List results;
- if (fieldName.equals(GlobusEPConstants.ENDPOINT)) {
- generator.setParameter(GlobusEPConstants.ENDPOINT, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusGKEndpoint gkEndpoint = (GlobusGKEndpoint) result;
- GlobusGKEndpointAppCatalogResourceAppCat gkEndpointResource =
- (GlobusGKEndpointAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, gkEndpoint);
- resources.add(gkEndpointResource);
- }
- }
- } else if (fieldName.equals(GlobusEPConstants.SUBMISSION_ID)) {
- generator.setParameter(GlobusEPConstants.SUBMISSION_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusGKEndpoint globusGKEndpoint = (GlobusGKEndpoint) result;
- GlobusGKEndpointAppCatalogResourceAppCat gkEndpointResource =
- (GlobusGKEndpointAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.GLOBUS_GK_ENDPOINT, globusGKEndpoint);
- resources.add(gkEndpointResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Globus Endpoint Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Globus Endpoint Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> list = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_GK_ENDPOINT);
- List results;
- if (fieldName.equals(GlobusEPConstants.SUBMISSION_ID)) {
- generator.setParameter(GlobusEPConstants.SUBMISSION_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusGKEndpoint globusGKEndpoint = (GlobusGKEndpoint) result;
- list.add(globusGKEndpoint.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GlobusEPConstants.ENDPOINT)) {
- generator.setParameter(GlobusEPConstants.ENDPOINT, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusGKEndpoint globusGKEndpoint = (GlobusGKEndpoint) result;
- list.add(globusGKEndpoint.getSubmissionID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Globus EP resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Globus EP Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return list;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GlobusGKEndpoint existingGlobusEP = em.find(GlobusGKEndpoint.class, new GlobusGKEndPointPK(submissionID, endpoint));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- GlobusJobSubmission globusJobSubmission = em.find(GlobusJobSubmission.class, submissionID);
- if (existingGlobusEP != null) {
- existingGlobusEP.setSubmissionID(submissionID);
- existingGlobusEP.setEndpoint(endpoint);
- existingGlobusEP.setGlobusSubmission(globusJobSubmission);
- em.merge(existingGlobusEP);
- } else {
- GlobusGKEndpoint globusGKEndpoint = new GlobusGKEndpoint();
- globusGKEndpoint.setSubmissionID(submissionID);
- globusGKEndpoint.setEndpoint(endpoint);
- globusGKEndpoint.setGlobusSubmission(globusJobSubmission);
- em.persist(globusGKEndpoint);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- GlobusGKEndpoint gkEndpoint = em.find(GlobusGKEndpoint.class, new GlobusGKEndPointPK(ids.get(GlobusEPConstants.SUBMISSION_ID),
- ids.get(GlobusEPConstants.ENDPOINT)));
-
- em.close();
- return gkEndpoint != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- } }
-
- public String getSubmissionID() {
- return submissionID;
- }
-
- public void setSubmissionID(String submissionID) {
- this.submissionID = submissionID;
- }
-
- public String getEndpoint() {
- return endpoint;
- }
-
- public void setEndpoint(String endpoint) {
- this.endpoint = endpoint;
- }
-
- public GlobusJobSubmissionAppCatalogResourceAppCat getGlobusJobSubmissionResource() {
- return globusJobSubmissionResource;
- }
-
- public void setGlobusJobSubmissionResource(GlobusJobSubmissionAppCatalogResourceAppCat globusJobSubmissionResource) {
- this.globusJobSubmissionResource = globusJobSubmissionResource;
- }
-}
[28/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationInterfaceImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationInterfaceImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationInterfaceImpl.java
index c830f0a..a113d57 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationInterfaceImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationInterfaceImpl.java
@@ -45,7 +45,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public String addApplicationModule(ApplicationModule applicationModule, String gatewayId) throws AppCatalogException {
try {
- AppModuleAppCatalogResourceAppCat moduleResource = new AppModuleAppCatalogResourceAppCat();
+ AppModuleResource moduleResource = new AppModuleResource();
moduleResource.setModuleName(applicationModule.getAppModuleName());
moduleResource.setGatewayId(gatewayId);
if (!applicationModule.getAppModuleId().equals("") && !applicationModule.getAppModuleId().equals(applicationInterfaceModelConstants.DEFAULT_ID)){
@@ -67,7 +67,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public String addApplicationInterface(ApplicationInterfaceDescription applicationInterfaceDescription, String gatewayId) throws AppCatalogException {
try {
- AppInterfaceAppCatalogResourceAppCat resource = new AppInterfaceAppCatalogResourceAppCat();
+ AppInterfaceResource resource = new AppInterfaceResource();
resource.setAppName(applicationInterfaceDescription.getApplicationName());
if (!applicationInterfaceDescription.getApplicationInterfaceId().equals("") && !applicationInterfaceDescription.getApplicationInterfaceId().equals(applicationInterfaceModelConstants.DEFAULT_ID)){
resource.setInterfaceId(applicationInterfaceDescription.getApplicationInterfaceId());
@@ -82,11 +82,11 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
List<String> applicationModules = applicationInterfaceDescription.getApplicationModules();
if (applicationModules != null && !applicationModules.isEmpty()){
for (String moduleId : applicationModules){
- AppModuleAppCatalogResourceAppCat appModuleResource = new AppModuleAppCatalogResourceAppCat();
+ AppModuleResource appModuleResource = new AppModuleResource();
AppModuleMappingAppCatalogResourceAppCat moduleMappingResource = new AppModuleMappingAppCatalogResourceAppCat();
moduleMappingResource.setInterfaceId(resource.getInterfaceId());
moduleMappingResource.setModuleId(moduleId);
- moduleMappingResource.setModuleResource((AppModuleAppCatalogResourceAppCat)appModuleResource.get(moduleId));
+ moduleMappingResource.setModuleResource((AppModuleResource)appModuleResource.get(moduleId));
moduleMappingResource.setAppInterfaceResource(resource);
moduleMappingResource.save();
}
@@ -95,7 +95,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
List<InputDataObjectType> applicationInputs = applicationInterfaceDescription.getApplicationInputs();
if (applicationInputs != null && !applicationInputs.isEmpty()){
for (InputDataObjectType input : applicationInputs){
- ApplicationInputAppCatalogResourceAppCat inputResource = new ApplicationInputAppCatalogResourceAppCat();
+ ApplicationInputResource inputResource = new ApplicationInputResource();
inputResource.setAppInterfaceResource(resource);
inputResource.setInterfaceID(resource.getInterfaceId());
inputResource.setUserFriendlyDesc(input.getUserFriendlyDescription());
@@ -115,7 +115,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
List<OutputDataObjectType> applicationOutputs = applicationInterfaceDescription.getApplicationOutputs();
if (applicationOutputs != null && !applicationOutputs.isEmpty()) {
for (OutputDataObjectType output : applicationOutputs) {
- ApplicationOutputAppCatalogResourceAppCat outputResource = new ApplicationOutputAppCatalogResourceAppCat();
+ ApplicationOutputResource outputResource = new ApplicationOutputResource();
outputResource.setInterfaceID(resource.getInterfaceId());
outputResource.setAppInterfaceResource(resource);
outputResource.setOutputKey(output.getName());
@@ -140,13 +140,13 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public void addApplicationModuleMapping(String moduleId, String interfaceId) throws AppCatalogException {
try {
- AppModuleAppCatalogResourceAppCat appModuleResource = new AppModuleAppCatalogResourceAppCat();
- AppInterfaceAppCatalogResourceAppCat interfaceResource = new AppInterfaceAppCatalogResourceAppCat();
+ AppModuleResource appModuleResource = new AppModuleResource();
+ AppInterfaceResource interfaceResource = new AppInterfaceResource();
AppModuleMappingAppCatalogResourceAppCat moduleMappingResource = new AppModuleMappingAppCatalogResourceAppCat();
moduleMappingResource.setInterfaceId(interfaceId);
moduleMappingResource.setModuleId(moduleId);
- moduleMappingResource.setModuleResource((AppModuleAppCatalogResourceAppCat)appModuleResource.get(moduleId));
- moduleMappingResource.setAppInterfaceResource((AppInterfaceAppCatalogResourceAppCat)interfaceResource.get(interfaceId));
+ moduleMappingResource.setModuleResource((AppModuleResource)appModuleResource.get(moduleId));
+ moduleMappingResource.setAppInterfaceResource((AppInterfaceResource)interfaceResource.get(interfaceId));
moduleMappingResource.save();
}catch (Exception e) {
logger.error("Error while saving application module mapping "+moduleId, e);
@@ -157,8 +157,8 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public void updateApplicationModule(String moduleId, ApplicationModule updatedModule) throws AppCatalogException {
try {
- AppModuleAppCatalogResourceAppCat moduleResource = new AppModuleAppCatalogResourceAppCat();
- AppModuleAppCatalogResourceAppCat existingModule = (AppModuleAppCatalogResourceAppCat)moduleResource.get(moduleId);
+ AppModuleResource moduleResource = new AppModuleResource();
+ AppModuleResource existingModule = (AppModuleResource)moduleResource.get(moduleId);
existingModule.setModuleName(updatedModule.getAppModuleName());
existingModule.setModuleDesc(updatedModule.getAppModuleDescription());
existingModule.setModuleVersion(updatedModule.getAppModuleVersion());
@@ -172,8 +172,8 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public void updateApplicationInterface(String interfaceId, ApplicationInterfaceDescription updatedInterface) throws AppCatalogException {
try {
- AppInterfaceAppCatalogResourceAppCat resource = new AppInterfaceAppCatalogResourceAppCat();
- AppInterfaceAppCatalogResourceAppCat existingInterface = (AppInterfaceAppCatalogResourceAppCat) resource.get(interfaceId);
+ AppInterfaceResource resource = new AppInterfaceResource();
+ AppInterfaceResource existingInterface = (AppInterfaceResource) resource.get(interfaceId);
existingInterface.setAppName(updatedInterface.getApplicationName());
existingInterface.setAppDescription(updatedInterface.getApplicationDescription());
existingInterface.save();
@@ -186,7 +186,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
List<String> applicationModules = updatedInterface.getApplicationModules();
if (applicationModules != null && !applicationModules.isEmpty()) {
for (String moduleId : applicationModules) {
- AppModuleAppCatalogResourceAppCat appModuleResource = new AppModuleAppCatalogResourceAppCat();
+ AppModuleResource appModuleResource = new AppModuleResource();
moduleMappingResource = new AppModuleMappingAppCatalogResourceAppCat();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppModuleMappingConstants.MODULE_ID, moduleId);
@@ -199,26 +199,26 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
}
existingMapping.setInterfaceId(interfaceId);
existingMapping.setModuleId(moduleId);
- existingMapping.setModuleResource((AppModuleAppCatalogResourceAppCat) appModuleResource.get(moduleId));
+ existingMapping.setModuleResource((AppModuleResource) appModuleResource.get(moduleId));
existingMapping.setAppInterfaceResource(existingInterface);
existingMapping.save();
}
}
// remove existing application inputs
- ApplicationInputAppCatalogResourceAppCat inputResource = new ApplicationInputAppCatalogResourceAppCat();
+ ApplicationInputResource inputResource = new ApplicationInputResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppInputConstants.INTERFACE_ID, interfaceId);
inputResource.remove(ids);
List<InputDataObjectType> applicationInputs = updatedInterface.getApplicationInputs();
if (applicationInputs != null && !applicationInputs.isEmpty()) {
for (InputDataObjectType input : applicationInputs) {
- inputResource = new ApplicationInputAppCatalogResourceAppCat();
+ inputResource = new ApplicationInputResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppInputConstants.INTERFACE_ID, interfaceId);
ids.put(AppCatAbstractResource.AppInputConstants.INPUT_KEY, input.getName());
if (inputResource.isExists(ids)) {
- inputResource = (ApplicationInputAppCatalogResourceAppCat) inputResource.get(ids);
+ inputResource = (ApplicationInputResource) inputResource.get(ids);
}
inputResource.setAppInterfaceResource(existingInterface);
inputResource.setInterfaceID(interfaceId);
@@ -237,19 +237,19 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
}
// remove existing app outputs before adding
- ApplicationOutputAppCatalogResourceAppCat outputResource = new ApplicationOutputAppCatalogResourceAppCat();
+ ApplicationOutputResource outputResource = new ApplicationOutputResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppOutputConstants.INTERFACE_ID, interfaceId);
outputResource.remove(ids);
List<OutputDataObjectType> applicationOutputs = updatedInterface.getApplicationOutputs();
if (applicationOutputs != null && !applicationOutputs.isEmpty()) {
for (OutputDataObjectType output : applicationOutputs) {
- outputResource = new ApplicationOutputAppCatalogResourceAppCat();
+ outputResource = new ApplicationOutputResource();
ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.AppOutputConstants.INTERFACE_ID, interfaceId);
ids.put(AppCatAbstractResource.AppOutputConstants.OUTPUT_KEY, output.getName());
if (outputResource.isExists(ids)) {
- outputResource = (ApplicationOutputAppCatalogResourceAppCat) outputResource.get(ids);
+ outputResource = (ApplicationOutputResource) outputResource.get(ids);
}
outputResource.setInterfaceID(interfaceId);
outputResource.setAppInterfaceResource(existingInterface);
@@ -274,8 +274,8 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public ApplicationModule getApplicationModule(String moduleId) throws AppCatalogException {
try {
- AppModuleAppCatalogResourceAppCat appModuleResource = new AppModuleAppCatalogResourceAppCat();
- return AppCatalogThriftConversion.getApplicationModuleDesc((AppModuleAppCatalogResourceAppCat) appModuleResource.get(moduleId));
+ AppModuleResource appModuleResource = new AppModuleResource();
+ return AppCatalogThriftConversion.getApplicationModuleDesc((AppModuleResource) appModuleResource.get(moduleId));
}catch (Exception e) {
logger.error("Error while retrieving application module "+moduleId, e);
throw new AppCatalogException(e);
@@ -285,8 +285,8 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public ApplicationInterfaceDescription getApplicationInterface(String interfaceId) throws AppCatalogException {
try {
- AppInterfaceAppCatalogResourceAppCat interfaceResource = new AppInterfaceAppCatalogResourceAppCat();
- return AppCatalogThriftConversion.getApplicationInterfaceDescription((AppInterfaceAppCatalogResourceAppCat)interfaceResource.get(interfaceId));
+ AppInterfaceResource interfaceResource = new AppInterfaceResource();
+ return AppCatalogThriftConversion.getApplicationInterfaceDescription((AppInterfaceResource)interfaceResource.get(interfaceId));
}catch (Exception e) {
logger.error("Error while retrieving application interface '"+interfaceId, e);
throw new AppCatalogException(e);
@@ -297,7 +297,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
public List<ApplicationModule> getApplicationModules(Map<String, String> filters) throws AppCatalogException {
List<ApplicationModule> modules = new ArrayList<ApplicationModule>();
try {
- AppModuleAppCatalogResourceAppCat resource = new AppModuleAppCatalogResourceAppCat();
+ AppModuleResource resource = new AppModuleResource();
for (String fieldName : filters.keySet() ){
if (fieldName.equals(AppCatAbstractResource.ApplicationModuleConstants.MODULE_NAME)){
List<AppCatalogResource> resources = resource.get(AppCatAbstractResource.ApplicationModuleConstants.MODULE_NAME, filters.get(fieldName));
@@ -320,7 +320,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
public List<ApplicationModule> getAllApplicationModules(String gatewayId) throws AppCatalogException {
List<ApplicationModule> applicationModules = new ArrayList<ApplicationModule>();
try {
- AppModuleAppCatalogResourceAppCat resource = new AppModuleAppCatalogResourceAppCat();
+ AppModuleResource resource = new AppModuleResource();
resource.setGatewayId(gatewayId);
List<AppCatalogResource> resources = resource.getAll();
if (resources != null && !resources.isEmpty()){
@@ -337,7 +337,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
public List<ApplicationInterfaceDescription> getApplicationInterfaces(Map<String, String> filters) throws AppCatalogException {
List<ApplicationInterfaceDescription> appInterfaces = new ArrayList<ApplicationInterfaceDescription>();
try {
- AppInterfaceAppCatalogResourceAppCat resource = new AppInterfaceAppCatalogResourceAppCat();
+ AppInterfaceResource resource = new AppInterfaceResource();
for (String fieldName : filters.keySet() ){
if (fieldName.equals(AppCatAbstractResource.ApplicationInterfaceConstants.APPLICATION_NAME)){
List<AppCatalogResource> resources = resource.get(AppCatAbstractResource.ApplicationInterfaceConstants.APPLICATION_NAME, filters.get(fieldName));
@@ -357,7 +357,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public List<ApplicationInterfaceDescription> getAllApplicationInterfaces(String gatewayId) throws AppCatalogException {
try {
- AppInterfaceAppCatalogResourceAppCat resource = new AppInterfaceAppCatalogResourceAppCat();
+ AppInterfaceResource resource = new AppInterfaceResource();
resource.setGatewayId(gatewayId);
List<AppCatalogResource> resources = resource.getAll();
return AppCatalogThriftConversion.getAppInterfaceDescList(resources);
@@ -370,7 +370,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public List<String> getAllApplicationInterfaceIds() throws AppCatalogException {
try {
- AppInterfaceAppCatalogResourceAppCat resource = new AppInterfaceAppCatalogResourceAppCat();
+ AppInterfaceResource resource = new AppInterfaceResource();
return resource.getAllIds();
}catch (Exception e){
logger.error("Error while retrieving app interface list...", e);
@@ -381,7 +381,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public boolean removeApplicationInterface(String interfaceId) throws AppCatalogException {
try {
- AppInterfaceAppCatalogResourceAppCat resource = new AppInterfaceAppCatalogResourceAppCat();
+ AppInterfaceResource resource = new AppInterfaceResource();
resource.remove(interfaceId);
return true;
}catch (Exception e){
@@ -393,7 +393,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public boolean removeApplicationModule(String moduleId) throws AppCatalogException {
try {
- AppModuleAppCatalogResourceAppCat resource = new AppModuleAppCatalogResourceAppCat();
+ AppModuleResource resource = new AppModuleResource();
resource.remove(moduleId);
return true;
}catch (Exception e){
@@ -405,7 +405,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public boolean isApplicationInterfaceExists(String interfaceId) throws AppCatalogException {
try {
- AppInterfaceAppCatalogResourceAppCat resource = new AppInterfaceAppCatalogResourceAppCat();
+ AppInterfaceResource resource = new AppInterfaceResource();
return resource.isExists(interfaceId);
}catch (Exception e){
logger.error("Error while checking app interface existence "+interfaceId, e);
@@ -416,7 +416,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public boolean isApplicationModuleExists(String moduleId) throws AppCatalogException {
try {
- AppModuleAppCatalogResourceAppCat resource = new AppModuleAppCatalogResourceAppCat();
+ AppModuleResource resource = new AppModuleResource();
return resource.isExists(moduleId);
}catch (Exception e){
logger.error("Error while checking app module existence "+moduleId, e);
@@ -427,7 +427,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public List<InputDataObjectType> getApplicationInputs(String interfaceId) throws AppCatalogException {
try {
- ApplicationInputAppCatalogResourceAppCat resource = new ApplicationInputAppCatalogResourceAppCat();
+ ApplicationInputResource resource = new ApplicationInputResource();
List<AppCatalogResource> resources = resource.get(AppCatAbstractResource.AppInputConstants.INTERFACE_ID, interfaceId);
return AppCatalogThriftConversion.getAppInputs(resources);
}catch (Exception e){
@@ -439,7 +439,7 @@ public class ApplicationInterfaceImpl implements ApplicationInterface {
@Override
public List<OutputDataObjectType> getApplicationOutputs(String interfaceId) throws AppCatalogException {
try {
- ApplicationOutputAppCatalogResourceAppCat resource = new ApplicationOutputAppCatalogResourceAppCat();
+ ApplicationOutputResource resource = new ApplicationOutputResource();
List<AppCatalogResource> resources = resource.get(AppCatAbstractResource.AppOutputConstants.INTERFACE_ID, interfaceId);
return AppCatalogThriftConversion.getAppOutputs(resources);
}catch (Exception e){
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java
index 0f14078..385a92a 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ComputeResourceImpl.java
@@ -51,7 +51,7 @@ public class ComputeResourceImpl implements ComputeResource {
protected String saveComputeResourceDescriptorData(
ComputeResourceDescription description) throws AppCatalogException {
//TODO remove existing one
- ComputeResourceAppCatalogResourceAppCat computeHostResource = saveComputeResource(description);
+ ComputeResourceResource computeHostResource = saveComputeResource(description);
saveHostAliases(description, computeHostResource);
saveIpAddresses(description, computeHostResource);
saveBatchQueues(description, computeHostResource);
@@ -61,21 +61,21 @@ public class ComputeResourceImpl implements ComputeResource {
return computeHostResource.getResourceId();
}
- protected ComputeResourceAppCatalogResourceAppCat saveComputeResource(
+ protected ComputeResourceResource saveComputeResource(
ComputeResourceDescription description) throws AppCatalogException {
- ComputeResourceAppCatalogResourceAppCat computeHostResource = AppCatalogThriftConversion.getComputeHostResource(description);
+ ComputeResourceResource computeHostResource = AppCatalogThriftConversion.getComputeHostResource(description);
computeHostResource.save();
return computeHostResource;
}
protected void saveDataMovementInterfaces(
ComputeResourceDescription description,
- ComputeResourceAppCatalogResourceAppCat computeHostResource)
+ ComputeResourceResource computeHostResource)
throws AppCatalogException {
List<DataMovementInterface> dataMovemenetInterfaces = description.getDataMovementInterfaces();
if (dataMovemenetInterfaces != null && !dataMovemenetInterfaces.isEmpty()) {
for (DataMovementInterface dataMovementInterface : dataMovemenetInterfaces) {
- DataMovementInterfaceAppCatalogResourceAppCat dmir = AppCatalogThriftConversion.getDataMovementInterface(dataMovementInterface);
+ DataMovementInterfaceResource dmir = AppCatalogThriftConversion.getDataMovementInterface(dataMovementInterface);
dmir.setComputeHostResource(computeHostResource);
dmir.setComputeResourceId(computeHostResource.getResourceId());
dmir.save();
@@ -85,12 +85,12 @@ public class ComputeResourceImpl implements ComputeResource {
protected void saveJobSubmissionInterfaces(
ComputeResourceDescription description,
- ComputeResourceAppCatalogResourceAppCat computeHostResource)
+ ComputeResourceResource computeHostResource)
throws AppCatalogException {
List<JobSubmissionInterface> jobSubmissionInterfaces = description.getJobSubmissionInterfaces();
if (jobSubmissionInterfaces != null && !jobSubmissionInterfaces.isEmpty()) {
for (JobSubmissionInterface jobSubmissionInterface : jobSubmissionInterfaces) {
- JobSubmissionInterfaceAppCatalogResourceAppCat jsir = AppCatalogThriftConversion.getJobSubmissionInterface(jobSubmissionInterface);
+ JobSubmissionInterfaceResource jsir = AppCatalogThriftConversion.getJobSubmissionInterface(jobSubmissionInterface);
jsir.setComputeHostResource(computeHostResource);
jsir.setComputeResourceId(computeHostResource.getResourceId());
jsir.save();
@@ -99,12 +99,12 @@ public class ComputeResourceImpl implements ComputeResource {
}
protected void saveFileSystems(ComputeResourceDescription description,
- ComputeResourceAppCatalogResourceAppCat computeHostResource)
+ ComputeResourceResource computeHostResource)
throws AppCatalogException {
Map<FileSystems, String> fileSystems = description.getFileSystems();
if (fileSystems != null && !fileSystems.isEmpty()) {
for (FileSystems key : fileSystems.keySet()) {
- ComputeResourceFileSystemAppCatalogResourceAppCat computeResourceFileSystemResource = new ComputeResourceFileSystemAppCatalogResourceAppCat();
+ ComputeResourceFileSystemResource computeResourceFileSystemResource = new ComputeResourceFileSystemResource();
computeResourceFileSystemResource.setComputeHostResource(computeHostResource);
computeResourceFileSystemResource.setComputeResourceId(computeHostResource.getResourceId());
computeResourceFileSystemResource.setFileSystem(key.toString());
@@ -115,12 +115,12 @@ public class ComputeResourceImpl implements ComputeResource {
}
protected void saveBatchQueues(ComputeResourceDescription description,
- ComputeResourceAppCatalogResourceAppCat computeHostResource)
+ ComputeResourceResource computeHostResource)
throws AppCatalogException {
List<BatchQueue> batchQueueList = description.getBatchQueues();
if (batchQueueList != null && !batchQueueList.isEmpty()) {
for (BatchQueue batchQueue : batchQueueList) {
- BatchQueueAppCatalogResourceAppCat bq = AppCatalogThriftConversion.getBatchQueue(batchQueue);
+ BatchQueueResource bq = AppCatalogThriftConversion.getBatchQueue(batchQueue);
bq.setComputeResourceId(computeHostResource.getResourceId());
bq.setComputeHostResource(computeHostResource);
bq.save();
@@ -129,14 +129,14 @@ public class ComputeResourceImpl implements ComputeResource {
}
protected void saveIpAddresses(ComputeResourceDescription description,
- ComputeResourceAppCatalogResourceAppCat computeHostResource)
+ ComputeResourceResource computeHostResource)
throws AppCatalogException {
List<String> ipAddresses = description.getIpAddresses();
- HostIPAddressAppCatalogResourceAppCat resource = new HostIPAddressAppCatalogResourceAppCat();
+ HostIPAddressResource resource = new HostIPAddressResource();
resource.remove(description.getComputeResourceId());
if (ipAddresses != null && !ipAddresses.isEmpty()) {
for (String ipAddress : ipAddresses) {
- HostIPAddressAppCatalogResourceAppCat ipAddressResource = new HostIPAddressAppCatalogResourceAppCat();
+ HostIPAddressResource ipAddressResource = new HostIPAddressResource();
ipAddressResource.setComputeHostResource(computeHostResource);
ipAddressResource.setResourceID(computeHostResource.getResourceId());
ipAddressResource.setIpaddress(ipAddress);
@@ -146,15 +146,15 @@ public class ComputeResourceImpl implements ComputeResource {
}
protected void saveHostAliases(ComputeResourceDescription description,
- ComputeResourceAppCatalogResourceAppCat computeHostResource)
+ ComputeResourceResource computeHostResource)
throws AppCatalogException {
List<String> hostAliases = description.getHostAliases();
// delete previous host aliases
- HostAliasAppCatalogResourceAppCat resource = new HostAliasAppCatalogResourceAppCat();
+ HostAliasAppResource resource = new HostAliasAppResource();
resource.remove(description.getComputeResourceId());
if (hostAliases != null && !hostAliases.isEmpty()) {
for (String alias : hostAliases) {
- HostAliasAppCatalogResourceAppCat aliasResource = new HostAliasAppCatalogResourceAppCat();
+ HostAliasAppResource aliasResource = new HostAliasAppResource();
aliasResource.setComputeHostResource(computeHostResource);
aliasResource.setResourceID(computeHostResource.getResourceId());
aliasResource.setAlias(alias);
@@ -179,7 +179,7 @@ public class ComputeResourceImpl implements ComputeResource {
String submissionId = AppCatalogUtils.getID("SSH");
sshJobSubmission.setJobSubmissionInterfaceId(submissionId);
String resourceJobManagerId = addResourceJobManager(sshJobSubmission.getResourceJobManager());
- SshJobSubmissionAppCatalogResourceAppCat resource = AppCatalogThriftConversion.getSSHJobSubmission(sshJobSubmission);
+ SshJobSubmissionResource resource = AppCatalogThriftConversion.getSSHJobSubmission(sshJobSubmission);
resource.setResourceJobManagerId(resourceJobManagerId);
resource.getResourceJobManagerResource().setResourceJobManagerId(resourceJobManagerId);
if (sshJobSubmission.getMonitorMode() != null){
@@ -197,7 +197,7 @@ public class ComputeResourceImpl implements ComputeResource {
public String addCloudJobSubmission(CloudJobSubmission sshJobSubmission) throws AppCatalogException {
try {
sshJobSubmission.setJobSubmissionInterfaceId(AppCatalogUtils.getID("Cloud"));
- CloudSubmissionAppCatalogResourceAppCat resource = AppCatalogThriftConversion.getCloudJobSubmission(sshJobSubmission);
+ CloudSubmissionResource resource = AppCatalogThriftConversion.getCloudJobSubmission(sshJobSubmission);
resource.save();
return resource.getJobSubmissionInterfaceId();
}catch (Exception e) {
@@ -211,7 +211,7 @@ public class ComputeResourceImpl implements ComputeResource {
throws AppCatalogException {
try {
unicoreJobSubmission.setJobSubmissionInterfaceId(AppCatalogUtils.getID("UNICORE"));
- UnicoreJobSubmissionAppCatalogResourceAppCat resource = AppCatalogThriftConversion.getUnicoreJobSubmission(unicoreJobSubmission);
+ UnicoreJobSubmissionResource resource = AppCatalogThriftConversion.getUnicoreJobSubmission(unicoreJobSubmission);
resource.setUnicoreEndpointUrl(unicoreJobSubmission.getUnicoreEndPointURL());
if (unicoreJobSubmission.getSecurityProtocol() != null){
resource.setSecurityProtocol(unicoreJobSubmission.getSecurityProtocol().toString());
@@ -228,10 +228,10 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public String addJobSubmissionProtocol(String computeResourceId, JobSubmissionInterface jobSubmissionInterface) throws AppCatalogException {
try {
- JobSubmissionInterfaceAppCatalogResourceAppCat jsi = AppCatalogThriftConversion.getJobSubmissionInterface(jobSubmissionInterface);
+ JobSubmissionInterfaceResource jsi = AppCatalogThriftConversion.getJobSubmissionInterface(jobSubmissionInterface);
jsi.setComputeResourceId(computeResourceId);
- ComputeResourceAppCatalogResourceAppCat computeResourceResource = new ComputeResourceAppCatalogResourceAppCat();
- computeResourceResource=(ComputeResourceAppCatalogResourceAppCat)computeResourceResource.get(computeResourceId);
+ ComputeResourceResource computeResourceResource = new ComputeResourceResource();
+ computeResourceResource=(ComputeResourceResource)computeResourceResource.get(computeResourceId);
jsi.setComputeHostResource(computeResourceResource);
jsi.save();
return jsi.getJobSubmissionInterfaceId();
@@ -341,7 +341,7 @@ public class ComputeResourceImpl implements ComputeResource {
public String addScpDataMovement(SCPDataMovement scpDataMovement) throws AppCatalogException {
try {
scpDataMovement.setDataMovementInterfaceId(AppCatalogUtils.getID("SCP"));
- ScpDataMovementAppCatalogResourceAppCat resource = AppCatalogThriftConversion.getSCPDataMovementDescription(scpDataMovement);
+ ScpDataMovementResource resource = AppCatalogThriftConversion.getSCPDataMovementDescription(scpDataMovement);
resource.save();
return resource.getDataMovementInterfaceId();
}catch (Exception e){
@@ -354,7 +354,7 @@ public class ComputeResourceImpl implements ComputeResource {
public String addUnicoreDataMovement(UnicoreDataMovement unicoreDataMovement) throws AppCatalogException {
try {
unicoreDataMovement.setDataMovementInterfaceId(AppCatalogUtils.getID("UNICORE"));
- UnicoreDataMovementAppCatalogResourceAppCat resource = AppCatalogThriftConversion.getUnicoreDMResource(unicoreDataMovement);
+ UnicoreDataMovementResource resource = AppCatalogThriftConversion.getUnicoreDMResource(unicoreDataMovement);
resource.save();
return resource.getDataMovementId();
}catch (Exception e){
@@ -366,10 +366,10 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public String addDataMovementProtocol(String computeResourceId, DataMovementInterface dataMovementInterface) throws AppCatalogException {
try {
- DataMovementInterfaceAppCatalogResourceAppCat dmi = AppCatalogThriftConversion.getDataMovementInterface(dataMovementInterface);
+ DataMovementInterfaceResource dmi = AppCatalogThriftConversion.getDataMovementInterface(dataMovementInterface);
dmi.setComputeResourceId(computeResourceId);
- ComputeResourceAppCatalogResourceAppCat computeResourceResource = new ComputeResourceAppCatalogResourceAppCat();
- computeResourceResource=(ComputeResourceAppCatalogResourceAppCat)computeResourceResource.get(computeResourceId);
+ ComputeResourceResource computeResourceResource = new ComputeResourceResource();
+ computeResourceResource=(ComputeResourceResource)computeResourceResource.get(computeResourceId);
dmi.setComputeHostResource(computeResourceResource);
dmi.save();
return dmi.getDataMovementInterfaceId();
@@ -383,12 +383,12 @@ public class ComputeResourceImpl implements ComputeResource {
public String addGridFTPDataMovement(GridFTPDataMovement gridFTPDataMovement) throws AppCatalogException {
try {
gridFTPDataMovement.setDataMovementInterfaceId(AppCatalogUtils.getID("GRIDFTP"));
- GridftpDataMovementAppCatalogResourceAppCat resource = AppCatalogThriftConversion.getGridFTPDataMovementDescription(gridFTPDataMovement);
+ GridftpDataMovementResource resource = AppCatalogThriftConversion.getGridFTPDataMovementDescription(gridFTPDataMovement);
resource.save();
List<String> gridFTPEndPoint = gridFTPDataMovement.getGridFTPEndPoints();
if (gridFTPEndPoint != null && !gridFTPEndPoint.isEmpty()) {
for (String endpoint : gridFTPEndPoint) {
- GridftpEndpointAppCatalogResourceAppCat endpointResource = new GridftpEndpointAppCatalogResourceAppCat();
+ GridftpEndpointResource endpointResource = new GridftpEndpointResource();
endpointResource.setDataMovementInterfaceId(resource.getDataMovementInterfaceId());
endpointResource.setEndpoint(endpoint);
endpointResource.setGridftpDataMovementResource(resource);
@@ -405,8 +405,8 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public ComputeResourceDescription getComputeResource(String resourceId) throws AppCatalogException {
try {
- ComputeResourceAppCatalogResourceAppCat resource = new ComputeResourceAppCatalogResourceAppCat();
- ComputeResourceAppCatalogResourceAppCat computeResource = (ComputeResourceAppCatalogResourceAppCat)resource.get(resourceId);
+ ComputeResourceResource resource = new ComputeResourceResource();
+ ComputeResourceResource computeResource = (ComputeResourceResource)resource.get(resourceId);
return AppCatalogThriftConversion.getComputeHostDescription(computeResource);
}catch (Exception e){
logger.error("Error while retrieving compute resource...", e);
@@ -419,7 +419,7 @@ public class ComputeResourceImpl implements ComputeResource {
List<ComputeResourceDescription> computeResourceDescriptions = new ArrayList<ComputeResourceDescription>();
try {
//TODO check if this is correct way to do this
- ComputeResourceAppCatalogResourceAppCat resource = new ComputeResourceAppCatalogResourceAppCat();
+ ComputeResourceResource resource = new ComputeResourceResource();
for (String fieldName : filters.keySet() ){
if (fieldName.equals(AppCatAbstractResource.ComputeResourceConstants.HOST_NAME)){
List<AppCatalogResource> resources = resource.get(AppCatAbstractResource.ComputeResourceConstants.HOST_NAME, filters.get(fieldName));
@@ -442,7 +442,7 @@ public class ComputeResourceImpl implements ComputeResource {
public List<ComputeResourceDescription> getAllComputeResourceList() throws AppCatalogException {
List<ComputeResourceDescription> computeResourceDescriptions = new ArrayList<ComputeResourceDescription>();
try {
- ComputeResourceAppCatalogResourceAppCat resource = new ComputeResourceAppCatalogResourceAppCat();
+ ComputeResourceResource resource = new ComputeResourceResource();
List<AppCatalogResource> resources = resource.getAll();
if (resources != null && !resources.isEmpty()){
computeResourceDescriptions = AppCatalogThriftConversion.getComputeDescriptionList(resources);
@@ -458,11 +458,11 @@ public class ComputeResourceImpl implements ComputeResource {
public Map<String, String> getAllComputeResourceIdList() throws AppCatalogException {
try {
Map<String, String> computeResourceMap = new HashMap<String, String>();
- ComputeResourceAppCatalogResourceAppCat resource = new ComputeResourceAppCatalogResourceAppCat();
+ ComputeResourceResource resource = new ComputeResourceResource();
List<AppCatalogResource> allComputeResources = resource.getAll();
if (allComputeResources != null && !allComputeResources.isEmpty()){
for (AppCatalogResource cm : allComputeResources){
- ComputeResourceAppCatalogResourceAppCat cmr = (ComputeResourceAppCatalogResourceAppCat)cm;
+ ComputeResourceResource cmr = (ComputeResourceResource)cm;
computeResourceMap.put(cmr.getResourceId(), cmr.getHostName());
}
}
@@ -552,8 +552,8 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public SSHJobSubmission getSSHJobSubmission(String submissionId) throws AppCatalogException {
try {
- SshJobSubmissionAppCatalogResourceAppCat resource = new SshJobSubmissionAppCatalogResourceAppCat();
- resource = (SshJobSubmissionAppCatalogResourceAppCat)resource.get(submissionId);
+ SshJobSubmissionResource resource = new SshJobSubmissionResource();
+ resource = (SshJobSubmissionResource)resource.get(submissionId);
return AppCatalogThriftConversion.getSSHJobSubmissionDescription(resource);
}catch (Exception e){
logger.error("Error while retrieving SSH Job Submission...", e);
@@ -587,8 +587,8 @@ public class ComputeResourceImpl implements ComputeResource {
public UnicoreJobSubmission getUNICOREJobSubmission(String submissionId)
throws AppCatalogException {
try {
- UnicoreJobSubmissionAppCatalogResourceAppCat resource = new UnicoreJobSubmissionAppCatalogResourceAppCat();
- resource = (UnicoreJobSubmissionAppCatalogResourceAppCat)resource.get(submissionId);
+ UnicoreJobSubmissionResource resource = new UnicoreJobSubmissionResource();
+ resource = (UnicoreJobSubmissionResource)resource.get(submissionId);
return AppCatalogThriftConversion.getUnicoreJobSubmissionDescription(resource);
}catch (Exception e){
logger.error("Error while retrieving UNICORE Job Submission model instance...", e);
@@ -600,8 +600,8 @@ public class ComputeResourceImpl implements ComputeResource {
public UnicoreDataMovement getUNICOREDataMovement(String dataMovementId)
throws AppCatalogException {
try {
- UnicoreDataMovementAppCatalogResourceAppCat resource = new UnicoreDataMovementAppCatalogResourceAppCat();
- resource = (UnicoreDataMovementAppCatalogResourceAppCat)resource.get(dataMovementId);
+ UnicoreDataMovementResource resource = new UnicoreDataMovementResource();
+ resource = (UnicoreDataMovementResource)resource.get(dataMovementId);
return AppCatalogThriftConversion.getUnicoreDMDescription(resource);
}catch (Exception e){
logger.error("Error while retrieving UNICORE data movement...", e);
@@ -612,8 +612,8 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public CloudJobSubmission getCloudJobSubmission(String submissionId) throws AppCatalogException {
try {
- CloudSubmissionAppCatalogResourceAppCat resource = new CloudSubmissionAppCatalogResourceAppCat();
- resource = (CloudSubmissionAppCatalogResourceAppCat)resource.get(submissionId);
+ CloudSubmissionResource resource = new CloudSubmissionResource();
+ resource = (CloudSubmissionResource)resource.get(submissionId);
return AppCatalogThriftConversion.getCloudJobSubmissionDescription(resource);
}catch (Exception e){
logger.error("Error while retrieving SSH Job Submission...", e);
@@ -646,8 +646,8 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public SCPDataMovement getSCPDataMovement(String dataMoveId) throws AppCatalogException {
try {
- ScpDataMovementAppCatalogResourceAppCat resource = new ScpDataMovementAppCatalogResourceAppCat();
- ScpDataMovementAppCatalogResourceAppCat dataMovementResource = (ScpDataMovementAppCatalogResourceAppCat)resource.get(dataMoveId);
+ ScpDataMovementResource resource = new ScpDataMovementResource();
+ ScpDataMovementResource dataMovementResource = (ScpDataMovementResource)resource.get(dataMoveId);
return AppCatalogThriftConversion.getSCPDataMovementDescription(dataMovementResource);
}catch (Exception e){
logger.error("Error while retrieving SCP Data Movement...", e);
@@ -680,8 +680,8 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public GridFTPDataMovement getGridFTPDataMovement(String dataMoveId) throws AppCatalogException {
try {
- GridftpDataMovementAppCatalogResourceAppCat resource = new GridftpDataMovementAppCatalogResourceAppCat();
- GridftpDataMovementAppCatalogResourceAppCat dataMovementResource = (GridftpDataMovementAppCatalogResourceAppCat)resource.get(dataMoveId);
+ GridftpDataMovementResource resource = new GridftpDataMovementResource();
+ GridftpDataMovementResource dataMovementResource = (GridftpDataMovementResource)resource.get(dataMoveId);
return AppCatalogThriftConversion.getGridFTPDataMovementDescription(dataMovementResource);
}catch (Exception e){
logger.error("Error while retrieving Grid FTP Data Movement...", e);
@@ -714,7 +714,7 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public boolean isComputeResourceExists(String resourceId) throws AppCatalogException {
try {
- ComputeResourceAppCatalogResourceAppCat resource = new ComputeResourceAppCatalogResourceAppCat();
+ ComputeResourceResource resource = new ComputeResourceResource();
return resource.isExists(resourceId);
}catch (Exception e){
logger.error("Error while retrieving compute resource...", e);
@@ -725,7 +725,7 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public void removeComputeResource(String resourceId) throws AppCatalogException {
try {
- ComputeResourceAppCatalogResourceAppCat resource = new ComputeResourceAppCatalogResourceAppCat();
+ ComputeResourceResource resource = new ComputeResourceResource();
resource.remove(resourceId);
}catch (Exception e){
logger.error("Error while removing compute resource...", e);
@@ -736,7 +736,7 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public void removeJobSubmissionInterface(String computeResourceId, String jobSubmissionInterfaceId) throws AppCatalogException {
try {
- JobSubmissionInterfaceAppCatalogResourceAppCat resource = new JobSubmissionInterfaceAppCatalogResourceAppCat();
+ JobSubmissionInterfaceResource resource = new JobSubmissionInterfaceResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, computeResourceId);
ids.put(AppCatAbstractResource.JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID, jobSubmissionInterfaceId);
@@ -750,7 +750,7 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public void removeDataMovementInterface(String computeResourceId, String dataMovementInterfaceId) throws AppCatalogException {
try {
- DataMovementInterfaceAppCatalogResourceAppCat resource = new DataMovementInterfaceAppCatalogResourceAppCat();
+ DataMovementInterfaceResource resource = new DataMovementInterfaceResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID, computeResourceId);
ids.put(AppCatAbstractResource.DataMovementInterfaceConstants.DATA_MOVEMENT_INTERFACE_ID, dataMovementInterfaceId);
@@ -764,7 +764,7 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public void removeBatchQueue(String computeResourceId, String queueName) throws AppCatalogException {
try {
- BatchQueueAppCatalogResourceAppCat resource = new BatchQueueAppCatalogResourceAppCat();
+ BatchQueueResource resource = new BatchQueueResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.BatchQueueConstants.COMPUTE_RESOURCE_ID, computeResourceId);
ids.put(AppCatAbstractResource.BatchQueueConstants.QUEUE_NAME, queueName);
@@ -779,12 +779,12 @@ public class ComputeResourceImpl implements ComputeResource {
public String addResourceJobManager(ResourceJobManager resourceJobManager)
throws AppCatalogException {
resourceJobManager.setResourceJobManagerId(AppCatalogUtils.getID("RJM"));
- ResourceJobManagerAppCatalogResourceAppCat resource = AppCatalogThriftConversion.getResourceJobManager(resourceJobManager);
+ ResourceJobManagerResource resource = AppCatalogThriftConversion.getResourceJobManager(resourceJobManager);
resource.save();
Map<JobManagerCommand, String> jobManagerCommands = resourceJobManager.getJobManagerCommands();
if (jobManagerCommands!=null && jobManagerCommands.size() != 0) {
for (JobManagerCommand commandType : jobManagerCommands.keySet()) {
- JobManagerCommandAppCatalogResourceAppCat r = new JobManagerCommandAppCatalogResourceAppCat();
+ JobManagerCommandResource r = new JobManagerCommandResource();
r.setCommandType(commandType.toString());
r.setCommand(jobManagerCommands.get(commandType));
r.setResourceJobManagerId(resource.getResourceJobManagerId());
@@ -797,21 +797,21 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public void updateResourceJobManager(String resourceJobManagerId, ResourceJobManager updatedResourceJobManager) throws AppCatalogException {
try {
- ResourceJobManagerAppCatalogResourceAppCat resource = AppCatalogThriftConversion.getResourceJobManager(updatedResourceJobManager);
+ ResourceJobManagerResource resource = AppCatalogThriftConversion.getResourceJobManager(updatedResourceJobManager);
resource.setResourceJobManagerId(resourceJobManagerId);
resource.save();
Map<JobManagerCommand, String> jobManagerCommands = updatedResourceJobManager.getJobManagerCommands();
if (jobManagerCommands!=null && jobManagerCommands.size() != 0) {
for (JobManagerCommand commandType : jobManagerCommands.keySet()) {
- JobManagerCommandAppCatalogResourceAppCat r = new JobManagerCommandAppCatalogResourceAppCat();
+ JobManagerCommandResource r = new JobManagerCommandResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, resourceJobManagerId);
ids.put(AppCatAbstractResource.JobManagerCommandConstants.COMMAND_TYPE, commandType.toString());
- JobManagerCommandAppCatalogResourceAppCat existingCommand;
+ JobManagerCommandResource existingCommand;
if (r.isExists(ids)){
- existingCommand = (JobManagerCommandAppCatalogResourceAppCat)r.get(ids);
+ existingCommand = (JobManagerCommandResource)r.get(ids);
}else {
- existingCommand = new JobManagerCommandAppCatalogResourceAppCat();
+ existingCommand = new JobManagerCommandResource();
}
existingCommand.setCommandType(commandType.toString());
existingCommand.setCommand(jobManagerCommands.get(commandType));
@@ -828,8 +828,8 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public ResourceJobManager getResourceJobManager(String resourceJobManagerId) throws AppCatalogException {
try {
- ResourceJobManagerAppCatalogResourceAppCat resource = new ResourceJobManagerAppCatalogResourceAppCat();
- ResourceJobManagerAppCatalogResourceAppCat jobManagerResource = (ResourceJobManagerAppCatalogResourceAppCat)resource.get(resourceJobManagerId);
+ ResourceJobManagerResource resource = new ResourceJobManagerResource();
+ ResourceJobManagerResource jobManagerResource = (ResourceJobManagerResource)resource.get(resourceJobManagerId);
return AppCatalogThriftConversion.getResourceJobManager(jobManagerResource);
}catch (Exception e){
logger.error("Error while retrieving resource job manager..", e);
@@ -840,7 +840,7 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public void deleteResourceJobManager(String resourceJobManagerId) throws AppCatalogException {
try {
- ResourceJobManagerAppCatalogResourceAppCat resource = new ResourceJobManagerAppCatalogResourceAppCat();
+ ResourceJobManagerResource resource = new ResourceJobManagerResource();
resource.remove(resourceJobManagerId);
}catch (Exception e){
logger.error("Error while deleting resource job manager..", e);
@@ -853,7 +853,7 @@ public class ComputeResourceImpl implements ComputeResource {
throws AppCatalogException {
localSubmission.setJobSubmissionInterfaceId(AppCatalogUtils.getID("LOCAL"));
String resourceJobManagerId = addResourceJobManager(localSubmission.getResourceJobManager());
- LocalSubmissionAppCatalogResourceAppCat localJobSubmission = AppCatalogThriftConversion.getLocalJobSubmission(localSubmission);
+ LocalSubmissionResource localJobSubmission = AppCatalogThriftConversion.getLocalJobSubmission(localSubmission);
localJobSubmission.setResourceJobManagerId(resourceJobManagerId);
localJobSubmission.getResourceJobManagerResource().setResourceJobManagerId(resourceJobManagerId);
localJobSubmission.save();
@@ -864,7 +864,7 @@ public class ComputeResourceImpl implements ComputeResource {
public String addLocalDataMovement(LOCALDataMovement localDataMovement)
throws AppCatalogException {
localDataMovement.setDataMovementInterfaceId(AppCatalogUtils.getID("LOCAL"));
- LocalDataMovementAppCatalogResourceAppCat ldm = AppCatalogThriftConversion.getLocalDataMovement(localDataMovement);
+ LocalDataMovementResource ldm = AppCatalogThriftConversion.getLocalDataMovement(localDataMovement);
ldm.save();
return ldm.getDataMovementInterfaceId();
}
@@ -872,16 +872,16 @@ public class ComputeResourceImpl implements ComputeResource {
@Override
public LOCALSubmission getLocalJobSubmission(String submissionId)
throws AppCatalogException {
- LocalSubmissionAppCatalogResourceAppCat localSubmissionResource = new LocalSubmissionAppCatalogResourceAppCat();
- localSubmissionResource= (LocalSubmissionAppCatalogResourceAppCat)localSubmissionResource.get(submissionId);
+ LocalSubmissionResource localSubmissionResource = new LocalSubmissionResource();
+ localSubmissionResource= (LocalSubmissionResource)localSubmissionResource.get(submissionId);
return AppCatalogThriftConversion.getLocalJobSubmission(localSubmissionResource);
}
@Override
public LOCALDataMovement getLocalDataMovement(String datamovementId)
throws AppCatalogException {
- LocalDataMovementAppCatalogResourceAppCat localDataMovementResource = new LocalDataMovementAppCatalogResourceAppCat();
- localDataMovementResource = (LocalDataMovementAppCatalogResourceAppCat) localDataMovementResource.get(datamovementId);
+ LocalDataMovementResource localDataMovementResource = new LocalDataMovementResource();
+ localDataMovementResource = (LocalDataMovementResource) localDataMovementResource.get(datamovementId);
return AppCatalogThriftConversion.getLocalDataMovement(localDataMovementResource);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java
index 05cbcdc..8a4e067 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/GwyResourceProfileImpl.java
@@ -42,7 +42,7 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
@Override
public String addGatewayResourceProfile(org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile gatewayProfile) throws AppCatalogException {
try {
- GatewayProfileAppCatalogResourceAppCat profileResource = new GatewayProfileAppCatalogResourceAppCat();
+ GatewayProfileResource profileResource = new GatewayProfileResource();
if (!gatewayProfile.getGatewayID().equals("") && !gatewayProfile.getGatewayID().equals(gatewayResourceProfileModelConstants.DEFAULT_ID)){
profileResource.setGatewayID(gatewayProfile.getGatewayID());
}
@@ -51,11 +51,11 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
List<ComputeResourcePreference> computeResourcePreferences = gatewayProfile.getComputeResourcePreferences();
if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()){
for (ComputeResourcePreference preference : computeResourcePreferences ){
- ComputeHostPreferenceAppCatalogResourceAppCat resource = new ComputeHostPreferenceAppCatalogResourceAppCat();
+ ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
resource.setGatewayProfile(profileResource);
resource.setResourceId(preference.getComputeResourceId());
- ComputeResourceAppCatalogResourceAppCat computeHostResource = new ComputeResourceAppCatalogResourceAppCat();
- resource.setComputeHostResource((ComputeResourceAppCatalogResourceAppCat)computeHostResource.get(preference.getComputeResourceId()));
+ ComputeResourceResource computeHostResource = new ComputeResourceResource();
+ resource.setComputeHostResource((ComputeResourceResource)computeHostResource.get(preference.getComputeResourceId()));
resource.setGatewayId(profileResource.getGatewayID());
resource.setOverrideByAiravata(preference.isOverridebyAiravata());
resource.setLoginUserName(preference.getLoginUserName());
@@ -83,18 +83,18 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
@Override
public void updateGatewayResourceProfile(String gatewayId, org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile updatedProfile) throws AppCatalogException {
try {
- GatewayProfileAppCatalogResourceAppCat profileResource = new GatewayProfileAppCatalogResourceAppCat();
- GatewayProfileAppCatalogResourceAppCat existingGP = (GatewayProfileAppCatalogResourceAppCat)profileResource.get(gatewayId);
+ GatewayProfileResource profileResource = new GatewayProfileResource();
+ GatewayProfileResource existingGP = (GatewayProfileResource)profileResource.get(gatewayId);
existingGP.save();
List<ComputeResourcePreference> computeResourcePreferences = updatedProfile.getComputeResourcePreferences();
if (computeResourcePreferences != null && !computeResourcePreferences.isEmpty()){
for (ComputeResourcePreference preference : computeResourcePreferences ){
- ComputeHostPreferenceAppCatalogResourceAppCat resource = new ComputeHostPreferenceAppCatalogResourceAppCat();
+ ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
resource.setGatewayProfile(existingGP);
resource.setResourceId(preference.getComputeResourceId());
- ComputeResourceAppCatalogResourceAppCat computeHostResource = new ComputeResourceAppCatalogResourceAppCat();
- resource.setComputeHostResource((ComputeResourceAppCatalogResourceAppCat)computeHostResource.get(preference.getComputeResourceId()));
+ ComputeResourceResource computeHostResource = new ComputeResourceResource();
+ resource.setComputeHostResource((ComputeResourceResource)computeHostResource.get(preference.getComputeResourceId()));
resource.setGatewayId(gatewayId);
resource.setLoginUserName(preference.getLoginUserName());
resource.setOverrideByAiravata(preference.isOverridebyAiravata());
@@ -120,9 +120,9 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
@Override
public GatewayResourceProfile getGatewayProfile(String gatewayId) throws AppCatalogException {
try {
- GatewayProfileAppCatalogResourceAppCat resource = new GatewayProfileAppCatalogResourceAppCat();
- GatewayProfileAppCatalogResourceAppCat gwresource = (GatewayProfileAppCatalogResourceAppCat)resource.get(gatewayId);
- ComputeHostPreferenceAppCatalogResourceAppCat prefResource = new ComputeHostPreferenceAppCatalogResourceAppCat();
+ GatewayProfileResource resource = new GatewayProfileResource();
+ GatewayProfileResource gwresource = (GatewayProfileResource)resource.get(gatewayId);
+ ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
List<ComputeResourcePreference> computeResourcePreferences = AppCatalogThriftConversion.getComputeResourcePreferences(computePrefList);
return AppCatalogThriftConversion.getGatewayResourceProfile(gwresource, computeResourcePreferences);
@@ -135,7 +135,7 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
@Override
public boolean removeGatewayResourceProfile(String gatewayId) throws AppCatalogException {
try {
- GatewayProfileAppCatalogResourceAppCat resource = new GatewayProfileAppCatalogResourceAppCat();
+ GatewayProfileResource resource = new GatewayProfileResource();
resource.remove(gatewayId);
return true;
}catch (Exception e) {
@@ -147,7 +147,7 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
@Override
public boolean removeComputeResourcePreferenceFromGateway(String gatewayId, String preferenceId) throws AppCatalogException {
try {
- ComputeHostPreferenceAppCatalogResourceAppCat resource = new ComputeHostPreferenceAppCatalogResourceAppCat();
+ ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
ids.put(AppCatAbstractResource.ComputeResourcePreferenceConstants.RESOURCE_ID, preferenceId);
@@ -162,7 +162,7 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
@Override
public boolean isGatewayResourceProfileExists(String gatewayId) throws AppCatalogException {
try {
- GatewayProfileAppCatalogResourceAppCat resource = new GatewayProfileAppCatalogResourceAppCat();
+ GatewayProfileResource resource = new GatewayProfileResource();
return resource.isExists(gatewayId);
}catch (Exception e) {
logger.error("Error while retrieving gateway profile...", e);
@@ -178,10 +178,10 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
@Override
public ComputeResourcePreference getComputeResourcePreference(String gatewayId, String hostId) throws AppCatalogException {
try {
- ComputeHostPreferenceAppCatalogResourceAppCat prefResource = new ComputeHostPreferenceAppCatalogResourceAppCat();
+ ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
for (AppCatalogResource resource : computePrefList){
- ComputeHostPreferenceAppCatalogResourceAppCat cmP = (ComputeHostPreferenceAppCatalogResourceAppCat) resource;
+ ComputeHostPreferenceResource cmP = (ComputeHostPreferenceResource) resource;
if (cmP.getResourceId() != null && !cmP.getResourceId().equals("")){
if (cmP.getResourceId().equals(hostId)){
return AppCatalogThriftConversion.getComputeResourcePreference(cmP);
@@ -202,7 +202,7 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
@Override
public List<ComputeResourcePreference> getAllComputeResourcePreferences(String gatewayId) throws AppCatalogException {
try {
- ComputeHostPreferenceAppCatalogResourceAppCat prefResource = new ComputeHostPreferenceAppCatalogResourceAppCat();
+ ComputeHostPreferenceResource prefResource = new ComputeHostPreferenceResource();
List<AppCatalogResource> computePrefList = prefResource.get(AppCatAbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId);
return AppCatalogThriftConversion.getComputeResourcePreferences(computePrefList);
}catch (Exception e) {
@@ -214,12 +214,12 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
@Override
public List<String> getGatewayProfileIds(String gatewayName) throws AppCatalogException {
try {
- GatewayProfileAppCatalogResourceAppCat profileResource = new GatewayProfileAppCatalogResourceAppCat();
+ GatewayProfileResource profileResource = new GatewayProfileResource();
List<AppCatalogResource> resourceList = profileResource.get(AppCatAbstractResource.GatewayProfileConstants.GATEWAY_ID, gatewayName);
List<String> gatewayIds = new ArrayList<String>();
if (resourceList != null && !resourceList.isEmpty()){
for (AppCatalogResource resource : resourceList){
- gatewayIds.add(((GatewayProfileAppCatalogResourceAppCat)resource).getGatewayID());
+ gatewayIds.add(((GatewayProfileResource)resource).getGatewayID());
}
}
return gatewayIds;
@@ -233,11 +233,11 @@ public class GwyResourceProfileImpl implements GwyResourceProfile {
public List<GatewayResourceProfile> getAllGatewayProfiles() throws AppCatalogException {
try {
List<GatewayResourceProfile> gatewayResourceProfileList = new ArrayList<GatewayResourceProfile>();
- GatewayProfileAppCatalogResourceAppCat profileResource = new GatewayProfileAppCatalogResourceAppCat();
+ GatewayProfileResource profileResource = new GatewayProfileResource();
List<AppCatalogResource> resourceList = profileResource.getAll();
if (resourceList != null && !resourceList.isEmpty()){
for (AppCatalogResource resource : resourceList){
- GatewayProfileAppCatalogResourceAppCat gatewayProfileResource = (GatewayProfileAppCatalogResourceAppCat)resource;
+ GatewayProfileResource gatewayProfileResource = (GatewayProfileResource)resource;
List<ComputeResourcePreference> computeResourcePreferences = getAllComputeResourcePreferences(gatewayProfileResource.getGatewayID());
GatewayResourceProfile gatewayResourceProfile = AppCatalogThriftConversion.getGatewayResourceProfile(gatewayProfileResource, computeResourcePreferences);
gatewayResourceProfileList.add(gatewayResourceProfile);
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java
index 3a400cc..da3d66b 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/WorkflowCatalogImpl.java
@@ -44,7 +44,7 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
public List<String> getAllWorkflows(String gatewayId) throws AppCatalogException {
List<String> workflowIds = new ArrayList<String>();
try {
- WorkflowAppCatalogResourceAppCat resource = new WorkflowAppCatalogResourceAppCat();
+ WorkflowResource resource = new WorkflowResource();
resource.setGatewayId(gatewayId);
workflowIds = resource.getAllIds();
} catch (Exception e) {
@@ -57,8 +57,8 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
@Override
public Workflow getWorkflow(String workflowTemplateId) throws AppCatalogException {
try {
- WorkflowAppCatalogResourceAppCat resource = new WorkflowAppCatalogResourceAppCat();
- WorkflowAppCatalogResourceAppCat wfResource = (WorkflowAppCatalogResourceAppCat)resource.get(workflowTemplateId);
+ WorkflowResource resource = new WorkflowResource();
+ WorkflowResource wfResource = (WorkflowResource)resource.get(workflowTemplateId);
return AppCatalogThriftConversion.getWorkflow(wfResource);
} catch (Exception e) {
logger.error("Error while retrieving the workflow...", e);
@@ -69,7 +69,7 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
@Override
public void deleteWorkflow(String workflowTemplateId) throws AppCatalogException {
try {
- WorkflowAppCatalogResourceAppCat resource = new WorkflowAppCatalogResourceAppCat();
+ WorkflowResource resource = new WorkflowResource();
resource.remove(workflowTemplateId);
} catch (Exception e) {
logger.error("Error while deleting the workflow...", e);
@@ -80,7 +80,7 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
@Override
public String registerWorkflow(Workflow workflow, String gatewayId) throws AppCatalogException {
try {
- WorkflowAppCatalogResourceAppCat resource = new WorkflowAppCatalogResourceAppCat();
+ WorkflowResource resource = new WorkflowResource();
resource.setWfTemplateId(AppCatalogUtils.getID(workflow.getName()));
resource.setWfName(workflow.getName());
resource.setGraph(workflow.getGraph());
@@ -93,7 +93,7 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
List<InputDataObjectType> workflowInputs = workflow.getWorkflowInputs();
if (workflowInputs != null && workflowInputs.size() != 0){
for (InputDataObjectType input : workflowInputs){
- WorkflowInputAppCatalogResourceAppCat wfInputResource = new WorkflowInputAppCatalogResourceAppCat();
+ WorkflowInputResource wfInputResource = new WorkflowInputResource();
wfInputResource.setWorkflowResource(resource);
wfInputResource.setInputKey(input.getName());
wfInputResource.setInputVal(input.getValue());
@@ -109,7 +109,7 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
List<OutputDataObjectType> workflowOutputs = workflow.getWorkflowOutputs();
if (workflowOutputs != null && workflowOutputs.size() != 0){
for (OutputDataObjectType output : workflowOutputs){
- WorkflowOutputAppCatalogResourceAppCat outputResource = new WorkflowOutputAppCatalogResourceAppCat();
+ WorkflowOutputResource outputResource = new WorkflowOutputResource();
outputResource.setWorkflowResource(resource);
outputResource.setOutputKey(output.getName());
outputResource.setOutputVal(output.getValue());
@@ -128,8 +128,8 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
@Override
public void updateWorkflow(String workflowTemplateId, Workflow workflow) throws AppCatalogException {
try {
- WorkflowAppCatalogResourceAppCat resource = new WorkflowAppCatalogResourceAppCat();
- WorkflowAppCatalogResourceAppCat existingWF = (WorkflowAppCatalogResourceAppCat)resource.get(workflowTemplateId);
+ WorkflowResource resource = new WorkflowResource();
+ WorkflowResource existingWF = (WorkflowResource)resource.get(workflowTemplateId);
existingWF.setWfName(workflow.getName());
existingWF.setGraph(workflow.getGraph());
if (workflow.getImage() != null){
@@ -139,11 +139,11 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
List<InputDataObjectType> existingwFInputs = workflow.getWorkflowInputs();
if (existingwFInputs != null && existingwFInputs.size() != 0){
for (InputDataObjectType input : existingwFInputs){
- WorkflowInputAppCatalogResourceAppCat wfInputResource = new WorkflowInputAppCatalogResourceAppCat();
+ WorkflowInputResource wfInputResource = new WorkflowInputResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.WFInputConstants.WF_TEMPLATE_ID,existingWF.getWfTemplateId());
ids.put(AppCatAbstractResource.WFInputConstants.INPUT_KEY,input.getName());
- WorkflowInputAppCatalogResourceAppCat existingInput = (WorkflowInputAppCatalogResourceAppCat)wfInputResource.get(ids);
+ WorkflowInputResource existingInput = (WorkflowInputResource)wfInputResource.get(ids);
existingInput.setWorkflowResource(existingWF);
existingInput.setInputKey(input.getName());
existingInput.setInputVal(input.getValue());
@@ -159,11 +159,11 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
List<OutputDataObjectType> workflowOutputs = workflow.getWorkflowOutputs();
if (workflowOutputs != null && workflowOutputs.size() != 0){
for (OutputDataObjectType output : workflowOutputs){
- WorkflowOutputAppCatalogResourceAppCat outputResource = new WorkflowOutputAppCatalogResourceAppCat();
+ WorkflowOutputResource outputResource = new WorkflowOutputResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.WFOutputConstants.WF_TEMPLATE_ID,existingWF.getWfTemplateId());
ids.put(AppCatAbstractResource.WFOutputConstants.OUTPUT_KEY,output.getName());
- WorkflowOutputAppCatalogResourceAppCat existingOutput = (WorkflowOutputAppCatalogResourceAppCat)outputResource.get(ids);
+ WorkflowOutputResource existingOutput = (WorkflowOutputResource)outputResource.get(ids);
existingOutput.setWorkflowResource(existingWF);
existingOutput.setOutputKey(output.getName());
existingOutput.setOutputVal(output.getValue());
@@ -181,10 +181,10 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
@Override
public String getWorkflowTemplateId(String workflowName) throws AppCatalogException {
try {
- WorkflowAppCatalogResourceAppCat resource = new WorkflowAppCatalogResourceAppCat();
+ WorkflowResource resource = new WorkflowResource();
List<AppCatalogResource> resourceList = resource.get(AppCatAbstractResource.WorkflowConstants.WF_NAME, workflowName);
if (resourceList != null && !resourceList.isEmpty()){
- WorkflowAppCatalogResourceAppCat wfResource = (WorkflowAppCatalogResourceAppCat)resourceList.get(0);
+ WorkflowResource wfResource = (WorkflowResource)resourceList.get(0);
return wfResource.getWfTemplateId();
}
} catch (Exception e) {
@@ -197,7 +197,7 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
@Override
public boolean isWorkflowExistWithName(String workflowName) throws AppCatalogException {
try {
- WorkflowAppCatalogResourceAppCat resource = new WorkflowAppCatalogResourceAppCat();
+ WorkflowResource resource = new WorkflowResource();
List<AppCatalogResource> resourceList = resource.get(AppCatAbstractResource.WorkflowConstants.WF_NAME, workflowName);
if (resourceList != null && !resourceList.isEmpty()){
return true;
@@ -211,15 +211,15 @@ public class WorkflowCatalogImpl implements WorkflowCatalog {
@Override
public void updateWorkflowOutputs(String workflowTemplateId, List<OutputDataObjectType> workflowOutputs) throws AppCatalogException {
- WorkflowAppCatalogResourceAppCat resource = new WorkflowAppCatalogResourceAppCat();
- WorkflowAppCatalogResourceAppCat existingWF = (WorkflowAppCatalogResourceAppCat)resource.get(workflowTemplateId);
+ WorkflowResource resource = new WorkflowResource();
+ WorkflowResource existingWF = (WorkflowResource)resource.get(workflowTemplateId);
if (workflowOutputs != null && workflowOutputs.size() != 0) {
for (OutputDataObjectType output : workflowOutputs) {
- WorkflowOutputAppCatalogResourceAppCat outputResource = new WorkflowOutputAppCatalogResourceAppCat();
+ WorkflowOutputResource outputResource = new WorkflowOutputResource();
Map<String, String> ids = new HashMap<String, String>();
ids.put(AppCatAbstractResource.WFOutputConstants.WF_TEMPLATE_ID, existingWF.getWfTemplateId());
ids.put(AppCatAbstractResource.WFOutputConstants.OUTPUT_KEY, output.getName());
- WorkflowOutputAppCatalogResourceAppCat existingOutput = (WorkflowOutputAppCatalogResourceAppCat) outputResource.get(ids);
+ WorkflowOutputResource existingOutput = (WorkflowOutputResource) outputResource.get(ids);
existingOutput.setWorkflowResource(existingWF);
existingOutput.setOutputKey(output.getName());
existingOutput.setOutputVal(output.getValue());
[12/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
index 35605f8..6bae21f 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
@@ -43,16 +43,16 @@ import java.sql.Timestamp;
import java.util.*;
public class ExperimentRegistry {
- private GatewayExperimentCatResource gatewayResource;
- private WorkerExperimentCatResource workerResource;
+ private GatewayResource gatewayResource;
+ private WorkerResource workerResource;
private final static AiravataLogger logger = AiravataLoggerFactory.getLogger(ExperimentRegistry.class);
- public ExperimentRegistry(GatewayExperimentCatResource gateway, UserExperimentCatResource user) throws RegistryException {
+ public ExperimentRegistry(GatewayResource gateway, UserResource user) throws RegistryException {
gatewayResource = gateway;
if (!gatewayResource.isExists(ResourceType.GATEWAY_WORKER, user.getUserName())) {
workerResource = ExpCatResourceUtils.addGatewayWorker(gateway, user);
} else {
- workerResource = (WorkerExperimentCatResource) ExpCatResourceUtils.getWorker(gateway.getGatewayId(), user.getUserName());
+ workerResource = (WorkerResource) ExpCatResourceUtils.getWorker(gateway.getGatewayId(), user.getUserName());
}
}
@@ -66,7 +66,7 @@ public class ExperimentRegistry {
experimentID = getExperimentID(experiment.getName());
experiment.setExperimentID(experimentID);
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
+ ExperimentResource experimentResource = new ExperimentResource();
experimentResource.setExpID(experimentID);
experimentResource.setExpName(experiment.getName());
experimentResource.setExecutionUser(experiment.getUserName());
@@ -90,7 +90,7 @@ public class ExperimentRegistry {
List<String> emailAddresses = experiment.getEmailAddresses();
if (emailAddresses != null && !emailAddresses.isEmpty()){
for (String email : emailAddresses){
- NotificationEmailExperimentCatResource emailResource = new NotificationEmailExperimentCatResource();
+ NotificationEmailResource emailResource = new NotificationEmailResource();
emailResource.setExperimentId(experimentID);
emailResource.setEmailAddress(email);
emailResource.save();
@@ -146,8 +146,8 @@ public class ExperimentRegistry {
public String addUserConfigData(UserConfigurationData configurationData, String experimentID) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment(experimentID);
- ConfigDataExperimentCatResource configData = (ConfigDataExperimentCatResource) experiment.create(ResourceType.CONFIG_DATA);
+ ExperimentResource experiment = gatewayResource.getExperiment(experimentID);
+ ConfigDataResource configData = (ConfigDataResource) experiment.create(ResourceType.CONFIG_DATA);
configData.setExperimentId(experimentID);
configData.setAiravataAutoSchedule(configurationData.isAiravataAutoSchedule());
configData.setOverrideManualParams(configurationData.isOverrideManualScheduledParams());
@@ -182,17 +182,17 @@ public class ExperimentRegistry {
public void addQosParams(QualityOfServiceParams qosParams, ExperimentCatResource resource) throws RegistryException {
try {
- QosParamExperimentCatResource qosr = new QosParamExperimentCatResource();
- if (resource instanceof ExperimentExperimentCatResource) {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) resource;
+ QosParamResource qosr = new QosParamResource();
+ if (resource instanceof ExperimentResource) {
+ ExperimentResource experiment = (ExperimentResource) resource;
qosr.setExperimentId(experiment.getExpID());
}
- if (resource instanceof TaskDetailExperimentCatResource) {
- TaskDetailExperimentCatResource taskDetailResource = (TaskDetailExperimentCatResource) resource;
+ if (resource instanceof TaskDetailResource) {
+ TaskDetailResource taskDetailResource = (TaskDetailResource) resource;
qosr.setTaskId(taskDetailResource.getTaskId());
String nodeId = taskDetailResource.getNodeId();
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
- WorkflowNodeDetailExperimentCatResource workflowNode = experimentResource.getWorkflowNode(nodeId);
+ ExperimentResource experimentResource = new ExperimentResource();
+ WorkflowNodeDetailResource workflowNode = experimentResource.getWorkflowNode(nodeId);
qosr.setExperimentId(workflowNode.getExperimentId());
}
qosr.setStartExecutionAt(qosParams.getStartExecutionAt());
@@ -207,17 +207,17 @@ public class ExperimentRegistry {
}
public void addOutputDataHandling(AdvancedOutputDataHandling outputDataHandling, ExperimentCatResource resource) throws RegistryException {
- AdvancedOutputDataHandlingExperimentCatResource adodh = new AdvancedOutputDataHandlingExperimentCatResource();
+ AdvancedOutputDataHandlingResource adodh = new AdvancedOutputDataHandlingResource();
try {
- if (resource instanceof ExperimentExperimentCatResource) {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) resource;
+ if (resource instanceof ExperimentResource) {
+ ExperimentResource experiment = (ExperimentResource) resource;
adodh.setExperimentId(experiment.getExpID());
}
- if (resource instanceof TaskDetailExperimentCatResource) {
- TaskDetailExperimentCatResource taskDetailResource = (TaskDetailExperimentCatResource) resource;
+ if (resource instanceof TaskDetailResource) {
+ TaskDetailResource taskDetailResource = (TaskDetailResource) resource;
String nodeId = taskDetailResource.getNodeId();
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
- WorkflowNodeDetailExperimentCatResource workflowNode = experimentResource.getWorkflowNode(nodeId);
+ ExperimentResource experimentResource = new ExperimentResource();
+ WorkflowNodeDetailResource workflowNode = experimentResource.getWorkflowNode(nodeId);
adodh.setExperimentId(workflowNode.getExperimentId());
adodh.setTaskId(taskDetailResource.getTaskId());
}
@@ -233,17 +233,17 @@ public class ExperimentRegistry {
}
public void addInputDataHandling(AdvancedInputDataHandling inputDataHandling, ExperimentCatResource resource) throws RegistryException {
- AdvanceInputDataHandlingExperimentCatResource adidh = new AdvanceInputDataHandlingExperimentCatResource();
+ AdvanceInputDataHandlingResource adidh = new AdvanceInputDataHandlingResource();
try {
- if (resource instanceof ExperimentExperimentCatResource) {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) resource;
+ if (resource instanceof ExperimentResource) {
+ ExperimentResource experiment = (ExperimentResource) resource;
adidh.setExperimentId(experiment.getExpID());
}
- if (resource instanceof TaskDetailExperimentCatResource) {
- TaskDetailExperimentCatResource taskDetailResource = (TaskDetailExperimentCatResource) resource;
+ if (resource instanceof TaskDetailResource) {
+ TaskDetailResource taskDetailResource = (TaskDetailResource) resource;
String nodeId = taskDetailResource.getNodeId();
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
- WorkflowNodeDetailExperimentCatResource workflowNode = experimentResource.getWorkflowNode(nodeId);
+ ExperimentResource experimentResource = new ExperimentResource();
+ WorkflowNodeDetailResource workflowNode = experimentResource.getWorkflowNode(nodeId);
adidh.setExperimentId(workflowNode.getExperimentId());
adidh.setTaskId(taskDetailResource.getTaskId());
}
@@ -260,17 +260,17 @@ public class ExperimentRegistry {
}
public void addComputationScheduling(ComputationalResourceScheduling resourceScheduling, ExperimentCatResource resource) throws RegistryException {
- ComputationSchedulingExperimentCatResource cmsr = new ComputationSchedulingExperimentCatResource();
+ ComputationSchedulingResource cmsr = new ComputationSchedulingResource();
try {
- if (resource instanceof ExperimentExperimentCatResource) {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) resource;
+ if (resource instanceof ExperimentResource) {
+ ExperimentResource experiment = (ExperimentResource) resource;
cmsr.setExperimentId(experiment.getExpID());
}
- if (resource instanceof TaskDetailExperimentCatResource) {
- TaskDetailExperimentCatResource taskDetailResource = (TaskDetailExperimentCatResource) resource;
+ if (resource instanceof TaskDetailResource) {
+ TaskDetailResource taskDetailResource = (TaskDetailResource) resource;
String nodeId = taskDetailResource.getNodeId();
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
- WorkflowNodeDetailExperimentCatResource workflowNode = experimentResource.getWorkflowNode(nodeId);
+ ExperimentResource experimentResource = new ExperimentResource();
+ WorkflowNodeDetailResource workflowNode = experimentResource.getWorkflowNode(nodeId);
cmsr.setExperimentId(workflowNode.getExperimentId());
cmsr.setTaskId(taskDetailResource.getTaskId());
}
@@ -291,10 +291,10 @@ public class ExperimentRegistry {
}
- public void addExpInputs(List<InputDataObjectType> exInputs, ExperimentExperimentCatResource experimentResource) throws RegistryException {
+ public void addExpInputs(List<InputDataObjectType> exInputs, ExperimentResource experimentResource) throws RegistryException {
try {
for (InputDataObjectType input : exInputs) {
- ExperimentInputExperimentCatResource resource = (ExperimentInputExperimentCatResource) experimentResource.create(ResourceType.EXPERIMENT_INPUT);
+ ExperimentInputResource resource = (ExperimentInputResource) experimentResource.create(ResourceType.EXPERIMENT_INPUT);
resource.setExperimentId(experimentResource.getExpID());
resource.setExperimentKey(input.getName());
resource.setValue(input.getValue());
@@ -314,11 +314,11 @@ public class ExperimentRegistry {
}
}
- public void updateExpInputs(List<InputDataObjectType> exInputs, ExperimentExperimentCatResource experimentResource) throws RegistryException {
+ public void updateExpInputs(List<InputDataObjectType> exInputs, ExperimentResource experimentResource) throws RegistryException {
try {
- List<ExperimentInputExperimentCatResource> experimentInputs = experimentResource.getExperimentInputs();
+ List<ExperimentInputResource> experimentInputs = experimentResource.getExperimentInputs();
for (InputDataObjectType input : exInputs) {
- for (ExperimentInputExperimentCatResource exinput : experimentInputs) {
+ for (ExperimentInputResource exinput : experimentInputs) {
if (exinput.getExperimentKey().equals(input.getName())) {
exinput.setValue(input.getValue());
if (input.getType() != null) {
@@ -342,9 +342,9 @@ public class ExperimentRegistry {
public String addExpOutputs(List<OutputDataObjectType> exOutput, String expId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment(expId);
+ ExperimentResource experiment = gatewayResource.getExperiment(expId);
for (OutputDataObjectType output : exOutput) {
- ExperimentOutputExperimentCatResource resource = (ExperimentOutputExperimentCatResource) experiment.create(ResourceType.EXPERIMENT_OUTPUT);
+ ExperimentOutputResource resource = (ExperimentOutputResource) experiment.create(ResourceType.EXPERIMENT_OUTPUT);
resource.setExperimentId(expId);
resource.setExperimentKey(output.getName());
resource.setValue(output.getValue());
@@ -369,10 +369,10 @@ public class ExperimentRegistry {
public void updateExpOutputs(List<OutputDataObjectType> exOutput, String expId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment(expId);
- List<ExperimentOutputExperimentCatResource> existingExpOutputs = experiment.getExperimentOutputs();
+ ExperimentResource experiment = gatewayResource.getExperiment(expId);
+ List<ExperimentOutputResource> existingExpOutputs = experiment.getExperimentOutputs();
for (OutputDataObjectType output : exOutput) {
- for (ExperimentOutputExperimentCatResource resource : existingExpOutputs) {
+ for (ExperimentOutputResource resource : existingExpOutputs) {
if (resource.getExperimentKey().equals(output.getName())) {
resource.setExperimentId(expId);
resource.setExperimentKey(output.getName());
@@ -399,10 +399,10 @@ public class ExperimentRegistry {
public String addNodeOutputs(List<OutputDataObjectType> wfOutputs, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode((String) ids.getSecondLevelIdentifier());
+ ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) ids.getSecondLevelIdentifier());
for (OutputDataObjectType output : wfOutputs) {
- NodeOutputExperimentCatResource resource = (NodeOutputExperimentCatResource) workflowNode.create(ResourceType.NODE_OUTPUT);
+ NodeOutputResource resource = (NodeOutputResource) workflowNode.create(ResourceType.NODE_OUTPUT);
resource.setNodeId(workflowNode.getNodeInstanceId());
resource.setOutputKey(output.getName());
resource.setValue(output.getValue());
@@ -427,11 +427,11 @@ public class ExperimentRegistry {
public void updateNodeOutputs(List<OutputDataObjectType> wfOutputs, String nodeId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode(nodeId);
- List<NodeOutputExperimentCatResource> nodeOutputs = workflowNode.getNodeOutputs();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode(nodeId);
+ List<NodeOutputResource> nodeOutputs = workflowNode.getNodeOutputs();
for (OutputDataObjectType output : wfOutputs) {
- for (NodeOutputExperimentCatResource resource : nodeOutputs) {
+ for (NodeOutputResource resource : nodeOutputs) {
resource.setNodeId(workflowNode.getNodeInstanceId());
resource.setOutputKey(output.getName());
resource.setValue(output.getValue());
@@ -456,11 +456,11 @@ public class ExperimentRegistry {
public String addApplicationOutputs(List<OutputDataObjectType> appOutputs, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode((String) ids.getTopLevelIdentifier());
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) ids.getSecondLevelIdentifier());
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) ids.getTopLevelIdentifier());
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) ids.getSecondLevelIdentifier());
for (OutputDataObjectType output : appOutputs) {
- ApplicationOutputExperimentCatResource resource = (ApplicationOutputExperimentCatResource) taskDetail.create(ResourceType.APPLICATION_OUTPUT);
+ ApplicationOutputResource resource = (ApplicationOutputResource) taskDetail.create(ResourceType.APPLICATION_OUTPUT);
resource.setTaskId(taskDetail.getTaskId());
resource.setOutputKey(output.getName());
resource.setValue(output.getValue());
@@ -485,10 +485,10 @@ public class ExperimentRegistry {
public String updateExperimentStatus(ExperimentStatus experimentStatus, String expId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment(expId);
- StatusExperimentCatResource status = experiment.getExperimentStatus();
+ ExperimentResource experiment = gatewayResource.getExperiment(expId);
+ StatusResource status = experiment.getExperimentStatus();
if (status == null) {
- status = (StatusExperimentCatResource) experiment.create(ResourceType.STATUS);
+ status = (StatusResource) experiment.create(ResourceType.STATUS);
}
status.setExperimentId(expId);
status.setStatusUpdateTime(AiravataUtils.getTime(experimentStatus.getTimeOfStateChange()));
@@ -510,9 +510,9 @@ public class ExperimentRegistry {
public String addWorkflowNodeStatus(WorkflowNodeStatus status, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode((String) ids.getSecondLevelIdentifier());
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) experiment.create(ResourceType.STATUS);
+ ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) ids.getSecondLevelIdentifier());
+ StatusResource statusResource = (StatusResource) experiment.create(ResourceType.STATUS);
statusResource.setExperimentId(experiment.getExpID());
statusResource.setNodeId(workflowNode.getNodeInstanceId());
statusResource.setStatusType(StatusType.WORKFLOW_NODE.toString());
@@ -532,11 +532,11 @@ public class ExperimentRegistry {
public String updateWorkflowNodeStatus(WorkflowNodeStatus status, String nodeId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode(nodeId);
- StatusExperimentCatResource statusResource = workflowNode.getWorkflowNodeStatus();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode(nodeId);
+ StatusResource statusResource = workflowNode.getWorkflowNodeStatus();
if (statusResource == null) {
- statusResource = (StatusExperimentCatResource) workflowNode.create(ResourceType.STATUS);
+ statusResource = (StatusResource) workflowNode.create(ResourceType.STATUS);
}
statusResource.setExperimentId(workflowNode.getExperimentId());
statusResource.setNodeId(nodeId);
@@ -554,10 +554,10 @@ public class ExperimentRegistry {
public String addTaskStatus(TaskStatus status, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode((String) ids.getTopLevelIdentifier());
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) ids.getSecondLevelIdentifier());
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) workflowNode.create(ResourceType.STATUS);
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) ids.getTopLevelIdentifier());
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) ids.getSecondLevelIdentifier());
+ StatusResource statusResource = (StatusResource) workflowNode.create(ResourceType.STATUS);
statusResource.setExperimentId(workflowNode.getExperimentId());
statusResource.setNodeId(workflowNode.getNodeInstanceId());
statusResource.setTaskId(taskDetail.getTaskId());
@@ -578,15 +578,15 @@ public class ExperimentRegistry {
public void updateTaskStatus(TaskStatus status, String taskId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail(taskId);
- StatusExperimentCatResource statusResource;
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail(taskId);
+ StatusResource statusResource;
if (taskDetail.isTaskStatusExist(taskId)) {
workflowNode = experiment.getWorkflowNode(taskDetail.getNodeId());
statusResource = workflowNode.getTaskStatus(taskId);
} else {
- statusResource = (StatusExperimentCatResource) taskDetail.create(ResourceType.STATUS);
+ statusResource = (StatusResource) taskDetail.create(ResourceType.STATUS);
}
statusResource.setExperimentId(workflowNode.getExperimentId());
statusResource.setNodeId(workflowNode.getNodeInstanceId());
@@ -609,12 +609,12 @@ public class ExperimentRegistry {
*/
public String addJobStatus(JobStatus status, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
workflowNode = experiment.getWorkflowNode(taskDetail.getNodeId());
- JobDetailExperimentCatResource jobDetail = taskDetail.getJobDetail((String) ids.getSecondLevelIdentifier());
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) jobDetail.create(ResourceType.STATUS);
+ JobDetailResource jobDetail = taskDetail.getJobDetail((String) ids.getSecondLevelIdentifier());
+ StatusResource statusResource = (StatusResource) jobDetail.create(ResourceType.STATUS);
statusResource.setExperimentId(workflowNode.getExperimentId());
statusResource.setNodeId(workflowNode.getNodeInstanceId());
statusResource.setTaskId(taskDetail.getTaskId());
@@ -635,11 +635,11 @@ public class ExperimentRegistry {
public String updateJobStatus(JobStatus status, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
- JobDetailExperimentCatResource jobDetail = taskDetail.getJobDetail((String) ids.getSecondLevelIdentifier());
- StatusExperimentCatResource statusResource = jobDetail.getJobStatus();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
+ JobDetailResource jobDetail = taskDetail.getJobDetail((String) ids.getSecondLevelIdentifier());
+ StatusResource statusResource = jobDetail.getJobStatus();
workflowNode = experiment.getWorkflowNode(taskDetail.getNodeId());
statusResource.setExperimentId(workflowNode.getExperimentId());
statusResource.setNodeId(workflowNode.getNodeInstanceId());
@@ -663,11 +663,11 @@ public class ExperimentRegistry {
*/
public String addApplicationStatus(ApplicationStatus status, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
- JobDetailExperimentCatResource jobDetail = taskDetail.getJobDetail((String) ids.getSecondLevelIdentifier());
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) jobDetail.create(ResourceType.STATUS);
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
+ JobDetailResource jobDetail = taskDetail.getJobDetail((String) ids.getSecondLevelIdentifier());
+ StatusResource statusResource = (StatusResource) jobDetail.create(ResourceType.STATUS);
workflowNode = experiment.getWorkflowNode(taskDetail.getNodeId());
statusResource.setExperimentId(workflowNode.getExperimentId());
statusResource.setNodeId(workflowNode.getNodeInstanceId());
@@ -689,11 +689,11 @@ public class ExperimentRegistry {
public void updateApplicationStatus(ApplicationStatus status, String jobId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = (TaskDetailExperimentCatResource) workflowNode.create(ResourceType.TASK_DETAIL);
- JobDetailExperimentCatResource jobDetail = taskDetail.getJobDetail(jobId);
- StatusExperimentCatResource statusResource = jobDetail.getApplicationStatus();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = (TaskDetailResource) workflowNode.create(ResourceType.TASK_DETAIL);
+ JobDetailResource jobDetail = taskDetail.getJobDetail(jobId);
+ StatusResource statusResource = jobDetail.getApplicationStatus();
workflowNode = experiment.getWorkflowNode(taskDetail.getNodeId());
statusResource.setExperimentId(workflowNode.getExperimentId());
statusResource.setNodeId(workflowNode.getNodeInstanceId());
@@ -716,11 +716,11 @@ public class ExperimentRegistry {
*/
public String addTransferStatus(TransferStatus status, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
- DataTransferDetailExperimentCatResource dataTransferDetail = taskDetail.getDataTransferDetail((String) ids.getSecondLevelIdentifier());
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) dataTransferDetail.create(ResourceType.STATUS);
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
+ DataTransferDetailResource dataTransferDetail = taskDetail.getDataTransferDetail((String) ids.getSecondLevelIdentifier());
+ StatusResource statusResource = (StatusResource) dataTransferDetail.create(ResourceType.STATUS);
workflowNode = experiment.getWorkflowNode(taskDetail.getNodeId());
statusResource.setExperimentId(workflowNode.getExperimentId());
statusResource.setNodeId(workflowNode.getNodeInstanceId());
@@ -743,11 +743,11 @@ public class ExperimentRegistry {
public void updateTransferStatus(TransferStatus status, String transferId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = (TaskDetailExperimentCatResource) workflowNode.create(ResourceType.TASK_DETAIL);
- DataTransferDetailExperimentCatResource dataTransferDetail = taskDetail.getDataTransferDetail(transferId);
- StatusExperimentCatResource statusResource = dataTransferDetail.getDataTransferStatus();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = (TaskDetailResource) workflowNode.create(ResourceType.TASK_DETAIL);
+ DataTransferDetailResource dataTransferDetail = taskDetail.getDataTransferDetail(transferId);
+ StatusResource statusResource = dataTransferDetail.getDataTransferStatus();
String taskId = dataTransferDetail.getTaskId();
taskDetail = workflowNode.getTaskDetail(taskId);
@@ -770,8 +770,8 @@ public class ExperimentRegistry {
public String addWorkflowNodeDetails(WorkflowNodeDetails nodeDetails, String expId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment(expId);
- WorkflowNodeDetailExperimentCatResource resource = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ ExperimentResource experiment = gatewayResource.getExperiment(expId);
+ WorkflowNodeDetailResource resource = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
resource.setExperimentId(expId);
resource.setNodeName(nodeDetails.getNodeName());
resource.setExecutionUnit(nodeDetails.getExecutionUnit().toString());
@@ -828,8 +828,8 @@ public class ExperimentRegistry {
public void updateWorkflowNodeDetails(WorkflowNodeDetails nodeDetails, String nodeId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode(nodeId);
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode(nodeId);
workflowNode.setNodeName(nodeDetails.getNodeName());
workflowNode.setExecutionUnit(nodeDetails.getExecutionUnit().toString());
workflowNode.setExecutionUnitData(nodeDetails.getExecutionUnitData());
@@ -878,10 +878,10 @@ public class ExperimentRegistry {
}
- public void addWorkflowInputs(List<InputDataObjectType> wfInputs, WorkflowNodeDetailExperimentCatResource nodeDetailResource) throws RegistryException {
+ public void addWorkflowInputs(List<InputDataObjectType> wfInputs, WorkflowNodeDetailResource nodeDetailResource) throws RegistryException {
try {
for (InputDataObjectType input : wfInputs) {
- NodeInputExperimentCatResource resource = (NodeInputExperimentCatResource) nodeDetailResource.create(ResourceType.NODE_INPUT);
+ NodeInputResource resource = (NodeInputResource) nodeDetailResource.create(ResourceType.NODE_INPUT);
resource.setNodeId(nodeDetailResource.getNodeInstanceId());
resource.setInputKey(input.getName());
resource.setValue(input.getValue());
@@ -902,11 +902,11 @@ public class ExperimentRegistry {
}
- public void updateWorkflowInputs(List<InputDataObjectType> wfInputs, WorkflowNodeDetailExperimentCatResource nodeDetailResource) throws RegistryException {
+ public void updateWorkflowInputs(List<InputDataObjectType> wfInputs, WorkflowNodeDetailResource nodeDetailResource) throws RegistryException {
try {
- List<NodeInputExperimentCatResource> nodeInputs = nodeDetailResource.getNodeInputs();
+ List<NodeInputResource> nodeInputs = nodeDetailResource.getNodeInputs();
for (InputDataObjectType input : wfInputs) {
- for (NodeInputExperimentCatResource resource : nodeInputs) {
+ for (NodeInputResource resource : nodeInputs) {
resource.setNodeId(nodeDetailResource.getNodeInstanceId());
resource.setInputKey(input.getName());
resource.setValue(input.getValue());
@@ -930,9 +930,9 @@ public class ExperimentRegistry {
public String addTaskDetails(TaskDetails taskDetails, String nodeId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode(nodeId);
- TaskDetailExperimentCatResource taskDetail = (TaskDetailExperimentCatResource) workflowNode.create(ResourceType.TASK_DETAIL);
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode(nodeId);
+ TaskDetailResource taskDetail = (TaskDetailResource) workflowNode.create(ResourceType.TASK_DETAIL);
taskDetail.setNodeId(nodeId);
taskDetail.setTaskId(getTaskID(workflowNode.getNodeName()));
taskDetail.setApplicationId(taskDetails.getApplicationId());
@@ -944,7 +944,7 @@ public class ExperimentRegistry {
List<String> emailAddresses = taskDetails.getEmailAddresses();
if (emailAddresses != null && !emailAddresses.isEmpty()){
for (String email : emailAddresses){
- NotificationEmailExperimentCatResource emailResource = new NotificationEmailExperimentCatResource();
+ NotificationEmailResource emailResource = new NotificationEmailResource();
emailResource.setExperimentId(workflowNode.getExperimentId());
emailResource.setTaskId(taskDetail.getTaskId());
emailResource.setEmailAddress(email);
@@ -1018,9 +1018,9 @@ public class ExperimentRegistry {
public String updateTaskDetails(TaskDetails taskDetails, String taskId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail(taskId);
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail(taskId);
// taskDetail.setWorkflowNodeDetailResource(workflowNode);
taskDetail.setApplicationId(taskDetails.getApplicationId());
taskDetail.setApplicationVersion(taskDetails.getApplicationVersion());
@@ -1036,7 +1036,7 @@ public class ExperimentRegistry {
taskDetail.remove(ResourceType.NOTIFICATION_EMAIL, taskId);
if (emailAddresses != null && !emailAddresses.isEmpty()){
for (String email : emailAddresses){
- NotificationEmailExperimentCatResource emailResource = new NotificationEmailExperimentCatResource();
+ NotificationEmailResource emailResource = new NotificationEmailResource();
emailResource.setExperimentId(workflowNode.getExperimentId());
emailResource.setTaskId(taskId);
emailResource.setEmailAddress(email);
@@ -1092,10 +1092,10 @@ public class ExperimentRegistry {
}
}
- public void addAppInputs(List<InputDataObjectType> appInputs, TaskDetailExperimentCatResource taskDetailResource) throws RegistryException {
+ public void addAppInputs(List<InputDataObjectType> appInputs, TaskDetailResource taskDetailResource) throws RegistryException {
try {
for (InputDataObjectType input : appInputs) {
- ApplicationInputExperimentCatResource resource = (ApplicationInputExperimentCatResource) taskDetailResource.create(ResourceType.APPLICATION_INPUT);
+ ApplicationInputResource resource = (ApplicationInputResource) taskDetailResource.create(ResourceType.APPLICATION_INPUT);
resource.setTaskId(taskDetailResource.getTaskId());
resource.setInputKey(input.getName());
resource.setValue(input.getValue());
@@ -1116,10 +1116,10 @@ public class ExperimentRegistry {
}
- public void addAppOutputs(List<OutputDataObjectType> appOytputs, TaskDetailExperimentCatResource taskDetailResource) throws RegistryException {
+ public void addAppOutputs(List<OutputDataObjectType> appOytputs, TaskDetailResource taskDetailResource) throws RegistryException {
try {
for (OutputDataObjectType output : appOytputs) {
- ApplicationOutputExperimentCatResource resource = (ApplicationOutputExperimentCatResource) taskDetailResource.create(ResourceType.APPLICATION_OUTPUT);
+ ApplicationOutputResource resource = (ApplicationOutputResource) taskDetailResource.create(ResourceType.APPLICATION_OUTPUT);
resource.setTaskId(taskDetailResource.getTaskId());
resource.setOutputKey(output.getName());
resource.setValue(output.getValue());
@@ -1143,12 +1143,12 @@ public class ExperimentRegistry {
public void updateAppOutputs(List<OutputDataObjectType> appOutputs, String taskId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail(taskId);
- List<ApplicationOutputExperimentCatResource> outputs = taskDetail.getApplicationOutputs();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail(taskId);
+ List<ApplicationOutputResource> outputs = taskDetail.getApplicationOutputs();
for (OutputDataObjectType output : appOutputs) {
- for (ApplicationOutputExperimentCatResource resource : outputs) {
+ for (ApplicationOutputResource resource : outputs) {
resource.setTaskId(taskId);
resource.setOutputKey(output.getName());
resource.setValue(output.getValue());
@@ -1171,11 +1171,11 @@ public class ExperimentRegistry {
}
}
- public void updateAppInputs(List<InputDataObjectType> appInputs, TaskDetailExperimentCatResource taskDetailResource) throws RegistryException {
+ public void updateAppInputs(List<InputDataObjectType> appInputs, TaskDetailResource taskDetailResource) throws RegistryException {
try {
- List<ApplicationInputExperimentCatResource> inputs = taskDetailResource.getApplicationInputs();
+ List<ApplicationInputResource> inputs = taskDetailResource.getApplicationInputs();
for (InputDataObjectType input : appInputs) {
- for (ApplicationInputExperimentCatResource resource : inputs) {
+ for (ApplicationInputResource resource : inputs) {
resource.setTaskId(taskDetailResource.getTaskId());
resource.setInputKey(input.getName());
resource.setValue(input.getValue());
@@ -1200,10 +1200,10 @@ public class ExperimentRegistry {
public String addJobDetails(JobDetails jobDetails, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
- JobDetailExperimentCatResource jobDetail = taskDetail.createJobDetail((String) ids.getSecondLevelIdentifier());
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) ids.getTopLevelIdentifier());
+ JobDetailResource jobDetail = taskDetail.createJobDetail((String) ids.getSecondLevelIdentifier());
jobDetail.setTaskId(taskDetail.getTaskId());
jobDetail.setJobDescription(jobDetails.getJobDescription());
jobDetail.setCreationTime(AiravataUtils.getTime(jobDetails.getCreationTime()));
@@ -1245,12 +1245,12 @@ public class ExperimentRegistry {
// ids - taskId + jobid
public void updateJobDetails(JobDetails jobDetails, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
String taskId = (String) ids.getTopLevelIdentifier();
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail(taskId);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail(taskId);
String jobId = (String) ids.getSecondLevelIdentifier();
- JobDetailExperimentCatResource jobDetail = taskDetail.getJobDetail(jobId);
+ JobDetailResource jobDetail = taskDetail.getJobDetail(jobId);
jobDetail.setTaskId(taskDetail.getTaskId());
jobDetail.setJobDescription(jobDetails.getJobDescription());
jobDetail.setCreationTime(AiravataUtils.getTime(jobDetails.getCreationTime()));
@@ -1293,10 +1293,10 @@ public class ExperimentRegistry {
if (transferDetails.getTransferDescription() == null){
throw new RegistryException("Data transfer description cannot be empty");
}
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail(taskId);
- DataTransferDetailExperimentCatResource resource = (DataTransferDetailExperimentCatResource) taskDetail.create(ResourceType.DATA_TRANSFER_DETAIL);
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail(taskId);
+ DataTransferDetailResource resource = (DataTransferDetailResource) taskDetail.create(ResourceType.DATA_TRANSFER_DETAIL);
resource.setTaskId(taskId);
resource.setTransferId(getDataTransferID(taskId));
@@ -1323,10 +1323,10 @@ public class ExperimentRegistry {
public String updateDataTransferDetails(DataTransferDetails transferDetails, String transferId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = (TaskDetailExperimentCatResource) workflowNode.create(ResourceType.TASK_DETAIL);
- DataTransferDetailExperimentCatResource resource = taskDetail.getDataTransferDetail(transferId);
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = (TaskDetailResource) workflowNode.create(ResourceType.TASK_DETAIL);
+ DataTransferDetailResource resource = taskDetail.getDataTransferDetail(transferId);
// resource.setTaskDetailResource(taskDetail);
resource.setTransferDescription(transferDetails.getTransferDescription());
resource.setCreationTime(AiravataUtils.getTime(transferDetails.getCreationTime()));
@@ -1356,11 +1356,11 @@ public class ExperimentRegistry {
*/
public String addComputationalResourceScheduling(ComputationalResourceScheduling scheduling, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
- ComputationSchedulingExperimentCatResource schedulingResource = (ComputationSchedulingExperimentCatResource) experiment.create(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING);
+ ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
+ ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) experiment.create(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING);
if (ids.getSecondLevelIdentifier() != null) {
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
+ WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
schedulingResource.setTaskId(taskDetail.getTaskId());
}
schedulingResource.setExperimentId(experiment.getExpID());
@@ -1388,11 +1388,11 @@ public class ExperimentRegistry {
*/
public String addInputDataHandling(AdvancedInputDataHandling dataHandling, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
- AdvanceInputDataHandlingExperimentCatResource dataHandlingResource = (AdvanceInputDataHandlingExperimentCatResource) experiment.create(ResourceType.ADVANCE_INPUT_DATA_HANDLING);
+ ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
+ AdvanceInputDataHandlingResource dataHandlingResource = (AdvanceInputDataHandlingResource) experiment.create(ResourceType.ADVANCE_INPUT_DATA_HANDLING);
if (ids.getSecondLevelIdentifier() != null) {
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
+ WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
dataHandlingResource.setTaskId(taskDetail.getTaskId());
}
dataHandlingResource.setExperimentId(experiment.getExpID());
@@ -1415,11 +1415,11 @@ public class ExperimentRegistry {
*/
public String addOutputDataHandling(AdvancedOutputDataHandling dataHandling, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
- AdvancedOutputDataHandlingExperimentCatResource dataHandlingResource = (AdvancedOutputDataHandlingExperimentCatResource) experiment.create(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING);
+ ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
+ AdvancedOutputDataHandlingResource dataHandlingResource = (AdvancedOutputDataHandlingResource) experiment.create(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING);
if (ids.getSecondLevelIdentifier() != null) {
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
+ WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
dataHandlingResource.setTaskId(taskDetail.getTaskId());
}
dataHandlingResource.setExperimentId(experiment.getExpID());
@@ -1436,11 +1436,11 @@ public class ExperimentRegistry {
public String addQosParams(QualityOfServiceParams qosParams, CompositeIdentifier ids) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
- QosParamExperimentCatResource qosParamResource = (QosParamExperimentCatResource) experiment.create(ResourceType.QOS_PARAM);
+ ExperimentResource experiment = gatewayResource.getExperiment((String) ids.getTopLevelIdentifier());
+ QosParamResource qosParamResource = (QosParamResource) experiment.create(ResourceType.QOS_PARAM);
if (ids.getSecondLevelIdentifier() != null) {
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
+ WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = nodeDetailResource.getTaskDetail((String) ids.getSecondLevelIdentifier());
qosParamResource.setTaskId(taskDetail.getTaskId());
}
qosParamResource.setExperimentId(experiment.getExpID());
@@ -1458,10 +1458,10 @@ public class ExperimentRegistry {
public String addErrorDetails(ErrorDetails error, Object id) throws RegistryException {
try {
- ErrorDetailExperimentCatResource errorResource = null;
- ExperimentExperimentCatResource experiment;
- TaskDetailExperimentCatResource taskDetail;
- WorkflowNodeDetailExperimentCatResource workflowNode;
+ ErrorDetailResource errorResource = null;
+ ExperimentResource experiment;
+ TaskDetailResource taskDetail;
+ WorkflowNodeDetailResource workflowNode;
// figure out the id is an experiment, node task or job
if (id instanceof String) {
// FIXME : for .12 we only save task related errors
@@ -1475,14 +1475,14 @@ public class ExperimentRegistry {
// errorResource.setExperimentResource(workflowNode.getExperimentResource());
// } else
if (isTaskDetailExist((String) id)) {
- experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
taskDetail = workflowNode.getTaskDetail((String) id);
- errorResource = (ErrorDetailExperimentCatResource) taskDetail.create(ResourceType.ERROR_DETAIL);
+ errorResource = (ErrorDetailResource) taskDetail.create(ResourceType.ERROR_DETAIL);
if (error.getErrorID() != null && !error.getErrorID().equals(experimentModelConstants.DEFAULT_ID)) {
- List<ErrorDetailExperimentCatResource> errorDetailList = taskDetail.getErrorDetailList();
+ List<ErrorDetailResource> errorDetailList = taskDetail.getErrorDetailList();
if (errorDetailList != null && !errorDetailList.isEmpty()) {
- for (ErrorDetailExperimentCatResource errorDetailResource : errorDetailList) {
+ for (ErrorDetailResource errorDetailResource : errorDetailList) {
if (errorDetailResource.getErrorId() == Integer.parseInt(error.getErrorID())) {
errorResource = errorDetailResource;
}
@@ -1499,15 +1499,15 @@ public class ExperimentRegistry {
} else if (id instanceof CompositeIdentifier) {
CompositeIdentifier cid = (CompositeIdentifier) id;
if (isJobDetailExist(cid)) {
- experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
taskDetail = workflowNode.getTaskDetail((String) cid.getTopLevelIdentifier());
- JobDetailExperimentCatResource jobDetail = taskDetail.getJobDetail((String) cid.getSecondLevelIdentifier());
- errorResource = (ErrorDetailExperimentCatResource) jobDetail.create(ResourceType.ERROR_DETAIL);
+ JobDetailResource jobDetail = taskDetail.getJobDetail((String) cid.getSecondLevelIdentifier());
+ errorResource = (ErrorDetailResource) jobDetail.create(ResourceType.ERROR_DETAIL);
if (error.getErrorID() != null && !error.getErrorID().equals(experimentModelConstants.DEFAULT_ID)) {
- List<ErrorDetailExperimentCatResource> errorDetailList = taskDetail.getErrorDetailList();
+ List<ErrorDetailResource> errorDetailList = taskDetail.getErrorDetailList();
if (errorDetailList != null && !errorDetailList.isEmpty()) {
- for (ErrorDetailExperimentCatResource errorDetailResource : errorDetailList) {
+ for (ErrorDetailResource errorDetailResource : errorDetailList) {
if (errorDetailResource.getErrorId() == Integer.parseInt(error.getErrorID())) {
errorResource = errorDetailResource;
}
@@ -1575,7 +1575,7 @@ public class ExperimentRegistry {
public void updateExperimentField(String expID, String fieldName, Object value) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment(expID);
+ ExperimentResource experiment = gatewayResource.getExperiment(expID);
if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME)) {
experiment.setExpName((String) value);
experiment.save();
@@ -1609,8 +1609,8 @@ public class ExperimentRegistry {
public void updateExpConfigDataField(String expID, String fieldName, Object value) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment(expID);
- ConfigDataExperimentCatResource exConfigData = (ConfigDataExperimentCatResource) experiment.get(ResourceType.CONFIG_DATA, expID);
+ ExperimentResource experiment = gatewayResource.getExperiment(expID);
+ ConfigDataResource exConfigData = (ConfigDataResource) experiment.get(ResourceType.CONFIG_DATA, expID);
if (fieldName.equals(Constants.FieldConstants.ConfigurationDataConstants.AIRAVATA_AUTO_SCHEDULE)) {
exConfigData.setAiravataAutoSchedule((Boolean) value);
exConfigData.save();
@@ -1640,7 +1640,7 @@ public class ExperimentRegistry {
public void updateExperiment(Experiment experiment, String expId) throws RegistryException {
try {
- ExperimentExperimentCatResource existingExperiment = gatewayResource.getExperiment(expId);
+ ExperimentResource existingExperiment = gatewayResource.getExperiment(expId);
existingExperiment.setExpName(experiment.getName());
existingExperiment.setExecutionUser(experiment.getUserName());
existingExperiment.setGatewayId(gatewayResource.getGatewayId());
@@ -1665,7 +1665,7 @@ public class ExperimentRegistry {
existingExperiment.remove(ResourceType.NOTIFICATION_EMAIL, expId);
if (emailAddresses != null && !emailAddresses.isEmpty()){
for (String email : emailAddresses){
- NotificationEmailExperimentCatResource emailResource = new NotificationEmailExperimentCatResource();
+ NotificationEmailResource emailResource = new NotificationEmailResource();
emailResource.setExperimentId(expId);
emailResource.setEmailAddress(email);
emailResource.save();
@@ -1711,8 +1711,8 @@ public class ExperimentRegistry {
public void updateUserConfigData(UserConfigurationData configData, String expId) throws RegistryException {
try {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment(expId);
- ConfigDataExperimentCatResource resource = (ConfigDataExperimentCatResource) experiment.get(ResourceType.CONFIG_DATA, expId);
+ ExperimentResource experiment = gatewayResource.getExperiment(expId);
+ ConfigDataResource resource = (ConfigDataResource) experiment.get(ResourceType.CONFIG_DATA, expId);
resource.setExperimentId(expId);
resource.setAiravataAutoSchedule(configData.isAiravataAutoSchedule());
resource.setOverrideManualParams(configData.isOverrideManualScheduledParams());
@@ -1746,9 +1746,9 @@ public class ExperimentRegistry {
public void updateQosParams(QualityOfServiceParams qosParams, ExperimentCatResource resource) throws RegistryException {
try {
- if (resource instanceof ExperimentExperimentCatResource) {
- ExperimentExperimentCatResource expResource = (ExperimentExperimentCatResource) resource;
- QosParamExperimentCatResource qosr = expResource.getQOSparams(expResource.getExpID());
+ if (resource instanceof ExperimentResource) {
+ ExperimentResource expResource = (ExperimentResource) resource;
+ QosParamResource qosr = expResource.getQOSparams(expResource.getExpID());
qosr.setExperimentId(expResource.getExpID());
qosr.setStartExecutionAt(qosParams.getStartExecutionAt());
qosr.setExecuteBefore(qosParams.getExecuteBefore());
@@ -1763,18 +1763,18 @@ public class ExperimentRegistry {
}
public void updateOutputDataHandling(AdvancedOutputDataHandling outputDataHandling, ExperimentCatResource resource) throws RegistryException {
- AdvancedOutputDataHandlingExperimentCatResource adodh;
+ AdvancedOutputDataHandlingResource adodh;
try {
- if (resource instanceof ExperimentExperimentCatResource) {
- ExperimentExperimentCatResource expResource = (ExperimentExperimentCatResource) resource;
+ if (resource instanceof ExperimentResource) {
+ ExperimentResource expResource = (ExperimentResource) resource;
adodh = expResource.getOutputDataHandling(expResource.getExpID());
adodh.setExperimentId(expResource.getExpID());
} else {
- TaskDetailExperimentCatResource taskDetailResource = (TaskDetailExperimentCatResource) resource;
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
+ TaskDetailResource taskDetailResource = (TaskDetailResource) resource;
+ ExperimentResource experimentResource = new ExperimentResource();
adodh = taskDetailResource.getOutputDataHandling(taskDetailResource.getTaskId());
adodh.setTaskId(taskDetailResource.getTaskId());
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = experimentResource.getWorkflowNode(taskDetailResource.getNodeId());
+ WorkflowNodeDetailResource nodeDetailResource = experimentResource.getWorkflowNode(taskDetailResource.getNodeId());
adodh.setExperimentId(nodeDetailResource.getExperimentId());
}
adodh.setOutputDataDir(outputDataHandling.getOutputDataDir());
@@ -1789,18 +1789,18 @@ public class ExperimentRegistry {
}
public void updateInputDataHandling(AdvancedInputDataHandling inputDataHandling, ExperimentCatResource resource) throws RegistryException {
- AdvanceInputDataHandlingExperimentCatResource adidh;
+ AdvanceInputDataHandlingResource adidh;
try {
- if (resource instanceof ExperimentExperimentCatResource) {
- ExperimentExperimentCatResource expResource = (ExperimentExperimentCatResource) resource;
+ if (resource instanceof ExperimentResource) {
+ ExperimentResource expResource = (ExperimentResource) resource;
adidh = expResource.getInputDataHandling(expResource.getExpID());
adidh.setExperimentId(expResource.getExpID());
} else {
- TaskDetailExperimentCatResource taskDetailResource = (TaskDetailExperimentCatResource) resource;
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
+ TaskDetailResource taskDetailResource = (TaskDetailResource) resource;
+ ExperimentResource experimentResource = new ExperimentResource();
adidh = taskDetailResource.getInputDataHandling(taskDetailResource.getTaskId());
adidh.setTaskId(taskDetailResource.getTaskId());
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = experimentResource.getWorkflowNode(taskDetailResource.getNodeId());
+ WorkflowNodeDetailResource nodeDetailResource = experimentResource.getWorkflowNode(taskDetailResource.getNodeId());
adidh.setExperimentId(nodeDetailResource.getExperimentId());
}
adidh.setWorkingDir(inputDataHandling.getUniqueWorkingDirectory());
@@ -1816,18 +1816,18 @@ public class ExperimentRegistry {
}
public void updateSchedulingData(ComputationalResourceScheduling resourceScheduling, ExperimentCatResource resource) throws RegistryException {
- ComputationSchedulingExperimentCatResource cmsr;
+ ComputationSchedulingResource cmsr;
try {
- if (resource instanceof ExperimentExperimentCatResource) {
- ExperimentExperimentCatResource expResource = (ExperimentExperimentCatResource) resource;
+ if (resource instanceof ExperimentResource) {
+ ExperimentResource expResource = (ExperimentResource) resource;
cmsr = expResource.getComputationScheduling(expResource.getExpID());
cmsr.setExperimentId(expResource.getExpID());
} else {
- TaskDetailExperimentCatResource taskDetailResource = (TaskDetailExperimentCatResource) resource;
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
+ TaskDetailResource taskDetailResource = (TaskDetailResource) resource;
+ ExperimentResource experimentResource = new ExperimentResource();
cmsr = taskDetailResource.getComputationScheduling(taskDetailResource.getTaskId());
cmsr.setTaskId(taskDetailResource.getTaskId());
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = experimentResource.getWorkflowNode(taskDetailResource.getNodeId());
+ WorkflowNodeDetailResource nodeDetailResource = experimentResource.getWorkflowNode(taskDetailResource.getNodeId());
cmsr.setExperimentId(nodeDetailResource.getExperimentId());
}
cmsr.setResourceHostId(resourceScheduling.getResourceHostId());
@@ -1857,25 +1857,25 @@ public class ExperimentRegistry {
List<Experiment> experiments = new ArrayList<Experiment>();
try {
if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) {
- WorkerExperimentCatResource resource = (WorkerExperimentCatResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
+ WorkerResource resource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
resource.setUser((String) value);
- List<ExperimentExperimentCatResource> resources = resource.getExperiments();
- for (ExperimentExperimentCatResource experimentResource : resources) {
+ List<ExperimentResource> resources = resource.getExperiments();
+ for (ExperimentResource experimentResource : resources) {
Experiment experiment = ThriftDataModelConversion.getExperiment(experimentResource);
experiments.add(experiment);
}
return experiments;
} else if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.PROJECT_ID)) {
- ProjectExperimentCatResource project = workerResource.getProject((String) value);
- List<ExperimentExperimentCatResource> resources = project.getExperiments();
- for (ExperimentExperimentCatResource resource : resources) {
+ ProjectResource project = workerResource.getProject((String) value);
+ List<ExperimentResource> resources = project.getExperiments();
+ for (ExperimentResource resource : resources) {
Experiment experiment = ThriftDataModelConversion.getExperiment(resource);
experiments.add(experiment);
}
return experiments;
} else if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.GATEWAY)) {
- List<ExperimentExperimentCatResource> resources = gatewayResource.getExperiments();
- for (ExperimentExperimentCatResource resource : resources) {
+ List<ExperimentResource> resources = gatewayResource.getExperiments();
+ for (ExperimentResource resource : resources) {
Experiment experiment = ThriftDataModelConversion.getExperiment(resource);
experiments.add(experiment);
}
@@ -1885,10 +1885,10 @@ public class ExperimentRegistry {
if (value instanceof List<?>) {
return getExperimentList(fieldName, ((List<?>) value).get(0));
} else if (value instanceof WorkflowNodeDetails) {
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = getWorkflowNodeDetailResource(((WorkflowNodeDetails) value).getNodeInstanceId());
+ WorkflowNodeDetailResource nodeDetailResource = getWorkflowNodeDetailResource(((WorkflowNodeDetails) value).getNodeInstanceId());
if (nodeDetailResource != null) {
String experimentId = nodeDetailResource.getExperimentId();
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment(experimentId);
+ ExperimentResource experiment = gatewayResource.getExperiment(experimentId);
return Arrays.asList(ThriftDataModelConversion
.getExperiment(experiment));
}
@@ -1922,20 +1922,20 @@ public class ExperimentRegistry {
List<Experiment> experiments = new ArrayList<Experiment>();
try {
if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) {
- WorkerExperimentCatResource resource = (WorkerExperimentCatResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
+ WorkerResource resource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
resource.setUser((String) value);
- List<ExperimentExperimentCatResource> resources = resource.getExperiments(limit, offset,
+ List<ExperimentResource> resources = resource.getExperiments(limit, offset,
orderByIdentifier, resultOrderType);
- for (ExperimentExperimentCatResource experimentResource : resources) {
+ for (ExperimentResource experimentResource : resources) {
Experiment experiment = ThriftDataModelConversion.getExperiment(experimentResource);
experiments.add(experiment);
}
return experiments;
} else if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.PROJECT_ID)) {
- ProjectExperimentCatResource project = workerResource.getProject((String) value);
- List<ExperimentExperimentCatResource> resources = project.getExperiments(limit, offset,
+ ProjectResource project = workerResource.getProject((String) value);
+ List<ExperimentResource> resources = project.getExperiments(limit, offset,
Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
- for (ExperimentExperimentCatResource resource : resources) {
+ for (ExperimentResource resource : resources) {
Experiment experiment = ThriftDataModelConversion.getExperiment(resource);
experiments.add(experiment);
}
@@ -1953,8 +1953,8 @@ public class ExperimentRegistry {
public List<WorkflowNodeDetails> getWFNodeDetails(String fieldName, Object value) throws RegistryException {
try {
if (fieldName.equals(Constants.FieldConstants.WorkflowNodeConstants.EXPERIMENT_ID)) {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment((String) value);
- List<WorkflowNodeDetailExperimentCatResource> workflowNodeDetails = experiment.getWorkflowNodeDetails();
+ ExperimentResource experiment = gatewayResource.getExperiment((String) value);
+ List<WorkflowNodeDetailResource> workflowNodeDetails = experiment.getWorkflowNodeDetails();
return ThriftDataModelConversion.getWfNodeList(workflowNodeDetails);
}
@@ -1962,10 +1962,10 @@ public class ExperimentRegistry {
if (value instanceof List<?>) {
return getWFNodeDetails(fieldName, ((List<?>) value).get(0));
} else if (value instanceof TaskDetails) {
- TaskDetailExperimentCatResource taskDetailResource = getTaskDetailResource(((TaskDetails) value).getTaskID());
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
+ TaskDetailResource taskDetailResource = getTaskDetailResource(((TaskDetails) value).getTaskID());
+ ExperimentResource experimentResource = new ExperimentResource();
if (taskDetailResource != null) {
- WorkflowNodeDetailExperimentCatResource workflowNode = experimentResource.getWorkflowNode(taskDetailResource.getNodeId());
+ WorkflowNodeDetailResource workflowNode = experimentResource.getWorkflowNode(taskDetailResource.getNodeId());
return Arrays.asList(ThriftDataModelConversion
.getWorkflowNodeDetails(workflowNode));
}
@@ -1985,8 +1985,8 @@ public class ExperimentRegistry {
public List<WorkflowNodeStatus> getWFNodeStatusList(String fieldName, Object value) throws RegistryException {
try {
if (fieldName.equals(Constants.FieldConstants.WorkflowNodeStatusConstants.EXPERIMENT_ID)) {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment((String) value);
- List<StatusExperimentCatResource> workflowNodeStatuses = experiment.getWorkflowNodeStatuses();
+ ExperimentResource experiment = gatewayResource.getExperiment((String) value);
+ List<StatusResource> workflowNodeStatuses = experiment.getWorkflowNodeStatuses();
return ThriftDataModelConversion.getWorkflowNodeStatusList(workflowNodeStatuses);
} else {
logger.error("Unsupported field name to retrieve workflow status list...");
@@ -2001,9 +2001,9 @@ public class ExperimentRegistry {
public List<TaskDetails> getTaskDetails(String fieldName, Object value) throws RegistryException {
try {
if (fieldName.equals(Constants.FieldConstants.TaskDetailConstants.NODE_ID)) {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode((String) value);
- List<TaskDetailExperimentCatResource> taskDetails = workflowNode.getTaskDetails();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) value);
+ List<TaskDetailResource> taskDetails = workflowNode.getTaskDetails();
return ThriftDataModelConversion.getTaskDetailsList(taskDetails);
} else {
logger.error("Unsupported field name to retrieve task detail list...");
@@ -2018,10 +2018,10 @@ public class ExperimentRegistry {
public List<JobDetails> getJobDetails(String fieldName, Object value) throws RegistryException {
try {
if (fieldName.equals(Constants.FieldConstants.JobDetaisConstants.TASK_ID)) {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) value);
- List<JobDetailExperimentCatResource> jobDetailList = taskDetail.getJobDetailList();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) value);
+ List<JobDetailResource> jobDetailList = taskDetail.getJobDetailList();
return ThriftDataModelConversion.getJobDetailsList(jobDetailList);
} else {
logger.error("Unsupported field name to retrieve job details list...");
@@ -2036,10 +2036,10 @@ public class ExperimentRegistry {
public List<DataTransferDetails> getDataTransferDetails(String fieldName, Object value) throws RegistryException {
try {
if (fieldName.equals(Constants.FieldConstants.DataTransferDetailConstants.TASK_ID)) {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) value);
- List<DataTransferDetailExperimentCatResource> dataTransferDetailList = taskDetail.getDataTransferDetailList();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) value);
+ List<DataTransferDetailResource> dataTransferDetailList = taskDetail.getDataTransferDetailList();
return ThriftDataModelConversion.getDataTransferlList(dataTransferDetailList);
} else {
logger.error("Unsupported field name to retrieve job details list...");
@@ -2054,27 +2054,27 @@ public class ExperimentRegistry {
public List<ErrorDetails> getErrorDetails(String fieldName, Object value) throws RegistryException {
try {
if (fieldName.equals(Constants.FieldConstants.ErrorDetailsConstants.EXPERIMENT_ID)) {
- ExperimentExperimentCatResource experiment = gatewayResource.getExperiment((String) value);
- List<ErrorDetailExperimentCatResource> errorDetails = experiment.getErrorDetails();
+ ExperimentResource experiment = gatewayResource.getExperiment((String) value);
+ List<ErrorDetailResource> errorDetails = experiment.getErrorDetails();
return ThriftDataModelConversion.getErrorDetailList(errorDetails);
} else if (fieldName.equals(Constants.FieldConstants.ErrorDetailsConstants.NODE_ID)) {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = experiment.getWorkflowNode((String) value);
- List<ErrorDetailExperimentCatResource> errorDetails = workflowNode.getErrorDetails();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = experiment.getWorkflowNode((String) value);
+ List<ErrorDetailResource> errorDetails = workflowNode.getErrorDetails();
return ThriftDataModelConversion.getErrorDetailList(errorDetails);
} else if (fieldName.equals(Constants.FieldConstants.ErrorDetailsConstants.TASK_ID)) {
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) value);
- List<ErrorDetailExperimentCatResource> errorDetailList = taskDetail.getErrorDetailList();
+ ExperimentResource experiment = (ExperimentResource) gatewayResource.create(ResourceType.EXPERIMENT);
+ WorkflowNodeDetailResource workflowNode = (WorkflowNodeDetailResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
+ TaskDetailResource taskDetail = workflowNode.getTaskDetail((String) value);
+ List<ErrorDetailResource> errorDetailList = taskDetail.getErrorDetailList();
return ThriftDataModelConversion.getErrorDetailList(errorDetailList);
} else if (fieldName.equals(Constants.FieldConstants.ErrorDetailsConstants.JOB_ID)) {
CompositeIdentifier cid = (CompositeIdentifier) value;
- ExperimentExperimentCatResource experiment = (ExperimentExperimentCatResource) gatewayResource.create(ResourceType.EXPERIMENT);
- WorkflowNodeDetailExperimentCatResource workflowNode = (WorkflowNodeDetailExperimentCatResource) experiment.create(ResourceType.WORKFLOW_NODE_DETAIL);
- TaskDetailExperimentCatResource taskDetail = workflowNode.getTaskDetail((String) cid.getTopLevelIdentifier());
- JobDetailExperimentCatResource jobDetail = taskDetail.getJobDetail((String) cid.getSecondLevelIdentifier());
- List<ErrorDetailExperimentCatResource> errorDetails = jobDetail.getErrorDetails();
+
<TRUNCATED>
[16/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementAppCatalogResourceAppCat.java
deleted file mode 100644
index 59839ea..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,308 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.ScpDataMovement;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-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 ScpDataMovementAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(ScpDataMovementAppCatalogResourceAppCat.class);
- private String queueDescription;
- private String dataMovementInterfaceId;
- private String securityProtocol;
- private String alternativeScpHostname;
- private int sshPort;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
- generator.setParameter(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
- generator.setParameter(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
- Query q = generator.selectQuery(em);
- ScpDataMovement scpDataMovement = (ScpDataMovement) q.getSingleResult();
- ScpDataMovementAppCatalogResourceAppCat scpDataMovementResource = (ScpDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SCP_DATA_MOVEMENT, scpDataMovement);
- em.getTransaction().commit();
- em.close();
- return scpDataMovementResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> scpDataMovementResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
- Query q;
- if ((fieldName.equals(ScpDataMovementConstants.QUEUE_DESCRIPTION)) || (fieldName.equals(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(ScpDataMovementConstants.SECURITY_PROTOCOL)) || (fieldName.equals(ScpDataMovementConstants.ALTERNATIVE_SCP_HOSTNAME)) || (fieldName.equals(ScpDataMovementConstants.SSH_PORT))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ScpDataMovement scpDataMovement = (ScpDataMovement) result;
- ScpDataMovementAppCatalogResourceAppCat scpDataMovementResource = (ScpDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SCP_DATA_MOVEMENT, scpDataMovement);
- scpDataMovementResources.add(scpDataMovementResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Scp Data Movement Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Scp Data Movement Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return scpDataMovementResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> scpDataMovementResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
- Query q;
- if ((fieldName.equals(ScpDataMovementConstants.QUEUE_DESCRIPTION)) || (fieldName.equals(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(ScpDataMovementConstants.SECURITY_PROTOCOL)) || (fieldName.equals(ScpDataMovementConstants.ALTERNATIVE_SCP_HOSTNAME)) || (fieldName.equals(ScpDataMovementConstants.SSH_PORT))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ScpDataMovement scpDataMovement = (ScpDataMovement) result;
- ScpDataMovementAppCatalogResourceAppCat scpDataMovementResource = (ScpDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SCP_DATA_MOVEMENT, scpDataMovement);
- scpDataMovementResourceIDs.add(scpDataMovementResource.getDataMovementInterfaceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Scp Data Movement Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Scp Data Movement Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return scpDataMovementResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ScpDataMovement existingScpDataMovement = em.find(ScpDataMovement.class, dataMovementInterfaceId);
- em.close();
- ScpDataMovement scpDataMovement;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingScpDataMovement == null) {
- scpDataMovement = new ScpDataMovement();
- scpDataMovement.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- scpDataMovement = existingScpDataMovement;
- scpDataMovement.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- scpDataMovement.setQueueDescription(getQueueDescription());
- scpDataMovement.setDataMovementInterfaceId(getDataMovementInterfaceId());
- scpDataMovement.setSecurityProtocol(getSecurityProtocol());
- scpDataMovement.setAlternativeScpHostname(getAlternativeScpHostname());
- scpDataMovement.setSshPort(getSshPort());
- if (existingScpDataMovement == null) {
- em.persist(scpDataMovement);
- } else {
- em.merge(scpDataMovement);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ScpDataMovement scpDataMovement = em.find(ScpDataMovement.class, identifier);
- em.close();
- return scpDataMovement != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getQueueDescription() {
- return queueDescription;
- }
-
- public String getDataMovementInterfaceId() {
- return dataMovementInterfaceId;
- }
-
- public String getSecurityProtocol() {
- return securityProtocol;
- }
-
- public String getAlternativeScpHostname() {
- return alternativeScpHostname;
- }
-
- public int getSshPort() {
- return sshPort;
- }
-
- public void setQueueDescription(String queueDescription) {
- this.queueDescription=queueDescription;
- }
-
- public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
- this.dataMovementInterfaceId=dataMovementInterfaceId;
- }
-
- public void setSecurityProtocol(String securityProtocol) {
- this.securityProtocol=securityProtocol;
- }
-
- public void setAlternativeScpHostname(String alternativeScpHostname) {
- this.alternativeScpHostname=alternativeScpHostname;
- }
-
- public void setSshPort(int sshPort) {
- this.sshPort=sshPort;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementResource.java
new file mode 100644
index 0000000..3b4c63d
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ScpDataMovementResource.java
@@ -0,0 +1,308 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ScpDataMovement;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+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 ScpDataMovementResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ScpDataMovementResource.class);
+ private String queueDescription;
+ private String dataMovementInterfaceId;
+ private String securityProtocol;
+ private String alternativeScpHostname;
+ private int sshPort;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
+ generator.setParameter(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
+ generator.setParameter(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ ScpDataMovement scpDataMovement = (ScpDataMovement) q.getSingleResult();
+ ScpDataMovementResource scpDataMovementResource = (ScpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SCP_DATA_MOVEMENT, scpDataMovement);
+ em.getTransaction().commit();
+ em.close();
+ return scpDataMovementResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> scpDataMovementResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
+ Query q;
+ if ((fieldName.equals(ScpDataMovementConstants.QUEUE_DESCRIPTION)) || (fieldName.equals(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(ScpDataMovementConstants.SECURITY_PROTOCOL)) || (fieldName.equals(ScpDataMovementConstants.ALTERNATIVE_SCP_HOSTNAME)) || (fieldName.equals(ScpDataMovementConstants.SSH_PORT))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ScpDataMovement scpDataMovement = (ScpDataMovement) result;
+ ScpDataMovementResource scpDataMovementResource = (ScpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SCP_DATA_MOVEMENT, scpDataMovement);
+ scpDataMovementResources.add(scpDataMovementResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Scp Data Movement Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Scp Data Movement Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return scpDataMovementResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> scpDataMovementResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SCP_DATA_MOVEMENT);
+ Query q;
+ if ((fieldName.equals(ScpDataMovementConstants.QUEUE_DESCRIPTION)) || (fieldName.equals(ScpDataMovementConstants.DATA_MOVEMENT_INTERFACE_ID)) || (fieldName.equals(ScpDataMovementConstants.SECURITY_PROTOCOL)) || (fieldName.equals(ScpDataMovementConstants.ALTERNATIVE_SCP_HOSTNAME)) || (fieldName.equals(ScpDataMovementConstants.SSH_PORT))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ScpDataMovement scpDataMovement = (ScpDataMovement) result;
+ ScpDataMovementResource scpDataMovementResource = (ScpDataMovementResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SCP_DATA_MOVEMENT, scpDataMovement);
+ scpDataMovementResourceIDs.add(scpDataMovementResource.getDataMovementInterfaceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Scp Data Movement Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Scp Data Movement Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return scpDataMovementResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ScpDataMovement existingScpDataMovement = em.find(ScpDataMovement.class, dataMovementInterfaceId);
+ em.close();
+ ScpDataMovement scpDataMovement;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingScpDataMovement == null) {
+ scpDataMovement = new ScpDataMovement();
+ scpDataMovement.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ scpDataMovement = existingScpDataMovement;
+ scpDataMovement.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ scpDataMovement.setQueueDescription(getQueueDescription());
+ scpDataMovement.setDataMovementInterfaceId(getDataMovementInterfaceId());
+ scpDataMovement.setSecurityProtocol(getSecurityProtocol());
+ scpDataMovement.setAlternativeScpHostname(getAlternativeScpHostname());
+ scpDataMovement.setSshPort(getSshPort());
+ if (existingScpDataMovement == null) {
+ em.persist(scpDataMovement);
+ } else {
+ em.merge(scpDataMovement);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ScpDataMovement scpDataMovement = em.find(ScpDataMovement.class, identifier);
+ em.close();
+ return scpDataMovement != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getQueueDescription() {
+ return queueDescription;
+ }
+
+ public String getDataMovementInterfaceId() {
+ return dataMovementInterfaceId;
+ }
+
+ public String getSecurityProtocol() {
+ return securityProtocol;
+ }
+
+ public String getAlternativeScpHostname() {
+ return alternativeScpHostname;
+ }
+
+ public int getSshPort() {
+ return sshPort;
+ }
+
+ public void setQueueDescription(String queueDescription) {
+ this.queueDescription=queueDescription;
+ }
+
+ public void setDataMovementInterfaceId(String dataMovementInterfaceId) {
+ this.dataMovementInterfaceId=dataMovementInterfaceId;
+ }
+
+ public void setSecurityProtocol(String securityProtocol) {
+ this.securityProtocol=securityProtocol;
+ }
+
+ public void setAlternativeScpHostname(String alternativeScpHostname) {
+ this.alternativeScpHostname=alternativeScpHostname;
+ }
+
+ public void setSshPort(int sshPort) {
+ this.sshPort=sshPort;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionAppCatalogResourceAppCat.java
deleted file mode 100644
index 2bbd6f3..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,332 +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.registry.core.app.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager;
-import org.apache.airavata.registry.core.app.catalog.model.SshJobSubmission;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SshJobSubmissionAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(SshJobSubmissionAppCatalogResourceAppCat.class);
- private String resourceJobManagerId;
- private ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource;
- private String jobSubmissionInterfaceId;
- private String alternativeSshHostname;
- private String securityProtocol;
- private int sshPort;
- private String monitorMode;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_JOB_SUBMISSION);
- generator.setParameter(SshJobSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_JOB_SUBMISSION);
- generator.setParameter(SshJobSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
- Query q = generator.selectQuery(em);
- SshJobSubmission sshJobSubmission = (SshJobSubmission) q.getSingleResult();
- SshJobSubmissionAppCatalogResourceAppCat sshJobSubmissionResource = (SshJobSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_JOB_SUBMISSION, sshJobSubmission);
- em.getTransaction().commit();
- em.close();
- return sshJobSubmissionResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> sshJobSubmissionResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_JOB_SUBMISSION);
- Query q;
- if ((fieldName.equals(SshJobSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(SshJobSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(SshJobSubmissionConstants.ALTERNATIVE_SSH_HOSTNAME)) || (fieldName.equals(SshJobSubmissionConstants.SECURITY_PROTOCOL)) || (fieldName.equals(SshJobSubmissionConstants.SSH_PORT))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- SshJobSubmission sshJobSubmission = (SshJobSubmission) result;
- SshJobSubmissionAppCatalogResourceAppCat sshJobSubmissionResource = (SshJobSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_JOB_SUBMISSION, sshJobSubmission);
- sshJobSubmissionResources.add(sshJobSubmissionResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Ssh Job Submission Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Ssh Job Submission Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return sshJobSubmissionResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> sshJobSubmissionResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_JOB_SUBMISSION);
- Query q;
- if ((fieldName.equals(SshJobSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(SshJobSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(SshJobSubmissionConstants.ALTERNATIVE_SSH_HOSTNAME)) || (fieldName.equals(SshJobSubmissionConstants.SECURITY_PROTOCOL)) || (fieldName.equals(SshJobSubmissionConstants.SSH_PORT))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- SshJobSubmission sshJobSubmission = (SshJobSubmission) result;
- SshJobSubmissionAppCatalogResourceAppCat sshJobSubmissionResource = (SshJobSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_JOB_SUBMISSION, sshJobSubmission);
- sshJobSubmissionResourceIDs.add(sshJobSubmissionResource.getJobSubmissionInterfaceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Ssh Job Submission Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Ssh Job Submission Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return sshJobSubmissionResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- SshJobSubmission existingSshJobSubmission = em.find(SshJobSubmission.class, jobSubmissionInterfaceId);
- em.close();
- SshJobSubmission sshJobSubmission;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingSshJobSubmission == null) {
- sshJobSubmission = new SshJobSubmission();
- sshJobSubmission.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- sshJobSubmission = existingSshJobSubmission;
- sshJobSubmission.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- sshJobSubmission.setResourceJobManagerId(getResourceJobManagerId());
- ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
- sshJobSubmission.setResourceJobManager(resourceJobManager);
- sshJobSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
- sshJobSubmission.setAlternativeSshHostname(getAlternativeSshHostname());
- sshJobSubmission.setSecurityProtocol(getSecurityProtocol());
- sshJobSubmission.setSshPort(getSshPort());
- sshJobSubmission.setMonitorMode(getMonitorMode());
- if (existingSshJobSubmission == null) {
- em.persist(sshJobSubmission);
- } else {
- em.merge(sshJobSubmission);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- SshJobSubmission sshJobSubmission = em.find(SshJobSubmission.class, identifier);
- em.close();
- return sshJobSubmission != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getResourceJobManagerId() {
- return resourceJobManagerId;
- }
-
- public ResourceJobManagerAppCatalogResourceAppCat getResourceJobManagerResource() {
- return resourceJobManagerResource;
- }
-
- public String getJobSubmissionInterfaceId() {
- return jobSubmissionInterfaceId;
- }
-
- public String getAlternativeSshHostname() {
- return alternativeSshHostname;
- }
-
- public String getSecurityProtocol() {
- return securityProtocol;
- }
-
- public int getSshPort() {
- return sshPort;
- }
-
- public void setResourceJobManagerId(String resourceJobManagerId) {
- this.resourceJobManagerId=resourceJobManagerId;
- }
-
- public void setResourceJobManagerResource(ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource) {
- this.resourceJobManagerResource=resourceJobManagerResource;
- }
-
- public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
- this.jobSubmissionInterfaceId=jobSubmissionInterfaceId;
- }
-
- public void setAlternativeSshHostname(String alternativeSshHostname) {
- this.alternativeSshHostname=alternativeSshHostname;
- }
-
- public void setSecurityProtocol(String securityProtocol) {
- this.securityProtocol=securityProtocol;
- }
-
- public void setSshPort(int sshPort) {
- this.sshPort=sshPort;
- }
-
- public String getMonitorMode() {
- return monitorMode;
- }
-
- public void setMonitorMode(String monitorMode) {
- this.monitorMode = monitorMode;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionResource.java
new file mode 100644
index 0000000..2390f68
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/SshJobSubmissionResource.java
@@ -0,0 +1,332 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager;
+import org.apache.airavata.registry.core.app.catalog.model.SshJobSubmission;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SshJobSubmissionResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(SshJobSubmissionResource.class);
+ private String resourceJobManagerId;
+ private ResourceJobManagerResource resourceJobManagerResource;
+ private String jobSubmissionInterfaceId;
+ private String alternativeSshHostname;
+ private String securityProtocol;
+ private int sshPort;
+ private String monitorMode;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_JOB_SUBMISSION);
+ generator.setParameter(SshJobSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_JOB_SUBMISSION);
+ generator.setParameter(SshJobSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ SshJobSubmission sshJobSubmission = (SshJobSubmission) q.getSingleResult();
+ SshJobSubmissionResource sshJobSubmissionResource = (SshJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_JOB_SUBMISSION, sshJobSubmission);
+ em.getTransaction().commit();
+ em.close();
+ return sshJobSubmissionResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> sshJobSubmissionResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_JOB_SUBMISSION);
+ Query q;
+ if ((fieldName.equals(SshJobSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(SshJobSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(SshJobSubmissionConstants.ALTERNATIVE_SSH_HOSTNAME)) || (fieldName.equals(SshJobSubmissionConstants.SECURITY_PROTOCOL)) || (fieldName.equals(SshJobSubmissionConstants.SSH_PORT))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ SshJobSubmission sshJobSubmission = (SshJobSubmission) result;
+ SshJobSubmissionResource sshJobSubmissionResource = (SshJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_JOB_SUBMISSION, sshJobSubmission);
+ sshJobSubmissionResources.add(sshJobSubmissionResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Ssh Job Submission Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Ssh Job Submission Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return sshJobSubmissionResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> sshJobSubmissionResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(SSH_JOB_SUBMISSION);
+ Query q;
+ if ((fieldName.equals(SshJobSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(SshJobSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(SshJobSubmissionConstants.ALTERNATIVE_SSH_HOSTNAME)) || (fieldName.equals(SshJobSubmissionConstants.SECURITY_PROTOCOL)) || (fieldName.equals(SshJobSubmissionConstants.SSH_PORT))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ SshJobSubmission sshJobSubmission = (SshJobSubmission) result;
+ SshJobSubmissionResource sshJobSubmissionResource = (SshJobSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.SSH_JOB_SUBMISSION, sshJobSubmission);
+ sshJobSubmissionResourceIDs.add(sshJobSubmissionResource.getJobSubmissionInterfaceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Ssh Job Submission Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Ssh Job Submission Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return sshJobSubmissionResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ SshJobSubmission existingSshJobSubmission = em.find(SshJobSubmission.class, jobSubmissionInterfaceId);
+ em.close();
+ SshJobSubmission sshJobSubmission;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingSshJobSubmission == null) {
+ sshJobSubmission = new SshJobSubmission();
+ sshJobSubmission.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ sshJobSubmission = existingSshJobSubmission;
+ sshJobSubmission.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ sshJobSubmission.setResourceJobManagerId(getResourceJobManagerId());
+ ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
+ sshJobSubmission.setResourceJobManager(resourceJobManager);
+ sshJobSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
+ sshJobSubmission.setAlternativeSshHostname(getAlternativeSshHostname());
+ sshJobSubmission.setSecurityProtocol(getSecurityProtocol());
+ sshJobSubmission.setSshPort(getSshPort());
+ sshJobSubmission.setMonitorMode(getMonitorMode());
+ if (existingSshJobSubmission == null) {
+ em.persist(sshJobSubmission);
+ } else {
+ em.merge(sshJobSubmission);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ SshJobSubmission sshJobSubmission = em.find(SshJobSubmission.class, identifier);
+ em.close();
+ return sshJobSubmission != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getResourceJobManagerId() {
+ return resourceJobManagerId;
+ }
+
+ public ResourceJobManagerResource getResourceJobManagerResource() {
+ return resourceJobManagerResource;
+ }
+
+ public String getJobSubmissionInterfaceId() {
+ return jobSubmissionInterfaceId;
+ }
+
+ public String getAlternativeSshHostname() {
+ return alternativeSshHostname;
+ }
+
+ public String getSecurityProtocol() {
+ return securityProtocol;
+ }
+
+ public int getSshPort() {
+ return sshPort;
+ }
+
+ public void setResourceJobManagerId(String resourceJobManagerId) {
+ this.resourceJobManagerId=resourceJobManagerId;
+ }
+
+ public void setResourceJobManagerResource(ResourceJobManagerResource resourceJobManagerResource) {
+ this.resourceJobManagerResource=resourceJobManagerResource;
+ }
+
+ public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
+ this.jobSubmissionInterfaceId=jobSubmissionInterfaceId;
+ }
+
+ public void setAlternativeSshHostname(String alternativeSshHostname) {
+ this.alternativeSshHostname=alternativeSshHostname;
+ }
+
+ public void setSecurityProtocol(String securityProtocol) {
+ this.securityProtocol=securityProtocol;
+ }
+
+ public void setSshPort(int sshPort) {
+ this.sshPort=sshPort;
+ }
+
+ public String getMonitorMode() {
+ return monitorMode;
+ }
+
+ public void setMonitorMode(String monitorMode) {
+ this.monitorMode = monitorMode;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementAppCatalogResourceAppCat.java
deleted file mode 100644
index af8899a..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,255 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.UnicoreDataMovement;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.List;
-
-public class UnicoreDataMovementAppCatalogResourceAppCat extends AppCatAbstractResource {
-
- private final static Logger logger = LoggerFactory.getLogger(UnicoreDataMovementAppCatalogResourceAppCat.class);
-
- private String dataMovementId;
- private String securityProtocol;
- private String unicoreEndpointUrl;
-
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_DATA_MOVEMENT);
- generator.setParameter(UnicoreDataMovementConstants.DATAMOVEMENT_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_DATA_MOVEMENT);
- generator.setParameter(UnicoreDataMovementConstants.DATAMOVEMENT_ID, identifier);
- Query q = generator.selectQuery(em);
- UnicoreDataMovement unicoreDataMovement = (UnicoreDataMovement) q.getSingleResult();
- UnicoreDataMovementAppCatalogResourceAppCat dataMovementResource =
- (UnicoreDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils
- .getResource(AppCatalogResourceType.UNICORE_DATA_MOVEMENT,
- unicoreDataMovement);
- em.getTransaction().commit();
- em.close();
- return dataMovementResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> unicoreDMResourceList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_DATA_MOVEMENT);
- List results;
- if (fieldName.equals(UnicoreDataMovementConstants.UNICORE_ENDPOINT_URL)) {
- generator.setParameter(UnicoreDataMovementConstants.UNICORE_ENDPOINT_URL, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- UnicoreDataMovement dataMovement = (UnicoreDataMovement) result;
- UnicoreDataMovementAppCatalogResourceAppCat unicoreJobSubmissionResource =
- (UnicoreDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.UNICORE_DATA_MOVEMENT, dataMovement);
- unicoreDMResourceList.add(unicoreJobSubmissionResource);
- }
- }
- } else if (fieldName.equals(UnicoreDataMovementConstants.SECURITY_PROTOCAL)) {
- generator.setParameter(UnicoreDataMovementConstants.SECURITY_PROTOCAL, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- UnicoreDataMovement dataMovement = (UnicoreDataMovement) result;
- UnicoreDataMovementAppCatalogResourceAppCat dataMovementResource =
- (UnicoreDataMovementAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.UNICORE_DATA_MOVEMENT, dataMovement);
- unicoreDMResourceList.add(dataMovementResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Unicore data movement resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Unicore data movement resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return unicoreDMResourceList;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- return null;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- UnicoreDataMovement existingDataMovement = em.find(UnicoreDataMovement.class, dataMovementId);
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingDataMovement != null) {
- existingDataMovement.setDataMovementId(dataMovementId);;
- existingDataMovement.setUnicoreEndpointUrl(unicoreEndpointUrl);
- existingDataMovement.setSecurityProtocol(securityProtocol);
- em.merge(existingDataMovement);
- } else {
- UnicoreDataMovement unicoreJobSubmission = new UnicoreDataMovement();
- unicoreJobSubmission.setDataMovementId(dataMovementId);
- unicoreJobSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
- unicoreJobSubmission.setSecurityProtocol(securityProtocol);
- em.persist(unicoreJobSubmission);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- UnicoreDataMovement dataMovement = em.find(UnicoreDataMovement.class, identifier);
- em.close();
- return dataMovement != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public String getDataMovementId() {
- return dataMovementId;
- }
-
- public void setDataMovementId(String dataMovementId) {
- this.dataMovementId = dataMovementId;
- }
-
- public String getSecurityProtocol() {
- return securityProtocol;
- }
-
- public void setSecurityProtocol(String securityProtocol) {
- this.securityProtocol = securityProtocol;
- }
-
- public String getUnicoreEndpointUrl() {
- return unicoreEndpointUrl;
- }
-
- public void setUnicoreEndpointUrl(String unicoreEndpointUrl) {
- this.unicoreEndpointUrl = unicoreEndpointUrl;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementResource.java
new file mode 100644
index 0000000..db5ccde
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreDataMovementResource.java
@@ -0,0 +1,255 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.UnicoreDataMovement;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+
+public class UnicoreDataMovementResource extends AppCatAbstractResource {
+
+ private final static Logger logger = LoggerFactory.getLogger(UnicoreDataMovementResource.class);
+
+ private String dataMovementId;
+ private String securityProtocol;
+ private String unicoreEndpointUrl;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_DATA_MOVEMENT);
+ generator.setParameter(UnicoreDataMovementConstants.DATAMOVEMENT_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_DATA_MOVEMENT);
+ generator.setParameter(UnicoreDataMovementConstants.DATAMOVEMENT_ID, identifier);
+ Query q = generator.selectQuery(em);
+ UnicoreDataMovement unicoreDataMovement = (UnicoreDataMovement) q.getSingleResult();
+ UnicoreDataMovementResource dataMovementResource =
+ (UnicoreDataMovementResource) AppCatalogJPAUtils
+ .getResource(AppCatalogResourceType.UNICORE_DATA_MOVEMENT,
+ unicoreDataMovement);
+ em.getTransaction().commit();
+ em.close();
+ return dataMovementResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> unicoreDMResourceList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_DATA_MOVEMENT);
+ List results;
+ if (fieldName.equals(UnicoreDataMovementConstants.UNICORE_ENDPOINT_URL)) {
+ generator.setParameter(UnicoreDataMovementConstants.UNICORE_ENDPOINT_URL, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ UnicoreDataMovement dataMovement = (UnicoreDataMovement) result;
+ UnicoreDataMovementResource unicoreJobSubmissionResource =
+ (UnicoreDataMovementResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.UNICORE_DATA_MOVEMENT, dataMovement);
+ unicoreDMResourceList.add(unicoreJobSubmissionResource);
+ }
+ }
+ } else if (fieldName.equals(UnicoreDataMovementConstants.SECURITY_PROTOCAL)) {
+ generator.setParameter(UnicoreDataMovementConstants.SECURITY_PROTOCAL, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ UnicoreDataMovement dataMovement = (UnicoreDataMovement) result;
+ UnicoreDataMovementResource dataMovementResource =
+ (UnicoreDataMovementResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.UNICORE_DATA_MOVEMENT, dataMovement);
+ unicoreDMResourceList.add(dataMovementResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Unicore data movement resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Unicore data movement resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return unicoreDMResourceList;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ return null;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ UnicoreDataMovement existingDataMovement = em.find(UnicoreDataMovement.class, dataMovementId);
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingDataMovement != null) {
+ existingDataMovement.setDataMovementId(dataMovementId);;
+ existingDataMovement.setUnicoreEndpointUrl(unicoreEndpointUrl);
+ existingDataMovement.setSecurityProtocol(securityProtocol);
+ em.merge(existingDataMovement);
+ } else {
+ UnicoreDataMovement unicoreJobSubmission = new UnicoreDataMovement();
+ unicoreJobSubmission.setDataMovementId(dataMovementId);
+ unicoreJobSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
+ unicoreJobSubmission.setSecurityProtocol(securityProtocol);
+ em.persist(unicoreJobSubmission);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ UnicoreDataMovement dataMovement = em.find(UnicoreDataMovement.class, identifier);
+ em.close();
+ return dataMovement != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+
+ public String getDataMovementId() {
+ return dataMovementId;
+ }
+
+ public void setDataMovementId(String dataMovementId) {
+ this.dataMovementId = dataMovementId;
+ }
+
+ public String getSecurityProtocol() {
+ return securityProtocol;
+ }
+
+ public void setSecurityProtocol(String securityProtocol) {
+ this.securityProtocol = securityProtocol;
+ }
+
+ public String getUnicoreEndpointUrl() {
+ return unicoreEndpointUrl;
+ }
+
+ public void setUnicoreEndpointUrl(String unicoreEndpointUrl) {
+ this.unicoreEndpointUrl = unicoreEndpointUrl;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionAppCatalogResourceAppCat.java
deleted file mode 100644
index ae029f2..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,328 +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.registry.core.app.catalog.resources;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission;
-import org.apache.airavata.registry.core.app.catalog.model.UnicoreJobSubmission;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class UnicoreJobSubmissionAppCatalogResourceAppCat extends AppCatAbstractResource {
-
- private final static Logger logger = LoggerFactory.getLogger(UnicoreJobSubmissionAppCatalogResourceAppCat.class);
-
- private String jobSubmissionInterfaceId;
- private String securityProtocol;
- private String unicoreEndpointUrl;
-
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
- generator.setParameter(UnicoreJobSubmissionConstants.SUBMISSION_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
- generator.setParameter(UnicoreJobSubmissionConstants.SUBMISSION_ID, identifier);
- Query q = generator.selectQuery(em);
- UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) q.getSingleResult();
- UnicoreJobSubmissionAppCatalogResourceAppCat unicoreSubmissionResource =
- (UnicoreJobSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils
- .getResource(AppCatalogResourceType.UNICORE_JOB_SUBMISSION,
- unicoreJobSubmission);
- em.getTransaction().commit();
- em.close();
- return unicoreSubmissionResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> unicoreSubmissionResourceList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
- List results;
- if (fieldName.equals(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL)) {
- generator.setParameter(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) result;
- UnicoreJobSubmissionAppCatalogResourceAppCat unicoreJobSubmissionResource =
- (UnicoreJobSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
- unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
- }
- }
- } else if (fieldName.equals(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL)) {
- generator.setParameter(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) result;
- UnicoreJobSubmissionAppCatalogResourceAppCat unicoreJobSubmissionResource =
- (UnicoreJobSubmissionAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
- unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
- }
- }
- }
- else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Unicore submission resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Unicore Submission resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return unicoreSubmissionResourceList;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> globusSubmissionResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
- List results;
- if (fieldName.equals(GlobusJobSubmissionConstants.SUBMISSION_ID)) {
- generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP)) {
- generator.setParameter(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
- }
- }
- }
- else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
- generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
- }
- }
- } else if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER)) {
- generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
- globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Globus Submission resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Globus Submission resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return globusSubmissionResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- UnicoreJobSubmission existingUnicoreSubmission = em.find(UnicoreJobSubmission.class, jobSubmissionInterfaceId);
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingUnicoreSubmission != null) {
- existingUnicoreSubmission.setSubmissionID(jobSubmissionInterfaceId);;
- existingUnicoreSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
- existingUnicoreSubmission.setSecurityProtocol(securityProtocol);
-
- em.merge(existingUnicoreSubmission);
- } else {
- UnicoreJobSubmission unicoreJobSubmission = new UnicoreJobSubmission();
- unicoreJobSubmission.setSubmissionID(jobSubmissionInterfaceId);
- unicoreJobSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
- unicoreJobSubmission.setSecurityProtocol(securityProtocol);
- em.persist(unicoreJobSubmission);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- UnicoreJobSubmission unicoreJobSubmission = em.find(UnicoreJobSubmission.class, identifier);
- em.close();
- return unicoreJobSubmission != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public String getjobSubmissionInterfaceId() {
- return jobSubmissionInterfaceId;
- }
-
- public void setjobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
- this.jobSubmissionInterfaceId = jobSubmissionInterfaceId;
- }
-
- public String getSecurityProtocol() {
- return securityProtocol;
- }
-
- public void setSecurityProtocol(String securityProtocol) {
- this.securityProtocol = securityProtocol;
- }
-
- public String getUnicoreEndpointUrl() {
- return unicoreEndpointUrl;
- }
-
- public void setUnicoreEndpointUrl(String unicoreEndpointUrl) {
- this.unicoreEndpointUrl = unicoreEndpointUrl;
- }
-
-}
[02/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
index 474fcf5..044e9af 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
@@ -41,7 +41,7 @@ import java.util.List;
public class ThriftDataModelConversion {
private final static Logger logger = LoggerFactory.getLogger(ThriftDataModelConversion.class);
- public static Project getProject (ProjectExperimentCatResource pr) throws RegistryException {
+ public static Project getProject (ProjectResource pr) throws RegistryException {
if (pr != null) {
Project project = new Project();
project.setProjectID(pr.getId());
@@ -51,10 +51,10 @@ public class ThriftDataModelConversion {
}
project.setDescription(pr.getDescription());
project.setOwner(pr.getWorker().getUser());
- List<ProjectUserExperimentCatResource> projectUserList = pr.getProjectUserList();
+ List<ProjectUserResource> projectUserList = pr.getProjectUserList();
List<String> sharedUsers = new ArrayList<String>();
if (projectUserList != null && !projectUserList.isEmpty()){
- for (ProjectUserExperimentCatResource resource : projectUserList){
+ for (ProjectUserResource resource : projectUserList){
sharedUsers.add(resource.getUserName());
}
}
@@ -64,7 +64,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static Gateway getGateway (GatewayExperimentCatResource resource){
+ public static Gateway getGateway (GatewayResource resource){
Gateway gateway = new Gateway();
gateway.setGatewayId(resource.getGatewayId());
gateway.setGatewayName(resource.getGatewayName());
@@ -76,13 +76,13 @@ public class ThriftDataModelConversion {
public static List<Gateway> getAllGateways (List<ExperimentCatResource> gatewayList){
List<Gateway> gateways = new ArrayList<Gateway>();
for (ExperimentCatResource resource : gatewayList){
- gateways.add(getGateway((GatewayExperimentCatResource)resource));
+ gateways.add(getGateway((GatewayResource)resource));
}
return gateways;
}
- public static Experiment getExperiment(ExperimentExperimentCatResource experimentResource) throws RegistryException {
+ public static Experiment getExperiment(ExperimentResource experimentResource) throws RegistryException {
if (experimentResource != null){
Experiment experiment = new Experiment();
experiment.setProjectID(experimentResource.getProjectId());
@@ -97,34 +97,34 @@ public class ThriftDataModelConversion {
experiment.setEnableEmailNotification(experimentResource.isEnableEmailNotifications());
experiment.setGatewayExecutionId(experimentResource.getGatewayExecutionId());
if (experiment.isEnableEmailNotification()){
- List<NotificationEmailExperimentCatResource> notificationEmails = experimentResource.getNotificationEmails();
+ List<NotificationEmailResource> notificationEmails = experimentResource.getNotificationEmails();
experiment.setEmailAddresses(getEmailAddresses(notificationEmails));
}
experiment.setWorkflowTemplateVersion(experimentResource.getWorkflowTemplateVersion());
experiment.setWorkflowExecutionInstanceId(experimentResource.getWorkflowExecutionId());
- List<ExperimentInputExperimentCatResource> experimentInputs = experimentResource.getExperimentInputs();
+ List<ExperimentInputResource> experimentInputs = experimentResource.getExperimentInputs();
experiment.setExperimentInputs(getExpInputs(experimentInputs));
- List<ExperimentOutputExperimentCatResource> experimentOutputs = experimentResource.getExperimentOutputs();
+ List<ExperimentOutputResource> experimentOutputs = experimentResource.getExperimentOutputs();
experiment.setExperimentOutputs(getExpOutputs(experimentOutputs));
- StatusExperimentCatResource experimentStatus = experimentResource.getExperimentStatus();
+ StatusResource experimentStatus = experimentResource.getExperimentStatus();
if (experimentStatus != null){
experiment.setExperimentStatus(getExperimentStatus(experimentStatus));
}
- List<StatusExperimentCatResource> changeList = experimentResource.getWorkflowNodeStatuses();
+ List<StatusResource> changeList = experimentResource.getWorkflowNodeStatuses();
if (changeList != null && !changeList.isEmpty()){
experiment.setStateChangeList(getWorkflowNodeStatusList(changeList));
}
- List<WorkflowNodeDetailExperimentCatResource> workflowNodeDetails = experimentResource.getWorkflowNodeDetails();
+ List<WorkflowNodeDetailResource> workflowNodeDetails = experimentResource.getWorkflowNodeDetails();
if (workflowNodeDetails != null && !workflowNodeDetails.isEmpty()){
experiment.setWorkflowNodeDetailsList(getWfNodeList(workflowNodeDetails));
}
- List<ErrorDetailExperimentCatResource> errorDetails = experimentResource.getErrorDetails();
+ List<ErrorDetailResource> errorDetails = experimentResource.getErrorDetails();
if (errorDetails!= null && !errorDetails.isEmpty()){
experiment.setErrors(getErrorDetailList(errorDetails));
}
if (experimentResource.isExists(ResourceType.CONFIG_DATA, experimentResource.getExpID())){
- ConfigDataExperimentCatResource userConfigData = experimentResource.getUserConfigData(experimentResource.getExpID());
+ ConfigDataResource userConfigData = experimentResource.getUserConfigData(experimentResource.getExpID());
experiment.setUserConfigurationData(getUserConfigData(userConfigData));
}
return experiment;
@@ -132,7 +132,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static ExperimentSummary getExperimentSummary(ExperimentSummaryExperimentCatResource experimentSummaryResource) throws RegistryException {
+ public static ExperimentSummary getExperimentSummary(ExperimentSummaryResource experimentSummaryResource) throws RegistryException {
if (experimentSummaryResource != null){
ExperimentSummary experimentSummary = new ExperimentSummary();
experimentSummary.setProjectID(experimentSummaryResource.getProjectID());
@@ -142,7 +142,7 @@ public class ThriftDataModelConversion {
experimentSummary.setName(experimentSummaryResource.getExpName());
experimentSummary.setDescription(experimentSummaryResource.getDescription());
experimentSummary.setApplicationId(experimentSummaryResource.getApplicationId());
- StatusExperimentCatResource experimentStatus = experimentSummaryResource.getStatus();
+ StatusResource experimentStatus = experimentSummaryResource.getStatus();
if (experimentStatus != null){
experimentSummary.setExperimentStatus(getExperimentStatus(experimentStatus));
}
@@ -154,8 +154,8 @@ public class ThriftDataModelConversion {
public static InputDataObjectType getInput(Object object){
if (object != null){
InputDataObjectType dataObjectType = new InputDataObjectType();
- if (object instanceof ExperimentInputExperimentCatResource){
- ExperimentInputExperimentCatResource expInput = (ExperimentInputExperimentCatResource) object;
+ if (object instanceof ExperimentInputResource){
+ ExperimentInputResource expInput = (ExperimentInputResource) object;
dataObjectType.setName(expInput.getExperimentKey());
dataObjectType.setValue(expInput.getValue());
if (expInput.getDataType() != null){
@@ -170,8 +170,8 @@ public class ThriftDataModelConversion {
dataObjectType.setRequiredToAddedToCommandLine(expInput.getRequiredToCMD());
dataObjectType.setDataStaged(expInput.isDataStaged());
return dataObjectType;
- }else if (object instanceof NodeInputExperimentCatResource){
- NodeInputExperimentCatResource nodeInputResource = (NodeInputExperimentCatResource)object;
+ }else if (object instanceof NodeInputResource){
+ NodeInputResource nodeInputResource = (NodeInputResource)object;
dataObjectType.setName(nodeInputResource.getInputKey());
dataObjectType.setValue(nodeInputResource.getValue());
if (nodeInputResource.getDataType() != null){
@@ -186,8 +186,8 @@ public class ThriftDataModelConversion {
dataObjectType.setRequiredToAddedToCommandLine(nodeInputResource.getRequiredToCMD());
dataObjectType.setDataStaged(nodeInputResource.isDataStaged());
return dataObjectType;
- }else if (object instanceof ApplicationInputExperimentCatResource){
- ApplicationInputExperimentCatResource inputResource = (ApplicationInputExperimentCatResource)object;
+ }else if (object instanceof ApplicationInputResource){
+ ApplicationInputResource inputResource = (ApplicationInputResource)object;
dataObjectType.setName(inputResource.getInputKey());
dataObjectType.setValue(inputResource.getValue());
if (inputResource.getDataType() != null){
@@ -212,8 +212,8 @@ public class ThriftDataModelConversion {
public static OutputDataObjectType getOutput(Object object){
if (object != null){
OutputDataObjectType dataObjectType = new OutputDataObjectType();
- if (object instanceof ExperimentOutputExperimentCatResource){
- ExperimentOutputExperimentCatResource expOutput = (ExperimentOutputExperimentCatResource)object;
+ if (object instanceof ExperimentOutputResource){
+ ExperimentOutputResource expOutput = (ExperimentOutputResource)object;
dataObjectType.setName(expOutput.getExperimentKey());
dataObjectType.setValue(expOutput.getValue());
if (expOutput.getDataType() != null){
@@ -226,8 +226,8 @@ public class ThriftDataModelConversion {
dataObjectType.setSearchQuery(expOutput.getSearchQuery());
dataObjectType.setApplicationArgument(expOutput.getAppArgument());
return dataObjectType;
- }else if (object instanceof NodeOutputExperimentCatResource){
- NodeOutputExperimentCatResource nodeOutputResource = (NodeOutputExperimentCatResource)object;
+ }else if (object instanceof NodeOutputResource){
+ NodeOutputResource nodeOutputResource = (NodeOutputResource)object;
dataObjectType.setName(nodeOutputResource.getOutputKey());
dataObjectType.setValue(nodeOutputResource.getValue());
if (nodeOutputResource.getDataType() != null){
@@ -240,8 +240,8 @@ public class ThriftDataModelConversion {
dataObjectType.setSearchQuery(nodeOutputResource.getSearchQuery());
dataObjectType.setApplicationArgument(nodeOutputResource.getAppArgument());
return dataObjectType;
- }else if (object instanceof ApplicationOutputExperimentCatResource){
- ApplicationOutputExperimentCatResource outputResource = (ApplicationOutputExperimentCatResource)object;
+ }else if (object instanceof ApplicationOutputResource){
+ ApplicationOutputResource outputResource = (ApplicationOutputResource)object;
dataObjectType.setName(outputResource.getOutputKey());
dataObjectType.setValue(outputResource.getValue());
dataObjectType.setIsRequired(outputResource.isRequired());
@@ -261,20 +261,20 @@ public class ThriftDataModelConversion {
return null;
}
- public static List<String> getEmailAddresses (List<NotificationEmailExperimentCatResource> resourceList){
+ public static List<String> getEmailAddresses (List<NotificationEmailResource> resourceList){
List<String> emailAddresses = new ArrayList<String>();
if (resourceList != null && !resourceList.isEmpty()){
- for (NotificationEmailExperimentCatResource emailResource : resourceList){
+ for (NotificationEmailResource emailResource : resourceList){
emailAddresses.add(emailResource.getEmailAddress());
}
}
return emailAddresses;
}
- public static List<InputDataObjectType> getExpInputs (List<ExperimentInputExperimentCatResource> exInputList){
+ public static List<InputDataObjectType> getExpInputs (List<ExperimentInputResource> exInputList){
List<InputDataObjectType> expInputs = new ArrayList<InputDataObjectType>();
if (exInputList != null && !exInputList.isEmpty()){
- for (ExperimentInputExperimentCatResource inputResource : exInputList){
+ for (ExperimentInputResource inputResource : exInputList){
InputDataObjectType exInput = getInput(inputResource);
expInputs.add(exInput);
}
@@ -282,10 +282,10 @@ public class ThriftDataModelConversion {
return expInputs;
}
- public static List<OutputDataObjectType> getExpOutputs (List<ExperimentOutputExperimentCatResource> experimentOutputResourceList){
+ public static List<OutputDataObjectType> getExpOutputs (List<ExperimentOutputResource> experimentOutputResourceList){
List<OutputDataObjectType> exOutputs = new ArrayList<OutputDataObjectType>();
if (experimentOutputResourceList != null && !experimentOutputResourceList.isEmpty()){
- for (ExperimentOutputExperimentCatResource outputResource : experimentOutputResourceList){
+ for (ExperimentOutputResource outputResource : experimentOutputResourceList){
OutputDataObjectType output = getOutput(outputResource);
exOutputs.add(output);
}
@@ -293,10 +293,10 @@ public class ThriftDataModelConversion {
return exOutputs;
}
- public static List<InputDataObjectType> getNodeInputs (List<NodeInputExperimentCatResource> nodeInputResources){
+ public static List<InputDataObjectType> getNodeInputs (List<NodeInputResource> nodeInputResources){
List<InputDataObjectType> nodeInputs = new ArrayList<InputDataObjectType>();
if (nodeInputResources != null && !nodeInputResources.isEmpty()){
- for (NodeInputExperimentCatResource inputResource : nodeInputResources){
+ for (NodeInputResource inputResource : nodeInputResources){
InputDataObjectType nodeInput = getInput(inputResource);
nodeInputs.add(nodeInput);
}
@@ -304,10 +304,10 @@ public class ThriftDataModelConversion {
return nodeInputs;
}
- public static List<OutputDataObjectType> getNodeOutputs (List<NodeOutputExperimentCatResource> nodeOutputResourceList){
+ public static List<OutputDataObjectType> getNodeOutputs (List<NodeOutputResource> nodeOutputResourceList){
List<OutputDataObjectType> nodeOutputs = new ArrayList<OutputDataObjectType>();
if (nodeOutputResourceList != null && !nodeOutputResourceList.isEmpty()){
- for (NodeOutputExperimentCatResource outputResource : nodeOutputResourceList){
+ for (NodeOutputResource outputResource : nodeOutputResourceList){
OutputDataObjectType output = getOutput(outputResource);
nodeOutputs.add(output);
}
@@ -315,10 +315,10 @@ public class ThriftDataModelConversion {
return nodeOutputs;
}
- public static List<InputDataObjectType> getApplicationInputs (List<ApplicationInputExperimentCatResource> applicationInputResources){
+ public static List<InputDataObjectType> getApplicationInputs (List<ApplicationInputResource> applicationInputResources){
List<InputDataObjectType> appInputs = new ArrayList<InputDataObjectType>();
if (applicationInputResources != null && !applicationInputResources.isEmpty()){
- for (ApplicationInputExperimentCatResource inputResource : applicationInputResources){
+ for (ApplicationInputResource inputResource : applicationInputResources){
InputDataObjectType appInput = getInput(inputResource);
appInputs.add(appInput);
}
@@ -326,10 +326,10 @@ public class ThriftDataModelConversion {
return appInputs;
}
- public static List<OutputDataObjectType> getApplicationOutputs (List<ApplicationOutputExperimentCatResource> outputResources){
+ public static List<OutputDataObjectType> getApplicationOutputs (List<ApplicationOutputResource> outputResources){
List<OutputDataObjectType> appOutputs = new ArrayList<OutputDataObjectType>();
if (outputResources != null && !outputResources.isEmpty()){
- for (ApplicationOutputExperimentCatResource outputResource : outputResources){
+ for (ApplicationOutputResource outputResource : outputResources){
OutputDataObjectType output = getOutput(outputResource);
appOutputs.add(output);
}
@@ -337,7 +337,7 @@ public class ThriftDataModelConversion {
return appOutputs;
}
- public static ExperimentStatus getExperimentStatus(StatusExperimentCatResource status){
+ public static ExperimentStatus getExperimentStatus(StatusResource status){
if (status != null){
ExperimentStatus experimentStatus = new ExperimentStatus();
if (status.getState() == null || status.getState().equals("")){
@@ -350,7 +350,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static WorkflowNodeStatus getWorkflowNodeStatus (StatusExperimentCatResource status){
+ public static WorkflowNodeStatus getWorkflowNodeStatus (StatusResource status){
if (status != null){
WorkflowNodeStatus workflowNodeStatus = new WorkflowNodeStatus();
if (status.getState() == null || status.getState().equals("")){
@@ -363,7 +363,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static TaskStatus getTaskStatus (StatusExperimentCatResource status){
+ public static TaskStatus getTaskStatus (StatusResource status){
if (status != null){
TaskStatus taskStatus = new TaskStatus();
if (status.getState() == null || status.getState().equals("")){
@@ -376,7 +376,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static JobStatus getJobStatus (StatusExperimentCatResource status){
+ public static JobStatus getJobStatus (StatusResource status){
if (status != null){
JobStatus jobStatus = new JobStatus();
if (status.getState() == null || status.getState().equals("")){
@@ -393,7 +393,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static TransferStatus getTransferStatus (StatusExperimentCatResource status){
+ public static TransferStatus getTransferStatus (StatusResource status){
if (status != null){
TransferStatus transferStatus = new TransferStatus();
if (status.getState() == null || status.getState().equals("")){
@@ -406,7 +406,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static ApplicationStatus getApplicationStatus (StatusExperimentCatResource status){
+ public static ApplicationStatus getApplicationStatus (StatusResource status){
if (status != null){
ApplicationStatus applicationStatus = new ApplicationStatus();
if (status.getState() == null || status.getState().equals("")){
@@ -419,30 +419,30 @@ public class ThriftDataModelConversion {
return null;
}
- public static List<WorkflowNodeStatus> getWorkflowNodeStatusList(List<StatusExperimentCatResource> statuses){
+ public static List<WorkflowNodeStatus> getWorkflowNodeStatusList(List<StatusResource> statuses){
List<WorkflowNodeStatus> wfNodeStatuses = new ArrayList<WorkflowNodeStatus>();
if (statuses != null && !statuses.isEmpty()){
- for (StatusExperimentCatResource statusResource : statuses){
+ for (StatusResource statusResource : statuses){
wfNodeStatuses.add(getWorkflowNodeStatus(statusResource));
}
}
return wfNodeStatuses;
}
- public static WorkflowNodeDetails getWorkflowNodeDetails(WorkflowNodeDetailExperimentCatResource nodeDetailResource) throws RegistryException {
+ public static WorkflowNodeDetails getWorkflowNodeDetails(WorkflowNodeDetailResource nodeDetailResource) throws RegistryException {
if (nodeDetailResource != null){
WorkflowNodeDetails wfNode = new WorkflowNodeDetails();
wfNode.setNodeInstanceId(nodeDetailResource.getNodeInstanceId());
wfNode.setCreationTime(nodeDetailResource.getCreationTime().getTime());
wfNode.setNodeName(nodeDetailResource.getNodeName());
- List<NodeInputExperimentCatResource> nodeInputs = nodeDetailResource.getNodeInputs();
+ List<NodeInputResource> nodeInputs = nodeDetailResource.getNodeInputs();
wfNode.setNodeInputs(getNodeInputs(nodeInputs));
- List<NodeOutputExperimentCatResource> nodeOutputs = nodeDetailResource.getNodeOutputs();
+ List<NodeOutputResource> nodeOutputs = nodeDetailResource.getNodeOutputs();
wfNode.setNodeOutputs(getNodeOutputs(nodeOutputs));
- List<TaskDetailExperimentCatResource> taskDetails = nodeDetailResource.getTaskDetails();
+ List<TaskDetailResource> taskDetails = nodeDetailResource.getTaskDetails();
wfNode.setTaskDetailsList(getTaskDetailsList(taskDetails));
wfNode.setWorkflowNodeStatus(getWorkflowNodeStatus(nodeDetailResource.getWorkflowNodeStatus()));
- List<ErrorDetailExperimentCatResource> errorDetails = nodeDetailResource.getErrorDetails();
+ List<ErrorDetailResource> errorDetails = nodeDetailResource.getErrorDetails();
wfNode.setErrors(getErrorDetailList(errorDetails));
wfNode.setExecutionUnit(ExecutionUnit.valueOf(nodeDetailResource.getExecutionUnit()));
wfNode.setExecutionUnitData(nodeDetailResource.getExecutionUnitData());
@@ -451,50 +451,50 @@ public class ThriftDataModelConversion {
return null;
}
- public static List<WorkflowNodeDetails> getWfNodeList (List<WorkflowNodeDetailExperimentCatResource> resources) throws RegistryException {
+ public static List<WorkflowNodeDetails> getWfNodeList (List<WorkflowNodeDetailResource> resources) throws RegistryException {
List<WorkflowNodeDetails> workflowNodeDetailsList = new ArrayList<WorkflowNodeDetails>();
if (resources != null && !resources.isEmpty()){
- for (WorkflowNodeDetailExperimentCatResource resource : resources){
+ for (WorkflowNodeDetailResource resource : resources){
workflowNodeDetailsList.add(getWorkflowNodeDetails(resource));
}
}
return workflowNodeDetailsList;
}
- public static TaskDetails getTaskDetail (TaskDetailExperimentCatResource taskDetailResource) throws RegistryException {
+ public static TaskDetails getTaskDetail (TaskDetailResource taskDetailResource) throws RegistryException {
if (taskDetailResource != null){
TaskDetails taskDetails = new TaskDetails();
String taskId = taskDetailResource.getTaskId();
taskDetails.setTaskID(taskId);
taskDetails.setApplicationId(taskDetailResource.getApplicationId());
taskDetails.setApplicationVersion(taskDetailResource.getApplicationVersion());
- List<ApplicationInputExperimentCatResource> applicationInputs = taskDetailResource.getApplicationInputs();
+ List<ApplicationInputResource> applicationInputs = taskDetailResource.getApplicationInputs();
taskDetails.setApplicationInputs(getApplicationInputs(applicationInputs));
- List<ApplicationOutputExperimentCatResource> applicationOutputs = taskDetailResource.getApplicationOutputs();
+ List<ApplicationOutputResource> applicationOutputs = taskDetailResource.getApplicationOutputs();
taskDetails.setApplicationOutputs(getApplicationOutputs(applicationOutputs));
taskDetails.setEnableEmailNotification(taskDetailResource.isEnableEmailNotifications());
if (taskDetails.isEnableEmailNotification()){
- List<NotificationEmailExperimentCatResource> notificationEmails = taskDetailResource.getNotificationEmails();
+ List<NotificationEmailResource> notificationEmails = taskDetailResource.getNotificationEmails();
taskDetails.setEmailAddresses(getEmailAddresses(notificationEmails));
}
taskDetails.setApplicationDeploymentId(taskDetailResource.getApplicationDeploymentId());
if (taskDetailResource.isExists(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, taskId)){
- ComputationSchedulingExperimentCatResource computationScheduling = taskDetailResource.getComputationScheduling(taskId);
+ ComputationSchedulingResource computationScheduling = taskDetailResource.getComputationScheduling(taskId);
taskDetails.setTaskScheduling(getComputationalResourceScheduling(computationScheduling));
}
if (taskDetailResource.isExists(ResourceType.ADVANCE_INPUT_DATA_HANDLING, taskId)){
- AdvanceInputDataHandlingExperimentCatResource inputDataHandling = taskDetailResource.getInputDataHandling(taskId);
+ AdvanceInputDataHandlingResource inputDataHandling = taskDetailResource.getInputDataHandling(taskId);
taskDetails.setAdvancedInputDataHandling(getAdvanceInputDataHandling(inputDataHandling));
}
if (taskDetailResource.isExists(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, taskId)){
- AdvancedOutputDataHandlingExperimentCatResource outputDataHandling = taskDetailResource.getOutputDataHandling(taskId);
+ AdvancedOutputDataHandlingResource outputDataHandling = taskDetailResource.getOutputDataHandling(taskId);
taskDetails.setAdvancedOutputDataHandling(getAdvanceOutputDataHandling(outputDataHandling));
}
taskDetails.setTaskStatus(getTaskStatus(taskDetailResource.getTaskStatus()));
- List<JobDetailExperimentCatResource> jobDetailList = taskDetailResource.getJobDetailList();
+ List<JobDetailResource> jobDetailList = taskDetailResource.getJobDetailList();
taskDetails.setJobDetailsList(getJobDetailsList(jobDetailList));
taskDetails.setErrors(getErrorDetailList(taskDetailResource.getErrorDetailList()));
taskDetails.setDataTransferDetailsList(getDataTransferlList(taskDetailResource.getDataTransferDetailList()));
@@ -503,20 +503,20 @@ public class ThriftDataModelConversion {
return null;
}
- public static List<TaskDetails> getTaskDetailsList (List<TaskDetailExperimentCatResource> resources) throws RegistryException {
+ public static List<TaskDetails> getTaskDetailsList (List<TaskDetailResource> resources) throws RegistryException {
List<TaskDetails> taskDetailsList = new ArrayList<TaskDetails>();
if (resources != null && !resources.isEmpty()){
- for (TaskDetailExperimentCatResource resource : resources){
+ for (TaskDetailResource resource : resources){
taskDetailsList.add(getTaskDetail(resource));
}
}
return taskDetailsList;
}
- public static List<JobDetails> getJobDetailsList(List<JobDetailExperimentCatResource> jobs) throws RegistryException {
+ public static List<JobDetails> getJobDetailsList(List<JobDetailResource> jobs) throws RegistryException {
List<JobDetails> jobDetailsList = new ArrayList<JobDetails>();
if (jobs != null && !jobs.isEmpty()){
- for (JobDetailExperimentCatResource resource : jobs){
+ for (JobDetailResource resource : jobs){
jobDetailsList.add(getJobDetail(resource));
}
}
@@ -524,19 +524,19 @@ public class ThriftDataModelConversion {
}
- public static JobDetails getJobDetail(JobDetailExperimentCatResource jobDetailResource) throws RegistryException {
+ public static JobDetails getJobDetail(JobDetailResource jobDetailResource) throws RegistryException {
if (jobDetailResource != null){
JobDetails jobDetails = new JobDetails();
jobDetails.setJobID(jobDetailResource.getJobId());
jobDetails.setJobDescription(jobDetailResource.getJobDescription());
jobDetails.setCreationTime(jobDetailResource.getCreationTime().getTime());
- StatusExperimentCatResource jobStatus = jobDetailResource.getJobStatus();
+ StatusResource jobStatus = jobDetailResource.getJobStatus();
jobDetails.setJobStatus(getJobStatus(jobStatus));
jobDetails.setJobName(jobDetailResource.getJobName());
jobDetails.setWorkingDir(jobDetailResource.getWorkingDir());
- StatusExperimentCatResource applicationStatus = jobDetailResource.getApplicationStatus();
+ StatusResource applicationStatus = jobDetailResource.getApplicationStatus();
jobDetails.setApplicationStatus(getApplicationStatus(applicationStatus));
- List<ErrorDetailExperimentCatResource> errorDetails = jobDetailResource.getErrorDetails();
+ List<ErrorDetailResource> errorDetails = jobDetailResource.getErrorDetails();
jobDetails.setErrors(getErrorDetailList(errorDetails));
jobDetails.setComputeResourceConsumed(jobDetailResource.getComputeResourceConsumed());
return jobDetails;
@@ -544,7 +544,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static ErrorDetails getErrorDetails (ErrorDetailExperimentCatResource resource){
+ public static ErrorDetails getErrorDetails (ErrorDetailResource resource){
if (resource != null){
ErrorDetails errorDetails = new ErrorDetails();
errorDetails.setErrorID(String.valueOf(resource.getErrorId()));
@@ -560,17 +560,17 @@ public class ThriftDataModelConversion {
return null;
}
- public static List<ErrorDetails> getErrorDetailList (List<ErrorDetailExperimentCatResource> errorDetailResources){
+ public static List<ErrorDetails> getErrorDetailList (List<ErrorDetailResource> errorDetailResources){
List<ErrorDetails> errorDetailsList = new ArrayList<ErrorDetails>();
if (errorDetailResources != null && !errorDetailResources.isEmpty()){
- for (ErrorDetailExperimentCatResource errorDetailResource : errorDetailResources){
+ for (ErrorDetailResource errorDetailResource : errorDetailResources){
errorDetailsList.add(getErrorDetails(errorDetailResource));
}
}
return errorDetailsList;
}
- public static DataTransferDetails getDataTransferDetail (DataTransferDetailExperimentCatResource resource) throws RegistryException {
+ public static DataTransferDetails getDataTransferDetail (DataTransferDetailResource resource) throws RegistryException {
if (resource != null){
DataTransferDetails details = new DataTransferDetails();
details.setTransferID(resource.getTransferId());
@@ -582,10 +582,10 @@ public class ThriftDataModelConversion {
return null;
}
- public static List<DataTransferDetails> getDataTransferlList (List<DataTransferDetailExperimentCatResource> resources) throws RegistryException {
+ public static List<DataTransferDetails> getDataTransferlList (List<DataTransferDetailResource> resources) throws RegistryException {
List<DataTransferDetails> transferDetailsList = new ArrayList<DataTransferDetails>();
if (resources != null && !resources.isEmpty()){
- for (DataTransferDetailExperimentCatResource resource : resources){
+ for (DataTransferDetailResource resource : resources){
transferDetailsList.add(getDataTransferDetail(resource));
}
}
@@ -593,7 +593,7 @@ public class ThriftDataModelConversion {
}
- public static UserConfigurationData getUserConfigData (ConfigDataExperimentCatResource resource) throws RegistryException {
+ public static UserConfigurationData getUserConfigData (ConfigDataResource resource) throws RegistryException {
if (resource != null){
UserConfigurationData data = new UserConfigurationData();
data.setAiravataAutoSchedule(resource.isAiravataAutoSchedule());
@@ -602,25 +602,25 @@ public class ThriftDataModelConversion {
data.setUserDN(resource.getUserDn());
data.setGenerateCert(resource.isGenerateCert());
String expID = resource.getExperimentId();
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
+ ExperimentResource experimentResource = new ExperimentResource();
experimentResource.setExpID(expID);
if (experimentResource.isExists(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, expID)){
- ComputationSchedulingExperimentCatResource computationScheduling = experimentResource.getComputationScheduling(expID);
+ ComputationSchedulingResource computationScheduling = experimentResource.getComputationScheduling(expID);
data.setComputationalResourceScheduling(getComputationalResourceScheduling(computationScheduling));
}
if (experimentResource.isExists(ResourceType.ADVANCE_INPUT_DATA_HANDLING, expID)){
- AdvanceInputDataHandlingExperimentCatResource inputDataHandling = experimentResource.getInputDataHandling(expID);
+ AdvanceInputDataHandlingResource inputDataHandling = experimentResource.getInputDataHandling(expID);
data.setAdvanceInputDataHandling(getAdvanceInputDataHandling(inputDataHandling));
}
if (experimentResource.isExists(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, expID)){
- AdvancedOutputDataHandlingExperimentCatResource outputDataHandling = experimentResource.getOutputDataHandling(expID);
+ AdvancedOutputDataHandlingResource outputDataHandling = experimentResource.getOutputDataHandling(expID);
data.setAdvanceOutputDataHandling(getAdvanceOutputDataHandling(outputDataHandling));
}
if (experimentResource.isExists(ResourceType.QOS_PARAM, expID)){
- QosParamExperimentCatResource qoSparams = experimentResource.getQOSparams(expID);
+ QosParamResource qoSparams = experimentResource.getQOSparams(expID);
data.setQosParams(getQOSParams(qoSparams));
}
return data;
@@ -629,7 +629,7 @@ public class ThriftDataModelConversion {
}
- public static ComputationalResourceScheduling getComputationalResourceScheduling (ComputationSchedulingExperimentCatResource csr){
+ public static ComputationalResourceScheduling getComputationalResourceScheduling (ComputationSchedulingResource csr){
if (csr != null){
ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
scheduling.setResourceHostId(csr.getResourceHostId());
@@ -647,7 +647,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static AdvancedInputDataHandling getAdvanceInputDataHandling(AdvanceInputDataHandlingExperimentCatResource adhr){
+ public static AdvancedInputDataHandling getAdvanceInputDataHandling(AdvanceInputDataHandlingResource adhr){
if (adhr != null){
AdvancedInputDataHandling adih = new AdvancedInputDataHandling();
adih.setStageInputFilesToWorkingDir(adhr.isStageInputFiles());
@@ -659,7 +659,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static AdvancedOutputDataHandling getAdvanceOutputDataHandling(AdvancedOutputDataHandlingExperimentCatResource adodh){
+ public static AdvancedOutputDataHandling getAdvanceOutputDataHandling(AdvancedOutputDataHandlingResource adodh){
if (adodh != null){
AdvancedOutputDataHandling outputDataHandling = new AdvancedOutputDataHandling();
outputDataHandling.setOutputDataDir(adodh.getOutputDataDir());
@@ -670,7 +670,7 @@ public class ThriftDataModelConversion {
return null;
}
- public static QualityOfServiceParams getQOSParams (QosParamExperimentCatResource qos){
+ public static QualityOfServiceParams getQOSParams (QosParamResource qos){
if (qos != null){
QualityOfServiceParams qosParams = new QualityOfServiceParams();
qosParams.setStartExecutionAt(qos.getStartExecutionAt());
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/resources/META-INF/experiment-catalog.xml
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/META-INF/experiment-catalog.xml b/modules/registry/registry-core/src/main/resources/META-INF/experiment-catalog.xml
deleted file mode 100644
index d854c5d..0000000
--- a/modules/registry/registry-core/src/main/resources/META-INF/experiment-catalog.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.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.
- *
-* -->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
- <persistence-unit name="experiment_data">
- <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Gateway</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Configuration</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Users</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Gateway_Worker</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Project</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.ProjectUser</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Experiment</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Notification_Email</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Input</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Output</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.WorkflowNodeDetail</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.TaskDetail</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.ErrorDetail</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.ApplicationInput</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.NodeInput</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.NodeOutput</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.JobDetail</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.DataTransferDetail</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Status</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.ExperimentConfigData</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.Computational_Resource_Scheduling</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.AdvancedInputDataHandling</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.AdvancedOutputDataHandling</class>
- <class>org.apache.airavata.registry.core.experiment.catalog.model.QosParam</class>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
- <!--properties>
- <property name="openjpa.ConnectionURL"
- value="jdbc:mysql://localhost:3306/persitant_data" />
- <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
- <property name="openjpa.ConnectionUserName" value="airavata" />
- <property name="openjpa.ConnectionPassword" value="airavata" />
- <property name="openjpa.DynamicEnhancementAgent" value="true" />
- <property name="openjpa.RuntimeUnenhancedClasses" value="supported" />
- <property name="openjpa.Log" value="SQL=TRACE" />
- <property name="openjpa.ConnectionFactoryProperties"
- value="PrettyPrint=true, PrettyPrintLineLength=72, PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=60000" />
- </properties-->
- </persistence-unit>
-</persistence>
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
index dc74376..438aab4 100644
--- a/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
+++ b/modules/registry/registry-core/src/main/resources/META-INF/persistence.xml
@@ -64,4 +64,33 @@
<class>org.apache.airavata.registry.core.app.catalog.model.Configuration</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
+ <persistence-unit name="experiment_data">
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Gateway</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Configuration</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Users</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Gateway_Worker</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Project</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.ProjectUser</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Experiment</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Notification_Email</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Input</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Output</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.WorkflowNodeDetail</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.TaskDetail</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.ErrorDetail</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.ApplicationInput</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.ApplicationOutput</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.NodeInput</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.NodeOutput</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.JobDetail</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.DataTransferDetail</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Status</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.ExperimentConfigData</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.Computational_Resource_Scheduling</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.AdvancedInputDataHandling</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.AdvancedOutputDataHandling</class>
+ <class>org.apache.airavata.registry.core.experiment.catalog.model.QosParam</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ </persistence-unit>
</persistence>
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/AbstractResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/AbstractResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/AbstractResourceTest.java
index 14bde6e..dc5501c 100644
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/AbstractResourceTest.java
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/AbstractResourceTest.java
@@ -19,14 +19,14 @@
*
*/
-package org.apache.airavata.registry.core.experiment.catalog;
+package org.apache.airavata.experiment.catalog;
import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.experiment.catalog.util.Initialize;
+import org.apache.airavata.experiment.catalog.util.Initialize;
import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.resources.*;
-import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.WorkerExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.WorkerResource;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -36,23 +36,23 @@ import java.util.Calendar;
public abstract class AbstractResourceTest {
- private GatewayExperimentCatResource gatewayResource;
- private WorkerExperimentCatResource workerResource;
- private UserExperimentCatResource userResource;
- private ProjectExperimentCatResource projectResource;
+ private GatewayResource gatewayResource;
+ private WorkerResource workerResource;
+ private UserResource userResource;
+ private ProjectResource projectResource;
private static Initialize initialize;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
- initialize = new Initialize("registry-derby.sql");
+ initialize = new Initialize("expcatalog-derby.sql");
initialize.initializeDB();
}
@Before
public void setUp() throws Exception {
- gatewayResource = (GatewayExperimentCatResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
- workerResource = (WorkerExperimentCatResource) ExpCatResourceUtils.getWorker(gatewayResource.getGatewayName(), ServerSettings.getDefaultUser());
- userResource = (UserExperimentCatResource) ExpCatResourceUtils.getUser(ServerSettings.getDefaultUser());
+ gatewayResource = (GatewayResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
+ workerResource = (WorkerResource) ExpCatResourceUtils.getWorker(gatewayResource.getGatewayName(), ServerSettings.getDefaultUser());
+ userResource = (UserResource) ExpCatResourceUtils.getUser(ServerSettings.getDefaultUser());
projectResource = workerResource.getProject("default");
}
@@ -67,23 +67,23 @@ public abstract class AbstractResourceTest {
}
- public GatewayExperimentCatResource getGatewayResource() {
+ public GatewayResource getGatewayResource() {
return gatewayResource;
}
- public WorkerExperimentCatResource getWorkerResource() {
+ public WorkerResource getWorkerResource() {
return workerResource;
}
- public UserExperimentCatResource getUserResource() {
+ public UserResource getUserResource() {
return userResource;
}
- public ProjectExperimentCatResource getProjectResource() {
+ public ProjectResource getProjectResource() {
return projectResource;
}
- public void setProjectResource(ProjectExperimentCatResource projectResource) {
+ public void setProjectResource(ProjectResource projectResource) {
this.projectResource = projectResource;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ComputationalSchedulingTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ComputationalSchedulingTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ComputationalSchedulingTest.java
index d6f0191..9b9e945 100644
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ComputationalSchedulingTest.java
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ComputationalSchedulingTest.java
@@ -19,11 +19,11 @@
*
*/
-package org.apache.airavata.registry.core.experiment.catalog;
+package org.apache.airavata.experiment.catalog;
import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ComputationSchedulingExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ComputationSchedulingResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentResource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -36,15 +36,15 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class ComputationalSchedulingTest extends AbstractResourceTest {
- private ExperimentExperimentCatResource experimentResource;
- private ComputationSchedulingExperimentCatResource schedulingResource;
+ private ExperimentResource experimentResource;
+ private ComputationSchedulingResource schedulingResource;
private String experimentID = "testExpID";
@Override
@Before
public void setUp() throws Exception {
super.setUp();
- experimentResource = (ExperimentExperimentCatResource) getGatewayResource().create(ResourceType.EXPERIMENT);
+ experimentResource = (ExperimentResource) getGatewayResource().create(ResourceType.EXPERIMENT);
experimentResource.setExpID(experimentID);
experimentResource.setExecutionUser(getWorkerResource().getUser());
experimentResource.setProjectId(getProjectResource().getId());
@@ -56,7 +56,7 @@ public class ComputationalSchedulingTest extends AbstractResourceTest {
experimentResource.setExpName("TestExperiment");
experimentResource.save();
- schedulingResource = (ComputationSchedulingExperimentCatResource)experimentResource.create(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING);
+ schedulingResource = (ComputationSchedulingResource)experimentResource.create(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING);
schedulingResource.setResourceHostId("testResource");
schedulingResource.setCpuCount(10);
schedulingResource.setNodeCount(5);
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ConfigurationExperimentCatResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ConfigurationExperimentCatResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ConfigurationExperimentCatResourceTest.java
deleted file mode 100644
index 9636454..0000000
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ConfigurationExperimentCatResourceTest.java
+++ /dev/null
@@ -1,58 +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.registry.core.experiment.catalog;
-import static org.junit.Assert.*;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ConfigurationExperimentCatResource;
-import org.junit.After;
-import org.junit.Test;
-
-import java.sql.Timestamp;
-import java.util.Calendar;
-
-public class ConfigurationExperimentCatResourceTest extends AbstractResourceTest {
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- }
- @Test
- public void testSave() throws Exception {
- ConfigurationExperimentCatResource configuration = ExpCatResourceUtils.createConfiguration("testConfigKey");
- configuration.setConfigVal("testConfigValue");
- Calendar calender = Calendar.getInstance();
- java.util.Date d = calender.getTime();
- Timestamp currentTime = new Timestamp(d.getTime());
- configuration.setExpireDate(currentTime);
- configuration.setCategoryID("SYSTEM");
- configuration.save();
-
- assertTrue("Configuration Save succuessful", ExpCatResourceUtils.isConfigurationExist("testConfigKey"));
- //remove test configuration
- ExpCatResourceUtils.removeConfiguration("testConfigKey");
- }
-
- @After
- public void tearDown() throws Exception {
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ConfigurationResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ConfigurationResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ConfigurationResourceTest.java
new file mode 100644
index 0000000..fdcc553
--- /dev/null
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ConfigurationResourceTest.java
@@ -0,0 +1,58 @@
+/*
+*
+* 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.experiment.catalog;
+import static org.junit.Assert.*;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ConfigurationResource;
+import org.junit.After;
+import org.junit.Test;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+
+public class ConfigurationResourceTest extends AbstractResourceTest {
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+ @Test
+ public void testSave() throws Exception {
+ ConfigurationResource configuration = ExpCatResourceUtils.createConfiguration("testConfigKey");
+ configuration.setConfigVal("testConfigValue");
+ Calendar calender = Calendar.getInstance();
+ java.util.Date d = calender.getTime();
+ Timestamp currentTime = new Timestamp(d.getTime());
+ configuration.setExpireDate(currentTime);
+ configuration.setCategoryID("SYSTEM");
+ configuration.save();
+
+ assertTrue("Configuration Save succuessful", ExpCatResourceUtils.isConfigurationExist("testConfigKey"));
+ //remove test configuration
+ ExpCatResourceUtils.removeConfiguration("testConfigKey");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentCatalogUseCaseTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentCatalogUseCaseTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentCatalogUseCaseTest.java
deleted file mode 100644
index d66dd16..0000000
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentCatalogUseCaseTest.java
+++ /dev/null
@@ -1,296 +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.registry.core.experiment.catalog;
-
-import junit.framework.Assert;
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
-import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
-import org.apache.airavata.model.workspace.Project;
-import org.apache.airavata.model.workspace.experiment.*;
-import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
-import org.apache.airavata.registry.core.experiment.catalog.util.Initialize;
-import org.apache.airavata.registry.cpi.*;
-import org.apache.airavata.registry.cpi.utils.Constants;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- * This class contains test cases for the RegistryImpl class which is the default registry
- * implementation. These test cases are written from the perspective of the Airavata API
- * such as creating/updating/deleting/searching projects and experiments etc.
- */
-public class ExperimentCatalogUseCaseTest {
-
- private static ExperimentCatalog experimentCatalog;
- private static Initialize initialize;
-
- @BeforeClass
- public static void setupBeforeClass() throws RegistryException, SQLException {
- initialize = new Initialize("registry-derby.sql");
- initialize.initializeDB();
- experimentCatalog = RegistryFactory.getDefaultRegistry();
- }
-
- @Test
- public void testProject(){
- try {
- String TAG = System.currentTimeMillis() + "";
-
- String gatewayId = ServerSettings.getDefaultUserGateway();
-
- //testing the creation of a project
- Project project = new Project();
- project.setOwner("TestUser"+TAG);
- project.setName("TestProject"+TAG);
- project.setDescription("This is a test project"+TAG);
- String projectId1 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
- Assert.assertNotNull(projectId1);
-
- //testing the update of a project
- Project updatedProject = new Project();
- updatedProject.setProjectID(projectId1);
- updatedProject.setOwner("TestUser"+TAG);
- updatedProject.setName("UpdatedTestProject"+TAG);
- updatedProject.setDescription("This is an updated test project"+TAG);
- experimentCatalog.update(ExperimentCatalogModelType.PROJECT, updatedProject, projectId1);
-
- //testing project retrieval
- Project retrievedProject = (Project) experimentCatalog.get(ExperimentCatalogModelType.PROJECT, projectId1);
- Assert.assertEquals(updatedProject.getProjectID(), retrievedProject.getProjectID());
- Assert.assertEquals(updatedProject.getOwner(), retrievedProject.getOwner());
- Assert.assertEquals(updatedProject.getName(), retrievedProject.getName());
- Assert.assertEquals(updatedProject.getDescription(), retrievedProject.getDescription());
- Assert.assertNotNull(retrievedProject.getCreationTime());
- //created user should be in the shared users list
- Assert.assertTrue(retrievedProject.getSharedUsers().size()==1);
-
- //creating more projects for the same user
- project = new Project();
- project.setOwner("TestUser"+TAG);
- project.setName("Project Terrible"+TAG);
- project.setDescription("This is a test project_2"+TAG);
- String projectId2 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
- Assert.assertNotNull(projectId2);
-
- project = new Project();
- project.setOwner("TestUser"+TAG);
- project.setName("Project Funny"+TAG);
- project.setDescription("This is a test project_3"+TAG);
- String projectId3 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
- Assert.assertNotNull(projectId3);
-
- project = new Project();
- project.setOwner("TestUser"+TAG);
- project.setName("Project Stupid"+TAG);
- project.setDescription("This is a test project_4"+TAG);
- String projectId4 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
- Assert.assertNotNull(projectId4);
-
- project = new Project();
- project.setOwner("TestUser"+TAG);
- project.setName("Project Boring"+TAG);
- project.setDescription("This is a test project_5"+TAG);
- String projectId5 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
- Assert.assertNotNull(projectId5);
-
- //test get all projects created by the user
- List<Object> list = experimentCatalog.get(ExperimentCatalogModelType.PROJECT,
- Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
- Assert.assertTrue(list.size()==5);
-
- //search project by project name
- Map<String, String> filters = new HashMap<String, String>();
- filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
- filters.put(Constants.FieldConstants.ProjectConstants.PROJECT_NAME, "Terrible"+TAG);
- list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters);
- Assert.assertTrue(list.size()==1);
-
- //search project by project description
- filters = new HashMap<String, String>();
- filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
- filters.put(Constants.FieldConstants.ProjectConstants.DESCRIPTION, "test project_2"+TAG);
- list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters);
- Assert.assertTrue(list.size()==1);
-
- //search project with only ownername
- filters = new HashMap<String, String>();
- filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
- list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters);
- Assert.assertTrue(list.size()==5);
-
- //search projects with pagination
- filters = new HashMap<String, String>();
- filters.put(Constants.FieldConstants.ProjectConstants.OWNER, "TestUser"+TAG);
- list = experimentCatalog.search(ExperimentCatalogModelType.PROJECT, filters, 2, 2,
- Constants.FieldConstants.ProjectConstants.CREATION_TIME, ResultOrderType.DESC);
- Assert.assertTrue(list.size()==2);
- Project project1 = (Project)list.get(0);
- Project project2 = (Project)list.get(1);
- Assert.assertTrue(project1.getCreationTime()-project2.getCreationTime() > 0);
- } catch (RegistryException e) {
- e.printStackTrace();
- Assert.fail();
- } catch (ApplicationSettingsException e) {
- e.printStackTrace();
- }
- }
-
- @Test
- public void testExperiment(){
- try {
- long time = System.currentTimeMillis();
- String TAG = time + "";
-
- String gatewayId = ServerSettings.getDefaultUserGateway();
-
- //creating project
- Project project = new Project();
- project.setOwner("TestUser"+TAG);
- project.setName("TestProject"+TAG);
- project.setDescription("This is a test project"+TAG);
- String projectId1 = (String) experimentCatalog.add(ExpCatParentDataType.PROJECT, project, gatewayId);
- Assert.assertNotNull(projectId1);
-
- //creating sample echo experiment. assumes echo application is already defined
- InputDataObjectType inputDataObjectType = new InputDataObjectType();
- inputDataObjectType.setName("Input_to_Echo");
- inputDataObjectType.setValue("Hello World");
-
- ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
- scheduling.setResourceHostId(UUID.randomUUID().toString());
- scheduling.setComputationalProjectAccount("TG-STA110014S");
- scheduling.setTotalCPUCount(1);
- scheduling.setNodeCount(1);
- scheduling.setWallTimeLimit(15);
- scheduling.setQueueName("normal");
-
- UserConfigurationData userConfigurationData = new UserConfigurationData();
- userConfigurationData.setAiravataAutoSchedule(false);
- userConfigurationData.setOverrideManualScheduledParams(false);
- userConfigurationData.setComputationalResourceScheduling(scheduling);
-
- Experiment experiment = new Experiment();
- experiment.setProjectID(projectId1);
- experiment.setUserName("TestUser" + TAG);
- experiment.setName("TestExperiment"+TAG);
- experiment.setDescription("Test 1 experiment");
- experiment.setApplicationId(UUID.randomUUID().toString());
- experiment.setUserConfigurationData(userConfigurationData);
- experiment.addToExperimentInputs(inputDataObjectType);
-
- String experimentId1 = (String) experimentCatalog.add(ExpCatParentDataType.EXPERIMENT, experiment, gatewayId);
- Assert.assertNotNull(experimentId1);
-
- //retrieving the stored experiment
- Experiment retrievedExperiment = (Experiment) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT,
- experimentId1);
- Assert.assertNotNull(retrievedExperiment);
- Assert.assertEquals(retrievedExperiment.getProjectID(), experiment.getProjectID());
- Assert.assertEquals(retrievedExperiment.getDescription(), experiment.getDescription());
- Assert.assertEquals(retrievedExperiment.getName(), experiment.getName());
- Assert.assertEquals(retrievedExperiment.getApplicationId(), experiment.getApplicationId());
- Assert.assertNotNull(retrievedExperiment.getUserConfigurationData());
- Assert.assertNotNull(retrievedExperiment.getExperimentInputs());
-
- //updating an existing experiment
- experiment.setName("NewExperimentName"+TAG);
- OutputDataObjectType outputDataObjectType = new OutputDataObjectType();
- outputDataObjectType.setName("Output_to_Echo");
- outputDataObjectType.setValue("Hello World");
- experiment.addToExperimentOutputs(outputDataObjectType);
- experimentCatalog.update(ExperimentCatalogModelType.EXPERIMENT, experiment, experimentId1);
-
- //creating more experiments
- experiment = new Experiment();
- experiment.setProjectID(projectId1);
- experiment.setUserName("TestUser" + TAG);
- experiment.setName("TestExperiment2" + TAG);
- experiment.setDescription("Test 2 experiment");
- experiment.setApplicationId(UUID.randomUUID().toString());
- experiment.setUserConfigurationData(userConfigurationData);
- experiment.addToExperimentInputs(inputDataObjectType);
-
- String experimentId2 = (String) experimentCatalog.add(ExpCatParentDataType.EXPERIMENT, experiment, gatewayId);
- Assert.assertNotNull(experimentId2);
-
- experiment = new Experiment();
- experiment.setProjectID(projectId1);
- experiment.setUserName("TestUser" + TAG);
- experiment.setName("TestExperiment3"+TAG);
- experiment.setDescription("Test 3 experiment");
- experiment.setApplicationId(UUID.randomUUID().toString());
- experiment.setUserConfigurationData(userConfigurationData);
- experiment.addToExperimentInputs(inputDataObjectType);
-
- String experimentId3 = (String) experimentCatalog.add(ExpCatParentDataType.EXPERIMENT, experiment, gatewayId);
- Assert.assertNotNull(experimentId3);
-
- //searching experiments by
- Map<String, String> filters = new HashMap<String, String>();
- filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, "TestUser" + TAG);
- filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
- filters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_NAME, "Experiment2");
- filters.put(Constants.FieldConstants.ExperimentConstants.EXPERIMENT_STATUS, ExperimentState.CREATED.toString());
- filters.put(Constants.FieldConstants.ExperimentConstants.FROM_DATE, time - 999999999 + "");
- filters.put(Constants.FieldConstants.ExperimentConstants.TO_DATE, time + 999999999 + "");
- List<Object> results = experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT, filters);
- Assert.assertTrue(results.size()==1);
-
- //retrieving all experiments in project
- List<Object> list = experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT,
- Constants.FieldConstants.ExperimentConstants.PROJECT_ID, projectId1);
- Assert.assertTrue(list.size()==3);
-
- //searching all user experiments
- filters = new HashMap();
- filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, "TestUser" + TAG);
- filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
- list = experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT, filters);
- Assert.assertTrue(list.size()==3);
-
- //searching user experiments with pagination
- filters = new HashMap();
- filters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, "TestUser" + TAG);
- filters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY, gatewayId);
- list = experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT, filters, 2, 1,
- Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
- Assert.assertTrue(list.size()==2);
- ExperimentSummary exp1 = (ExperimentSummary)list.get(0);
- ExperimentSummary exp2 = (ExperimentSummary)list.get(1);
- Assert.assertTrue(exp1.getCreationTime()-exp2.getCreationTime() > 0);
-
- } catch (RegistryException e) {
- e.printStackTrace();
- Assert.fail();
- } catch (ApplicationSettingsException e) {
- e.printStackTrace();
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentExperimentCatResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentExperimentCatResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentExperimentCatResourceTest.java
deleted file mode 100644
index e59d842..0000000
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentExperimentCatResourceTest.java
+++ /dev/null
@@ -1,78 +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.registry.core.experiment.catalog;
-
-import static org.junit.Assert.*;
-
-import java.sql.Timestamp;
-import java.util.Date;
-
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentExperimentCatResource;
-import org.junit.After;
-import org.junit.Test;
-
-public class ExperimentExperimentCatResourceTest extends AbstractResourceTest {
- private ExperimentExperimentCatResource experimentResource;
- private String experimentID = "testExpID";
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- experimentResource = (ExperimentExperimentCatResource) getGatewayResource().create(ResourceType.EXPERIMENT);
- experimentResource.setExpID(experimentID);
- experimentResource.setExecutionUser(getWorkerResource().getUser());
- experimentResource.setProjectId(getProjectResource().getId());
- Timestamp currentDate = new Timestamp(new Date().getTime());
- experimentResource.setCreationTime(currentDate);
- experimentResource.setApplicationId("testApplication");
- experimentResource.setApplicationVersion("1.0");
- experimentResource.setDescription("Test Application");
- experimentResource.setExpName("TestExperiment");
- experimentResource.save();
- }
-
- @Test
- public void testCreate() throws Exception {
- assertNotNull("experiment data resource has being created ", experimentResource);
- }
-
- @Test
- public void testSave() throws Exception {
- assertTrue("experiment save successfully", getGatewayResource().isExists(ResourceType.EXPERIMENT, experimentID));
- }
-
- @Test
- public void testGet() throws Exception {
- assertNotNull("experiment data retrieved successfully", getGatewayResource().get(ResourceType.EXPERIMENT, experimentID));
- }
-
- @Test
- public void testRemove() throws Exception {
- getGatewayResource().remove(ResourceType.EXPERIMENT, experimentID);
- assertFalse("experiment data removed successfully", getGatewayResource().isExists(ResourceType.EXPERIMENT, experimentID));
- }
-
- @After
- public void tearDown() throws Exception {
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentInputExperimentCatResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentInputExperimentCatResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentInputExperimentCatResourceTest.java
deleted file mode 100644
index 0ec3566..0000000
--- a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentInputExperimentCatResourceTest.java
+++ /dev/null
@@ -1,77 +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.registry.core.experiment.catalog;
-
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentInputExperimentCatResource;
-import org.junit.After;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
-
-public class ExperimentInputExperimentCatResourceTest extends AbstractResourceTest {
- private ExperimentExperimentCatResource experimentResource;
- private String experimentID = "testExpID";
- ExperimentInputExperimentCatResource experimentInputResource;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- experimentResource = (ExperimentExperimentCatResource) getGatewayResource().create(ResourceType.EXPERIMENT);
- experimentResource.setExpID(experimentID);
- experimentResource.setExecutionUser(getWorkerResource().getUser());
- experimentResource.setProjectId(getProjectResource().getId());
- experimentResource.setCreationTime(getCurrentTimestamp());
- experimentResource.setApplicationId("testApplication");
- experimentResource.setApplicationVersion("1.0");
- experimentResource.setDescription("Test Application");
- experimentResource.setExpName("TestExperiment");
- experimentResource.save();
-
- experimentInputResource = (ExperimentInputExperimentCatResource)experimentResource.create(ResourceType.EXPERIMENT_INPUT);
- experimentInputResource.setExperimentId(experimentID);
- experimentInputResource.setExperimentKey("testKey");
- experimentInputResource.setValue("testValue");
- experimentInputResource.setDataType("string");
- experimentInputResource.save();
- }
-
- @Test
- public void testSave() throws Exception {
- assertTrue("Experiment Input saved successfully", experimentResource.isExists(ResourceType.EXPERIMENT_INPUT, experimentID));
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testGet () throws Exception {
- List<ExperimentInputExperimentCatResource> experimentInputs = experimentResource.getExperimentInputs();
- System.out.println("input counts : " + experimentInputs.size());
- assertTrue("Experiment input retrieved successfully...", experimentInputs.size() > 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentInputResourceTest.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentInputResourceTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentInputResourceTest.java
new file mode 100644
index 0000000..aaf4f9d
--- /dev/null
+++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/experiment/catalog/ExperimentInputResourceTest.java
@@ -0,0 +1,77 @@
+/*
+*
+* 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.experiment.catalog;
+
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentInputResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.ExperimentResource;
+import org.junit.After;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertTrue;
+
+
+public class ExperimentInputResourceTest extends AbstractResourceTest {
+ private ExperimentResource experimentResource;
+ private String experimentID = "testExpID";
+ ExperimentInputResource experimentInputResource;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ experimentResource = (ExperimentResource) getGatewayResource().create(ResourceType.EXPERIMENT);
+ experimentResource.setExpID(experimentID);
+ experimentResource.setExecutionUser(getWorkerResource().getUser());
+ experimentResource.setProjectId(getProjectResource().getId());
+ experimentResource.setCreationTime(getCurrentTimestamp());
+ experimentResource.setApplicationId("testApplication");
+ experimentResource.setApplicationVersion("1.0");
+ experimentResource.setDescription("Test Application");
+ experimentResource.setExpName("TestExperiment");
+ experimentResource.save();
+
+ experimentInputResource = (ExperimentInputResource)experimentResource.create(ResourceType.EXPERIMENT_INPUT);
+ experimentInputResource.setExperimentId(experimentID);
+ experimentInputResource.setExperimentKey("testKey");
+ experimentInputResource.setValue("testValue");
+ experimentInputResource.setDataType("string");
+ experimentInputResource.save();
+ }
+
+ @Test
+ public void testSave() throws Exception {
+ assertTrue("Experiment Input saved successfully", experimentResource.isExists(ResourceType.EXPERIMENT_INPUT, experimentID));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testGet () throws Exception {
+ List<ExperimentInputResource> experimentInputs = experimentResource.getExperimentInputs();
+ System.out.println("input counts : " + experimentInputs.size());
+ assertTrue("Experiment input retrieved successfully...", experimentInputs.size() > 0);
+ }
+}
[08/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputExperimentCatResource.java
deleted file mode 100644
index 6ea26ce..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputExperimentCatResource.java
+++ /dev/null
@@ -1,204 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Output;
-import org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Output_PK;
-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 ExperimentOutputExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(ExperimentOutputExperimentCatResource.class);
-
- private String experimentId;
- private String experimentKey;
- private String value;
- private String dataType;
- private boolean isRequired;
- private boolean dataMovement;
- private String dataNameLocation;
- private boolean requiredToCMD;
- private String searchQuery;
- private String appArgument;
-
- public String getSearchQuery() {
- return searchQuery;
- }
-
- public void setSearchQuery(String searchQuery) {
- this.searchQuery = searchQuery;
- }
-
- public String getAppArgument() {
- return appArgument;
- }
-
- public void setAppArgument(String appArgument) {
- this.appArgument = appArgument;
- }
-
- public boolean getRequiredToCMD() {
- return requiredToCMD;
- }
-
- public void setRequiredToCMD(boolean requiredToCMD) {
- this.requiredToCMD = requiredToCMD;
- }
-
- public boolean getRequired() {
- return isRequired;
- }
-
- public void setRequired(boolean required) {
- this.isRequired = required;
- }
-
- public boolean isDataMovement() {
- return dataMovement;
- }
-
- public void setDataMovement(boolean dataMovement) {
- this.dataMovement = dataMovement;
- }
-
- public String getDataNameLocation() {
- return dataNameLocation;
- }
-
- public void setDataNameLocation(String dataNameLocation) {
- this.dataNameLocation = dataNameLocation;
- }
-
- public String getExperimentKey() {
- return experimentKey;
- }
-
- public void setExperimentKey(String experimentKey) {
- this.experimentKey = experimentKey;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getDataType() {
- return dataType;
- }
-
- public void setDataType(String dataType) {
- this.dataType = dataType;
- }
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public void save() throws RegistryException {
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- Experiment_Output existingOutput = em.find(Experiment_Output.class, new Experiment_Output_PK(experimentId, experimentKey));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Experiment_Output exOutput = new Experiment_Output();
- exOutput.setEx_key(experimentKey);
- exOutput.setExperiment_id(experimentId);
- if (value != null){
- exOutput.setValue(value.toCharArray());
- }
- exOutput.setDataType(dataType);
- exOutput.setRequired(isRequired);
- exOutput.setRequiredToCMD(requiredToCMD);
- exOutput.setDataMovement(dataMovement);
- exOutput.setDataNameLocation(dataNameLocation);
- exOutput.setApplicationArgument(appArgument);
- exOutput.setSearchQuery(searchQuery);
-
- if (existingOutput != null) {
- existingOutput.setEx_key(experimentKey);
- existingOutput.setExperiment_id(experimentId);
- if (value != null){
- existingOutput.setValue(value.toCharArray());
- }
- existingOutput.setDataType(dataType);
- existingOutput.setRequired(isRequired);
- existingOutput.setRequiredToCMD(requiredToCMD);
- existingOutput.setDataMovement(dataMovement);
- existingOutput.setDataNameLocation(dataNameLocation);
- existingOutput.setApplicationArgument(appArgument);
- existingOutput.setSearchQuery(searchQuery);
- exOutput = em.merge(existingOutput);
- } else {
- em.persist(exOutput);
- }
- 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputResource.java
new file mode 100644
index 0000000..d03bdd9
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputResource.java
@@ -0,0 +1,204 @@
+/*
+*
+* 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Output;
+import org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Output_PK;
+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 ExperimentOutputResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(ExperimentOutputResource.class);
+
+ private String experimentId;
+ private String experimentKey;
+ private String value;
+ private String dataType;
+ private boolean isRequired;
+ private boolean dataMovement;
+ private String dataNameLocation;
+ private boolean requiredToCMD;
+ private String searchQuery;
+ private String appArgument;
+
+ public String getSearchQuery() {
+ return searchQuery;
+ }
+
+ public void setSearchQuery(String searchQuery) {
+ this.searchQuery = searchQuery;
+ }
+
+ public String getAppArgument() {
+ return appArgument;
+ }
+
+ public void setAppArgument(String appArgument) {
+ this.appArgument = appArgument;
+ }
+
+ public boolean getRequiredToCMD() {
+ return requiredToCMD;
+ }
+
+ public void setRequiredToCMD(boolean requiredToCMD) {
+ this.requiredToCMD = requiredToCMD;
+ }
+
+ public boolean getRequired() {
+ return isRequired;
+ }
+
+ public void setRequired(boolean required) {
+ this.isRequired = required;
+ }
+
+ public boolean isDataMovement() {
+ return dataMovement;
+ }
+
+ public void setDataMovement(boolean dataMovement) {
+ this.dataMovement = dataMovement;
+ }
+
+ public String getDataNameLocation() {
+ return dataNameLocation;
+ }
+
+ public void setDataNameLocation(String dataNameLocation) {
+ this.dataNameLocation = dataNameLocation;
+ }
+
+ public String getExperimentKey() {
+ return experimentKey;
+ }
+
+ public void setExperimentKey(String experimentKey) {
+ this.experimentKey = experimentKey;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for experiment output data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public void save() throws RegistryException {
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ Experiment_Output existingOutput = em.find(Experiment_Output.class, new Experiment_Output_PK(experimentId, experimentKey));
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Experiment_Output exOutput = new Experiment_Output();
+ exOutput.setEx_key(experimentKey);
+ exOutput.setExperiment_id(experimentId);
+ if (value != null){
+ exOutput.setValue(value.toCharArray());
+ }
+ exOutput.setDataType(dataType);
+ exOutput.setRequired(isRequired);
+ exOutput.setRequiredToCMD(requiredToCMD);
+ exOutput.setDataMovement(dataMovement);
+ exOutput.setDataNameLocation(dataNameLocation);
+ exOutput.setApplicationArgument(appArgument);
+ exOutput.setSearchQuery(searchQuery);
+
+ if (existingOutput != null) {
+ existingOutput.setEx_key(experimentKey);
+ existingOutput.setExperiment_id(experimentId);
+ if (value != null){
+ existingOutput.setValue(value.toCharArray());
+ }
+ existingOutput.setDataType(dataType);
+ existingOutput.setRequired(isRequired);
+ existingOutput.setRequiredToCMD(requiredToCMD);
+ existingOutput.setDataMovement(dataMovement);
+ existingOutput.setDataNameLocation(dataNameLocation);
+ existingOutput.setApplicationArgument(appArgument);
+ existingOutput.setSearchQuery(searchQuery);
+ exOutput = em.merge(existingOutput);
+ } else {
+ em.persist(exOutput);
+ }
+ 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
new file mode 100644
index 0000000..7755f4f
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
@@ -0,0 +1,831 @@
+/*
+*
+* 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.registry.core.experiment.catalog.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.core.experiment.catalog.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;
+
+public class ExperimentResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(ExperimentResource.class);
+// private WorkerResource worker;
+ private String executionUser;
+ private String expID;
+ private Timestamp creationTime;
+ private String gatewayId;
+ private String projectId;
+ private String expName;
+ private String description;
+ private String applicationId;
+ private String applicationVersion;
+ private String workflowTemplateId;
+ private String workflowTemplateVersion;
+ private String workflowExecutionId;
+ private boolean enableEmailNotifications;
+ private String gatewayExecutionId;
+ private List<ExperimentInputResource> experimentInputResources;
+ private List<ExperimentOutputResource> experimentOutputputResources;
+ private ComputationSchedulingResource computationSchedulingResource;
+ private ConfigDataResource userConfigDataResource;
+ private List<WorkflowNodeDetailResource> workflowNodeDetailResourceList;
+ private List<StatusResource> stateChangeList;
+ private List<ErrorDetailResource> errorDetailList;
+ private StatusResource experimentStatus;
+ private List<NotificationEmailResource> emailResourceList;
+
+ /**
+ *
+ * @return experiment ID
+ */
+ public String getExpID() {
+ return expID;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public String getExpName() {
+ return expName;
+ }
+
+ public void setExpName(String expName) {
+ this.expName = expName;
+ }
+
+ public String getApplicationId() {
+ return applicationId;
+ }
+
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
+ }
+
+ public String getApplicationVersion() {
+ return applicationVersion;
+ }
+
+ public void setApplicationVersion(String applicationVersion) {
+ this.applicationVersion = applicationVersion;
+ }
+
+ public String getWorkflowTemplateId() {
+ return workflowTemplateId;
+ }
+
+ public void setWorkflowTemplateId(String workflowTemplateId) {
+ this.workflowTemplateId = workflowTemplateId;
+ }
+
+ public String getWorkflowTemplateVersion() {
+ return workflowTemplateVersion;
+ }
+
+ public void setWorkflowTemplateVersion(String workflowTemplateVersion) {
+ this.workflowTemplateVersion = workflowTemplateVersion;
+ }
+
+ public String getWorkflowExecutionId() {
+ return workflowExecutionId;
+ }
+
+ public void setWorkflowExecutionId(String workflowExecutionId) {
+ this.workflowExecutionId = workflowExecutionId;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isEnableEmailNotifications() {
+ return enableEmailNotifications;
+ }
+
+ public void setEnableEmailNotifications(boolean enableEmailNotifications) {
+ this.enableEmailNotifications = enableEmailNotifications;
+ }
+
+ public String getGatewayExecutionId() {
+ return gatewayExecutionId;
+ }
+
+ public void setGatewayExecutionId(String gatewayExecutionId) {
+ this.gatewayExecutionId = gatewayExecutionId;
+ }
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public String getProjectId() {
+ return projectId;
+ }
+
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
+ }
+
+ public List<ExperimentInputResource> getExperimentInputResources() {
+ return experimentInputResources;
+ }
+
+ public void setExperimentInputResources(List<ExperimentInputResource> experimentInputResources) {
+ this.experimentInputResources = experimentInputResources;
+ }
+
+ public List<ExperimentOutputResource> getExperimentOutputputResources() {
+ return experimentOutputputResources;
+ }
+
+ public void setExperimentOutputputResources(List<ExperimentOutputResource> experimentOutputputResources) {
+ this.experimentOutputputResources = experimentOutputputResources;
+ }
+
+ public ComputationSchedulingResource getComputationSchedulingResource() {
+ return computationSchedulingResource;
+ }
+
+ public void setComputationSchedulingResource(ComputationSchedulingResource computationSchedulingResource) {
+ this.computationSchedulingResource = computationSchedulingResource;
+ }
+
+ public ConfigDataResource getUserConfigDataResource() {
+ return userConfigDataResource;
+ }
+
+ public void setUserConfigDataResource(ConfigDataResource userConfigDataResource) {
+ this.userConfigDataResource = userConfigDataResource;
+ }
+
+ public List<WorkflowNodeDetailResource> getWorkflowNodeDetailResourceList() {
+ return workflowNodeDetailResourceList;
+ }
+
+ public void setWorkflowNodeDetailResourceList(List<WorkflowNodeDetailResource> workflowNodeDetailResourceList) {
+ this.workflowNodeDetailResourceList = workflowNodeDetailResourceList;
+ }
+
+ public List<StatusResource> getStateChangeList() {
+ return stateChangeList;
+ }
+
+ public void setStateChangeList(List<StatusResource> stateChangeList) {
+ this.stateChangeList = stateChangeList;
+ }
+
+ public List<ErrorDetailResource> getErrorDetailList() {
+ return errorDetailList;
+ }
+
+ public void setErrorDetailList(List<ErrorDetailResource> errorDetailList) {
+ this.errorDetailList = errorDetailList;
+ }
+
+ public void setExperimentStatus(StatusResource experimentStatus) {
+ this.experimentStatus = experimentStatus;
+ }
+
+ public List<NotificationEmailResource> getEmailResourceList() {
+ return emailResourceList;
+ }
+
+ public void setEmailResourceList(List<NotificationEmailResource> emailResourceList) {
+ this.emailResourceList = emailResourceList;
+ }
+
+
+ /**
+ * Since experiments are at the leaf level, this method is not
+ * valid for an experiment
+ * @param type child resource types
+ * @return UnsupportedOperationException
+ */
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ switch (type){
+ case EXPERIMENT_INPUT:
+ ExperimentInputResource inputResource = new ExperimentInputResource();
+ inputResource.setExperimentId(expID);
+ return inputResource;
+ case EXPERIMENT_OUTPUT:
+ ExperimentOutputResource experimentOutputResource = new ExperimentOutputResource();
+ experimentOutputResource.setExperimentId(expID);
+ return experimentOutputResource;
+ case NOTIFICATION_EMAIL:
+ NotificationEmailResource emailResource = new NotificationEmailResource();
+ emailResource.setExperimentId(expID);
+ return emailResource;
+ case WORKFLOW_NODE_DETAIL:
+ WorkflowNodeDetailResource nodeDetailResource = new WorkflowNodeDetailResource();
+ nodeDetailResource.setExperimentId(expID);
+ return nodeDetailResource;
+ case ERROR_DETAIL:
+ ErrorDetailResource errorDetailResource = new ErrorDetailResource();
+ errorDetailResource.setExperimentId(expID);
+ return errorDetailResource;
+ case STATUS:
+ StatusResource statusResource = new StatusResource();
+ statusResource.setExperimentId(expID);
+ return statusResource;
+ case CONFIG_DATA:
+ ConfigDataResource configDataResource = new ConfigDataResource();
+ configDataResource.setExperimentId(expID);
+ return configDataResource;
+ case COMPUTATIONAL_RESOURCE_SCHEDULING:
+ ComputationSchedulingResource schedulingResource = new ComputationSchedulingResource();
+ schedulingResource.setExperimentId(expID);
+ return schedulingResource;
+ case ADVANCE_INPUT_DATA_HANDLING:
+ AdvanceInputDataHandlingResource dataHandlingResource = new AdvanceInputDataHandlingResource();
+ dataHandlingResource.setExperimentId(expID);
+ return dataHandlingResource;
+ case ADVANCE_OUTPUT_DATA_HANDLING:
+ AdvancedOutputDataHandlingResource outputDataHandlingResource = new AdvancedOutputDataHandlingResource();
+ outputDataHandlingResource.setExperimentId(expID);
+ return outputDataHandlingResource;
+ case QOS_PARAM:
+ QosParamResource qosParamResource = new QosParamResource();
+ qosParamResource.setExperimentId(expID);
+ return qosParamResource;
+ default:
+ logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for experiment resource.");
+ }
+ }
+
+ /**
+ *
+ * @param type child resource types
+ * @param name name of the child resource
+ * @return UnsupportedOperationException
+ */
+ public void remove(ResourceType type, Object name) throws RegistryException {
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ switch (type) {
+ case EXPERIMENT_INPUT:
+ generator = new QueryGenerator(EXPERIMENT_INPUT);
+ generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case EXPERIMENT_OUTPUT:
+ generator = new QueryGenerator(EXPERIMENT_OUTPUT);
+ generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case NOTIFICATION_EMAIL:
+ generator = new QueryGenerator(NOTIFICATION_EMAIL);
+ generator.setParameter(NotificationEmailConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case WORKFLOW_NODE_DETAIL:
+ generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
+ generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.EXPERIMENT.toString());
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case CONFIG_DATA:
+ generator = new QueryGenerator(CONFIG_DATA);
+ generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case COMPUTATIONAL_RESOURCE_SCHEDULING:
+ generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+ generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case ADVANCE_INPUT_DATA_HANDLING:
+ generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+ generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case ADVANCE_OUTPUT_DATA_HANDLING:
+ generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+ generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case QOS_PARAM:
+ generator = new QueryGenerator(QOS_PARAMS);
+ generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ default:
+ logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+ break;
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param type child resource types
+ * @param name name of the child resource
+ * @return UnsupportedOperationException
+ */
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator;
+ Query q;
+ switch (type) {
+ case EXPERIMENT_INPUT:
+ generator = new QueryGenerator(EXPERIMENT_INPUT);
+ generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
+ q = generator.selectQuery(em);
+ Experiment_Input experimentInput = (Experiment_Input) q.getSingleResult();
+ ExperimentInputResource inputResource = (ExperimentInputResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, experimentInput);
+ em.getTransaction().commit();
+ em.close();
+ return inputResource;
+ case EXPERIMENT_OUTPUT:
+ generator = new QueryGenerator(EXPERIMENT_OUTPUT);
+ generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
+ q = generator.selectQuery(em);
+ Experiment_Output experimentOutput = (Experiment_Output) q.getSingleResult();
+ ExperimentOutputResource outputResource = (ExperimentOutputResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, experimentOutput);
+ em.getTransaction().commit();
+ em.close();
+ return outputResource;
+ case NOTIFICATION_EMAIL:
+ generator = new QueryGenerator(NOTIFICATION_EMAIL);
+ generator.setParameter(NotificationEmailConstants.EXPERIMENT_ID, name);
+ q = generator.selectQuery(em);
+ Notification_Email notificationEmail = (Notification_Email) q.getSingleResult();
+ NotificationEmailResource notificationEmailResource = (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
+ em.getTransaction().commit();
+ em.close();
+ return notificationEmailResource;
+ case WORKFLOW_NODE_DETAIL:
+ generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
+ generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
+ q = generator.selectQuery(em);
+ WorkflowNodeDetail workflowNodeDetail = (WorkflowNodeDetail) q.getSingleResult();
+ WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, workflowNodeDetail);
+ em.getTransaction().commit();
+ em.close();
+ return nodeDetailResource;
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
+ q = generator.selectQuery(em);
+ ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
+ ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+ em.getTransaction().commit();
+ em.close();
+ return errorDetailResource;
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.EXPERIMENT.toString());
+ q = generator.selectQuery(em);
+ Status status = (Status) q.getSingleResult();
+ StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+ em.getTransaction().commit();
+ em.close();
+ return statusResource;
+ case CONFIG_DATA:
+ generator = new QueryGenerator(CONFIG_DATA);
+ generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
+ q = generator.selectQuery(em);
+ ExperimentConfigData configData = (ExperimentConfigData) q.getSingleResult();
+ ConfigDataResource configDataResource = (ConfigDataResource) Utils.getResource(ResourceType.CONFIG_DATA, configData);
+ em.getTransaction().commit();
+ em.close();
+ return configDataResource;
+ case COMPUTATIONAL_RESOURCE_SCHEDULING:
+ generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+ generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
+ generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, null);
+ q = generator.selectQuery(em);
+ Computational_Resource_Scheduling scheduling = (Computational_Resource_Scheduling) q.getSingleResult();
+ ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, scheduling);
+ em.getTransaction().commit();
+ em.close();
+ return schedulingResource;
+ case ADVANCE_INPUT_DATA_HANDLING:
+ generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+ generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
+ generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, null);
+ q = generator.selectQuery(em);
+ AdvancedInputDataHandling inputDataHandling = (AdvancedInputDataHandling) q.getSingleResult();
+ AdvanceInputDataHandlingResource dataHandlingResource = (AdvanceInputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, inputDataHandling);
+ em.getTransaction().commit();
+ em.close();
+ return dataHandlingResource;
+ case ADVANCE_OUTPUT_DATA_HANDLING:
+ generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+ generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
+ generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, null);
+ q = generator.selectQuery(em);
+ AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
+ AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
+ em.getTransaction().commit();
+ em.close();
+ return outputDataHandlingResource;
+ case QOS_PARAM:
+ generator = new QueryGenerator(QOS_PARAMS);
+ generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
+ generator.setParameter(QosParamsConstants.TASK_ID, null);
+ q = generator.selectQuery(em);
+ QosParam qosParam = (QosParam) q.getSingleResult();
+ QosParamResource qosParamResource = (QosParamResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
+ em.getTransaction().commit();
+ em.close();
+ return qosParamResource;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for experiment data resource.");
+ }
+ } catch (Exception e) {
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+
+ }
+
+ /**
+ *
+ * @param type child resource types
+ * @return UnsupportedOperationException
+ */
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ List results;
+ switch (type) {
+ case EXPERIMENT_INPUT:
+ generator = new QueryGenerator(EXPERIMENT_INPUT);
+ generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, expID);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Experiment_Input exInput = (Experiment_Input) result;
+ ExperimentInputResource inputResource =
+ (ExperimentInputResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, exInput);
+ resourceList.add(inputResource);
+ }
+ }
+ break;
+ case EXPERIMENT_OUTPUT:
+ generator = new QueryGenerator(EXPERIMENT_OUTPUT);
+ generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, expID);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Experiment_Output output = (Experiment_Output) result;
+ ExperimentOutputResource outputResource =
+ (ExperimentOutputResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, output);
+ resourceList.add(outputResource);
+ }
+ }
+ break;
+ case NOTIFICATION_EMAIL:
+ generator = new QueryGenerator(NOTIFICATION_EMAIL);
+ generator.setParameter(NotificationEmailConstants.EXPERIMENT_ID, expID);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Notification_Email notificationEmail = (Notification_Email) result;
+ NotificationEmailResource emailResource =
+ (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
+ resourceList.add(emailResource);
+ }
+ }
+ break;
+ case WORKFLOW_NODE_DETAIL:
+ generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
+ generator.setParameter(WorkflowNodeDetailsConstants.EXPERIMENT_ID, expID);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowNodeDetail nodeDetail = (WorkflowNodeDetail) result;
+ WorkflowNodeDetailResource nodeDetailResource =
+ (WorkflowNodeDetailResource) Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, nodeDetail);
+ resourceList.add(nodeDetailResource);
+ }
+ }
+ break;
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, expID);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ErrorDetail errorDetail = (ErrorDetail) result;
+ ErrorDetailResource errorDetailResource =
+ (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+ resourceList.add(errorDetailResource);
+ }
+ }
+ break;
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.EXPERIMENT_ID, expID);
+ 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 experiment 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;
+ }
+
+ /**
+ * save experiment
+ */
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ Experiment existingExp = em.find(Experiment.class, expID);
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Experiment experiment = new Experiment();
+ experiment.setProjectID(projectId);
+ experiment.setExpId(expID);
+ experiment.setExecutionUser(executionUser);
+ experiment.setExecutionUser(executionUser);
+ experiment.setGatewayId(gatewayId);
+ experiment.setCreationTime(creationTime);
+ experiment.setExpName(expName);
+ experiment.setExpDesc(description);
+ experiment.setApplicationId(applicationId);
+ experiment.setAppVersion(applicationVersion);
+ experiment.setWorkflowExecutionId(workflowExecutionId);
+ experiment.setWorkflowTemplateVersion(workflowTemplateVersion);
+ experiment.setWorkflowExecutionId(workflowExecutionId);
+ experiment.setAllowNotification(enableEmailNotifications);
+ experiment.setGatewayExecutionId(gatewayExecutionId);
+ if (existingExp != null) {
+ existingExp.setGatewayId(gatewayId);
+ existingExp.setExecutionUser(executionUser);
+ existingExp.setProjectID(projectId);
+ existingExp.setCreationTime(creationTime);
+ existingExp.setExpName(expName);
+ existingExp.setExpDesc(description);
+ existingExp.setApplicationId(applicationId);
+ existingExp.setAppVersion(applicationVersion);
+ existingExp.setWorkflowExecutionId(workflowExecutionId);
+ existingExp.setWorkflowTemplateVersion(workflowTemplateVersion);
+ existingExp.setWorkflowExecutionId(workflowExecutionId);
+ existingExp.setAllowNotification(enableEmailNotifications);
+ existingExp.setGatewayExecutionId(gatewayExecutionId);
+ experiment = em.merge(existingExp);
+ } else {
+ em.persist(experiment);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param expID experiment ID
+ */
+ public void setExpID(String expID) {
+ this.expID = expID;
+ }
+
+ public String getExecutionUser() {
+ return executionUser;
+ }
+
+ public void setExecutionUser(String executionUser) {
+ this.executionUser = executionUser;
+ }
+
+ public List<NotificationEmailResource> getNotificationEmails () throws RegistryException{
+ List<NotificationEmailResource> emailResources = new ArrayList<NotificationEmailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.NOTIFICATION_EMAIL);
+ for (ExperimentCatResource resource : resources) {
+ emailResources.add((NotificationEmailResource) resource);
+ }
+ return emailResources;
+ }
+
+ public List<ExperimentInputResource> getExperimentInputs () throws RegistryException{
+ List<ExperimentInputResource> expInputs = new ArrayList<ExperimentInputResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT_INPUT);
+ for (ExperimentCatResource resource : resources) {
+ expInputs.add((ExperimentInputResource) resource);
+ }
+ return expInputs;
+ }
+
+ public List<ExperimentOutputResource> getExperimentOutputs () throws RegistryException{
+ List<ExperimentOutputResource> expOutputs = new ArrayList<ExperimentOutputResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT_OUTPUT);
+ for (ExperimentCatResource resource : resources) {
+ expOutputs.add((ExperimentOutputResource) resource);
+ }
+ return expOutputs;
+ }
+
+ public StatusResource getExperimentStatus() throws RegistryException{
+ List<ExperimentCatResource> resources = get(ResourceType.STATUS);
+ for (ExperimentCatResource resource : resources) {
+ StatusResource expStatus = (StatusResource) resource;
+ if(expStatus.getStatusType().equals(StatusType.EXPERIMENT.toString())){
+ if (expStatus.getState() == null || expStatus.getState().equals("") ){
+ expStatus.setState("UNKNOWN");
+ }
+ return expStatus;
+ }
+ }
+ return null;
+ }
+
+ public List<StatusResource> getWorkflowNodeStatuses() throws RegistryException{
+ List<StatusResource> statuses = new ArrayList<StatusResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.STATUS);
+ for (ExperimentCatResource resource : resources) {
+ StatusResource workflowNodeStatus = (StatusResource) resource;
+ if(workflowNodeStatus.getStatusType().equals(StatusType.WORKFLOW_NODE.toString())){
+ if (workflowNodeStatus.getState() == null || workflowNodeStatus.getState().equals("")){
+ workflowNodeStatus.setState("UNKNOWN");
+ }
+ statuses.add(workflowNodeStatus);
+ }
+ }
+ return statuses;
+ }
+
+ public List<WorkflowNodeDetailResource> getWorkflowNodeDetails () throws RegistryException{
+ List<WorkflowNodeDetailResource> workflowNodeDetailResourceList = new ArrayList<WorkflowNodeDetailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.WORKFLOW_NODE_DETAIL);
+ for (ExperimentCatResource resource : resources) {
+ WorkflowNodeDetailResource nodeDetailResource = (WorkflowNodeDetailResource) resource;
+ workflowNodeDetailResourceList.add(nodeDetailResource);
+ }
+ return workflowNodeDetailResourceList;
+ }
+
+ public List<ErrorDetailResource> getErrorDetails () throws RegistryException{
+ List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
+ for (ExperimentCatResource resource : resources) {
+ ErrorDetailResource errorDetailResource = (ErrorDetailResource) resource;
+ errorDetailResources.add(errorDetailResource);
+ }
+ return errorDetailResources;
+ }
+
+ public ComputationSchedulingResource getComputationScheduling (String expId) throws RegistryException{
+ return (ComputationSchedulingResource)get(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, expId);
+ }
+
+ public AdvanceInputDataHandlingResource getInputDataHandling (String expId) throws RegistryException{
+ return (AdvanceInputDataHandlingResource)get(ResourceType.ADVANCE_INPUT_DATA_HANDLING, expId);
+ }
+
+ public AdvancedOutputDataHandlingResource getOutputDataHandling (String expId) throws RegistryException{
+ return (AdvancedOutputDataHandlingResource)get(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, expId);
+ }
+
+ public QosParamResource getQOSparams (String expId) throws RegistryException{
+ return (QosParamResource)get(ResourceType.QOS_PARAM, expId);
+ }
+
+ public ConfigDataResource getUserConfigData(String expID) throws RegistryException{
+ return (ConfigDataResource)get(ResourceType.CONFIG_DATA, expID);
+ }
+ public WorkflowNodeDetailResource getWorkflowNode (String nodeId) throws RegistryException{
+ return (WorkflowNodeDetailResource)get(ResourceType.WORKFLOW_NODE_DETAIL, nodeId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryExperimentCatResource.java
deleted file mode 100644
index f1bb749..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryExperimentCatResource.java
+++ /dev/null
@@ -1,134 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.el.MethodNotFoundException;
-import java.sql.Timestamp;
-import java.util.List;
-
-public class ExperimentSummaryExperimentCatResource extends AbstractExperimentCatResource {
- private final static Logger logger = LoggerFactory.getLogger(ExperimentSummaryExperimentCatResource.class);
-
- private String executionUser;
- private String expID;
- private String projectID;
- private Timestamp creationTime;
- private String expName;
- private String description;
- private String applicationId;
-
- private StatusExperimentCatResource status;
-
- @Override
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- throw new MethodNotFoundException();
- }
-
- @Override
- public void remove(ResourceType type, Object name) throws RegistryException {
- throw new MethodNotFoundException();
- }
-
- @Override
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- throw new MethodNotFoundException();
- }
-
- @Override
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
- throw new MethodNotFoundException();
- }
-
- @Override
- public void save() throws RegistryException {
- throw new MethodNotFoundException();
- }
-
- public String getExecutionUser() {
- return executionUser;
- }
-
- public void setExecutionUser(String executionUser) {
- this.executionUser = executionUser;
- }
-
- public String getExpID() {
- return expID;
- }
-
- public void setExpID(String expID) {
- this.expID = expID;
- }
-
- public String getProjectID() {
- return projectID;
- }
-
- public void setProjectID(String projectID) {
- this.projectID = projectID;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- public String getExpName() {
- return expName;
- }
-
- public void setExpName(String expName) {
- this.expName = expName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getApplicationId() {
- return applicationId;
- }
-
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
- }
-
- public StatusExperimentCatResource getStatus() {
- return status;
- }
-
- public void setStatus(StatusExperimentCatResource status) {
- this.status = status;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryResource.java
new file mode 100644
index 0000000..0b0d1af
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentSummaryResource.java
@@ -0,0 +1,134 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.el.MethodNotFoundException;
+import java.sql.Timestamp;
+import java.util.List;
+
+public class ExperimentSummaryResource extends AbstractExpCatResource {
+ private final static Logger logger = LoggerFactory.getLogger(ExperimentSummaryResource.class);
+
+ private String executionUser;
+ private String expID;
+ private String projectID;
+ private Timestamp creationTime;
+ private String expName;
+ private String description;
+ private String applicationId;
+
+ private StatusResource status;
+
+ @Override
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ throw new MethodNotFoundException();
+ }
+
+ @Override
+ public void remove(ResourceType type, Object name) throws RegistryException {
+ throw new MethodNotFoundException();
+ }
+
+ @Override
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ throw new MethodNotFoundException();
+ }
+
+ @Override
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
+ throw new MethodNotFoundException();
+ }
+
+ @Override
+ public void save() throws RegistryException {
+ throw new MethodNotFoundException();
+ }
+
+ public String getExecutionUser() {
+ return executionUser;
+ }
+
+ public void setExecutionUser(String executionUser) {
+ this.executionUser = executionUser;
+ }
+
+ public String getExpID() {
+ return expID;
+ }
+
+ public void setExpID(String expID) {
+ this.expID = expID;
+ }
+
+ public String getProjectID() {
+ return projectID;
+ }
+
+ public void setProjectID(String projectID) {
+ this.projectID = projectID;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public String getExpName() {
+ return expName;
+ }
+
+ public void setExpName(String expName) {
+ this.expName = expName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getApplicationId() {
+ return applicationId;
+ }
+
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
+ }
+
+ public StatusResource getStatus() {
+ return status;
+ }
+
+ public void setStatus(StatusResource status) {
+ this.status = status;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayExperimentCatResource.java
deleted file mode 100644
index eadec86..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/GatewayExperimentCatResource.java
+++ /dev/null
@@ -1,437 +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.registry.core.experiment.catalog.resources;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GatewayExperimentCatResource extends AbstractExperimentCatResource {
- private final static Logger logger = LoggerFactory.getLogger(GatewayExperimentCatResource.class);
-
- private String gatewayId;
- private String gatewayName;
- private String domain;
- private String emailAddress;
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- public String getEmailAddress() {
- return emailAddress;
- }
-
- public void setEmailAddress(String emailAddress) {
- this.emailAddress = emailAddress;
- }
-
- /**
- *
- * @param gatewayId gateway name
- */
- public GatewayExperimentCatResource(String gatewayId) {
- setGatewayId(gatewayId);
- }
-
- /**
- *
- */
- public GatewayExperimentCatResource() {
- }
-
- /**
- *
- * @return gateway name
- */
- public String getGatewayName() {
- return gatewayName;
- }
-
- /**
- *
- * @param gatewayName
- */
- public void setGatewayName(String gatewayName) {
- this.gatewayName = gatewayName;
- }
-
- /**
- *
- * @return domain of the gateway
- */
- public String getDomain() {
- return domain;
- }
-
- /**
- *
- * @param domain domain of the gateway
- */
- public void setDomain(String domain) {
- this.domain = domain;
- }
-
-
- /**
- * Gateway is at the root level. So it can populate his child resources.
- * Project, User, Published Workflows, User workflows, Host descriptors,
- * Service Descriptors, Application descriptors and Experiments are all
- * its children
- * @param type resource type of the children
- * @return specific child resource type
- */
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- switch (type) {
- case PROJECT:
- ProjectExperimentCatResource projectResource = new ProjectExperimentCatResource();
- projectResource.setGatewayId(gatewayId);
- return projectResource;
- case EXPERIMENT:
- ExperimentExperimentCatResource experimentResource =new ExperimentExperimentCatResource();
- experimentResource.setGatewayId(gatewayId);
- return experimentResource;
- case GATEWAY_WORKER:
- WorkerExperimentCatResource workerResource = new WorkerExperimentCatResource();
- workerResource.setGatewayId(gatewayId);
- return workerResource;
- default:
- logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
- }
- }
-
- /**
- * Child resources can be removed from a gateway
- * @param type child resource type
- * @param name child resource name
- */
- public void remove(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- switch (type) {
- case USER:
- generator = new QueryGenerator(USERS);
- generator.setParameter(UserConstants.USERNAME, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case EXPERIMENT:
- generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- default:
- logger.error("Unsupported resource type for gateway 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();
- }
- }
- }
-
- /**
- * Gateway can get information of his children
- * @param type child resource type
- * @param name child resource name
- * @return specific child resource type
- */
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator;
- Query q;
- switch (type) {
- case GATEWAY_WORKER:
- generator = new QueryGenerator(GATEWAY_WORKER);
- generator.setParameter(GatewayWorkerConstants.USERNAME, name);
- generator.setParameter(GatewayWorkerConstants.GATEWAY_ID, gatewayId);
- q = generator.selectQuery(em);
- Gateway_Worker worker = (Gateway_Worker) q.getSingleResult();
- WorkerExperimentCatResource workerResource =
- (WorkerExperimentCatResource) Utils.getResource(ResourceType.GATEWAY_WORKER, worker);
- em.getTransaction().commit();
- em.close();
- return workerResource;
- case USER:
- generator = new QueryGenerator(USERS);
- generator.setParameter(UserConstants.USERNAME, name);
- q = generator.selectQuery(em);
- Users user = (Users) q.getSingleResult();
- UserExperimentCatResource userResource =
- (UserExperimentCatResource) Utils.getResource(ResourceType.USER, user);
- em.getTransaction().commit();
- em.close();
- return userResource;
- case EXPERIMENT:
- generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- Experiment experiment = (Experiment) q.getSingleResult();
- ExperimentExperimentCatResource experimentResource =
- (ExperimentExperimentCatResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
- em.getTransaction().commit();
- em.close();
- return experimentResource;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
- }
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @param type child resource type
- * @return list of child resources
- */
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- List results;
- switch (type) {
- case PROJECT:
- generator = new QueryGenerator(PROJECT);
- Gateway gatewayModel = em.find(Gateway.class, gatewayId);
- generator.setParameter("gateway", gatewayModel);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Project project = (Project) result;
- ProjectExperimentCatResource projectResource =
- (ProjectExperimentCatResource) Utils.getResource(ResourceType.PROJECT, project);
- resourceList.add(projectResource);
- }
- }
- break;
- case GATEWAY_WORKER:
- generator = new QueryGenerator(GATEWAY_WORKER);
- generator.setParameter(GatewayWorkerConstants.GATEWAY_ID, gatewayId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Gateway_Worker gatewayWorker = (Gateway_Worker) result;
- WorkerExperimentCatResource workerResource =
- (WorkerExperimentCatResource) Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
- resourceList.add(workerResource);
- }
- }
- break;
- case EXPERIMENT:
- generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.GATEWAY_ID, gatewayId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Experiment experiment = (Experiment) result;
- ExperimentExperimentCatResource experimentResource =
- (ExperimentExperimentCatResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
- resourceList.add(experimentResource);
- }
- }
- break;
- case USER:
- generator = new QueryGenerator(USERS);
- q = generator.selectQuery(em);
- for (Object o : q.getResultList()) {
- Users user = (Users) o;
- UserExperimentCatResource userResource =
- (UserExperimentCatResource) Utils.getResource(ResourceType.USER, user);
- resourceList.add(userResource);
- }
- break;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- /**
- * save the gateway to the database
- */
- public void save() throws RegistryException {
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- Gateway existingGateway = em.find(Gateway.class, gatewayId);
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Gateway gateway = new Gateway();
- gateway.setGateway_name(gatewayName);
- gateway.setGateway_id(gatewayId);
- gateway.setDomain(domain);
- gateway.setEmailAddress(emailAddress);
- if (existingGateway != null) {
- existingGateway.setDomain(domain);
- existingGateway.setGateway_name(gatewayName);
- existingGateway.setEmailAddress(emailAddress);
- gateway = em.merge(existingGateway);
- } else {
- em.persist(gateway);
- }
- 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();
- }
- }
-
- }
-
- /**
- * check whether child resource already exist in the database
- * @param type child resource type
- * @param name name of the child resource
- * @return true or false
- */
- public boolean isExists(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- switch (type) {
- case GATEWAY_WORKER:
- em = ExpCatResourceUtils.getEntityManager();
- Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayId, name.toString()));
- em.close();
- return existingWorker != null;
- case USER:
- em = ExpCatResourceUtils.getEntityManager();
- Users existingUser = em.find(Users.class, name);
- em.close();
- return existingUser != null;
- case EXPERIMENT:
- em = ExpCatResourceUtils.getEntityManager();
- Experiment existingExp = em.find(Experiment.class, name.toString());
- em.close();
- return existingExp != null;
- default:
- logger.error("Unsupported resource type for gateway resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for gateway resource.");
- }
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public ExperimentExperimentCatResource createExperiment (String experimentID) throws RegistryException{
- ExperimentExperimentCatResource metadataResource = (ExperimentExperimentCatResource)create(ResourceType.EXPERIMENT);
- metadataResource.setExpID(experimentID);
- return metadataResource;
- }
-
- public ExperimentExperimentCatResource getExperiment (String expId) throws RegistryException{
- return (ExperimentExperimentCatResource)get(ResourceType.EXPERIMENT, expId);
- }
-
- public List<ExperimentExperimentCatResource> getExperiments () throws RegistryException{
- List<ExperimentExperimentCatResource> experiments = new ArrayList<ExperimentExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT);
- for (ExperimentCatResource resource : resources){
- experiments.add((ExperimentExperimentCatResource)resource);
- }
- return experiments;
- }
-}
-
[14/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java
new file mode 100644
index 0000000..e4d7b5c
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputResource.java
@@ -0,0 +1,410 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.Workflow;
+import org.apache.airavata.registry.core.app.catalog.model.WorkflowOutput;
+import org.apache.airavata.registry.core.app.catalog.model.WorkflowOutput_PK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class WorkflowOutputResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(WorkflowOutputResource.class);
+
+ private String wfTemplateId;
+ private String outputKey;
+ private String outputVal;
+ private String dataType;
+ private String validityType;
+ private boolean dataMovement;
+ private String dataNameLocation;
+
+ private WorkflowResource workflowResource;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
+ generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, ids.get(WFOutputConstants.WF_TEMPLATE_ID));
+ generator.setParameter(WFOutputConstants.OUTPUT_KEY, ids.get(WFOutputConstants.OUTPUT_KEY));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
+ generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, ids.get(WFOutputConstants.WF_TEMPLATE_ID));
+ generator.setParameter(WFOutputConstants.OUTPUT_KEY, ids.get(WFOutputConstants.OUTPUT_KEY));
+ Query q = generator.selectQuery(em);
+ WorkflowOutput wfOutput = (WorkflowOutput) q.getSingleResult();
+ WorkflowOutputResource workflowOutputResource =
+ (WorkflowOutputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_OUTPUT
+ , wfOutput);
+ em.getTransaction().commit();
+ em.close();
+ return workflowOutputResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> wfOutputResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
+ List results;
+ if (fieldName.equals(WFOutputConstants.WF_TEMPLATE_ID)) {
+ generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowOutput wfOutput = (WorkflowOutput) result;
+ WorkflowOutputResource workflowOutputResource =
+ (WorkflowOutputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.WORKFLOW_OUTPUT, wfOutput);
+ wfOutputResources.add(workflowOutputResource);
+ }
+ }
+ } else if (fieldName.equals(WFOutputConstants.OUTPUT_KEY)) {
+ generator.setParameter(WFOutputConstants.OUTPUT_KEY, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowOutput workflowOutput = (WorkflowOutput) result;
+ WorkflowOutputResource workflowOutputResource =
+ (WorkflowOutputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.WORKFLOW_OUTPUT, workflowOutput);
+ wfOutputResources.add(workflowOutputResource);
+ }
+ }
+ } else if (fieldName.equals(WFOutputConstants.DATA_TYPE)) {
+ generator.setParameter(WFOutputConstants.DATA_TYPE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowOutput workflowOutput = (WorkflowOutput) result;
+ WorkflowOutputResource workflowOutputResource =
+ (WorkflowOutputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.WORKFLOW_OUTPUT, workflowOutput);
+ wfOutputResources.add(workflowOutputResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for WF Output Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for WF Output Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return wfOutputResources;
+ }
+
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> wfOutputResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
+ List results;
+ if (fieldName.equals(WFOutputConstants.WF_TEMPLATE_ID)) {
+ generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowOutput workflowOutput = (WorkflowOutput) result;
+ wfOutputResourceIDs.add(workflowOutput.getWfTemplateId());
+ }
+ }
+ }
+ if (fieldName.equals(WFOutputConstants.OUTPUT_KEY)) {
+ generator.setParameter(WFOutputConstants.OUTPUT_KEY, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowOutput workflowOutput = (WorkflowOutput) result;
+ wfOutputResourceIDs.add(workflowOutput.getWfTemplateId());
+ }
+ }
+ } else if (fieldName.equals(WFOutputConstants.DATA_TYPE)) {
+ generator.setParameter(WFOutputConstants.DATA_TYPE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowOutput workflowOutput = (WorkflowOutput) result;
+ wfOutputResourceIDs.add(workflowOutput.getWfTemplateId());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for WF Output resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for WF Output Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return wfOutputResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ WorkflowOutput existingWorkflowOutput = em.find(WorkflowOutput.class,
+ new WorkflowOutput_PK(wfTemplateId, outputKey));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingWorkflowOutput != null) {
+ existingWorkflowOutput.setWfTemplateId(wfTemplateId);
+ Workflow workflow = em.find(Workflow.class, wfTemplateId);
+ existingWorkflowOutput.setWorkflow(workflow);
+ existingWorkflowOutput.setDataType(dataType);
+ existingWorkflowOutput.setOutputKey(outputKey);
+ if (outputVal != null){
+ existingWorkflowOutput.setOutputVal(outputVal.toCharArray());
+ }
+ existingWorkflowOutput.setValidityType(validityType);
+ existingWorkflowOutput.setDataMovement(dataMovement);
+ existingWorkflowOutput.setDataNameLocation(dataNameLocation);
+ em.merge(existingWorkflowOutput);
+ } else {
+ WorkflowOutput workflowOutput = new WorkflowOutput();
+ workflowOutput.setWfTemplateId(wfTemplateId);
+ Workflow workflow = em.find(Workflow.class, wfTemplateId);
+ workflowOutput.setWorkflow(workflow);
+ workflowOutput.setDataType(dataType);
+ workflowOutput.setOutputKey(outputKey);
+ if (outputVal != null){
+ workflowOutput.setOutputVal(outputVal.toCharArray());
+ }
+ workflowOutput.setValidityType(validityType);
+ workflowOutput.setDataMovement(dataMovement);
+ workflowOutput.setDataNameLocation(dataNameLocation);
+ em.persist(workflowOutput);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ WorkflowOutput workflowOutput = em.find(WorkflowOutput.class, new WorkflowOutput_PK(
+ ids.get(WFOutputConstants.WF_TEMPLATE_ID),
+ ids.get(WFOutputConstants.OUTPUT_KEY)));
+
+ em.close();
+ return workflowOutput != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getWfTemplateId() {
+ return wfTemplateId;
+ }
+
+ public void setWfTemplateId(String wfTemplateId) {
+ this.wfTemplateId = wfTemplateId;
+ }
+
+ public String getOutputKey() {
+ return outputKey;
+ }
+
+ public void setOutputKey(String outputKey) {
+ this.outputKey = outputKey;
+ }
+
+ public String getOutputVal() {
+ return outputVal;
+ }
+
+ public void setOutputVal(String outputVal) {
+ this.outputVal = outputVal;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public WorkflowResource getWorkflowResource() {
+ return workflowResource;
+ }
+
+ public void setWorkflowResource(WorkflowResource workflowResource) {
+ this.workflowResource = workflowResource;
+ }
+
+ public String getValidityType() {
+ return validityType;
+ }
+
+ public void setValidityType(String validityType) {
+ this.validityType = validityType;
+ }
+
+ 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java
new file mode 100644
index 0000000..4c79ed1
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowResource.java
@@ -0,0 +1,382 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.Workflow;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+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 WorkflowResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(WorkflowResource.class);
+ private String wfName;
+ private String createdUser;
+ private String graph;
+ private String wfTemplateId;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+ private String image;
+ private String gatewayId;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
+ generator.setParameter(WorkflowConstants.WF_TEMPLATE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
+ generator.setParameter(WorkflowConstants.WF_TEMPLATE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ Workflow workflow = (Workflow) q.getSingleResult();
+ WorkflowResource workflowResource = (WorkflowResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
+ em.getTransaction().commit();
+ em.close();
+ return workflowResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> workflowResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
+ Query q;
+ if ((fieldName.equals(WorkflowConstants.WF_NAME)) || (fieldName.equals(WorkflowConstants.CREATED_USER)) || (fieldName.equals(WorkflowConstants.GRAPH)) || (fieldName.equals(WorkflowConstants.WF_TEMPLATE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ Workflow workflow = (Workflow) result;
+ WorkflowResource workflowResource = (WorkflowResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
+ workflowResources.add(workflowResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return workflowResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ List<AppCatalogResource> workflows = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
+ generator.setParameter(WorkflowConstants.GATEWAY_ID, gatewayId);
+ Query q = generator.selectQuery(em);
+ List results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Workflow workflow = (Workflow) result;
+ WorkflowResource wfResource =
+ (WorkflowResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
+ workflows.add(wfResource);
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return workflows;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ List<String> workflowIds = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
+ generator.setParameter(WorkflowConstants.GATEWAY_ID, gatewayId);
+ Query q = generator.selectQuery(em);
+ List results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Workflow workflow = (Workflow) result;
+ workflowIds.add(workflow.getWfTemplateId());
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return workflowIds;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> workflowResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
+ Query q;
+ if ((fieldName.equals(WorkflowConstants.WF_NAME)) || (fieldName.equals(WorkflowConstants.CREATED_USER)) || (fieldName.equals(WorkflowConstants.GRAPH)) || (fieldName.equals(WorkflowConstants.WF_TEMPLATE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ Workflow workflow = (Workflow) result;
+ WorkflowResource workflowResource = (WorkflowResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
+ workflowResourceIDs.add(workflowResource.getWfTemplateId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return workflowResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ Workflow existingWorkflow = em.find(Workflow.class, wfTemplateId);
+ em.close();
+ Workflow workflow;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingWorkflow == null) {
+ workflow = new Workflow();
+ workflow.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ workflow = existingWorkflow;
+ workflow.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ workflow.setWfName(getWfName());
+ workflow.setCreatedUser(getCreatedUser());
+ workflow.setGatewayId(gatewayId);
+ if (getGraph() != null){
+ workflow.setGraph(getGraph().toCharArray());
+ }
+ if (image != null){
+ workflow.setImage(image.getBytes());
+ }
+ workflow.setWfTemplateId(getWfTemplateId());
+ if (existingWorkflow == null) {
+ em.persist(workflow);
+ } else {
+ em.merge(workflow);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ Workflow workflow = em.find(Workflow.class, identifier);
+ em.close();
+ return workflow != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getWfName() {
+ return wfName;
+ }
+
+ public String getCreatedUser() {
+ return createdUser;
+ }
+
+ public String getGraph() {
+ return graph;
+ }
+
+ public String getWfTemplateId() {
+ return wfTemplateId;
+ }
+
+ public void setWfName(String wfName) {
+ this.wfName=wfName;
+ }
+
+ public void setCreatedUser(String createdUser) {
+ this.createdUser=createdUser;
+ }
+
+ public void setGraph(String graph) {
+ this.graph=graph;
+ }
+
+ public void setWfTemplateId(String wfTemplateId) {
+ this.wfTemplateId=wfTemplateId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
index f91c71d..7a40013 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
+import javax.persistence.PersistenceContext;
import java.util.HashMap;
import java.util.Map;
@@ -43,6 +44,7 @@ public class AppCatalogJPAUtils {
private static final String APPCATALOG_JDBC_PWD = "appcatalog.jdbc.password";
private static final String APPCATALOG_VALIDATION_QUERY = "appcatalog.validationQuery";
private static final String JPA_CACHE_SIZE = "jpa.cache.size";
+ @PersistenceContext(unitName="appcatalog_data")
protected static EntityManagerFactory factory;
public static EntityManager getEntityManager() throws ApplicationSettingsException {
@@ -375,7 +377,7 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createLocalDataMovement(LocalDataMovement o) {
- LocalDataMovementAppCatalogResourceAppCat localDataMovementResource = new LocalDataMovementAppCatalogResourceAppCat();
+ LocalDataMovementResource localDataMovementResource = new LocalDataMovementResource();
if (o != null){
localDataMovementResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
}
@@ -383,10 +385,10 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createLocalSubmission(LocalSubmission o) {
- LocalSubmissionAppCatalogResourceAppCat localSubmissionResource = new LocalSubmissionAppCatalogResourceAppCat();
+ LocalSubmissionResource localSubmissionResource = new LocalSubmissionResource();
if (o != null){
localSubmissionResource.setResourceJobManagerId(o.getResourceJobManagerId());
- localSubmissionResource.setResourceJobManagerResource((ResourceJobManagerAppCatalogResourceAppCat)createResourceJobManager(o.getResourceJobManager()));
+ localSubmissionResource.setResourceJobManagerResource((ResourceJobManagerResource)createResourceJobManager(o.getResourceJobManager()));
localSubmissionResource.setJobSubmissionInterfaceId(o.getJobSubmissionInterfaceId());
localSubmissionResource.setCreatedTime(o.getCreationTime());
if (o.getUpdateTime() != null){
@@ -397,10 +399,10 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createJobManagerCommand(JobManagerCommand o) {
- JobManagerCommandAppCatalogResourceAppCat jobManagerCommandResource = new JobManagerCommandAppCatalogResourceAppCat();
+ JobManagerCommandResource jobManagerCommandResource = new JobManagerCommandResource();
if (o != null){
jobManagerCommandResource.setResourceJobManagerId(o.getResourceJobManagerId());
- jobManagerCommandResource.setResourceJobManagerResource((ResourceJobManagerAppCatalogResourceAppCat)createResourceJobManager(o.getResourceJobManager()));
+ jobManagerCommandResource.setResourceJobManagerResource((ResourceJobManagerResource)createResourceJobManager(o.getResourceJobManager()));
jobManagerCommandResource.setCommandType(o.getCommandType());
jobManagerCommandResource.setCommand(o.getCommand());
}
@@ -408,7 +410,7 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createResourceJobManager(ResourceJobManager o) {
- ResourceJobManagerAppCatalogResourceAppCat resourceJobManagerResource = new ResourceJobManagerAppCatalogResourceAppCat();
+ ResourceJobManagerResource resourceJobManagerResource = new ResourceJobManagerResource();
if (o != null) {
resourceJobManagerResource.setResourceJobManagerId(o.getResourceJobManagerId());
resourceJobManagerResource.setPushMonitoringEndpoint(o.getPushMonitoringEndpoint());
@@ -423,10 +425,10 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createDataMovementInterface(DataMovementInterface o) {
- DataMovementInterfaceAppCatalogResourceAppCat dataMovementInterfaceResource = new DataMovementInterfaceAppCatalogResourceAppCat();
+ DataMovementInterfaceResource dataMovementInterfaceResource = new DataMovementInterfaceResource();
if (o != null) {
dataMovementInterfaceResource.setComputeResourceId(o.getComputeResourceId());
- dataMovementInterfaceResource.setComputeHostResource((ComputeResourceAppCatalogResourceAppCat)createComputeResource(o.getComputeResource()));
+ dataMovementInterfaceResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
dataMovementInterfaceResource.setDataMovementProtocol(o.getDataMovementProtocol());
dataMovementInterfaceResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
dataMovementInterfaceResource.setPriorityOrder(o.getPriorityOrder());
@@ -439,11 +441,11 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createJobSubmissionInterface(JobSubmissionInterface o) {
- JobSubmissionInterfaceAppCatalogResourceAppCat jobSubmissionInterfaceResource = new JobSubmissionInterfaceAppCatalogResourceAppCat();
+ JobSubmissionInterfaceResource jobSubmissionInterfaceResource = new JobSubmissionInterfaceResource();
if (o != null) {
jobSubmissionInterfaceResource.setJobSubmissionInterfaceId(o.getJobSubmissionInterfaceId());
jobSubmissionInterfaceResource.setComputeResourceId(o.getComputeResourceId());
- jobSubmissionInterfaceResource.setComputeHostResource((ComputeResourceAppCatalogResourceAppCat)createComputeResource(o.getComputeResource()));
+ jobSubmissionInterfaceResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
jobSubmissionInterfaceResource.setJobSubmissionProtocol(o.getJobSubmissionProtocol());
jobSubmissionInterfaceResource.setPriorityOrder(o.getPriorityOrder());
jobSubmissionInterfaceResource.setCreatedTime(o.getCreationTime());
@@ -455,10 +457,10 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createComputeResourceFileSystem(ComputeResourceFileSystem o) {
- ComputeResourceFileSystemAppCatalogResourceAppCat computeResourceFileSystemResource = new ComputeResourceFileSystemAppCatalogResourceAppCat();
+ ComputeResourceFileSystemResource computeResourceFileSystemResource = new ComputeResourceFileSystemResource();
if (o != null){
computeResourceFileSystemResource.setComputeResourceId(o.getComputeResourceId());
- computeResourceFileSystemResource.setComputeHostResource((ComputeResourceAppCatalogResourceAppCat)createComputeResource(o.getComputeResource()));
+ computeResourceFileSystemResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
computeResourceFileSystemResource.setPath(o.getPath());
computeResourceFileSystemResource.setFileSystem(o.getFileSystem());
}
@@ -466,10 +468,10 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createBatchQueue(BatchQueue o) {
- BatchQueueAppCatalogResourceAppCat batchQueueResource = new BatchQueueAppCatalogResourceAppCat();
+ BatchQueueResource batchQueueResource = new BatchQueueResource();
if (o != null){
batchQueueResource.setComputeResourceId(o.getComputeResourceId());
- batchQueueResource.setComputeHostResource((ComputeResourceAppCatalogResourceAppCat)createComputeResource(o.getComputeResource()));
+ batchQueueResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
batchQueueResource.setMaxRuntime(o.getMaxRuntime());
batchQueueResource.setMaxJobInQueue(o.getMaxJobInQueue());
batchQueueResource.setQueueDescription(o.getQueueDescription());
@@ -481,7 +483,7 @@ public class AppCatalogJPAUtils {
return batchQueueResource;
}
private static AppCatalogResource createComputeResource(ComputeResource o) {
- ComputeResourceAppCatalogResourceAppCat computeResourceResource = new ComputeResourceAppCatalogResourceAppCat();
+ ComputeResourceResource computeResourceResource = new ComputeResourceResource();
if (o != null) {
computeResourceResource.setResourceDescription(o.getResourceDescription());
computeResourceResource.setResourceId(o.getResourceId());
@@ -496,27 +498,27 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createHostAlias(HostAlias o) {
- HostAliasAppCatalogResourceAppCat aliasResource = new HostAliasAppCatalogResourceAppCat();
+ HostAliasAppResource aliasResource = new HostAliasAppResource();
if (o != null){
aliasResource.setResourceID(o.getResourceID());
aliasResource.setAlias(o.getAlias());
- aliasResource.setComputeHostResource((ComputeResourceAppCatalogResourceAppCat)createComputeResource(o.getComputeResource()));
+ aliasResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
}
return aliasResource;
}
private static AppCatalogResource createHostIPAddress(HostIPAddress o) {
- HostIPAddressAppCatalogResourceAppCat ipAddressResource = new HostIPAddressAppCatalogResourceAppCat();
+ HostIPAddressResource ipAddressResource = new HostIPAddressResource();
if (o != null){
ipAddressResource.setResourceID(o.getResourceID());
ipAddressResource.setIpaddress(o.getIpaddress());
- ipAddressResource.setComputeHostResource((ComputeResourceAppCatalogResourceAppCat)createComputeResource(o.getComputeResource()));
+ ipAddressResource.setComputeHostResource((ComputeResourceResource)createComputeResource(o.getComputeResource()));
}
return ipAddressResource;
}
private static AppCatalogResource createGSSISSHSubmission(GSISSHSubmission o) {
- GSISSHSubmissionAppCatalogResourceAppCat submissionResource = new GSISSHSubmissionAppCatalogResourceAppCat();
+ GSISSHSubmissionResource submissionResource = new GSISSHSubmissionResource();
if (o != null) {
submissionResource.setSubmissionID(o.getSubmissionID());
submissionResource.setResourceJobManager(o.getResourceJobManager());
@@ -529,7 +531,7 @@ public class AppCatalogJPAUtils {
private static AppCatalogResource createUnicoreJobSubmission(UnicoreJobSubmission o) {
- UnicoreJobSubmissionAppCatalogResourceAppCat submissionResource = new UnicoreJobSubmissionAppCatalogResourceAppCat();
+ UnicoreJobSubmissionResource submissionResource = new UnicoreJobSubmissionResource();
if (o != null) {
submissionResource.setjobSubmissionInterfaceId(o.getSubmissionID());
submissionResource.setUnicoreEndpointUrl(o.getUnicoreEndpointUrl());
@@ -539,7 +541,7 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createUnicoreDataMovement(UnicoreDataMovement o) {
- UnicoreDataMovementAppCatalogResourceAppCat dataMovementResource = new UnicoreDataMovementAppCatalogResourceAppCat();
+ UnicoreDataMovementResource dataMovementResource = new UnicoreDataMovementResource();
if (o != null) {
dataMovementResource.setDataMovementId(o.getDataMovementId());
dataMovementResource.setUnicoreEndpointUrl(o.getUnicoreEndpointUrl());
@@ -549,37 +551,37 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createGSISSHExport(GSISSHExport o){
- GSISSHExportAppCatalogResourceAppCat resource = new GSISSHExportAppCatalogResourceAppCat();
+ GSISSHExportResource resource = new GSISSHExportResource();
if (o != null) {
resource.setSubmissionID(o.getSubmissionID());
resource.setExport(o.getExport());
- resource.setGsisshSubmissionResource((GSISSHSubmissionAppCatalogResourceAppCat)createGSSISSHSubmission(o.getGsisshJobSubmission()));
+ resource.setGsisshSubmissionResource((GSISSHSubmissionResource)createGSSISSHSubmission(o.getGsisshJobSubmission()));
}
return resource;
}
private static AppCatalogResource createPreJobCommand(PreJobCommand o){
- PreJobCommandAppCatalogResourceAppCat resource = new PreJobCommandAppCatalogResourceAppCat();
+ PreJobCommandResource resource = new PreJobCommandResource();
if (o != null) {
resource.setAppDeploymentId(o.getDeploymentId());
resource.setCommand(o.getCommand());
- resource.setAppDeploymentResource((AppDeploymentAppCatalogResourceAppCat) createApplicationDeployment(o.getApplicationDeployment()));
+ resource.setAppDeploymentResource((AppDeploymentResource) createApplicationDeployment(o.getApplicationDeployment()));
}
return resource;
}
private static AppCatalogResource createPostJObCommand(PostJobCommand o){
- PostJobCommandAppCatalogResourceAppCat resource = new PostJobCommandAppCatalogResourceAppCat();
+ PostJobCommandResource resource = new PostJobCommandResource();
if (o != null){
resource.setAppDeploymentId(o.getDeploymentId());
resource.setCommand(o.getCommand());
- resource.setAppDeploymentResource((AppDeploymentAppCatalogResourceAppCat) createApplicationDeployment(o.getDeployment()));
+ resource.setAppDeploymentResource((AppDeploymentResource) createApplicationDeployment(o.getDeployment()));
}
return resource;
}
private static AppCatalogResource createGlobusJobSubmission(GlobusJobSubmission o) {
- GlobusJobSubmissionAppCatalogResourceAppCat resource = new GlobusJobSubmissionAppCatalogResourceAppCat();
+ GlobusJobSubmissionResource resource = new GlobusJobSubmissionResource();
if (o != null){
resource.setSubmissionID(o.getSubmissionID());
resource.setResourceJobManager(o.getResourceJobManager());
@@ -589,20 +591,20 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createGlobusEndpoint(GlobusGKEndpoint o) {
- GlobusGKEndpointAppCatalogResourceAppCat resource = new GlobusGKEndpointAppCatalogResourceAppCat();
+ GlobusGKEndpointResource resource = new GlobusGKEndpointResource();
if (o != null){
resource.setSubmissionID(o.getSubmissionID());
resource.setEndpoint(o.getEndpoint());
- resource.setGlobusJobSubmissionResource((GlobusJobSubmissionAppCatalogResourceAppCat)createGlobusJobSubmission(o.getGlobusSubmission()));
+ resource.setGlobusJobSubmissionResource((GlobusJobSubmissionResource)createGlobusJobSubmission(o.getGlobusSubmission()));
}
return resource;
}
private static AppCatalogResource createSshJobSubmission(SshJobSubmission o) {
- SshJobSubmissionAppCatalogResourceAppCat sshJobSubmissionResource = new SshJobSubmissionAppCatalogResourceAppCat();
+ SshJobSubmissionResource sshJobSubmissionResource = new SshJobSubmissionResource();
if (o != null) {
sshJobSubmissionResource.setResourceJobManagerId(o.getResourceJobManagerId());
- sshJobSubmissionResource.setResourceJobManagerResource((ResourceJobManagerAppCatalogResourceAppCat) createResourceJobManager(o.getResourceJobManager()));
+ sshJobSubmissionResource.setResourceJobManagerResource((ResourceJobManagerResource) createResourceJobManager(o.getResourceJobManager()));
sshJobSubmissionResource.setJobSubmissionInterfaceId(o.getJobSubmissionInterfaceId());
sshJobSubmissionResource.setAlternativeSshHostname(o.getAlternativeSshHostname());
sshJobSubmissionResource.setSecurityProtocol(o.getSecurityProtocol());
@@ -617,7 +619,7 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createScpDataMovement(ScpDataMovement o) {
- ScpDataMovementAppCatalogResourceAppCat scpDataMovementResource = new ScpDataMovementAppCatalogResourceAppCat();
+ ScpDataMovementResource scpDataMovementResource = new ScpDataMovementResource();
if (o != null){
scpDataMovementResource.setQueueDescription(o.getQueueDescription());
scpDataMovementResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
@@ -633,7 +635,7 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createGridftpDataMovement(GridftpDataMovement o) {
- GridftpDataMovementAppCatalogResourceAppCat gridftpDataMovementResource = new GridftpDataMovementAppCatalogResourceAppCat();
+ GridftpDataMovementResource gridftpDataMovementResource = new GridftpDataMovementResource();
if (o != null){
gridftpDataMovementResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
gridftpDataMovementResource.setSecurityProtocol(o.getSecurityProtocol());
@@ -646,11 +648,11 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createGridftpEndpoint(GridftpEndpoint o) {
- GridftpEndpointAppCatalogResourceAppCat gridftpEndpointResource = new GridftpEndpointAppCatalogResourceAppCat();
+ GridftpEndpointResource gridftpEndpointResource = new GridftpEndpointResource();
if (o != null){
gridftpEndpointResource.setEndpoint(o.getEndpoint());
gridftpEndpointResource.setDataMovementInterfaceId(o.getDataMovementInterfaceId());
- gridftpEndpointResource.setGridftpDataMovementResource((GridftpDataMovementAppCatalogResourceAppCat)createGridftpDataMovement(o.getGridftpDataMovement()));
+ gridftpEndpointResource.setGridftpDataMovementResource((GridftpDataMovementResource)createGridftpDataMovement(o.getGridftpDataMovement()));
gridftpEndpointResource.setCreatedTime(o.getCreationTime());
if (o.getUpdateTime() != null){
gridftpEndpointResource.setUpdatedTime(o.getUpdateTime());
@@ -682,7 +684,7 @@ public class AppCatalogJPAUtils {
// }
private static AppCatalogResource createApplicationModule(ApplicationModule o) {
- AppModuleAppCatalogResourceAppCat moduleResource = new AppModuleAppCatalogResourceAppCat();
+ AppModuleResource moduleResource = new AppModuleResource();
if (o != null){
moduleResource.setModuleId(o.getModuleID());
moduleResource.setModuleDesc(o.getModuleDesc());
@@ -698,7 +700,7 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createApplicationDeployment(ApplicationDeployment o) {
- AppDeploymentAppCatalogResourceAppCat resource = new AppDeploymentAppCatalogResourceAppCat();
+ AppDeploymentResource resource = new AppDeploymentResource();
if (o != null){
resource.setDeploymentId(o.getDeploymentID());
resource.setAppDes(o.getApplicationDesc());
@@ -707,8 +709,8 @@ public class AppCatalogJPAUtils {
resource.setExecutablePath(o.getExecutablePath());
resource.setGatewayId(o.getGatewayId());
resource.setParallelism(o.getParallelism());
- resource.setModuleResource((AppModuleAppCatalogResourceAppCat) createApplicationModule(o.getApplicationModule()));
- resource.setHostResource((ComputeResourceAppCatalogResourceAppCat) createComputeResource(o.getComputeResource()));
+ resource.setModuleResource((AppModuleResource) createApplicationModule(o.getApplicationModule()));
+ resource.setHostResource((ComputeResourceResource) createComputeResource(o.getComputeResource()));
resource.setCreatedTime(o.getCreationTime());
if (o.getUpdateTime() != null){
resource.setUpdatedTime(o.getUpdateTime());
@@ -718,40 +720,40 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createLibraryPrepPathResource(LibraryPrepandPath o) {
- LibraryPrepandPathAppCatalogResourceAppCat resource = new LibraryPrepandPathAppCatalogResourceAppCat();
+ LibraryPrepandPathResource resource = new LibraryPrepandPathResource();
if (o != null){
resource.setDeploymentId(o.getDeploymentID());
resource.setName(o.getName());
resource.setValue(o.getValue());
- resource.setAppDeploymentResource((AppDeploymentAppCatalogResourceAppCat) createApplicationDeployment(o.getApplicationDeployment()));
+ resource.setAppDeploymentResource((AppDeploymentResource) createApplicationDeployment(o.getApplicationDeployment()));
}
return resource;
}
private static AppCatalogResource createLibraryApendPathResource(LibraryApendPath o) {
- LibraryApendPathAppCatalogResourceAppCat resource = new LibraryApendPathAppCatalogResourceAppCat();
+ LibraryApendPathResource resource = new LibraryApendPathResource();
if (o != null){
resource.setDeploymentId(o.getDeploymentID());
resource.setName(o.getName());
resource.setValue(o.getValue());
- resource.setAppDeploymentResource((AppDeploymentAppCatalogResourceAppCat)createApplicationDeployment(o.getApplicationDeployment()));
+ resource.setAppDeploymentResource((AppDeploymentResource)createApplicationDeployment(o.getApplicationDeployment()));
}
return resource;
}
private static AppCatalogResource createAppEnvironmentResource(AppEnvironment o) {
- AppEnvironmentAppCatalogResourceAppCat resource = new AppEnvironmentAppCatalogResourceAppCat();
+ AppEnvironmentResource resource = new AppEnvironmentResource();
if (o != null){
resource.setDeploymentId(o.getDeploymentID());
resource.setName(o.getName());
resource.setValue(o.getValue());
- resource.setAppDeploymentResource((AppDeploymentAppCatalogResourceAppCat)createApplicationDeployment(o.getApplicationDeployment()));
+ resource.setAppDeploymentResource((AppDeploymentResource)createApplicationDeployment(o.getApplicationDeployment()));
}
return resource;
}
private static AppCatalogResource createAppInterfaceResource(ApplicationInterface o) {
- AppInterfaceAppCatalogResourceAppCat resource = new AppInterfaceAppCatalogResourceAppCat();
+ AppInterfaceResource resource = new AppInterfaceResource();
if (o != null){
resource.setInterfaceId(o.getInterfaceID());
resource.setAppName(o.getAppName());
@@ -775,7 +777,7 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createApplicationInput(ApplicationInput o) {
- ApplicationInputAppCatalogResourceAppCat resource = new ApplicationInputAppCatalogResourceAppCat();
+ ApplicationInputResource resource = new ApplicationInputResource();
if (o != null){
resource.setInterfaceID(o.getInterfaceID());
resource.setInputKey(o.getInputKey());
@@ -789,13 +791,13 @@ public class AppCatalogJPAUtils {
resource.setRequired(o.isRequired());
resource.setRequiredToCMD(o.isRequiredToCMD());
resource.setDataStaged(o.isDataStaged());
- resource.setAppInterfaceResource((AppInterfaceAppCatalogResourceAppCat)createAppInterfaceResource(o.getApplicationInterface()));
+ resource.setAppInterfaceResource((AppInterfaceResource)createAppInterfaceResource(o.getApplicationInterface()));
}
return resource;
}
private static AppCatalogResource createWorflowInput(WorkflowInput o) {
- WorkflowInputAppCatalogResourceAppCat resource = new WorkflowInputAppCatalogResourceAppCat();
+ WorkflowInputResource resource = new WorkflowInputResource();
if (o != null){
resource.setWfTemplateId(o.getWfTemplateId());
resource.setInputKey(o.getInputKey());
@@ -811,13 +813,13 @@ public class AppCatalogJPAUtils {
resource.setRequired(o.isRequired());
resource.setRequiredToCMD(o.isRequiredToCMD());
resource.setDataStaged(o.isDataStaged());
- resource.setWorkflowResource((WorkflowAppCatalogResourceAppCat)createWorkflow(o.getWorkflow()));
+ resource.setWorkflowResource((WorkflowResource)createWorkflow(o.getWorkflow()));
}
return resource;
}
private static AppCatalogResource createApplicationOutput(ApplicationOutput o) {
- ApplicationOutputAppCatalogResourceAppCat resource = new ApplicationOutputAppCatalogResourceAppCat();
+ ApplicationOutputResource resource = new ApplicationOutputResource();
if (o != null){
resource.setInterfaceID(o.getInterfaceID());
resource.setOutputKey(o.getOutputKey());
@@ -829,13 +831,13 @@ public class AppCatalogJPAUtils {
resource.setDataNameLocation(o.getDataNameLocation());
resource.setSearchQuery(o.getSearchQuery());
resource.setAppArgument(o.getApplicationArgument());
- resource.setAppInterfaceResource((AppInterfaceAppCatalogResourceAppCat)createAppInterfaceResource(o.getApplicationInterface()));
+ resource.setAppInterfaceResource((AppInterfaceResource)createAppInterfaceResource(o.getApplicationInterface()));
}
return resource;
}
private static AppCatalogResource createWorkflowOutput(WorkflowOutput o) {
- WorkflowOutputAppCatalogResourceAppCat resource = new WorkflowOutputAppCatalogResourceAppCat();
+ WorkflowOutputResource resource = new WorkflowOutputResource();
if (o != null){
resource.setWfTemplateId(o.getWfTemplateId());
resource.setOutputKey(o.getOutputKey());
@@ -846,13 +848,13 @@ public class AppCatalogJPAUtils {
resource.setValidityType(o.getValidityType());
resource.setDataMovement(o.isDataMovement());
resource.setDataNameLocation(o.getDataNameLocation());
- resource.setWorkflowResource((WorkflowAppCatalogResourceAppCat)createWorkflow(o.getWorkflow()));
+ resource.setWorkflowResource((WorkflowResource)createWorkflow(o.getWorkflow()));
}
return resource;
}
private static AppCatalogResource createGatewayProfile(GatewayProfile o) {
- GatewayProfileAppCatalogResourceAppCat resource = new GatewayProfileAppCatalogResourceAppCat();
+ GatewayProfileResource resource = new GatewayProfileResource();
if (o != null) {
resource.setGatewayID(o.getGatewayID());
resource.setCreatedTime(o.getCreationTime());
@@ -864,7 +866,7 @@ public class AppCatalogJPAUtils {
}
private static AppCatalogResource createComputeResourcePref(ComputeResourcePreference o) {
- ComputeHostPreferenceAppCatalogResourceAppCat resource = new ComputeHostPreferenceAppCatalogResourceAppCat();
+ ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource();
if (o != null) {
resource.setGatewayId(o.getGatewayId());
resource.setResourceId(o.getResourceId());
@@ -875,24 +877,24 @@ public class AppCatalogJPAUtils {
resource.setScratchLocation(o.getScratchLocation());
resource.setProjectNumber(o.getProjectNumber());
resource.setLoginUserName(o.getLoginUserName());
- resource.setComputeHostResource((ComputeResourceAppCatalogResourceAppCat) createComputeResource(o.getComputeHostResource()));
- resource.setGatewayProfile((GatewayProfileAppCatalogResourceAppCat) createGatewayProfile(o.getGatewayProfile()));
+ resource.setComputeHostResource((ComputeResourceResource) createComputeResource(o.getComputeHostResource()));
+ resource.setGatewayProfile((GatewayProfileResource) createGatewayProfile(o.getGatewayProfile()));
}
return resource;
}
private static AppCatalogResource createModuleLoadCmd(ModuleLoadCmd o) {
- ModuleLoadCmdAppCatalogResourceAppCat moduleLoadCmdResource = new ModuleLoadCmdAppCatalogResourceAppCat();
+ ModuleLoadCmdResource moduleLoadCmdResource = new ModuleLoadCmdResource();
if (o != null){
moduleLoadCmdResource.setCmd(o.getCmd());
moduleLoadCmdResource.setAppDeploymentId(o.getAppDeploymentId());
- moduleLoadCmdResource.setAppDeploymentResource((AppDeploymentAppCatalogResourceAppCat)createApplicationDeployment(o.getApplicationDeployment()));
+ moduleLoadCmdResource.setAppDeploymentResource((AppDeploymentResource)createApplicationDeployment(o.getApplicationDeployment()));
}
return moduleLoadCmdResource;
}
private static AppCatalogResource createWorkflow(Workflow o) {
- WorkflowAppCatalogResourceAppCat workflowResource = new WorkflowAppCatalogResourceAppCat();
+ WorkflowResource workflowResource = new WorkflowResource();
workflowResource.setWfName(o.getWfName());
workflowResource.setCreatedUser(o.getCreatedUser());
if (o.getGraph() != null){
[24/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionResource.java
new file mode 100644
index 0000000..d899a66
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/CloudSubmissionResource.java
@@ -0,0 +1,298 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.CloudJobSubmission;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CloudSubmissionResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(LocalSubmissionResource.class);
+ private String jobSubmissionInterfaceId;
+ private String securityProtocol;
+ private String nodeId;
+ private String executableType;
+ private String providerName;
+ private String userAccountName;
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(CLOUD_JOB_SUBMISSION);
+ generator.setParameter(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(CLOUD_JOB_SUBMISSION);
+ generator.setParameter(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ CloudJobSubmission cloudJobSubmission = (CloudJobSubmission) q.getSingleResult();
+ CloudSubmissionResource localSubmissionResource = (CloudSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.ClOUD_SUBMISSION, cloudJobSubmission);
+ em.getTransaction().commit();
+ em.close();
+ return localSubmissionResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> localSubmissionResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(CLOUD_JOB_SUBMISSION);
+ Query q;
+ if ((fieldName.equals(LocalSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ CloudJobSubmission localSubmission = (CloudJobSubmission) result;
+ CloudSubmissionResource localSubmissionResource = (CloudSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.ClOUD_SUBMISSION, localSubmission);
+ localSubmissionResources.add(localSubmissionResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return localSubmissionResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> localSubmissionResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(CLOUD_JOB_SUBMISSION);
+ Query q;
+ if ((fieldName.equals(LocalSubmissionConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(LocalSubmissionConstants.JOB_SUBMISSION_INTERFACE_ID))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ CloudJobSubmission localSubmission = (CloudJobSubmission) result;
+ LocalSubmissionResource localSubmissionResource = (LocalSubmissionResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.ClOUD_SUBMISSION, localSubmission);
+ localSubmissionResourceIDs.add(localSubmissionResource.getJobSubmissionInterfaceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Local Submission Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Local Submission Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return localSubmissionResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ CloudJobSubmission existingLocalSubmission = em.find(CloudJobSubmission.class, jobSubmissionInterfaceId);
+ em.close();
+ CloudJobSubmission cloudJobSubmission;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingLocalSubmission == null) {
+ cloudJobSubmission = new CloudJobSubmission();
+ } else {
+ cloudJobSubmission = existingLocalSubmission;
+ }
+ cloudJobSubmission.setExecutableType(getExecutableType());
+ cloudJobSubmission.setNodeId(getNodeId());
+ cloudJobSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
+ cloudJobSubmission.setSecurityProtocol(getSecurityProtocol());
+ cloudJobSubmission.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
+ cloudJobSubmission.setUserAccountName(getUserAccountName());
+ cloudJobSubmission.setProviderName(getProviderName());
+ if (existingLocalSubmission == null) {
+ em.persist(cloudJobSubmission);
+ } else {
+ em.merge(cloudJobSubmission);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ CloudJobSubmission localSubmission = em.find(CloudJobSubmission.class, identifier);
+ em.close();
+ return localSubmission != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getJobSubmissionInterfaceId() {
+ return jobSubmissionInterfaceId;
+ }
+
+ public String getSecurityProtocol() {
+ return securityProtocol;
+ }
+
+ public void setSecurityProtocol(String securityProtocol) {
+ this.securityProtocol = securityProtocol;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public String getExecutableType() {
+ return executableType;
+ }
+
+ public void setExecutableType(String executableType) {
+ this.executableType = executableType;
+ }
+
+ public String getProviderName() {
+ return providerName;
+ }
+
+ public void setProviderName(String providerName) {
+ this.providerName = providerName;
+ }
+
+ public String getUserAccountName() {
+ return userAccountName;
+ }
+
+ public void setUserAccountName(String userAccountName) {
+ this.userAccountName = userAccountName;
+ }
+
+ public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
+ this.jobSubmissionInterfaceId=jobSubmissionInterfaceId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceAppCatalogResourceAppCat.java
deleted file mode 100644
index 80f03f7..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,413 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResourcePreference;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResourcePreferencePK;
-import org.apache.airavata.registry.core.app.catalog.model.GatewayProfile;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ComputeHostPreferenceAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(ComputeHostPreferenceAppCatalogResourceAppCat.class);
- private String gatewayId;
- private String resourceId;
- private boolean overrideByAiravata;
- private String preferredJobProtocol;
- private String preferedDMProtocol;
- private String batchQueue;
- private String scratchLocation;
- private String projectNumber;
- private String loginUserName;
-
- private GatewayProfileAppCatalogResourceAppCat gatewayProfile;
- private ComputeResourceAppCatalogResourceAppCat computeHostResource;
-
- public String getLoginUserName() {
- return loginUserName;
- }
-
- public void setLoginUserName(String loginUserName) {
- this.loginUserName = loginUserName;
- }
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- public String getResourceId() {
- return resourceId;
- }
-
- public void setResourceId(String resourceId) {
- this.resourceId = resourceId;
- }
-
- public boolean getOverrideByAiravata() {
- return overrideByAiravata;
- }
-
- public void setOverrideByAiravata(boolean overrideByAiravata) {
- this.overrideByAiravata = overrideByAiravata;
- }
-
- public String getPreferredJobProtocol() {
- return preferredJobProtocol;
- }
-
- public void setPreferredJobProtocol(String preferredJobProtocol) {
- this.preferredJobProtocol = preferredJobProtocol;
- }
-
- public String getPreferedDMProtocol() {
- return preferedDMProtocol;
- }
-
- public void setPreferedDMProtocol(String preferedDMProtocol) {
- this.preferedDMProtocol = preferedDMProtocol;
- }
-
- public String getBatchQueue() {
- return batchQueue;
- }
-
- public void setBatchQueue(String batchQueue) {
- this.batchQueue = batchQueue;
- }
-
- public String getScratchLocation() {
- return scratchLocation;
- }
-
- public void setScratchLocation(String scratchLocation) {
- this.scratchLocation = scratchLocation;
- }
-
- public String getProjectNumber() {
- return projectNumber;
- }
-
- public void setProjectNumber(String projectNumber) {
- this.projectNumber = projectNumber;
- }
-
- public GatewayProfileAppCatalogResourceAppCat getGatewayProfile() {
- return gatewayProfile;
- }
-
- public void setGatewayProfile(GatewayProfileAppCatalogResourceAppCat gatewayProfile) {
- this.gatewayProfile = gatewayProfile;
- }
-
- public ComputeResourceAppCatalogResourceAppCat getComputeHostResource() {
- return computeHostResource;
- }
-
- public void setComputeHostResource(ComputeResourceAppCatalogResourceAppCat computeHostResource) {
- this.computeHostResource = computeHostResource;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_PREFERENCE);
- generator.setParameter(ComputeResourcePreferenceConstants.RESOURCE_ID, ids.get(ComputeResourcePreferenceConstants.RESOURCE_ID));
- generator.setParameter(ComputeResourcePreferenceConstants.GATEWAY_ID, ids.get(ComputeResourcePreferenceConstants.GATEWAY_ID));
-
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_PREFERENCE);
- generator.setParameter(ComputeResourcePreferenceConstants.GATEWAY_ID, ids.get(ComputeResourcePreferenceConstants.GATEWAY_ID));
- generator.setParameter(ComputeResourcePreferenceConstants.RESOURCE_ID, ids.get(ComputeResourcePreferenceConstants.RESOURCE_ID));
- Query q = generator.selectQuery(em);
- ComputeResourcePreference preference = (ComputeResourcePreference) q.getSingleResult();
- ComputeHostPreferenceAppCatalogResourceAppCat preferenceResource =
- (ComputeHostPreferenceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE, preference);
- em.getTransaction().commit();
- em.close();
- return preferenceResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> preferenceResourceList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_PREFERENCE);
- List results;
- if (fieldName.equals(ComputeResourcePreferenceConstants.RESOURCE_ID)) {
- generator.setParameter(ComputeResourcePreferenceConstants.RESOURCE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ComputeResourcePreference preference = (ComputeResourcePreference) result;
- if (preference.getComputeHostResource()!=null) {
- ComputeHostPreferenceAppCatalogResourceAppCat preferenceResource = (ComputeHostPreferenceAppCatalogResourceAppCat) AppCatalogJPAUtils
- .getResource(
- AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE,
- preference);
- preferenceResourceList.add(preferenceResource);
- }
- }
- }
- } else if (fieldName.equals(ComputeResourcePreferenceConstants.GATEWAY_ID)) {
- generator.setParameter(ComputeResourcePreferenceConstants.GATEWAY_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ComputeResourcePreference preference = (ComputeResourcePreference) result;
- if (preference.getComputeHostResource()!=null) {
- ComputeHostPreferenceAppCatalogResourceAppCat preferenceResource =
- (ComputeHostPreferenceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE, preference);
- preferenceResourceList.add(preferenceResource);
- }
- }
- }
- } else if (fieldName.equals(ComputeResourcePreferenceConstants.PREFERED_JOB_SUB_PROTOCOL)) {
- generator.setParameter(ComputeResourcePreferenceConstants.PREFERED_JOB_SUB_PROTOCOL, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ComputeResourcePreference preference = (ComputeResourcePreference) result;
- if (preference.getComputeHostResource()!=null) {
- ComputeHostPreferenceAppCatalogResourceAppCat preferenceResource = (ComputeHostPreferenceAppCatalogResourceAppCat) AppCatalogJPAUtils
- .getResource(
- AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE,
- preference);
- preferenceResourceList.add(preferenceResource);
- }
- }
- }
- } else if (fieldName.equals(ComputeResourcePreferenceConstants.PREFERED_DATA_MOVE_PROTOCOL)) {
- generator.setParameter(ComputeResourcePreferenceConstants.PREFERED_DATA_MOVE_PROTOCOL, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ComputeResourcePreference preference = (ComputeResourcePreference) result;
- if (preference.getResourceId()!=null) {
- ComputeHostPreferenceAppCatalogResourceAppCat preferenceResource = (ComputeHostPreferenceAppCatalogResourceAppCat) AppCatalogJPAUtils
- .getResource(
- AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE,
- preference);
- preferenceResourceList.add(preferenceResource);
- }
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Compute host preference Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Compute host preference Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return preferenceResourceList;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- logger.error("Unsupported for objects with a composite identifier");
- throw new AppCatalogException("Unsupported for objects with a composite identifier");
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ComputeResourcePreference existingPreference = em.find(ComputeResourcePreference.class, new ComputeResourcePreferencePK(gatewayId, resourceId));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- ComputeResource computeResource = em.find(ComputeResource.class, resourceId);
- GatewayProfile gatewayProf = em.find(GatewayProfile.class, gatewayId);
- if (existingPreference != null) {
- existingPreference.setResourceId(resourceId);
- existingPreference.setGatewayId(gatewayId);
- existingPreference.setComputeHostResource(computeResource);
- existingPreference.setGatewayProfile(gatewayProf);
- existingPreference.setOverrideByAiravata(overrideByAiravata);
- existingPreference.setPreferedJobSubmissionProtocol(preferredJobProtocol);
- existingPreference.setPreferedDataMoveProtocol(preferedDMProtocol);
- existingPreference.setScratchLocation(scratchLocation);
- existingPreference.setProjectNumber(projectNumber);
- existingPreference.setBatchQueue(batchQueue);
- existingPreference.setLoginUserName(loginUserName);
- em.merge(existingPreference);
- } else {
- ComputeResourcePreference resourcePreference = new ComputeResourcePreference();
- resourcePreference.setResourceId(resourceId);
- resourcePreference.setGatewayId(gatewayId);
- resourcePreference.setComputeHostResource(computeResource);
- resourcePreference.setGatewayProfile(gatewayProf);
- resourcePreference.setOverrideByAiravata(overrideByAiravata);
- resourcePreference.setPreferedJobSubmissionProtocol(preferredJobProtocol);
- resourcePreference.setPreferedDataMoveProtocol(preferedDMProtocol);
- resourcePreference.setScratchLocation(scratchLocation);
- resourcePreference.setProjectNumber(projectNumber);
- resourcePreference.setBatchQueue(batchQueue);
- resourcePreference.setLoginUserName(loginUserName);
- em.persist(resourcePreference);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ComputeResourcePreference existingPreference = em.find(ComputeResourcePreference.class,
- new ComputeResourcePreferencePK(ids.get(ComputeResourcePreferenceConstants.GATEWAY_ID),
- ids.get(ComputeResourcePreferenceConstants.RESOURCE_ID)));
- em.close();
- return existingPreference != null;
- }catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
new file mode 100644
index 0000000..46685c2
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeHostPreferenceResource.java
@@ -0,0 +1,413 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResourcePreference;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResourcePreferencePK;
+import org.apache.airavata.registry.core.app.catalog.model.GatewayProfile;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ComputeHostPreferenceResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(ComputeHostPreferenceResource.class);
+ private String gatewayId;
+ private String resourceId;
+ private boolean overrideByAiravata;
+ private String preferredJobProtocol;
+ private String preferedDMProtocol;
+ private String batchQueue;
+ private String scratchLocation;
+ private String projectNumber;
+ private String loginUserName;
+
+ private GatewayProfileResource gatewayProfile;
+ private ComputeResourceResource computeHostResource;
+
+ public String getLoginUserName() {
+ return loginUserName;
+ }
+
+ public void setLoginUserName(String loginUserName) {
+ this.loginUserName = loginUserName;
+ }
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ public void setResourceId(String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public boolean getOverrideByAiravata() {
+ return overrideByAiravata;
+ }
+
+ public void setOverrideByAiravata(boolean overrideByAiravata) {
+ this.overrideByAiravata = overrideByAiravata;
+ }
+
+ public String getPreferredJobProtocol() {
+ return preferredJobProtocol;
+ }
+
+ public void setPreferredJobProtocol(String preferredJobProtocol) {
+ this.preferredJobProtocol = preferredJobProtocol;
+ }
+
+ public String getPreferedDMProtocol() {
+ return preferedDMProtocol;
+ }
+
+ public void setPreferedDMProtocol(String preferedDMProtocol) {
+ this.preferedDMProtocol = preferedDMProtocol;
+ }
+
+ public String getBatchQueue() {
+ return batchQueue;
+ }
+
+ public void setBatchQueue(String batchQueue) {
+ this.batchQueue = batchQueue;
+ }
+
+ public String getScratchLocation() {
+ return scratchLocation;
+ }
+
+ public void setScratchLocation(String scratchLocation) {
+ this.scratchLocation = scratchLocation;
+ }
+
+ public String getProjectNumber() {
+ return projectNumber;
+ }
+
+ public void setProjectNumber(String projectNumber) {
+ this.projectNumber = projectNumber;
+ }
+
+ public GatewayProfileResource getGatewayProfile() {
+ return gatewayProfile;
+ }
+
+ public void setGatewayProfile(GatewayProfileResource gatewayProfile) {
+ this.gatewayProfile = gatewayProfile;
+ }
+
+ public ComputeResourceResource getComputeHostResource() {
+ return computeHostResource;
+ }
+
+ public void setComputeHostResource(ComputeResourceResource computeHostResource) {
+ this.computeHostResource = computeHostResource;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_PREFERENCE);
+ generator.setParameter(ComputeResourcePreferenceConstants.RESOURCE_ID, ids.get(ComputeResourcePreferenceConstants.RESOURCE_ID));
+ generator.setParameter(ComputeResourcePreferenceConstants.GATEWAY_ID, ids.get(ComputeResourcePreferenceConstants.GATEWAY_ID));
+
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_PREFERENCE);
+ generator.setParameter(ComputeResourcePreferenceConstants.GATEWAY_ID, ids.get(ComputeResourcePreferenceConstants.GATEWAY_ID));
+ generator.setParameter(ComputeResourcePreferenceConstants.RESOURCE_ID, ids.get(ComputeResourcePreferenceConstants.RESOURCE_ID));
+ Query q = generator.selectQuery(em);
+ ComputeResourcePreference preference = (ComputeResourcePreference) q.getSingleResult();
+ ComputeHostPreferenceResource preferenceResource =
+ (ComputeHostPreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE, preference);
+ em.getTransaction().commit();
+ em.close();
+ return preferenceResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> preferenceResourceList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_PREFERENCE);
+ List results;
+ if (fieldName.equals(ComputeResourcePreferenceConstants.RESOURCE_ID)) {
+ generator.setParameter(ComputeResourcePreferenceConstants.RESOURCE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ComputeResourcePreference preference = (ComputeResourcePreference) result;
+ if (preference.getComputeHostResource()!=null) {
+ ComputeHostPreferenceResource preferenceResource = (ComputeHostPreferenceResource) AppCatalogJPAUtils
+ .getResource(
+ AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE,
+ preference);
+ preferenceResourceList.add(preferenceResource);
+ }
+ }
+ }
+ } else if (fieldName.equals(ComputeResourcePreferenceConstants.GATEWAY_ID)) {
+ generator.setParameter(ComputeResourcePreferenceConstants.GATEWAY_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ComputeResourcePreference preference = (ComputeResourcePreference) result;
+ if (preference.getComputeHostResource()!=null) {
+ ComputeHostPreferenceResource preferenceResource =
+ (ComputeHostPreferenceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE, preference);
+ preferenceResourceList.add(preferenceResource);
+ }
+ }
+ }
+ } else if (fieldName.equals(ComputeResourcePreferenceConstants.PREFERED_JOB_SUB_PROTOCOL)) {
+ generator.setParameter(ComputeResourcePreferenceConstants.PREFERED_JOB_SUB_PROTOCOL, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ComputeResourcePreference preference = (ComputeResourcePreference) result;
+ if (preference.getComputeHostResource()!=null) {
+ ComputeHostPreferenceResource preferenceResource = (ComputeHostPreferenceResource) AppCatalogJPAUtils
+ .getResource(
+ AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE,
+ preference);
+ preferenceResourceList.add(preferenceResource);
+ }
+ }
+ }
+ } else if (fieldName.equals(ComputeResourcePreferenceConstants.PREFERED_DATA_MOVE_PROTOCOL)) {
+ generator.setParameter(ComputeResourcePreferenceConstants.PREFERED_DATA_MOVE_PROTOCOL, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ComputeResourcePreference preference = (ComputeResourcePreference) result;
+ if (preference.getResourceId()!=null) {
+ ComputeHostPreferenceResource preferenceResource = (ComputeHostPreferenceResource) AppCatalogJPAUtils
+ .getResource(
+ AppCatalogResourceType.COMPUTE_RESOURCE_PREFERENCE,
+ preference);
+ preferenceResourceList.add(preferenceResource);
+ }
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Compute host preference Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Compute host preference Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return preferenceResourceList;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ logger.error("Unsupported for objects with a composite identifier");
+ throw new AppCatalogException("Unsupported for objects with a composite identifier");
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ComputeResourcePreference existingPreference = em.find(ComputeResourcePreference.class, new ComputeResourcePreferencePK(gatewayId, resourceId));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ ComputeResource computeResource = em.find(ComputeResource.class, resourceId);
+ GatewayProfile gatewayProf = em.find(GatewayProfile.class, gatewayId);
+ if (existingPreference != null) {
+ existingPreference.setResourceId(resourceId);
+ existingPreference.setGatewayId(gatewayId);
+ existingPreference.setComputeHostResource(computeResource);
+ existingPreference.setGatewayProfile(gatewayProf);
+ existingPreference.setOverrideByAiravata(overrideByAiravata);
+ existingPreference.setPreferedJobSubmissionProtocol(preferredJobProtocol);
+ existingPreference.setPreferedDataMoveProtocol(preferedDMProtocol);
+ existingPreference.setScratchLocation(scratchLocation);
+ existingPreference.setProjectNumber(projectNumber);
+ existingPreference.setBatchQueue(batchQueue);
+ existingPreference.setLoginUserName(loginUserName);
+ em.merge(existingPreference);
+ } else {
+ ComputeResourcePreference resourcePreference = new ComputeResourcePreference();
+ resourcePreference.setResourceId(resourceId);
+ resourcePreference.setGatewayId(gatewayId);
+ resourcePreference.setComputeHostResource(computeResource);
+ resourcePreference.setGatewayProfile(gatewayProf);
+ resourcePreference.setOverrideByAiravata(overrideByAiravata);
+ resourcePreference.setPreferedJobSubmissionProtocol(preferredJobProtocol);
+ resourcePreference.setPreferedDataMoveProtocol(preferedDMProtocol);
+ resourcePreference.setScratchLocation(scratchLocation);
+ resourcePreference.setProjectNumber(projectNumber);
+ resourcePreference.setBatchQueue(batchQueue);
+ resourcePreference.setLoginUserName(loginUserName);
+ em.persist(resourcePreference);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ComputeResourcePreference existingPreference = em.find(ComputeResourcePreference.class,
+ new ComputeResourcePreferencePK(ids.get(ComputeResourcePreferenceConstants.GATEWAY_ID),
+ ids.get(ComputeResourcePreferenceConstants.RESOURCE_ID)));
+ em.close();
+ return existingPreference != null;
+ }catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceAppCatalogResourceAppCat.java
deleted file mode 100644
index 38e6988..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,351 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-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 ComputeResourceAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(ComputeResourceAppCatalogResourceAppCat.class);
- private String resourceDescription;
- private String resourceId;
- private String hostName;
- private Timestamp createdTime;
- private Timestamp updatedTime;
- private int maxMemoryPerNode;
-
- public int getMaxMemoryPerNode() {
- return maxMemoryPerNode;
- }
-
- public void setMaxMemoryPerNode(int maxMemoryPerNode) {
- this.maxMemoryPerNode = maxMemoryPerNode;
- }
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
- generator.setParameter(ComputeResourceConstants.RESOURCE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
- generator.setParameter(ComputeResourceConstants.RESOURCE_ID, identifier);
- Query q = generator.selectQuery(em);
- ComputeResource computeResource = (ComputeResource) q.getSingleResult();
- ComputeResourceAppCatalogResourceAppCat computeResourceResource = (ComputeResourceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE, computeResource);
- em.getTransaction().commit();
- em.close();
- return computeResourceResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> computeResourceResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
- Query q;
- if ((fieldName.equals(ComputeResourceConstants.RESOURCE_DESCRIPTION)) || (fieldName.equals(ComputeResourceConstants.RESOURCE_ID)) || (fieldName.equals(ComputeResourceConstants.HOST_NAME))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ComputeResource computeResource = (ComputeResource) result;
- ComputeResourceAppCatalogResourceAppCat computeResourceResource = (ComputeResourceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE, computeResource);
- computeResourceResources.add(computeResourceResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Compute Resource Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Compute Resource Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return computeResourceResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- List<AppCatalogResource> computeResourceResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
- Query q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ComputeResource computeResource = (ComputeResource) result;
- ComputeResourceAppCatalogResourceAppCat computeResourceResource = (ComputeResourceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE, computeResource);
- computeResourceResources.add(computeResourceResource);
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return computeResourceResources;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- List<String> computeResourceResources = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
- Query q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ComputeResource computeResource = (ComputeResource) result;
- computeResourceResources.add(computeResource.getResourceId());
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return computeResourceResources;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> computeResourceResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE);
- Query q;
- if ((fieldName.equals(ComputeResourceConstants.RESOURCE_DESCRIPTION)) || (fieldName.equals(ComputeResourceConstants.RESOURCE_ID)) || (fieldName.equals(ComputeResourceConstants.HOST_NAME))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ComputeResource computeResource = (ComputeResource) result;
- ComputeResourceAppCatalogResourceAppCat computeResourceResource = (ComputeResourceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE, computeResource);
- computeResourceResourceIDs.add(computeResourceResource.getResourceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Compute Resource Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Compute Resource Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return computeResourceResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ComputeResource existingComputeResource = em.find(ComputeResource.class, resourceId);
- em.close();
- ComputeResource computeResource;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingComputeResource == null) {
- computeResource = new ComputeResource();
- computeResource.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- computeResource = existingComputeResource;
- computeResource.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- computeResource.setResourceDescription(getResourceDescription());
- computeResource.setResourceId(getResourceId());
- computeResource.setHostName(getHostName());
- computeResource.setMaxMemoryPerNode(getMaxMemoryPerNode());
- if (existingComputeResource == null) {
- em.persist(computeResource);
- } else {
- em.merge(computeResource);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ComputeResource computeResource = em.find(ComputeResource.class, identifier);
- em.close();
- return computeResource != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getResourceDescription() {
- return resourceDescription;
- }
-
- public String getResourceId() {
- return resourceId;
- }
-
- public String getHostName() {
- return hostName;
- }
-
- public void setResourceDescription(String resourceDescription) {
- this.resourceDescription=resourceDescription;
- }
-
- public void setResourceId(String resourceId) {
- this.resourceId=resourceId;
- }
-
- public void setHostName(String hostName) {
- this.hostName=hostName;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemAppCatalogResourceAppCat.java
deleted file mode 100644
index 5bf98e4..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ComputeResourceFileSystemAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,307 +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.registry.core.app.catalog.resources;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResourceFileSystem;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResourceFileSystem_PK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ComputeResourceFileSystemAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(ComputeResourceFileSystemAppCatalogResourceAppCat.class);
- private String computeResourceId;
- private ComputeResourceAppCatalogResourceAppCat computeHostResource;
- private String path;
- private String fileSystem;
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_FILE_SYSTEM);
- generator.setParameter(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID, ids.get(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID));
- generator.setParameter(ComputeResourceFileSystemConstants.FILE_SYSTEM, ids.get(ComputeResourceFileSystemConstants.FILE_SYSTEM));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_FILE_SYSTEM);
- generator.setParameter(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID, ids.get(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID));
- generator.setParameter(ComputeResourceFileSystemConstants.FILE_SYSTEM, ids.get(ComputeResourceFileSystemConstants.FILE_SYSTEM));
- Query q = generator.selectQuery(em);
- ComputeResourceFileSystem computeResourceFileSystem = (ComputeResourceFileSystem) q.getSingleResult();
- ComputeResourceFileSystemAppCatalogResourceAppCat computeResourceFileSystemResource = (ComputeResourceFileSystemAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_FILE_SYSTEM, computeResourceFileSystem);
- em.getTransaction().commit();
- em.close();
- return computeResourceFileSystemResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> computeResourceFileSystemResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_FILE_SYSTEM);
- Query q;
- if ((fieldName.equals(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(ComputeResourceFileSystemConstants.PATH)) || (fieldName.equals(ComputeResourceFileSystemConstants.FILE_SYSTEM))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ComputeResourceFileSystem computeResourceFileSystem = (ComputeResourceFileSystem) result;
- ComputeResourceFileSystemAppCatalogResourceAppCat computeResourceFileSystemResource = (ComputeResourceFileSystemAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_FILE_SYSTEM, computeResourceFileSystem);
- computeResourceFileSystemResources.add(computeResourceFileSystemResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Compute Resource File System Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Compute Resource File System Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return computeResourceFileSystemResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> computeResourceFileSystemResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(COMPUTE_RESOURCE_FILE_SYSTEM);
- Query q;
- if ((fieldName.equals(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(ComputeResourceFileSystemConstants.PATH)) || (fieldName.equals(ComputeResourceFileSystemConstants.FILE_SYSTEM))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ComputeResourceFileSystem computeResourceFileSystem = (ComputeResourceFileSystem) result;
- ComputeResourceFileSystemAppCatalogResourceAppCat computeResourceFileSystemResource = (ComputeResourceFileSystemAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.COMPUTE_RESOURCE_FILE_SYSTEM, computeResourceFileSystem);
- computeResourceFileSystemResourceIDs.add(computeResourceFileSystemResource.getComputeResourceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Compute Resource File System Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Compute Resource File System Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return computeResourceFileSystemResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ComputeResourceFileSystem existingComputeResourceFileSystem = em.find(ComputeResourceFileSystem.class, new ComputeResourceFileSystem_PK(computeResourceId, fileSystem));
- em.close();
- ComputeResourceFileSystem computeResourceFileSystem;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingComputeResourceFileSystem == null) {
- computeResourceFileSystem = new ComputeResourceFileSystem();
- } else {
- computeResourceFileSystem = existingComputeResourceFileSystem;
- }
- computeResourceFileSystem.setComputeResourceId(getComputeResourceId());
- ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
- computeResourceFileSystem.setComputeResource(computeResource);
- computeResourceFileSystem.setPath(getPath());
- computeResourceFileSystem.setFileSystem(getFileSystem());
- if (existingComputeResourceFileSystem == null) {
- em.persist(computeResourceFileSystem);
- } else {
- em.merge(computeResourceFileSystem);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ComputeResourceFileSystem computeResourceFileSystem = em.find(ComputeResourceFileSystem.class, new ComputeResourceFileSystem_PK(ids.get(ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID), ids.get(ComputeResourceFileSystemConstants.FILE_SYSTEM)));
- em.close();
- return computeResourceFileSystem != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getComputeResourceId() {
- return computeResourceId;
- }
-
- public ComputeResourceAppCatalogResourceAppCat getComputeHostResource() {
- return computeHostResource;
- }
-
- public String getPath() {
- return path;
- }
-
- public String getFileSystem() {
- return fileSystem;
- }
-
- public void setComputeResourceId(String computeResourceId) {
- this.computeResourceId=computeResourceId;
- }
-
- public void setComputeHostResource(ComputeResourceAppCatalogResourceAppCat computeHostResource) {
- this.computeHostResource=computeHostResource;
- }
-
- public void setPath(String path) {
- this.path=path;
- }
-
- public void setFileSystem(String fileSystem) {
- this.fileSystem=fileSystem;
- }
-}
[05/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskDetailExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskDetailExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskDetailExperimentCatResource.java
deleted file mode 100644
index 6db4f34..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskDetailExperimentCatResource.java
+++ /dev/null
@@ -1,748 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.core.experiment.catalog.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 TaskDetailExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(TaskDetailExperimentCatResource.class);
- private String taskId;
- private String nodeId;
- private Timestamp creationTime;
- private String applicationId;
- private String applicationVersion;
- private String applicationDeploymentId;
- private boolean enableEmailNotifications;
- private List<ApplicationInputExperimentCatResource> applicationInputs;
- private List<ApplicationOutputExperimentCatResource> applicationOutputs;
- private ComputationSchedulingExperimentCatResource schedulingResource;
- private AdvanceInputDataHandlingExperimentCatResource inputDataHandlingResource;
- private AdvancedOutputDataHandlingExperimentCatResource outputDataHandlingResource;
- private StatusExperimentCatResource taskStatus;
- private List<JobDetailExperimentCatResource> jobDetailResources;
- private List<DataTransferDetailExperimentCatResource> transferDetailResourceList;
- private List<NotificationEmailExperimentCatResource> emailResourceList;
- private List<ErrorDetailExperimentCatResource> errors;
-
- public List<JobDetailExperimentCatResource> getJobDetailResources() {
- return jobDetailResources;
- }
-
- public void setJobDetailResources(List<JobDetailExperimentCatResource> jobDetailResources) {
- this.jobDetailResources = jobDetailResources;
- }
-
- public void setApplicationInputs(List<ApplicationInputExperimentCatResource> applicationInputs) {
- this.applicationInputs = applicationInputs;
- }
-
- public void setApplicationOutputs(List<ApplicationOutputExperimentCatResource> applicationOutputs) {
- this.applicationOutputs = applicationOutputs;
- }
-
- public ComputationSchedulingExperimentCatResource getSchedulingResource() {
- return schedulingResource;
- }
-
- public void setSchedulingResource(ComputationSchedulingExperimentCatResource schedulingResource) {
- this.schedulingResource = schedulingResource;
- }
-
- public AdvanceInputDataHandlingExperimentCatResource getInputDataHandlingResource() {
- return inputDataHandlingResource;
- }
-
- public void setInputDataHandlingResource(AdvanceInputDataHandlingExperimentCatResource inputDataHandlingResource) {
- this.inputDataHandlingResource = inputDataHandlingResource;
- }
-
- public AdvancedOutputDataHandlingExperimentCatResource getOutputDataHandlingResource() {
- return outputDataHandlingResource;
- }
-
- public void setOutputDataHandlingResource(AdvancedOutputDataHandlingExperimentCatResource outputDataHandlingResource) {
- this.outputDataHandlingResource = outputDataHandlingResource;
- }
-
- public void setTaskStatus(StatusExperimentCatResource taskStatus) {
- this.taskStatus = taskStatus;
- }
-
- public List<DataTransferDetailExperimentCatResource> getTransferDetailResourceList() {
- return transferDetailResourceList;
- }
-
- public void setTransferDetailResourceList(List<DataTransferDetailExperimentCatResource> transferDetailResourceList) {
- this.transferDetailResourceList = transferDetailResourceList;
- }
-
- public List<NotificationEmailExperimentCatResource> getEmailResourceList() {
- return emailResourceList;
- }
-
- public void setEmailResourceList(List<NotificationEmailExperimentCatResource> emailResourceList) {
- this.emailResourceList = emailResourceList;
- }
-
- public List<ErrorDetailExperimentCatResource> getErrors() {
- return errors;
- }
-
- public void setErrors(List<ErrorDetailExperimentCatResource> errors) {
- this.errors = errors;
- }
-
- public boolean isEnableEmailNotifications() {
- return enableEmailNotifications;
- }
-
- public void setEnableEmailNotifications(boolean enableEmailNotifications) {
- this.enableEmailNotifications = enableEmailNotifications;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- public String getApplicationId() {
- return applicationId;
- }
-
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
- }
-
- public String getApplicationVersion() {
- return applicationVersion;
- }
-
- public void setApplicationVersion(String applicationVersion) {
- this.applicationVersion = applicationVersion;
- }
-
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException{
- switch (type){
- case ERROR_DETAIL:
- ErrorDetailExperimentCatResource errorDetailResource = new ErrorDetailExperimentCatResource();
- errorDetailResource.setTaskId(taskId);
- return errorDetailResource;
- case NOTIFICATION_EMAIL:
- NotificationEmailExperimentCatResource emailResource = new NotificationEmailExperimentCatResource();
- emailResource.setTaskId(taskId);
- return emailResource;
- case APPLICATION_INPUT:
- ApplicationInputExperimentCatResource applicationInputResource = new ApplicationInputExperimentCatResource();
- applicationInputResource.setTaskId(taskId);
- return applicationInputResource;
- case APPLICATION_OUTPUT:
- ApplicationOutputExperimentCatResource applicationOutputResource = new ApplicationOutputExperimentCatResource();
- applicationOutputResource.setTaskId(taskId);
- return applicationOutputResource;
- case JOB_DETAIL:
- JobDetailExperimentCatResource jobDetailResource = new JobDetailExperimentCatResource();
- jobDetailResource.setTaskId(taskId);
- return jobDetailResource;
- case DATA_TRANSFER_DETAIL:
- DataTransferDetailExperimentCatResource dataTransferDetailResource = new DataTransferDetailExperimentCatResource();
- dataTransferDetailResource.setTaskId(taskId);
- return dataTransferDetailResource;
- case STATUS:
- StatusExperimentCatResource statusResource = new StatusExperimentCatResource();
- statusResource.setTaskId(taskId);
- return statusResource;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- ComputationSchedulingExperimentCatResource schedulingResource = new ComputationSchedulingExperimentCatResource();
- schedulingResource.setTaskId(taskId);
- return schedulingResource;
- case ADVANCE_INPUT_DATA_HANDLING:
- AdvanceInputDataHandlingExperimentCatResource inputDataHandlingResource = new AdvanceInputDataHandlingExperimentCatResource();
- inputDataHandlingResource.setTaskId(taskId);
- return inputDataHandlingResource;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- AdvancedOutputDataHandlingExperimentCatResource outputDataHandlingResource = new AdvancedOutputDataHandlingExperimentCatResource();
- outputDataHandlingResource.setTaskId(taskId);
- return outputDataHandlingResource;
- case QOS_PARAM:
- QosParamExperimentCatResource qosParamResource = new QosParamExperimentCatResource();
- qosParamResource.setTaskId(taskId);
- return qosParamResource;
- default:
- logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for task detail resource.");
- }
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- switch (type) {
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case APPLICATION_INPUT:
- generator = new QueryGenerator(APPLICATION_INPUT);
- generator.setParameter(ApplicationInputConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case APPLICATION_OUTPUT:
- generator = new QueryGenerator(APPLICATION_OUTPUT);
- generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case JOB_DETAIL:
- generator = new QueryGenerator(JOB_DETAIL);
- generator.setParameter(JobDetailConstants.TASK_ID, taskId);
- generator.setParameter(JobDetailConstants.JOB_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case DATA_TRANSFER_DETAIL:
- generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
- generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.TASK_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.TASK.toString());
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
- generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ADVANCE_INPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
- generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
- generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case QOS_PARAM:
- generator = new QueryGenerator(QOS_PARAMS);
- generator.setParameter(QosParamsConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- default:
- logger.error("Unsupported resource type for task detail 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator;
- Query q;
- switch (type) {
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
- ErrorDetailExperimentCatResource errorDetailResource = (ErrorDetailExperimentCatResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- em.getTransaction().commit();
- em.close();
- return errorDetailResource;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- Notification_Email notificationEmail = (Notification_Email) q.getSingleResult();
- NotificationEmailExperimentCatResource emailResource = (NotificationEmailExperimentCatResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
- em.getTransaction().commit();
- em.close();
- return emailResource;
- case APPLICATION_INPUT:
- generator = new QueryGenerator(APPLICATION_INPUT);
- generator.setParameter(ApplicationInputConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- ApplicationInput applicationInput = (ApplicationInput) q.getSingleResult();
- ApplicationInputExperimentCatResource inputResource = (ApplicationInputExperimentCatResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
- em.getTransaction().commit();
- em.close();
- return inputResource;
- case APPLICATION_OUTPUT:
- generator = new QueryGenerator(APPLICATION_OUTPUT);
- generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- ApplicationOutput applicationOutput = (ApplicationOutput) q.getSingleResult();
- ApplicationOutputExperimentCatResource outputResource = (ApplicationOutputExperimentCatResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
- em.getTransaction().commit();
- em.close();
- return outputResource;
- case JOB_DETAIL:
- generator = new QueryGenerator(JOB_DETAIL);
- generator.setParameter(JobDetailConstants.JOB_ID, name);
- generator.setParameter(JobDetailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- JobDetail jobDetail = (JobDetail) q.getSingleResult();
- JobDetailExperimentCatResource jobDetailResource = (JobDetailExperimentCatResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
- em.getTransaction().commit();
- em.close();
- return jobDetailResource;
- case DATA_TRANSFER_DETAIL:
- generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
- generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
- q = generator.selectQuery(em);
- DataTransferDetail transferDetail = (DataTransferDetail) q.getSingleResult();
- DataTransferDetailExperimentCatResource transferDetailResource = (DataTransferDetailExperimentCatResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
- em.getTransaction().commit();
- em.close();
- return transferDetailResource;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.TASK_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.TASK.toString());
- q = generator.selectQuery(em);
- Status status = (Status) q.getSingleResult();
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) Utils.getResource(ResourceType.STATUS, status);
- em.getTransaction().commit();
- em.close();
- return statusResource;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
- generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- Computational_Resource_Scheduling resourceScheduling = (Computational_Resource_Scheduling) q.getSingleResult();
- ComputationSchedulingExperimentCatResource schedulingResource = (ComputationSchedulingExperimentCatResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling);
- em.getTransaction().commit();
- em.close();
- return schedulingResource;
- case ADVANCE_INPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
- generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- AdvancedInputDataHandling dataHandling = (AdvancedInputDataHandling) q.getSingleResult();
- AdvanceInputDataHandlingExperimentCatResource inputDataHandlingResource = (AdvanceInputDataHandlingExperimentCatResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, dataHandling);
- em.getTransaction().commit();
- em.close();
- return inputDataHandlingResource;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
- generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
- AdvancedOutputDataHandlingExperimentCatResource outputDataHandlingResource = (AdvancedOutputDataHandlingExperimentCatResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
- em.getTransaction().commit();
- em.close();
- return outputDataHandlingResource;
- case QOS_PARAM:
- generator = new QueryGenerator(QOS_PARAMS);
- generator.setParameter(QosParamsConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- QosParam qosParam = (QosParam) q.getSingleResult();
- QosParamExperimentCatResource qosParamResource = (QosParamExperimentCatResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
- em.getTransaction().commit();
- em.close();
- return qosParamResource;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
- }
- } catch (Exception e) {
-// logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- List results;
- switch (type) {
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ErrorDetail errorDetail = (ErrorDetail) result;
- ErrorDetailExperimentCatResource errorDetailResource =
- (ErrorDetailExperimentCatResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- resourceList.add(errorDetailResource);
- }
- }
- break;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Notification_Email notificationEmail = (Notification_Email) result;
- NotificationEmailExperimentCatResource emailResource =
- (NotificationEmailExperimentCatResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
- resourceList.add(emailResource);
- }
- }
- break;
- case APPLICATION_INPUT:
- generator = new QueryGenerator(APPLICATION_INPUT);
- generator.setParameter(ApplicationInputConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInput applicationInput = (ApplicationInput) result;
- ApplicationInputExperimentCatResource inputResource =
- (ApplicationInputExperimentCatResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
- resourceList.add(inputResource);
- }
- }
- break;
- case APPLICATION_OUTPUT:
- generator = new QueryGenerator(APPLICATION_OUTPUT);
- generator.setParameter(ApplicationOutputConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationOutput applicationOutput = (ApplicationOutput) result;
- ApplicationOutputExperimentCatResource outputResource =
- (ApplicationOutputExperimentCatResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
- resourceList.add(outputResource);
- }
- }
- break;
- case JOB_DETAIL:
- generator = new QueryGenerator(JOB_DETAIL);
- generator.setParameter(JobDetailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- JobDetail jobDetail = (JobDetail) result;
- JobDetailExperimentCatResource jobDetailResource =
- (JobDetailExperimentCatResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
- resourceList.add(jobDetailResource);
- }
- }
- break;
- case DATA_TRANSFER_DETAIL:
- generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
- generator.setParameter(DataTransferDetailConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- DataTransferDetail transferDetail = (DataTransferDetail) result;
- DataTransferDetailExperimentCatResource transferDetailResource =
- (DataTransferDetailExperimentCatResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
- resourceList.add(transferDetailResource);
- }
- }
- break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.TASK_ID, taskId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Status status = (Status) result;
- StatusExperimentCatResource statusResource =
- (StatusExperimentCatResource) 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 = ExpCatResourceUtils.getEntityManager();
- TaskDetail taskDetail = em.find(TaskDetail.class, taskId);
- em.close();
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- if (taskDetail != null) {
- updateTaskDetail(taskDetail, nodeId);
- em.merge(taskDetail);
- } else {
- taskDetail = new TaskDetail();
- updateTaskDetail(taskDetail, nodeId);
- em.persist(taskDetail);
- }
- em.getTransaction().commit();
- } 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();
- }
- }
- }
-
- private void updateTaskDetail(TaskDetail taskDetail, String nodeId) {
- taskDetail.setTaskId(taskId);
- taskDetail.setNodeId(nodeId);
- taskDetail.setCreationTime(creationTime);
- taskDetail.setAppId(applicationId);
- taskDetail.setAppVersion(applicationVersion);
- taskDetail.setAllowNotification(enableEmailNotifications);
- taskDetail.setApplicationDeploymentId(getApplicationDeploymentId());
- }
-
- public List<ApplicationInputExperimentCatResource> getApplicationInputs() {
- return applicationInputs;
- }
-
- public List<ApplicationOutputExperimentCatResource> getApplicationOutputs() {
- return applicationOutputs;
- }
-
- public List<ApplicationInputExperimentCatResource> getApplicationInputs1() throws RegistryException{
- List<ApplicationInputExperimentCatResource> applicationInputResources = new ArrayList<ApplicationInputExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.APPLICATION_INPUT);
- for (ExperimentCatResource resource : resources) {
- ApplicationInputExperimentCatResource inputResource = (ApplicationInputExperimentCatResource) resource;
- applicationInputResources.add(inputResource);
- }
- return applicationInputResources;
- }
-
- public List<ApplicationOutputExperimentCatResource> getApplicationOutputs1() throws RegistryException{
- List<ApplicationOutputExperimentCatResource> outputResources = new ArrayList<ApplicationOutputExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.APPLICATION_OUTPUT);
- for (ExperimentCatResource resource : resources) {
- ApplicationOutputExperimentCatResource outputResource = (ApplicationOutputExperimentCatResource) resource;
- outputResources.add(outputResource);
- }
- return outputResources;
- }
-
- public StatusExperimentCatResource getTaskStatus() {
- return taskStatus;
- }
-
- public StatusExperimentCatResource getTaskStatus1() throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusExperimentCatResource taskStatus = (StatusExperimentCatResource) resource;
- if(taskStatus.getStatusType().equals(StatusType.TASK.toString())){
- if (taskStatus.getState() == null || taskStatus.getState().equals("") ){
- taskStatus.setState("UNKNOWN");
- }
- return taskStatus;
- }
- }
- return null;
- }
-
- public List<JobDetailExperimentCatResource> getJobDetailList() throws RegistryException{
- List<JobDetailExperimentCatResource> jobDetailResources = new ArrayList<JobDetailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.JOB_DETAIL);
- for (ExperimentCatResource resource : resources) {
- JobDetailExperimentCatResource jobDetailResource = (JobDetailExperimentCatResource) resource;
- jobDetailResources.add(jobDetailResource);
- }
- return jobDetailResources;
- }
-
- public List<DataTransferDetailExperimentCatResource> getDataTransferDetailList() throws RegistryException{
- List<DataTransferDetailExperimentCatResource> transferDetails = new ArrayList<DataTransferDetailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.DATA_TRANSFER_DETAIL);
- for (ExperimentCatResource resource : resources) {
- DataTransferDetailExperimentCatResource transferDetailResource = (DataTransferDetailExperimentCatResource) resource;
- transferDetails.add(transferDetailResource);
- }
- return transferDetails;
- }
-
- public List<ErrorDetailExperimentCatResource> getErrorDetailList() throws RegistryException{
- List<ErrorDetailExperimentCatResource> errorDetailResources = new ArrayList<ErrorDetailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
- for (ExperimentCatResource resource : resources) {
- ErrorDetailExperimentCatResource errorDetailResource = (ErrorDetailExperimentCatResource) resource;
- errorDetailResources.add(errorDetailResource);
- }
- return errorDetailResources;
- }
-
- public ComputationSchedulingExperimentCatResource getComputationScheduling (String taskId) throws RegistryException{
- return (ComputationSchedulingExperimentCatResource)get(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, taskId);
- }
-
- public AdvanceInputDataHandlingExperimentCatResource getInputDataHandling (String taskId) throws RegistryException{
- return (AdvanceInputDataHandlingExperimentCatResource)get(ResourceType.ADVANCE_INPUT_DATA_HANDLING, taskId);
- }
-
- public AdvancedOutputDataHandlingExperimentCatResource getOutputDataHandling (String taskId) throws RegistryException{
- return (AdvancedOutputDataHandlingExperimentCatResource)get(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, taskId);
- }
-
- public JobDetailExperimentCatResource createJobDetail (String jobId) throws RegistryException{
- JobDetailExperimentCatResource resource = (JobDetailExperimentCatResource)create(ResourceType.JOB_DETAIL);
- resource.setJobId(jobId);
- return resource;
- }
-
- public JobDetailExperimentCatResource getJobDetail (String jobId) throws RegistryException{
- return (JobDetailExperimentCatResource)get(ResourceType.JOB_DETAIL, jobId);
- }
-
- public DataTransferDetailExperimentCatResource getDataTransferDetail (String dataTransferId) throws RegistryException{
- return (DataTransferDetailExperimentCatResource)get(ResourceType.DATA_TRANSFER_DETAIL, dataTransferId);
- }
-
- public boolean isTaskStatusExist (String taskId) throws RegistryException{
- return isExists(ResourceType.STATUS, taskId);
- }
-
- public String getApplicationDeploymentId() {
- return applicationDeploymentId;
- }
-
- public void setApplicationDeploymentId(String applicationDeploymentId) {
- this.applicationDeploymentId = applicationDeploymentId;
- }
-
- public List<NotificationEmailExperimentCatResource> getNotificationEmails () throws RegistryException{
- List<NotificationEmailExperimentCatResource> emailResources = new ArrayList<NotificationEmailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.NOTIFICATION_EMAIL);
- for (ExperimentCatResource resource : resources) {
- emailResources.add((NotificationEmailExperimentCatResource) resource);
- }
- return emailResources;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskDetailResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskDetailResource.java
new file mode 100644
index 0000000..7dd2ffd
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskDetailResource.java
@@ -0,0 +1,748 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.core.experiment.catalog.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 TaskDetailResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(TaskDetailResource.class);
+ private String taskId;
+ private String nodeId;
+ private Timestamp creationTime;
+ private String applicationId;
+ private String applicationVersion;
+ private String applicationDeploymentId;
+ private boolean enableEmailNotifications;
+ private List<ApplicationInputResource> applicationInputs;
+ private List<ApplicationOutputResource> applicationOutputs;
+ private ComputationSchedulingResource schedulingResource;
+ private AdvanceInputDataHandlingResource inputDataHandlingResource;
+ private AdvancedOutputDataHandlingResource outputDataHandlingResource;
+ private StatusResource taskStatus;
+ private List<JobDetailResource> jobDetailResources;
+ private List<DataTransferDetailResource> transferDetailResourceList;
+ private List<NotificationEmailResource> emailResourceList;
+ private List<ErrorDetailResource> errors;
+
+ public List<JobDetailResource> getJobDetailResources() {
+ return jobDetailResources;
+ }
+
+ public void setJobDetailResources(List<JobDetailResource> jobDetailResources) {
+ this.jobDetailResources = jobDetailResources;
+ }
+
+ public void setApplicationInputs(List<ApplicationInputResource> applicationInputs) {
+ this.applicationInputs = applicationInputs;
+ }
+
+ public void setApplicationOutputs(List<ApplicationOutputResource> applicationOutputs) {
+ this.applicationOutputs = applicationOutputs;
+ }
+
+ public ComputationSchedulingResource getSchedulingResource() {
+ return schedulingResource;
+ }
+
+ public void setSchedulingResource(ComputationSchedulingResource schedulingResource) {
+ this.schedulingResource = schedulingResource;
+ }
+
+ public AdvanceInputDataHandlingResource getInputDataHandlingResource() {
+ return inputDataHandlingResource;
+ }
+
+ public void setInputDataHandlingResource(AdvanceInputDataHandlingResource inputDataHandlingResource) {
+ this.inputDataHandlingResource = inputDataHandlingResource;
+ }
+
+ public AdvancedOutputDataHandlingResource getOutputDataHandlingResource() {
+ return outputDataHandlingResource;
+ }
+
+ public void setOutputDataHandlingResource(AdvancedOutputDataHandlingResource outputDataHandlingResource) {
+ this.outputDataHandlingResource = outputDataHandlingResource;
+ }
+
+ public void setTaskStatus(StatusResource taskStatus) {
+ this.taskStatus = taskStatus;
+ }
+
+ public List<DataTransferDetailResource> getTransferDetailResourceList() {
+ return transferDetailResourceList;
+ }
+
+ public void setTransferDetailResourceList(List<DataTransferDetailResource> transferDetailResourceList) {
+ this.transferDetailResourceList = transferDetailResourceList;
+ }
+
+ public List<NotificationEmailResource> getEmailResourceList() {
+ return emailResourceList;
+ }
+
+ public void setEmailResourceList(List<NotificationEmailResource> emailResourceList) {
+ this.emailResourceList = emailResourceList;
+ }
+
+ public List<ErrorDetailResource> getErrors() {
+ return errors;
+ }
+
+ public void setErrors(List<ErrorDetailResource> errors) {
+ this.errors = errors;
+ }
+
+ public boolean isEnableEmailNotifications() {
+ return enableEmailNotifications;
+ }
+
+ public void setEnableEmailNotifications(boolean enableEmailNotifications) {
+ this.enableEmailNotifications = enableEmailNotifications;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public String getApplicationId() {
+ return applicationId;
+ }
+
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
+ }
+
+ public String getApplicationVersion() {
+ return applicationVersion;
+ }
+
+ public void setApplicationVersion(String applicationVersion) {
+ this.applicationVersion = applicationVersion;
+ }
+
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException{
+ switch (type){
+ case ERROR_DETAIL:
+ ErrorDetailResource errorDetailResource = new ErrorDetailResource();
+ errorDetailResource.setTaskId(taskId);
+ return errorDetailResource;
+ case NOTIFICATION_EMAIL:
+ NotificationEmailResource emailResource = new NotificationEmailResource();
+ emailResource.setTaskId(taskId);
+ return emailResource;
+ case APPLICATION_INPUT:
+ ApplicationInputResource applicationInputResource = new ApplicationInputResource();
+ applicationInputResource.setTaskId(taskId);
+ return applicationInputResource;
+ case APPLICATION_OUTPUT:
+ ApplicationOutputResource applicationOutputResource = new ApplicationOutputResource();
+ applicationOutputResource.setTaskId(taskId);
+ return applicationOutputResource;
+ case JOB_DETAIL:
+ JobDetailResource jobDetailResource = new JobDetailResource();
+ jobDetailResource.setTaskId(taskId);
+ return jobDetailResource;
+ case DATA_TRANSFER_DETAIL:
+ DataTransferDetailResource dataTransferDetailResource = new DataTransferDetailResource();
+ dataTransferDetailResource.setTaskId(taskId);
+ return dataTransferDetailResource;
+ case STATUS:
+ StatusResource statusResource = new StatusResource();
+ statusResource.setTaskId(taskId);
+ return statusResource;
+ case COMPUTATIONAL_RESOURCE_SCHEDULING:
+ ComputationSchedulingResource schedulingResource = new ComputationSchedulingResource();
+ schedulingResource.setTaskId(taskId);
+ return schedulingResource;
+ case ADVANCE_INPUT_DATA_HANDLING:
+ AdvanceInputDataHandlingResource inputDataHandlingResource = new AdvanceInputDataHandlingResource();
+ inputDataHandlingResource.setTaskId(taskId);
+ return inputDataHandlingResource;
+ case ADVANCE_OUTPUT_DATA_HANDLING:
+ AdvancedOutputDataHandlingResource outputDataHandlingResource = new AdvancedOutputDataHandlingResource();
+ outputDataHandlingResource.setTaskId(taskId);
+ return outputDataHandlingResource;
+ case QOS_PARAM:
+ QosParamResource qosParamResource = new QosParamResource();
+ qosParamResource.setTaskId(taskId);
+ return qosParamResource;
+ default:
+ logger.error("Unsupported resource type for task detail resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for task detail resource.");
+ }
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ switch (type) {
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.TASK_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case NOTIFICATION_EMAIL:
+ generator = new QueryGenerator(NOTIFICATION_EMAIL);
+ generator.setParameter(NotificationEmailConstants.TASK_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case APPLICATION_INPUT:
+ generator = new QueryGenerator(APPLICATION_INPUT);
+ generator.setParameter(ApplicationInputConstants.TASK_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case APPLICATION_OUTPUT:
+ generator = new QueryGenerator(APPLICATION_OUTPUT);
+ generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case JOB_DETAIL:
+ generator = new QueryGenerator(JOB_DETAIL);
+ generator.setParameter(JobDetailConstants.TASK_ID, taskId);
+ generator.setParameter(JobDetailConstants.JOB_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case DATA_TRANSFER_DETAIL:
+ generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
+ generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.TASK_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.TASK.toString());
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case COMPUTATIONAL_RESOURCE_SCHEDULING:
+ generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+ generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case ADVANCE_INPUT_DATA_HANDLING:
+ generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+ generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case ADVANCE_OUTPUT_DATA_HANDLING:
+ generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+ generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case QOS_PARAM:
+ generator = new QueryGenerator(QOS_PARAMS);
+ generator.setParameter(QosParamsConstants.TASK_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ default:
+ logger.error("Unsupported resource type for task detail 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator;
+ Query q;
+ switch (type) {
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.TASK_ID, name);
+ q = generator.selectQuery(em);
+ ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
+ ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+ em.getTransaction().commit();
+ em.close();
+ return errorDetailResource;
+ case NOTIFICATION_EMAIL:
+ generator = new QueryGenerator(NOTIFICATION_EMAIL);
+ generator.setParameter(NotificationEmailConstants.TASK_ID, name);
+ q = generator.selectQuery(em);
+ Notification_Email notificationEmail = (Notification_Email) q.getSingleResult();
+ NotificationEmailResource emailResource = (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
+ em.getTransaction().commit();
+ em.close();
+ return emailResource;
+ case APPLICATION_INPUT:
+ generator = new QueryGenerator(APPLICATION_INPUT);
+ generator.setParameter(ApplicationInputConstants.TASK_ID, name);
+ q = generator.selectQuery(em);
+ ApplicationInput applicationInput = (ApplicationInput) q.getSingleResult();
+ ApplicationInputResource inputResource = (ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
+ em.getTransaction().commit();
+ em.close();
+ return inputResource;
+ case APPLICATION_OUTPUT:
+ generator = new QueryGenerator(APPLICATION_OUTPUT);
+ generator.setParameter(ApplicationOutputConstants.TASK_ID, name);
+ q = generator.selectQuery(em);
+ ApplicationOutput applicationOutput = (ApplicationOutput) q.getSingleResult();
+ ApplicationOutputResource outputResource = (ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
+ em.getTransaction().commit();
+ em.close();
+ return outputResource;
+ case JOB_DETAIL:
+ generator = new QueryGenerator(JOB_DETAIL);
+ generator.setParameter(JobDetailConstants.JOB_ID, name);
+ generator.setParameter(JobDetailConstants.TASK_ID, taskId);
+ q = generator.selectQuery(em);
+ JobDetail jobDetail = (JobDetail) q.getSingleResult();
+ JobDetailResource jobDetailResource = (JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
+ em.getTransaction().commit();
+ em.close();
+ return jobDetailResource;
+ case DATA_TRANSFER_DETAIL:
+ generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
+ generator.setParameter(DataTransferDetailConstants.TRANSFER_ID, name);
+ q = generator.selectQuery(em);
+ DataTransferDetail transferDetail = (DataTransferDetail) q.getSingleResult();
+ DataTransferDetailResource transferDetailResource = (DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
+ em.getTransaction().commit();
+ em.close();
+ return transferDetailResource;
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.TASK_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.TASK.toString());
+ q = generator.selectQuery(em);
+ Status status = (Status) q.getSingleResult();
+ StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+ em.getTransaction().commit();
+ em.close();
+ return statusResource;
+ case COMPUTATIONAL_RESOURCE_SCHEDULING:
+ generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
+ generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, name);
+ q = generator.selectQuery(em);
+ Computational_Resource_Scheduling resourceScheduling = (Computational_Resource_Scheduling) q.getSingleResult();
+ ComputationSchedulingResource schedulingResource = (ComputationSchedulingResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, resourceScheduling);
+ em.getTransaction().commit();
+ em.close();
+ return schedulingResource;
+ case ADVANCE_INPUT_DATA_HANDLING:
+ generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
+ generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, name);
+ q = generator.selectQuery(em);
+ AdvancedInputDataHandling dataHandling = (AdvancedInputDataHandling) q.getSingleResult();
+ AdvanceInputDataHandlingResource inputDataHandlingResource = (AdvanceInputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, dataHandling);
+ em.getTransaction().commit();
+ em.close();
+ return inputDataHandlingResource;
+ case ADVANCE_OUTPUT_DATA_HANDLING:
+ generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
+ generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, name);
+ q = generator.selectQuery(em);
+ AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
+ AdvancedOutputDataHandlingResource outputDataHandlingResource = (AdvancedOutputDataHandlingResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
+ em.getTransaction().commit();
+ em.close();
+ return outputDataHandlingResource;
+ case QOS_PARAM:
+ generator = new QueryGenerator(QOS_PARAMS);
+ generator.setParameter(QosParamsConstants.TASK_ID, name);
+ q = generator.selectQuery(em);
+ QosParam qosParam = (QosParam) q.getSingleResult();
+ QosParamResource qosParamResource = (QosParamResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
+ em.getTransaction().commit();
+ em.close();
+ return qosParamResource;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
+ }
+ } catch (Exception e) {
+// logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ List results;
+ switch (type) {
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.TASK_ID, taskId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ErrorDetail errorDetail = (ErrorDetail) result;
+ ErrorDetailResource errorDetailResource =
+ (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+ resourceList.add(errorDetailResource);
+ }
+ }
+ break;
+ case NOTIFICATION_EMAIL:
+ generator = new QueryGenerator(NOTIFICATION_EMAIL);
+ generator.setParameter(NotificationEmailConstants.TASK_ID, taskId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Notification_Email notificationEmail = (Notification_Email) result;
+ NotificationEmailResource emailResource =
+ (NotificationEmailResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
+ resourceList.add(emailResource);
+ }
+ }
+ break;
+ case APPLICATION_INPUT:
+ generator = new QueryGenerator(APPLICATION_INPUT);
+ generator.setParameter(ApplicationInputConstants.TASK_ID, taskId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInput applicationInput = (ApplicationInput) result;
+ ApplicationInputResource inputResource =
+ (ApplicationInputResource) Utils.getResource(ResourceType.APPLICATION_INPUT, applicationInput);
+ resourceList.add(inputResource);
+ }
+ }
+ break;
+ case APPLICATION_OUTPUT:
+ generator = new QueryGenerator(APPLICATION_OUTPUT);
+ generator.setParameter(ApplicationOutputConstants.TASK_ID, taskId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationOutput applicationOutput = (ApplicationOutput) result;
+ ApplicationOutputResource outputResource =
+ (ApplicationOutputResource) Utils.getResource(ResourceType.APPLICATION_OUTPUT, applicationOutput);
+ resourceList.add(outputResource);
+ }
+ }
+ break;
+ case JOB_DETAIL:
+ generator = new QueryGenerator(JOB_DETAIL);
+ generator.setParameter(JobDetailConstants.TASK_ID, taskId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ JobDetail jobDetail = (JobDetail) result;
+ JobDetailResource jobDetailResource =
+ (JobDetailResource) Utils.getResource(ResourceType.JOB_DETAIL, jobDetail);
+ resourceList.add(jobDetailResource);
+ }
+ }
+ break;
+ case DATA_TRANSFER_DETAIL:
+ generator = new QueryGenerator(DATA_TRANSFER_DETAIL);
+ generator.setParameter(DataTransferDetailConstants.TASK_ID, taskId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ DataTransferDetail transferDetail = (DataTransferDetail) result;
+ DataTransferDetailResource transferDetailResource =
+ (DataTransferDetailResource) Utils.getResource(ResourceType.DATA_TRANSFER_DETAIL, transferDetail);
+ resourceList.add(transferDetailResource);
+ }
+ }
+ break;
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.TASK_ID, taskId);
+ 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 = ExpCatResourceUtils.getEntityManager();
+ TaskDetail taskDetail = em.find(TaskDetail.class, taskId);
+ em.close();
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (taskDetail != null) {
+ updateTaskDetail(taskDetail, nodeId);
+ em.merge(taskDetail);
+ } else {
+ taskDetail = new TaskDetail();
+ updateTaskDetail(taskDetail, nodeId);
+ em.persist(taskDetail);
+ }
+ em.getTransaction().commit();
+ } 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();
+ }
+ }
+ }
+
+ private void updateTaskDetail(TaskDetail taskDetail, String nodeId) {
+ taskDetail.setTaskId(taskId);
+ taskDetail.setNodeId(nodeId);
+ taskDetail.setCreationTime(creationTime);
+ taskDetail.setAppId(applicationId);
+ taskDetail.setAppVersion(applicationVersion);
+ taskDetail.setAllowNotification(enableEmailNotifications);
+ taskDetail.setApplicationDeploymentId(getApplicationDeploymentId());
+ }
+
+ public List<ApplicationInputResource> getApplicationInputs() {
+ return applicationInputs;
+ }
+
+ public List<ApplicationOutputResource> getApplicationOutputs() {
+ return applicationOutputs;
+ }
+
+ public List<ApplicationInputResource> getApplicationInputs1() throws RegistryException{
+ List<ApplicationInputResource> applicationInputResources = new ArrayList<ApplicationInputResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.APPLICATION_INPUT);
+ for (ExperimentCatResource resource : resources) {
+ ApplicationInputResource inputResource = (ApplicationInputResource) resource;
+ applicationInputResources.add(inputResource);
+ }
+ return applicationInputResources;
+ }
+
+ public List<ApplicationOutputResource> getApplicationOutputs1() throws RegistryException{
+ List<ApplicationOutputResource> outputResources = new ArrayList<ApplicationOutputResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.APPLICATION_OUTPUT);
+ for (ExperimentCatResource resource : resources) {
+ ApplicationOutputResource outputResource = (ApplicationOutputResource) resource;
+ outputResources.add(outputResource);
+ }
+ return outputResources;
+ }
+
+ public StatusResource getTaskStatus() {
+ return taskStatus;
+ }
+
+ public StatusResource getTaskStatus1() throws RegistryException{
+ List<ExperimentCatResource> resources = get(ResourceType.STATUS);
+ for (ExperimentCatResource resource : resources) {
+ StatusResource taskStatus = (StatusResource) resource;
+ if(taskStatus.getStatusType().equals(StatusType.TASK.toString())){
+ if (taskStatus.getState() == null || taskStatus.getState().equals("") ){
+ taskStatus.setState("UNKNOWN");
+ }
+ return taskStatus;
+ }
+ }
+ return null;
+ }
+
+ public List<JobDetailResource> getJobDetailList() throws RegistryException{
+ List<JobDetailResource> jobDetailResources = new ArrayList<JobDetailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.JOB_DETAIL);
+ for (ExperimentCatResource resource : resources) {
+ JobDetailResource jobDetailResource = (JobDetailResource) resource;
+ jobDetailResources.add(jobDetailResource);
+ }
+ return jobDetailResources;
+ }
+
+ public List<DataTransferDetailResource> getDataTransferDetailList() throws RegistryException{
+ List<DataTransferDetailResource> transferDetails = new ArrayList<DataTransferDetailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.DATA_TRANSFER_DETAIL);
+ for (ExperimentCatResource resource : resources) {
+ DataTransferDetailResource transferDetailResource = (DataTransferDetailResource) resource;
+ transferDetails.add(transferDetailResource);
+ }
+ return transferDetails;
+ }
+
+ public List<ErrorDetailResource> getErrorDetailList() throws RegistryException{
+ List<ErrorDetailResource> errorDetailResources = new ArrayList<ErrorDetailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
+ for (ExperimentCatResource resource : resources) {
+ ErrorDetailResource errorDetailResource = (ErrorDetailResource) resource;
+ errorDetailResources.add(errorDetailResource);
+ }
+ return errorDetailResources;
+ }
+
+ public ComputationSchedulingResource getComputationScheduling (String taskId) throws RegistryException{
+ return (ComputationSchedulingResource)get(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, taskId);
+ }
+
+ public AdvanceInputDataHandlingResource getInputDataHandling (String taskId) throws RegistryException{
+ return (AdvanceInputDataHandlingResource)get(ResourceType.ADVANCE_INPUT_DATA_HANDLING, taskId);
+ }
+
+ public AdvancedOutputDataHandlingResource getOutputDataHandling (String taskId) throws RegistryException{
+ return (AdvancedOutputDataHandlingResource)get(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, taskId);
+ }
+
+ public JobDetailResource createJobDetail (String jobId) throws RegistryException{
+ JobDetailResource resource = (JobDetailResource)create(ResourceType.JOB_DETAIL);
+ resource.setJobId(jobId);
+ return resource;
+ }
+
+ public JobDetailResource getJobDetail (String jobId) throws RegistryException{
+ return (JobDetailResource)get(ResourceType.JOB_DETAIL, jobId);
+ }
+
+ public DataTransferDetailResource getDataTransferDetail (String dataTransferId) throws RegistryException{
+ return (DataTransferDetailResource)get(ResourceType.DATA_TRANSFER_DETAIL, dataTransferId);
+ }
+
+ public boolean isTaskStatusExist (String taskId) throws RegistryException{
+ return isExists(ResourceType.STATUS, taskId);
+ }
+
+ public String getApplicationDeploymentId() {
+ return applicationDeploymentId;
+ }
+
+ public void setApplicationDeploymentId(String applicationDeploymentId) {
+ this.applicationDeploymentId = applicationDeploymentId;
+ }
+
+ public List<NotificationEmailResource> getNotificationEmails () throws RegistryException{
+ List<NotificationEmailResource> emailResources = new ArrayList<NotificationEmailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.NOTIFICATION_EMAIL);
+ for (ExperimentCatResource resource : resources) {
+ emailResources.add((NotificationEmailResource) resource);
+ }
+ return emailResources;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserExperimentCatResource.java
deleted file mode 100644
index 63c0204..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserExperimentCatResource.java
+++ /dev/null
@@ -1,186 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.SecurityUtil;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.Users;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import java.security.NoSuchAlgorithmException;
-import java.util.List;
-
-public class UserExperimentCatResource extends AbstractExperimentCatResource {
- private final static Logger logger = LoggerFactory.getLogger(UserExperimentCatResource.class);
- private String userName;
- private String password;
- /**
- *
- */
- public UserExperimentCatResource() {
- }
-
- /**
- *
- * @param userName user name
- */
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- /**
- *
- * @return user name
- */
- public String getUserName() {
- return userName;
- }
-
-
- /**
- * User is a hypothical data structure.
- * @param type child resource type
- * @return child resource
- */
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- /**
- *
- * @param type child resource type
- * @param name child resource name
- */
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- /**
- *
- * @param type child resource type
- * @param name child resource name
- * @return UnsupportedOperationException
- */
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- /**
- *
- * @param type child resource type
- * @return UnsupportedOperationException
- */
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- /**
- * save user to the database
- */
- public void save() throws RegistryException {
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- Users existingUser = em.find(Users.class, userName);
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Users user = new Users();
- user.setUser_name(userName);
- if (password != null && !password.equals("")) {
- try {
- user.setPassword(SecurityUtil.digestString(password,
- ServerSettings.getSetting("default.registry.password.hash.method")));
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
- } catch (ApplicationSettingsException e) {
- throw new RuntimeException("Error reading hash algorithm from configurations", e);
- }
- }
- if (existingUser != null) {
- if (password != null && !password.equals("")) {
- try {
- existingUser.setPassword(SecurityUtil.digestString(password,
- ServerSettings.getSetting("default.registry.password.hash.method")));
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
- } catch (ApplicationSettingsException e) {
- throw new RuntimeException("Error reading hash algorithm from configurations", e);
- }
- }
- user = em.merge(existingUser);
- } else {
- em.persist(user);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @param type child resource type
- * @param name child resource name
- * @return UnsupportedOperationException
- */
- public boolean isExists(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- /**
- *
- * @return password
- */
- public String getPassword() {
- return password;
- }
-
- /**
- *
- * @param password password
- */
- public void setPassword(String password) {
- this.password = password;
- }
-}
[27/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentAppCatalogResourceAppCat.java
deleted file mode 100644
index 50136de..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,446 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationModule;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-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 AppDeploymentAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(AppDeploymentAppCatalogResourceAppCat.class);
- private String deploymentId;
- private String appModuleId;
- private String hostId;
- private String executablePath;
- private String parallelism;
- private String appDes;
- private String gatewayId;
- private ComputeResourceAppCatalogResourceAppCat hostResource;
- private AppModuleAppCatalogResourceAppCat moduleResource;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- public String getDeploymentId() {
- return deploymentId;
- }
-
- public void setDeploymentId(String deploymentId) {
- this.deploymentId = deploymentId;
- }
-
- public String getAppModuleId() {
- return appModuleId;
- }
-
- public void setAppModuleId(String appModuleId) {
- this.appModuleId = appModuleId;
- }
-
- public String getHostId() {
- return hostId;
- }
-
- public void setHostId(String hostId) {
- this.hostId = hostId;
- }
-
- public String getExecutablePath() {
- return executablePath;
- }
-
- public void setExecutablePath(String executablePath) {
- this.executablePath = executablePath;
- }
-
- public String getAppDes() {
- return appDes;
- }
-
- public void setAppDes(String appDes) {
- this.appDes = appDes;
- }
-
- public ComputeResourceAppCatalogResourceAppCat getHostResource() {
- return hostResource;
- }
-
- public void setHostResource(ComputeResourceAppCatalogResourceAppCat hostResource) {
- this.hostResource = hostResource;
- }
-
- public AppModuleAppCatalogResourceAppCat getModuleResource() {
- return moduleResource;
- }
-
- public void setModuleResource(AppModuleAppCatalogResourceAppCat moduleResource) {
- this.moduleResource = moduleResource;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
- generator.setParameter(ApplicationDeploymentConstants.DEPLOYMENT_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
- generator.setParameter(ApplicationDeploymentConstants.DEPLOYMENT_ID, identifier);
- Query q = generator.selectQuery(em);
- ApplicationDeployment deployment = (ApplicationDeployment) q.getSingleResult();
- AppDeploymentAppCatalogResourceAppCat deploymentResource =
- (AppDeploymentAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
- em.getTransaction().commit();
- em.close();
- return deploymentResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> appDeployments = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
- List results;
- if (fieldName.equals(ApplicationDeploymentConstants.APP_MODULE_ID)) {
- generator.setParameter(ApplicationDeploymentConstants.APP_MODULE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationDeployment deployment = (ApplicationDeployment) result;
- AppDeploymentAppCatalogResourceAppCat deploymentResource =
- (AppDeploymentAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
- appDeployments.add(deploymentResource);
- }
- }
- } else if (fieldName.equals(ApplicationDeploymentConstants.COMPUTE_HOST_ID)) {
- generator.setParameter(ApplicationDeploymentConstants.COMPUTE_HOST_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationDeployment deployment = (ApplicationDeployment) result;
- AppDeploymentAppCatalogResourceAppCat deploymentResource =
- (AppDeploymentAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
- appDeployments.add(deploymentResource);
- }
- }
- }else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for app deployment resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for app deployment resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appDeployments;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- List<AppCatalogResource> appDeployments = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
- generator.setParameter(ApplicationDeploymentConstants.GATEWAY_ID, gatewayId);
- Query q = generator.selectQuery(em);
- List results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationDeployment deployment = (ApplicationDeployment) result;
- AppDeploymentAppCatalogResourceAppCat deploymentResource =
- (AppDeploymentAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
- appDeployments.add(deploymentResource);
- }
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appDeployments;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- List<String> appDeployments = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
- Query q = generator.selectQuery(em);
- List results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationDeployment deployment = (ApplicationDeployment) result;
- appDeployments.add(deployment.getDeploymentID());
- }
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appDeployments;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> appDeployments = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
- List results;
- if (fieldName.equals(ApplicationDeploymentConstants.APP_MODULE_ID)) {
- generator.setParameter(ApplicationDeploymentConstants.APP_MODULE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationDeployment deployment = (ApplicationDeployment) result;
- appDeployments.add(deployment.getDeploymentID());
- }
- }
- } else if (fieldName.equals(ApplicationDeploymentConstants.COMPUTE_HOST_ID)) {
- generator.setParameter(ApplicationDeploymentConstants.COMPUTE_HOST_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationDeployment deployment = (ApplicationDeployment) result;
- appDeployments.add(deployment.getDeploymentID());
- }
- }
- }else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for app deployment resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for app deployment resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appDeployments;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationDeployment existingDeployment = em.find(ApplicationDeployment.class, deploymentId);
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- ApplicationModule applicationModule = em.find(ApplicationModule.class, appModuleId);
- ComputeResource computeHost = em.find(ComputeResource.class, hostId);
- if (existingDeployment != null){
- existingDeployment.setDeploymentID(deploymentId);
- existingDeployment.setApplicationDesc(appDes);
- existingDeployment.setAppModuleID(appModuleId);
- existingDeployment.setApplicationModule(applicationModule);
- existingDeployment.setComputeResource(computeHost);
- existingDeployment.setHostID(hostId);
- existingDeployment.setExecutablePath(executablePath);
- existingDeployment.setParallelism(parallelism);
- existingDeployment.setGatewayId(gatewayId);
- existingDeployment.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- em.merge(existingDeployment);
- }else {
- ApplicationDeployment deployment = new ApplicationDeployment();
- deployment.setApplicationDesc(appDes);
- deployment.setDeploymentID(deploymentId);
- deployment.setAppModuleID(appModuleId);
- deployment.setHostID(hostId);
- deployment.setApplicationModule(applicationModule);
- deployment.setComputeResource(computeHost);
- deployment.setExecutablePath(executablePath);
- deployment.setParallelism(parallelism);
- deployment.setGatewayId(gatewayId);
- deployment.setCreationTime(AiravataUtils.getCurrentTimestamp());
- em.persist(deployment);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
-
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationDeployment deployment = em.find(ApplicationDeployment.class, identifier);
- em.close();
- return deployment != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getParallelism() {
- return parallelism;
- }
-
- public void setParallelism(String parallelism) {
- this.parallelism = parallelism;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentResource.java
new file mode 100644
index 0000000..e1ab857
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppDeploymentResource.java
@@ -0,0 +1,446 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationModule;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+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 AppDeploymentResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(AppDeploymentResource.class);
+ private String deploymentId;
+ private String appModuleId;
+ private String hostId;
+ private String executablePath;
+ private String parallelism;
+ private String appDes;
+ private String gatewayId;
+ private ComputeResourceResource hostResource;
+ private AppModuleResource moduleResource;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public String getDeploymentId() {
+ return deploymentId;
+ }
+
+ public void setDeploymentId(String deploymentId) {
+ this.deploymentId = deploymentId;
+ }
+
+ public String getAppModuleId() {
+ return appModuleId;
+ }
+
+ public void setAppModuleId(String appModuleId) {
+ this.appModuleId = appModuleId;
+ }
+
+ public String getHostId() {
+ return hostId;
+ }
+
+ public void setHostId(String hostId) {
+ this.hostId = hostId;
+ }
+
+ public String getExecutablePath() {
+ return executablePath;
+ }
+
+ public void setExecutablePath(String executablePath) {
+ this.executablePath = executablePath;
+ }
+
+ public String getAppDes() {
+ return appDes;
+ }
+
+ public void setAppDes(String appDes) {
+ this.appDes = appDes;
+ }
+
+ public ComputeResourceResource getHostResource() {
+ return hostResource;
+ }
+
+ public void setHostResource(ComputeResourceResource hostResource) {
+ this.hostResource = hostResource;
+ }
+
+ public AppModuleResource getModuleResource() {
+ return moduleResource;
+ }
+
+ public void setModuleResource(AppModuleResource moduleResource) {
+ this.moduleResource = moduleResource;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
+ generator.setParameter(ApplicationDeploymentConstants.DEPLOYMENT_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
+ generator.setParameter(ApplicationDeploymentConstants.DEPLOYMENT_ID, identifier);
+ Query q = generator.selectQuery(em);
+ ApplicationDeployment deployment = (ApplicationDeployment) q.getSingleResult();
+ AppDeploymentResource deploymentResource =
+ (AppDeploymentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
+ em.getTransaction().commit();
+ em.close();
+ return deploymentResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> appDeployments = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
+ List results;
+ if (fieldName.equals(ApplicationDeploymentConstants.APP_MODULE_ID)) {
+ generator.setParameter(ApplicationDeploymentConstants.APP_MODULE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationDeployment deployment = (ApplicationDeployment) result;
+ AppDeploymentResource deploymentResource =
+ (AppDeploymentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
+ appDeployments.add(deploymentResource);
+ }
+ }
+ } else if (fieldName.equals(ApplicationDeploymentConstants.COMPUTE_HOST_ID)) {
+ generator.setParameter(ApplicationDeploymentConstants.COMPUTE_HOST_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationDeployment deployment = (ApplicationDeployment) result;
+ AppDeploymentResource deploymentResource =
+ (AppDeploymentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
+ appDeployments.add(deploymentResource);
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for app deployment resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for app deployment resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appDeployments;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ List<AppCatalogResource> appDeployments = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
+ generator.setParameter(ApplicationDeploymentConstants.GATEWAY_ID, gatewayId);
+ Query q = generator.selectQuery(em);
+ List results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationDeployment deployment = (ApplicationDeployment) result;
+ AppDeploymentResource deploymentResource =
+ (AppDeploymentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_DEPLOYMENT, deployment);
+ appDeployments.add(deploymentResource);
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appDeployments;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ List<String> appDeployments = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
+ Query q = generator.selectQuery(em);
+ List results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationDeployment deployment = (ApplicationDeployment) result;
+ appDeployments.add(deployment.getDeploymentID());
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appDeployments;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> appDeployments = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_DEPLOYMENT);
+ List results;
+ if (fieldName.equals(ApplicationDeploymentConstants.APP_MODULE_ID)) {
+ generator.setParameter(ApplicationDeploymentConstants.APP_MODULE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationDeployment deployment = (ApplicationDeployment) result;
+ appDeployments.add(deployment.getDeploymentID());
+ }
+ }
+ } else if (fieldName.equals(ApplicationDeploymentConstants.COMPUTE_HOST_ID)) {
+ generator.setParameter(ApplicationDeploymentConstants.COMPUTE_HOST_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationDeployment deployment = (ApplicationDeployment) result;
+ appDeployments.add(deployment.getDeploymentID());
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for app deployment resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for app deployment resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appDeployments;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationDeployment existingDeployment = em.find(ApplicationDeployment.class, deploymentId);
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ ApplicationModule applicationModule = em.find(ApplicationModule.class, appModuleId);
+ ComputeResource computeHost = em.find(ComputeResource.class, hostId);
+ if (existingDeployment != null){
+ existingDeployment.setDeploymentID(deploymentId);
+ existingDeployment.setApplicationDesc(appDes);
+ existingDeployment.setAppModuleID(appModuleId);
+ existingDeployment.setApplicationModule(applicationModule);
+ existingDeployment.setComputeResource(computeHost);
+ existingDeployment.setHostID(hostId);
+ existingDeployment.setExecutablePath(executablePath);
+ existingDeployment.setParallelism(parallelism);
+ existingDeployment.setGatewayId(gatewayId);
+ existingDeployment.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ em.merge(existingDeployment);
+ }else {
+ ApplicationDeployment deployment = new ApplicationDeployment();
+ deployment.setApplicationDesc(appDes);
+ deployment.setDeploymentID(deploymentId);
+ deployment.setAppModuleID(appModuleId);
+ deployment.setHostID(hostId);
+ deployment.setApplicationModule(applicationModule);
+ deployment.setComputeResource(computeHost);
+ deployment.setExecutablePath(executablePath);
+ deployment.setParallelism(parallelism);
+ deployment.setGatewayId(gatewayId);
+ deployment.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ em.persist(deployment);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationDeployment deployment = em.find(ApplicationDeployment.class, identifier);
+ em.close();
+ return deployment != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getParallelism() {
+ return parallelism;
+ }
+
+ public void setParallelism(String parallelism) {
+ this.parallelism = parallelism;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentAppCatalogResourceAppCat.java
deleted file mode 100644
index c81cd8a..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,293 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.AppEnvironment;
-import org.apache.airavata.registry.core.app.catalog.model.AppEnvironment_PK;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class AppEnvironmentAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(AppEnvironmentAppCatalogResourceAppCat.class);
- private String deploymentId;
- private String name;
- private String value;
- private AppDeploymentAppCatalogResourceAppCat appDeploymentResource;
-
- public String getDeploymentId() {
- return deploymentId;
- }
-
- public void setDeploymentId(String deploymentId) {
- this.deploymentId = deploymentId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public AppDeploymentAppCatalogResourceAppCat getAppDeploymentResource() {
- return appDeploymentResource;
- }
-
- public void setAppDeploymentResource(AppDeploymentAppCatalogResourceAppCat appDeploymentResource) {
- this.appDeploymentResource = appDeploymentResource;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APP_ENVIRONMENT);
- generator.setParameter(AppEnvironmentConstants.DEPLOYMENT_ID, ids.get(AppEnvironmentConstants.DEPLOYMENT_ID));
- if (ids.get(AppEnvironmentConstants.NAME) != null){
- generator.setParameter(AppEnvironmentConstants.NAME, ids.get(AppEnvironmentConstants.NAME));
- }
-
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_ENVIRONMENT);
- generator.setParameter(AppEnvironmentConstants.DEPLOYMENT_ID, ids.get(AppEnvironmentConstants.DEPLOYMENT_ID));
- generator.setParameter(AppEnvironmentConstants.NAME, ids.get(AppEnvironmentConstants.NAME));
- Query q = generator.selectQuery(em);
- AppEnvironment appEnvironment = (AppEnvironment) q.getSingleResult();
- AppEnvironmentAppCatalogResourceAppCat resource =
- (AppEnvironmentAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_ENVIRONMENT, appEnvironment);
- em.getTransaction().commit();
- em.close();
- return resource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> appEnvironmentList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_ENVIRONMENT);
- List results;
- if (fieldName.equals(AppEnvironmentConstants.DEPLOYMENT_ID)) {
- generator.setParameter(AppEnvironmentConstants.DEPLOYMENT_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- AppEnvironment appEnvironment = (AppEnvironment) result;
- AppEnvironmentAppCatalogResourceAppCat resource =
- (AppEnvironmentAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_ENVIRONMENT, appEnvironment);
- appEnvironmentList.add(resource);
- }
- }
- } else if (fieldName.equals(AppEnvironmentConstants.NAME)) {
- generator.setParameter(AppEnvironmentConstants.NAME, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- AppEnvironment appEnvironment = (AppEnvironment) result;
- AppEnvironmentAppCatalogResourceAppCat resource =
- (AppEnvironmentAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_ENVIRONMENT, appEnvironment);
- appEnvironmentList.add(resource);
- }
- }
- }else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for App Environment resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for App Environment resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appEnvironmentList;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- logger.error("Unsupported for objects with a composite identifier");
- throw new AppCatalogException("Unsupported for objects with a composite identifier");
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- AppEnvironment existigAppEnv = em.find(AppEnvironment.class, new AppEnvironment_PK(deploymentId, name));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
-
- ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId);
- if (existigAppEnv != null){
- existigAppEnv.setValue(value);
- existigAppEnv.setApplicationDeployment(deployment);
- em.merge(existigAppEnv);
- }else {
- AppEnvironment appEnvironment = new AppEnvironment();
- appEnvironment.setDeploymentID(deploymentId);
- appEnvironment.setName(name);
- appEnvironment.setValue(value);
- appEnvironment.setApplicationDeployment(deployment);
- em.persist(appEnvironment);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- AppEnvironment appEnvironment = em.find(AppEnvironment.class,
- new AppEnvironment_PK(ids.get(AppEnvironmentConstants.DEPLOYMENT_ID),
- ids.get(AppEnvironmentConstants.NAME)));
- em.close();
- return appEnvironment != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
new file mode 100644
index 0000000..ba4975a
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
@@ -0,0 +1,293 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.AppEnvironment;
+import org.apache.airavata.registry.core.app.catalog.model.AppEnvironment_PK;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AppEnvironmentResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(AppEnvironmentResource.class);
+ private String deploymentId;
+ private String name;
+ private String value;
+ private AppDeploymentResource appDeploymentResource;
+
+ public String getDeploymentId() {
+ return deploymentId;
+ }
+
+ public void setDeploymentId(String deploymentId) {
+ this.deploymentId = deploymentId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public AppDeploymentResource getAppDeploymentResource() {
+ return appDeploymentResource;
+ }
+
+ public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) {
+ this.appDeploymentResource = appDeploymentResource;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APP_ENVIRONMENT);
+ generator.setParameter(AppEnvironmentConstants.DEPLOYMENT_ID, ids.get(AppEnvironmentConstants.DEPLOYMENT_ID));
+ if (ids.get(AppEnvironmentConstants.NAME) != null){
+ generator.setParameter(AppEnvironmentConstants.NAME, ids.get(AppEnvironmentConstants.NAME));
+ }
+
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_ENVIRONMENT);
+ generator.setParameter(AppEnvironmentConstants.DEPLOYMENT_ID, ids.get(AppEnvironmentConstants.DEPLOYMENT_ID));
+ generator.setParameter(AppEnvironmentConstants.NAME, ids.get(AppEnvironmentConstants.NAME));
+ Query q = generator.selectQuery(em);
+ AppEnvironment appEnvironment = (AppEnvironment) q.getSingleResult();
+ AppEnvironmentResource resource =
+ (AppEnvironmentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_ENVIRONMENT, appEnvironment);
+ em.getTransaction().commit();
+ em.close();
+ return resource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> appEnvironmentList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_ENVIRONMENT);
+ List results;
+ if (fieldName.equals(AppEnvironmentConstants.DEPLOYMENT_ID)) {
+ generator.setParameter(AppEnvironmentConstants.DEPLOYMENT_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ AppEnvironment appEnvironment = (AppEnvironment) result;
+ AppEnvironmentResource resource =
+ (AppEnvironmentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_ENVIRONMENT, appEnvironment);
+ appEnvironmentList.add(resource);
+ }
+ }
+ } else if (fieldName.equals(AppEnvironmentConstants.NAME)) {
+ generator.setParameter(AppEnvironmentConstants.NAME, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ AppEnvironment appEnvironment = (AppEnvironment) result;
+ AppEnvironmentResource resource =
+ (AppEnvironmentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_ENVIRONMENT, appEnvironment);
+ appEnvironmentList.add(resource);
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for App Environment resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for App Environment resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appEnvironmentList;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ logger.error("Unsupported for objects with a composite identifier");
+ throw new AppCatalogException("Unsupported for objects with a composite identifier");
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ AppEnvironment existigAppEnv = em.find(AppEnvironment.class, new AppEnvironment_PK(deploymentId, name));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+
+ ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId);
+ if (existigAppEnv != null){
+ existigAppEnv.setValue(value);
+ existigAppEnv.setApplicationDeployment(deployment);
+ em.merge(existigAppEnv);
+ }else {
+ AppEnvironment appEnvironment = new AppEnvironment();
+ appEnvironment.setDeploymentID(deploymentId);
+ appEnvironment.setName(name);
+ appEnvironment.setValue(value);
+ appEnvironment.setApplicationDeployment(deployment);
+ em.persist(appEnvironment);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ AppEnvironment appEnvironment = em.find(AppEnvironment.class,
+ new AppEnvironment_PK(ids.get(AppEnvironmentConstants.DEPLOYMENT_ID),
+ ids.get(AppEnvironmentConstants.NAME)));
+ em.close();
+ return appEnvironment != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceAppCatalogResourceAppCat.java
deleted file mode 100644
index 6e972e8..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,363 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-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 AppInterfaceAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(AppInterfaceAppCatalogResourceAppCat.class);
- private String interfaceId;
- private String appName;
- private String appDescription;
- private Timestamp createdTime;
- private Timestamp updatedTime;
- private String gatewayId;
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- public String getInterfaceId() {
- return interfaceId;
- }
-
- public void setInterfaceId(String interfaceId) {
- this.interfaceId = interfaceId;
- }
-
- public String getAppName() {
- return appName;
- }
-
- public void setAppName(String appName) {
- this.appName = appName;
- }
-
- public String getAppDescription() {
- return appDescription;
- }
-
- public void setAppDescription(String appDescription) {
- this.appDescription = appDescription;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
- generator.setParameter(ApplicationInterfaceConstants.INTERFACE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
- generator.setParameter(ApplicationInterfaceConstants.INTERFACE_ID, identifier);
- Query q = generator.selectQuery(em);
- ApplicationInterface applicationInterface = (ApplicationInterface) q.getSingleResult();
- AppInterfaceAppCatalogResourceAppCat resource =
- (AppInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INTERFACE, applicationInterface);
- em.getTransaction().commit();
- em.close();
- return resource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> resourceList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
- List results;
- if (fieldName.equals(ApplicationInterfaceConstants.APPLICATION_NAME)) {
- generator.setParameter(ApplicationInterfaceConstants.APPLICATION_NAME, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInterface appInterface = (ApplicationInterface) result;
- AppInterfaceAppCatalogResourceAppCat resource =
- (AppInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INTERFACE, appInterface);
- resourceList.add(resource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for application interface.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for application interface.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- List<AppCatalogResource> resourceList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
- generator.setParameter(ApplicationInterfaceConstants.GATEWAY_ID, gatewayId);
- Query q = generator.selectQuery(em);
- List results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInterface appInterface = (ApplicationInterface) result;
- AppInterfaceAppCatalogResourceAppCat resource =
- (AppInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INTERFACE, appInterface);
- resourceList.add(resource);
- }
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- List<String> resourceList = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
- Query q = generator.selectQuery(em);
- List results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInterface appInterface = (ApplicationInterface) result;
- resourceList.add(appInterface.getInterfaceID());
- }
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> resourceList = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
- List results;
- if (fieldName.equals(ApplicationInterfaceConstants.APPLICATION_NAME)) {
- generator.setParameter(ApplicationInterfaceConstants.APPLICATION_NAME, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInterface appInterface = (ApplicationInterface) result;
- resourceList.add(appInterface.getInterfaceID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for application interface.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for application interface.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return resourceList;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationInterface existigAppInterface = em.find(ApplicationInterface.class, interfaceId);
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existigAppInterface != null){
- existigAppInterface.setAppName(appName);
- existigAppInterface.setAppDescription(appDescription);
- existigAppInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- existigAppInterface.setGatewayId(gatewayId);
- em.merge(existigAppInterface);
- }else {
- ApplicationInterface applicationInterface = new ApplicationInterface();
- applicationInterface.setInterfaceID(interfaceId);
- applicationInterface.setAppName(appName);
- applicationInterface.setAppDescription(appDescription);
- applicationInterface.setCreationTime(AiravataUtils.getCurrentTimestamp());
- applicationInterface.setGatewayId(gatewayId);
- em.persist(applicationInterface);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationInterface existigAppInterface = em.find(ApplicationInterface.class, identifier);
- em.close();
- return existigAppInterface != null;
- }catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
[04/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserResource.java
new file mode 100644
index 0000000..a0927cb
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserResource.java
@@ -0,0 +1,186 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.SecurityUtil;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.Users;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import java.security.NoSuchAlgorithmException;
+import java.util.List;
+
+public class UserResource extends AbstractExpCatResource {
+ private final static Logger logger = LoggerFactory.getLogger(UserResource.class);
+ private String userName;
+ private String password;
+ /**
+ *
+ */
+ public UserResource() {
+ }
+
+ /**
+ *
+ * @param userName user name
+ */
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ /**
+ *
+ * @return user name
+ */
+ public String getUserName() {
+ return userName;
+ }
+
+
+ /**
+ * User is a hypothical data structure.
+ * @param type child resource type
+ * @return child resource
+ */
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @param name child resource name
+ */
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @param name child resource name
+ * @return UnsupportedOperationException
+ */
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @return UnsupportedOperationException
+ */
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * save user to the database
+ */
+ public void save() throws RegistryException {
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ Users existingUser = em.find(Users.class, userName);
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Users user = new Users();
+ user.setUser_name(userName);
+ if (password != null && !password.equals("")) {
+ try {
+ user.setPassword(SecurityUtil.digestString(password,
+ ServerSettings.getSetting("default.registry.password.hash.method")));
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
+ } catch (ApplicationSettingsException e) {
+ throw new RuntimeException("Error reading hash algorithm from configurations", e);
+ }
+ }
+ if (existingUser != null) {
+ if (password != null && !password.equals("")) {
+ try {
+ existingUser.setPassword(SecurityUtil.digestString(password,
+ ServerSettings.getSetting("default.registry.password.hash.method")));
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
+ } catch (ApplicationSettingsException e) {
+ throw new RuntimeException("Error reading hash algorithm from configurations", e);
+ }
+ }
+ user = em.merge(existingUser);
+ } else {
+ em.persist(user);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @param name child resource name
+ * @return UnsupportedOperationException
+ */
+ public boolean isExists(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for user resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ * @return password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ *
+ * @param password password
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java
index 6164b12..bc8377c 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/Utils.java
@@ -361,7 +361,7 @@ public class Utils {
* @return GatewayResource object
*/
private static ExperimentCatResource createGateway(Gateway o) {
- GatewayExperimentCatResource gatewayResource = new GatewayExperimentCatResource();
+ GatewayResource gatewayResource = new GatewayResource();
gatewayResource.setGatewayName(o.getGateway_name());
gatewayResource.setGatewayId(o.getGateway_id());
gatewayResource.setDomain(o.getDomain());
@@ -375,7 +375,7 @@ public class Utils {
* @return ProjectResource object
*/
private static ExperimentCatResource createProject(Project o) {
- ProjectExperimentCatResource projectResource = new ProjectExperimentCatResource();
+ ProjectResource projectResource = new ProjectResource();
if (o != null){
projectResource.setId(o.getProject_id());
projectResource.setName(o.getProject_name());
@@ -384,7 +384,7 @@ public class Utils {
gateway_worker.setGateway(o.getGateway());
gateway_worker.setUser(o.getUsers());
gateway_worker.setUser_name(o.getUsers().getUser_name());
- WorkerExperimentCatResource workerResource = (WorkerExperimentCatResource) createGatewayWorker(gateway_worker);
+ WorkerResource workerResource = (WorkerResource) createGatewayWorker(gateway_worker);
projectResource.setWorker(workerResource);
projectResource.setDescription(o.getDescription());
projectResource.setCreationTime(o.getCreationTime());
@@ -394,7 +394,7 @@ public class Utils {
}
private static ExperimentCatResource createProjectUser(ProjectUser o) {
- ProjectUserExperimentCatResource projectUserResource = new ProjectUserExperimentCatResource();
+ ProjectUserResource projectUserResource = new ProjectUserResource();
if (o != null){
projectUserResource.setUserName(o.getUser().getUser_name());
projectUserResource.setProjectId(o.getProjectID());
@@ -408,7 +408,7 @@ public class Utils {
* @return configuration resource object
*/
private static ExperimentCatResource createConfiguration (Configuration o){
- ConfigurationExperimentCatResource configurationResource = new ConfigurationExperimentCatResource();
+ ConfigurationResource configurationResource = new ConfigurationResource();
if (o != null){
configurationResource.setConfigKey(o.getConfig_key());
configurationResource.setConfigVal(o.getConfig_val());
@@ -426,7 +426,7 @@ public class Utils {
*/
private static ExperimentCatResource createGatewayWorker(Gateway_Worker o) {
if (o != null){
- WorkerExperimentCatResource workerResource = new WorkerExperimentCatResource();
+ WorkerResource workerResource = new WorkerResource();
workerResource.setGatewayId(o.getGateway_id());
workerResource.setUser(o.getUser_name());
return workerResource;
@@ -440,7 +440,7 @@ public class Utils {
* @return UserResource object
*/
private static ExperimentCatResource createUser(Users o) {
- UserExperimentCatResource userResource = new UserExperimentCatResource();
+ UserResource userResource = new UserResource();
if (o != null){
userResource.setUserName(o.getUser_name());
userResource.setPassword(o.getPassword());
@@ -454,7 +454,7 @@ public class Utils {
* @return Experiment resource object
*/
private static ExperimentCatResource createExperiment(Experiment o) {
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
+ ExperimentResource experimentResource = new ExperimentResource();
if (o != null){
experimentResource.setGatewayId(o.getGatewayId());
experimentResource.setExecutionUser(o.getExecutionUser());
@@ -477,10 +477,10 @@ public class Utils {
experimentResource.setExperimentOutputputResources(getExperimentOutputs(o.getExperimentOutputs()));
}
if (o.getResourceScheduling() != null){
- experimentResource.setComputationSchedulingResource((ComputationSchedulingExperimentCatResource)createComputationalScheduling(o.getResourceScheduling()));
+ experimentResource.setComputationSchedulingResource((ComputationSchedulingResource)createComputationalScheduling(o.getResourceScheduling()));
}
if (o.getUserConfigurationData() != null){
- experimentResource.setUserConfigDataResource((ConfigDataExperimentCatResource)createExConfigDataResource(o.getUserConfigurationData()));
+ experimentResource.setUserConfigDataResource((ConfigDataResource)createExConfigDataResource(o.getUserConfigurationData()));
}
if (o.getWorkflowNodeDetails() != null && !o.getWorkflowNodeDetails().isEmpty()){
@@ -496,7 +496,7 @@ public class Utils {
}
if (o.getExperimentStatus() != null){
- experimentResource.setExperimentStatus((StatusExperimentCatResource)createStatusResource(o.getExperimentStatus()));
+ experimentResource.setExperimentStatus((StatusResource)createStatusResource(o.getExperimentStatus()));
}
if (o.getNotificationEmails() != null && !o.getNotificationEmails().isEmpty()){
@@ -512,7 +512,7 @@ public class Utils {
* @return ExperimentSummary Resource object
*/
private static ExperimentCatResource createExperimentSummary(Experiment o) {
- ExperimentSummaryExperimentCatResource experimentSummaryResource = new ExperimentSummaryExperimentCatResource();
+ ExperimentSummaryResource experimentSummaryResource = new ExperimentSummaryResource();
if (o != null){
experimentSummaryResource.setExecutionUser(o.getExecutionUser());
experimentSummaryResource.setExpID(o.getExpId());
@@ -524,7 +524,7 @@ public class Utils {
Status experimentStatus = o.getExperimentStatus();
if(experimentStatus != null) {
- StatusExperimentCatResource statusResource = new StatusExperimentCatResource();
+ StatusResource statusResource = new StatusResource();
statusResource.setStatusId(experimentStatus.getStatusId());
statusResource.setJobId(experimentStatus.getJobId());
statusResource.setState(experimentStatus.getState());
@@ -537,104 +537,104 @@ public class Utils {
return experimentSummaryResource;
}
- private static List<ExperimentInputExperimentCatResource> getExperimentInputs(List<Experiment_Input> inputs){
- List<ExperimentInputExperimentCatResource> inputResources = new ArrayList<ExperimentInputExperimentCatResource>();
+ private static List<ExperimentInputResource> getExperimentInputs(List<Experiment_Input> inputs){
+ List<ExperimentInputResource> inputResources = new ArrayList<ExperimentInputResource>();
for (Experiment_Input input : inputs){
- inputResources.add((ExperimentInputExperimentCatResource)createExperimentInput(input));
+ inputResources.add((ExperimentInputResource)createExperimentInput(input));
}
return inputResources;
}
- private static List<ExperimentOutputExperimentCatResource> getExperimentOutputs(List<Experiment_Output> outputs){
- List<ExperimentOutputExperimentCatResource> outputResources = new ArrayList<>();
+ private static List<ExperimentOutputResource> getExperimentOutputs(List<Experiment_Output> outputs){
+ List<ExperimentOutputResource> outputResources = new ArrayList<>();
for (Experiment_Output output : outputs){
- outputResources.add((ExperimentOutputExperimentCatResource) createExperimentOutput(output));
+ outputResources.add((ExperimentOutputResource) createExperimentOutput(output));
}
return outputResources;
}
- private static List<NodeInputExperimentCatResource> getNodeInputs(List<NodeInput> inputs){
- List<NodeInputExperimentCatResource> inputResources = new ArrayList<NodeInputExperimentCatResource>();
+ private static List<NodeInputResource> getNodeInputs(List<NodeInput> inputs){
+ List<NodeInputResource> inputResources = new ArrayList<NodeInputResource>();
for (NodeInput input : inputs){
- inputResources.add((NodeInputExperimentCatResource)createNodeInput(input));
+ inputResources.add((NodeInputResource)createNodeInput(input));
}
return inputResources;
}
- private static List<NodeOutputExperimentCatResource> getNodeOutputs(List<NodeOutput> outputs){
- List<NodeOutputExperimentCatResource> outputResources = new ArrayList<>();
+ private static List<NodeOutputResource> getNodeOutputs(List<NodeOutput> outputs){
+ List<NodeOutputResource> outputResources = new ArrayList<>();
for (NodeOutput output : outputs){
- outputResources.add((NodeOutputExperimentCatResource) createNodeOutput(output));
+ outputResources.add((NodeOutputResource) createNodeOutput(output));
}
return outputResources;
}
- private static List<ApplicationInputExperimentCatResource> getApplicationInputs(List<ApplicationInput> inputs){
- List<ApplicationInputExperimentCatResource> inputResources = new ArrayList<ApplicationInputExperimentCatResource>();
+ private static List<ApplicationInputResource> getApplicationInputs(List<ApplicationInput> inputs){
+ List<ApplicationInputResource> inputResources = new ArrayList<ApplicationInputResource>();
for (ApplicationInput input : inputs){
- inputResources.add((ApplicationInputExperimentCatResource)createApplicationInput(input));
+ inputResources.add((ApplicationInputResource)createApplicationInput(input));
}
return inputResources;
}
- private static List<ApplicationOutputExperimentCatResource> getApplicationOutputs(List<ApplicationOutput> outputs){
- List<ApplicationOutputExperimentCatResource> outputResources = new ArrayList<>();
+ private static List<ApplicationOutputResource> getApplicationOutputs(List<ApplicationOutput> outputs){
+ List<ApplicationOutputResource> outputResources = new ArrayList<>();
for (ApplicationOutput output : outputs){
- outputResources.add((ApplicationOutputExperimentCatResource) createApplicationOutput(output));
+ outputResources.add((ApplicationOutputResource) createApplicationOutput(output));
}
return outputResources;
}
- private static List<WorkflowNodeDetailExperimentCatResource> getWorkflowNodeLit(List<WorkflowNodeDetail> nodes){
- List<WorkflowNodeDetailExperimentCatResource> nodeList = new ArrayList<>();
+ private static List<WorkflowNodeDetailResource> getWorkflowNodeLit(List<WorkflowNodeDetail> nodes){
+ List<WorkflowNodeDetailResource> nodeList = new ArrayList<>();
for (WorkflowNodeDetail node : nodes){
- nodeList.add((WorkflowNodeDetailExperimentCatResource) createWorkflowNodeDetail(node));
+ nodeList.add((WorkflowNodeDetailResource) createWorkflowNodeDetail(node));
}
return nodeList;
}
- private static List<StatusExperimentCatResource> getStateChangeList(List<Status> statusList){
- List<StatusExperimentCatResource> changeList = new ArrayList<>();
+ private static List<StatusResource> getStateChangeList(List<Status> statusList){
+ List<StatusResource> changeList = new ArrayList<>();
for (Status status : statusList){
- changeList.add((StatusExperimentCatResource) createStatusResource(status));
+ changeList.add((StatusResource) createStatusResource(status));
}
return changeList;
}
- private static List<ErrorDetailExperimentCatResource> getErrorList(List<ErrorDetail> errorDetails){
- List<ErrorDetailExperimentCatResource> errors = new ArrayList<>();
+ private static List<ErrorDetailResource> getErrorList(List<ErrorDetail> errorDetails){
+ List<ErrorDetailResource> errors = new ArrayList<>();
for (ErrorDetail error : errorDetails){
- errors.add((ErrorDetailExperimentCatResource) createErrorDetail(error));
+ errors.add((ErrorDetailResource) createErrorDetail(error));
}
return errors;
}
- private static List<JobDetailExperimentCatResource> getJobDetails(List<JobDetail> jobDetails){
- List<JobDetailExperimentCatResource> resources = new ArrayList<>();
+ private static List<JobDetailResource> getJobDetails(List<JobDetail> jobDetails){
+ List<JobDetailResource> resources = new ArrayList<>();
for (JobDetail jobDetail : jobDetails){
- resources.add((JobDetailExperimentCatResource) createJobDetail(jobDetail));
+ resources.add((JobDetailResource) createJobDetail(jobDetail));
}
return resources;
}
- private static List<DataTransferDetailExperimentCatResource> getDTDetails(List<DataTransferDetail> dataTransferDetails){
- List<DataTransferDetailExperimentCatResource> resources = new ArrayList<>();
+ private static List<DataTransferDetailResource> getDTDetails(List<DataTransferDetail> dataTransferDetails){
+ List<DataTransferDetailResource> resources = new ArrayList<>();
for (DataTransferDetail detail : dataTransferDetails){
- resources.add((DataTransferDetailExperimentCatResource) createDataTransferResource(detail));
+ resources.add((DataTransferDetailResource) createDataTransferResource(detail));
}
return resources;
}
- private static List<NotificationEmailExperimentCatResource> getEmailList(List<Notification_Email> emails){
- List<NotificationEmailExperimentCatResource> emailResources = new ArrayList<>();
+ private static List<NotificationEmailResource> getEmailList(List<Notification_Email> emails){
+ List<NotificationEmailResource> emailResources = new ArrayList<>();
for (Notification_Email email : emails){
- emailResources.add((NotificationEmailExperimentCatResource) createNotificationEmail(email));
+ emailResources.add((NotificationEmailResource) createNotificationEmail(email));
}
return emailResources;
}
private static ExperimentCatResource createNotificationEmail (Notification_Email o){
- NotificationEmailExperimentCatResource emailResource = new NotificationEmailExperimentCatResource();
+ NotificationEmailResource emailResource = new NotificationEmailResource();
if (o != null){
emailResource.setExperimentId(o.getExperiment_id());
emailResource.setTaskId(o.getTaskId());
@@ -644,7 +644,7 @@ public class Utils {
}
private static ExperimentCatResource createExperimentInput (Experiment_Input o){
- ExperimentInputExperimentCatResource eInputResource = new ExperimentInputExperimentCatResource();
+ ExperimentInputResource eInputResource = new ExperimentInputResource();
if (o != null){
eInputResource.setExperimentId(o.getExperiment_id());
eInputResource.setDataType(o.getDataType());
@@ -665,7 +665,7 @@ public class Utils {
}
private static ExperimentCatResource createExperimentOutput (Experiment_Output o){
- ExperimentOutputExperimentCatResource eOutputResource = new ExperimentOutputExperimentCatResource();
+ ExperimentOutputResource eOutputResource = new ExperimentOutputResource();
if (o != null){
eOutputResource.setExperimentId(o.getExperiment_id());
eOutputResource.setExperimentKey(o.getEx_key());
@@ -684,7 +684,7 @@ public class Utils {
}
private static ExperimentCatResource createWorkflowNodeDetail (WorkflowNodeDetail o){
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = new WorkflowNodeDetailExperimentCatResource();
+ WorkflowNodeDetailResource nodeDetailResource = new WorkflowNodeDetailResource();
if (o != null){
nodeDetailResource.setExperimentId(o.getExpId());
nodeDetailResource.setCreationTime(o.getCreationTime());
@@ -705,7 +705,7 @@ public class Utils {
}
if (o.getNodeStatus() != null){
- nodeDetailResource.setNodeStatus((StatusExperimentCatResource) createStatusResource(o.getNodeStatus()));
+ nodeDetailResource.setNodeStatus((StatusResource) createStatusResource(o.getNodeStatus()));
}
if (o.getErrorDetails() != null && !o.getErrorDetails().isEmpty()){
@@ -715,16 +715,16 @@ public class Utils {
return nodeDetailResource;
}
- private static List<TaskDetailExperimentCatResource> getTaskDetails (List<TaskDetail> taskDetails){
- List<TaskDetailExperimentCatResource> tasks = new ArrayList<>();
+ private static List<TaskDetailResource> getTaskDetails (List<TaskDetail> taskDetails){
+ List<TaskDetailResource> tasks = new ArrayList<>();
for (TaskDetail detail : taskDetails){
- tasks.add((TaskDetailExperimentCatResource) createTaskDetail(detail));
+ tasks.add((TaskDetailResource) createTaskDetail(detail));
}
return tasks;
}
private static ExperimentCatResource createTaskDetail(TaskDetail o){
- TaskDetailExperimentCatResource taskDetailResource = new TaskDetailExperimentCatResource();
+ TaskDetailResource taskDetailResource = new TaskDetailResource();
if ( o != null){
taskDetailResource.setNodeId(o.getNodeId());
taskDetailResource.setCreationTime(o.getCreationTime());
@@ -740,20 +740,20 @@ public class Utils {
taskDetailResource.setApplicationOutputs(getApplicationOutputs(o.getApplicationOutputs()));
}
if (o.getResourceScheduling() != null){
- taskDetailResource.setSchedulingResource((ComputationSchedulingExperimentCatResource) createComputationalScheduling(o.getResourceScheduling()));
+ taskDetailResource.setSchedulingResource((ComputationSchedulingResource) createComputationalScheduling(o.getResourceScheduling()));
}
if (o.getInputDataHandling() != null){
- taskDetailResource.setInputDataHandlingResource((AdvanceInputDataHandlingExperimentCatResource) createAdvancedInputDataResource(o.getInputDataHandling()));
+ taskDetailResource.setInputDataHandlingResource((AdvanceInputDataHandlingResource) createAdvancedInputDataResource(o.getInputDataHandling()));
}
if (o.getOutputDataHandling() != null){
- taskDetailResource.setOutputDataHandlingResource((AdvancedOutputDataHandlingExperimentCatResource) createAdvancedOutputDataResource(o.getOutputDataHandling()));
+ taskDetailResource.setOutputDataHandlingResource((AdvancedOutputDataHandlingResource) createAdvancedOutputDataResource(o.getOutputDataHandling()));
}
if (o.getErrorDetails() != null && !o.getErrorDetails().isEmpty()){
taskDetailResource.setErrors(getErrorList(o.getErrorDetails()));
}
if (o.getTaskStatus() != null){
- taskDetailResource.setTaskStatus((StatusExperimentCatResource) createStatusResource(o.getTaskStatus()));
+ taskDetailResource.setTaskStatus((StatusResource) createStatusResource(o.getTaskStatus()));
}
if (o.getNotificationEmails() != null && !o.getNotificationEmails().isEmpty()){
taskDetailResource.setEmailResourceList(getEmailList(o.getNotificationEmails()));
@@ -770,7 +770,7 @@ public class Utils {
}
private static ExperimentCatResource createErrorDetail (ErrorDetail o){
- ErrorDetailExperimentCatResource errorDetailResource = new ErrorDetailExperimentCatResource();
+ ErrorDetailResource errorDetailResource = new ErrorDetailResource();
if (o != null){
errorDetailResource.setExperimentId(o.getExpId());
errorDetailResource.setTaskId(o.getTaskId());
@@ -792,7 +792,7 @@ public class Utils {
}
private static ExperimentCatResource createApplicationInput (ApplicationInput o){
- ApplicationInputExperimentCatResource inputResource = new ApplicationInputExperimentCatResource();
+ ApplicationInputResource inputResource = new ApplicationInputResource();
if (o != null){
inputResource.setTaskId(o.getTaskId());
inputResource.setInputKey(o.getInputKey());
@@ -813,7 +813,7 @@ public class Utils {
}
private static ExperimentCatResource createApplicationOutput (ApplicationOutput o){
- ApplicationOutputExperimentCatResource outputResource = new ApplicationOutputExperimentCatResource();
+ ApplicationOutputResource outputResource = new ApplicationOutputResource();
if (o != null){
outputResource.setTaskId(o.getTaskId());
outputResource.setDataType(o.getDataType());
@@ -832,7 +832,7 @@ public class Utils {
}
private static ExperimentCatResource createNodeInput (NodeInput o){
- NodeInputExperimentCatResource inputResource = new NodeInputExperimentCatResource();
+ NodeInputResource inputResource = new NodeInputResource();
if (o != null){
inputResource.setNodeId(o.getNodeId());
inputResource.setInputKey(o.getInputKey());
@@ -851,7 +851,7 @@ public class Utils {
}
private static ExperimentCatResource createNodeOutput (NodeOutput o){
- NodeOutputExperimentCatResource outputResource = new NodeOutputExperimentCatResource();
+ NodeOutputResource outputResource = new NodeOutputResource();
if (o != null){
outputResource.setNodeId(o.getNodeId());
outputResource.setDataType(o.getDataType());
@@ -869,7 +869,7 @@ public class Utils {
}
private static ExperimentCatResource createJobDetail (JobDetail o){
- JobDetailExperimentCatResource jobDetailResource = new JobDetailExperimentCatResource();
+ JobDetailResource jobDetailResource = new JobDetailResource();
if (o != null){
jobDetailResource.setTaskId(o.getTaskId());
if (o.getJobDescription() != null){
@@ -880,7 +880,7 @@ public class Utils {
jobDetailResource.setComputeResourceConsumed(o.getComputeResourceConsumed());
jobDetailResource.setJobName(o.getJobName());
jobDetailResource.setWorkingDir(o.getWorkingDir());
- jobDetailResource.setJobStatus((StatusExperimentCatResource)createStatusResource(o.getJobStatus()));
+ jobDetailResource.setJobStatus((StatusResource)createStatusResource(o.getJobStatus()));
jobDetailResource.setErrors(getErrorList(o.getErrorDetails()));
}
@@ -888,7 +888,7 @@ public class Utils {
}
private static ExperimentCatResource createDataTransferResource (DataTransferDetail o){
- DataTransferDetailExperimentCatResource transferDetailResource = new DataTransferDetailExperimentCatResource();
+ DataTransferDetailResource transferDetailResource = new DataTransferDetailResource();
if (o != null){
transferDetailResource.setTaskId(o.getTaskId());
transferDetailResource.setTransferId(o.getTransferId());
@@ -897,14 +897,14 @@ public class Utils {
transferDetailResource.setTransferDescription(new String(o.getTransferDesc()));
}
if (o.getDataTransferStatus() != null){
- transferDetailResource.setDatatransferStatus((StatusExperimentCatResource)createStatusResource(o.getDataTransferStatus()));
+ transferDetailResource.setDatatransferStatus((StatusResource)createStatusResource(o.getDataTransferStatus()));
}
}
return transferDetailResource;
}
private static ExperimentCatResource createStatusResource (Status o){
- StatusExperimentCatResource statusResource = new StatusExperimentCatResource();
+ StatusResource statusResource = new StatusResource();
if (o != null){
statusResource.setExperimentId(o.getExpId());
statusResource.setTaskId(o.getTaskId());
@@ -921,7 +921,7 @@ public class Utils {
}
private static ExperimentCatResource createExConfigDataResource (ExperimentConfigData o){
- ConfigDataExperimentCatResource configDataResource = new ConfigDataExperimentCatResource();
+ ConfigDataResource configDataResource = new ConfigDataResource();
if (o != null){
configDataResource.setExperimentId(o.getExpId());
configDataResource.setAiravataAutoSchedule(o.isAiravataAutoSchedule());
@@ -930,16 +930,16 @@ public class Utils {
configDataResource.setUserDn(o.getUserDn());
configDataResource.setGenerateCert(o.isGenerateCert());
if (o.getOutputDataHandling() != null){
- configDataResource.setAdvancedOutputDataHandlingResource((AdvancedOutputDataHandlingExperimentCatResource) createAdvancedOutputDataResource(o.getOutputDataHandling()));
+ configDataResource.setAdvancedOutputDataHandlingResource((AdvancedOutputDataHandlingResource) createAdvancedOutputDataResource(o.getOutputDataHandling()));
}
if (o.getInputDataHandling() != null){
- configDataResource.setAdvanceInputDataHandlingResource((AdvanceInputDataHandlingExperimentCatResource) createAdvancedInputDataResource(o.getInputDataHandling()));
+ configDataResource.setAdvanceInputDataHandlingResource((AdvanceInputDataHandlingResource) createAdvancedInputDataResource(o.getInputDataHandling()));
}
if (o.getResourceScheduling() != null){
- configDataResource.setComputationSchedulingResource((ComputationSchedulingExperimentCatResource) createComputationalScheduling(o.getResourceScheduling()));
+ configDataResource.setComputationSchedulingResource((ComputationSchedulingResource) createComputationalScheduling(o.getResourceScheduling()));
}
if (o.getQosParam() != null){
- configDataResource.setQosParamResource((QosParamExperimentCatResource) createQosParamResource(o.getQosParam()));
+ configDataResource.setQosParamResource((QosParamResource) createQosParamResource(o.getQosParam()));
}
}
@@ -947,7 +947,7 @@ public class Utils {
}
private static ExperimentCatResource createComputationalScheduling (Computational_Resource_Scheduling o){
- ComputationSchedulingExperimentCatResource schedulingResource = new ComputationSchedulingExperimentCatResource();
+ ComputationSchedulingResource schedulingResource = new ComputationSchedulingResource();
if (o != null){
schedulingResource.setExperimentId(o.getExpId());
schedulingResource.setTaskId(o.getTaskId());
@@ -968,7 +968,7 @@ public class Utils {
}
private static ExperimentCatResource createAdvancedInputDataResource (AdvancedInputDataHandling o){
- AdvanceInputDataHandlingExperimentCatResource dataHandlingResource = new AdvanceInputDataHandlingExperimentCatResource();
+ AdvanceInputDataHandlingResource dataHandlingResource = new AdvanceInputDataHandlingResource();
if (o != null){
dataHandlingResource.setExperimentId(o.getExpId());
dataHandlingResource.setTaskId(o.getTaskId());
@@ -983,7 +983,7 @@ public class Utils {
}
private static ExperimentCatResource createAdvancedOutputDataResource (AdvancedOutputDataHandling o){
- AdvancedOutputDataHandlingExperimentCatResource dataHandlingResource = new AdvancedOutputDataHandlingExperimentCatResource();
+ AdvancedOutputDataHandlingResource dataHandlingResource = new AdvancedOutputDataHandlingResource();
if (o != null){
dataHandlingResource.setExperimentId(o.getExpId());
dataHandlingResource.setTaskId(o.getTaskId());
@@ -996,7 +996,7 @@ public class Utils {
}
private static ExperimentCatResource createQosParamResource (QosParam o){
- QosParamExperimentCatResource qosParamResource = new QosParamExperimentCatResource();
+ QosParamResource qosParamResource = new QosParamResource();
if (o != null){
qosParamResource.setExperimentId(o.getExpId());
qosParamResource.setTaskId(o.getTaskId());
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerExperimentCatResource.java
deleted file mode 100644
index 91dc631..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerExperimentCatResource.java
+++ /dev/null
@@ -1,725 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.model.workspace.experiment.ExperimentState;
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.apache.airavata.registry.cpi.ResultOrderType;
-import org.apache.airavata.registry.cpi.utils.Constants;
-import org.apache.airavata.registry.cpi.utils.StatusType;
-import org.apache.openjpa.persistence.OpenJPAPersistence;
-import org.apache.openjpa.persistence.OpenJPAQuery;
-import org.apache.openjpa.persistence.jdbc.FetchMode;
-import org.apache.openjpa.persistence.jdbc.JDBCFetchPlan;
-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;
-import java.util.Map;
-import java.util.UUID;
-
-public class WorkerExperimentCatResource extends AbstractExperimentCatResource {
- private final static Logger logger = LoggerFactory.getLogger(WorkerExperimentCatResource.class);
- private String user;
- private String gatewayId;
-
- public WorkerExperimentCatResource() {
- }
-
- public WorkerExperimentCatResource(String user, String gatewayId) {
- this.user = user;
- this.gatewayId = gatewayId;
- }
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- /**
- * Gateway worker can create child data structures such as projects and user workflows
- * @param type child resource type
- * @return child resource
- */
- public ExperimentCatResource create(ResourceType type) throws RegistryException{
- ExperimentCatResource result = null;
- switch (type) {
- case PROJECT:
- ProjectExperimentCatResource projectResource = new ProjectExperimentCatResource();
- projectResource.setWorker(this);
- projectResource.setGatewayId(gatewayId);
- result=projectResource;
- break;
- case EXPERIMENT:
- ExperimentExperimentCatResource experimentResource = new ExperimentExperimentCatResource();
- experimentResource.setExecutionUser(user);
- experimentResource.setGatewayId(gatewayId);
- result = experimentResource;
- break;
- default:
- logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for worker resource.");
-
- }
- return result;
- }
-
- /**
- *
- * @param type child resource type
- * @param name child resource name
- */
- public void remove(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- switch (type) {
- case PROJECT:
- generator = new QueryGenerator(PROJECT);
- generator.setParameter(ProjectConstants.PROJECT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case EXPERIMENT:
- generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- default:
- logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
- break;
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e.getMessage());
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @param type child resource type
- * @param name child resource name
- * @return child resource
- */
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- ExperimentCatResource result = null;
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator;
- Query q;
- switch (type) {
- case PROJECT:
- generator = new QueryGenerator(PROJECT);
- generator.setParameter(ProjectConstants.PROJECT_ID, name);
- q = generator.selectQuery(em);
- Project project = (Project) q.getSingleResult();
- result = Utils.getResource(ResourceType.PROJECT, project);
- break;
- case EXPERIMENT:
- generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- Experiment experiment = (Experiment) q.getSingleResult();
- result = Utils.getResource(ResourceType.EXPERIMENT, experiment);
- break;
- default:
- logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
- break;
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return result;
- }
-
-// public List<GFacJobDataResource> getGFacJobs(String serviceDescriptionId, String hostDescriptionId, String applicationDescriptionId){
-// List<GFacJobDataResource> result = new ArrayList<GFacJobDataResource>();
-// EntityManager em = ResourceUtils.getEntityManager();
-// em.getTransaction().begin();
-// QueryGenerator generator;
-// Query q;
-// generator = new QueryGenerator(GFAC_JOB_DATA);
-// generator.setParameter(GFacJobDataConstants.SERVICE_DESC_ID, serviceDescriptionId);
-// generator.setParameter(GFacJobDataConstants.HOST_DESC_ID, hostDescriptionId);
-// generator.setParameter(GFacJobDataConstants.APP_DESC_ID, applicationDescriptionId);
-// q = generator.selectQuery(em);
-// for (Object o : q.getResultList()) {
-// GFac_Job_Data gFacJobData = (GFac_Job_Data)o;
-// result.add((GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA, gFacJobData));
-// }
-// em.getTransaction().commit();
-// em.close();
-// return result;
-// }
-//
-// public List<GFacJobStatusResource> getGFacJobStatuses(String jobId){
-// List<GFacJobStatusResource> resourceList = new ArrayList<GFacJobStatusResource>();
-// EntityManager em = ResourceUtils.getEntityManager();
-// em.getTransaction().begin();
-// QueryGenerator generator;
-// Query q;
-// generator = new QueryGenerator(GFAC_JOB_STATUS);
-// generator.setParameter(GFacJobStatusConstants.LOCAL_JOB_ID, jobId);
-// q = generator.selectQuery(em);
-// for (Object result : q.getResultList()) {
-// GFac_Job_Status gFacJobStatus = (GFac_Job_Status) result;
-// GFacJobStatusResource gFacJobStatusResource =
-// (GFacJobStatusResource)Utils.getResource(ResourceType.GFAC_JOB_STATUS, gFacJobStatus);
-// resourceList.add(gFacJobStatusResource);
-// }
-// return resourceList;
-// }
-
- /**
- * Method get all results of the given child resource type
- *
- * @param type child resource type
- * @return list of child resources
- */
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- return get(type, -1, -1, null, null);
- }
-
- /**
- * Method get all results of the given child resource type with paginaltion and ordering
- *
- * @param type child resource type
- * @param limit
- * @param offset
- * @param orderByIdentifier
- * @param resultOrderType
- * @return list of child resources
- * @throws RegistryException
- */
- public List<ExperimentCatResource> get(ResourceType type, int limit, int offset, Object orderByIdentifier,
- ResultOrderType resultOrderType) throws RegistryException{
- List<ExperimentCatResource> result = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator;
- Query q;
- switch (type) {
- case PROJECT:
- generator = new QueryGenerator(PROJECT);
- Users users = em.find(Users.class, getUser());
- Gateway gatewayModel = em.find(Gateway.class, gatewayId);
- generator.setParameter("users", users);
- if (gatewayModel != null){
- generator.setParameter("gateway", gatewayModel);
- }
-
- //ordering - only supported only by CREATION_TIME
- if(orderByIdentifier != null && resultOrderType != null
- && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
- q = generator.selectQuery(em, ProjectConstants.CREATION_TIME, resultOrderType);
- }else{
- q = generator.selectQuery(em);
- }
-
- //pagination
- if(limit>0 && offset>=0){
- q.setFirstResult(offset);
- q.setMaxResults(limit);
- }
-
- for (Object o : q.getResultList()) {
- Project project = (Project) o;
- ProjectExperimentCatResource projectResource = (ProjectExperimentCatResource) Utils.getResource(ResourceType.PROJECT, project);
- result.add(projectResource);
- }
- break;
- case EXPERIMENT:
- generator = new QueryGenerator(EXPERIMENT);
- generator.setParameter(ExperimentConstants.EXECUTION_USER, getUser());
-
- //ordering - only supported only by CREATION_TIME
- if(orderByIdentifier != null && resultOrderType != null
- && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
- q = generator.selectQuery(em, ExperimentConstants.CREATION_TIME, resultOrderType);
- }else{
- q = generator.selectQuery(em);
- }
-
- //pagination
- if(limit>0 && offset>=0){
- q.setFirstResult(offset);
- q.setMaxResults(limit);
- }
- for (Object o : q.getResultList()) {
- Experiment experiment = (Experiment) o;
- ExperimentExperimentCatResource experimentResource = (ExperimentExperimentCatResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
- result.add(experimentResource);
- }
-
- break;
- default:
- logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
- break;
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return result;
- }
-
- /**
- * save gateway worker to database
- */
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayId, user));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Gateway_Worker gatewayWorker = new Gateway_Worker();
- Users existingUser = em.find(Users.class, this.user);
- gatewayWorker.setUser(existingUser);
- gatewayWorker.setUser_name(existingUser.getUser_name());
- gatewayWorker.setGateway_id(gatewayId);
- if (existingWorker != null) {
- existingWorker.setUser_name(existingUser.getUser_name());
- existingWorker.setUser(existingUser);
- existingWorker.setGateway_id(gatewayId);
- gatewayWorker = em.merge(existingWorker);
- } else {
- em.persist(gatewayWorker);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @return user name
- */
- public String getUser() {
- return user;
- }
-
- /**
- *
- * @param user user name
- */
- public void setUser(String user) {
- this.user = user;
- }
-
- /**
- *
- * @param id project id
- * @return whether the project is available under the user
- */
- public boolean isProjectExists(String id) throws RegistryException{
- return isExists(ResourceType.PROJECT, id);
- }
-
- /**
- *
- * @param projectId project id
- * @return project resource for the user
- */
- public ProjectExperimentCatResource createProject(String projectId) throws RegistryException{
- ProjectExperimentCatResource project=(ProjectExperimentCatResource)create(ResourceType.PROJECT);
- project.setId(projectId);
- return project;
- }
-
- public String getProjectID(String projectName) {
- String pro = projectName.replaceAll("\\s", "");
- return pro + "_" + UUID.randomUUID();
- }
-
- /**
- *
- * @param id project id
- * @return project resource
- */
- public ProjectExperimentCatResource getProject(String id) throws RegistryException{
- return (ProjectExperimentCatResource)get(ResourceType.PROJECT, id);
- }
-
- /**
- *
- * @param id project id
- */
- public void removeProject(String id) throws RegistryException{
- remove(ResourceType.PROJECT, id);
- }
-
- /**
- * Get projects list of user
- * @return list of projects for the user
- */
- public List<ProjectExperimentCatResource> getProjects() throws RegistryException{
- return getProjects(-1, -1, null, null);
- }
-
-
- /**
- * Get projects list of user with pagination and ordering
- *
- * @return list of projects for the user
- */
- public List<ProjectExperimentCatResource> getProjects(int limit, int offset, Object orderByIdentifier,
- ResultOrderType resultOrderType) throws RegistryException{
- List<ProjectExperimentCatResource> result=new ArrayList<ProjectExperimentCatResource>();
- List<ExperimentCatResource> list = get(ResourceType.PROJECT, limit, offset, orderByIdentifier, resultOrderType);
- for (ExperimentCatResource resource : list) {
- result.add((ProjectExperimentCatResource) resource);
- }
- return result;
- }
-
- /**
- *
- * @param name experiment name
- * @return whether experiment is already exist for the given user
- */
- public boolean isExperimentExists(String name) throws RegistryException{
- return isExists(ResourceType.EXPERIMENT, name);
- }
-
-
- /**
- *
- * @param name experiment name
- * @return experiment resource
- */
- public ExperimentExperimentCatResource getExperiment(String name) throws RegistryException{
- return (ExperimentExperimentCatResource)get(ResourceType.EXPERIMENT, name);
- }
-//
-// public GFacJobDataResource getGFacJob(String jobId){
-// return (GFacJobDataResource)get(ResourceType.GFAC_JOB_DATA,jobId);
-// }
-
- /**
- * Method to get list of expeirments of user
- * @return list of experiments for the user
- */
- public List<ExperimentExperimentCatResource> getExperiments() throws RegistryException{
- return getExperiments(-1, -1, null, null);
- }
-
- /**
- * Method to get list of experiments of user with pagination and ordering
- * @param limit
- * @param offset
- * @param orderByIdentifier
- * @param resultOrderType
- * @return
- * @throws RegistryException
- */
- public List<ExperimentExperimentCatResource> getExperiments(int limit, int offset, Object orderByIdentifier,
- ResultOrderType resultOrderType) throws RegistryException{
- List<ExperimentExperimentCatResource> result=new ArrayList<ExperimentExperimentCatResource>();
- List<ExperimentCatResource> list = get(ResourceType.EXPERIMENT, limit, offset, orderByIdentifier, resultOrderType);
- for (ExperimentCatResource resource : list) {
- result.add((ExperimentExperimentCatResource) resource);
- }
- return result;
- }
-
- /**
- *
- * @param experimentId experiment name
- */
- public void removeExperiment(String experimentId) throws RegistryException{
- remove(ResourceType.EXPERIMENT, experimentId);
- }
-
- /**
- * To search the projects of user with the given filter criteria and retrieve the results with
- * pagination support. Results can be ordered based on an identifier (i.e column) either ASC or
- * DESC. But in the current implementation ordering is only supported based on the project
- * creation time
- *
- * @param filters
- * @param limit
- * @param offset
- * @param orderByIdentifier
- * @param resultOrderType
- * @return
- * @throws RegistryException
- */
- public List<ProjectExperimentCatResource> searchProjects(Map<String, String> filters, int limit,
- int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
- List<ProjectExperimentCatResource> result = new ArrayList<ProjectExperimentCatResource>();
- EntityManager em = null;
- try {
- String query = "SELECT p from Project p WHERE ";
- if (filters != null && filters.size() != 0) {
- for (String field : filters.keySet()) {
- String filterVal = filters.get(field);
- if (field.equals(ProjectConstants.USERNAME)) {
- query += "p." + field + "= '" + filterVal + "' AND ";
- }else if (field.equals(ProjectConstants.GATEWAY_ID)) {
- query += "p." + field + "= '" + filterVal + "' AND ";
- }else {
- if (filterVal.contains("*")){
- filterVal = filterVal.replaceAll("\\*", "");
- }
- query += "p." + field + " LIKE '%" + filterVal + "%' AND ";
- }
- }
- }
- query = query.substring(0, query.length() - 5);
-
- //ordering
- if( orderByIdentifier != null && resultOrderType != null
- && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)){
- String order = (resultOrderType == ResultOrderType.ASC) ? "ASC" : "DESC";
- query += " ORDER BY p." + ProjectConstants.CREATION_TIME + " " + order;
- }
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
-
- //pagination
- if(offset>=0 && limit >=0){
- q = em.createQuery(query).setFirstResult(offset).setMaxResults(limit);
- }else{
- q = em.createQuery(query);
- }
-
- List resultList = q.getResultList();
- for (Object o : resultList) {
- Project project = (Project) o;
- ProjectExperimentCatResource projectResource =
- (ProjectExperimentCatResource) Utils.getResource(ResourceType.PROJECT, project);
- result.add(projectResource);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return result;
- }
-
- /**
- * To search the experiments of user with the given time period and filter criteria and retrieve the results with
- * pagination support. Results can be ordered based on an identifier (i.e column) either ASC or
- * DESC. But in the current implementation ordering is only supported based on creationTime. Also if
- * time period values i.e fromTime and toTime are null they will be ignored.
- *
- * @param fromTime
- * @param toTime
- * @param filters
- * @param limit
- * @param offset
- * @param orderByIdentifier
- * @param resultOrderType
- * @return
- * @throws RegistryException
- */
- public List<ExperimentSummaryExperimentCatResource> searchExperiments(Timestamp fromTime, Timestamp toTime, Map<String, String> filters, int limit,
- int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
- List<ExperimentSummaryExperimentCatResource> result = new ArrayList();
- EntityManager em = null;
- try {
- String query = "SELECT e, s FROM Experiment e " +
- ",Status s WHERE e.expId=s.expId AND " +
- "s.statusType='" + StatusType.EXPERIMENT + "' AND ";
- if(filters.get(StatusConstants.STATE) != null) {
- String experimentState = ExperimentState.valueOf(filters.get(StatusConstants.STATE)).toString();
- query += "s.state='" + experimentState + "' AND ";
- }
-
- if(toTime != null && fromTime != null && toTime.after(fromTime)){
- query += "e.creationTime > '" + fromTime + "' " + "AND e.creationTime <'" + toTime + "' AND ";
- }
-
- filters.remove(StatusConstants.STATE);
- if (filters != null && filters.size() != 0) {
- for (String field : filters.keySet()) {
- String filterVal = filters.get(field);
- if (field.equals(ExperimentConstants.EXECUTION_USER)) {
- query += "e." + field + "= '" + filterVal + "' AND ";
- }else if (field.equals(ExperimentConstants.GATEWAY_ID)) {
- query += "e." + field + "= '" + filterVal + "' AND ";
- } else if (field.equals(ExperimentConstants.PROJECT_ID)) {
- query += "e." + field + "= '" + filterVal + "' AND ";
- } else {
- if (filterVal.contains("*")){
- filterVal = filterVal.replaceAll("\\*", "");
- }
- query += "e." + field + " LIKE '%" + filterVal + "%' AND ";
- }
- }
- }
- query = query.substring(0, query.length() - 5);
-
- //ordering
- if( orderByIdentifier != null && resultOrderType != null
- && orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)){
- String order = (resultOrderType == ResultOrderType.ASC) ? "ASC" : "DESC";
- query += " ORDER BY e." + ExperimentConstants.CREATION_TIME + " " + order;
- }
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
-
- //pagination
- if(offset>=0 && limit >=0){
- q = em.createQuery(query).setFirstResult(offset).setMaxResults(limit);
- }else{
- q = em.createQuery(query);
- }
- OpenJPAQuery kq = OpenJPAPersistence.cast(q);
- JDBCFetchPlan fetch = (JDBCFetchPlan) kq.getFetchPlan();
- fetch.setEagerFetchMode(FetchMode.JOIN);
-
- List resultList = q.getResultList();
- for (Object o : resultList) {
- Experiment experiment = (Experiment) ((Object[])o)[0];
- Status experimentStatus = (Status) ((Object[])o)[1];
- experiment.setExperimentStatus(experimentStatus);
- ExperimentSummaryExperimentCatResource experimentSummaryResource =
- (ExperimentSummaryExperimentCatResource) Utils.getResource(ResourceType.EXPERIMENT_SUMMARY, experiment);
- result.add(experimentSummaryResource);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return result;
- }
-
- /**
- *
- * @return list of experiments for the user
- */
- public List<ExperimentExperimentCatResource> getExperimentsByCaching(String user) throws RegistryException{
- List<ExperimentExperimentCatResource> result = new ArrayList<ExperimentExperimentCatResource>();
- EntityManager em = null;
- try {
- String query = "SELECT e from Experiment e WHERE e.executionUser = '" + user + "'";
- em = ExpCatResourceUtils.getEntityManager();
-// OpenJPAEntityManagerFactory oemf = OpenJPAPersistence.cast(em.getEntityManagerFactory());
-// QueryResultCache qcache = oemf.getQueryResultCache();
- // qcache.evictAll(Experiment.class);
- em.getTransaction().begin();
- Query q = em.createQuery(query);
- List resultList = q.getResultList();
- for (Object o : resultList) {
- Experiment experiment = (Experiment) o;
- ExperimentExperimentCatResource experimentResource = (ExperimentExperimentCatResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
- result.add(experimentResource);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return result;
- }
-}
[03/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerResource.java
new file mode 100644
index 0000000..80bfe8e
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerResource.java
@@ -0,0 +1,725 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.model.workspace.experiment.ExperimentState;
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.ResultOrderType;
+import org.apache.airavata.registry.cpi.utils.Constants;
+import org.apache.airavata.registry.cpi.utils.StatusType;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+import org.apache.openjpa.persistence.jdbc.FetchMode;
+import org.apache.openjpa.persistence.jdbc.JDBCFetchPlan;
+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;
+import java.util.Map;
+import java.util.UUID;
+
+public class WorkerResource extends AbstractExpCatResource {
+ private final static Logger logger = LoggerFactory.getLogger(WorkerResource.class);
+ private String user;
+ private String gatewayId;
+
+ public WorkerResource() {
+ }
+
+ public WorkerResource(String user, String gatewayId) {
+ this.user = user;
+ this.gatewayId = gatewayId;
+ }
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ /**
+ * Gateway worker can create child data structures such as projects and user workflows
+ * @param type child resource type
+ * @return child resource
+ */
+ public ExperimentCatResource create(ResourceType type) throws RegistryException{
+ ExperimentCatResource result = null;
+ switch (type) {
+ case PROJECT:
+ ProjectResource projectResource = new ProjectResource();
+ projectResource.setWorker(this);
+ projectResource.setGatewayId(gatewayId);
+ result=projectResource;
+ break;
+ case EXPERIMENT:
+ ExperimentResource experimentResource = new ExperimentResource();
+ experimentResource.setExecutionUser(user);
+ experimentResource.setGatewayId(gatewayId);
+ result = experimentResource;
+ break;
+ default:
+ logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for worker resource.");
+
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @param name child resource name
+ */
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ switch (type) {
+ case PROJECT:
+ generator = new QueryGenerator(PROJECT);
+ generator.setParameter(ProjectConstants.PROJECT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case EXPERIMENT:
+ generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ default:
+ logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
+ break;
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e.getMessage());
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param type child resource type
+ * @param name child resource name
+ * @return child resource
+ */
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ ExperimentCatResource result = null;
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator;
+ Query q;
+ switch (type) {
+ case PROJECT:
+ generator = new QueryGenerator(PROJECT);
+ generator.setParameter(ProjectConstants.PROJECT_ID, name);
+ q = generator.selectQuery(em);
+ Project project = (Project) q.getSingleResult();
+ result = Utils.getResource(ResourceType.PROJECT, project);
+ break;
+ case EXPERIMENT:
+ generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+ q = generator.selectQuery(em);
+ Experiment experiment = (Experiment) q.getSingleResult();
+ result = Utils.getResource(ResourceType.EXPERIMENT, experiment);
+ break;
+ default:
+ logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
+ break;
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return result;
+ }
+
+// public List<GFacJobDataResource> getGFacJobs(String serviceDescriptionId, String hostDescriptionId, String applicationDescriptionId){
+// List<GFacJobDataResource> result = new ArrayList<GFacJobDataResource>();
+// EntityManager em = ResourceUtils.getEntityManager();
+// em.getTransaction().begin();
+// QueryGenerator generator;
+// Query q;
+// generator = new QueryGenerator(GFAC_JOB_DATA);
+// generator.setParameter(GFacJobDataConstants.SERVICE_DESC_ID, serviceDescriptionId);
+// generator.setParameter(GFacJobDataConstants.HOST_DESC_ID, hostDescriptionId);
+// generator.setParameter(GFacJobDataConstants.APP_DESC_ID, applicationDescriptionId);
+// q = generator.selectQuery(em);
+// for (Object o : q.getResultList()) {
+// GFac_Job_Data gFacJobData = (GFac_Job_Data)o;
+// result.add((GFacJobDataResource)Utils.getResource(ResourceType.GFAC_JOB_DATA, gFacJobData));
+// }
+// em.getTransaction().commit();
+// em.close();
+// return result;
+// }
+//
+// public List<GFacJobStatusResource> getGFacJobStatuses(String jobId){
+// List<GFacJobStatusResource> resourceList = new ArrayList<GFacJobStatusResource>();
+// EntityManager em = ResourceUtils.getEntityManager();
+// em.getTransaction().begin();
+// QueryGenerator generator;
+// Query q;
+// generator = new QueryGenerator(GFAC_JOB_STATUS);
+// generator.setParameter(GFacJobStatusConstants.LOCAL_JOB_ID, jobId);
+// q = generator.selectQuery(em);
+// for (Object result : q.getResultList()) {
+// GFac_Job_Status gFacJobStatus = (GFac_Job_Status) result;
+// GFacJobStatusResource gFacJobStatusResource =
+// (GFacJobStatusResource)Utils.getResource(ResourceType.GFAC_JOB_STATUS, gFacJobStatus);
+// resourceList.add(gFacJobStatusResource);
+// }
+// return resourceList;
+// }
+
+ /**
+ * Method get all results of the given child resource type
+ *
+ * @param type child resource type
+ * @return list of child resources
+ */
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ return get(type, -1, -1, null, null);
+ }
+
+ /**
+ * Method get all results of the given child resource type with paginaltion and ordering
+ *
+ * @param type child resource type
+ * @param limit
+ * @param offset
+ * @param orderByIdentifier
+ * @param resultOrderType
+ * @return list of child resources
+ * @throws RegistryException
+ */
+ public List<ExperimentCatResource> get(ResourceType type, int limit, int offset, Object orderByIdentifier,
+ ResultOrderType resultOrderType) throws RegistryException{
+ List<ExperimentCatResource> result = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator;
+ Query q;
+ switch (type) {
+ case PROJECT:
+ generator = new QueryGenerator(PROJECT);
+ Users users = em.find(Users.class, getUser());
+ Gateway gatewayModel = em.find(Gateway.class, gatewayId);
+ generator.setParameter("users", users);
+ if (gatewayModel != null){
+ generator.setParameter("gateway", gatewayModel);
+ }
+
+ //ordering - only supported only by CREATION_TIME
+ if(orderByIdentifier != null && resultOrderType != null
+ && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
+ q = generator.selectQuery(em, ProjectConstants.CREATION_TIME, resultOrderType);
+ }else{
+ q = generator.selectQuery(em);
+ }
+
+ //pagination
+ if(limit>0 && offset>=0){
+ q.setFirstResult(offset);
+ q.setMaxResults(limit);
+ }
+
+ for (Object o : q.getResultList()) {
+ Project project = (Project) o;
+ ProjectResource projectResource = (ProjectResource) Utils.getResource(ResourceType.PROJECT, project);
+ result.add(projectResource);
+ }
+ break;
+ case EXPERIMENT:
+ generator = new QueryGenerator(EXPERIMENT);
+ generator.setParameter(ExperimentConstants.EXECUTION_USER, getUser());
+
+ //ordering - only supported only by CREATION_TIME
+ if(orderByIdentifier != null && resultOrderType != null
+ && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)) {
+ q = generator.selectQuery(em, ExperimentConstants.CREATION_TIME, resultOrderType);
+ }else{
+ q = generator.selectQuery(em);
+ }
+
+ //pagination
+ if(limit>0 && offset>=0){
+ q.setFirstResult(offset);
+ q.setMaxResults(limit);
+ }
+ for (Object o : q.getResultList()) {
+ Experiment experiment = (Experiment) o;
+ ExperimentResource experimentResource = (ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
+ result.add(experimentResource);
+ }
+
+ break;
+ default:
+ logger.error("Unsupported resource type for worker resource.", new IllegalArgumentException());
+ break;
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * save gateway worker to database
+ */
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ Gateway_Worker existingWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayId, user));
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Gateway_Worker gatewayWorker = new Gateway_Worker();
+ Users existingUser = em.find(Users.class, this.user);
+ gatewayWorker.setUser(existingUser);
+ gatewayWorker.setUser_name(existingUser.getUser_name());
+ gatewayWorker.setGateway_id(gatewayId);
+ if (existingWorker != null) {
+ existingWorker.setUser_name(existingUser.getUser_name());
+ existingWorker.setUser(existingUser);
+ existingWorker.setGateway_id(gatewayId);
+ gatewayWorker = em.merge(existingWorker);
+ } else {
+ em.persist(gatewayWorker);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ /**
+ *
+ * @return user name
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ *
+ * @param user user name
+ */
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ /**
+ *
+ * @param id project id
+ * @return whether the project is available under the user
+ */
+ public boolean isProjectExists(String id) throws RegistryException{
+ return isExists(ResourceType.PROJECT, id);
+ }
+
+ /**
+ *
+ * @param projectId project id
+ * @return project resource for the user
+ */
+ public ProjectResource createProject(String projectId) throws RegistryException{
+ ProjectResource project=(ProjectResource)create(ResourceType.PROJECT);
+ project.setId(projectId);
+ return project;
+ }
+
+ public String getProjectID(String projectName) {
+ String pro = projectName.replaceAll("\\s", "");
+ return pro + "_" + UUID.randomUUID();
+ }
+
+ /**
+ *
+ * @param id project id
+ * @return project resource
+ */
+ public ProjectResource getProject(String id) throws RegistryException{
+ return (ProjectResource)get(ResourceType.PROJECT, id);
+ }
+
+ /**
+ *
+ * @param id project id
+ */
+ public void removeProject(String id) throws RegistryException{
+ remove(ResourceType.PROJECT, id);
+ }
+
+ /**
+ * Get projects list of user
+ * @return list of projects for the user
+ */
+ public List<ProjectResource> getProjects() throws RegistryException{
+ return getProjects(-1, -1, null, null);
+ }
+
+
+ /**
+ * Get projects list of user with pagination and ordering
+ *
+ * @return list of projects for the user
+ */
+ public List<ProjectResource> getProjects(int limit, int offset, Object orderByIdentifier,
+ ResultOrderType resultOrderType) throws RegistryException{
+ List<ProjectResource> result=new ArrayList<ProjectResource>();
+ List<ExperimentCatResource> list = get(ResourceType.PROJECT, limit, offset, orderByIdentifier, resultOrderType);
+ for (ExperimentCatResource resource : list) {
+ result.add((ProjectResource) resource);
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @param name experiment name
+ * @return whether experiment is already exist for the given user
+ */
+ public boolean isExperimentExists(String name) throws RegistryException{
+ return isExists(ResourceType.EXPERIMENT, name);
+ }
+
+
+ /**
+ *
+ * @param name experiment name
+ * @return experiment resource
+ */
+ public ExperimentResource getExperiment(String name) throws RegistryException{
+ return (ExperimentResource)get(ResourceType.EXPERIMENT, name);
+ }
+//
+// public GFacJobDataResource getGFacJob(String jobId){
+// return (GFacJobDataResource)get(ResourceType.GFAC_JOB_DATA,jobId);
+// }
+
+ /**
+ * Method to get list of expeirments of user
+ * @return list of experiments for the user
+ */
+ public List<ExperimentResource> getExperiments() throws RegistryException{
+ return getExperiments(-1, -1, null, null);
+ }
+
+ /**
+ * Method to get list of experiments of user with pagination and ordering
+ * @param limit
+ * @param offset
+ * @param orderByIdentifier
+ * @param resultOrderType
+ * @return
+ * @throws RegistryException
+ */
+ public List<ExperimentResource> getExperiments(int limit, int offset, Object orderByIdentifier,
+ ResultOrderType resultOrderType) throws RegistryException{
+ List<ExperimentResource> result=new ArrayList<ExperimentResource>();
+ List<ExperimentCatResource> list = get(ResourceType.EXPERIMENT, limit, offset, orderByIdentifier, resultOrderType);
+ for (ExperimentCatResource resource : list) {
+ result.add((ExperimentResource) resource);
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @param experimentId experiment name
+ */
+ public void removeExperiment(String experimentId) throws RegistryException{
+ remove(ResourceType.EXPERIMENT, experimentId);
+ }
+
+ /**
+ * To search the projects of user with the given filter criteria and retrieve the results with
+ * pagination support. Results can be ordered based on an identifier (i.e column) either ASC or
+ * DESC. But in the current implementation ordering is only supported based on the project
+ * creation time
+ *
+ * @param filters
+ * @param limit
+ * @param offset
+ * @param orderByIdentifier
+ * @param resultOrderType
+ * @return
+ * @throws RegistryException
+ */
+ public List<ProjectResource> searchProjects(Map<String, String> filters, int limit,
+ int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
+ List<ProjectResource> result = new ArrayList<ProjectResource>();
+ EntityManager em = null;
+ try {
+ String query = "SELECT p from Project p WHERE ";
+ if (filters != null && filters.size() != 0) {
+ for (String field : filters.keySet()) {
+ String filterVal = filters.get(field);
+ if (field.equals(ProjectConstants.USERNAME)) {
+ query += "p." + field + "= '" + filterVal + "' AND ";
+ }else if (field.equals(ProjectConstants.GATEWAY_ID)) {
+ query += "p." + field + "= '" + filterVal + "' AND ";
+ }else {
+ if (filterVal.contains("*")){
+ filterVal = filterVal.replaceAll("\\*", "");
+ }
+ query += "p." + field + " LIKE '%" + filterVal + "%' AND ";
+ }
+ }
+ }
+ query = query.substring(0, query.length() - 5);
+
+ //ordering
+ if( orderByIdentifier != null && resultOrderType != null
+ && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME)){
+ String order = (resultOrderType == ResultOrderType.ASC) ? "ASC" : "DESC";
+ query += " ORDER BY p." + ProjectConstants.CREATION_TIME + " " + order;
+ }
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+
+ //pagination
+ if(offset>=0 && limit >=0){
+ q = em.createQuery(query).setFirstResult(offset).setMaxResults(limit);
+ }else{
+ q = em.createQuery(query);
+ }
+
+ List resultList = q.getResultList();
+ for (Object o : resultList) {
+ Project project = (Project) o;
+ ProjectResource projectResource =
+ (ProjectResource) Utils.getResource(ResourceType.PROJECT, project);
+ result.add(projectResource);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * To search the experiments of user with the given time period and filter criteria and retrieve the results with
+ * pagination support. Results can be ordered based on an identifier (i.e column) either ASC or
+ * DESC. But in the current implementation ordering is only supported based on creationTime. Also if
+ * time period values i.e fromTime and toTime are null they will be ignored.
+ *
+ * @param fromTime
+ * @param toTime
+ * @param filters
+ * @param limit
+ * @param offset
+ * @param orderByIdentifier
+ * @param resultOrderType
+ * @return
+ * @throws RegistryException
+ */
+ public List<ExperimentSummaryResource> searchExperiments(Timestamp fromTime, Timestamp toTime, Map<String, String> filters, int limit,
+ int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
+ List<ExperimentSummaryResource> result = new ArrayList();
+ EntityManager em = null;
+ try {
+ String query = "SELECT e, s FROM Experiment e " +
+ ",Status s WHERE e.expId=s.expId AND " +
+ "s.statusType='" + StatusType.EXPERIMENT + "' AND ";
+ if(filters.get(StatusConstants.STATE) != null) {
+ String experimentState = ExperimentState.valueOf(filters.get(StatusConstants.STATE)).toString();
+ query += "s.state='" + experimentState + "' AND ";
+ }
+
+ if(toTime != null && fromTime != null && toTime.after(fromTime)){
+ query += "e.creationTime > '" + fromTime + "' " + "AND e.creationTime <'" + toTime + "' AND ";
+ }
+
+ filters.remove(StatusConstants.STATE);
+ if (filters != null && filters.size() != 0) {
+ for (String field : filters.keySet()) {
+ String filterVal = filters.get(field);
+ if (field.equals(ExperimentConstants.EXECUTION_USER)) {
+ query += "e." + field + "= '" + filterVal + "' AND ";
+ }else if (field.equals(ExperimentConstants.GATEWAY_ID)) {
+ query += "e." + field + "= '" + filterVal + "' AND ";
+ } else if (field.equals(ExperimentConstants.PROJECT_ID)) {
+ query += "e." + field + "= '" + filterVal + "' AND ";
+ } else {
+ if (filterVal.contains("*")){
+ filterVal = filterVal.replaceAll("\\*", "");
+ }
+ query += "e." + field + " LIKE '%" + filterVal + "%' AND ";
+ }
+ }
+ }
+ query = query.substring(0, query.length() - 5);
+
+ //ordering
+ if( orderByIdentifier != null && resultOrderType != null
+ && orderByIdentifier.equals(Constants.FieldConstants.ExperimentConstants.CREATION_TIME)){
+ String order = (resultOrderType == ResultOrderType.ASC) ? "ASC" : "DESC";
+ query += " ORDER BY e." + ExperimentConstants.CREATION_TIME + " " + order;
+ }
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+
+ //pagination
+ if(offset>=0 && limit >=0){
+ q = em.createQuery(query).setFirstResult(offset).setMaxResults(limit);
+ }else{
+ q = em.createQuery(query);
+ }
+ OpenJPAQuery kq = OpenJPAPersistence.cast(q);
+ JDBCFetchPlan fetch = (JDBCFetchPlan) kq.getFetchPlan();
+ fetch.setEagerFetchMode(FetchMode.JOIN);
+
+ List resultList = q.getResultList();
+ for (Object o : resultList) {
+ Experiment experiment = (Experiment) ((Object[])o)[0];
+ Status experimentStatus = (Status) ((Object[])o)[1];
+ experiment.setExperimentStatus(experimentStatus);
+ ExperimentSummaryResource experimentSummaryResource =
+ (ExperimentSummaryResource) Utils.getResource(ResourceType.EXPERIMENT_SUMMARY, experiment);
+ result.add(experimentSummaryResource);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * @return list of experiments for the user
+ */
+ public List<ExperimentResource> getExperimentsByCaching(String user) throws RegistryException{
+ List<ExperimentResource> result = new ArrayList<ExperimentResource>();
+ EntityManager em = null;
+ try {
+ String query = "SELECT e from Experiment e WHERE e.executionUser = '" + user + "'";
+ em = ExpCatResourceUtils.getEntityManager();
+// OpenJPAEntityManagerFactory oemf = OpenJPAPersistence.cast(em.getEntityManagerFactory());
+// QueryResultCache qcache = oemf.getQueryResultCache();
+ // qcache.evictAll(Experiment.class);
+ em.getTransaction().begin();
+ Query q = em.createQuery(query);
+ List resultList = q.getResultList();
+ for (Object o : resultList) {
+ Experiment experiment = (Experiment) o;
+ ExperimentResource experimentResource = (ExperimentResource) Utils.getResource(ResourceType.EXPERIMENT, experiment);
+ result.add(experimentResource);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkflowNodeDetailExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkflowNodeDetailExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkflowNodeDetailExperimentCatResource.java
deleted file mode 100644
index abbb076..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkflowNodeDetailExperimentCatResource.java
+++ /dev/null
@@ -1,515 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
-import org.apache.airavata.registry.cpi.utils.StatusType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.airavata.registry.cpi.RegistryException;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WorkflowNodeDetailExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(WorkflowNodeDetailExperimentCatResource.class);
- private String experimentId;
- private String nodeInstanceId;
- private Timestamp creationTime;
- private String nodeName;
- private String executionUnit;
- private String executionUnitData;
- private List<TaskDetailExperimentCatResource> taskDetailResourceList;
- private List<NodeInputExperimentCatResource> nodeInputs;
- private List<NodeOutputExperimentCatResource> nodeOutputs;
- private StatusExperimentCatResource nodeStatus;
- private List<ErrorDetailExperimentCatResource> erros;
-
- public List<TaskDetailExperimentCatResource> getTaskDetailResourceList() {
- return taskDetailResourceList;
- }
-
- public void setTaskDetailResourceList(List<TaskDetailExperimentCatResource> taskDetailResourceList) {
- this.taskDetailResourceList = taskDetailResourceList;
- }
-
- public void setNodeInputs(List<NodeInputExperimentCatResource> nodeInputs) {
- this.nodeInputs = nodeInputs;
- }
-
- public void setNodeOutputs(List<NodeOutputExperimentCatResource> nodeOutputs) {
- this.nodeOutputs = nodeOutputs;
- }
-
- public StatusExperimentCatResource getNodeStatus() {
- return nodeStatus;
- }
-
- public void setNodeStatus(StatusExperimentCatResource nodeStatus) {
- this.nodeStatus = nodeStatus;
- }
-
- public List<ErrorDetailExperimentCatResource> getErros() {
- return erros;
- }
-
- public void setErros(List<ErrorDetailExperimentCatResource> erros) {
- this.erros = erros;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getNodeInstanceId() {
- return nodeInstanceId;
- }
-
- public void setNodeInstanceId(String nodeInstanceId) {
- this.nodeInstanceId = nodeInstanceId;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- public String getNodeName() {
- return nodeName;
- }
-
- public void setNodeName(String nodeName) {
- this.nodeName = nodeName;
- }
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException{
- switch (type){
- case TASK_DETAIL:
- TaskDetailExperimentCatResource taskDetailResource = new TaskDetailExperimentCatResource();
- taskDetailResource.setNodeId(nodeInstanceId);
- return taskDetailResource;
- case ERROR_DETAIL:
- ErrorDetailExperimentCatResource errorDetailResource = new ErrorDetailExperimentCatResource();
- errorDetailResource.setNodeId(nodeInstanceId);;
- return errorDetailResource;
- case NODE_INPUT:
- NodeInputExperimentCatResource nodeInputResource = new NodeInputExperimentCatResource();
- nodeInputResource.setNodeId(nodeInstanceId);
- return nodeInputResource;
- case NODE_OUTPUT:
- NodeOutputExperimentCatResource nodeOutputResource = new NodeOutputExperimentCatResource();
- nodeOutputResource.setNodeId(nodeInstanceId);
- return nodeOutputResource;
- case STATUS:
- StatusExperimentCatResource statusResource = new StatusExperimentCatResource();
- statusResource.setNodeId(nodeInstanceId);
- return statusResource;
- default:
- logger.error("Unsupported resource type for workflow node detail resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for workflow node detail resource.");
- }
- }
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- switch (type) {
- case TASK_DETAIL:
- generator = new QueryGenerator(TASK_DETAIL);
- generator.setParameter(TaskDetailConstants.TASK_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case NODE_INPUT:
- generator = new QueryGenerator(NODE_INPUT);
- generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case NODE_OUTPUT:
- generator = new QueryGenerator(NODE_OUTPUT);
- generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.WORKFLOW_NODE.toString());
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- default:
- logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
- break;
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator;
- Query q;
- switch (type) {
- case TASK_DETAIL:
- generator = new QueryGenerator(TASK_DETAIL);
- generator.setParameter(TaskDetailConstants.TASK_ID, name);
- q = generator.selectQuery(em);
- TaskDetail taskDetail = (TaskDetail) q.getSingleResult();
- TaskDetailExperimentCatResource taskDetailResource = (TaskDetailExperimentCatResource) Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
- em.getTransaction().commit();
- em.close();
- return taskDetailResource;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
- q = generator.selectQuery(em);
- ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
- ErrorDetailExperimentCatResource errorDetailResource = (ErrorDetailExperimentCatResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- em.getTransaction().commit();
- em.close();
- return errorDetailResource;
- case NODE_INPUT:
- generator = new QueryGenerator(NODE_INPUT);
- generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
- q = generator.selectQuery(em);
- NodeInput nodeInput = (NodeInput) q.getSingleResult();
- NodeInputExperimentCatResource nodeInputResource = (NodeInputExperimentCatResource) Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
- em.getTransaction().commit();
- em.close();
- return nodeInputResource;
- case NODE_OUTPUT:
- generator = new QueryGenerator(NODE_OUTPUT);
- generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
- q = generator.selectQuery(em);
- NodeOutput nodeOutput = (NodeOutput) q.getSingleResult();
- NodeOutputExperimentCatResource nodeOutputResource = (NodeOutputExperimentCatResource) Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
- em.getTransaction().commit();
- em.close();
- return nodeOutputResource;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.WORKFLOW_NODE.toString());
- q = generator.selectQuery(em);
- Status status = (Status) q.getSingleResult();
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) Utils.getResource(ResourceType.STATUS, status);
- em.getTransaction().commit();
- em.close();
- return statusResource;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
- }
- } catch (Exception e) {
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- List results;
- switch (type) {
- case TASK_DETAIL:
- generator = new QueryGenerator(TASK_DETAIL);
- generator.setParameter(TaskDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- TaskDetail taskDetail = (TaskDetail) result;
- TaskDetailExperimentCatResource taskDetailResource =
- (TaskDetailExperimentCatResource) Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
- resourceList.add(taskDetailResource);
- }
- }
- break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ErrorDetail errorDetail = (ErrorDetail) result;
- ErrorDetailExperimentCatResource errorDetailResource =
- (ErrorDetailExperimentCatResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- resourceList.add(errorDetailResource);
- }
- }
- break;
- case NODE_INPUT:
- generator = new QueryGenerator(NODE_INPUT);
- generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, nodeInstanceId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- NodeInput nodeInput = (NodeInput) result;
- NodeInputExperimentCatResource nodeInputResource =
- (NodeInputExperimentCatResource) Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
- resourceList.add(nodeInputResource);
- }
- }
- break;
- case NODE_OUTPUT:
- generator = new QueryGenerator(NODE_OUTPUT);
- generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, nodeInstanceId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- NodeOutput nodeOutput = (NodeOutput) result;
- NodeOutputExperimentCatResource nodeOutputResource =
- (NodeOutputExperimentCatResource) Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
- resourceList.add(nodeOutputResource);
- }
- }
- break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.NODE_INSTANCE_ID, nodeInstanceId);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Status status = (Status) result;
- StatusExperimentCatResource statusResource =
- (StatusExperimentCatResource) 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 = ExpCatResourceUtils.getEntityManager();
- WorkflowNodeDetail existingNode = em.find(WorkflowNodeDetail.class, nodeInstanceId);
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- WorkflowNodeDetail workflowNodeDetail = new WorkflowNodeDetail();
- workflowNodeDetail.setNodeId(nodeInstanceId);
- workflowNodeDetail.setExpId(experimentId);
- workflowNodeDetail.setCreationTime(creationTime);
- workflowNodeDetail.setNodeName(nodeName);
- workflowNodeDetail.setExecutionUnit(getExecutionUnit());
- workflowNodeDetail.setExecutionUnitData(getExecutionUnitData());
-
- if (existingNode != null) {
- existingNode.setExpId(experimentId);
- existingNode.setCreationTime(creationTime);
- existingNode.setNodeName(nodeName);
- existingNode.setExecutionUnit(getExecutionUnit());
- existingNode.setExecutionUnitData(getExecutionUnitData());
- workflowNodeDetail = em.merge(existingNode);
- } else {
- em.persist(workflowNodeDetail);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<NodeInputExperimentCatResource> getNodeInputs() {
- return nodeInputs;
- }
-
- public List<NodeOutputExperimentCatResource> getNodeOutputs() {
- return nodeOutputs;
- }
-
- public List<NodeInputExperimentCatResource> getNodeInputs1() throws RegistryException{
- List<NodeInputExperimentCatResource> nodeInputResourceList = new ArrayList<NodeInputExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.NODE_INPUT);
- for (ExperimentCatResource resource : resources) {
- NodeInputExperimentCatResource nodeInputResource = (NodeInputExperimentCatResource) resource;
- nodeInputResourceList.add(nodeInputResource);
- }
- return nodeInputResourceList;
- }
-
- public List<NodeOutputExperimentCatResource> getNodeOutputs1() throws RegistryException{
- List<NodeOutputExperimentCatResource> outputResources = new ArrayList<NodeOutputExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.NODE_OUTPUT);
- for (ExperimentCatResource resource : resources) {
- NodeOutputExperimentCatResource nodeOutputResource = (NodeOutputExperimentCatResource) resource;
- outputResources.add(nodeOutputResource);
- }
- return outputResources;
- }
-
- public StatusExperimentCatResource getWorkflowNodeStatus() throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusExperimentCatResource nodeStatus = (StatusExperimentCatResource) resource;
- if(nodeStatus.getStatusType().equals(StatusType.WORKFLOW_NODE.toString())){
- if (nodeStatus.getState() == null || nodeStatus.getState().equals("") ){
- nodeStatus.setState("UNKNOWN");
- }
- return nodeStatus;
- }
- }
- return null;
- }
-
- public StatusExperimentCatResource getTaskStatus(String taskId) throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusExperimentCatResource taskStatus = (StatusExperimentCatResource) resource;
- if(taskStatus.getStatusType().equals(StatusType.TASK.toString()) && taskStatus.getTaskId().equals(taskId)){
- if (taskStatus.getState() == null || taskStatus.getState().equals("") ){
- taskStatus.setState("UNKNOWN");
- }
- return taskStatus;
- }
- }
- return null;
- }
-
- public List<TaskDetailExperimentCatResource> getTaskDetails() throws RegistryException{
- List<TaskDetailExperimentCatResource> taskDetailResources = new ArrayList<TaskDetailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.TASK_DETAIL);
- for (ExperimentCatResource resource : resources) {
- TaskDetailExperimentCatResource taskDetailResource = (TaskDetailExperimentCatResource) resource;
- taskDetailResources.add(taskDetailResource);
- }
- return taskDetailResources;
- }
-
- public List<ErrorDetailExperimentCatResource> getErrorDetails() throws RegistryException{
- List<ErrorDetailExperimentCatResource> errorDetails = new ArrayList<ErrorDetailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
- for (ExperimentCatResource resource : resources) {
- ErrorDetailExperimentCatResource errorDetailResource = (ErrorDetailExperimentCatResource) resource;
- errorDetails.add(errorDetailResource);
- }
- return errorDetails;
- }
-
- public TaskDetailExperimentCatResource getTaskDetail(String taskId) throws RegistryException{
- return (TaskDetailExperimentCatResource)get(ResourceType.TASK_DETAIL, taskId);
- }
-
- public String getExecutionUnit() {
- return executionUnit;
- }
-
- public void setExecutionUnit(String executionUnit) {
- this.executionUnit = executionUnit;
- }
-
- public String getExecutionUnitData() {
- return executionUnitData;
- }
-
- public void setExecutionUnitData(String executionUnitData) {
- this.executionUnitData = executionUnitData;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkflowNodeDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkflowNodeDetailResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkflowNodeDetailResource.java
new file mode 100644
index 0000000..bce4229
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkflowNodeDetailResource.java
@@ -0,0 +1,515 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.*;
+import org.apache.airavata.registry.core.experiment.catalog.utils.QueryGenerator;
+import org.apache.airavata.registry.cpi.utils.StatusType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.airavata.registry.cpi.RegistryException;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+public class WorkflowNodeDetailResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(WorkflowNodeDetailResource.class);
+ private String experimentId;
+ private String nodeInstanceId;
+ private Timestamp creationTime;
+ private String nodeName;
+ private String executionUnit;
+ private String executionUnitData;
+ private List<TaskDetailResource> taskDetailResourceList;
+ private List<NodeInputResource> nodeInputs;
+ private List<NodeOutputResource> nodeOutputs;
+ private StatusResource nodeStatus;
+ private List<ErrorDetailResource> erros;
+
+ public List<TaskDetailResource> getTaskDetailResourceList() {
+ return taskDetailResourceList;
+ }
+
+ public void setTaskDetailResourceList(List<TaskDetailResource> taskDetailResourceList) {
+ this.taskDetailResourceList = taskDetailResourceList;
+ }
+
+ public void setNodeInputs(List<NodeInputResource> nodeInputs) {
+ this.nodeInputs = nodeInputs;
+ }
+
+ public void setNodeOutputs(List<NodeOutputResource> nodeOutputs) {
+ this.nodeOutputs = nodeOutputs;
+ }
+
+ public StatusResource getNodeStatus() {
+ return nodeStatus;
+ }
+
+ public void setNodeStatus(StatusResource nodeStatus) {
+ this.nodeStatus = nodeStatus;
+ }
+
+ public List<ErrorDetailResource> getErros() {
+ return erros;
+ }
+
+ public void setErros(List<ErrorDetailResource> erros) {
+ this.erros = erros;
+ }
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getNodeInstanceId() {
+ return nodeInstanceId;
+ }
+
+ public void setNodeInstanceId(String nodeInstanceId) {
+ this.nodeInstanceId = nodeInstanceId;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public String getNodeName() {
+ return nodeName;
+ }
+
+ public void setNodeName(String nodeName) {
+ this.nodeName = nodeName;
+ }
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException{
+ switch (type){
+ case TASK_DETAIL:
+ TaskDetailResource taskDetailResource = new TaskDetailResource();
+ taskDetailResource.setNodeId(nodeInstanceId);
+ return taskDetailResource;
+ case ERROR_DETAIL:
+ ErrorDetailResource errorDetailResource = new ErrorDetailResource();
+ errorDetailResource.setNodeId(nodeInstanceId);;
+ return errorDetailResource;
+ case NODE_INPUT:
+ NodeInputResource nodeInputResource = new NodeInputResource();
+ nodeInputResource.setNodeId(nodeInstanceId);
+ return nodeInputResource;
+ case NODE_OUTPUT:
+ NodeOutputResource nodeOutputResource = new NodeOutputResource();
+ nodeOutputResource.setNodeId(nodeInstanceId);
+ return nodeOutputResource;
+ case STATUS:
+ StatusResource statusResource = new StatusResource();
+ statusResource.setNodeId(nodeInstanceId);
+ return statusResource;
+ default:
+ logger.error("Unsupported resource type for workflow node detail resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for workflow node detail resource.");
+ }
+ }
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ switch (type) {
+ case TASK_DETAIL:
+ generator = new QueryGenerator(TASK_DETAIL);
+ generator.setParameter(TaskDetailConstants.TASK_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case NODE_INPUT:
+ generator = new QueryGenerator(NODE_INPUT);
+ generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case NODE_OUTPUT:
+ generator = new QueryGenerator(NODE_OUTPUT);
+ generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.WORKFLOW_NODE.toString());
+ q = generator.deleteQuery(em);
+ q.executeUpdate();
+ break;
+ default:
+ logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
+ break;
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ QueryGenerator generator;
+ Query q;
+ switch (type) {
+ case TASK_DETAIL:
+ generator = new QueryGenerator(TASK_DETAIL);
+ generator.setParameter(TaskDetailConstants.TASK_ID, name);
+ q = generator.selectQuery(em);
+ TaskDetail taskDetail = (TaskDetail) q.getSingleResult();
+ TaskDetailResource taskDetailResource = (TaskDetailResource) Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
+ em.getTransaction().commit();
+ em.close();
+ return taskDetailResource;
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, name);
+ q = generator.selectQuery(em);
+ ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
+ ErrorDetailResource errorDetailResource = (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+ em.getTransaction().commit();
+ em.close();
+ return errorDetailResource;
+ case NODE_INPUT:
+ generator = new QueryGenerator(NODE_INPUT);
+ generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, name);
+ q = generator.selectQuery(em);
+ NodeInput nodeInput = (NodeInput) q.getSingleResult();
+ NodeInputResource nodeInputResource = (NodeInputResource) Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
+ em.getTransaction().commit();
+ em.close();
+ return nodeInputResource;
+ case NODE_OUTPUT:
+ generator = new QueryGenerator(NODE_OUTPUT);
+ generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, name);
+ q = generator.selectQuery(em);
+ NodeOutput nodeOutput = (NodeOutput) q.getSingleResult();
+ NodeOutputResource nodeOutputResource = (NodeOutputResource) Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
+ em.getTransaction().commit();
+ em.close();
+ return nodeOutputResource;
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.NODE_INSTANCE_ID, name);
+ generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.WORKFLOW_NODE.toString());
+ q = generator.selectQuery(em);
+ Status status = (Status) q.getSingleResult();
+ StatusResource statusResource = (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+ em.getTransaction().commit();
+ em.close();
+ return statusResource;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported resource type for workflow node resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported resource type for workflow node resource.");
+ }
+ } catch (Exception e) {
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ QueryGenerator generator;
+ List results;
+ switch (type) {
+ case TASK_DETAIL:
+ generator = new QueryGenerator(TASK_DETAIL);
+ generator.setParameter(TaskDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ TaskDetail taskDetail = (TaskDetail) result;
+ TaskDetailResource taskDetailResource =
+ (TaskDetailResource) Utils.getResource(ResourceType.TASK_DETAIL, taskDetail);
+ resourceList.add(taskDetailResource);
+ }
+ }
+ break;
+ case ERROR_DETAIL:
+ generator = new QueryGenerator(ERROR_DETAIL);
+ generator.setParameter(ErrorDetailConstants.NODE_INSTANCE_ID, nodeInstanceId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ErrorDetail errorDetail = (ErrorDetail) result;
+ ErrorDetailResource errorDetailResource =
+ (ErrorDetailResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
+ resourceList.add(errorDetailResource);
+ }
+ }
+ break;
+ case NODE_INPUT:
+ generator = new QueryGenerator(NODE_INPUT);
+ generator.setParameter(NodeInputConstants.NODE_INSTANCE_ID, nodeInstanceId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ NodeInput nodeInput = (NodeInput) result;
+ NodeInputResource nodeInputResource =
+ (NodeInputResource) Utils.getResource(ResourceType.NODE_INPUT, nodeInput);
+ resourceList.add(nodeInputResource);
+ }
+ }
+ break;
+ case NODE_OUTPUT:
+ generator = new QueryGenerator(NODE_OUTPUT);
+ generator.setParameter(NodeOutputConstants.NODE_INSTANCE_ID, nodeInstanceId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ NodeOutput nodeOutput = (NodeOutput) result;
+ NodeOutputResource nodeOutputResource =
+ (NodeOutputResource) Utils.getResource(ResourceType.NODE_OUTPUT, nodeOutput);
+ resourceList.add(nodeOutputResource);
+ }
+ }
+ break;
+ case STATUS:
+ generator = new QueryGenerator(STATUS);
+ generator.setParameter(StatusConstants.NODE_INSTANCE_ID, nodeInstanceId);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ Status status = (Status) result;
+ StatusResource statusResource =
+ (StatusResource) Utils.getResource(ResourceType.STATUS, status);
+ resourceList.add(statusResource);
+ }
+ }
+ break;
+ default:
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported resource type for workflow node details resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+// logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ WorkflowNodeDetail existingNode = em.find(WorkflowNodeDetail.class, nodeInstanceId);
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ WorkflowNodeDetail workflowNodeDetail = new WorkflowNodeDetail();
+ workflowNodeDetail.setNodeId(nodeInstanceId);
+ workflowNodeDetail.setExpId(experimentId);
+ workflowNodeDetail.setCreationTime(creationTime);
+ workflowNodeDetail.setNodeName(nodeName);
+ workflowNodeDetail.setExecutionUnit(getExecutionUnit());
+ workflowNodeDetail.setExecutionUnitData(getExecutionUnitData());
+
+ if (existingNode != null) {
+ existingNode.setExpId(experimentId);
+ existingNode.setCreationTime(creationTime);
+ existingNode.setNodeName(nodeName);
+ existingNode.setExecutionUnit(getExecutionUnit());
+ existingNode.setExecutionUnitData(getExecutionUnitData());
+ workflowNodeDetail = em.merge(existingNode);
+ } else {
+ em.persist(workflowNodeDetail);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new RegistryException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<NodeInputResource> getNodeInputs() {
+ return nodeInputs;
+ }
+
+ public List<NodeOutputResource> getNodeOutputs() {
+ return nodeOutputs;
+ }
+
+ public List<NodeInputResource> getNodeInputs1() throws RegistryException{
+ List<NodeInputResource> nodeInputResourceList = new ArrayList<NodeInputResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.NODE_INPUT);
+ for (ExperimentCatResource resource : resources) {
+ NodeInputResource nodeInputResource = (NodeInputResource) resource;
+ nodeInputResourceList.add(nodeInputResource);
+ }
+ return nodeInputResourceList;
+ }
+
+ public List<NodeOutputResource> getNodeOutputs1() throws RegistryException{
+ List<NodeOutputResource> outputResources = new ArrayList<NodeOutputResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.NODE_OUTPUT);
+ for (ExperimentCatResource resource : resources) {
+ NodeOutputResource nodeOutputResource = (NodeOutputResource) resource;
+ outputResources.add(nodeOutputResource);
+ }
+ return outputResources;
+ }
+
+ public StatusResource getWorkflowNodeStatus() throws RegistryException{
+ List<ExperimentCatResource> resources = get(ResourceType.STATUS);
+ for (ExperimentCatResource resource : resources) {
+ StatusResource nodeStatus = (StatusResource) resource;
+ if(nodeStatus.getStatusType().equals(StatusType.WORKFLOW_NODE.toString())){
+ if (nodeStatus.getState() == null || nodeStatus.getState().equals("") ){
+ nodeStatus.setState("UNKNOWN");
+ }
+ return nodeStatus;
+ }
+ }
+ return null;
+ }
+
+ public StatusResource getTaskStatus(String taskId) throws RegistryException{
+ List<ExperimentCatResource> resources = get(ResourceType.STATUS);
+ for (ExperimentCatResource resource : resources) {
+ StatusResource taskStatus = (StatusResource) resource;
+ if(taskStatus.getStatusType().equals(StatusType.TASK.toString()) && taskStatus.getTaskId().equals(taskId)){
+ if (taskStatus.getState() == null || taskStatus.getState().equals("") ){
+ taskStatus.setState("UNKNOWN");
+ }
+ return taskStatus;
+ }
+ }
+ return null;
+ }
+
+ public List<TaskDetailResource> getTaskDetails() throws RegistryException{
+ List<TaskDetailResource> taskDetailResources = new ArrayList<TaskDetailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.TASK_DETAIL);
+ for (ExperimentCatResource resource : resources) {
+ TaskDetailResource taskDetailResource = (TaskDetailResource) resource;
+ taskDetailResources.add(taskDetailResource);
+ }
+ return taskDetailResources;
+ }
+
+ public List<ErrorDetailResource> getErrorDetails() throws RegistryException{
+ List<ErrorDetailResource> errorDetails = new ArrayList<ErrorDetailResource>();
+ List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
+ for (ExperimentCatResource resource : resources) {
+ ErrorDetailResource errorDetailResource = (ErrorDetailResource) resource;
+ errorDetails.add(errorDetailResource);
+ }
+ return errorDetails;
+ }
+
+ public TaskDetailResource getTaskDetail(String taskId) throws RegistryException{
+ return (TaskDetailResource)get(ResourceType.TASK_DETAIL, taskId);
+ }
+
+ public String getExecutionUnit() {
+ return executionUnit;
+ }
+
+ public void setExecutionUnit(String executionUnit) {
+ this.executionUnit = executionUnit;
+ }
+
+ public String getExecutionUnitData() {
+ return executionUnitData;
+ }
+
+ public void setExecutionUnitData(String executionUnitData) {
+ this.executionUnitData = executionUnitData;
+ }
+}
[19/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java
new file mode 100644
index 0000000..4cc623b
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobManagerCommandResource.java
@@ -0,0 +1,307 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.JobManagerCommand;
+import org.apache.airavata.registry.core.app.catalog.model.JobManagerCommand_PK;
+import org.apache.airavata.registry.core.app.catalog.model.ResourceJobManager;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JobManagerCommandResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(JobManagerCommandResource.class);
+ private String resourceJobManagerId;
+ private ResourceJobManagerResource resourceJobManagerResource;
+ private String commandType;
+ private String command;
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND);
+ generator.setParameter(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID));
+ generator.setParameter(JobManagerCommandConstants.COMMAND_TYPE, ids.get(JobManagerCommandConstants.COMMAND_TYPE));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND);
+ generator.setParameter(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID));
+ generator.setParameter(JobManagerCommandConstants.COMMAND_TYPE, ids.get(JobManagerCommandConstants.COMMAND_TYPE));
+ Query q = generator.selectQuery(em);
+ JobManagerCommand jobManagerCommand = (JobManagerCommand) q.getSingleResult();
+ JobManagerCommandResource jobManagerCommandResource = (JobManagerCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand);
+ em.getTransaction().commit();
+ em.close();
+ return jobManagerCommandResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> jobManagerCommandResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND);
+ Query q;
+ if ((fieldName.equals(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(JobManagerCommandConstants.COMMAND_TYPE)) || (fieldName.equals(JobManagerCommandConstants.COMMAND))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ JobManagerCommand jobManagerCommand = (JobManagerCommand) result;
+ JobManagerCommandResource jobManagerCommandResource = (JobManagerCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand);
+ jobManagerCommandResources.add(jobManagerCommandResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Job Manager Command Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Job Manager Command Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return jobManagerCommandResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> jobManagerCommandResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_MANAGER_COMMAND);
+ Query q;
+ if ((fieldName.equals(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID)) || (fieldName.equals(JobManagerCommandConstants.COMMAND_TYPE)) || (fieldName.equals(JobManagerCommandConstants.COMMAND))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ JobManagerCommand jobManagerCommand = (JobManagerCommand) result;
+ JobManagerCommandResource jobManagerCommandResource = (JobManagerCommandResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_MANAGER_COMMAND, jobManagerCommand);
+ jobManagerCommandResourceIDs.add(jobManagerCommandResource.getResourceJobManagerId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Job Manager Command Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Job Manager Command Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return jobManagerCommandResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ JobManagerCommand existingJobManagerCommand = em.find(JobManagerCommand.class, new JobManagerCommand_PK(resourceJobManagerId, commandType));
+ em.close();
+ JobManagerCommand jobManagerCommand;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingJobManagerCommand == null) {
+ jobManagerCommand = new JobManagerCommand();
+ } else {
+ jobManagerCommand = existingJobManagerCommand;
+ }
+ jobManagerCommand.setResourceJobManagerId(getResourceJobManagerId());
+ ResourceJobManager resourceJobManager = em.find(ResourceJobManager.class, getResourceJobManagerId());
+ jobManagerCommand.setResourceJobManager(resourceJobManager);
+ jobManagerCommand.setCommandType(getCommandType());
+ jobManagerCommand.setCommand(getCommand());
+ if (existingJobManagerCommand == null) {
+ em.persist(jobManagerCommand);
+ } else {
+ em.merge(jobManagerCommand);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ JobManagerCommand jobManagerCommand = em.find(JobManagerCommand.class, new JobManagerCommand_PK(ids.get(JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID), ids.get(JobManagerCommandConstants.COMMAND_TYPE)));
+ em.close();
+ return jobManagerCommand != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getResourceJobManagerId() {
+ return resourceJobManagerId;
+ }
+
+ public ResourceJobManagerResource getResourceJobManagerResource() {
+ return resourceJobManagerResource;
+ }
+
+ public String getCommandType() {
+ return commandType;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setResourceJobManagerId(String resourceJobManagerId) {
+ this.resourceJobManagerId=resourceJobManagerId;
+ }
+
+ public void setResourceJobManagerResource(ResourceJobManagerResource resourceJobManagerResource) {
+ this.resourceJobManagerResource=resourceJobManagerResource;
+ }
+
+ public void setCommandType(String commandType) {
+ this.commandType=commandType;
+ }
+
+ public void setCommand(String command) {
+ this.command=command;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceAppCatalogResourceAppCat.java
deleted file mode 100644
index ab34dff..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,339 +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.registry.core.app.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
-import org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface;
-import org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface_PK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JobSubmissionInterfaceAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(JobSubmissionInterfaceAppCatalogResourceAppCat.class);
- private String jobSubmissionInterfaceId;
- private String computeResourceId;
- private ComputeResourceAppCatalogResourceAppCat computeHostResource;
- private String jobSubmissionProtocol;
- private int priorityOrder;
- private Timestamp createdTime;
- private Timestamp updatedTime;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE);
- generator.setParameter(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID, ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID));
- generator.setParameter(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE);
- generator.setParameter(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID, ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID));
- generator.setParameter(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID));
- Query q = generator.selectQuery(em);
- JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) q.getSingleResult();
- JobSubmissionInterfaceAppCatalogResourceAppCat jobSubmissionInterfaceResource = (JobSubmissionInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface);
- em.getTransaction().commit();
- em.close();
- return jobSubmissionInterfaceResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> jobSubmissionInterfaceResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE);
- Query q;
- if ((fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_PROTOCOL)) || (fieldName.equals(JobSubmissionInterfaceConstants.PRIORITY_ORDER))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) result;
- JobSubmissionInterfaceAppCatalogResourceAppCat jobSubmissionInterfaceResource = (JobSubmissionInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface);
- jobSubmissionInterfaceResources.add(jobSubmissionInterfaceResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return jobSubmissionInterfaceResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> jobSubmissionInterfaceResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE);
- Query q;
- if ((fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_PROTOCOL)) || (fieldName.equals(JobSubmissionInterfaceConstants.PRIORITY_ORDER))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) result;
- JobSubmissionInterfaceAppCatalogResourceAppCat jobSubmissionInterfaceResource = (JobSubmissionInterfaceAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface);
- jobSubmissionInterfaceResourceIDs.add(jobSubmissionInterfaceResource.getComputeResourceId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return jobSubmissionInterfaceResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- JobSubmissionInterface existingJobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(jobSubmissionInterfaceId, computeResourceId));
- em.close();
- JobSubmissionInterface jobSubmissionInterface;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingJobSubmissionInterface == null) {
- jobSubmissionInterface = new JobSubmissionInterface();
- jobSubmissionInterface.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- jobSubmissionInterface = existingJobSubmissionInterface;
- jobSubmissionInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- jobSubmissionInterface.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
- jobSubmissionInterface.setComputeResourceId(getComputeResourceId());
- ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
- jobSubmissionInterface.setComputeResource(computeResource);
- jobSubmissionInterface.setJobSubmissionProtocol(getJobSubmissionProtocol());
- jobSubmissionInterface.setPriorityOrder(getPriorityOrder());
- if (existingJobSubmissionInterface == null) {
- em.persist(jobSubmissionInterface);
- } else {
- em.merge(jobSubmissionInterface);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- JobSubmissionInterface jobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID), ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)));
- em.close();
- return jobSubmissionInterface != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getJobSubmissionInterfaceId() {
- return jobSubmissionInterfaceId;
- }
-
- public String getComputeResourceId() {
- return computeResourceId;
- }
-
- public ComputeResourceAppCatalogResourceAppCat getComputeHostResource() {
- return computeHostResource;
- }
-
- public String getJobSubmissionProtocol() {
- return jobSubmissionProtocol;
- }
-
- public int getPriorityOrder() {
- return priorityOrder;
- }
-
- public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
- this.jobSubmissionInterfaceId=jobSubmissionInterfaceId;
- }
-
- public void setComputeResourceId(String computeResourceId) {
- this.computeResourceId=computeResourceId;
- }
-
- public void setComputeHostResource(ComputeResourceAppCatalogResourceAppCat computeHostResource) {
- this.computeHostResource=computeHostResource;
- }
-
- public void setJobSubmissionProtocol(String jobSubmissionProtocol) {
- this.jobSubmissionProtocol=jobSubmissionProtocol;
- }
-
- public void setPriorityOrder(int priorityOrder) {
- this.priorityOrder=priorityOrder;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java
new file mode 100644
index 0000000..a8df941
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/JobSubmissionInterfaceResource.java
@@ -0,0 +1,339 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ComputeResource;
+import org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface;
+import org.apache.airavata.registry.core.app.catalog.model.JobSubmissionInterface_PK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JobSubmissionInterfaceResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(JobSubmissionInterfaceResource.class);
+ private String jobSubmissionInterfaceId;
+ private String computeResourceId;
+ private ComputeResourceResource computeHostResource;
+ private String jobSubmissionProtocol;
+ private int priorityOrder;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE);
+ generator.setParameter(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID, ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID));
+ generator.setParameter(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE);
+ generator.setParameter(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID, ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID));
+ generator.setParameter(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID));
+ Query q = generator.selectQuery(em);
+ JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) q.getSingleResult();
+ JobSubmissionInterfaceResource jobSubmissionInterfaceResource = (JobSubmissionInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface);
+ em.getTransaction().commit();
+ em.close();
+ return jobSubmissionInterfaceResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> jobSubmissionInterfaceResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE);
+ Query q;
+ if ((fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_PROTOCOL)) || (fieldName.equals(JobSubmissionInterfaceConstants.PRIORITY_ORDER))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) result;
+ JobSubmissionInterfaceResource jobSubmissionInterfaceResource = (JobSubmissionInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface);
+ jobSubmissionInterfaceResources.add(jobSubmissionInterfaceResource);
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return jobSubmissionInterfaceResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> jobSubmissionInterfaceResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(JOB_SUBMISSION_INTERFACE);
+ Query q;
+ if ((fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)) || (fieldName.equals(JobSubmissionInterfaceConstants.JOB_SUBMISSION_PROTOCOL)) || (fieldName.equals(JobSubmissionInterfaceConstants.PRIORITY_ORDER))) {
+ generator.setParameter(fieldName, value);
+ q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ JobSubmissionInterface jobSubmissionInterface = (JobSubmissionInterface) result;
+ JobSubmissionInterfaceResource jobSubmissionInterfaceResource = (JobSubmissionInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.JOB_SUBMISSION_INTERFACE, jobSubmissionInterface);
+ jobSubmissionInterfaceResourceIDs.add(jobSubmissionInterfaceResource.getComputeResourceId());
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Job Submission Interface Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Job Submission Interface Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return jobSubmissionInterfaceResourceIDs;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ JobSubmissionInterface existingJobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(jobSubmissionInterfaceId, computeResourceId));
+ em.close();
+ JobSubmissionInterface jobSubmissionInterface;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingJobSubmissionInterface == null) {
+ jobSubmissionInterface = new JobSubmissionInterface();
+ jobSubmissionInterface.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ } else {
+ jobSubmissionInterface = existingJobSubmissionInterface;
+ jobSubmissionInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ }
+ jobSubmissionInterface.setJobSubmissionInterfaceId(getJobSubmissionInterfaceId());
+ jobSubmissionInterface.setComputeResourceId(getComputeResourceId());
+ ComputeResource computeResource = em.find(ComputeResource.class, getComputeResourceId());
+ jobSubmissionInterface.setComputeResource(computeResource);
+ jobSubmissionInterface.setJobSubmissionProtocol(getJobSubmissionProtocol());
+ jobSubmissionInterface.setPriorityOrder(getPriorityOrder());
+ if (existingJobSubmissionInterface == null) {
+ em.persist(jobSubmissionInterface);
+ } else {
+ em.merge(jobSubmissionInterface);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ JobSubmissionInterface jobSubmissionInterface = em.find(JobSubmissionInterface.class, new JobSubmissionInterface_PK(ids.get(JobSubmissionInterfaceConstants.JOB_SUBMISSION_INTERFACE_ID), ids.get(JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID)));
+ em.close();
+ return jobSubmissionInterface != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getJobSubmissionInterfaceId() {
+ return jobSubmissionInterfaceId;
+ }
+
+ public String getComputeResourceId() {
+ return computeResourceId;
+ }
+
+ public ComputeResourceResource getComputeHostResource() {
+ return computeHostResource;
+ }
+
+ public String getJobSubmissionProtocol() {
+ return jobSubmissionProtocol;
+ }
+
+ public int getPriorityOrder() {
+ return priorityOrder;
+ }
+
+ public void setJobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
+ this.jobSubmissionInterfaceId=jobSubmissionInterfaceId;
+ }
+
+ public void setComputeResourceId(String computeResourceId) {
+ this.computeResourceId=computeResourceId;
+ }
+
+ public void setComputeHostResource(ComputeResourceResource computeHostResource) {
+ this.computeHostResource=computeHostResource;
+ }
+
+ public void setJobSubmissionProtocol(String jobSubmissionProtocol) {
+ this.jobSubmissionProtocol=jobSubmissionProtocol;
+ }
+
+ public void setPriorityOrder(int priorityOrder) {
+ this.priorityOrder=priorityOrder;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathAppCatalogResourceAppCat.java
deleted file mode 100644
index e7e83ce..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,292 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
-import org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath;
-import org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath_PK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class LibraryApendPathAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(LibraryApendPathAppCatalogResourceAppCat.class);
- private String deploymentId;
- private String name;
- private String value;
- private AppDeploymentAppCatalogResourceAppCat appDeploymentResource;
-
- public String getDeploymentId() {
- return deploymentId;
- }
-
- public void setDeploymentId(String deploymentId) {
- this.deploymentId = deploymentId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public AppDeploymentAppCatalogResourceAppCat getAppDeploymentResource() {
- return appDeploymentResource;
- }
-
- public void setAppDeploymentResource(AppDeploymentAppCatalogResourceAppCat appDeploymentResource) {
- this.appDeploymentResource = appDeploymentResource;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(LIBRARY_APEND_PATH);
- generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, ids.get(LibraryApendPathConstants.DEPLOYMENT_ID));
- if (ids.get(LibraryApendPathConstants.NAME) != null){
- generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME));
- }
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_APEND_PATH);
- generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, ids.get(LibraryApendPathConstants.DEPLOYMENT_ID));
- generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME));
- Query q = generator.selectQuery(em);
- LibraryApendPath libraryApendPath = (LibraryApendPath) q.getSingleResult();
- LibraryApendPathAppCatalogResourceAppCat resource =
- (LibraryApendPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, libraryApendPath);
- em.getTransaction().commit();
- em.close();
- return resource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> libApPathList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_APEND_PATH);
- List results;
- if (fieldName.equals(LibraryApendPathConstants.DEPLOYMENT_ID)) {
- generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- LibraryApendPath prepandPath = (LibraryApendPath) result;
- LibraryApendPathAppCatalogResourceAppCat resource =
- (LibraryApendPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, prepandPath);
- libApPathList.add(resource);
- }
- }
- } else if (fieldName.equals(LibraryApendPathConstants.NAME)) {
- generator.setParameter(LibraryApendPathConstants.NAME, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- LibraryApendPath prepandPath = (LibraryApendPath) result;
- LibraryApendPathAppCatalogResourceAppCat resource =
- (LibraryApendPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, prepandPath);
- libApPathList.add(resource);
- }
- }
- }else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for libraryApendPath resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for libraryApendPath resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return libApPathList;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- logger.error("Unsupported for objects with a composite identifier");
- throw new AppCatalogException("Unsupported for objects with a composite identifier");
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- LibraryApendPath existigApendPath = em.find(LibraryApendPath.class, new LibraryApendPath_PK(deploymentId, name));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
-
- ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId);
- if (existigApendPath != null){
- existigApendPath.setValue(value);
- existigApendPath.setApplicationDeployment(deployment);
- em.merge(existigApendPath);
- }else {
- LibraryApendPath apendPath = new LibraryApendPath();
- apendPath.setDeploymentID(deploymentId);
- apendPath.setName(name);
- apendPath.setValue(value);
- apendPath.setApplicationDeployment(deployment);
- em.persist(apendPath);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- LibraryApendPath apendPath = em.find(LibraryApendPath.class,
- new LibraryApendPath_PK(ids.get(LibraryApendPathConstants.DEPLOYMENT_ID),
- ids.get(LibraryApendPathConstants.NAME)));
- em.close();
- return apendPath != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java
new file mode 100644
index 0000000..0949f20
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryApendPathResource.java
@@ -0,0 +1,292 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
+import org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath;
+import org.apache.airavata.registry.core.app.catalog.model.LibraryApendPath_PK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class LibraryApendPathResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(LibraryApendPathResource.class);
+ private String deploymentId;
+ private String name;
+ private String value;
+ private AppDeploymentResource appDeploymentResource;
+
+ public String getDeploymentId() {
+ return deploymentId;
+ }
+
+ public void setDeploymentId(String deploymentId) {
+ this.deploymentId = deploymentId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public AppDeploymentResource getAppDeploymentResource() {
+ return appDeploymentResource;
+ }
+
+ public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) {
+ this.appDeploymentResource = appDeploymentResource;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(LIBRARY_APEND_PATH);
+ generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, ids.get(LibraryApendPathConstants.DEPLOYMENT_ID));
+ if (ids.get(LibraryApendPathConstants.NAME) != null){
+ generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME));
+ }
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_APEND_PATH);
+ generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, ids.get(LibraryApendPathConstants.DEPLOYMENT_ID));
+ generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME));
+ Query q = generator.selectQuery(em);
+ LibraryApendPath libraryApendPath = (LibraryApendPath) q.getSingleResult();
+ LibraryApendPathResource resource =
+ (LibraryApendPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, libraryApendPath);
+ em.getTransaction().commit();
+ em.close();
+ return resource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> libApPathList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_APEND_PATH);
+ List results;
+ if (fieldName.equals(LibraryApendPathConstants.DEPLOYMENT_ID)) {
+ generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ LibraryApendPath prepandPath = (LibraryApendPath) result;
+ LibraryApendPathResource resource =
+ (LibraryApendPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, prepandPath);
+ libApPathList.add(resource);
+ }
+ }
+ } else if (fieldName.equals(LibraryApendPathConstants.NAME)) {
+ generator.setParameter(LibraryApendPathConstants.NAME, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ LibraryApendPath prepandPath = (LibraryApendPath) result;
+ LibraryApendPathResource resource =
+ (LibraryApendPathResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_APEND_PATH, prepandPath);
+ libApPathList.add(resource);
+ }
+ }
+ }else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for libraryApendPath resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for libraryApendPath resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return libApPathList;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ logger.error("Unsupported for objects with a composite identifier");
+ throw new AppCatalogException("Unsupported for objects with a composite identifier");
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ LibraryApendPath existigApendPath = em.find(LibraryApendPath.class, new LibraryApendPath_PK(deploymentId, name));
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+
+ ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId);
+ if (existigApendPath != null){
+ existigApendPath.setValue(value);
+ existigApendPath.setApplicationDeployment(deployment);
+ em.merge(existigApendPath);
+ }else {
+ LibraryApendPath apendPath = new LibraryApendPath();
+ apendPath.setDeploymentID(deploymentId);
+ apendPath.setName(name);
+ apendPath.setValue(value);
+ apendPath.setApplicationDeployment(deployment);
+ em.persist(apendPath);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map){
+ ids = (HashMap)identifier;
+ }else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ LibraryApendPath apendPath = em.find(LibraryApendPath.class,
+ new LibraryApendPath_PK(ids.get(LibraryApendPathConstants.DEPLOYMENT_ID),
+ ids.get(LibraryApendPathConstants.NAME)));
+ em.close();
+ return apendPath != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathAppCatalogResourceAppCat.java
deleted file mode 100644
index 799b0b3..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/LibraryPrepandPathAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,291 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationDeployment;
-import org.apache.airavata.registry.core.app.catalog.model.LibraryPrepandPath;
-import org.apache.airavata.registry.core.app.catalog.model.LibraryPrepandPath_PK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class LibraryPrepandPathAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(LibraryPrepandPathAppCatalogResourceAppCat.class);
- private String deploymentId;
- private String name;
- private String value;
- private AppDeploymentAppCatalogResourceAppCat appDeploymentResource;
-
- public String getDeploymentId() {
- return deploymentId;
- }
-
- public void setDeploymentId(String deploymentId) {
- this.deploymentId = deploymentId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public AppDeploymentAppCatalogResourceAppCat getAppDeploymentResource() {
- return appDeploymentResource;
- }
-
- public void setAppDeploymentResource(AppDeploymentAppCatalogResourceAppCat appDeploymentResource) {
- this.appDeploymentResource = appDeploymentResource;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH);
- generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID));
- if (ids.get(LibraryPrepandPathConstants.NAME) != null){
- generator.setParameter(LibraryPrepandPathConstants.NAME, ids.get(LibraryPrepandPathConstants.NAME));
- }
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH);
- generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID));
- generator.setParameter(LibraryPrepandPathConstants.NAME, ids.get(LibraryPrepandPathConstants.NAME));
- Query q = generator.selectQuery(em);
- LibraryPrepandPath libraryPrepandPath = (LibraryPrepandPath) q.getSingleResult();
- LibraryPrepandPathAppCatalogResourceAppCat resource =
- (LibraryPrepandPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, libraryPrepandPath);
- em.getTransaction().commit();
- em.close();
- return resource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> libPrepPathList = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH);
- List results;
- if (fieldName.equals(LibraryPrepandPathConstants.DEPLOYMENT_ID)) {
- generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- LibraryPrepandPath prepandPath = (LibraryPrepandPath) result;
- LibraryPrepandPathAppCatalogResourceAppCat resource =
- (LibraryPrepandPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, prepandPath);
- libPrepPathList.add(resource);
- }
- }
- } else if (fieldName.equals(LibraryPrepandPathConstants.NAME)) {
- generator.setParameter(LibraryPrepandPathConstants.NAME, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- LibraryPrepandPath prepandPath = (LibraryPrepandPath) result;
- LibraryPrepandPathAppCatalogResourceAppCat resource =
- (LibraryPrepandPathAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.LIBRARY_PREPAND_PATH, prepandPath);
- libPrepPathList.add(resource);
- }
- }
- }else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for libraryPrepandPath resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for libraryPrepandPath resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return libPrepPathList;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- logger.error("Unsupported for objects with a composite identifier");
- throw new AppCatalogException("Unsupported for objects with a composite identifier");
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- LibraryPrepandPath existigPrepPath = em.find(LibraryPrepandPath.class, new LibraryPrepandPath_PK(deploymentId, name));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- ApplicationDeployment deployment = em.find(ApplicationDeployment.class, deploymentId);
- if (existigPrepPath != null){
- existigPrepPath.setValue(value);
- existigPrepPath.setApplicationDeployment(deployment);
- em.merge(existigPrepPath);
- }else {
- LibraryPrepandPath prepandPath = new LibraryPrepandPath();
- prepandPath.setDeploymentID(deploymentId);
- prepandPath.setName(name);
- prepandPath.setValue(value);
- prepandPath.setApplicationDeployment(deployment);
- em.persist(prepandPath);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map){
- ids = (HashMap)identifier;
- }else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- LibraryPrepandPath prepandPath = em.find(LibraryPrepandPath.class,
- new LibraryPrepandPath_PK(ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID),
- ids.get(LibraryPrepandPathConstants.NAME)));
- em.close();
- return prepandPath != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-}
[11/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/GatewayRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/GatewayRegistry.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/GatewayRegistry.java
index d97f0d4..4fb29e5 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/GatewayRegistry.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/GatewayRegistry.java
@@ -26,7 +26,7 @@ import org.apache.airavata.common.utils.ServerSettings;
import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource;
import org.apache.airavata.registry.core.experiment.catalog.utils.ThriftDataModelConversion;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
@@ -38,17 +38,17 @@ import java.util.List;
public class GatewayRegistry {
private final static Logger logger = LoggerFactory.getLogger(GatewayRegistry.class);
- public GatewayExperimentCatResource getDefaultGateway () throws ApplicationSettingsException, RegistryException {
- return (GatewayExperimentCatResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
+ public GatewayResource getDefaultGateway () throws ApplicationSettingsException, RegistryException {
+ return (GatewayResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
}
- public GatewayExperimentCatResource getExistingGateway (String gatewayName) throws RegistryException {
- return (GatewayExperimentCatResource) ExpCatResourceUtils.getGateway(gatewayName);
+ public GatewayResource getExistingGateway (String gatewayName) throws RegistryException {
+ return (GatewayResource) ExpCatResourceUtils.getGateway(gatewayName);
}
public String addGateway (Gateway gateway) throws RegistryException{
try {
- GatewayExperimentCatResource resource = (GatewayExperimentCatResource) ExpCatResourceUtils.createGateway(gateway.getGatewayId());
+ GatewayResource resource = (GatewayResource) ExpCatResourceUtils.createGateway(gateway.getGatewayId());
resource.setGatewayName(gateway.getGatewayName());
resource.setEmailAddress(gateway.getEmailAddress());
resource.setDomain(gateway.getDomain());
@@ -62,7 +62,7 @@ public class GatewayRegistry {
public void updateGateway (String gatewayId, Gateway updatedGateway) throws RegistryException{
try {
- GatewayExperimentCatResource existingGateway = (GatewayExperimentCatResource) ExpCatResourceUtils.getGateway(gatewayId);
+ GatewayResource existingGateway = (GatewayResource) ExpCatResourceUtils.getGateway(gatewayId);
existingGateway.setGatewayName(updatedGateway.getGatewayName());
existingGateway.setEmailAddress(updatedGateway.getEmailAddress());
existingGateway.setDomain(updatedGateway.getDomain());
@@ -75,7 +75,7 @@ public class GatewayRegistry {
public Gateway getGateway (String gatewayId) throws RegistryException{
try {
- GatewayExperimentCatResource resource = (GatewayExperimentCatResource) ExpCatResourceUtils.getGateway(gatewayId);
+ GatewayResource resource = (GatewayResource) ExpCatResourceUtils.getGateway(gatewayId);
return ThriftDataModelConversion.getGateway(resource);
}catch (RegistryException e){
logger.error("Error while getting gateway", e);
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java
index f0c4965..9e6ec07 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java
@@ -36,20 +36,20 @@ import org.slf4j.LoggerFactory;
import java.util.*;
public class ProjectRegistry {
- private GatewayExperimentCatResource gatewayResource;
- private WorkerExperimentCatResource workerResource;
+ private GatewayResource gatewayResource;
+ private WorkerResource workerResource;
private final static Logger logger = LoggerFactory.getLogger(ProjectRegistry.class);
- public ProjectRegistry(GatewayExperimentCatResource gatewayResource, UserExperimentCatResource user) throws RegistryException {
+ public ProjectRegistry(GatewayResource gatewayResource, UserResource user) throws RegistryException {
if (!ExpCatResourceUtils.isGatewayExist(gatewayResource.getGatewayId())){
this.gatewayResource = gatewayResource;
}else {
- this.gatewayResource = (GatewayExperimentCatResource) ExpCatResourceUtils.getGateway(gatewayResource.getGatewayId());
+ this.gatewayResource = (GatewayResource) ExpCatResourceUtils.getGateway(gatewayResource.getGatewayId());
}
if (!gatewayResource.isExists(ResourceType.GATEWAY_WORKER, user.getUserName())){
workerResource = ExpCatResourceUtils.addGatewayWorker(gatewayResource, user);
}else {
- workerResource = (WorkerExperimentCatResource) ExpCatResourceUtils.getWorker(gatewayResource.getGatewayId(),
+ workerResource = (WorkerResource) ExpCatResourceUtils.getWorker(gatewayResource.getGatewayId(),
user.getUserName());
}
}
@@ -60,7 +60,7 @@ public class ProjectRegistry {
if (!ExpCatResourceUtils.isUserExist(project.getOwner())){
ExpCatResourceUtils.addUser(project.getOwner(), null);
}
- ProjectExperimentCatResource projectResource = new ProjectExperimentCatResource();
+ ProjectResource projectResource = new ProjectResource();
projectId = getProjectId(project.getName());
projectResource.setId(projectId);
project.setProjectID(projectId);
@@ -68,10 +68,10 @@ public class ProjectRegistry {
projectResource.setDescription(project.getDescription());
projectResource.setCreationTime(AiravataUtils.getTime(project.getCreationTime()));
projectResource.setGatewayId(gatewayId);
- WorkerExperimentCatResource worker = new WorkerExperimentCatResource(project.getOwner(), gatewayId);
+ WorkerResource worker = new WorkerResource(project.getOwner(), gatewayId);
projectResource.setWorker(worker);
projectResource.save();
- ProjectUserExperimentCatResource resource = (ProjectUserExperimentCatResource)projectResource.create(
+ ProjectUserResource resource = (ProjectUserResource)projectResource.create(
ResourceType.PROJECT_USER);
resource.setProjectId(project.getProjectID());
resource.setUserName(project.getOwner());
@@ -87,7 +87,7 @@ public class ProjectRegistry {
List<String> sharedUsers = project.getSharedUsers();
if (sharedUsers != null && !sharedUsers.isEmpty()){
for (String username : sharedUsers){
- ProjectUserExperimentCatResource pr = (ProjectUserExperimentCatResource)projectResource.
+ ProjectUserResource pr = (ProjectUserResource)projectResource.
create(ResourceType.PROJECT_USER);
pr.setUserName(username);
pr.save();
@@ -107,21 +107,21 @@ public class ProjectRegistry {
public void updateProject (Project project, String projectId) throws RegistryException{
try {
- ProjectExperimentCatResource existingProject = workerResource.getProject(projectId);
+ ProjectResource existingProject = workerResource.getProject(projectId);
existingProject.setDescription(project.getDescription());
existingProject.setName(project.getName());
// existingProject.setGateway(gatewayResource);
- UserExperimentCatResource user = (UserExperimentCatResource) ExpCatResourceUtils.getUser(project.getOwner());
+ UserResource user = (UserResource) ExpCatResourceUtils.getUser(project.getOwner());
if (!gatewayResource.isExists(ResourceType.GATEWAY_WORKER, user.getUserName())){
workerResource = ExpCatResourceUtils.addGatewayWorker(gatewayResource, user);
}else {
- workerResource = (WorkerExperimentCatResource) ExpCatResourceUtils.getWorker(
+ workerResource = (WorkerResource) ExpCatResourceUtils.getWorker(
gatewayResource.getGatewayName(), user.getUserName());
}
- WorkerExperimentCatResource worker = new WorkerExperimentCatResource(project.getOwner(), gatewayResource.getGatewayId());
+ WorkerResource worker = new WorkerResource(project.getOwner(), gatewayResource.getGatewayId());
existingProject.setWorker(worker);
existingProject.save();
- ProjectUserExperimentCatResource resource = (ProjectUserExperimentCatResource)existingProject.create(
+ ProjectUserResource resource = (ProjectUserResource)existingProject.create(
ResourceType.PROJECT_USER);
resource.setProjectId(projectId);
resource.setUserName(project.getOwner());
@@ -137,7 +137,7 @@ public class ProjectRegistry {
List<String> sharedUsers = project.getSharedUsers();
if (sharedUsers != null && !sharedUsers.isEmpty()){
for (String username : sharedUsers){
- ProjectUserExperimentCatResource pr = (ProjectUserExperimentCatResource)existingProject.create(
+ ProjectUserResource pr = (ProjectUserResource)existingProject.create(
ResourceType.PROJECT_USER);
pr.setUserName(username);
pr.save();
@@ -151,7 +151,7 @@ public class ProjectRegistry {
public Project getProject (String projectId) throws RegistryException{
try {
- ProjectExperimentCatResource project = workerResource.getProject(projectId);
+ ProjectResource project = workerResource.getProject(projectId);
if (project != null){
return ThriftDataModelConversion.getProject(project);
}
@@ -190,9 +190,9 @@ public class ProjectRegistry {
try {
if (fieldName.equals(Constants.FieldConstants.ProjectConstants.OWNER)){
workerResource.setUser((String)value);
- List<ProjectExperimentCatResource> projectList = workerResource.getProjects();
+ List<ProjectResource> projectList = workerResource.getProjects();
if (projectList != null && !projectList.isEmpty()){
- for (ProjectExperimentCatResource pr : projectList){
+ for (ProjectResource pr : projectList){
projects.add(ThriftDataModelConversion.getProject(pr));
}
}
@@ -237,19 +237,19 @@ public class ProjectRegistry {
try {
for (String field : filters.keySet()){
if (field.equals(Constants.FieldConstants.ProjectConstants.PROJECT_NAME)){
- fil.put(AbstractExperimentCatResource.ProjectConstants.PROJECT_NAME, filters.get(field));
+ fil.put(AbstractExpCatResource.ProjectConstants.PROJECT_NAME, filters.get(field));
}else if (field.equals(Constants.FieldConstants.ProjectConstants.OWNER)){
- fil.put(AbstractExperimentCatResource.ProjectConstants.USERNAME, filters.get(field));
+ fil.put(AbstractExpCatResource.ProjectConstants.USERNAME, filters.get(field));
}else if (field.equals(Constants.FieldConstants.ProjectConstants.DESCRIPTION)){
- fil.put(AbstractExperimentCatResource.ProjectConstants.DESCRIPTION, filters.get(field));
+ fil.put(AbstractExpCatResource.ProjectConstants.DESCRIPTION, filters.get(field));
}else if (field.equals(Constants.FieldConstants.ProjectConstants.GATEWAY_ID)){
- fil.put(AbstractExperimentCatResource.ProjectConstants.GATEWAY_ID, filters.get(field));
+ fil.put(AbstractExpCatResource.ProjectConstants.GATEWAY_ID, filters.get(field));
}
}
- List<ProjectExperimentCatResource> projectResources = workerResource
+ List<ProjectResource> projectResources = workerResource
.searchProjects(fil, limit, offset, orderByIdentifier, resultOrderType);
if (projectResources != null && !projectResources.isEmpty()){
- for (ProjectExperimentCatResource pr : projectResources){
+ for (ProjectResource pr : projectResources){
projects.add(ThriftDataModelConversion.getProject(pr));
}
}
@@ -267,9 +267,9 @@ public class ProjectRegistry {
try {
if (fieldName.equals(Constants.FieldConstants.ProjectConstants.OWNER)){
workerResource.setUser((String)value);
- List<ProjectExperimentCatResource> projectList = workerResource.getProjects();
+ List<ProjectResource> projectList = workerResource.getProjects();
if (projectList != null && !projectList.isEmpty()){
- for (ProjectExperimentCatResource pr : projectList){
+ for (ProjectResource pr : projectList){
projectIds.add(pr.getName());
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java
index b54e0cf..9cea1c4 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/RegistryFactory.java
@@ -24,12 +24,14 @@ package org.apache.airavata.registry.core.experiment.catalog.impl;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.ServerSettings;
import org.apache.airavata.registry.cpi.ExperimentCatalog;
+import org.apache.airavata.registry.cpi.Registry;
import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RegistryFactory {
private static ExperimentCatalog experimentCatalog;
+ private static Registry registry;
private static Logger logger = LoggerFactory.getLogger(RegistryFactory.class);
public static ExperimentCatalog getRegistry(String gateway, String username, String password) throws RegistryException {
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/UserReg.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/UserReg.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/UserReg.java
index e720df0..6dd6130 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/UserReg.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/UserReg.java
@@ -24,16 +24,16 @@ package org.apache.airavata.registry.core.experiment.catalog.impl;
import org.apache.airavata.common.exception.ApplicationSettingsException;
import org.apache.airavata.common.utils.ServerSettings;
import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.resources.WorkerExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.WorkerResource;
import org.apache.airavata.registry.cpi.RegistryException;
public class UserReg {
- public WorkerExperimentCatResource getSystemUser() throws ApplicationSettingsException, RegistryException {
- return (WorkerExperimentCatResource) ExpCatResourceUtils.getWorker(ServerSettings.getDefaultUserGateway(), ServerSettings.getDefaultUser());
+ public WorkerResource getSystemUser() throws ApplicationSettingsException, RegistryException {
+ return (WorkerResource) ExpCatResourceUtils.getWorker(ServerSettings.getDefaultUserGateway(), ServerSettings.getDefaultUser());
}
- public WorkerExperimentCatResource getExistingUser (String gatewayName, String userName) throws RegistryException {
- return (WorkerExperimentCatResource) ExpCatResourceUtils.getWorker(gatewayName, userName);
+ public WorkerResource getExistingUser (String gatewayName, String userName) throws RegistryException {
+ return (WorkerResource) ExpCatResourceUtils.getWorker(gatewayName, userName);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.java
new file mode 100644
index 0000000..c1adb42
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExpCatResource.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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.cpi.RegistryException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AbstractExpCatResource implements ExperimentCatResource {
+ // 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 AbstractExpCatResource() {
+ }
+
+ 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<ExperimentCatResource> resources,
+ Class<?> T) {
+ List<T> list = new ArrayList<T>();
+ for (ExperimentCatResource o : resources) {
+ list.add((T) o);
+ }
+ return list;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExperimentCatResource.java
deleted file mode 100644
index 46bebb2..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AbstractExperimentCatResource.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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.cpi.RegistryException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class AbstractExperimentCatResource implements ExperimentCatResource {
- // 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 AbstractExperimentCatResource() {
- }
-
- 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<ExperimentCatResource> resources,
- Class<?> T) {
- List<T> list = new ArrayList<T>();
- for (ExperimentCatResource o : resources) {
- list.add((T) o);
- }
- return list;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvanceInputDataHandlingExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvanceInputDataHandlingExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvanceInputDataHandlingExperimentCatResource.java
deleted file mode 100644
index 033d2e7..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvanceInputDataHandlingExperimentCatResource.java
+++ /dev/null
@@ -1,160 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.AdvancedInputDataHandling;
-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 AdvanceInputDataHandlingExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(AdvanceInputDataHandlingExperimentCatResource.class);
- private int dataHandlingId = 0;
- private String workingDirParent;
- private String workingDir;
- private boolean stageInputFiles;
- private boolean cleanAfterJob;
- private String experimentId;
- private String taskId;
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public int getDataHandlingId() {
- return dataHandlingId;
- }
-
- public void setDataHandlingId(int dataHandlingId) {
- this.dataHandlingId = dataHandlingId;
- }
-
- 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- AdvancedInputDataHandling dataHandling;
- if (dataHandlingId != 0) {
- dataHandling = em.find(AdvancedInputDataHandling.class, dataHandlingId);
- dataHandling.setDataHandlingId(dataHandlingId);
- } else {
- dataHandling = new AdvancedInputDataHandling();
- }
- dataHandling.setWorkingDir(workingDir);
- dataHandling.setParentWorkingDir(workingDirParent);
- dataHandling.setStageInputsToWorkingDir(stageInputFiles);
- dataHandling.setCleanAfterJob(cleanAfterJob);
- dataHandling.setExpId(experimentId);
- dataHandling.setTaskId(taskId);
- 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvanceInputDataHandlingResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvanceInputDataHandlingResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvanceInputDataHandlingResource.java
new file mode 100644
index 0000000..727882f
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvanceInputDataHandlingResource.java
@@ -0,0 +1,160 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.AdvancedInputDataHandling;
+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 AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(AdvanceInputDataHandlingResource.class);
+ private int dataHandlingId = 0;
+ private String workingDirParent;
+ private String workingDir;
+ private boolean stageInputFiles;
+ private boolean cleanAfterJob;
+ private String experimentId;
+ private String taskId;
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public int getDataHandlingId() {
+ return dataHandlingId;
+ }
+
+ public void setDataHandlingId(int dataHandlingId) {
+ this.dataHandlingId = dataHandlingId;
+ }
+
+ 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for input data handling resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ AdvancedInputDataHandling dataHandling;
+ if (dataHandlingId != 0) {
+ dataHandling = em.find(AdvancedInputDataHandling.class, dataHandlingId);
+ dataHandling.setDataHandlingId(dataHandlingId);
+ } else {
+ dataHandling = new AdvancedInputDataHandling();
+ }
+ dataHandling.setWorkingDir(workingDir);
+ dataHandling.setParentWorkingDir(workingDirParent);
+ dataHandling.setStageInputsToWorkingDir(stageInputFiles);
+ dataHandling.setCleanAfterJob(cleanAfterJob);
+ dataHandling.setExpId(experimentId);
+ dataHandling.setTaskId(taskId);
+ 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvancedOutputDataHandlingExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvancedOutputDataHandlingExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvancedOutputDataHandlingExperimentCatResource.java
deleted file mode 100644
index bc3045b..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvancedOutputDataHandlingExperimentCatResource.java
+++ /dev/null
@@ -1,150 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.AdvancedOutputDataHandling;
-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 AdvancedOutputDataHandlingExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(AdvancedOutputDataHandlingExperimentCatResource.class);
- private int outputDataHandlingId = 0;
- private String outputDataDir;
- private String dataRegUrl;
- private boolean persistOutputData;
- private String experimentId;
- private String taskId;
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public int getOutputDataHandlingId() {
- return outputDataHandlingId;
- }
-
- public void setOutputDataHandlingId(int outputDataHandlingId) {
- this.outputDataHandlingId = outputDataHandlingId;
- }
-
- 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- AdvancedOutputDataHandling dataHandling;
- if (outputDataHandlingId != 0 ){
- dataHandling = em.find(AdvancedOutputDataHandling.class, outputDataHandlingId);
- dataHandling.setOutputDataHandlingId(outputDataHandlingId);
- }else {
- dataHandling = new AdvancedOutputDataHandling();
- }
- dataHandling.setDataRegUrl(dataRegUrl);
- dataHandling.setOutputDataDir(outputDataDir);
- dataHandling.setPersistOutputData(persistOutputData);
- dataHandling.setExpId(experimentId);
- dataHandling.setTaskId(taskId);
- 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvancedOutputDataHandlingResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvancedOutputDataHandlingResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvancedOutputDataHandlingResource.java
new file mode 100644
index 0000000..622eebd
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/AdvancedOutputDataHandlingResource.java
@@ -0,0 +1,150 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.AdvancedOutputDataHandling;
+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 AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(AdvancedOutputDataHandlingResource.class);
+ private int outputDataHandlingId = 0;
+ private String outputDataDir;
+ private String dataRegUrl;
+ private boolean persistOutputData;
+ private String experimentId;
+ private String taskId;
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public int getOutputDataHandlingId() {
+ return outputDataHandlingId;
+ }
+
+ public void setOutputDataHandlingId(int outputDataHandlingId) {
+ this.outputDataHandlingId = outputDataHandlingId;
+ }
+
+ 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported resource type for output data handling resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ AdvancedOutputDataHandling dataHandling;
+ if (outputDataHandlingId != 0 ){
+ dataHandling = em.find(AdvancedOutputDataHandling.class, outputDataHandlingId);
+ dataHandling.setOutputDataHandlingId(outputDataHandlingId);
+ }else {
+ dataHandling = new AdvancedOutputDataHandling();
+ }
+ dataHandling.setDataRegUrl(dataRegUrl);
+ dataHandling.setOutputDataDir(outputDataDir);
+ dataHandling.setPersistOutputData(persistOutputData);
+ dataHandling.setExpId(experimentId);
+ dataHandling.setTaskId(taskId);
+ 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputExperimentCatResource.java
deleted file mode 100644
index 6481fea..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ApplicationInputExperimentCatResource.java
+++ /dev/null
@@ -1,230 +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.registry.core.experiment.catalog.resources;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationInput;
-import org.apache.airavata.registry.core.experiment.catalog.model.ApplicationInput_PK;
-import org.apache.airavata.registry.cpi.RegistryException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ApplicationInputExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(ApplicationInputExperimentCatResource.class);
- 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;
- private String taskId;
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- 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 ExperimentCatResource 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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- logger.error("Unsupported resource type for application input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> 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 = ExpCatResourceUtils.getEntityManager();
- ApplicationInput existingInput = em.find(ApplicationInput.class, new ApplicationInput_PK(inputKey, taskId));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- ApplicationInput applicationInput = new ApplicationInput();
- applicationInput.setTaskId(taskId);
- 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.setTaskId(taskId);
- 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();
- }
- }
- }
-}
[26/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceResource.java
new file mode 100644
index 0000000..ec15ed1
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppInterfaceResource.java
@@ -0,0 +1,363 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+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 AppInterfaceResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(AppInterfaceResource.class);
+ private String interfaceId;
+ private String appName;
+ private String appDescription;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+ private String gatewayId;
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public String getInterfaceId() {
+ return interfaceId;
+ }
+
+ public void setInterfaceId(String interfaceId) {
+ this.interfaceId = interfaceId;
+ }
+
+ public String getAppName() {
+ return appName;
+ }
+
+ public void setAppName(String appName) {
+ this.appName = appName;
+ }
+
+ public String getAppDescription() {
+ return appDescription;
+ }
+
+ public void setAppDescription(String appDescription) {
+ this.appDescription = appDescription;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
+ generator.setParameter(ApplicationInterfaceConstants.INTERFACE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
+ generator.setParameter(ApplicationInterfaceConstants.INTERFACE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ ApplicationInterface applicationInterface = (ApplicationInterface) q.getSingleResult();
+ AppInterfaceResource resource =
+ (AppInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INTERFACE, applicationInterface);
+ em.getTransaction().commit();
+ em.close();
+ return resource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> resourceList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
+ List results;
+ if (fieldName.equals(ApplicationInterfaceConstants.APPLICATION_NAME)) {
+ generator.setParameter(ApplicationInterfaceConstants.APPLICATION_NAME, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInterface appInterface = (ApplicationInterface) result;
+ AppInterfaceResource resource =
+ (AppInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INTERFACE, appInterface);
+ resourceList.add(resource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for application interface.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for application interface.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ List<AppCatalogResource> resourceList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
+ generator.setParameter(ApplicationInterfaceConstants.GATEWAY_ID, gatewayId);
+ Query q = generator.selectQuery(em);
+ List results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInterface appInterface = (ApplicationInterface) result;
+ AppInterfaceResource resource =
+ (AppInterfaceResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INTERFACE, appInterface);
+ resourceList.add(resource);
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ List<String> resourceList = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
+ Query q = generator.selectQuery(em);
+ List results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInterface appInterface = (ApplicationInterface) result;
+ resourceList.add(appInterface.getInterfaceID());
+ }
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> resourceList = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INTERFACE);
+ List results;
+ if (fieldName.equals(ApplicationInterfaceConstants.APPLICATION_NAME)) {
+ generator.setParameter(ApplicationInterfaceConstants.APPLICATION_NAME, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInterface appInterface = (ApplicationInterface) result;
+ resourceList.add(appInterface.getInterfaceID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for application interface.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for application interface.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return resourceList;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationInterface existigAppInterface = em.find(ApplicationInterface.class, interfaceId);
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existigAppInterface != null){
+ existigAppInterface.setAppName(appName);
+ existigAppInterface.setAppDescription(appDescription);
+ existigAppInterface.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ existigAppInterface.setGatewayId(gatewayId);
+ em.merge(existigAppInterface);
+ }else {
+ ApplicationInterface applicationInterface = new ApplicationInterface();
+ applicationInterface.setInterfaceID(interfaceId);
+ applicationInterface.setAppName(appName);
+ applicationInterface.setAppDescription(appDescription);
+ applicationInterface.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ applicationInterface.setGatewayId(gatewayId);
+ em.persist(applicationInterface);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationInterface existigAppInterface = em.find(ApplicationInterface.class, identifier);
+ em.close();
+ return existigAppInterface != null;
+ }catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleAppCatalogResourceAppCat.java
deleted file mode 100644
index 3021cee..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,344 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationModule;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-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 AppModuleAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(AppModuleAppCatalogResourceAppCat.class);
- private String moduleId;
- private String moduleName;
- private String moduleVersion;
- private String moduleDesc;
- private Timestamp createdTime;
- private Timestamp updatedTime;
- private String gatewayId;
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- public String getModuleId() {
- return moduleId;
- }
-
- public void setModuleId(String moduleId) {
- this.moduleId = moduleId;
- }
-
- public String getModuleName() {
- return moduleName;
- }
-
- public void setModuleName(String moduleName) {
- this.moduleName = moduleName;
- }
-
- public String getModuleVersion() {
- return moduleVersion;
- }
-
- public void setModuleVersion(String moduleVersion) {
- this.moduleVersion = moduleVersion;
- }
-
- public String getModuleDesc() {
- return moduleDesc;
- }
-
- public void setModuleDesc(String moduleDesc) {
- this.moduleDesc = moduleDesc;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APPLICATION_MODULE);
- generator.setParameter(ApplicationModuleConstants.MODULE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
- generator.setParameter(ApplicationModuleConstants.MODULE_ID, identifier);
- Query q = generator.selectQuery(em);
- ApplicationModule applicationModule = (ApplicationModule) q.getSingleResult();
- AppModuleAppCatalogResourceAppCat appModuleResource =
- (AppModuleAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
- em.getTransaction().commit();
- em.close();
- return appModuleResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> moduleResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
- List results;
- if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
- generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationModule applicationModule = (ApplicationModule) result;
- AppModuleAppCatalogResourceAppCat moduleResource =
- (AppModuleAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
- moduleResources.add(moduleResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for app module resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return moduleResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- List<AppCatalogResource> appModuleResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
- generator.setParameter(ApplicationModuleConstants.GATEWAY_ID, gatewayId);
- Query q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- ApplicationModule module = (ApplicationModule) result;
- AppModuleAppCatalogResourceAppCat appModuleResource = (AppModuleAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, module);
- appModuleResources.add(appModuleResource);
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appModuleResources;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> moduleResources = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
- List results;
- if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
- generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationModule applicationModule = (ApplicationModule) result;
- moduleResources.add(applicationModule.getModuleID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for app module resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return moduleResources;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationModule existingModule = em.find(ApplicationModule.class, moduleId);
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingModule != null){
- existingModule.setModuleName(moduleName);
- existingModule.setModuleVersion(moduleVersion);
- existingModule.setModuleDesc(moduleDesc);
- existingModule.setGatewayId(gatewayId);
- existingModule.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- em.merge(existingModule);
- }else {
- ApplicationModule applicationModule = new ApplicationModule();
- applicationModule.setModuleID(moduleId);
- applicationModule.setModuleName(moduleName);
- applicationModule.setModuleVersion(moduleVersion);
- applicationModule.setModuleDesc(moduleDesc);
- applicationModule.setGatewayId(gatewayId);
- applicationModule.setCreationTime(AiravataUtils.getCurrentTimestamp());
- em.persist(applicationModule);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationModule applicationModule = em.find(ApplicationModule.class, identifier);
- em.close();
- return applicationModule != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
index 12d32a0..49cdd8b 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleMappingAppCatalogResourceAppCat.java
@@ -44,8 +44,8 @@ public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractReso
private final static Logger logger = LoggerFactory.getLogger(AppModuleMappingAppCatalogResourceAppCat.class);
private String interfaceId;
private String moduleId;
- private AppInterfaceAppCatalogResourceAppCat appInterfaceResource;
- private AppModuleAppCatalogResourceAppCat moduleResource;
+ private AppInterfaceResource appInterfaceResource;
+ private AppModuleResource moduleResource;
public String getModuleId() {
@@ -64,19 +64,19 @@ public class AppModuleMappingAppCatalogResourceAppCat extends AppCatAbstractReso
this.interfaceId = interfaceId;
}
- public AppInterfaceAppCatalogResourceAppCat getAppInterfaceResource() {
+ public AppInterfaceResource getAppInterfaceResource() {
return appInterfaceResource;
}
- public void setAppInterfaceResource(AppInterfaceAppCatalogResourceAppCat appInterfaceResource) {
+ public void setAppInterfaceResource(AppInterfaceResource appInterfaceResource) {
this.appInterfaceResource = appInterfaceResource;
}
- public AppModuleAppCatalogResourceAppCat getModuleResource() {
+ public AppModuleResource getModuleResource() {
return moduleResource;
}
- public void setModuleResource(AppModuleAppCatalogResourceAppCat moduleResource) {
+ public void setModuleResource(AppModuleResource moduleResource) {
this.moduleResource = moduleResource;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
new file mode 100644
index 0000000..ea1400e
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppModuleResource.java
@@ -0,0 +1,344 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationModule;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+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 AppModuleResource extends AppCatAbstractResource {
+ private final static Logger logger = LoggerFactory.getLogger(AppModuleResource.class);
+ private String moduleId;
+ private String moduleName;
+ private String moduleVersion;
+ private String moduleDesc;
+ private Timestamp createdTime;
+ private Timestamp updatedTime;
+ private String gatewayId;
+
+ public String getGatewayId() {
+ return gatewayId;
+ }
+
+ public void setGatewayId(String gatewayId) {
+ this.gatewayId = gatewayId;
+ }
+
+ public Timestamp getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(Timestamp createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public Timestamp getUpdatedTime() {
+ return updatedTime;
+ }
+
+ public void setUpdatedTime(Timestamp updatedTime) {
+ this.updatedTime = updatedTime;
+ }
+
+ public String getModuleId() {
+ return moduleId;
+ }
+
+ public void setModuleId(String moduleId) {
+ this.moduleId = moduleId;
+ }
+
+ public String getModuleName() {
+ return moduleName;
+ }
+
+ public void setModuleName(String moduleName) {
+ this.moduleName = moduleName;
+ }
+
+ public String getModuleVersion() {
+ return moduleVersion;
+ }
+
+ public void setModuleVersion(String moduleVersion) {
+ this.moduleVersion = moduleVersion;
+ }
+
+ public String getModuleDesc() {
+ return moduleDesc;
+ }
+
+ public void setModuleDesc(String moduleDesc) {
+ this.moduleDesc = moduleDesc;
+ }
+
+ @Override
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APPLICATION_MODULE);
+ generator.setParameter(ApplicationModuleConstants.MODULE_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+ generator.setParameter(ApplicationModuleConstants.MODULE_ID, identifier);
+ Query q = generator.selectQuery(em);
+ ApplicationModule applicationModule = (ApplicationModule) q.getSingleResult();
+ AppModuleResource appModuleResource =
+ (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
+ em.getTransaction().commit();
+ em.close();
+ return appModuleResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> moduleResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+ List results;
+ if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
+ generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationModule applicationModule = (ApplicationModule) result;
+ AppModuleResource moduleResource =
+ (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, applicationModule);
+ moduleResources.add(moduleResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for app module resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return moduleResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ List<AppCatalogResource> appModuleResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+ generator.setParameter(ApplicationModuleConstants.GATEWAY_ID, gatewayId);
+ Query q = generator.selectQuery(em);
+ List<?> results = q.getResultList();
+ for (Object result : results) {
+ ApplicationModule module = (ApplicationModule) result;
+ AppModuleResource appModuleResource = (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE, module);
+ appModuleResources.add(appModuleResource);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appModuleResources;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> moduleResources = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+ List results;
+ if (fieldName.equals(ApplicationModuleConstants.MODULE_NAME)) {
+ generator.setParameter(ApplicationModuleConstants.MODULE_NAME, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationModule applicationModule = (ApplicationModule) result;
+ moduleResources.add(applicationModule.getModuleID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for app module resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for app module resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return moduleResources;
+ }
+
+ @Override
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationModule existingModule = em.find(ApplicationModule.class, moduleId);
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingModule != null){
+ existingModule.setModuleName(moduleName);
+ existingModule.setModuleVersion(moduleVersion);
+ existingModule.setModuleDesc(moduleDesc);
+ existingModule.setGatewayId(gatewayId);
+ existingModule.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+ em.merge(existingModule);
+ }else {
+ ApplicationModule applicationModule = new ApplicationModule();
+ applicationModule.setModuleID(moduleId);
+ applicationModule.setModuleName(moduleName);
+ applicationModule.setModuleVersion(moduleVersion);
+ applicationModule.setModuleDesc(moduleDesc);
+ applicationModule.setGatewayId(gatewayId);
+ applicationModule.setCreationTime(AiravataUtils.getCurrentTimestamp());
+ em.persist(applicationModule);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()){
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationModule applicationModule = em.find(ApplicationModule.class, identifier);
+ em.close();
+ return applicationModule != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputAppCatalogResourceAppCat.java
deleted file mode 100644
index 412b2c1..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,454 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.AppInput_PK;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationInput;
-import org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ApplicationInputAppCatalogResourceAppCat extends AppCatAbstractResource {
-
- private final static Logger logger = LoggerFactory.getLogger(ApplicationInputAppCatalogResourceAppCat.class);
-
- private String interfaceID;
- private String inputKey;
- private String dataType;
- private String inputVal;
- private String metadata;
- private String appArgument;
- private String userFriendlyDesc;
- private int inputOrder;
- private boolean standardInput;
- private boolean isRequired;
- private boolean requiredToCMD;
- private boolean dataStaged;
-
- private AppInterfaceAppCatalogResourceAppCat appInterfaceResource;
-
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
- generator.setParameter(AppInputConstants.INTERFACE_ID, ids.get(AppInputConstants.INTERFACE_ID));
- if (ids.get(AppInputConstants.INPUT_KEY) != null){
- generator.setParameter(AppInputConstants.INPUT_KEY, ids.get(AppInputConstants.INPUT_KEY));
- }
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
- generator.setParameter(AppInputConstants.INTERFACE_ID, ids.get(AppInputConstants.INTERFACE_ID));
- generator.setParameter(AppInputConstants.INPUT_KEY, ids.get(AppInputConstants.INPUT_KEY));
- Query q = generator.selectQuery(em);
- ApplicationInput applicationInput = (ApplicationInput) q.getSingleResult();
- ApplicationInputAppCatalogResourceAppCat applicationInputResource =
- (ApplicationInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INPUT
- , applicationInput);
- em.getTransaction().commit();
- em.close();
- return applicationInputResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> appInputResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
- List results;
- if (fieldName.equals(AppInputConstants.INTERFACE_ID)) {
- generator.setParameter(AppInputConstants.INTERFACE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInput applicationInput = (ApplicationInput) result;
- ApplicationInputAppCatalogResourceAppCat applicationInputResource =
- (ApplicationInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.APPLICATION_INPUT, applicationInput);
- appInputResources.add(applicationInputResource);
- }
- }
- } else if (fieldName.equals(AppInputConstants.INPUT_KEY)) {
- generator.setParameter(AppInputConstants.INPUT_KEY, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInput applicationInput = (ApplicationInput) result;
- ApplicationInputAppCatalogResourceAppCat applicationInputResource =
- (ApplicationInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.APPLICATION_INPUT, applicationInput);
- appInputResources.add(applicationInputResource);
- }
- }
- } else if (fieldName.equals(AppInputConstants.DATA_TYPE)) {
- generator.setParameter(AppInputConstants.DATA_TYPE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInput applicationInput = (ApplicationInput) result;
- ApplicationInputAppCatalogResourceAppCat applicationInputResource =
- (ApplicationInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.APPLICATION_INPUT, applicationInput);
- appInputResources.add(applicationInputResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for AppInput Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for AppInput Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appInputResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> appInputResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
- List results;
- if (fieldName.equals(AppInputConstants.INTERFACE_ID)) {
- generator.setParameter(AppInputConstants.INTERFACE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInput applicationInput = (ApplicationInput) result;
- appInputResourceIDs.add(applicationInput.getInterfaceID());
- }
- }
- } else if (fieldName.equals(AppInputConstants.INPUT_KEY)) {
- generator.setParameter(AppInputConstants.INPUT_KEY, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInput applicationInput = (ApplicationInput) result;
- appInputResourceIDs.add(applicationInput.getInterfaceID());
- }
- }
- } else if (fieldName.equals(AppInputConstants.DATA_TYPE)) {
- generator.setParameter(AppInputConstants.DATA_TYPE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ApplicationInput applicationInput = (ApplicationInput) result;
- appInputResourceIDs.add(applicationInput.getInterfaceID());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for AppInput resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for AppInput Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return appInputResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationInput existingApplicationInput = em.find(ApplicationInput.class, new AppInput_PK(interfaceID, inputKey));
- em.close();
- ApplicationInput applicationInput;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingApplicationInput == null) {
- applicationInput = new ApplicationInput();
- } else {
- applicationInput=existingApplicationInput;
- }
- ApplicationInterface applicationInterface = em.find(ApplicationInterface.class, interfaceID);
- applicationInput.setApplicationInterface(applicationInterface);
- applicationInput.setInterfaceID(applicationInterface.getInterfaceID());
- applicationInput.setDataType(dataType);
- applicationInput.setInputKey(inputKey);
- applicationInput.setInputVal(inputVal);
- applicationInput.setMetadata(metadata);
- applicationInput.setAppArgument(appArgument);
- applicationInput.setUserFriendlyDesc(userFriendlyDesc);
- applicationInput.setStandardInput(standardInput);
- applicationInput.setInputOrder(inputOrder);
- applicationInput.setRequiredToCMD(requiredToCMD);
- applicationInput.setRequired(isRequired);
- applicationInput.setDataStaged(dataStaged);
- if (existingApplicationInput == null) {
- em.persist(applicationInput);
- } else {
- em.merge(applicationInput);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- ApplicationInput applicationInput = em.find(ApplicationInput.class, new AppInput_PK(
- ids.get(AppInputConstants.INTERFACE_ID),
- ids.get(AppInputConstants.INPUT_KEY)));
-
- em.close();
- return applicationInput != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getInterfaceID() {
- return interfaceID;
- }
-
- public void setInterfaceID(String interfaceID) {
- this.interfaceID = interfaceID;
- }
-
- 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 getInputVal() {
- return inputVal;
- }
-
- public void setInputVal(String inputVal) {
- this.inputVal = inputVal;
- }
-
- public String getMetadata() {
- return metadata;
- }
-
- public void setMetadata(String metadata) {
- this.metadata = metadata;
- }
-
- public String getAppArgument() {
- return appArgument;
- }
-
- public void setAppArgument(String appArgument) {
- this.appArgument = appArgument;
- }
-
- public String getUserFriendlyDesc() {
- return userFriendlyDesc;
- }
-
- public void setUserFriendlyDesc(String userFriendlyDesc) {
- this.userFriendlyDesc = userFriendlyDesc;
- }
-
- public AppInterfaceAppCatalogResourceAppCat getAppInterfaceResource() {
- return appInterfaceResource;
- }
-
- public void setAppInterfaceResource(AppInterfaceAppCatalogResourceAppCat appInterfaceResource) {
- this.appInterfaceResource = appInterfaceResource;
- }
-
- public boolean isStandardInput() {
- return standardInput;
- }
-
- public void setStandardInput(boolean standardInput) {
- this.standardInput = standardInput;
- }
-
- public int getInputOrder() {
- return inputOrder;
- }
-
- public void setInputOrder(int inputOrder) {
- this.inputOrder = inputOrder;
- }
-
- public boolean getRequired() {
- return isRequired;
- }
-
- public void setRequired(boolean required) {
- this.isRequired = required;
- }
-
- public boolean getRequiredToCMD() {
- return requiredToCMD;
- }
-
- public void setRequiredToCMD(boolean requiredToCMD) {
- this.requiredToCMD = requiredToCMD;
- }
-
- public boolean isDataStaged() {
- return dataStaged;
- }
-
- public void setDataStaged(boolean dataStaged) {
- this.dataStaged = dataStaged;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputResource.java
new file mode 100644
index 0000000..36c52a0
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ApplicationInputResource.java
@@ -0,0 +1,454 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.AppInput_PK;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationInput;
+import org.apache.airavata.registry.core.app.catalog.model.ApplicationInterface;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ApplicationInputResource extends AppCatAbstractResource {
+
+ private final static Logger logger = LoggerFactory.getLogger(ApplicationInputResource.class);
+
+ private String interfaceID;
+ private String inputKey;
+ private String dataType;
+ private String inputVal;
+ private String metadata;
+ private String appArgument;
+ private String userFriendlyDesc;
+ private int inputOrder;
+ private boolean standardInput;
+ private boolean isRequired;
+ private boolean requiredToCMD;
+ private boolean dataStaged;
+
+ private AppInterfaceResource appInterfaceResource;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
+ generator.setParameter(AppInputConstants.INTERFACE_ID, ids.get(AppInputConstants.INTERFACE_ID));
+ if (ids.get(AppInputConstants.INPUT_KEY) != null){
+ generator.setParameter(AppInputConstants.INPUT_KEY, ids.get(AppInputConstants.INPUT_KEY));
+ }
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
+ generator.setParameter(AppInputConstants.INTERFACE_ID, ids.get(AppInputConstants.INTERFACE_ID));
+ generator.setParameter(AppInputConstants.INPUT_KEY, ids.get(AppInputConstants.INPUT_KEY));
+ Query q = generator.selectQuery(em);
+ ApplicationInput applicationInput = (ApplicationInput) q.getSingleResult();
+ ApplicationInputResource applicationInputResource =
+ (ApplicationInputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_INPUT
+ , applicationInput);
+ em.getTransaction().commit();
+ em.close();
+ return applicationInputResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> appInputResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
+ List results;
+ if (fieldName.equals(AppInputConstants.INTERFACE_ID)) {
+ generator.setParameter(AppInputConstants.INTERFACE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInput applicationInput = (ApplicationInput) result;
+ ApplicationInputResource applicationInputResource =
+ (ApplicationInputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.APPLICATION_INPUT, applicationInput);
+ appInputResources.add(applicationInputResource);
+ }
+ }
+ } else if (fieldName.equals(AppInputConstants.INPUT_KEY)) {
+ generator.setParameter(AppInputConstants.INPUT_KEY, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInput applicationInput = (ApplicationInput) result;
+ ApplicationInputResource applicationInputResource =
+ (ApplicationInputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.APPLICATION_INPUT, applicationInput);
+ appInputResources.add(applicationInputResource);
+ }
+ }
+ } else if (fieldName.equals(AppInputConstants.DATA_TYPE)) {
+ generator.setParameter(AppInputConstants.DATA_TYPE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInput applicationInput = (ApplicationInput) result;
+ ApplicationInputResource applicationInputResource =
+ (ApplicationInputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.APPLICATION_INPUT, applicationInput);
+ appInputResources.add(applicationInputResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for AppInput Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for AppInput Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appInputResources;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> appInputResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
+ List results;
+ if (fieldName.equals(AppInputConstants.INTERFACE_ID)) {
+ generator.setParameter(AppInputConstants.INTERFACE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInput applicationInput = (ApplicationInput) result;
+ appInputResourceIDs.add(applicationInput.getInterfaceID());
+ }
+ }
+ } else if (fieldName.equals(AppInputConstants.INPUT_KEY)) {
+ generator.setParameter(AppInputConstants.INPUT_KEY, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInput applicationInput = (ApplicationInput) result;
+ appInputResourceIDs.add(applicationInput.getInterfaceID());
+ }
+ }
+ } else if (fieldName.equals(AppInputConstants.DATA_TYPE)) {
+ generator.setParameter(AppInputConstants.DATA_TYPE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ ApplicationInput applicationInput = (ApplicationInput) result;
+ appInputResourceIDs.add(applicationInput.getInterfaceID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for AppInput resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for AppInput Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return appInputResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationInput existingApplicationInput = em.find(ApplicationInput.class, new AppInput_PK(interfaceID, inputKey));
+ em.close();
+ ApplicationInput applicationInput;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingApplicationInput == null) {
+ applicationInput = new ApplicationInput();
+ } else {
+ applicationInput=existingApplicationInput;
+ }
+ ApplicationInterface applicationInterface = em.find(ApplicationInterface.class, interfaceID);
+ applicationInput.setApplicationInterface(applicationInterface);
+ applicationInput.setInterfaceID(applicationInterface.getInterfaceID());
+ applicationInput.setDataType(dataType);
+ applicationInput.setInputKey(inputKey);
+ applicationInput.setInputVal(inputVal);
+ applicationInput.setMetadata(metadata);
+ applicationInput.setAppArgument(appArgument);
+ applicationInput.setUserFriendlyDesc(userFriendlyDesc);
+ applicationInput.setStandardInput(standardInput);
+ applicationInput.setInputOrder(inputOrder);
+ applicationInput.setRequiredToCMD(requiredToCMD);
+ applicationInput.setRequired(isRequired);
+ applicationInput.setDataStaged(dataStaged);
+ if (existingApplicationInput == null) {
+ em.persist(applicationInput);
+ } else {
+ em.merge(applicationInput);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ ApplicationInput applicationInput = em.find(ApplicationInput.class, new AppInput_PK(
+ ids.get(AppInputConstants.INTERFACE_ID),
+ ids.get(AppInputConstants.INPUT_KEY)));
+
+ em.close();
+ return applicationInput != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getInterfaceID() {
+ return interfaceID;
+ }
+
+ public void setInterfaceID(String interfaceID) {
+ this.interfaceID = interfaceID;
+ }
+
+ 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 getInputVal() {
+ return inputVal;
+ }
+
+ public void setInputVal(String inputVal) {
+ this.inputVal = inputVal;
+ }
+
+ public String getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(String metadata) {
+ this.metadata = metadata;
+ }
+
+ public String getAppArgument() {
+ return appArgument;
+ }
+
+ public void setAppArgument(String appArgument) {
+ this.appArgument = appArgument;
+ }
+
+ public String getUserFriendlyDesc() {
+ return userFriendlyDesc;
+ }
+
+ public void setUserFriendlyDesc(String userFriendlyDesc) {
+ this.userFriendlyDesc = userFriendlyDesc;
+ }
+
+ public AppInterfaceResource getAppInterfaceResource() {
+ return appInterfaceResource;
+ }
+
+ public void setAppInterfaceResource(AppInterfaceResource appInterfaceResource) {
+ this.appInterfaceResource = appInterfaceResource;
+ }
+
+ public boolean isStandardInput() {
+ return standardInput;
+ }
+
+ public void setStandardInput(boolean standardInput) {
+ this.standardInput = standardInput;
+ }
+
+ public int getInputOrder() {
+ return inputOrder;
+ }
+
+ public void setInputOrder(int inputOrder) {
+ this.inputOrder = inputOrder;
+ }
+
+ public boolean getRequired() {
+ return isRequired;
+ }
+
+ public void setRequired(boolean required) {
+ this.isRequired = required;
+ }
+
+ public boolean getRequiredToCMD() {
+ return requiredToCMD;
+ }
+
+ public void setRequiredToCMD(boolean requiredToCMD) {
+ this.requiredToCMD = requiredToCMD;
+ }
+
+ public boolean isDataStaged() {
+ return dataStaged;
+ }
+
+ public void setDataStaged(boolean dataStaged) {
+ this.dataStaged = dataStaged;
+ }
+}
[15/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionResource.java
new file mode 100644
index 0000000..f5b9760
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/UnicoreJobSubmissionResource.java
@@ -0,0 +1,328 @@
+/*
+ *
+ * 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.registry.core.app.catalog.resources;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.GlobusJobSubmission;
+import org.apache.airavata.registry.core.app.catalog.model.UnicoreJobSubmission;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UnicoreJobSubmissionResource extends AppCatAbstractResource {
+
+ private final static Logger logger = LoggerFactory.getLogger(UnicoreJobSubmissionResource.class);
+
+ private String jobSubmissionInterfaceId;
+ private String securityProtocol;
+ private String unicoreEndpointUrl;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
+ generator.setParameter(UnicoreJobSubmissionConstants.SUBMISSION_ID, identifier);
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
+ generator.setParameter(UnicoreJobSubmissionConstants.SUBMISSION_ID, identifier);
+ Query q = generator.selectQuery(em);
+ UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) q.getSingleResult();
+ UnicoreJobSubmissionResource unicoreSubmissionResource =
+ (UnicoreJobSubmissionResource) AppCatalogJPAUtils
+ .getResource(AppCatalogResourceType.UNICORE_JOB_SUBMISSION,
+ unicoreJobSubmission);
+ em.getTransaction().commit();
+ em.close();
+ return unicoreSubmissionResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> unicoreSubmissionResourceList = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(UNICORE_JOB_SUBMISSION);
+ List results;
+ if (fieldName.equals(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL)) {
+ generator.setParameter(UnicoreJobSubmissionConstants.UNICORE_ENDPOINT_URL, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) result;
+ UnicoreJobSubmissionResource unicoreJobSubmissionResource =
+ (UnicoreJobSubmissionResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
+ unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
+ }
+ }
+ } else if (fieldName.equals(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL)) {
+ generator.setParameter(UnicoreJobSubmissionConstants.SECURITY_PROTOCAL, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ UnicoreJobSubmission unicoreJobSubmission = (UnicoreJobSubmission) result;
+ UnicoreJobSubmissionResource unicoreJobSubmissionResource =
+ (UnicoreJobSubmissionResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.UNICORE_JOB_SUBMISSION, unicoreJobSubmission);
+ unicoreSubmissionResourceList.add(unicoreJobSubmissionResource);
+ }
+ }
+ }
+ else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Unicore submission resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Unicore Submission resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return unicoreSubmissionResourceList;
+ }
+
+ @Override
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getAllIds() throws AppCatalogException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> globusSubmissionResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(GLOBUS_SUBMISSION);
+ List results;
+ if (fieldName.equals(GlobusJobSubmissionConstants.SUBMISSION_ID)) {
+ generator.setParameter(GlobusJobSubmissionConstants.SUBMISSION_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP)) {
+ generator.setParameter(GlobusJobSubmissionConstants.GLOBUS_GATEKEEPER_EP, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+ }
+ }
+ }
+ else if (fieldName.equals(GlobusJobSubmissionConstants.SECURITY_PROTOCAL)) {
+ generator.setParameter(GlobusJobSubmissionConstants.SECURITY_PROTOCAL, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+ }
+ }
+ } else if (fieldName.equals(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER)) {
+ generator.setParameter(GlobusJobSubmissionConstants.RESOURCE_JOB_MANAGER, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ GlobusJobSubmission globusJobSubmission = (GlobusJobSubmission) result;
+ globusSubmissionResourceIDs.add(globusJobSubmission.getSubmissionID());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for Globus Submission resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for Globus Submission resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return globusSubmissionResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ UnicoreJobSubmission existingUnicoreSubmission = em.find(UnicoreJobSubmission.class, jobSubmissionInterfaceId);
+ em.close();
+
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingUnicoreSubmission != null) {
+ existingUnicoreSubmission.setSubmissionID(jobSubmissionInterfaceId);;
+ existingUnicoreSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
+ existingUnicoreSubmission.setSecurityProtocol(securityProtocol);
+
+ em.merge(existingUnicoreSubmission);
+ } else {
+ UnicoreJobSubmission unicoreJobSubmission = new UnicoreJobSubmission();
+ unicoreJobSubmission.setSubmissionID(jobSubmissionInterfaceId);
+ unicoreJobSubmission.setUnicoreEndpointUrl(unicoreEndpointUrl);
+ unicoreJobSubmission.setSecurityProtocol(securityProtocol);
+ em.persist(unicoreJobSubmission);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ UnicoreJobSubmission unicoreJobSubmission = em.find(UnicoreJobSubmission.class, identifier);
+ em.close();
+ return unicoreJobSubmission != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+
+ public String getjobSubmissionInterfaceId() {
+ return jobSubmissionInterfaceId;
+ }
+
+ public void setjobSubmissionInterfaceId(String jobSubmissionInterfaceId) {
+ this.jobSubmissionInterfaceId = jobSubmissionInterfaceId;
+ }
+
+ public String getSecurityProtocol() {
+ return securityProtocol;
+ }
+
+ public void setSecurityProtocol(String securityProtocol) {
+ this.securityProtocol = securityProtocol;
+ }
+
+ public String getUnicoreEndpointUrl() {
+ return unicoreEndpointUrl;
+ }
+
+ public void setUnicoreEndpointUrl(String unicoreEndpointUrl) {
+ this.unicoreEndpointUrl = unicoreEndpointUrl;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowAppCatalogResourceAppCat.java
deleted file mode 100644
index ffc0fff..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,382 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.registry.core.app.catalog.model.Workflow;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-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 WorkflowAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(WorkflowAppCatalogResourceAppCat.class);
- private String wfName;
- private String createdUser;
- private String graph;
- private String wfTemplateId;
- private Timestamp createdTime;
- private Timestamp updatedTime;
- private String image;
- private String gatewayId;
-
- public Timestamp getCreatedTime() {
- return createdTime;
- }
-
- public void setCreatedTime(Timestamp createdTime) {
- this.createdTime = createdTime;
- }
-
- public Timestamp getUpdatedTime() {
- return updatedTime;
- }
-
- public void setUpdatedTime(Timestamp updatedTime) {
- this.updatedTime = updatedTime;
- }
-
- public String getImage() {
- return image;
- }
-
- public void setImage(String image) {
- this.image = image;
- }
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- @Override
- public void remove(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- generator.setParameter(WorkflowConstants.WF_TEMPLATE_ID, identifier);
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- generator.setParameter(WorkflowConstants.WF_TEMPLATE_ID, identifier);
- Query q = generator.selectQuery(em);
- Workflow workflow = (Workflow) q.getSingleResult();
- WorkflowAppCatalogResourceAppCat workflowResource = (WorkflowAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
- em.getTransaction().commit();
- em.close();
- return workflowResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> workflowResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- Query q;
- if ((fieldName.equals(WorkflowConstants.WF_NAME)) || (fieldName.equals(WorkflowConstants.CREATED_USER)) || (fieldName.equals(WorkflowConstants.GRAPH)) || (fieldName.equals(WorkflowConstants.WF_TEMPLATE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- Workflow workflow = (Workflow) result;
- WorkflowAppCatalogResourceAppCat workflowResource = (WorkflowAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
- workflowResources.add(workflowResource);
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return workflowResources;
- }
-
- @Override
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- List<AppCatalogResource> workflows = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- generator.setParameter(WorkflowConstants.GATEWAY_ID, gatewayId);
- Query q = generator.selectQuery(em);
- List results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Workflow workflow = (Workflow) result;
- WorkflowAppCatalogResourceAppCat wfResource =
- (WorkflowAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
- workflows.add(wfResource);
- }
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return workflows;
- }
-
- @Override
- public List<String> getAllIds() throws AppCatalogException {
- List<String> workflowIds = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- generator.setParameter(WorkflowConstants.GATEWAY_ID, gatewayId);
- Query q = generator.selectQuery(em);
- List results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Workflow workflow = (Workflow) result;
- workflowIds.add(workflow.getWfTemplateId());
- }
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return workflowIds;
- }
-
- @Override
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> workflowResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW);
- Query q;
- if ((fieldName.equals(WorkflowConstants.WF_NAME)) || (fieldName.equals(WorkflowConstants.CREATED_USER)) || (fieldName.equals(WorkflowConstants.GRAPH)) || (fieldName.equals(WorkflowConstants.WF_TEMPLATE_ID))) {
- generator.setParameter(fieldName, value);
- q = generator.selectQuery(em);
- List<?> results = q.getResultList();
- for (Object result : results) {
- Workflow workflow = (Workflow) result;
- WorkflowAppCatalogResourceAppCat workflowResource = (WorkflowAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW, workflow);
- workflowResourceIDs.add(workflowResource.getWfTemplateId());
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for Workflow Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for Workflow Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return workflowResourceIDs;
- }
-
- @Override
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- Workflow existingWorkflow = em.find(Workflow.class, wfTemplateId);
- em.close();
- Workflow workflow;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingWorkflow == null) {
- workflow = new Workflow();
- workflow.setCreationTime(AiravataUtils.getCurrentTimestamp());
- } else {
- workflow = existingWorkflow;
- workflow.setUpdateTime(AiravataUtils.getCurrentTimestamp());
- }
- workflow.setWfName(getWfName());
- workflow.setCreatedUser(getCreatedUser());
- workflow.setGatewayId(gatewayId);
- if (getGraph() != null){
- workflow.setGraph(getGraph().toCharArray());
- }
- if (image != null){
- workflow.setImage(image.getBytes());
- }
- workflow.setWfTemplateId(getWfTemplateId());
- if (existingWorkflow == null) {
- em.persist(workflow);
- } else {
- em.merge(workflow);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- @Override
- public boolean isExists(Object identifier) throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- Workflow workflow = em.find(Workflow.class, identifier);
- em.close();
- return workflow != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getWfName() {
- return wfName;
- }
-
- public String getCreatedUser() {
- return createdUser;
- }
-
- public String getGraph() {
- return graph;
- }
-
- public String getWfTemplateId() {
- return wfTemplateId;
- }
-
- public void setWfName(String wfName) {
- this.wfName=wfName;
- }
-
- public void setCreatedUser(String createdUser) {
- this.createdUser=createdUser;
- }
-
- public void setGraph(String graph) {
- this.graph=graph;
- }
-
- public void setWfTemplateId(String wfTemplateId) {
- this.wfTemplateId=wfTemplateId;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputAppCatalogResourceAppCat.java
deleted file mode 100644
index 89a34f4..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,451 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.Workflow;
-import org.apache.airavata.registry.core.app.catalog.model.WorkflowInput;
-import org.apache.airavata.registry.core.app.catalog.model.WorkflowInput_PK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class WorkflowInputAppCatalogResourceAppCat extends AppCatAbstractResource {
-
- private final static Logger logger = LoggerFactory.getLogger(WorkflowInputAppCatalogResourceAppCat.class);
-
- private String wfTemplateId;
- private String inputKey;
- private String dataType;
- private String inputVal;
- private String metadata;
- private String appArgument;
- private String userFriendlyDesc;
- private boolean standardInput;
- private int inputOrder;
- private boolean isRequired;
- private boolean requiredToCMD;
- private boolean dataStaged;
-
- private WorkflowAppCatalogResourceAppCat workflowResource;
-
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT);
- generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, ids.get(WFInputConstants.WF_TEMPLATE_ID));
- generator.setParameter(WFInputConstants.INPUT_KEY, ids.get(WFInputConstants.INPUT_KEY));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT);
- generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, ids.get(WFInputConstants.WF_TEMPLATE_ID));
- generator.setParameter(WFInputConstants.INPUT_KEY, ids.get(WFInputConstants.INPUT_KEY));
- Query q = generator.selectQuery(em);
- WorkflowInput workflowInput = (WorkflowInput) q.getSingleResult();
- WorkflowInputAppCatalogResourceAppCat workflowInputResource =
- (WorkflowInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_INPUT
- , workflowInput);
- em.getTransaction().commit();
- em.close();
- return workflowInputResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> wfInputResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT);
- List results;
- if (fieldName.equals(WFInputConstants.WF_TEMPLATE_ID)) {
- generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowInput workflowInput = (WorkflowInput) result;
- WorkflowInputAppCatalogResourceAppCat workflowInputResource =
- (WorkflowInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.WORKFLOW_INPUT, workflowInput);
- wfInputResources.add(workflowInputResource);
- }
- }
- } else if (fieldName.equals(WFInputConstants.INPUT_KEY)) {
- generator.setParameter(WFInputConstants.INPUT_KEY, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowInput workflowInput = (WorkflowInput) result;
- WorkflowInputAppCatalogResourceAppCat workflowInputResource =
- (WorkflowInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.WORKFLOW_INPUT, workflowInput);
- wfInputResources.add(workflowInputResource);
- }
- }
- } else if (fieldName.equals(WFInputConstants.DATA_TYPE)) {
- generator.setParameter(WFInputConstants.DATA_TYPE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowInput workflowInput = (WorkflowInput) result;
- WorkflowInputAppCatalogResourceAppCat workflowInputResource =
- (WorkflowInputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.WORKFLOW_INPUT, workflowInput);
- wfInputResources.add(workflowInputResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for WFInput Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for WFInput Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return wfInputResources;
- }
-
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> wfInputResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT);
- List results;
- if (fieldName.equals(WFInputConstants.WF_TEMPLATE_ID)) {
- generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowInput workflowInput = (WorkflowInput) result;
- wfInputResourceIDs.add(workflowInput.getWfTemplateId());
- }
- }
- } else if (fieldName.equals(WFInputConstants.INPUT_KEY)) {
- generator.setParameter(WFInputConstants.INPUT_KEY, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowInput workflowInput = (WorkflowInput) result;
- wfInputResourceIDs.add(workflowInput.getWfTemplateId());
- }
- }
- } else if (fieldName.equals(WFInputConstants.DATA_TYPE)) {
- generator.setParameter(WFInputConstants.DATA_TYPE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowInput workflowInput = (WorkflowInput) result;
- wfInputResourceIDs.add(workflowInput.getWfTemplateId());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for WFInput resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for WFInput Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return wfInputResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- WorkflowInput existingWFInput = em.find(WorkflowInput.class, new WorkflowInput_PK(wfTemplateId, inputKey));
- em.close();
- WorkflowInput workflowInput;
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingWFInput == null) {
- workflowInput = new WorkflowInput();
- } else {
- workflowInput=existingWFInput;
- }
- workflowInput.setWfTemplateId(wfTemplateId);
- Workflow workflow = em.find(Workflow.class, wfTemplateId);
- workflowInput.setWorkflow(workflow);
- workflowInput.setDataType(dataType);
- workflowInput.setInputKey(inputKey);
- if (inputVal != null){
- workflowInput.setInputVal(inputVal.toCharArray());
- }
- workflowInput.setMetadata(metadata);
- workflowInput.setAppArgument(appArgument);
- workflowInput.setUserFriendlyDesc(userFriendlyDesc);
- workflowInput.setStandardInput(standardInput);
- workflowInput.setRequiredToCMD(requiredToCMD);
- workflowInput.setRequired(isRequired);
- workflowInput.setDataStaged(dataStaged);
- if (existingWFInput == null) {
- em.persist(workflowInput);
- } else {
- em.merge(workflowInput);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap<String, String>) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- WorkflowInput workflowInput = em.find(WorkflowInput.class, new WorkflowInput_PK(
- ids.get(WFInputConstants.WF_TEMPLATE_ID),
- ids.get(WFInputConstants.INPUT_KEY)));
-
- em.close();
- return workflowInput != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getWfTemplateId() {
- return wfTemplateId;
- }
-
- public void setWfTemplateId(String wfTemplateId) {
- this.wfTemplateId = wfTemplateId;
- }
-
- 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 getInputVal() {
- return inputVal;
- }
-
- public void setInputVal(String inputVal) {
- this.inputVal = inputVal;
- }
-
- public String getMetadata() {
- return metadata;
- }
-
- public void setMetadata(String metadata) {
- this.metadata = metadata;
- }
-
- public String getAppArgument() {
- return appArgument;
- }
-
- public void setAppArgument(String appArgument) {
- this.appArgument = appArgument;
- }
-
- public String getUserFriendlyDesc() {
- return userFriendlyDesc;
- }
-
- public void setUserFriendlyDesc(String userFriendlyDesc) {
- this.userFriendlyDesc = userFriendlyDesc;
- }
-
- public WorkflowAppCatalogResourceAppCat getWorkflowResource() {
- return workflowResource;
- }
-
- public void setWorkflowResource(WorkflowAppCatalogResourceAppCat workflowResource) {
- this.workflowResource = workflowResource;
- }
-
- public boolean isStandardInput() {
- return standardInput;
- }
-
- public void setStandardInput(boolean standardInput) {
- this.standardInput = standardInput;
- }
-
- public int getInputOrder() {
- return inputOrder;
- }
-
- public void setInputOrder(int inputOrder) {
- this.inputOrder = inputOrder;
- }
-
- public boolean getRequired() {
- return isRequired;
- }
-
- public void setRequired(boolean required) {
- this.isRequired = required;
- }
-
- public boolean getRequiredToCMD() {
- return requiredToCMD;
- }
-
- public void setRequiredToCMD(boolean requiredToCMD) {
- this.requiredToCMD = requiredToCMD;
- }
-
- public boolean isDataStaged() {
- return dataStaged;
- }
-
- public void setDataStaged(boolean dataStaged) {
- this.dataStaged = dataStaged;
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java
new file mode 100644
index 0000000..913d996
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowInputResource.java
@@ -0,0 +1,451 @@
+/**
+ * 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.registry.core.app.catalog.resources;
+
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.registry.core.app.catalog.model.Workflow;
+import org.apache.airavata.registry.core.app.catalog.model.WorkflowInput;
+import org.apache.airavata.registry.core.app.catalog.model.WorkflowInput_PK;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
+import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
+import org.apache.airavata.registry.cpi.AppCatalogException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class WorkflowInputResource extends AppCatAbstractResource {
+
+ private final static Logger logger = LoggerFactory.getLogger(WorkflowInputResource.class);
+
+ private String wfTemplateId;
+ private String inputKey;
+ private String dataType;
+ private String inputVal;
+ private String metadata;
+ private String appArgument;
+ private String userFriendlyDesc;
+ private boolean standardInput;
+ private int inputOrder;
+ private boolean isRequired;
+ private boolean requiredToCMD;
+ private boolean dataStaged;
+
+ private WorkflowResource workflowResource;
+
+ public void remove(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT);
+ generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, ids.get(WFInputConstants.WF_TEMPLATE_ID));
+ generator.setParameter(WFInputConstants.INPUT_KEY, ids.get(WFInputConstants.INPUT_KEY));
+ Query q = generator.deleteQuery(em);
+ q.executeUpdate();
+ em.getTransaction().commit();
+ em.close();
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public AppCatalogResource get(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT);
+ generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, ids.get(WFInputConstants.WF_TEMPLATE_ID));
+ generator.setParameter(WFInputConstants.INPUT_KEY, ids.get(WFInputConstants.INPUT_KEY));
+ Query q = generator.selectQuery(em);
+ WorkflowInput workflowInput = (WorkflowInput) q.getSingleResult();
+ WorkflowInputResource workflowInputResource =
+ (WorkflowInputResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_INPUT
+ , workflowInput);
+ em.getTransaction().commit();
+ em.close();
+ return workflowInputResource;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
+ List<AppCatalogResource> wfInputResources = new ArrayList<AppCatalogResource>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT);
+ List results;
+ if (fieldName.equals(WFInputConstants.WF_TEMPLATE_ID)) {
+ generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowInput workflowInput = (WorkflowInput) result;
+ WorkflowInputResource workflowInputResource =
+ (WorkflowInputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.WORKFLOW_INPUT, workflowInput);
+ wfInputResources.add(workflowInputResource);
+ }
+ }
+ } else if (fieldName.equals(WFInputConstants.INPUT_KEY)) {
+ generator.setParameter(WFInputConstants.INPUT_KEY, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowInput workflowInput = (WorkflowInput) result;
+ WorkflowInputResource workflowInputResource =
+ (WorkflowInputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.WORKFLOW_INPUT, workflowInput);
+ wfInputResources.add(workflowInputResource);
+ }
+ }
+ } else if (fieldName.equals(WFInputConstants.DATA_TYPE)) {
+ generator.setParameter(WFInputConstants.DATA_TYPE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowInput workflowInput = (WorkflowInput) result;
+ WorkflowInputResource workflowInputResource =
+ (WorkflowInputResource) AppCatalogJPAUtils.getResource(
+ AppCatalogResourceType.WORKFLOW_INPUT, workflowInput);
+ wfInputResources.add(workflowInputResource);
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for WFInput Resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for WFInput Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return wfInputResources;
+ }
+
+ public List<AppCatalogResource> getAll() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getAllIds() throws AppCatalogException {
+ return null;
+ }
+
+ public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
+ List<String> wfInputResourceIDs = new ArrayList<String>();
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ Query q;
+ AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_INPUT);
+ List results;
+ if (fieldName.equals(WFInputConstants.WF_TEMPLATE_ID)) {
+ generator.setParameter(WFInputConstants.WF_TEMPLATE_ID, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowInput workflowInput = (WorkflowInput) result;
+ wfInputResourceIDs.add(workflowInput.getWfTemplateId());
+ }
+ }
+ } else if (fieldName.equals(WFInputConstants.INPUT_KEY)) {
+ generator.setParameter(WFInputConstants.INPUT_KEY, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowInput workflowInput = (WorkflowInput) result;
+ wfInputResourceIDs.add(workflowInput.getWfTemplateId());
+ }
+ }
+ } else if (fieldName.equals(WFInputConstants.DATA_TYPE)) {
+ generator.setParameter(WFInputConstants.DATA_TYPE, value);
+ q = generator.selectQuery(em);
+ results = q.getResultList();
+ if (results.size() != 0) {
+ for (Object result : results) {
+ WorkflowInput workflowInput = (WorkflowInput) result;
+ wfInputResourceIDs.add(workflowInput.getWfTemplateId());
+ }
+ }
+ } else {
+ em.getTransaction().commit();
+ em.close();
+ logger.error("Unsupported field name for WFInput resource.", new IllegalArgumentException());
+ throw new IllegalArgumentException("Unsupported field name for WFInput Resource.");
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ return wfInputResourceIDs;
+ }
+
+ public void save() throws AppCatalogException {
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ WorkflowInput existingWFInput = em.find(WorkflowInput.class, new WorkflowInput_PK(wfTemplateId, inputKey));
+ em.close();
+ WorkflowInput workflowInput;
+ em = AppCatalogJPAUtils.getEntityManager();
+ em.getTransaction().begin();
+ if (existingWFInput == null) {
+ workflowInput = new WorkflowInput();
+ } else {
+ workflowInput=existingWFInput;
+ }
+ workflowInput.setWfTemplateId(wfTemplateId);
+ Workflow workflow = em.find(Workflow.class, wfTemplateId);
+ workflowInput.setWorkflow(workflow);
+ workflowInput.setDataType(dataType);
+ workflowInput.setInputKey(inputKey);
+ if (inputVal != null){
+ workflowInput.setInputVal(inputVal.toCharArray());
+ }
+ workflowInput.setMetadata(metadata);
+ workflowInput.setAppArgument(appArgument);
+ workflowInput.setUserFriendlyDesc(userFriendlyDesc);
+ workflowInput.setStandardInput(standardInput);
+ workflowInput.setRequiredToCMD(requiredToCMD);
+ workflowInput.setRequired(isRequired);
+ workflowInput.setDataStaged(dataStaged);
+ if (existingWFInput == null) {
+ em.persist(workflowInput);
+ } else {
+ em.merge(workflowInput);
+ }
+ em.getTransaction().commit();
+ em.close();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public boolean isExists(Object identifier) throws AppCatalogException {
+ HashMap<String, String> ids;
+ if (identifier instanceof Map) {
+ ids = (HashMap<String, String>) identifier;
+ } else {
+ logger.error("Identifier should be a map with the field name and it's value");
+ throw new AppCatalogException("Identifier should be a map with the field name and it's value");
+ }
+
+ EntityManager em = null;
+ try {
+ em = AppCatalogJPAUtils.getEntityManager();
+ WorkflowInput workflowInput = em.find(WorkflowInput.class, new WorkflowInput_PK(
+ ids.get(WFInputConstants.WF_TEMPLATE_ID),
+ ids.get(WFInputConstants.INPUT_KEY)));
+
+ em.close();
+ return workflowInput != null;
+ } catch (ApplicationSettingsException e) {
+ logger.error(e.getMessage(), e);
+ throw new AppCatalogException(e);
+ } finally {
+ if (em != null && em.isOpen()) {
+ if (em.getTransaction().isActive()) {
+ em.getTransaction().rollback();
+ }
+ em.close();
+ }
+ }
+ }
+
+ public String getWfTemplateId() {
+ return wfTemplateId;
+ }
+
+ public void setWfTemplateId(String wfTemplateId) {
+ this.wfTemplateId = wfTemplateId;
+ }
+
+ 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 getInputVal() {
+ return inputVal;
+ }
+
+ public void setInputVal(String inputVal) {
+ this.inputVal = inputVal;
+ }
+
+ public String getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(String metadata) {
+ this.metadata = metadata;
+ }
+
+ public String getAppArgument() {
+ return appArgument;
+ }
+
+ public void setAppArgument(String appArgument) {
+ this.appArgument = appArgument;
+ }
+
+ public String getUserFriendlyDesc() {
+ return userFriendlyDesc;
+ }
+
+ public void setUserFriendlyDesc(String userFriendlyDesc) {
+ this.userFriendlyDesc = userFriendlyDesc;
+ }
+
+ public WorkflowResource getWorkflowResource() {
+ return workflowResource;
+ }
+
+ public void setWorkflowResource(WorkflowResource workflowResource) {
+ this.workflowResource = workflowResource;
+ }
+
+ public boolean isStandardInput() {
+ return standardInput;
+ }
+
+ public void setStandardInput(boolean standardInput) {
+ this.standardInput = standardInput;
+ }
+
+ public int getInputOrder() {
+ return inputOrder;
+ }
+
+ public void setInputOrder(int inputOrder) {
+ this.inputOrder = inputOrder;
+ }
+
+ public boolean getRequired() {
+ return isRequired;
+ }
+
+ public void setRequired(boolean required) {
+ this.isRequired = required;
+ }
+
+ public boolean getRequiredToCMD() {
+ return requiredToCMD;
+ }
+
+ public void setRequiredToCMD(boolean requiredToCMD) {
+ this.requiredToCMD = requiredToCMD;
+ }
+
+ public boolean isDataStaged() {
+ return dataStaged;
+ }
+
+ public void setDataStaged(boolean dataStaged) {
+ this.dataStaged = dataStaged;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputAppCatalogResourceAppCat.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputAppCatalogResourceAppCat.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputAppCatalogResourceAppCat.java
deleted file mode 100644
index 75f5f7e..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/WorkflowOutputAppCatalogResourceAppCat.java
+++ /dev/null
@@ -1,410 +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.registry.core.app.catalog.resources;
-
-import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.registry.core.app.catalog.model.Workflow;
-import org.apache.airavata.registry.core.app.catalog.model.WorkflowOutput;
-import org.apache.airavata.registry.core.app.catalog.model.WorkflowOutput_PK;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogJPAUtils;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogQueryGenerator;
-import org.apache.airavata.registry.core.app.catalog.util.AppCatalogResourceType;
-import org.apache.airavata.registry.cpi.AppCatalogException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class WorkflowOutputAppCatalogResourceAppCat extends AppCatAbstractResource {
- private final static Logger logger = LoggerFactory.getLogger(WorkflowOutputAppCatalogResourceAppCat.class);
-
- private String wfTemplateId;
- private String outputKey;
- private String outputVal;
- private String dataType;
- private String validityType;
- private boolean dataMovement;
- private String dataNameLocation;
-
- private WorkflowAppCatalogResourceAppCat workflowResource;
-
- public void remove(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
- generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, ids.get(WFOutputConstants.WF_TEMPLATE_ID));
- generator.setParameter(WFOutputConstants.OUTPUT_KEY, ids.get(WFOutputConstants.OUTPUT_KEY));
- Query q = generator.deleteQuery(em);
- q.executeUpdate();
- em.getTransaction().commit();
- em.close();
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public AppCatalogResource get(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
- generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, ids.get(WFOutputConstants.WF_TEMPLATE_ID));
- generator.setParameter(WFOutputConstants.OUTPUT_KEY, ids.get(WFOutputConstants.OUTPUT_KEY));
- Query q = generator.selectQuery(em);
- WorkflowOutput wfOutput = (WorkflowOutput) q.getSingleResult();
- WorkflowOutputAppCatalogResourceAppCat workflowOutputResource =
- (WorkflowOutputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(AppCatalogResourceType.WORKFLOW_OUTPUT
- , wfOutput);
- em.getTransaction().commit();
- em.close();
- return workflowOutputResource;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException {
- List<AppCatalogResource> wfOutputResources = new ArrayList<AppCatalogResource>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
- List results;
- if (fieldName.equals(WFOutputConstants.WF_TEMPLATE_ID)) {
- generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowOutput wfOutput = (WorkflowOutput) result;
- WorkflowOutputAppCatalogResourceAppCat workflowOutputResource =
- (WorkflowOutputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.WORKFLOW_OUTPUT, wfOutput);
- wfOutputResources.add(workflowOutputResource);
- }
- }
- } else if (fieldName.equals(WFOutputConstants.OUTPUT_KEY)) {
- generator.setParameter(WFOutputConstants.OUTPUT_KEY, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowOutput workflowOutput = (WorkflowOutput) result;
- WorkflowOutputAppCatalogResourceAppCat workflowOutputResource =
- (WorkflowOutputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.WORKFLOW_OUTPUT, workflowOutput);
- wfOutputResources.add(workflowOutputResource);
- }
- }
- } else if (fieldName.equals(WFOutputConstants.DATA_TYPE)) {
- generator.setParameter(WFOutputConstants.DATA_TYPE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowOutput workflowOutput = (WorkflowOutput) result;
- WorkflowOutputAppCatalogResourceAppCat workflowOutputResource =
- (WorkflowOutputAppCatalogResourceAppCat) AppCatalogJPAUtils.getResource(
- AppCatalogResourceType.WORKFLOW_OUTPUT, workflowOutput);
- wfOutputResources.add(workflowOutputResource);
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for WF Output Resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for WF Output Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return wfOutputResources;
- }
-
- public List<AppCatalogResource> getAll() throws AppCatalogException {
- return null;
- }
-
- public List<String> getAllIds() throws AppCatalogException {
- return null;
- }
-
- public List<String> getIds(String fieldName, Object value) throws AppCatalogException {
- List<String> wfOutputResourceIDs = new ArrayList<String>();
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(WORKFLOW_OUTPUT);
- List results;
- if (fieldName.equals(WFOutputConstants.WF_TEMPLATE_ID)) {
- generator.setParameter(WFOutputConstants.WF_TEMPLATE_ID, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowOutput workflowOutput = (WorkflowOutput) result;
- wfOutputResourceIDs.add(workflowOutput.getWfTemplateId());
- }
- }
- }
- if (fieldName.equals(WFOutputConstants.OUTPUT_KEY)) {
- generator.setParameter(WFOutputConstants.OUTPUT_KEY, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowOutput workflowOutput = (WorkflowOutput) result;
- wfOutputResourceIDs.add(workflowOutput.getWfTemplateId());
- }
- }
- } else if (fieldName.equals(WFOutputConstants.DATA_TYPE)) {
- generator.setParameter(WFOutputConstants.DATA_TYPE, value);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowOutput workflowOutput = (WorkflowOutput) result;
- wfOutputResourceIDs.add(workflowOutput.getWfTemplateId());
- }
- }
- } else {
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported field name for WF Output resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported field name for WF Output Resource.");
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- return wfOutputResourceIDs;
- }
-
- public void save() throws AppCatalogException {
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- WorkflowOutput existingWorkflowOutput = em.find(WorkflowOutput.class,
- new WorkflowOutput_PK(wfTemplateId, outputKey));
- em.close();
-
- em = AppCatalogJPAUtils.getEntityManager();
- em.getTransaction().begin();
- if (existingWorkflowOutput != null) {
- existingWorkflowOutput.setWfTemplateId(wfTemplateId);
- Workflow workflow = em.find(Workflow.class, wfTemplateId);
- existingWorkflowOutput.setWorkflow(workflow);
- existingWorkflowOutput.setDataType(dataType);
- existingWorkflowOutput.setOutputKey(outputKey);
- if (outputVal != null){
- existingWorkflowOutput.setOutputVal(outputVal.toCharArray());
- }
- existingWorkflowOutput.setValidityType(validityType);
- existingWorkflowOutput.setDataMovement(dataMovement);
- existingWorkflowOutput.setDataNameLocation(dataNameLocation);
- em.merge(existingWorkflowOutput);
- } else {
- WorkflowOutput workflowOutput = new WorkflowOutput();
- workflowOutput.setWfTemplateId(wfTemplateId);
- Workflow workflow = em.find(Workflow.class, wfTemplateId);
- workflowOutput.setWorkflow(workflow);
- workflowOutput.setDataType(dataType);
- workflowOutput.setOutputKey(outputKey);
- if (outputVal != null){
- workflowOutput.setOutputVal(outputVal.toCharArray());
- }
- workflowOutput.setValidityType(validityType);
- workflowOutput.setDataMovement(dataMovement);
- workflowOutput.setDataNameLocation(dataNameLocation);
- em.persist(workflowOutput);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public boolean isExists(Object identifier) throws AppCatalogException {
- HashMap<String, String> ids;
- if (identifier instanceof Map) {
- ids = (HashMap) identifier;
- } else {
- logger.error("Identifier should be a map with the field name and it's value");
- throw new AppCatalogException("Identifier should be a map with the field name and it's value");
- }
-
- EntityManager em = null;
- try {
- em = AppCatalogJPAUtils.getEntityManager();
- WorkflowOutput workflowOutput = em.find(WorkflowOutput.class, new WorkflowOutput_PK(
- ids.get(WFOutputConstants.WF_TEMPLATE_ID),
- ids.get(WFOutputConstants.OUTPUT_KEY)));
-
- em.close();
- return workflowOutput != null;
- } catch (ApplicationSettingsException e) {
- logger.error(e.getMessage(), e);
- throw new AppCatalogException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()) {
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- public String getWfTemplateId() {
- return wfTemplateId;
- }
-
- public void setWfTemplateId(String wfTemplateId) {
- this.wfTemplateId = wfTemplateId;
- }
-
- public String getOutputKey() {
- return outputKey;
- }
-
- public void setOutputKey(String outputKey) {
- this.outputKey = outputKey;
- }
-
- public String getOutputVal() {
- return outputVal;
- }
-
- public void setOutputVal(String outputVal) {
- this.outputVal = outputVal;
- }
-
- public String getDataType() {
- return dataType;
- }
-
- public void setDataType(String dataType) {
- this.dataType = dataType;
- }
-
- public WorkflowAppCatalogResourceAppCat getWorkflowResource() {
- return workflowResource;
- }
-
- public void setWorkflowResource(WorkflowAppCatalogResourceAppCat workflowResource) {
- this.workflowResource = workflowResource;
- }
-
- public String getValidityType() {
- return validityType;
- }
-
- public void setValidityType(String validityType) {
- this.validityType = validityType;
- }
-
- 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;
- }
-}
[09/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailResource.java
new file mode 100644
index 0000000..c5efb88
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/DataTransferDetailResource.java
@@ -0,0 +1,276 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.DataTransferDetail;
+import org.apache.airavata.registry.core.experiment.catalog.model.Status;
+import org.apache.airavata.registry.core.experiment.catalog.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 AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(DataTransferDetailResource.class);
+ private String transferId;
+ private String taskId;
+ private Timestamp creationTime;
+ private String transferDescription;
+ private StatusResource datatransferStatus;
+
+ public StatusResource getDatatransferStatus() {
+ return datatransferStatus;
+ }
+
+ public void setDatatransferStatus(StatusResource datatransferStatus) {
+ this.datatransferStatus = datatransferStatus;
+ }
+
+ public String getTransferId() {
+ return transferId;
+ }
+
+ public void setTransferId(String transferId) {
+ this.transferId = transferId;
+ }
+
+ 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 String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ switch (type){
+ case STATUS:
+ StatusResource statusResource = new StatusResource();
+ statusResource.setTransferId(transferId);
+ 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 = ExpCatResourceUtils.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 ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.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<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.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 = ExpCatResourceUtils.getEntityManager();
+ DataTransferDetail existingDF = em.find(DataTransferDetail.class, transferId);
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ DataTransferDetail dataTransferDetail = new DataTransferDetail();
+ dataTransferDetail.setTransferId(transferId);
+ dataTransferDetail.setTaskId(taskId);
+ dataTransferDetail.setCreationTime(creationTime);
+ if (transferDescription != null) {
+ dataTransferDetail.setTransferDesc(transferDescription.toCharArray());
+ }
+ if (existingDF != null) {
+ existingDF.setTransferId(transferId);
+ existingDF.setTaskId(taskId);
+ 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<ExperimentCatResource> resources = get(ResourceType.STATUS);
+ for (ExperimentCatResource 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ErrorDetailExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ErrorDetailExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ErrorDetailExperimentCatResource.java
deleted file mode 100644
index d96821e..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ErrorDetailExperimentCatResource.java
+++ /dev/null
@@ -1,215 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.ErrorDetail;
-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 ErrorDetailExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(ErrorDetailExperimentCatResource.class);
- private int errorId;
- private String experimentId;
- private String taskId;
- private String nodeId;
- private Timestamp creationTime;
- private String actualErrorMsg;
- private String userFriendlyErrorMsg;
- private boolean transientPersistent;
- private String errorCategory;
- private String correctiveAction;
- private String actionableGroup;
- private String jobId;
-
- public int getErrorId() {
- return errorId;
- }
-
- public void setErrorId(int errorId) {
- this.errorId = errorId;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- public String getActualErrorMsg() {
- return actualErrorMsg;
- }
-
- public void setActualErrorMsg(String actualErrorMsg) {
- this.actualErrorMsg = actualErrorMsg;
- }
-
- public String getUserFriendlyErrorMsg() {
- return userFriendlyErrorMsg;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- public String getTaskId() {
- return taskId;
- }
-
- public void setTaskId(String taskId) {
- this.taskId = taskId;
- }
-
- public String getNodeId() {
- return nodeId;
- }
-
- public void setNodeId(String nodeId) {
- this.nodeId = nodeId;
- }
-
- public void setUserFriendlyErrorMsg(String userFriendlyErrorMsg) {
- this.userFriendlyErrorMsg = userFriendlyErrorMsg;
- }
-
- public boolean isTransientPersistent() {
- return transientPersistent;
- }
-
- public void setTransientPersistent(boolean transientPersistent) {
- this.transientPersistent = transientPersistent;
- }
-
- public String getErrorCategory() {
- return errorCategory;
- }
-
- public void setErrorCategory(String errorCategory) {
- this.errorCategory = errorCategory;
- }
-
- public String getCorrectiveAction() {
- return correctiveAction;
- }
-
- public void setCorrectiveAction(String correctiveAction) {
- this.correctiveAction = correctiveAction;
- }
-
- public String getActionableGroup() {
- return actionableGroup;
- }
-
- public void setActionableGroup(String actionableGroup) {
- this.actionableGroup = actionableGroup;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
-
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void remove(ResourceType type, Object name) throws RegistryException {
- logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- ErrorDetail errorDetail;
- if (errorId != 0) {
- errorDetail = em.find(ErrorDetail.class, errorId);
- errorDetail.setErrorID(errorId);
- } else {
- errorDetail = new ErrorDetail();
- }
- errorDetail.setErrorID(errorId);
- errorDetail.setExpId(experimentId);
- errorDetail.setTaskId(taskId);
- errorDetail.setNodeId(nodeId);
- errorDetail.setCreationTime(creationTime);
- if (actualErrorMsg != null){
- errorDetail.setActualErrorMsg(actualErrorMsg.toCharArray());
- }
-
- errorDetail.setUserFriendlyErrorMsg(userFriendlyErrorMsg);
- errorDetail.setTransientPersistent(transientPersistent);
- errorDetail.setErrorCategory(errorCategory);
- errorDetail.setCorrectiveAction(correctiveAction);
- errorDetail.setActionableGroup(actionableGroup);
- errorDetail.setJobId(jobId);
- em.persist(errorDetail);
- errorId = errorDetail.getErrorID();
- 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ErrorDetailResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ErrorDetailResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ErrorDetailResource.java
new file mode 100644
index 0000000..ae1907d
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ErrorDetailResource.java
@@ -0,0 +1,215 @@
+/*
+ *
+ * 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.ErrorDetail;
+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 ErrorDetailResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(ErrorDetailResource.class);
+ private int errorId;
+ private String experimentId;
+ private String taskId;
+ private String nodeId;
+ private Timestamp creationTime;
+ private String actualErrorMsg;
+ private String userFriendlyErrorMsg;
+ private boolean transientPersistent;
+ private String errorCategory;
+ private String correctiveAction;
+ private String actionableGroup;
+ private String jobId;
+
+ public int getErrorId() {
+ return errorId;
+ }
+
+ public void setErrorId(int errorId) {
+ this.errorId = errorId;
+ }
+
+ public Timestamp getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Timestamp creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public String getActualErrorMsg() {
+ return actualErrorMsg;
+ }
+
+ public void setActualErrorMsg(String actualErrorMsg) {
+ this.actualErrorMsg = actualErrorMsg;
+ }
+
+ public String getUserFriendlyErrorMsg() {
+ return userFriendlyErrorMsg;
+ }
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public void setUserFriendlyErrorMsg(String userFriendlyErrorMsg) {
+ this.userFriendlyErrorMsg = userFriendlyErrorMsg;
+ }
+
+ public boolean isTransientPersistent() {
+ return transientPersistent;
+ }
+
+ public void setTransientPersistent(boolean transientPersistent) {
+ this.transientPersistent = transientPersistent;
+ }
+
+ public String getErrorCategory() {
+ return errorCategory;
+ }
+
+ public void setErrorCategory(String errorCategory) {
+ this.errorCategory = errorCategory;
+ }
+
+ public String getCorrectiveAction() {
+ return correctiveAction;
+ }
+
+ public void setCorrectiveAction(String correctiveAction) {
+ this.correctiveAction = correctiveAction;
+ }
+
+ public String getActionableGroup() {
+ return actionableGroup;
+ }
+
+ public void setActionableGroup(String actionableGroup) {
+ this.actionableGroup = actionableGroup;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+
+ public ExperimentCatResource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void remove(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
+ logger.error("Unsupported resource type for error details data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ ErrorDetail errorDetail;
+ if (errorId != 0) {
+ errorDetail = em.find(ErrorDetail.class, errorId);
+ errorDetail.setErrorID(errorId);
+ } else {
+ errorDetail = new ErrorDetail();
+ }
+ errorDetail.setErrorID(errorId);
+ errorDetail.setExpId(experimentId);
+ errorDetail.setTaskId(taskId);
+ errorDetail.setNodeId(nodeId);
+ errorDetail.setCreationTime(creationTime);
+ if (actualErrorMsg != null){
+ errorDetail.setActualErrorMsg(actualErrorMsg.toCharArray());
+ }
+
+ errorDetail.setUserFriendlyErrorMsg(userFriendlyErrorMsg);
+ errorDetail.setTransientPersistent(transientPersistent);
+ errorDetail.setErrorCategory(errorCategory);
+ errorDetail.setCorrectiveAction(correctiveAction);
+ errorDetail.setActionableGroup(actionableGroup);
+ errorDetail.setJobId(jobId);
+ em.persist(errorDetail);
+ errorId = errorDetail.getErrorID();
+ 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentExperimentCatResource.java
deleted file mode 100644
index 030cc76..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentExperimentCatResource.java
+++ /dev/null
@@ -1,831 +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.registry.core.experiment.catalog.resources;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.*;
-import org.apache.airavata.registry.core.experiment.catalog.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;
-
-public class ExperimentExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(ExperimentExperimentCatResource.class);
-// private WorkerResource worker;
- private String executionUser;
- private String expID;
- private Timestamp creationTime;
- private String gatewayId;
- private String projectId;
- private String expName;
- private String description;
- private String applicationId;
- private String applicationVersion;
- private String workflowTemplateId;
- private String workflowTemplateVersion;
- private String workflowExecutionId;
- private boolean enableEmailNotifications;
- private String gatewayExecutionId;
- private List<ExperimentInputExperimentCatResource> experimentInputResources;
- private List<ExperimentOutputExperimentCatResource> experimentOutputputResources;
- private ComputationSchedulingExperimentCatResource computationSchedulingResource;
- private ConfigDataExperimentCatResource userConfigDataResource;
- private List<WorkflowNodeDetailExperimentCatResource> workflowNodeDetailResourceList;
- private List<StatusExperimentCatResource> stateChangeList;
- private List<ErrorDetailExperimentCatResource> errorDetailList;
- private StatusExperimentCatResource experimentStatus;
- private List<NotificationEmailExperimentCatResource> emailResourceList;
-
- /**
- *
- * @return experiment ID
- */
- public String getExpID() {
- return expID;
- }
-
- public Timestamp getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Timestamp creationTime) {
- this.creationTime = creationTime;
- }
-
- public String getExpName() {
- return expName;
- }
-
- public void setExpName(String expName) {
- this.expName = expName;
- }
-
- public String getApplicationId() {
- return applicationId;
- }
-
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
- }
-
- public String getApplicationVersion() {
- return applicationVersion;
- }
-
- public void setApplicationVersion(String applicationVersion) {
- this.applicationVersion = applicationVersion;
- }
-
- public String getWorkflowTemplateId() {
- return workflowTemplateId;
- }
-
- public void setWorkflowTemplateId(String workflowTemplateId) {
- this.workflowTemplateId = workflowTemplateId;
- }
-
- public String getWorkflowTemplateVersion() {
- return workflowTemplateVersion;
- }
-
- public void setWorkflowTemplateVersion(String workflowTemplateVersion) {
- this.workflowTemplateVersion = workflowTemplateVersion;
- }
-
- public String getWorkflowExecutionId() {
- return workflowExecutionId;
- }
-
- public void setWorkflowExecutionId(String workflowExecutionId) {
- this.workflowExecutionId = workflowExecutionId;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public boolean isEnableEmailNotifications() {
- return enableEmailNotifications;
- }
-
- public void setEnableEmailNotifications(boolean enableEmailNotifications) {
- this.enableEmailNotifications = enableEmailNotifications;
- }
-
- public String getGatewayExecutionId() {
- return gatewayExecutionId;
- }
-
- public void setGatewayExecutionId(String gatewayExecutionId) {
- this.gatewayExecutionId = gatewayExecutionId;
- }
-
- public String getGatewayId() {
- return gatewayId;
- }
-
- public void setGatewayId(String gatewayId) {
- this.gatewayId = gatewayId;
- }
-
- public String getProjectId() {
- return projectId;
- }
-
- public void setProjectId(String projectId) {
- this.projectId = projectId;
- }
-
- public List<ExperimentInputExperimentCatResource> getExperimentInputResources() {
- return experimentInputResources;
- }
-
- public void setExperimentInputResources(List<ExperimentInputExperimentCatResource> experimentInputResources) {
- this.experimentInputResources = experimentInputResources;
- }
-
- public List<ExperimentOutputExperimentCatResource> getExperimentOutputputResources() {
- return experimentOutputputResources;
- }
-
- public void setExperimentOutputputResources(List<ExperimentOutputExperimentCatResource> experimentOutputputResources) {
- this.experimentOutputputResources = experimentOutputputResources;
- }
-
- public ComputationSchedulingExperimentCatResource getComputationSchedulingResource() {
- return computationSchedulingResource;
- }
-
- public void setComputationSchedulingResource(ComputationSchedulingExperimentCatResource computationSchedulingResource) {
- this.computationSchedulingResource = computationSchedulingResource;
- }
-
- public ConfigDataExperimentCatResource getUserConfigDataResource() {
- return userConfigDataResource;
- }
-
- public void setUserConfigDataResource(ConfigDataExperimentCatResource userConfigDataResource) {
- this.userConfigDataResource = userConfigDataResource;
- }
-
- public List<WorkflowNodeDetailExperimentCatResource> getWorkflowNodeDetailResourceList() {
- return workflowNodeDetailResourceList;
- }
-
- public void setWorkflowNodeDetailResourceList(List<WorkflowNodeDetailExperimentCatResource> workflowNodeDetailResourceList) {
- this.workflowNodeDetailResourceList = workflowNodeDetailResourceList;
- }
-
- public List<StatusExperimentCatResource> getStateChangeList() {
- return stateChangeList;
- }
-
- public void setStateChangeList(List<StatusExperimentCatResource> stateChangeList) {
- this.stateChangeList = stateChangeList;
- }
-
- public List<ErrorDetailExperimentCatResource> getErrorDetailList() {
- return errorDetailList;
- }
-
- public void setErrorDetailList(List<ErrorDetailExperimentCatResource> errorDetailList) {
- this.errorDetailList = errorDetailList;
- }
-
- public void setExperimentStatus(StatusExperimentCatResource experimentStatus) {
- this.experimentStatus = experimentStatus;
- }
-
- public List<NotificationEmailExperimentCatResource> getEmailResourceList() {
- return emailResourceList;
- }
-
- public void setEmailResourceList(List<NotificationEmailExperimentCatResource> emailResourceList) {
- this.emailResourceList = emailResourceList;
- }
-
-
- /**
- * Since experiments are at the leaf level, this method is not
- * valid for an experiment
- * @param type child resource types
- * @return UnsupportedOperationException
- */
- public ExperimentCatResource create(ResourceType type) throws RegistryException {
- switch (type){
- case EXPERIMENT_INPUT:
- ExperimentInputExperimentCatResource inputResource = new ExperimentInputExperimentCatResource();
- inputResource.setExperimentId(expID);
- return inputResource;
- case EXPERIMENT_OUTPUT:
- ExperimentOutputExperimentCatResource experimentOutputResource = new ExperimentOutputExperimentCatResource();
- experimentOutputResource.setExperimentId(expID);
- return experimentOutputResource;
- case NOTIFICATION_EMAIL:
- NotificationEmailExperimentCatResource emailResource = new NotificationEmailExperimentCatResource();
- emailResource.setExperimentId(expID);
- return emailResource;
- case WORKFLOW_NODE_DETAIL:
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = new WorkflowNodeDetailExperimentCatResource();
- nodeDetailResource.setExperimentId(expID);
- return nodeDetailResource;
- case ERROR_DETAIL:
- ErrorDetailExperimentCatResource errorDetailResource = new ErrorDetailExperimentCatResource();
- errorDetailResource.setExperimentId(expID);
- return errorDetailResource;
- case STATUS:
- StatusExperimentCatResource statusResource = new StatusExperimentCatResource();
- statusResource.setExperimentId(expID);
- return statusResource;
- case CONFIG_DATA:
- ConfigDataExperimentCatResource configDataResource = new ConfigDataExperimentCatResource();
- configDataResource.setExperimentId(expID);
- return configDataResource;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- ComputationSchedulingExperimentCatResource schedulingResource = new ComputationSchedulingExperimentCatResource();
- schedulingResource.setExperimentId(expID);
- return schedulingResource;
- case ADVANCE_INPUT_DATA_HANDLING:
- AdvanceInputDataHandlingExperimentCatResource dataHandlingResource = new AdvanceInputDataHandlingExperimentCatResource();
- dataHandlingResource.setExperimentId(expID);
- return dataHandlingResource;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- AdvancedOutputDataHandlingExperimentCatResource outputDataHandlingResource = new AdvancedOutputDataHandlingExperimentCatResource();
- outputDataHandlingResource.setExperimentId(expID);
- return outputDataHandlingResource;
- case QOS_PARAM:
- QosParamExperimentCatResource qosParamResource = new QosParamExperimentCatResource();
- qosParamResource.setExperimentId(expID);
- return qosParamResource;
- default:
- logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for experiment resource.");
- }
- }
-
- /**
- *
- * @param type child resource types
- * @param name name of the child resource
- * @return UnsupportedOperationException
- */
- public void remove(ResourceType type, Object name) throws RegistryException {
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- switch (type) {
- case EXPERIMENT_INPUT:
- generator = new QueryGenerator(EXPERIMENT_INPUT);
- generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case EXPERIMENT_OUTPUT:
- generator = new QueryGenerator(EXPERIMENT_OUTPUT);
- generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case WORKFLOW_NODE_DETAIL:
- generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
- generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.EXPERIMENT.toString());
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case CONFIG_DATA:
- generator = new QueryGenerator(CONFIG_DATA);
- generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
- generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ADVANCE_INPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
- generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
- generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- case QOS_PARAM:
- generator = new QueryGenerator(QOS_PARAMS);
- generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
- q = generator.deleteQuery(em);
- q.executeUpdate();
- break;
- default:
- logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
- break;
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @param type child resource types
- * @param name name of the child resource
- * @return UnsupportedOperationException
- */
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- QueryGenerator generator;
- Query q;
- switch (type) {
- case EXPERIMENT_INPUT:
- generator = new QueryGenerator(EXPERIMENT_INPUT);
- generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- Experiment_Input experimentInput = (Experiment_Input) q.getSingleResult();
- ExperimentInputExperimentCatResource inputResource = (ExperimentInputExperimentCatResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, experimentInput);
- em.getTransaction().commit();
- em.close();
- return inputResource;
- case EXPERIMENT_OUTPUT:
- generator = new QueryGenerator(EXPERIMENT_OUTPUT);
- generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- Experiment_Output experimentOutput = (Experiment_Output) q.getSingleResult();
- ExperimentOutputExperimentCatResource outputResource = (ExperimentOutputExperimentCatResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, experimentOutput);
- em.getTransaction().commit();
- em.close();
- return outputResource;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- Notification_Email notificationEmail = (Notification_Email) q.getSingleResult();
- NotificationEmailExperimentCatResource notificationEmailResource = (NotificationEmailExperimentCatResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
- em.getTransaction().commit();
- em.close();
- return notificationEmailResource;
- case WORKFLOW_NODE_DETAIL:
- generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
- generator.setParameter(WorkflowNodeDetailsConstants.NODE_INSTANCE_ID, name);
- q = generator.selectQuery(em);
- WorkflowNodeDetail workflowNodeDetail = (WorkflowNodeDetail) q.getSingleResult();
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = (WorkflowNodeDetailExperimentCatResource) Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, workflowNodeDetail);
- em.getTransaction().commit();
- em.close();
- return nodeDetailResource;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- ErrorDetail errorDetail = (ErrorDetail) q.getSingleResult();
- ErrorDetailExperimentCatResource errorDetailResource = (ErrorDetailExperimentCatResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- em.getTransaction().commit();
- em.close();
- return errorDetailResource;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.EXPERIMENT_ID, name);
- generator.setParameter(StatusConstants.STATUS_TYPE, StatusType.EXPERIMENT.toString());
- q = generator.selectQuery(em);
- Status status = (Status) q.getSingleResult();
- StatusExperimentCatResource statusResource = (StatusExperimentCatResource) Utils.getResource(ResourceType.STATUS, status);
- em.getTransaction().commit();
- em.close();
- return statusResource;
- case CONFIG_DATA:
- generator = new QueryGenerator(CONFIG_DATA);
- generator.setParameter(ExperimentConfigurationDataConstants.EXPERIMENT_ID, name);
- q = generator.selectQuery(em);
- ExperimentConfigData configData = (ExperimentConfigData) q.getSingleResult();
- ConfigDataExperimentCatResource configDataResource = (ConfigDataExperimentCatResource) Utils.getResource(ResourceType.CONFIG_DATA, configData);
- em.getTransaction().commit();
- em.close();
- return configDataResource;
- case COMPUTATIONAL_RESOURCE_SCHEDULING:
- generator = new QueryGenerator(COMPUTATIONAL_RESOURCE_SCHEDULING);
- generator.setParameter(ComputationalResourceSchedulingConstants.EXPERIMENT_ID, name);
- generator.setParameter(ComputationalResourceSchedulingConstants.TASK_ID, null);
- q = generator.selectQuery(em);
- Computational_Resource_Scheduling scheduling = (Computational_Resource_Scheduling) q.getSingleResult();
- ComputationSchedulingExperimentCatResource schedulingResource = (ComputationSchedulingExperimentCatResource) Utils.getResource(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, scheduling);
- em.getTransaction().commit();
- em.close();
- return schedulingResource;
- case ADVANCE_INPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_INPUT_DATA_HANDLING);
- generator.setParameter(AdvancedInputDataHandlingConstants.EXPERIMENT_ID, name);
- generator.setParameter(AdvancedInputDataHandlingConstants.TASK_ID, null);
- q = generator.selectQuery(em);
- AdvancedInputDataHandling inputDataHandling = (AdvancedInputDataHandling) q.getSingleResult();
- AdvanceInputDataHandlingExperimentCatResource dataHandlingResource = (AdvanceInputDataHandlingExperimentCatResource) Utils.getResource(ResourceType.ADVANCE_INPUT_DATA_HANDLING, inputDataHandling);
- em.getTransaction().commit();
- em.close();
- return dataHandlingResource;
- case ADVANCE_OUTPUT_DATA_HANDLING:
- generator = new QueryGenerator(ADVANCE_OUTPUT_DATA_HANDLING);
- generator.setParameter(AdvancedOutputDataHandlingConstants.EXPERIMENT_ID, name);
- generator.setParameter(AdvancedOutputDataHandlingConstants.TASK_ID, null);
- q = generator.selectQuery(em);
- AdvancedOutputDataHandling outputDataHandling = (AdvancedOutputDataHandling) q.getSingleResult();
- AdvancedOutputDataHandlingExperimentCatResource outputDataHandlingResource = (AdvancedOutputDataHandlingExperimentCatResource) Utils.getResource(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, outputDataHandling);
- em.getTransaction().commit();
- em.close();
- return outputDataHandlingResource;
- case QOS_PARAM:
- generator = new QueryGenerator(QOS_PARAMS);
- generator.setParameter(QosParamsConstants.EXPERIMENT_ID, name);
- generator.setParameter(QosParamsConstants.TASK_ID, null);
- q = generator.selectQuery(em);
- QosParam qosParam = (QosParam) q.getSingleResult();
- QosParamExperimentCatResource qosParamResource = (QosParamExperimentCatResource) Utils.getResource(ResourceType.QOS_PARAM, qosParam);
- em.getTransaction().commit();
- em.close();
- return qosParamResource;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
- throw new IllegalArgumentException("Unsupported resource type for experiment data resource.");
- }
- } catch (Exception e) {
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
-
- }
-
- /**
- *
- * @param type child resource types
- * @return UnsupportedOperationException
- */
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException{
- List<ExperimentCatResource> resourceList = new ArrayList<ExperimentCatResource>();
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Query q;
- QueryGenerator generator;
- List results;
- switch (type) {
- case EXPERIMENT_INPUT:
- generator = new QueryGenerator(EXPERIMENT_INPUT);
- generator.setParameter(ExperimentInputConstants.EXPERIMENT_ID, expID);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Experiment_Input exInput = (Experiment_Input) result;
- ExperimentInputExperimentCatResource inputResource =
- (ExperimentInputExperimentCatResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, exInput);
- resourceList.add(inputResource);
- }
- }
- break;
- case EXPERIMENT_OUTPUT:
- generator = new QueryGenerator(EXPERIMENT_OUTPUT);
- generator.setParameter(ExperimentOutputConstants.EXPERIMENT_ID, expID);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Experiment_Output output = (Experiment_Output) result;
- ExperimentOutputExperimentCatResource outputResource =
- (ExperimentOutputExperimentCatResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, output);
- resourceList.add(outputResource);
- }
- }
- break;
- case NOTIFICATION_EMAIL:
- generator = new QueryGenerator(NOTIFICATION_EMAIL);
- generator.setParameter(NotificationEmailConstants.EXPERIMENT_ID, expID);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Notification_Email notificationEmail = (Notification_Email) result;
- NotificationEmailExperimentCatResource emailResource =
- (NotificationEmailExperimentCatResource) Utils.getResource(ResourceType.NOTIFICATION_EMAIL, notificationEmail);
- resourceList.add(emailResource);
- }
- }
- break;
- case WORKFLOW_NODE_DETAIL:
- generator = new QueryGenerator(WORKFLOW_NODE_DETAIL);
- generator.setParameter(WorkflowNodeDetailsConstants.EXPERIMENT_ID, expID);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- WorkflowNodeDetail nodeDetail = (WorkflowNodeDetail) result;
- WorkflowNodeDetailExperimentCatResource nodeDetailResource =
- (WorkflowNodeDetailExperimentCatResource) Utils.getResource(ResourceType.WORKFLOW_NODE_DETAIL, nodeDetail);
- resourceList.add(nodeDetailResource);
- }
- }
- break;
- case ERROR_DETAIL:
- generator = new QueryGenerator(ERROR_DETAIL);
- generator.setParameter(ErrorDetailConstants.EXPERIMENT_ID, expID);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- ErrorDetail errorDetail = (ErrorDetail) result;
- ErrorDetailExperimentCatResource errorDetailResource =
- (ErrorDetailExperimentCatResource) Utils.getResource(ResourceType.ERROR_DETAIL, errorDetail);
- resourceList.add(errorDetailResource);
- }
- }
- break;
- case STATUS:
- generator = new QueryGenerator(STATUS);
- generator.setParameter(StatusConstants.EXPERIMENT_ID, expID);
- q = generator.selectQuery(em);
- results = q.getResultList();
- if (results.size() != 0) {
- for (Object result : results) {
- Status status = (Status) result;
- StatusExperimentCatResource statusResource =
- (StatusExperimentCatResource) Utils.getResource(ResourceType.STATUS, status);
- resourceList.add(statusResource);
- }
- }
- break;
- default:
- em.getTransaction().commit();
- em.close();
- logger.error("Unsupported resource type for experiment 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;
- }
-
- /**
- * save experiment
- */
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- Experiment existingExp = em.find(Experiment.class, expID);
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Experiment experiment = new Experiment();
- experiment.setProjectID(projectId);
- experiment.setExpId(expID);
- experiment.setExecutionUser(executionUser);
- experiment.setExecutionUser(executionUser);
- experiment.setGatewayId(gatewayId);
- experiment.setCreationTime(creationTime);
- experiment.setExpName(expName);
- experiment.setExpDesc(description);
- experiment.setApplicationId(applicationId);
- experiment.setAppVersion(applicationVersion);
- experiment.setWorkflowExecutionId(workflowExecutionId);
- experiment.setWorkflowTemplateVersion(workflowTemplateVersion);
- experiment.setWorkflowExecutionId(workflowExecutionId);
- experiment.setAllowNotification(enableEmailNotifications);
- experiment.setGatewayExecutionId(gatewayExecutionId);
- if (existingExp != null) {
- existingExp.setGatewayId(gatewayId);
- existingExp.setExecutionUser(executionUser);
- existingExp.setProjectID(projectId);
- existingExp.setCreationTime(creationTime);
- existingExp.setExpName(expName);
- existingExp.setExpDesc(description);
- existingExp.setApplicationId(applicationId);
- existingExp.setAppVersion(applicationVersion);
- existingExp.setWorkflowExecutionId(workflowExecutionId);
- existingExp.setWorkflowTemplateVersion(workflowTemplateVersion);
- existingExp.setWorkflowExecutionId(workflowExecutionId);
- existingExp.setAllowNotification(enableEmailNotifications);
- existingExp.setGatewayExecutionId(gatewayExecutionId);
- experiment = em.merge(existingExp);
- } else {
- em.persist(experiment);
- }
- em.getTransaction().commit();
- em.close();
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- throw new RegistryException(e);
- } finally {
- if (em != null && em.isOpen()) {
- if (em.getTransaction().isActive()){
- em.getTransaction().rollback();
- }
- em.close();
- }
- }
- }
-
- /**
- *
- * @param expID experiment ID
- */
- public void setExpID(String expID) {
- this.expID = expID;
- }
-
- public String getExecutionUser() {
- return executionUser;
- }
-
- public void setExecutionUser(String executionUser) {
- this.executionUser = executionUser;
- }
-
- public List<NotificationEmailExperimentCatResource> getNotificationEmails () throws RegistryException{
- List<NotificationEmailExperimentCatResource> emailResources = new ArrayList<NotificationEmailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.NOTIFICATION_EMAIL);
- for (ExperimentCatResource resource : resources) {
- emailResources.add((NotificationEmailExperimentCatResource) resource);
- }
- return emailResources;
- }
-
- public List<ExperimentInputExperimentCatResource> getExperimentInputs () throws RegistryException{
- List<ExperimentInputExperimentCatResource> expInputs = new ArrayList<ExperimentInputExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT_INPUT);
- for (ExperimentCatResource resource : resources) {
- expInputs.add((ExperimentInputExperimentCatResource) resource);
- }
- return expInputs;
- }
-
- public List<ExperimentOutputExperimentCatResource> getExperimentOutputs () throws RegistryException{
- List<ExperimentOutputExperimentCatResource> expOutputs = new ArrayList<ExperimentOutputExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.EXPERIMENT_OUTPUT);
- for (ExperimentCatResource resource : resources) {
- expOutputs.add((ExperimentOutputExperimentCatResource) resource);
- }
- return expOutputs;
- }
-
- public StatusExperimentCatResource getExperimentStatus() throws RegistryException{
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusExperimentCatResource expStatus = (StatusExperimentCatResource) resource;
- if(expStatus.getStatusType().equals(StatusType.EXPERIMENT.toString())){
- if (expStatus.getState() == null || expStatus.getState().equals("") ){
- expStatus.setState("UNKNOWN");
- }
- return expStatus;
- }
- }
- return null;
- }
-
- public List<StatusExperimentCatResource> getWorkflowNodeStatuses() throws RegistryException{
- List<StatusExperimentCatResource> statuses = new ArrayList<StatusExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.STATUS);
- for (ExperimentCatResource resource : resources) {
- StatusExperimentCatResource workflowNodeStatus = (StatusExperimentCatResource) resource;
- if(workflowNodeStatus.getStatusType().equals(StatusType.WORKFLOW_NODE.toString())){
- if (workflowNodeStatus.getState() == null || workflowNodeStatus.getState().equals("")){
- workflowNodeStatus.setState("UNKNOWN");
- }
- statuses.add(workflowNodeStatus);
- }
- }
- return statuses;
- }
-
- public List<WorkflowNodeDetailExperimentCatResource> getWorkflowNodeDetails () throws RegistryException{
- List<WorkflowNodeDetailExperimentCatResource> workflowNodeDetailResourceList = new ArrayList<WorkflowNodeDetailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.WORKFLOW_NODE_DETAIL);
- for (ExperimentCatResource resource : resources) {
- WorkflowNodeDetailExperimentCatResource nodeDetailResource = (WorkflowNodeDetailExperimentCatResource) resource;
- workflowNodeDetailResourceList.add(nodeDetailResource);
- }
- return workflowNodeDetailResourceList;
- }
-
- public List<ErrorDetailExperimentCatResource> getErrorDetails () throws RegistryException{
- List<ErrorDetailExperimentCatResource> errorDetailResources = new ArrayList<ErrorDetailExperimentCatResource>();
- List<ExperimentCatResource> resources = get(ResourceType.ERROR_DETAIL);
- for (ExperimentCatResource resource : resources) {
- ErrorDetailExperimentCatResource errorDetailResource = (ErrorDetailExperimentCatResource) resource;
- errorDetailResources.add(errorDetailResource);
- }
- return errorDetailResources;
- }
-
- public ComputationSchedulingExperimentCatResource getComputationScheduling (String expId) throws RegistryException{
- return (ComputationSchedulingExperimentCatResource)get(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, expId);
- }
-
- public AdvanceInputDataHandlingExperimentCatResource getInputDataHandling (String expId) throws RegistryException{
- return (AdvanceInputDataHandlingExperimentCatResource)get(ResourceType.ADVANCE_INPUT_DATA_HANDLING, expId);
- }
-
- public AdvancedOutputDataHandlingExperimentCatResource getOutputDataHandling (String expId) throws RegistryException{
- return (AdvancedOutputDataHandlingExperimentCatResource)get(ResourceType.ADVANCE_OUTPUT_DATA_HANDLING, expId);
- }
-
- public QosParamExperimentCatResource getQOSparams (String expId) throws RegistryException{
- return (QosParamExperimentCatResource)get(ResourceType.QOS_PARAM, expId);
- }
-
- public ConfigDataExperimentCatResource getUserConfigData(String expID) throws RegistryException{
- return (ConfigDataExperimentCatResource)get(ResourceType.CONFIG_DATA, expID);
- }
- public WorkflowNodeDetailExperimentCatResource getWorkflowNode (String nodeId) throws RegistryException{
- return (WorkflowNodeDetailExperimentCatResource)get(ResourceType.WORKFLOW_NODE_DETAIL, nodeId);
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputExperimentCatResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputExperimentCatResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputExperimentCatResource.java
deleted file mode 100644
index d921e54..0000000
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputExperimentCatResource.java
+++ /dev/null
@@ -1,225 +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.registry.core.experiment.catalog.resources;
-
-import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
-import org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Input;
-import org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Input_PK;
-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 ExperimentInputExperimentCatResource extends AbstractExperimentCatResource {
- private static final Logger logger = LoggerFactory.getLogger(ExperimentInputExperimentCatResource.class);
-
- private String experimentId;
- private String experimentKey;
- private String value;
- private String metadata;
- private String dataType;
- private String appArgument;
- private boolean standardInput;
- private String userFriendlyDesc;
- private int inputOrder;
- private boolean isRequired;
- private boolean requiredToCMD;
- private boolean dataStaged;
-
- public boolean getRequired() {
- return isRequired;
- }
-
- public void setRequired(boolean required) {
- this.isRequired = required;
- }
-
- public boolean getRequiredToCMD() {
- return requiredToCMD;
- }
-
- public void setRequiredToCMD(boolean requiredToCMD) {
- this.requiredToCMD = requiredToCMD;
- }
-
- public boolean isDataStaged() {
- return dataStaged;
- }
-
- public void setDataStaged(boolean dataStaged) {
- this.dataStaged = dataStaged;
- }
-
- public 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 getExperimentKey() {
- return experimentKey;
- }
-
- public void setExperimentKey(String experimentKey) {
- this.experimentKey = experimentKey;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getExperimentId() {
- return experimentId;
- }
-
- public void setExperimentId(String experimentId) {
- this.experimentId = experimentId;
- }
-
- 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 ExperimentCatResource create(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public void remove(ResourceType type, Object name) throws RegistryException{
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
- logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
- throw new UnsupportedOperationException();
- }
-
- public void save() throws RegistryException{
- EntityManager em = null;
- try {
- em = ExpCatResourceUtils.getEntityManager();
- Experiment_Input existingInput = em.find(Experiment_Input.class, new Experiment_Input_PK(experimentId, experimentKey));
- em.close();
-
- em = ExpCatResourceUtils.getEntityManager();
- em.getTransaction().begin();
- Experiment_Input exInput = new Experiment_Input();
- exInput.setEx_key(experimentKey);
- exInput.setExperiment_id(experimentId);
- if (value != null){
- exInput.setValue(value.toCharArray());
- }
- exInput.setDataType(dataType);
- exInput.setMetadata(metadata);
- exInput.setAppArgument(appArgument);
- exInput.setStandardInput(standardInput);
- exInput.setUserFriendlyDesc(userFriendlyDesc);
- exInput.setInputOrder(inputOrder);
- exInput.setRequiredToCMD(requiredToCMD);
- exInput.setRequired(isRequired);
- exInput.setDataStaged(dataStaged);
- if (existingInput != null) {
- existingInput.setEx_key(experimentKey);
- existingInput.setExperiment_id(experimentId);
- if (value != null){
- existingInput.setValue(value.toCharArray());
- }
- existingInput.setDataType(dataType);
- existingInput.setMetadata(metadata);
- existingInput.setAppArgument(appArgument);
- existingInput.setStandardInput(standardInput);
- existingInput.setUserFriendlyDesc(userFriendlyDesc);
- existingInput.setInputOrder(inputOrder);
- existingInput.setRequiredToCMD(requiredToCMD);
- existingInput.setRequired(isRequired);
- existingInput.setDataStaged(dataStaged);
- exInput = em.merge(existingInput);
- } else {
- em.persist(exInput);
- }
- 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/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputResource.java
new file mode 100644
index 0000000..4c3f646
--- /dev/null
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentInputResource.java
@@ -0,0 +1,225 @@
+/*
+*
+* 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.registry.core.experiment.catalog.resources;
+
+import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
+import org.apache.airavata.registry.core.experiment.catalog.ExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.ResourceType;
+import org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Input;
+import org.apache.airavata.registry.core.experiment.catalog.model.Experiment_Input_PK;
+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 ExperimentInputResource extends AbstractExpCatResource {
+ private static final Logger logger = LoggerFactory.getLogger(ExperimentInputResource.class);
+
+ private String experimentId;
+ private String experimentKey;
+ private String value;
+ private String metadata;
+ private String dataType;
+ private String appArgument;
+ private boolean standardInput;
+ private String userFriendlyDesc;
+ private int inputOrder;
+ private boolean isRequired;
+ private boolean requiredToCMD;
+ private boolean dataStaged;
+
+ public boolean getRequired() {
+ return isRequired;
+ }
+
+ public void setRequired(boolean required) {
+ this.isRequired = required;
+ }
+
+ public boolean getRequiredToCMD() {
+ return requiredToCMD;
+ }
+
+ public void setRequiredToCMD(boolean requiredToCMD) {
+ this.requiredToCMD = requiredToCMD;
+ }
+
+ public boolean isDataStaged() {
+ return dataStaged;
+ }
+
+ public void setDataStaged(boolean dataStaged) {
+ this.dataStaged = dataStaged;
+ }
+
+ public 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 getExperimentKey() {
+ return experimentKey;
+ }
+
+ public void setExperimentKey(String experimentKey) {
+ this.experimentKey = experimentKey;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getExperimentId() {
+ return experimentId;
+ }
+
+ public void setExperimentId(String experimentId) {
+ this.experimentId = experimentId;
+ }
+
+ 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 ExperimentCatResource create(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public void remove(ResourceType type, Object name) throws RegistryException{
+ logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public ExperimentCatResource get(ResourceType type, Object name) throws RegistryException {
+ logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public List<ExperimentCatResource> get(ResourceType type) throws RegistryException {
+ logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException());
+ throw new UnsupportedOperationException();
+ }
+
+ public void save() throws RegistryException{
+ EntityManager em = null;
+ try {
+ em = ExpCatResourceUtils.getEntityManager();
+ Experiment_Input existingInput = em.find(Experiment_Input.class, new Experiment_Input_PK(experimentId, experimentKey));
+ em.close();
+
+ em = ExpCatResourceUtils.getEntityManager();
+ em.getTransaction().begin();
+ Experiment_Input exInput = new Experiment_Input();
+ exInput.setEx_key(experimentKey);
+ exInput.setExperiment_id(experimentId);
+ if (value != null){
+ exInput.setValue(value.toCharArray());
+ }
+ exInput.setDataType(dataType);
+ exInput.setMetadata(metadata);
+ exInput.setAppArgument(appArgument);
+ exInput.setStandardInput(standardInput);
+ exInput.setUserFriendlyDesc(userFriendlyDesc);
+ exInput.setInputOrder(inputOrder);
+ exInput.setRequiredToCMD(requiredToCMD);
+ exInput.setRequired(isRequired);
+ exInput.setDataStaged(dataStaged);
+ if (existingInput != null) {
+ existingInput.setEx_key(experimentKey);
+ existingInput.setExperiment_id(experimentId);
+ if (value != null){
+ existingInput.setValue(value.toCharArray());
+ }
+ existingInput.setDataType(dataType);
+ existingInput.setMetadata(metadata);
+ existingInput.setAppArgument(appArgument);
+ existingInput.setStandardInput(standardInput);
+ existingInput.setUserFriendlyDesc(userFriendlyDesc);
+ existingInput.setInputOrder(inputOrder);
+ existingInput.setRequiredToCMD(requiredToCMD);
+ existingInput.setRequired(isRequired);
+ existingInput.setDataStaged(dataStaged);
+ exInput = em.merge(existingInput);
+ } else {
+ em.persist(exInput);
+ }
+ 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();
+ }
+ }
+ }
+}
[13/30] airavata git commit: registry refactoring changes
Posted by ch...@apache.org.
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
index cc0abc8..9fa0b59 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogThriftConversion.java
@@ -44,8 +44,8 @@ import org.apache.airavata.registry.cpi.AppCatalogException;
import java.util.*;
public class AppCatalogThriftConversion {
- public static ComputeResourceAppCatalogResourceAppCat getComputeHostResource (ComputeResourceDescription description){
- ComputeResourceAppCatalogResourceAppCat resource = new ComputeResourceAppCatalogResourceAppCat();
+ public static ComputeResourceResource getComputeHostResource (ComputeResourceDescription description){
+ ComputeResourceResource resource = new ComputeResourceResource();
resource.setHostName(description.getHostName());
resource.setResourceDescription(description.getResourceDescription());
resource.setResourceId(description.getComputeResourceId());
@@ -53,46 +53,46 @@ public class AppCatalogThriftConversion {
return resource;
}
- public static ComputeResourceDescription getComputeHostDescription (ComputeResourceAppCatalogResourceAppCat resource) throws AppCatalogException {
+ public static ComputeResourceDescription getComputeHostDescription (ComputeResourceResource resource) throws AppCatalogException {
ComputeResourceDescription description = new ComputeResourceDescription();
description.setComputeResourceId(resource.getResourceId());
description.setHostName(resource.getHostName());
description.setResourceDescription(resource.getResourceDescription());
description.setMaxMemoryPerNode(resource.getMaxMemoryPerNode());
- HostAliasAppCatalogResourceAppCat aliasResource = new HostAliasAppCatalogResourceAppCat();
+ HostAliasAppResource aliasResource = new HostAliasAppResource();
List<AppCatalogResource> resources = aliasResource.get(AppCatAbstractResource.HostAliasConstants.RESOURCE_ID, resource.getResourceId());
if (resources != null && !resources.isEmpty()){
description.setHostAliases(getHostAliases(resources));
}
- HostIPAddressAppCatalogResourceAppCat ipAddressResource = new HostIPAddressAppCatalogResourceAppCat();
+ HostIPAddressResource ipAddressResource = new HostIPAddressResource();
List<AppCatalogResource> ipAddresses = ipAddressResource.get(AppCatAbstractResource.HostIPAddressConstants.RESOURCE_ID, resource.getResourceId());
if (ipAddresses != null && !ipAddresses.isEmpty()){
description.setIpAddresses(getIpAddresses(ipAddresses));
}
- BatchQueueAppCatalogResourceAppCat bqResource = new BatchQueueAppCatalogResourceAppCat();
+ BatchQueueResource bqResource = new BatchQueueResource();
List<AppCatalogResource> batchQueues = bqResource.get(AppCatAbstractResource.BatchQueueConstants.COMPUTE_RESOURCE_ID, resource.getResourceId());
if (batchQueues != null && !batchQueues.isEmpty()){
description.setBatchQueues(getBatchQueues(batchQueues));
}
- ComputeResourceFileSystemAppCatalogResourceAppCat fsResource = new ComputeResourceFileSystemAppCatalogResourceAppCat();
+ ComputeResourceFileSystemResource fsResource = new ComputeResourceFileSystemResource();
List<AppCatalogResource> fsList = fsResource.get(AppCatAbstractResource.ComputeResourceFileSystemConstants.COMPUTE_RESOURCE_ID, resource.getResourceId());
description.setFileSystems(new HashMap<FileSystems,String>());
if (fsList != null && !fsList.isEmpty()){
for (AppCatalogResource r : fsList) {
- ComputeResourceFileSystemAppCatalogResourceAppCat rr=(ComputeResourceFileSystemAppCatalogResourceAppCat)r;
+ ComputeResourceFileSystemResource rr=(ComputeResourceFileSystemResource)r;
description.getFileSystems().put(FileSystems.valueOf(rr.getFileSystem()), rr.getPath());
}
}
- JobSubmissionInterfaceAppCatalogResourceAppCat jsiResource = new JobSubmissionInterfaceAppCatalogResourceAppCat();
+ JobSubmissionInterfaceResource jsiResource = new JobSubmissionInterfaceResource();
List<AppCatalogResource> hsiList = jsiResource.get(AppCatAbstractResource.JobSubmissionInterfaceConstants.COMPUTE_RESOURCE_ID, resource.getResourceId());
if (hsiList != null && !hsiList.isEmpty()){
description.setJobSubmissionInterfaces(getJobSubmissionInterfaces(hsiList));
}
- DataMovementInterfaceAppCatalogResourceAppCat dmiResource = new DataMovementInterfaceAppCatalogResourceAppCat();
+ DataMovementInterfaceResource dmiResource = new DataMovementInterfaceResource();
List<AppCatalogResource> dmiList = dmiResource.get(AppCatAbstractResource.DataMovementInterfaceConstants.COMPUTE_RESOURCE_ID, resource.getResourceId());
if (dmiList != null && !dmiList.isEmpty()){
description.setDataMovementInterfaces(getDataMovementInterfaces(dmiList));
@@ -103,7 +103,7 @@ public class AppCatalogThriftConversion {
public static List<ComputeResourceDescription> getComputeDescriptionList (List<AppCatalogResource> resources) throws AppCatalogException {
List<ComputeResourceDescription> list = new ArrayList<ComputeResourceDescription>();
for (AppCatalogResource resource : resources){
- list.add(getComputeHostDescription((ComputeResourceAppCatalogResourceAppCat)resource));
+ list.add(getComputeHostDescription((ComputeResourceResource)resource));
}
return list;
}
@@ -111,7 +111,7 @@ public class AppCatalogThriftConversion {
public static List<String> getHostAliases (List<AppCatalogResource> resources){
List<String> hostAliases = new ArrayList<String>();
for (AppCatalogResource alias : resources){
- hostAliases.add(((HostAliasAppCatalogResourceAppCat)alias).getAlias());
+ hostAliases.add(((HostAliasAppResource)alias).getAlias());
}
return hostAliases;
}
@@ -119,7 +119,7 @@ public class AppCatalogThriftConversion {
public static List<String> getIpAddresses (List<AppCatalogResource> resources){
List<String> hostIpAddresses = new ArrayList<String>();
for (AppCatalogResource resource : resources){
- hostIpAddresses.add(((HostIPAddressAppCatalogResourceAppCat)resource).getIpaddress());
+ hostIpAddresses.add(((HostIPAddressResource)resource).getIpaddress());
}
return hostIpAddresses;
}
@@ -127,7 +127,7 @@ public class AppCatalogThriftConversion {
public static List<BatchQueue> getBatchQueues (List<AppCatalogResource> resources){
List<BatchQueue> batchQueues = new ArrayList<BatchQueue>();
for (AppCatalogResource resource : resources){
- batchQueues.add(getBatchQueue((BatchQueueAppCatalogResourceAppCat)resource));
+ batchQueues.add(getBatchQueue((BatchQueueResource)resource));
}
return batchQueues;
}
@@ -135,12 +135,12 @@ public class AppCatalogThriftConversion {
public static List<DataMovementInterface> getDataMovementInterfaces(List<AppCatalogResource> resources){
List<DataMovementInterface> dataMovementInterfaces = new ArrayList<DataMovementInterface>();
for (AppCatalogResource resource : resources){
- dataMovementInterfaces.add(getDataMovementInterface((DataMovementInterfaceAppCatalogResourceAppCat)resource));
+ dataMovementInterfaces.add(getDataMovementInterface((DataMovementInterfaceResource)resource));
}
return dataMovementInterfaces;
}
- public static DataMovementInterface getDataMovementInterface(DataMovementInterfaceAppCatalogResourceAppCat resource){
+ public static DataMovementInterface getDataMovementInterface(DataMovementInterfaceResource resource){
DataMovementInterface dmi = new DataMovementInterface();
dmi.setDataMovementInterfaceId(resource.getDataMovementInterfaceId());
dmi.setDataMovementProtocol(DataMovementProtocol.valueOf(resource.getDataMovementProtocol()));
@@ -148,8 +148,8 @@ public class AppCatalogThriftConversion {
return dmi;
}
- public static DataMovementInterfaceAppCatalogResourceAppCat getDataMovementInterface(DataMovementInterface resource){
- DataMovementInterfaceAppCatalogResourceAppCat dmi = new DataMovementInterfaceAppCatalogResourceAppCat();
+ public static DataMovementInterfaceResource getDataMovementInterface(DataMovementInterface resource){
+ DataMovementInterfaceResource dmi = new DataMovementInterfaceResource();
dmi.setDataMovementInterfaceId(resource.getDataMovementInterfaceId());
dmi.setDataMovementProtocol(resource.getDataMovementProtocol().toString());
dmi.setPriorityOrder(resource.getPriorityOrder());
@@ -159,12 +159,12 @@ public class AppCatalogThriftConversion {
public static List<JobSubmissionInterface> getJobSubmissionInterfaces(List<AppCatalogResource> resources){
List<JobSubmissionInterface> jobSubmissionInterfaces = new ArrayList<JobSubmissionInterface>();
for (AppCatalogResource resource : resources){
- jobSubmissionInterfaces.add(getJobSubmissionInterface((JobSubmissionInterfaceAppCatalogResourceAppCat)resource));
+ jobSubmissionInterfaces.add(getJobSubmissionInterface((JobSubmissionInterfaceResource)resource));
}
return jobSubmissionInterfaces;
}
- public static JobSubmissionInterface getJobSubmissionInterface(JobSubmissionInterfaceAppCatalogResourceAppCat resource){
+ public static JobSubmissionInterface getJobSubmissionInterface(JobSubmissionInterfaceResource resource){
JobSubmissionInterface jsi = new JobSubmissionInterface();
jsi.setJobSubmissionInterfaceId(resource.getJobSubmissionInterfaceId());
jsi.setJobSubmissionProtocol(JobSubmissionProtocol.valueOf(resource.getJobSubmissionProtocol()));
@@ -172,15 +172,15 @@ public class AppCatalogThriftConversion {
return jsi;
}
- public static JobSubmissionInterfaceAppCatalogResourceAppCat getJobSubmissionInterface(JobSubmissionInterface resource){
- JobSubmissionInterfaceAppCatalogResourceAppCat jsi = new JobSubmissionInterfaceAppCatalogResourceAppCat();
+ public static JobSubmissionInterfaceResource getJobSubmissionInterface(JobSubmissionInterface resource){
+ JobSubmissionInterfaceResource jsi = new JobSubmissionInterfaceResource();
jsi.setJobSubmissionInterfaceId(resource.getJobSubmissionInterfaceId());
jsi.setJobSubmissionProtocol(resource.getJobSubmissionProtocol().toString());
jsi.setPriorityOrder(resource.getPriorityOrder());
return jsi;
}
- public static BatchQueue getBatchQueue(BatchQueueAppCatalogResourceAppCat resource){
+ public static BatchQueue getBatchQueue(BatchQueueResource resource){
BatchQueue batchQueue = new BatchQueue();
batchQueue.setMaxJobsInQueue(resource.getMaxJobInQueue());
batchQueue.setMaxNodes(resource.getMaxNodes());
@@ -192,8 +192,8 @@ public class AppCatalogThriftConversion {
return batchQueue;
}
- public static BatchQueueAppCatalogResourceAppCat getBatchQueue(BatchQueue resource){
- BatchQueueAppCatalogResourceAppCat batchQueue = new BatchQueueAppCatalogResourceAppCat();
+ public static BatchQueueResource getBatchQueue(BatchQueue resource){
+ BatchQueueResource batchQueue = new BatchQueueResource();
batchQueue.setMaxJobInQueue(resource.getMaxJobsInQueue());
batchQueue.setMaxNodes(resource.getMaxNodes());
batchQueue.setMaxProcessors(resource.getMaxProcessors());
@@ -222,11 +222,11 @@ public class AppCatalogThriftConversion {
// return protocols;
// }
- public static SshJobSubmissionAppCatalogResourceAppCat getSSHJobSubmission (SSHJobSubmission submission){
- SshJobSubmissionAppCatalogResourceAppCat resource = new SshJobSubmissionAppCatalogResourceAppCat();
+ public static SshJobSubmissionResource getSSHJobSubmission (SSHJobSubmission submission){
+ SshJobSubmissionResource resource = new SshJobSubmissionResource();
resource.setAlternativeSshHostname(submission.getAlternativeSSHHostName());
resource.setJobSubmissionInterfaceId(submission.getJobSubmissionInterfaceId());
- ResourceJobManagerAppCatalogResourceAppCat resourceJobManager = getResourceJobManager(submission.getResourceJobManager());
+ ResourceJobManagerResource resourceJobManager = getResourceJobManager(submission.getResourceJobManager());
// resourceJobManager.setResourceJobManagerId(submission.getJobSubmissionInterfaceId());
resource.setResourceJobManagerId(resourceJobManager.getResourceJobManagerId());
if (submission.getMonitorMode() != null){
@@ -241,8 +241,8 @@ public class AppCatalogThriftConversion {
}
- public static UnicoreJobSubmissionAppCatalogResourceAppCat getUnicoreJobSubmission (UnicoreJobSubmission submission){
- UnicoreJobSubmissionAppCatalogResourceAppCat resource = new UnicoreJobSubmissionAppCatalogResourceAppCat();
+ public static UnicoreJobSubmissionResource getUnicoreJobSubmission (UnicoreJobSubmission submission){
+ UnicoreJobSubmissionResource resource = new UnicoreJobSubmissionResource();
resource.setjobSubmissionInterfaceId(submission.getJobSubmissionInterfaceId());
if (submission.getSecurityProtocol() != null){
resource.setSecurityProtocol(submission.getSecurityProtocol().toString());
@@ -251,8 +251,8 @@ public class AppCatalogThriftConversion {
return resource;
}
- public static UnicoreDataMovementAppCatalogResourceAppCat getUnicoreDMResource (UnicoreDataMovement dataMovement){
- UnicoreDataMovementAppCatalogResourceAppCat resource = new UnicoreDataMovementAppCatalogResourceAppCat();
+ public static UnicoreDataMovementResource getUnicoreDMResource (UnicoreDataMovement dataMovement){
+ UnicoreDataMovementResource resource = new UnicoreDataMovementResource();
resource.setDataMovementId(dataMovement.getDataMovementInterfaceId());
if (dataMovement.getSecurityProtocol() != null){
resource.setSecurityProtocol(dataMovement.getSecurityProtocol().toString());
@@ -262,8 +262,8 @@ public class AppCatalogThriftConversion {
}
- public static CloudSubmissionAppCatalogResourceAppCat getCloudJobSubmission (CloudJobSubmission submission){
- CloudSubmissionAppCatalogResourceAppCat resource = new CloudSubmissionAppCatalogResourceAppCat();
+ public static CloudSubmissionResource getCloudJobSubmission (CloudJobSubmission submission){
+ CloudSubmissionResource resource = new CloudSubmissionResource();
resource.setJobSubmissionInterfaceId(submission.getJobSubmissionInterfaceId());
if (submission.getSecurityProtocol() != null){
resource.setSecurityProtocol(submission.getSecurityProtocol().toString());
@@ -277,37 +277,37 @@ public class AppCatalogThriftConversion {
return resource;
}
- public static LocalDataMovementAppCatalogResourceAppCat getLocalDataMovement(LOCALDataMovement localSubmission)throws AppCatalogException {
- LocalDataMovementAppCatalogResourceAppCat submission = new LocalDataMovementAppCatalogResourceAppCat();
+ public static LocalDataMovementResource getLocalDataMovement(LOCALDataMovement localSubmission)throws AppCatalogException {
+ LocalDataMovementResource submission = new LocalDataMovementResource();
submission.setDataMovementInterfaceId(localSubmission.getDataMovementInterfaceId());
return submission;
}
- public static LOCALDataMovement getLocalDataMovement(LocalDataMovementAppCatalogResourceAppCat localSubmission)throws AppCatalogException {
+ public static LOCALDataMovement getLocalDataMovement(LocalDataMovementResource localSubmission)throws AppCatalogException {
LOCALDataMovement submission = new LOCALDataMovement();
submission.setDataMovementInterfaceId(localSubmission.getDataMovementInterfaceId());
return submission;
}
- public static LocalSubmissionAppCatalogResourceAppCat getLocalJobSubmission(LOCALSubmission localSubmission)throws AppCatalogException {
- LocalSubmissionAppCatalogResourceAppCat submission = new LocalSubmissionAppCatalogResourceAppCat();
+ public static LocalSubmissionResource getLocalJobSubmission(LOCALSubmission localSubmission)throws AppCatalogException {
+ LocalSubmissionResource submission = new LocalSubmissionResource();
submission.setJobSubmissionInterfaceId(localSubmission.getJobSubmissionInterfaceId());
- ResourceJobManagerAppCatalogResourceAppCat resourceJobManager = getResourceJobManager(localSubmission.getResourceJobManager());
+ ResourceJobManagerResource resourceJobManager = getResourceJobManager(localSubmission.getResourceJobManager());
submission.setResourceJobManagerId(resourceJobManager.getResourceJobManagerId());
submission.setResourceJobManagerResource(resourceJobManager);
return submission;
}
- public static LOCALSubmission getLocalJobSubmission(LocalSubmissionAppCatalogResourceAppCat localSubmission)throws AppCatalogException {
+ public static LOCALSubmission getLocalJobSubmission(LocalSubmissionResource localSubmission)throws AppCatalogException {
LOCALSubmission submission = new LOCALSubmission();
submission.setJobSubmissionInterfaceId(localSubmission.getJobSubmissionInterfaceId());
submission.setResourceJobManager(getResourceJobManager(localSubmission.getResourceJobManagerResource()));
return submission;
}
- public static ResourceJobManagerAppCatalogResourceAppCat getResourceJobManager(ResourceJobManager manager){
- ResourceJobManagerAppCatalogResourceAppCat r = new ResourceJobManagerAppCatalogResourceAppCat();
+ public static ResourceJobManagerResource getResourceJobManager(ResourceJobManager manager){
+ ResourceJobManagerResource r = new ResourceJobManagerResource();
r.setResourceJobManagerId(manager.getResourceJobManagerId());
r.setJobManagerBinPath(manager.getJobManagerBinPath());
r.setPushMonitoringEndpoint(manager.getPushMonitoringEndpoint());
@@ -315,18 +315,18 @@ public class AppCatalogThriftConversion {
return r;
}
- public static ResourceJobManager getResourceJobManager(ResourceJobManagerAppCatalogResourceAppCat manager) throws AppCatalogException {
+ public static ResourceJobManager getResourceJobManager(ResourceJobManagerResource manager) throws AppCatalogException {
ResourceJobManager r = new ResourceJobManager();
r.setResourceJobManagerId(manager.getResourceJobManagerId());
r.setJobManagerBinPath(manager.getJobManagerBinPath());
r.setPushMonitoringEndpoint(manager.getPushMonitoringEndpoint());
r.setResourceJobManagerType(ResourceJobManagerType.valueOf(manager.getResourceJobManagerType()));
r.setJobManagerCommands(new HashMap<JobManagerCommand, String>());
- JobManagerCommandAppCatalogResourceAppCat jmcr=new JobManagerCommandAppCatalogResourceAppCat();
+ JobManagerCommandResource jmcr=new JobManagerCommandResource();
List<AppCatalogResource> jmcrList = jmcr.get(AppCatAbstractResource.JobManagerCommandConstants.RESOURCE_JOB_MANAGER_ID, manager.getResourceJobManagerId());
if (jmcrList != null && !jmcrList.isEmpty()){
for (AppCatalogResource rrr : jmcrList) {
- JobManagerCommandAppCatalogResourceAppCat rr=(JobManagerCommandAppCatalogResourceAppCat)rrr;
+ JobManagerCommandResource rr=(JobManagerCommandResource)rrr;
r.getJobManagerCommands().put(JobManagerCommand.valueOf(rr.getCommandType()), rr.getCommand());
}
}
@@ -334,7 +334,7 @@ public class AppCatalogThriftConversion {
}
- public static SSHJobSubmission getSSHJobSubmissionDescription (SshJobSubmissionAppCatalogResourceAppCat submission) throws AppCatalogException {
+ public static SSHJobSubmission getSSHJobSubmissionDescription (SshJobSubmissionResource submission) throws AppCatalogException {
SSHJobSubmission sshJobSubmission = new SSHJobSubmission();
sshJobSubmission.setAlternativeSSHHostName(submission.getAlternativeSshHostname());
sshJobSubmission.setJobSubmissionInterfaceId(submission.getJobSubmissionInterfaceId());
@@ -347,7 +347,7 @@ public class AppCatalogThriftConversion {
return sshJobSubmission;
}
- public static UnicoreJobSubmission getUnicoreJobSubmissionDescription (UnicoreJobSubmissionAppCatalogResourceAppCat submission) throws AppCatalogException {
+ public static UnicoreJobSubmission getUnicoreJobSubmissionDescription (UnicoreJobSubmissionResource submission) throws AppCatalogException {
UnicoreJobSubmission unicoreJobSubmission = new UnicoreJobSubmission();
unicoreJobSubmission.setUnicoreEndPointURL(submission.getUnicoreEndpointUrl());
unicoreJobSubmission.setJobSubmissionInterfaceId(submission.getjobSubmissionInterfaceId());
@@ -357,7 +357,7 @@ public class AppCatalogThriftConversion {
return unicoreJobSubmission;
}
- public static UnicoreDataMovement getUnicoreDMDescription (UnicoreDataMovementAppCatalogResourceAppCat resource) throws AppCatalogException {
+ public static UnicoreDataMovement getUnicoreDMDescription (UnicoreDataMovementResource resource) throws AppCatalogException {
UnicoreDataMovement dataMovement = new UnicoreDataMovement();
dataMovement.setUnicoreEndPointURL(resource.getUnicoreEndpointUrl());
dataMovement.setDataMovementInterfaceId(resource.getDataMovementId());
@@ -368,7 +368,7 @@ public class AppCatalogThriftConversion {
}
- public static CloudJobSubmission getCloudJobSubmissionDescription (CloudSubmissionAppCatalogResourceAppCat submission) throws AppCatalogException {
+ public static CloudJobSubmission getCloudJobSubmissionDescription (CloudSubmissionResource submission) throws AppCatalogException {
CloudJobSubmission cloudJobSubmission = new CloudJobSubmission();
cloudJobSubmission.setJobSubmissionInterfaceId(submission.getJobSubmissionInterfaceId());
cloudJobSubmission.setExecutableType(submission.getExecutableType());
@@ -394,7 +394,7 @@ public class AppCatalogThriftConversion {
// return globusJobSubmission;
// }
- public static SCPDataMovement getSCPDataMovementDescription (ScpDataMovementAppCatalogResourceAppCat dataMovementResource) throws AppCatalogException {
+ public static SCPDataMovement getSCPDataMovementDescription (ScpDataMovementResource dataMovementResource) throws AppCatalogException {
SCPDataMovement dataMovement = new SCPDataMovement();
dataMovement.setDataMovementInterfaceId(dataMovementResource.getDataMovementInterfaceId());
dataMovement.setAlternativeSCPHostName(dataMovementResource.getAlternativeScpHostname());
@@ -403,8 +403,8 @@ public class AppCatalogThriftConversion {
return dataMovement;
}
- public static ScpDataMovementAppCatalogResourceAppCat getSCPDataMovementDescription (SCPDataMovement dataMovementResource) throws AppCatalogException {
- ScpDataMovementAppCatalogResourceAppCat dataMovement = new ScpDataMovementAppCatalogResourceAppCat();
+ public static ScpDataMovementResource getSCPDataMovementDescription (SCPDataMovement dataMovementResource) throws AppCatalogException {
+ ScpDataMovementResource dataMovement = new ScpDataMovementResource();
dataMovement.setDataMovementInterfaceId(dataMovementResource.getDataMovementInterfaceId());
dataMovement.setAlternativeScpHostname(dataMovementResource.getAlternativeSCPHostName());
dataMovement.setSecurityProtocol(dataMovementResource.getSecurityProtocol().toString());
@@ -412,11 +412,11 @@ public class AppCatalogThriftConversion {
return dataMovement;
}
- public static GridFTPDataMovement getGridFTPDataMovementDescription (GridftpDataMovementAppCatalogResourceAppCat dataMovementResource) throws AppCatalogException {
+ public static GridFTPDataMovement getGridFTPDataMovementDescription (GridftpDataMovementResource dataMovementResource) throws AppCatalogException {
GridFTPDataMovement dataMovement = new GridFTPDataMovement();
dataMovement.setDataMovementInterfaceId(dataMovementResource.getDataMovementInterfaceId());
dataMovement.setSecurityProtocol(SecurityProtocol.valueOf(dataMovementResource.getSecurityProtocol()));
- GridftpEndpointAppCatalogResourceAppCat endpointResource = new GridftpEndpointAppCatalogResourceAppCat();
+ GridftpEndpointResource endpointResource = new GridftpEndpointResource();
List<AppCatalogResource> endpoints = endpointResource.get(AppCatAbstractResource.GridftpEndpointConstants.DATA_MOVEMENT_INTERFACE_ID, dataMovementResource.getDataMovementInterfaceId());
if (endpoints != null && !endpoints.isEmpty()){
dataMovement.setGridFTPEndPoints(getGridFTPDMEPList(endpoints));
@@ -424,8 +424,8 @@ public class AppCatalogThriftConversion {
return dataMovement;
}
- public static GridftpDataMovementAppCatalogResourceAppCat getGridFTPDataMovementDescription (GridFTPDataMovement dataMovementResource) throws AppCatalogException {
- GridftpDataMovementAppCatalogResourceAppCat dataMovement = new GridftpDataMovementAppCatalogResourceAppCat();
+ public static GridftpDataMovementResource getGridFTPDataMovementDescription (GridFTPDataMovement dataMovementResource) throws AppCatalogException {
+ GridftpDataMovementResource dataMovement = new GridftpDataMovementResource();
dataMovement.setDataMovementInterfaceId(dataMovementResource.getDataMovementInterfaceId());
dataMovement.setSecurityProtocol(dataMovementResource.getSecurityProtocol().toString());
return dataMovement;
@@ -434,7 +434,7 @@ public class AppCatalogThriftConversion {
public static List<String> getGridFTPDMEPList (List<AppCatalogResource> endpoints){
List<String> list = new ArrayList<String>();
for (AppCatalogResource resource : endpoints){
- list.add(((GridftpEndpointAppCatalogResourceAppCat) resource).getEndpoint());
+ list.add(((GridftpEndpointResource) resource).getEndpoint());
}
return list;
}
@@ -442,7 +442,7 @@ public class AppCatalogThriftConversion {
public static List<String> getGlobusGateKeeperEndPointList (List<AppCatalogResource> resources) throws AppCatalogException {
List<String> list = new ArrayList<String>();
for (AppCatalogResource resource : resources){
- list.add(((GlobusGKEndpointAppCatalogResourceAppCat) resource).getEndpoint());
+ list.add(((GlobusGKEndpointResource) resource).getEndpoint());
}
return list;
}
@@ -519,7 +519,7 @@ public class AppCatalogThriftConversion {
// return resource;
// }
- public static ApplicationModule getApplicationModuleDesc (AppModuleAppCatalogResourceAppCat resource){
+ public static ApplicationModule getApplicationModuleDesc (AppModuleResource resource){
ApplicationModule module = new ApplicationModule();
module.setAppModuleId(resource.getModuleId());
module.setAppModuleDescription(resource.getModuleDesc());
@@ -528,7 +528,7 @@ public class AppCatalogThriftConversion {
return module;
}
- public static ApplicationInterfaceDescription getApplicationInterfaceDescription (AppInterfaceAppCatalogResourceAppCat resource) throws AppCatalogException {
+ public static ApplicationInterfaceDescription getApplicationInterfaceDescription (AppInterfaceResource resource) throws AppCatalogException {
ApplicationInterfaceDescription description = new ApplicationInterfaceDescription();
description.setApplicationInterfaceId(resource.getInterfaceId());
description.setApplicationName(resource.getAppName());
@@ -540,13 +540,13 @@ public class AppCatalogThriftConversion {
description.setApplicationModules(getAppModuleIds(appModules));
}
- ApplicationInputAppCatalogResourceAppCat inputResource = new ApplicationInputAppCatalogResourceAppCat();
+ ApplicationInputResource inputResource = new ApplicationInputResource();
List<AppCatalogResource> appInputs = inputResource.get(AppCatAbstractResource.AppInputConstants.INTERFACE_ID, resource.getInterfaceId());
if (appInputs != null && !appInputs.isEmpty()){
description.setApplicationInputs(getAppInputs(appInputs));
}
- ApplicationOutputAppCatalogResourceAppCat outputResource = new ApplicationOutputAppCatalogResourceAppCat();
+ ApplicationOutputResource outputResource = new ApplicationOutputResource();
List<AppCatalogResource> appOutputs = outputResource.get(AppCatAbstractResource.AppOutputConstants.INTERFACE_ID, resource.getInterfaceId());
if (appOutputs != null && !appOutputs.isEmpty()){
description.setApplicationOutputs(getAppOutputs(appOutputs));
@@ -565,7 +565,7 @@ public class AppCatalogThriftConversion {
public static List<ApplicationModule> getAppModules (List<AppCatalogResource> appModules){
List<ApplicationModule> modules = new ArrayList<ApplicationModule>();
for (AppCatalogResource resource : appModules){
- modules.add(getApplicationModuleDesc((AppModuleAppCatalogResourceAppCat) resource));
+ modules.add(getApplicationModuleDesc((AppModuleResource) resource));
}
return modules;
}
@@ -573,7 +573,7 @@ public class AppCatalogThriftConversion {
public static List<ApplicationInterfaceDescription> getAppInterfaceDescList (List<AppCatalogResource> appInterfaces) throws AppCatalogException {
List<ApplicationInterfaceDescription> interfaceDescriptions = new ArrayList<ApplicationInterfaceDescription>();
for (AppCatalogResource resource : appInterfaces){
- interfaceDescriptions.add(getApplicationInterfaceDescription((AppInterfaceAppCatalogResourceAppCat) resource));
+ interfaceDescriptions.add(getApplicationInterfaceDescription((AppInterfaceResource) resource));
}
return interfaceDescriptions;
}
@@ -581,12 +581,12 @@ public class AppCatalogThriftConversion {
public static List<InputDataObjectType> getAppInputs (List<AppCatalogResource> resources){
List<InputDataObjectType> inputs = new ArrayList<InputDataObjectType>();
for (AppCatalogResource resource : resources){
- inputs.add(getInputDataObjType((ApplicationInputAppCatalogResourceAppCat) resource));
+ inputs.add(getInputDataObjType((ApplicationInputResource) resource));
}
return inputs;
}
- public static InputDataObjectType getInputDataObjType (ApplicationInputAppCatalogResourceAppCat input){
+ public static InputDataObjectType getInputDataObjType (ApplicationInputResource input){
InputDataObjectType inputDataObjectType = new InputDataObjectType();
inputDataObjectType.setName(input.getInputKey());
inputDataObjectType.setValue(input.getInputVal());
@@ -605,11 +605,11 @@ public class AppCatalogThriftConversion {
public static List<OutputDataObjectType> getAppOutputs (List<AppCatalogResource> resources){
List<OutputDataObjectType> outputs = new ArrayList<OutputDataObjectType>();
for (AppCatalogResource resource : resources){
- outputs.add(getOutputDataObjType((ApplicationOutputAppCatalogResourceAppCat) resource));
+ outputs.add(getOutputDataObjType((ApplicationOutputResource) resource));
}
return outputs;
}
- public static OutputDataObjectType getOutputDataObjType (ApplicationOutputAppCatalogResourceAppCat output){
+ public static OutputDataObjectType getOutputDataObjType (ApplicationOutputResource output){
OutputDataObjectType outputDataObjectType = new OutputDataObjectType();
outputDataObjectType.setName(output.getOutputKey());
outputDataObjectType.setValue(output.getOutputVal());
@@ -623,7 +623,7 @@ public class AppCatalogThriftConversion {
return outputDataObjectType;
}
- public static ApplicationDeploymentDescription getApplicationDeploymentDescription (AppDeploymentAppCatalogResourceAppCat resource) throws AppCatalogException {
+ public static ApplicationDeploymentDescription getApplicationDeploymentDescription (AppDeploymentResource resource) throws AppCatalogException {
ApplicationDeploymentDescription description = new ApplicationDeploymentDescription();
description.setAppDeploymentId(resource.getDeploymentId());
description.setAppModuleId(resource.getAppModuleId());
@@ -633,42 +633,42 @@ public class AppCatalogThriftConversion {
description.setParallelism(ApplicationParallelismType.valueOf(resource.getParallelism()));
}
description.setAppDeploymentDescription(resource.getAppDes());
- ModuleLoadCmdAppCatalogResourceAppCat cmdResource = new ModuleLoadCmdAppCatalogResourceAppCat();
+ ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
List<AppCatalogResource> moduleLoadCmds = cmdResource.get(AppCatAbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, resource.getDeploymentId());
if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()){
for (AppCatalogResource moduleLoadCmd : moduleLoadCmds){
- description.addToModuleLoadCmds(((ModuleLoadCmdAppCatalogResourceAppCat) moduleLoadCmd).getCmd());
+ description.addToModuleLoadCmds(((ModuleLoadCmdResource) moduleLoadCmd).getCmd());
}
}
- LibraryPrepandPathAppCatalogResourceAppCat prepandPathResource = new LibraryPrepandPathAppCatalogResourceAppCat();
+ LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
List<AppCatalogResource> libPrepandPaths = prepandPathResource.get(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, resource.getDeploymentId());
if (libPrepandPaths != null && !libPrepandPaths.isEmpty()){
description.setLibPrependPaths(getLibPrepandPaths(libPrepandPaths));
}
- LibraryApendPathAppCatalogResourceAppCat apendPathResource = new LibraryApendPathAppCatalogResourceAppCat();
+ LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
List<AppCatalogResource> libApendPaths = apendPathResource.get(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, resource.getDeploymentId());
if (libApendPaths != null && !libApendPaths.isEmpty()){
description.setLibAppendPaths(getLibApendPaths(libApendPaths));
}
- AppEnvironmentAppCatalogResourceAppCat appEnvironmentResource = new AppEnvironmentAppCatalogResourceAppCat();
+ AppEnvironmentResource appEnvironmentResource = new AppEnvironmentResource();
List<AppCatalogResource> appEnvList = appEnvironmentResource.get(AppCatAbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, resource.getDeploymentId());
if (appEnvList != null && !appEnvList.isEmpty()){
description.setSetEnvironment(getAppEnvPaths(appEnvList));
}
- PreJobCommandAppCatalogResourceAppCat preJobCommandResource = new PreJobCommandAppCatalogResourceAppCat();
+ PreJobCommandResource preJobCommandResource = new PreJobCommandResource();
List<AppCatalogResource> preJobCommands = preJobCommandResource.get(AppCatAbstractResource.PreJobCommandConstants.DEPLOYMENT_ID, resource.getDeploymentId());
if (preJobCommands != null && !preJobCommands.isEmpty()){
for (AppCatalogResource prejobCommand : preJobCommands){
- description.addToPreJobCommands(((PreJobCommandAppCatalogResourceAppCat) prejobCommand).getCommand());
+ description.addToPreJobCommands(((PreJobCommandResource) prejobCommand).getCommand());
}
}
- PostJobCommandAppCatalogResourceAppCat postJobCommandResource = new PostJobCommandAppCatalogResourceAppCat();
+ PostJobCommandResource postJobCommandResource = new PostJobCommandResource();
List<AppCatalogResource> postJobCommands = postJobCommandResource.get(AppCatAbstractResource.PostJobCommandConstants.DEPLOYMENT_ID, resource.getDeploymentId());
if (postJobCommands != null && !postJobCommands.isEmpty()){
for (AppCatalogResource postjobCommand : postJobCommands){
- description.addToPostJobCommands(((PostJobCommandAppCatalogResourceAppCat) postjobCommand).getCommand());
+ description.addToPostJobCommands(((PostJobCommandResource) postjobCommand).getCommand());
}
}
return description;
@@ -677,24 +677,24 @@ public class AppCatalogThriftConversion {
public static List<ApplicationDeploymentDescription> getAppDepDescList (List<AppCatalogResource> resources) throws AppCatalogException {
List<ApplicationDeploymentDescription> appList = new ArrayList<ApplicationDeploymentDescription>();
for (AppCatalogResource resource : resources){
- appList.add(getApplicationDeploymentDescription((AppDeploymentAppCatalogResourceAppCat)resource));
+ appList.add(getApplicationDeploymentDescription((AppDeploymentResource)resource));
}
return appList;
}
public static SetEnvPaths getSetEnvPath(AppCatalogResource resource){
SetEnvPaths envPaths = new SetEnvPaths();
- if (resource instanceof LibraryPrepandPathAppCatalogResourceAppCat){
- envPaths.setName(((LibraryPrepandPathAppCatalogResourceAppCat) resource).getName());
- envPaths.setValue(((LibraryPrepandPathAppCatalogResourceAppCat) resource).getValue());
+ if (resource instanceof LibraryPrepandPathResource){
+ envPaths.setName(((LibraryPrepandPathResource) resource).getName());
+ envPaths.setValue(((LibraryPrepandPathResource) resource).getValue());
return envPaths;
- }else if (resource instanceof LibraryApendPathAppCatalogResourceAppCat){
- envPaths.setName(((LibraryApendPathAppCatalogResourceAppCat) resource).getName());
- envPaths.setValue(((LibraryApendPathAppCatalogResourceAppCat) resource).getValue());
+ }else if (resource instanceof LibraryApendPathResource){
+ envPaths.setName(((LibraryApendPathResource) resource).getName());
+ envPaths.setValue(((LibraryApendPathResource) resource).getValue());
return envPaths;
- }else if (resource instanceof AppEnvironmentAppCatalogResourceAppCat){
- envPaths.setName(((AppEnvironmentAppCatalogResourceAppCat) resource).getName());
- envPaths.setValue(((AppEnvironmentAppCatalogResourceAppCat) resource).getValue());
+ }else if (resource instanceof AppEnvironmentResource){
+ envPaths.setName(((AppEnvironmentResource) resource).getName());
+ envPaths.setValue(((AppEnvironmentResource) resource).getValue());
return envPaths;
}else {
return null;
@@ -725,7 +725,7 @@ public class AppCatalogThriftConversion {
return pathList;
}
- public static ComputeResourcePreference getComputeResourcePreference (ComputeHostPreferenceAppCatalogResourceAppCat resource){
+ public static ComputeResourcePreference getComputeResourcePreference (ComputeHostPreferenceResource resource){
ComputeResourcePreference preference = new ComputeResourcePreference();
preference.setComputeResourceId(resource.getResourceId());
preference.setOverridebyAiravata(resource.getOverrideByAiravata());
@@ -746,13 +746,13 @@ public class AppCatalogThriftConversion {
List<ComputeResourcePreference> preferences = new ArrayList<ComputeResourcePreference>();
if (resources != null && !resources.isEmpty()){
for (AppCatalogResource resource : resources){
- preferences.add(getComputeResourcePreference((ComputeHostPreferenceAppCatalogResourceAppCat)resource));
+ preferences.add(getComputeResourcePreference((ComputeHostPreferenceResource)resource));
}
}
return preferences;
}
- public static InputDataObjectType getWorkflowInput (WorkflowInputAppCatalogResourceAppCat resource){
+ public static InputDataObjectType getWorkflowInput (WorkflowInputResource resource){
InputDataObjectType input = new InputDataObjectType();
input.setName(resource.getInputKey());
input.setApplicationArgument(resource.getAppArgument());
@@ -770,20 +770,20 @@ public class AppCatalogThriftConversion {
List<InputDataObjectType> inputResources = new ArrayList<InputDataObjectType>();
if (resources != null && !resources.isEmpty()){
for (AppCatalogResource resource : resources){
- inputResources.add(getWorkflowInput((WorkflowInputAppCatalogResourceAppCat) resource));
+ inputResources.add(getWorkflowInput((WorkflowInputResource) resource));
}
}
return inputResources;
}
- public static GatewayResourceProfile getGatewayResourceProfile(GatewayProfileAppCatalogResourceAppCat gw, List<ComputeResourcePreference> preferences){
+ public static GatewayResourceProfile getGatewayResourceProfile(GatewayProfileResource gw, List<ComputeResourcePreference> preferences){
GatewayResourceProfile gatewayProfile = new GatewayResourceProfile();
gatewayProfile.setGatewayID(gw.getGatewayID());
gatewayProfile.setComputeResourcePreferences(preferences);
return gatewayProfile;
}
- public static Workflow getWorkflow (WorkflowAppCatalogResourceAppCat resource) throws AppCatalogException {
+ public static Workflow getWorkflow (WorkflowResource resource) throws AppCatalogException {
Workflow workflow = new Workflow();
workflow.setTemplateId(resource.getWfTemplateId());
workflow.setGraph(resource.getGraph());
@@ -791,7 +791,7 @@ public class AppCatalogThriftConversion {
if (resource.getImage() != null){
workflow.setImage(resource.getImage().getBytes());
}
- WorkflowInputAppCatalogResourceAppCat inputResource = new WorkflowInputAppCatalogResourceAppCat();
+ WorkflowInputResource inputResource = new WorkflowInputResource();
List<AppCatalogResource> resources = inputResource.get(AppCatAbstractResource.WFInputConstants.WF_TEMPLATE_ID, resource.getWfTemplateId());
workflow.setWorkflowInputs(getWFInputs(resources));
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java
index ad96e67..7aa3b62 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/ExpCatResourceUtils.java
@@ -27,10 +27,7 @@ import org.apache.airavata.registry.cpi.RegistryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import javax.persistence.Query;
+import javax.persistence.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -39,6 +36,7 @@ import java.util.Map;
public class ExpCatResourceUtils {
private final static Logger logger = LoggerFactory.getLogger(ExpCatResourceUtils.class);
private static final String PERSISTENCE_UNIT_NAME = "experiment_data";
+ @PersistenceContext(unitName="experiment_data")
protected static EntityManagerFactory factory;
public static void reset(){
@@ -52,7 +50,6 @@ public class ExpCatResourceUtils {
Utils.getValidationQuery();
System.out.println(connectionProperties);
Map<String, String> properties = new HashMap<String, String>();
- properties.put("persistenceXmlLocation", "META-INF/experiment-catalog.xml");
properties.put("openjpa.ConnectionDriverName", "org.apache.commons.dbcp.BasicDataSource");
properties.put("openjpa.ConnectionProperties", connectionProperties);
properties.put("openjpa.DynamicEnhancementAgent", "true");
@@ -80,7 +77,7 @@ public class ExpCatResourceUtils {
*/
public static ExperimentCatResource createGateway(String gatewayId) throws RegistryException {
if (!isGatewayExist(gatewayId)) {
- GatewayExperimentCatResource gatewayResource = new GatewayExperimentCatResource();
+ GatewayResource gatewayResource = new GatewayResource();
gatewayResource.setGatewayId(gatewayId);
return gatewayResource;
}else {
@@ -88,14 +85,14 @@ public class ExpCatResourceUtils {
}
}
- public static UserExperimentCatResource createUser(String username, String password) throws RegistryException {
+ public static UserResource createUser(String username, String password) throws RegistryException {
if (!isUserExist(username)) {
- UserExperimentCatResource userResource = new UserExperimentCatResource();
+ UserResource userResource = new UserResource();
userResource.setUserName(username);
userResource.setPassword(password);
return userResource;
}else {
- return (UserExperimentCatResource)getUser(username);
+ return (UserResource)getUser(username);
}
}
@@ -106,7 +103,7 @@ public class ExpCatResourceUtils {
if (isGatewayExist(gatewayId)) {
em = getEntityManager();
Gateway gateway = em.find(Gateway.class, gatewayId);
- GatewayExperimentCatResource gatewayResource = (GatewayExperimentCatResource)Utils.getResource(ResourceType.GATEWAY, gateway);
+ GatewayResource gatewayResource = (GatewayResource)Utils.getResource(ResourceType.GATEWAY, gateway);
em.close();
return gatewayResource;
}
@@ -125,7 +122,7 @@ public class ExpCatResourceUtils {
}
public static void addUser (String userName, String password) throws RegistryException{
- UserExperimentCatResource resource = new UserExperimentCatResource();
+ UserResource resource = new UserResource();
resource.setUserName(userName);
resource.setPassword(password);
resource.save();
@@ -136,8 +133,8 @@ public class ExpCatResourceUtils {
try {
em = getEntityManager();
em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(AbstractExperimentCatResource.USERS);
- generator.setParameter(AbstractExperimentCatResource.UserConstants.USERNAME, username);
+ QueryGenerator generator = new QueryGenerator(AbstractExpCatResource.USERS);
+ generator.setParameter(AbstractExpCatResource.UserConstants.USERNAME, username);
Query q = generator.selectQuery(em);
int size = q.getResultList().size();
em.getTransaction().commit();
@@ -163,7 +160,7 @@ public class ExpCatResourceUtils {
if (isUserExist(userName)) {
em = getEntityManager();
Users user = em.find(Users.class, userName);
- UserExperimentCatResource userResource = (UserExperimentCatResource)Utils.getResource(ResourceType.USER, user);
+ UserResource userResource = (UserResource)Utils.getResource(ResourceType.USER, user);
em.close();
return userResource;
}
@@ -187,7 +184,7 @@ public class ExpCatResourceUtils {
try {
em = getEntityManager();
Gateway_Worker gatewayWorker = em.find(Gateway_Worker.class, new Gateway_Worker_PK(gatewayId, userName));
- WorkerExperimentCatResource workerResource = (WorkerExperimentCatResource) Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
+ WorkerResource workerResource = (WorkerResource) Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
em.close();
return workerResource;
}catch (Exception e){
@@ -215,8 +212,8 @@ public class ExpCatResourceUtils {
try {
em = getEntityManager();
em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(AbstractExperimentCatResource.GATEWAY);
- generator.setParameter(AbstractExperimentCatResource.GatewayConstants.GATEWAY_ID, gatewayId);
+ QueryGenerator generator = new QueryGenerator(AbstractExpCatResource.GATEWAY);
+ generator.setParameter(AbstractExpCatResource.GatewayConstants.GATEWAY_ID, gatewayId);
Query q = generator.selectQuery(em);
int size = q.getResultList().size();
em.getTransaction().commit();
@@ -242,14 +239,14 @@ public class ExpCatResourceUtils {
try {
em = getEntityManager();
em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(AbstractExperimentCatResource.GATEWAY);
+ QueryGenerator generator = new QueryGenerator(AbstractExpCatResource.GATEWAY);
Query q = generator.selectQuery(em);
List results = q.getResultList();
if (results.size() != 0) {
for (Object result : results) {
Gateway gateway = (Gateway) result;
- GatewayExperimentCatResource gatewayResource =
- (GatewayExperimentCatResource) Utils.getResource(ResourceType.GATEWAY, gateway);
+ GatewayResource gatewayResource =
+ (GatewayResource) Utils.getResource(ResourceType.GATEWAY, gateway);
resourceList.add(gatewayResource);
}
}
@@ -278,8 +275,8 @@ public class ExpCatResourceUtils {
try {
em = getEntityManager();
em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(AbstractExperimentCatResource.GATEWAY);
- generator.setParameter(AbstractExperimentCatResource.GatewayConstants.GATEWAY_ID, gatewayId);
+ QueryGenerator generator = new QueryGenerator(AbstractExpCatResource.GATEWAY);
+ generator.setParameter(AbstractExpCatResource.GatewayConstants.GATEWAY_ID, gatewayId);
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
@@ -302,7 +299,7 @@ public class ExpCatResourceUtils {
* @param gatewayResource
* @param userResource
*/
- public static WorkerExperimentCatResource addGatewayWorker(GatewayExperimentCatResource gatewayResource, UserExperimentCatResource userResource) throws RegistryException{
+ public static WorkerResource addGatewayWorker(GatewayResource gatewayResource, UserResource userResource) throws RegistryException{
EntityManager em = null;
try {
em = getEntityManager();
@@ -321,7 +318,7 @@ public class ExpCatResourceUtils {
em.persist(gatewayWorker);
em.getTransaction().commit();
em.close();
- return (WorkerExperimentCatResource)Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
+ return (WorkerResource)Utils.getResource(ResourceType.GATEWAY_WORKER, gatewayWorker);
} catch (Exception e){
logger.error(e.getMessage(), e);
throw new RegistryException(e);
@@ -340,15 +337,15 @@ public class ExpCatResourceUtils {
* @param userResource
* @return
*/
- public static boolean removeGatewayWorker(GatewayExperimentCatResource gatewayResource, UserExperimentCatResource userResource) {
+ public static boolean removeGatewayWorker(GatewayResource gatewayResource, UserResource userResource) {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(AbstractExperimentCatResource.GATEWAY_WORKER);
- generator.setParameter(AbstractExperimentCatResource.GatewayWorkerConstants.GATEWAY_ID,
+ QueryGenerator generator = new QueryGenerator(AbstractExpCatResource.GATEWAY_WORKER);
+ generator.setParameter(AbstractExpCatResource.GatewayWorkerConstants.GATEWAY_ID,
gatewayResource.getGatewayName());
- generator.setParameter(AbstractExperimentCatResource.UserConstants.USERNAME, userResource.getUserName());
+ generator.setParameter(AbstractExpCatResource.UserConstants.USERNAME, userResource.getUserName());
Query q = generator.deleteQuery(em);
q.executeUpdate();
em.getTransaction().commit();
@@ -372,19 +369,19 @@ public class ExpCatResourceUtils {
* @param configKey
* @return
*/
- public static List<ConfigurationExperimentCatResource> getConfigurations(String configKey){
- List<ConfigurationExperimentCatResource> list = new ArrayList<ConfigurationExperimentCatResource>();
+ public static List<ConfigurationResource> getConfigurations(String configKey){
+ List<ConfigurationResource> list = new ArrayList<ConfigurationResource>();
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
- QueryGenerator generator = new QueryGenerator(AbstractExperimentCatResource.CONFIGURATION);
- generator.setParameter(AbstractExperimentCatResource.ConfigurationConstants.CONFIG_KEY, configKey);
+ QueryGenerator generator = new QueryGenerator(AbstractExpCatResource.CONFIGURATION);
+ generator.setParameter(AbstractExpCatResource.ConfigurationConstants.CONFIG_KEY, configKey);
Query q = generator.selectQuery(em);
List<?> resultList = q.getResultList();
if (resultList.size() != 0) {
for (Object result : resultList) {
- ConfigurationExperimentCatResource configurationResource = createConfigurationResourceObject(result);
+ ConfigurationResource configurationResource = createConfigurationResourceObject(result);
list.add(configurationResource);
}
}
@@ -407,8 +404,8 @@ public class ExpCatResourceUtils {
* @param configKey
* @return
*/
- public static ConfigurationExperimentCatResource getConfiguration(String configKey){
- List<ConfigurationExperimentCatResource> configurations = getConfigurations(configKey);
+ public static ConfigurationResource getConfiguration(String configKey){
+ List<ConfigurationResource> configurations = getConfigurations(configKey);
return (configurations != null && configurations.size() > 0) ? configurations.get(0) : null;
}
@@ -417,7 +414,7 @@ public class ExpCatResourceUtils {
* @return
*/
public static boolean isConfigurationExist(String configKey){
- List<ConfigurationExperimentCatResource> configurations = getConfigurations(configKey);
+ List<ConfigurationResource> configurations = getConfigurations(configKey);
return (configurations != null && configurations.size() > 0);
}
@@ -425,8 +422,8 @@ public class ExpCatResourceUtils {
* @param configKey
* @return
*/
- public static ConfigurationExperimentCatResource createConfiguration(String configKey) {
- ConfigurationExperimentCatResource config = new ConfigurationExperimentCatResource();
+ public static ConfigurationResource createConfiguration(String configKey) {
+ ConfigurationResource config = new ConfigurationResource();
config.setConfigKey(configKey);
return config;
}
@@ -435,10 +432,10 @@ public class ExpCatResourceUtils {
* @param result
* @return
*/
- private static ConfigurationExperimentCatResource createConfigurationResourceObject(
+ private static ConfigurationResource createConfigurationResourceObject(
Object result) {
Configuration configuration = (Configuration) result;
- ConfigurationExperimentCatResource configurationResource = new ConfigurationExperimentCatResource(configuration.getConfig_key(), configuration.getConfig_val());
+ ConfigurationResource configurationResource = new ConfigurationResource(configuration.getConfig_key(), configuration.getConfig_val());
configurationResource.setExpireDate(configuration.getExpire_date());
return configurationResource;
}
@@ -448,9 +445,9 @@ public class ExpCatResourceUtils {
* @param configValue
*/
public static void removeConfiguration(String configkey, String configValue) throws RegistryException{
- QueryGenerator queryGenerator = new QueryGenerator(AbstractExperimentCatResource.CONFIGURATION);
- queryGenerator.setParameter(AbstractExperimentCatResource.ConfigurationConstants.CONFIG_KEY, configkey);
- queryGenerator.setParameter(AbstractExperimentCatResource.ConfigurationConstants.CONFIG_VAL, configValue);
+ QueryGenerator queryGenerator = new QueryGenerator(AbstractExpCatResource.CONFIGURATION);
+ queryGenerator.setParameter(AbstractExpCatResource.ConfigurationConstants.CONFIG_KEY, configkey);
+ queryGenerator.setParameter(AbstractExpCatResource.ConfigurationConstants.CONFIG_VAL, configValue);
EntityManager em = null;
try {
if(isConfigurationExists(configkey, configValue)){
@@ -478,8 +475,8 @@ public class ExpCatResourceUtils {
* @param configkey
*/
public static void removeConfiguration(String configkey) throws RegistryException{
- QueryGenerator queryGenerator = new QueryGenerator(AbstractExperimentCatResource.CONFIGURATION);
- queryGenerator.setParameter(AbstractExperimentCatResource.ConfigurationConstants.CONFIG_KEY, configkey);
+ QueryGenerator queryGenerator = new QueryGenerator(AbstractExpCatResource.CONFIGURATION);
+ queryGenerator.setParameter(AbstractExpCatResource.ConfigurationConstants.CONFIG_KEY, configkey);
EntityManager em = null;
try {
if(isConfigurationExist(configkey)){
@@ -508,7 +505,7 @@ public class ExpCatResourceUtils {
try{
//Currently categoryID is hardcoded value
em = ExpCatResourceUtils.getEntityManager();
- Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, AbstractExperimentCatResource.ConfigurationConstants.CATEGORY_ID_DEFAULT_VALUE));
+ Configuration existing = em.find(Configuration.class, new Configuration_PK(configKey, configVal, AbstractExpCatResource.ConfigurationConstants.CATEGORY_ID_DEFAULT_VALUE));
em.close();
return existing!= null;
} catch (Exception e){
http://git-wip-us.apache.org/repos/asf/airavata/blob/4045c094/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java
index 6a7f723..e71cff0 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentCatalogImpl.java
@@ -28,8 +28,8 @@ import org.apache.airavata.model.workspace.Gateway;
import org.apache.airavata.model.workspace.Project;
import org.apache.airavata.model.workspace.experiment.*;
import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
-import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayExperimentCatResource;
-import org.apache.airavata.registry.core.experiment.catalog.resources.UserExperimentCatResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource;
+import org.apache.airavata.registry.core.experiment.catalog.resources.UserResource;
import org.apache.airavata.registry.cpi.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,8 +39,8 @@ import java.util.List;
import java.util.Map;
public class ExperimentCatalogImpl implements ExperimentCatalog {
- private GatewayExperimentCatResource gatewayResource;
- private UserExperimentCatResource user;
+ private GatewayResource gatewayResource;
+ private UserResource user;
private final static Logger logger = LoggerFactory.getLogger(ExperimentCatalogImpl.class);
private ExperimentRegistry experimentRegistry = null;
private ProjectRegistry projectRegistry = null;
@@ -49,18 +49,18 @@ public class ExperimentCatalogImpl implements ExperimentCatalog {
public ExperimentCatalogImpl() throws RegistryException{
try {
if (!ExpCatResourceUtils.isGatewayExist(ServerSettings.getDefaultUserGateway())){
- gatewayResource = (GatewayExperimentCatResource) ExpCatResourceUtils.createGateway(ServerSettings.getDefaultUserGateway());
+ gatewayResource = (GatewayResource) ExpCatResourceUtils.createGateway(ServerSettings.getDefaultUserGateway());
gatewayResource.setGatewayName(ServerSettings.getDefaultUserGateway());
gatewayResource.save();
}else {
- gatewayResource = (GatewayExperimentCatResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
+ gatewayResource = (GatewayResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
}
if (!ExpCatResourceUtils.isUserExist(ServerSettings.getDefaultUser())){
user = ExpCatResourceUtils.createUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword());
user.save();
}else {
- user = (UserExperimentCatResource) ExpCatResourceUtils.getUser(ServerSettings.getDefaultUser());
+ user = (UserResource) ExpCatResourceUtils.getUser(ServerSettings.getDefaultUser());
}
experimentRegistry = new ExperimentRegistry(gatewayResource, user);
projectRegistry = new ProjectRegistry(gatewayResource, user);
@@ -73,17 +73,17 @@ public class ExperimentCatalogImpl implements ExperimentCatalog {
public ExperimentCatalogImpl(String gateway, String username, String password) throws RegistryException{
if (!ExpCatResourceUtils.isGatewayExist(gateway)){
- gatewayResource = (GatewayExperimentCatResource) ExpCatResourceUtils.createGateway(gateway);
+ gatewayResource = (GatewayResource) ExpCatResourceUtils.createGateway(gateway);
gatewayResource.save();
}else {
- gatewayResource = (GatewayExperimentCatResource) ExpCatResourceUtils.getGateway(gateway);
+ gatewayResource = (GatewayResource) ExpCatResourceUtils.getGateway(gateway);
}
if (!ExpCatResourceUtils.isUserExist(username)){
user = ExpCatResourceUtils.createUser(username, password);
user.save();
}else {
- user = (UserExperimentCatResource) ExpCatResourceUtils.getUser(username);
+ user = (UserResource) ExpCatResourceUtils.getUser(username);
}
experimentRegistry = new ExperimentRegistry(gatewayResource, user);
projectRegistry = new ProjectRegistry(gatewayResource, user);