This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/develop by this push:
new 5d18d51 AIRAVATA-2876 Generating ID for App
Module/Interface/Deployment
5d18d51 is described below
commit 5d18d51dcc1e8c2842a425ac4a6c4f07ad526908
Author: Marcus Christie <[email protected]>
AuthorDate: Wed Sep 12 11:36:29 2018 -0400
AIRAVATA-2876 Generating ID for App Module/Interface/Deployment
---
.../ApplicationDeploymentRepository.java | 13 +++++++--
.../appcatalog/ApplicationInterfaceRepository.java | 23 ++++++++-------
.../ApplicationDeploymentRepositoryTest.java | 14 +++++++++
.../ApplicationInterfaceRepositoryTest.java | 34 +++++++++++++++++++++-
4 files changed, 71 insertions(+), 13 deletions(-)
diff --git
a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepository.java
index d85e5cd..0fbd560 100644
---
a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepository.java
+++
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepository.java
@@ -19,8 +19,10 @@
*/
package org.apache.airavata.registry.core.repositories.appcatalog;
-import org.apache.airavata.model.appcatalog.appdeployment.*;
-import org.apache.airavata.registry.core.entities.appcatalog.*;
+import
org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription;
+import
org.apache.airavata.model.appcatalog.appinterface.application_interface_modelConstants;
+import
org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription;
+import
org.apache.airavata.registry.core.entities.appcatalog.ApplicationDeploymentEntity;
import org.apache.airavata.registry.core.utils.DBConstants;
import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
import org.apache.airavata.registry.core.utils.QueryConstants;
@@ -48,6 +50,13 @@ public class ApplicationDeploymentRepository extends
AppCatAbstractRepository<Ap
protected ApplicationDeploymentEntity saveApplicationDeployment(
ApplicationDeploymentDescription applicationDeploymentDescription,
String gatewayId) throws AppCatalogException {
+
+ if
(applicationDeploymentDescription.getAppDeploymentId().trim().equals("") ||
applicationDeploymentDescription.getAppDeploymentId().equals(application_interface_modelConstants.DEFAULT_ID)
) {
+ logger.debug("If Application Deployment ID is empty or DEFAULT,
set it as the compute host name plus the App Module ID");
+ ComputeResourceDescription computeResourceDescription = new
ComputeResourceRepository().getComputeResource(applicationDeploymentDescription.getComputeHostId());
+
applicationDeploymentDescription.setAppDeploymentId(computeResourceDescription.getHostName()
+ "_" + applicationDeploymentDescription.getAppModuleId());
+ }
+
String applicationDeploymentId =
applicationDeploymentDescription.getAppDeploymentId();
Mapper mapper = ObjectMapperSingleton.getInstance();
ApplicationDeploymentEntity applicationDeploymentEntity =
mapper.map(applicationDeploymentDescription, ApplicationDeploymentEntity.class);
diff --git
a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepository.java
index 080fdd0..9cecc37 100644
---
a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepository.java
+++
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepository.java
@@ -19,6 +19,7 @@
*/
package org.apache.airavata.registry.core.repositories.appcatalog;
+import org.apache.airavata.common.utils.AiravataUtils;
import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule;
import
org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
import
org.apache.airavata.model.appcatalog.appinterface.application_interface_modelConstants;
@@ -54,6 +55,12 @@ public class ApplicationInterfaceRepository extends
AppCatAbstractRepository<App
protected ApplicationInterfaceEntity saveApplicationInterface(
ApplicationInterfaceDescription applicationInterfaceDescription,
String gatewayId) throws AppCatalogException {
+
+ if
(applicationInterfaceDescription.getApplicationInterfaceId().trim().equals("")
||
applicationInterfaceDescription.getApplicationInterfaceId().equals(application_interface_modelConstants.DEFAULT_ID)
) {
+ logger.debug("If Application Interface ID is empty or DEFAULT, set
it as the Application Interface Name plus random UUID");
+
applicationInterfaceDescription.setApplicationInterfaceId(AiravataUtils.getId(applicationInterfaceDescription.getApplicationName()));
+ }
+
String applicationInterfaceId =
applicationInterfaceDescription.getApplicationInterfaceId();
Mapper mapper = ObjectMapperSingleton.getInstance();
ApplicationInterfaceEntity applicationInterfaceEntity =
mapper.map(applicationInterfaceDescription, ApplicationInterfaceEntity.class);
@@ -90,6 +97,12 @@ public class ApplicationInterfaceRepository extends
AppCatAbstractRepository<App
protected ApplicationModuleEntity saveApplicationModule(
ApplicationModule applicationModule, String gatewayId) throws
AppCatalogException {
+
+ if (applicationModule.getAppModuleId().trim().equals("") ||
applicationModule.getAppModuleId().equals(application_interface_modelConstants.DEFAULT_ID))
{
+ logger.debug("If Application Module ID is empty or DEFAULT, set it
as the Application Module Name plus random UUID");
+
applicationModule.setAppModuleId(AiravataUtils.getId(applicationModule.getAppModuleName()));
+ }
+
String applicationModuleId = applicationModule.getAppModuleId();
Mapper mapper = ObjectMapperSingleton.getInstance();
ApplicationModuleEntity applicationModuleEntity =
mapper.map(applicationModule, ApplicationModuleEntity.class);
@@ -99,16 +112,6 @@ public class ApplicationInterfaceRepository extends
AppCatAbstractRepository<App
applicationModuleEntity.setGatewayId(gatewayId);
}
- if (!applicationModuleEntity.getAppModuleId().equals("") &&
!applicationModule.getAppModuleId().equals(application_interface_modelConstants.DEFAULT_ID))
{
- logger.debug("Checking if the Application Module ID is not empty
or DEFAULT");
-
applicationModuleEntity.setAppModuleId(applicationModule.getAppModuleId());
- }
-
- else {
- logger.debug("If Application Module ID is empty or DEFAULT, set it
as the Application Module Name");
-
applicationModuleEntity.setAppModuleId(applicationModule.getAppModuleName());
- }
-
if (!isApplicationModuleExists(applicationModuleId)) {
logger.debug("Checking if the Application Module already exists");
applicationModuleEntity.setCreationTime(new
Timestamp(System.currentTimeMillis()));
diff --git
a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java
index 7a0bd15..4bcd49a 100644
---
a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java
+++
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepositoryTest.java
@@ -23,6 +23,7 @@ import
org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentD
import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule;
import org.apache.airavata.model.appcatalog.appdeployment.CommandObject;
import org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths;
+import
org.apache.airavata.model.appcatalog.appinterface.application_interface_modelConstants;
import
org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription;
import org.apache.airavata.model.parallelism.ApplicationParallelismType;
import org.apache.airavata.registry.core.repositories.common.TestBase;
@@ -154,6 +155,19 @@ public class ApplicationDeploymentRepositoryTest extends
TestBase {
}
@Test
+ public void createAppDeploymentWithDefaultIdTest() throws
AppCatalogException {
+
+ String applicationModule = addSampleApplicationModule("1");
+ String computeResource = addSampleComputeResource("1");
+
+ ApplicationDeploymentDescription deployment =
prepareSampleDeployment("1", applicationModule, computeResource);
+
deployment.setAppDeploymentId(application_interface_modelConstants.DEFAULT_ID);
+ String deploymentId =
applicationDeploymentRepository.addApplicationDeployment(deployment, gatewayId);
+ Assert.assertNotEquals(deploymentId,
application_interface_modelConstants.DEFAULT_ID);
+ Assert.assertEquals("compHostName1" + "_" + applicationModule,
deploymentId);
+ }
+
+ @Test
public void updateAppDeploymentTest() throws AppCatalogException {
String applicationModule = addSampleApplicationModule("1");
String computeResource = addSampleComputeResource("1");
diff --git
a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
index 614a138..7e03e48 100644
---
a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
+++
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
@@ -36,9 +36,11 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.text.MessageFormat;
import java.util.*;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class ApplicationInterfaceRepositoryTest extends TestBase {
@@ -78,7 +80,8 @@ public class ApplicationInterfaceRepositoryTest extends
TestBase {
String moduleId =
applicationInterfaceRepository.addApplicationModule(applicationModule,
gatewayId);
ApplicationModule savedAppModule =
applicationInterfaceRepository.getApplicationModule(moduleId);
- Assert.assertEquals(applicationModule.getAppModuleName(),
savedAppModule.getAppModuleId());
+ Assert.assertNotEquals(applicationModule.getAppModuleName(),
savedAppModule.getAppModuleId());
+
Assert.assertTrue(savedAppModule.getAppModuleId().startsWith(applicationModule.getAppModuleName()));
}
@Test
@@ -136,6 +139,35 @@ public class ApplicationInterfaceRepositoryTest extends
TestBase {
}
@Test
+ public void addApplicationInterfaceWithDefaultIdTest() throws
AppCatalogException {
+ ApplicationInterfaceDescription applicationInterfaceDescription = new
ApplicationInterfaceDescription();
+ applicationInterfaceDescription.setApplicationName("app interface 1");
+
+ applicationInterfaceDescription.setApplicationModules(new
ArrayList<>());
+
+ InputDataObjectType input = new InputDataObjectType();
+ input.setName("input1");
+ input.setApplicationArgument("Arg");
+ input.setDataStaged(true);
+ input.setInputOrder(0);
+ input.setIsReadOnly(true);
+ input.setIsRequired(true);
+ input.setRequiredToAddedToCommandLine(true);
+ input.setType(DataType.FLOAT);
+ input.setUserFriendlyDescription("User friendly description");
+ input.setValue("113");
+ input.setMetaData("Metadata");
+ input.setStandardInput(true);
+
applicationInterfaceDescription.setApplicationInputs(Collections.singletonList(input));
+
+ applicationInterfaceDescription.setApplicationOutputs(new
ArrayList<>());
+
+ String interfaceId =
applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription,
gatewayId);
+ assertTrue(MessageFormat.format("{0} does not start with {1}",
interfaceId, "app_interface_1"),
+ interfaceId.startsWith("app_interface_1"));
+ }
+
+ @Test
public void deleteApplicationInterfaceTest() throws AppCatalogException {
Assert.assertNull(applicationInterfaceRepository.getApplicationModule("interface1"));