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 167d31a  AIRAVATA-2996 Correctly handle app input cascading delete
167d31a is described below

commit 167d31a6bccebd89ac8ba9efedf2d777724fe25b
Author: Marcus Christie <[email protected]>
AuthorDate: Wed Mar 20 15:44:45 2019 -0400

    AIRAVATA-2996 Correctly handle app input cascading delete
---
 .../appcatalog/ApplicationInputEntity.java         |  9 ++++---
 .../appcatalog/ApplicationOutputEntity.java        |  9 ++++---
 .../ApplicationInterfaceRepositoryTest.java        | 28 ++++++++++++++++++++++
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ApplicationInputEntity.java
 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ApplicationInputEntity.java
index 6a9353c..d9db823 100644
--- 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ApplicationInputEntity.java
+++ 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ApplicationInputEntity.java
@@ -21,6 +21,8 @@
 package org.apache.airavata.registry.core.entities.appcatalog;
 
 import org.apache.airavata.model.application.io.DataType;
+import org.apache.openjpa.persistence.jdbc.ForeignKey;
+import org.apache.openjpa.persistence.jdbc.ForeignKeyAction;
 
 import javax.persistence.*;
 import java.io.Serializable;
@@ -77,8 +79,9 @@ public class ApplicationInputEntity implements Serializable {
        @Column(name = "IS_READ_ONLY")
        private boolean isReadOnly;
 
-       @ManyToOne(targetEntity = ApplicationInterfaceEntity.class, cascade = 
CascadeType.MERGE)
-       @JoinColumn(name = "INTERFACE_ID")
+       @ManyToOne(targetEntity = ApplicationInterfaceEntity.class)
+       @JoinColumn(name = "INTERFACE_ID", nullable = false, updatable = false)
+       @ForeignKey(deleteAction = ForeignKeyAction.CASCADE)
        private ApplicationInterfaceEntity applicationInterface;
 
        public ApplicationInputEntity() {
@@ -197,4 +200,4 @@ public class ApplicationInputEntity implements Serializable 
{
                this.applicationInterface = applicationInterface;
        }
 
-}
\ No newline at end of file
+}
diff --git 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ApplicationOutputEntity.java
 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ApplicationOutputEntity.java
index eded35c..5b54d2d 100644
--- 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ApplicationOutputEntity.java
+++ 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/ApplicationOutputEntity.java
@@ -21,6 +21,8 @@
 package org.apache.airavata.registry.core.entities.appcatalog;
 
 import org.apache.airavata.model.application.io.DataType;
+import org.apache.openjpa.persistence.jdbc.ForeignKey;
+import org.apache.openjpa.persistence.jdbc.ForeignKeyAction;
 
 import javax.persistence.*;
 import java.io.Serializable;
@@ -70,8 +72,9 @@ public class ApplicationOutputEntity implements Serializable {
     @Column(name = "SEARCH_QUERY")
     private String searchQuery;
 
-    @ManyToOne(targetEntity = ApplicationInterfaceEntity.class, cascade = 
CascadeType.MERGE)
-    @JoinColumn(name = "INTERFACE_ID")
+    @ManyToOne(targetEntity = ApplicationInterfaceEntity.class)
+    @JoinColumn(name = "INTERFACE_ID", nullable = false, updatable = false)
+    @ForeignKey(deleteAction = ForeignKeyAction.CASCADE)
     private ApplicationInterfaceEntity applicationInterface;
 
     public ApplicationOutputEntity() {
@@ -173,4 +176,4 @@ public class ApplicationOutputEntity implements 
Serializable {
         this.applicationInterface = applicationInterface;
     }
 
-}
\ No newline at end of file
+}
diff --git 
a/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
 
b/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
index 7e03e48..942db12 100644
--- 
a/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
+++ 
b/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
@@ -179,6 +179,34 @@ public class ApplicationInterfaceRepositoryTest extends 
TestBase {
         applicationInterfaceDescription.setApplicationInputs(new 
ArrayList<>());
         applicationInterfaceDescription.setApplicationOutputs(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.addToApplicationInputs(input);
+
+        OutputDataObjectType output = new OutputDataObjectType();
+        output.setName("output1");
+        output.setValue("value");
+        output.setType(DataType.FLOAT);
+        output.setApplicationArgument("Argument");
+        output.setDataMovement(true);
+        output.setIsRequired(true);
+        output.setLocation("/home/");
+        output.setSearchQuery("Search query");
+        output.setRequiredToAddedToCommandLine(true);
+        output.setOutputStreaming(true);
+        applicationInterfaceDescription.addToApplicationOutputs(output);
+
         String interfaceId = 
applicationInterfaceRepository.addApplicationInterface(applicationInterfaceDescription,
 gatewayId);
 
         
Assert.assertNotNull(applicationInterfaceRepository.getApplicationInterface(interfaceId));

Reply via email to