Repository: airavata Updated Branches: refs/heads/master 92888e5f1 -> 7a6fbdb25
http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/experiment/WorkflowNodeDetails.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/experiment/WorkflowNodeDetails.java b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/experiment/WorkflowNodeDetails.java index bab25cd..c02d97b 100644 --- a/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/experiment/WorkflowNodeDetails.java +++ b/airavata-api/airavata-data-models/src/main/java/org/apache/airavata/model/workspace/experiment/WorkflowNodeDetails.java @@ -1181,14 +1181,14 @@ import org.slf4j.LoggerFactory; case 6: // NODE_INPUTS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list56 = iprot.readListBegin(); - struct.nodeInputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType>(_list56.size); - for (int _i57 = 0; _i57 < _list56.size; ++_i57) + org.apache.thrift.protocol.TList _list64 = iprot.readListBegin(); + struct.nodeInputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType>(_list64.size); + for (int _i65 = 0; _i65 < _list64.size; ++_i65) { - org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _elem58; - _elem58 = new org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType(); - _elem58.read(iprot); - struct.nodeInputs.add(_elem58); + org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _elem66; + _elem66 = new org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType(); + _elem66.read(iprot); + struct.nodeInputs.add(_elem66); } iprot.readListEnd(); } @@ -1200,14 +1200,14 @@ import org.slf4j.LoggerFactory; case 7: // NODE_OUTPUTS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list59 = iprot.readListBegin(); - struct.nodeOutputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType>(_list59.size); - for (int _i60 = 0; _i60 < _list59.size; ++_i60) + org.apache.thrift.protocol.TList _list67 = iprot.readListBegin(); + struct.nodeOutputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType>(_list67.size); + for (int _i68 = 0; _i68 < _list67.size; ++_i68) { - org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _elem61; - _elem61 = new org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType(); - _elem61.read(iprot); - struct.nodeOutputs.add(_elem61); + org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _elem69; + _elem69 = new org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType(); + _elem69.read(iprot); + struct.nodeOutputs.add(_elem69); } iprot.readListEnd(); } @@ -1228,14 +1228,14 @@ import org.slf4j.LoggerFactory; case 9: // TASK_DETAILS_LIST if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list62 = iprot.readListBegin(); - struct.taskDetailsList = new ArrayList<TaskDetails>(_list62.size); - for (int _i63 = 0; _i63 < _list62.size; ++_i63) + org.apache.thrift.protocol.TList _list70 = iprot.readListBegin(); + struct.taskDetailsList = new ArrayList<TaskDetails>(_list70.size); + for (int _i71 = 0; _i71 < _list70.size; ++_i71) { - TaskDetails _elem64; - _elem64 = new TaskDetails(); - _elem64.read(iprot); - struct.taskDetailsList.add(_elem64); + TaskDetails _elem72; + _elem72 = new TaskDetails(); + _elem72.read(iprot); + struct.taskDetailsList.add(_elem72); } iprot.readListEnd(); } @@ -1247,14 +1247,14 @@ import org.slf4j.LoggerFactory; case 10: // ERRORS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list65 = iprot.readListBegin(); - struct.errors = new ArrayList<ErrorDetails>(_list65.size); - for (int _i66 = 0; _i66 < _list65.size; ++_i66) + org.apache.thrift.protocol.TList _list73 = iprot.readListBegin(); + struct.errors = new ArrayList<ErrorDetails>(_list73.size); + for (int _i74 = 0; _i74 < _list73.size; ++_i74) { - ErrorDetails _elem67; - _elem67 = new ErrorDetails(); - _elem67.read(iprot); - struct.errors.add(_elem67); + ErrorDetails _elem75; + _elem75 = new ErrorDetails(); + _elem75.read(iprot); + struct.errors.add(_elem75); } iprot.readListEnd(); } @@ -1308,9 +1308,9 @@ import org.slf4j.LoggerFactory; oprot.writeFieldBegin(NODE_INPUTS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.nodeInputs.size())); - for (org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _iter68 : struct.nodeInputs) + for (org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _iter76 : struct.nodeInputs) { - _iter68.write(oprot); + _iter76.write(oprot); } oprot.writeListEnd(); } @@ -1322,9 +1322,9 @@ import org.slf4j.LoggerFactory; oprot.writeFieldBegin(NODE_OUTPUTS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.nodeOutputs.size())); - for (org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _iter69 : struct.nodeOutputs) + for (org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _iter77 : struct.nodeOutputs) { - _iter69.write(oprot); + _iter77.write(oprot); } oprot.writeListEnd(); } @@ -1343,9 +1343,9 @@ import org.slf4j.LoggerFactory; oprot.writeFieldBegin(TASK_DETAILS_LIST_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.taskDetailsList.size())); - for (TaskDetails _iter70 : struct.taskDetailsList) + for (TaskDetails _iter78 : struct.taskDetailsList) { - _iter70.write(oprot); + _iter78.write(oprot); } oprot.writeListEnd(); } @@ -1357,9 +1357,9 @@ import org.slf4j.LoggerFactory; oprot.writeFieldBegin(ERRORS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.errors.size())); - for (ErrorDetails _iter71 : struct.errors) + for (ErrorDetails _iter79 : struct.errors) { - _iter71.write(oprot); + _iter79.write(oprot); } oprot.writeListEnd(); } @@ -1418,18 +1418,18 @@ import org.slf4j.LoggerFactory; if (struct.isSetNodeInputs()) { { oprot.writeI32(struct.nodeInputs.size()); - for (org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _iter72 : struct.nodeInputs) + for (org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _iter80 : struct.nodeInputs) { - _iter72.write(oprot); + _iter80.write(oprot); } } } if (struct.isSetNodeOutputs()) { { oprot.writeI32(struct.nodeOutputs.size()); - for (org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _iter73 : struct.nodeOutputs) + for (org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _iter81 : struct.nodeOutputs) { - _iter73.write(oprot); + _iter81.write(oprot); } } } @@ -1439,18 +1439,18 @@ import org.slf4j.LoggerFactory; if (struct.isSetTaskDetailsList()) { { oprot.writeI32(struct.taskDetailsList.size()); - for (TaskDetails _iter74 : struct.taskDetailsList) + for (TaskDetails _iter82 : struct.taskDetailsList) { - _iter74.write(oprot); + _iter82.write(oprot); } } } if (struct.isSetErrors()) { { oprot.writeI32(struct.errors.size()); - for (ErrorDetails _iter75 : struct.errors) + for (ErrorDetails _iter83 : struct.errors) { - _iter75.write(oprot); + _iter83.write(oprot); } } } @@ -1476,28 +1476,28 @@ import org.slf4j.LoggerFactory; } if (incoming.get(2)) { { - org.apache.thrift.protocol.TList _list76 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.nodeInputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType>(_list76.size); - for (int _i77 = 0; _i77 < _list76.size; ++_i77) + org.apache.thrift.protocol.TList _list84 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.nodeInputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType>(_list84.size); + for (int _i85 = 0; _i85 < _list84.size; ++_i85) { - org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _elem78; - _elem78 = new org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType(); - _elem78.read(iprot); - struct.nodeInputs.add(_elem78); + org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType _elem86; + _elem86 = new org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType(); + _elem86.read(iprot); + struct.nodeInputs.add(_elem86); } } struct.setNodeInputsIsSet(true); } if (incoming.get(3)) { { - org.apache.thrift.protocol.TList _list79 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.nodeOutputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType>(_list79.size); - for (int _i80 = 0; _i80 < _list79.size; ++_i80) + org.apache.thrift.protocol.TList _list87 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.nodeOutputs = new ArrayList<org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType>(_list87.size); + for (int _i88 = 0; _i88 < _list87.size; ++_i88) { - org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _elem81; - _elem81 = new org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType(); - _elem81.read(iprot); - struct.nodeOutputs.add(_elem81); + org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType _elem89; + _elem89 = new org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType(); + _elem89.read(iprot); + struct.nodeOutputs.add(_elem89); } } struct.setNodeOutputsIsSet(true); @@ -1509,28 +1509,28 @@ import org.slf4j.LoggerFactory; } if (incoming.get(5)) { { - org.apache.thrift.protocol.TList _list82 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.taskDetailsList = new ArrayList<TaskDetails>(_list82.size); - for (int _i83 = 0; _i83 < _list82.size; ++_i83) + org.apache.thrift.protocol.TList _list90 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.taskDetailsList = new ArrayList<TaskDetails>(_list90.size); + for (int _i91 = 0; _i91 < _list90.size; ++_i91) { - TaskDetails _elem84; - _elem84 = new TaskDetails(); - _elem84.read(iprot); - struct.taskDetailsList.add(_elem84); + TaskDetails _elem92; + _elem92 = new TaskDetails(); + _elem92.read(iprot); + struct.taskDetailsList.add(_elem92); } } struct.setTaskDetailsListIsSet(true); } if (incoming.get(6)) { { - org.apache.thrift.protocol.TList _list85 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); - struct.errors = new ArrayList<ErrorDetails>(_list85.size); - for (int _i86 = 0; _i86 < _list85.size; ++_i86) + org.apache.thrift.protocol.TList _list93 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); + struct.errors = new ArrayList<ErrorDetails>(_list93.size); + for (int _i94 = 0; _i94 < _list93.size; ++_i94) { - ErrorDetails _elem87; - _elem87 = new ErrorDetails(); - _elem87.read(iprot); - struct.errors.add(_elem87); + ErrorDetails _elem95; + _elem95 = new ErrorDetails(); + _elem95.read(iprot); + struct.errors.add(_elem95); } } struct.setErrorsIsSet(true); http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/airavata-api/thrift-interface-descriptions/experimentModel.thrift ---------------------------------------------------------------------- diff --git a/airavata-api/thrift-interface-descriptions/experimentModel.thrift b/airavata-api/thrift-interface-descriptions/experimentModel.thrift index 512cfe8..93a961a 100644 --- a/airavata-api/thrift-interface-descriptions/experimentModel.thrift +++ b/airavata-api/thrift-interface-descriptions/experimentModel.thrift @@ -297,7 +297,9 @@ struct TaskDetails { 11: optional TaskStatus taskStatus, 12: optional list<JobDetails> jobDetailsList, 13: optional list<DataTransferDetails> dataTransferDetailsList, - 14: optional list<ErrorDetails> errors + 14: optional list<ErrorDetails> errors, + 15: optional bool enableEmailNotification, + 16: optional list<string> emailAddresses, } enum ExecutionUnit { @@ -370,14 +372,16 @@ struct Experiment { 8: optional string applicationVersion, 9: optional string workflowTemplateId, 10: optional string workflowTemplateVersion, - 11: optional UserConfigurationData userConfigurationData, - 12: optional string workflowExecutionInstanceId, - 13: optional list<applicationInterfaceModel.InputDataObjectType> experimentInputs, - 14: optional list<applicationInterfaceModel.OutputDataObjectType> experimentOutputs, - 15: optional ExperimentStatus experimentStatus, - 16: optional list<WorkflowNodeStatus> stateChangeList, - 17: optional list<WorkflowNodeDetails> workflowNodeDetailsList, - 18: optional list<ErrorDetails> errors + 11: optional bool enableEmailNotification, + 12: optional list<string> emailAddresses, + 13: optional UserConfigurationData userConfigurationData, + 14: optional string workflowExecutionInstanceId, + 15: optional list<applicationInterfaceModel.InputDataObjectType> experimentInputs, + 16: optional list<applicationInterfaceModel.OutputDataObjectType> experimentOutputs, + 17: optional ExperimentStatus experimentStatus, + 18: optional list<WorkflowNodeStatus> stateChangeList, + 19: optional list<WorkflowNodeDetails> workflowNodeDetailsList, + 20: optional list<ErrorDetails> errors } struct ExperimentSummary { http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java index 07f423f..c347587 100644 --- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java @@ -30,6 +30,7 @@ public enum ResourceType { CONFIGURATION, GATEWAY_WORKER, EXPERIMENT, + NOTIFICATION_EMAIL, EXPERIMENT_INPUT, EXPERIMENT_OUTPUT, WORKFLOW_NODE_DETAIL, http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java index fc5bb9f..cedbeb3 100644 --- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/ExperimentRegistry.java @@ -69,6 +69,7 @@ public class ExperimentRegistry { experimentResource.setExpName(experiment.getName()); experimentResource.setExecutionUser(experiment.getUserName()); experimentResource.setGateway(gatewayResource); + experimentResource.setEnableEmailNotifications(experiment.isEnableEmailNotification()); if (!workerResource.isProjectExists(experiment.getProjectID())) { logger.error("Project does not exist in the system.."); throw new Exception("Project does not exist in the system, Please create the project first..."); @@ -83,6 +84,17 @@ public class ExperimentRegistry { experimentResource.setWorkflowTemplateVersion(experiment.getWorkflowTemplateVersion()); experimentResource.setWorkflowExecutionId(experiment.getWorkflowExecutionInstanceId()); experimentResource.save(); + + List<String> emailAddresses = experiment.getEmailAddresses(); + if (emailAddresses != null && !emailAddresses.isEmpty()){ + for (String email : emailAddresses){ + NotificationEmailResource emailResource = new NotificationEmailResource(); + emailResource.setExperimentResource(experimentResource); + emailResource.setEmailAddress(email); + emailResource.save(); + } + } + List<InputDataObjectType> experimentInputs = experiment.getExperimentInputs(); if (experimentInputs != null) { addExpInputs(experimentInputs, experimentResource); @@ -903,7 +915,20 @@ public class ExperimentRegistry { taskDetail.setApplicationId(taskDetails.getApplicationId()); taskDetail.setApplicationVersion(taskDetails.getApplicationVersion()); taskDetail.setCreationTime(AiravataUtils.getTime(taskDetails.getCreationTime())); + taskDetail.setEnableEmailNotifications(taskDetails.isEnableEmailNotification()); taskDetail.save(); + + List<String> emailAddresses = taskDetails.getEmailAddresses(); + if (emailAddresses != null && !emailAddresses.isEmpty()){ + for (String email : emailAddresses){ + NotificationEmailResource emailResource = new NotificationEmailResource(); + emailResource.setExperimentResource(experiment); + emailResource.setTaskDetailResource(taskDetail); + emailResource.setEmailAddress(email); + emailResource.save(); + } + } + List<InputDataObjectType> applicationInputs = taskDetails.getApplicationInputs(); if (applicationInputs != null) { addAppInputs(applicationInputs, taskDetail); @@ -978,8 +1003,21 @@ public class ExperimentRegistry { taskDetail.setApplicationVersion(taskDetails.getApplicationVersion()); taskDetail.setCreationTime(AiravataUtils.getTime(taskDetails.getCreationTime())); taskDetail.setApplicationDeploymentId(taskDetails.getApplicationDeploymentId()); - + taskDetail.setEnableEmailNotifications(taskDetails.isEnableEmailNotification()); taskDetail.save(); + + List<String> emailAddresses = taskDetails.getEmailAddresses(); + // remove existing emails + taskDetail.remove(ResourceType.NOTIFICATION_EMAIL, taskId); + if (emailAddresses != null && !emailAddresses.isEmpty()){ + for (String email : emailAddresses){ + NotificationEmailResource emailResource = new NotificationEmailResource(); + emailResource.setExperimentResource(experiment); + emailResource.setTaskDetailResource(taskDetail); + emailResource.setEmailAddress(email); + emailResource.save(); + } + } List<InputDataObjectType> applicationInputs = taskDetails.getApplicationInputs(); if (applicationInputs != null) { updateAppInputs(applicationInputs, taskDetail); @@ -1585,7 +1623,21 @@ public class ExperimentRegistry { existingExperiment.setWorkflowTemplateId(experiment.getWorkflowTemplateId()); existingExperiment.setWorkflowTemplateVersion(experiment.getWorkflowTemplateVersion()); existingExperiment.setWorkflowExecutionId(experiment.getWorkflowExecutionInstanceId()); + existingExperiment.setEnableEmailNotifications(experiment.isEnableEmailNotification()); existingExperiment.save(); + + List<String> emailAddresses = experiment.getEmailAddresses(); + // remove existing email addresses + existingExperiment.remove(ResourceType.NOTIFICATION_EMAIL, expId); + if (emailAddresses != null && !emailAddresses.isEmpty()){ + for (String email : emailAddresses){ + NotificationEmailResource emailResource = new NotificationEmailResource(); + emailResource.setExperimentResource(existingExperiment); + emailResource.setEmailAddress(email); + emailResource.save(); + } + } + List<InputDataObjectType> experimentInputs = experiment.getExperimentInputs(); if (experimentInputs != null && !experimentInputs.isEmpty()) { updateExpInputs(experimentInputs, existingExperiment); http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java index 381efa8..29a22d6 100644 --- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Experiment.java @@ -56,7 +56,8 @@ public class Experiment implements Serializable { private String workflowTemplateVersion; @Column(name = "WORKFLOW_EXECUTION_ID") private String workflowExecutionId; - + @Column(name = "ALLOW_NOTIFICATION") + private boolean allowNotification; @ManyToOne(cascade=CascadeType.MERGE) @JoinColumn(name = "gateway_name") @@ -189,4 +190,12 @@ public class Experiment implements Serializable { public void setUser(Users user) { this.user = user; } + + public boolean isAllowNotification() { + return allowNotification; + } + + public void setAllowNotification(boolean allowNotification) { + this.allowNotification = allowNotification; + } } http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Notification_Email.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Notification_Email.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Notification_Email.java new file mode 100644 index 0000000..524994e --- /dev/null +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Notification_Email.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.persistance.registry.jpa.model; + +import org.apache.openjpa.persistence.DataCache; + +import javax.persistence.*; +import java.io.Serializable; + +@DataCache +@Entity +@Table(name ="NOTIFICATION_EMAIL") +public class Notification_Email implements Serializable { + @Id + @GeneratedValue + private int emailId; + @Column(name = "EXPERIMENT_ID") + private String experiment_id; + @Column(name = "TASK_ID") + private String taskId; + @Column(name = "EMAIL_ADDRESS") + private String emailAddress; + + @ManyToOne + @JoinColumn(name = "EXPERIMENT_ID") + private Experiment experiment; + @ManyToOne + @JoinColumn(name = "TASK_ID") + private TaskDetail taskDetail; + + public String getExperiment_id() { + return experiment_id; + } + + public void setExperiment_id(String experiment_id) { + this.experiment_id = experiment_id; + } + + public Experiment getExperiment() { + return experiment; + } + + public void setExperiment(Experiment experiment) { + this.experiment = experiment; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public TaskDetail getTaskDetail() { + return taskDetail; + } + + public void setTaskDetail(TaskDetail taskDetail) { + this.taskDetail = taskDetail; + } + + public int getEmailId() { + return emailId; + } + + public void setEmailId(int emailId) { + this.emailId = emailId; + } +} http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/TaskDetail.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/TaskDetail.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/TaskDetail.java index 07f700a..ebd7758 100644 --- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/TaskDetail.java +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/TaskDetail.java @@ -43,6 +43,8 @@ public class TaskDetail implements Serializable { private String appId; @Column(name = "APPLICATION_VERSION") private String appVersion; + @Column(name = "ALLOW_NOTIFICATION") + private boolean allowNotification; @Column(name = "APPLICATION_DEPLOYMENT_ID") private String applicationDeploymentId; @@ -106,4 +108,12 @@ public class TaskDetail implements Serializable { public void setApplicationDeploymentId(String applicationDeploymentId) { this.applicationDeploymentId = applicationDeploymentId; } + + public boolean isAllowNotification() { + return allowNotification; + } + + public void setAllowNotification(boolean allowNotification) { + this.allowNotification = allowNotification; + } } http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java index 449c072..32470de 100644 --- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java @@ -38,6 +38,7 @@ public abstract class AbstractResource implements Resource { public static final String PUBLISHED_WORKFLOW = "Published_Workflow"; public static final String USER_WORKFLOW = "User_Workflow"; 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"; @@ -146,6 +147,12 @@ public abstract class AbstractResource implements Resource { 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"; http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java index 3d06987..9958a10 100644 --- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ExperimentResource.java @@ -52,6 +52,7 @@ public class ExperimentResource extends AbstractResource { private String workflowTemplateId; private String workflowTemplateVersion; private String workflowExecutionId; + private boolean enableEmailNotifications; /** * @@ -125,6 +126,14 @@ public class ExperimentResource extends AbstractResource { this.description = description; } + public boolean isEnableEmailNotifications() { + return enableEmailNotifications; + } + + public void setEnableEmailNotifications(boolean enableEmailNotifications) { + this.enableEmailNotifications = enableEmailNotifications; + } + /** * Since experiments are at the leaf level, this method is not * valid for an experiment @@ -141,6 +150,10 @@ public class ExperimentResource extends AbstractResource { ExperimentOutputResource experimentOutputResource = new ExperimentOutputResource(); experimentOutputResource.setExperimentResource(this); return experimentOutputResource; + case NOTIFICATION_EMAIL: + NotificationEmailResource emailResource = new NotificationEmailResource(); + emailResource.setExperimentResource(this); + return emailResource; case WORKFLOW_NODE_DETAIL: WorkflowNodeDetailResource nodeDetailResource = new WorkflowNodeDetailResource(); nodeDetailResource.setExperimentResource(this); @@ -205,6 +218,12 @@ public class ExperimentResource extends AbstractResource { 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); @@ -305,6 +324,15 @@ public class ExperimentResource extends AbstractResource { 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); @@ -444,6 +472,20 @@ public class ExperimentResource extends AbstractResource { } } 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); @@ -540,6 +582,7 @@ public class ExperimentResource extends AbstractResource { experiment.setWorkflowExecutionId(workflowExecutionId); experiment.setWorkflowTemplateVersion(workflowTemplateVersion); experiment.setWorkflowExecutionId(workflowExecutionId); + experiment.setAllowNotification(enableEmailNotifications); if (existingExp != null) { existingExp.setGateway(gateway); existingExp.setGatewayName(gateway.getGateway_name()); @@ -555,6 +598,7 @@ public class ExperimentResource extends AbstractResource { existingExp.setWorkflowExecutionId(workflowExecutionId); existingExp.setWorkflowTemplateVersion(workflowTemplateVersion); existingExp.setWorkflowExecutionId(workflowExecutionId); + existingExp.setAllowNotification(enableEmailNotifications); experiment = em.merge(existingExp); } else { em.persist(experiment); @@ -622,6 +666,15 @@ public class ExperimentResource extends AbstractResource { this.project = project; } + public List<NotificationEmailResource> getNotificationEmails () throws RegistryException{ + List<NotificationEmailResource> emailResources = new ArrayList<NotificationEmailResource>(); + List<Resource> resources = get(ResourceType.NOTIFICATION_EMAIL); + for (Resource resource : resources) { + emailResources.add((NotificationEmailResource) resource); + } + return emailResources; + } + public List<ExperimentInputResource> getExperimentInputs () throws RegistryException{ List<ExperimentInputResource> expInputs = new ArrayList<ExperimentInputResource>(); List<Resource> resources = get(ResourceType.EXPERIMENT_INPUT); http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java new file mode 100644 index 0000000..5ac864f --- /dev/null +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/NotificationEmailResource.java @@ -0,0 +1,125 @@ +/* +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +* +*/ + +package org.apache.airavata.persistance.registry.jpa.resources; + +import org.apache.airavata.persistance.registry.jpa.Resource; +import org.apache.airavata.persistance.registry.jpa.ResourceType; +import org.apache.airavata.persistance.registry.jpa.ResourceUtils; +import org.apache.airavata.persistance.registry.jpa.model.*; +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 AbstractResource { + private static final Logger logger = LoggerFactory.getLogger(NotificationEmailResource.class); + + private int emailId = 0; + private ExperimentResource experimentResource; + private TaskDetailResource taskDetailResource; + private String emailAddress; + + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public ExperimentResource getExperimentResource() { + return experimentResource; + } + + public void setExperimentResource(ExperimentResource experimentResource) { + this.experimentResource = experimentResource; + } + + public TaskDetailResource getTaskDetailResource() { + return taskDetailResource; + } + + public void setTaskDetailResource(TaskDetailResource taskDetailResource) { + this.taskDetailResource = taskDetailResource; + } + + public Resource 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 Resource get(ResourceType type, Object name) throws RegistryException { + logger.error("Unsupported resource type for experiment input data resource.", new UnsupportedOperationException()); + throw new UnsupportedOperationException(); + } + + public List<Resource> 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 = ResourceUtils.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(); + } + Experiment experiment = em.find(Experiment.class, experimentResource.getExpID()); + notification_email.setExperiment(experiment); + notification_email.setExperiment_id(experiment.getExpId()); + if (taskDetailResource != null){ + TaskDetail taskDetail = em.find(TaskDetail.class, taskDetailResource.getTaskId()); + notification_email.setTaskDetail(taskDetail); + notification_email.setTaskId(taskDetail.getTaskId()); + } + 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/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java index a49675f..791c9f9 100644 --- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/TaskDetailResource.java @@ -45,7 +45,16 @@ public class TaskDetailResource extends AbstractResource { private String applicationId; private String applicationVersion; private String applicationDeploymentId; - + private boolean enableEmailNotifications; + + public boolean isEnableEmailNotifications() { + return enableEmailNotifications; + } + + public void setEnableEmailNotifications(boolean enableEmailNotifications) { + this.enableEmailNotifications = enableEmailNotifications; + } + public String getTaskId() { return taskId; } @@ -93,6 +102,10 @@ public class TaskDetailResource extends AbstractResource { ErrorDetailResource errorDetailResource = new ErrorDetailResource(); errorDetailResource.setTaskDetailResource(this); return errorDetailResource; + case NOTIFICATION_EMAIL: + NotificationEmailResource emailResource = new NotificationEmailResource(); + emailResource.setTaskDetailResource(this); + return emailResource; case APPLICATION_INPUT: ApplicationInputResource applicationInputResource = new ApplicationInputResource(); applicationInputResource.setTaskDetailResource(this); @@ -150,6 +163,12 @@ public class TaskDetailResource extends AbstractResource { 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); @@ -243,6 +262,15 @@ public class TaskDetailResource extends AbstractResource { 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); @@ -370,6 +398,20 @@ public class TaskDetailResource extends AbstractResource { } } 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); @@ -502,6 +544,7 @@ public class TaskDetailResource extends AbstractResource { taskDetail.setCreationTime(creationTime); taskDetail.setAppId(applicationId); taskDetail.setAppVersion(applicationVersion); + taskDetail.setAllowNotification(enableEmailNotifications); taskDetail.setApplicationDeploymentId(getApplicationDeploymentId()); } @@ -606,4 +649,13 @@ public class TaskDetailResource extends AbstractResource { public void setApplicationDeploymentId(String applicationDeploymentId) { this.applicationDeploymentId = applicationDeploymentId; } + + public List<NotificationEmailResource> getNotificationEmails () throws RegistryException{ + List<NotificationEmailResource> emailResources = new ArrayList<NotificationEmailResource>(); + List<Resource> resources = get(ResourceType.NOTIFICATION_EMAIL); + for (Resource resource : resources) { + emailResources.add((NotificationEmailResource) resource); + } + return emailResources; + } } http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java index f815505..36a5e90 100644 --- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java @@ -219,6 +219,13 @@ public class Utils { logger.error("Object should be a Experiment.", new IllegalArgumentException()); throw new IllegalArgumentException("Object should be a Experiment."); } + case NOTIFICATION_EMAIL: + if (o instanceof Notification_Email){ + return createNotificationEmail((Notification_Email)o); + }else { + logger.error("Object should be a Experiment.", new IllegalArgumentException()); + throw new IllegalArgumentException("Object should be a Experiment."); + } case EXPERIMENT_INPUT: if (o instanceof Experiment_Input){ return createExperimentInput((Experiment_Input)o); @@ -503,11 +510,24 @@ public class Utils { experimentResource.setWorkflowTemplateId(o.getWorkflowTemplateId()); experimentResource.setWorkflowTemplateVersion(o.getWorkflowTemplateVersion()); experimentResource.setWorkflowExecutionId(o.getWorkflowExecutionId()); + experimentResource.setEnableEmailNotifications(o.isAllowNotification()); } return experimentResource; } + private static Resource createNotificationEmail (Notification_Email o){ + NotificationEmailResource emailResource = new NotificationEmailResource(); + if (o != null){ + ExperimentResource experimentResource = (ExperimentResource)createExperiment(o.getExperiment()); + emailResource.setExperimentResource(experimentResource); + TaskDetailResource taskDetailResource = (TaskDetailResource)createTaskDetail(o.getTaskDetail()); + emailResource.setTaskDetailResource(taskDetailResource); + emailResource.setEmailAddress(o.getEmailAddress()); + } + return emailResource; + } + private static Resource createExperimentInput (Experiment_Input o){ ExperimentInputResource eInputResource = new ExperimentInputResource(); if (o != null){ @@ -577,6 +597,7 @@ public class Utils { taskDetailResource.setApplicationId(o.getAppId()); taskDetailResource.setApplicationVersion(o.getAppVersion()); taskDetailResource.setApplicationDeploymentId(o.getApplicationDeploymentId()); + taskDetailResource.setEnableEmailNotifications(o.isAllowNotification()); } return taskDetailResource; } http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java index 7a9c32d..b48bec8 100644 --- a/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java +++ b/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/ThriftDataModelConversion.java @@ -24,6 +24,7 @@ package org.apache.airavata.persistance.registry.jpa.utils; import java.util.ArrayList; import java.util.List; +import org.apache.airavata.common.utils.StringUtil; import org.apache.airavata.model.appcatalog.appinterface.*; import org.apache.airavata.model.workspace.Project; import org.apache.airavata.model.workspace.experiment.ActionableGroup; @@ -54,26 +55,7 @@ import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails; import org.apache.airavata.model.workspace.experiment.WorkflowNodeState; import org.apache.airavata.model.workspace.experiment.WorkflowNodeStatus; import org.apache.airavata.persistance.registry.jpa.ResourceType; -import org.apache.airavata.persistance.registry.jpa.resources.AdvanceInputDataHandlingResource; -import org.apache.airavata.persistance.registry.jpa.resources.AdvancedOutputDataHandlingResource; -import org.apache.airavata.persistance.registry.jpa.resources.ApplicationInputResource; -import org.apache.airavata.persistance.registry.jpa.resources.ApplicationOutputResource; -import org.apache.airavata.persistance.registry.jpa.resources.ComputationSchedulingResource; -import org.apache.airavata.persistance.registry.jpa.resources.ConfigDataResource; -import org.apache.airavata.persistance.registry.jpa.resources.DataTransferDetailResource; -import org.apache.airavata.persistance.registry.jpa.resources.ErrorDetailResource; -import org.apache.airavata.persistance.registry.jpa.resources.ExperimentInputResource; -import org.apache.airavata.persistance.registry.jpa.resources.ExperimentOutputResource; -import org.apache.airavata.persistance.registry.jpa.resources.ExperimentResource; -import org.apache.airavata.persistance.registry.jpa.resources.JobDetailResource; -import org.apache.airavata.persistance.registry.jpa.resources.NodeInputResource; -import org.apache.airavata.persistance.registry.jpa.resources.NodeOutputResource; -import org.apache.airavata.persistance.registry.jpa.resources.ProjectResource; -import org.apache.airavata.persistance.registry.jpa.resources.ProjectUserResource; -import org.apache.airavata.persistance.registry.jpa.resources.QosParamResource; -import org.apache.airavata.persistance.registry.jpa.resources.StatusResource; -import org.apache.airavata.persistance.registry.jpa.resources.TaskDetailResource; -import org.apache.airavata.persistance.registry.jpa.resources.WorkflowNodeDetailResource; +import org.apache.airavata.persistance.registry.jpa.resources.*; import org.apache.airavata.registry.cpi.RegistryException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -119,6 +101,11 @@ public class ThriftDataModelConversion { experiment.setApplicationId(experimentResource.getApplicationId()); experiment.setApplicationVersion(experimentResource.getApplicationVersion()); experiment.setWorkflowTemplateId(experimentResource.getWorkflowTemplateId()); + experiment.setEnableEmailNotification(experimentResource.isEnableEmailNotifications()); + if (experiment.isEnableEmailNotification()){ + List<NotificationEmailResource> notificationEmails = experimentResource.getNotificationEmails(); + experiment.setEmailAddresses(getEmailAddresses(notificationEmails)); + } experiment.setWorkflowTemplateVersion(experimentResource.getWorkflowTemplateVersion()); experiment.setWorkflowExecutionInstanceId(experimentResource.getWorkflowExecutionId()); List<ExperimentInputResource> experimentInputs = experimentResource.getExperimentInputs(); @@ -287,6 +274,16 @@ public class ThriftDataModelConversion { return null; } + public static List<String> getEmailAddresses (List<NotificationEmailResource> resourceList){ + List<String> emailAddresses = new ArrayList<String>(); + if (resourceList != null && !resourceList.isEmpty()){ + for (NotificationEmailResource emailResource : resourceList){ + emailAddresses.add(emailResource.getEmailAddress()); + } + } + return emailAddresses; + } + public static List<InputDataObjectType> getExpInputs (List<ExperimentInputResource> exInputList){ List<InputDataObjectType> expInputs = new ArrayList<InputDataObjectType>(); if (exInputList != null && !exInputList.isEmpty()){ @@ -484,6 +481,11 @@ public class ThriftDataModelConversion { taskDetails.setApplicationInputs(getApplicationInputs(applicationInputs)); List<ApplicationOutputResource> applicationOutputs = taskDetailResource.getApplicationOutputs(); taskDetails.setApplicationOutputs(getApplicationOutputs(applicationOutputs)); + taskDetails.setEnableEmailNotification(taskDetailResource.isEnableEmailNotifications()); + if (taskDetails.isEnableEmailNotification()){ + List<NotificationEmailResource> notificationEmails = taskDetailResource.getNotificationEmails(); + taskDetails.setEmailAddresses(getEmailAddresses(notificationEmails)); + } taskDetails.setApplicationDeploymentId(taskDetailResource.getApplicationDeploymentId()); if (taskDetailResource.isExists(ResourceType.COMPUTATIONAL_RESOURCE_SCHEDULING, taskId)){ ComputationSchedulingResource computationScheduling = taskDetailResource.getComputationScheduling(taskId); http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml b/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml index c5b9aec..a37b6ae 100644 --- a/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml +++ b/modules/registry/airavata-jpa-registry/src/main/resources/META-INF/persistence.xml @@ -32,6 +32,7 @@ <class>org.apache.airavata.persistance.registry.jpa.model.Published_Workflow</class> <class>org.apache.airavata.persistance.registry.jpa.model.User_Workflow</class> <class>org.apache.airavata.persistance.registry.jpa.model.Experiment</class> + <class>org.apache.airavata.persistance.registry.jpa.model.Notification_Email</class> <class>org.apache.airavata.persistance.registry.jpa.model.Experiment_Input</class> <class>org.apache.airavata.persistance.registry.jpa.model.Experiment_Output</class> <class>org.apache.airavata.persistance.registry.jpa.model.WorkflowNodeDetail</class> http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql b/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql index 8516950..c3d7b3a 100644 --- a/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql +++ b/modules/registry/airavata-jpa-registry/src/main/resources/registry-derby.sql @@ -115,12 +115,15 @@ CREATE TABLE EXPERIMENT WORKFLOW_TEMPLATE_ID VARCHAR(255), WORKFLOW_TEMPLATE_VERSION VARCHAR(255), WORKFLOW_EXECUTION_ID VARCHAR(255), + ALLOW_NOTIFICATION SMALLINT, 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), @@ -176,10 +179,22 @@ CREATE TABLE TASK_DETAIL 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, http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/main/resources/registry-mysql.sql ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/main/resources/registry-mysql.sql b/modules/registry/airavata-jpa-registry/src/main/resources/registry-mysql.sql index 855c7cc..356c7d6 100644 --- a/modules/registry/airavata-jpa-registry/src/main/resources/registry-mysql.sql +++ b/modules/registry/airavata-jpa-registry/src/main/resources/registry-mysql.sql @@ -115,6 +115,7 @@ CREATE TABLE EXPERIMENT WORKFLOW_TEMPLATE_ID VARCHAR(255), WORKFLOW_TEMPLATE_VERSION VARCHAR(255), WORKFLOW_EXECUTION_ID VARCHAR(255), + ALLOW_NOTIFICATION SMALLINT, 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, @@ -175,11 +176,21 @@ CREATE TABLE TASK_DETAIL 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 AUTO_INCREMENT, + 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 APPLICATION_INPUT ( http://git-wip-us.apache.org/repos/asf/airavata/blob/7a6fbdb2/modules/registry/airavata-jpa-registry/src/test/resources/registry-derby.sql ---------------------------------------------------------------------- diff --git a/modules/registry/airavata-jpa-registry/src/test/resources/registry-derby.sql b/modules/registry/airavata-jpa-registry/src/test/resources/registry-derby.sql index 8516950..cb9fc44 100644 --- a/modules/registry/airavata-jpa-registry/src/test/resources/registry-derby.sql +++ b/modules/registry/airavata-jpa-registry/src/test/resources/registry-derby.sql @@ -115,12 +115,21 @@ CREATE TABLE EXPERIMENT WORKFLOW_TEMPLATE_ID VARCHAR(255), WORKFLOW_TEMPLATE_VERSION VARCHAR(255), WORKFLOW_EXECUTION_ID VARCHAR(255), + ALLOW_NOTIFICATION SMALLINT, 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 NOTIFICATION_EMAIL +( + EXPERIMENT_ID VARCHAR(255), + EMAIL_ADDRESS VARCHAR(255), + PRIMARY KEY(EXPERIMENT_ID,EMAIL_ADDRESS), + FOREIGN KEY (EXPERIMENT_ID) REFERENCES EXPERIMENT(EXPERIMENT_ID) ON DELETE CASCADE +); + CREATE TABLE EXPERIMENT_INPUT ( EXPERIMENT_ID VARCHAR(255),
