You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2018/06/11 20:15:09 UTC
[airavata] branch group-based-auth updated: AIRAVATA-2822 Bringing
saveExperimentStatus in line with current impl
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch group-based-auth
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/group-based-auth by this push:
new d14aea5 AIRAVATA-2822 Bringing saveExperimentStatus in line with current impl
d14aea5 is described below
commit d14aea5840a18d2dadf02b971fb5ec1b23d0f4c8
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Mon Jun 11 16:12:51 2018 -0400
AIRAVATA-2822 Bringing saveExperimentStatus in line with current impl
ExperimentRegistry will update an existing ExperimentStatus record if
the new record has the same ExperimentState as the "current"
ExperimentStatus record.
---
.../repositories/expcatalog/ExperimentStatusRepository.java | 12 ++++++++++++
.../expcatalog/ExperimentStatusRepositoryTest.java | 5 +++++
2 files changed, 17 insertions(+)
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentStatusRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentStatusRepository.java
index 0babd10..dc06f19 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentStatusRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentStatusRepository.java
@@ -42,6 +42,18 @@ public class ExperimentStatusRepository extends ExpCatAbstractRepository<Experim
public ExperimentStatusRepository() { super(ExperimentStatus.class, ExperimentStatusEntity.class); }
protected String saveExperimentStatus(ExperimentStatus experimentStatus, String experimentId) throws RegistryException {
+
+ if (experimentStatus.getStatusId() == null) {
+
+ ExperimentStatus currentExperimentStatus = getExperimentStatus(experimentId);
+ if (currentExperimentStatus == null || currentExperimentStatus.getState() != experimentStatus.getState()) {
+ experimentStatus.setStatusId(ExpCatalogUtils.getID("EXPERIMENT_STATE"));
+ } else {
+ // Update the existing current status if experimentStatus has no status id and the same state
+ experimentStatus.setStatusId(currentExperimentStatus.getStatusId());
+ }
+ }
+
Mapper mapper = ObjectMapperSingleton.getInstance();
ExperimentStatusEntity experimentStatusEntity = mapper.map(experimentStatus, ExperimentStatusEntity.class);
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentStatusRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentStatusRepositoryTest.java
index c6f4de8..ec1224b 100644
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentStatusRepositoryTest.java
+++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentStatusRepositoryTest.java
@@ -101,8 +101,13 @@ public class ExperimentStatusRepositoryTest {
experimentStatus.setState(ExperimentState.EXECUTING);
experimentStatusRepository.updateExperimentStatus(experimentStatus, experimentId);
+ ExperimentStatus updatedExecutingStatus = new ExperimentStatus(ExperimentState.EXECUTING);
+ updatedExecutingStatus.setReason("updated reason");
+ String updatedExperimentStatusId = experimentStatusRepository.updateExperimentStatus(updatedExecutingStatus, experimentId);
+
ExperimentStatus retrievedExpStatus = experimentStatusRepository.getExperimentStatus(experimentId);
assertEquals(ExperimentState.EXECUTING, retrievedExpStatus.getState());
+ assertEquals("updated reason", updatedExecutingStatus.getReason());
experimentRepository.removeExperiment(experimentId);
gatewayRepository.removeGateway(gatewayId);
--
To stop receiving notification emails like this one, please contact
machristie@apache.org.