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/13 20:21:13 UTC
[airavata] branch group-based-auth updated: AIRAVATA-2825 Assign
statusId if missing in updateProcessStatus
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 10f1c7f AIRAVATA-2825 Assign statusId if missing in updateProcessStatus
10f1c7f is described below
commit 10f1c7f7bc82cafca738973e8f9587a7403af9c0
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Jun 13 16:19:49 2018 -0400
AIRAVATA-2825 Assign statusId if missing in updateProcessStatus
---
.../expcatalog/ProcessStatusRepository.java | 11 +++++++++++
.../expcatalog/ProcessStatusRepositoryTest.java | 20 ++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepository.java
index 6887a99..b1cc7bd 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepository.java
@@ -41,6 +41,17 @@ public class ProcessStatusRepository extends ExpCatAbstractRepository<ProcessSta
public ProcessStatusRepository() { super(ProcessStatus.class, ProcessStatusEntity.class); }
protected String saveProcessStatus(ProcessStatus processStatus, String processId) throws RegistryException {
+ if (processStatus.getStatusId() == null) {
+
+ ProcessStatus currentProcessStatus = getProcessStatus(processId);
+ if (currentProcessStatus == null || currentProcessStatus.getState() != currentProcessStatus.getState()) {
+ processStatus.setStatusId(ExpCatalogUtils.getID("PROCESS_STATE"));
+ } else {
+ // Update the existing current status if processStatus has no status id and the same state
+ processStatus.setStatusId(currentProcessStatus.getStatusId());
+ }
+ }
+
Mapper mapper = ObjectMapperSingleton.getInstance();
ProcessStatusEntity processStatusEntity = mapper.map(processStatus, ProcessStatusEntity.class);
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepositoryTest.java
index 0b51f8a..629b281 100644
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepositoryTest.java
+++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProcessStatusRepositoryTest.java
@@ -36,6 +36,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class ProcessStatusRepositoryTest {
@@ -108,6 +109,25 @@ public class ProcessStatusRepositoryTest {
ProcessStatus retrievedStatus = processStatusRepository.getProcessStatus(processId);
assertEquals(ProcessState.EXECUTING, retrievedStatus.getState());
+ ProcessStatus updatedStatus = new ProcessStatus(ProcessState.MONITORING);
+ // Verify that ProcessStatus without id can be added with updateProcessStatus
+ String updatedStatusId = processStatusRepository.updateProcessStatus(updatedStatus, processId);
+ retrievedStatus = processStatusRepository.getProcessStatus(processId);
+ assertEquals(ProcessState.MONITORING, retrievedStatus.getState());
+ assertEquals(updatedStatusId, retrievedStatus.getStatusId());
+ assertNull(retrievedStatus.getReason());
+
+ // Verify that updating status with same ProcessState as most recent ProcessStatus will update the most recent ProcessStatus
+ ProcessStatus updatedStatusWithReason = new ProcessStatus(ProcessState.MONITORING);
+ updatedStatusWithReason.setReason("test-reason");
+ String updateStatusWithReasonId = processStatusRepository.updateProcessStatus(updatedStatusWithReason, processId);
+ retrievedStatus = processStatusRepository.getProcessStatus(processId);
+ assertEquals(ProcessState.MONITORING, retrievedStatus.getState());
+ assertEquals(updateStatusWithReasonId, retrievedStatus.getStatusId());
+ assertEquals(updatedStatusId, updateStatusWithReasonId);
+ assertEquals("test-reason", retrievedStatus.getReason());
+
+
experimentRepository.removeExperiment(experimentId);
processRepository.removeProcess(processId);
gatewayRepository.removeGateway(gatewayId);
--
To stop receiving notification emails like this one, please contact
machristie@apache.org.