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/08 20:48:35 UTC

[airavata] branch group-based-auth updated: AIRAVATA-2819 addExperiment implicitly adds CREATED status

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 28cb205  AIRAVATA-2819 addExperiment implicitly adds CREATED status
28cb205 is described below

commit 28cb205d9471fe8152abcf2dbf729e97b367be70
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Fri Jun 8 16:33:19 2018 -0400

    AIRAVATA-2819 addExperiment implicitly adds CREATED status
---
 .../expcatalog/ExperimentRepository.java           | 28 ++++++++++++++++++----
 .../expcatalog/ExperimentStatusRepository.java     |  2 +-
 .../expcatalog/ExperimentRepositoryTest.java       | 13 ++++++----
 3 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepository.java
index 3835a14..3016787 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepository.java
@@ -20,21 +20,28 @@
 */
 package org.apache.airavata.registry.core.repositories.expcatalog;
 
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.model.commons.airavata_commonsConstants;
 import org.apache.airavata.model.experiment.ExperimentModel;
 import org.apache.airavata.model.experiment.UserConfigurationDataModel;
-import org.apache.airavata.registry.core.entities.expcatalog.*;
+import org.apache.airavata.model.status.ExperimentState;
+import org.apache.airavata.model.status.ExperimentStatus;
+import org.apache.airavata.registry.core.entities.expcatalog.ExperimentEntity;
 import org.apache.airavata.registry.core.utils.DBConstants;
-import org.apache.airavata.model.commons.airavata_commonsConstants;
 import org.apache.airavata.registry.core.utils.ExpCatalogUtils;
 import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
 import org.apache.airavata.registry.core.utils.QueryConstants;
-import org.apache.airavata.registry.cpi.*;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.ResultOrderType;
 import org.dozer.Mapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.sql.Timestamp;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 public class ExperimentRepository extends ExpCatAbstractRepository<ExperimentModel, ExperimentEntity, String> {
     private final static Logger logger = LoggerFactory.getLogger(ExperimentRepository.class);
@@ -75,7 +82,12 @@ public class ExperimentRepository extends ExpCatAbstractRepository<ExperimentMod
 
         if (experimentEntity.getExperimentStatus() != null) {
             logger.debug("Populating the Primary Key of ExperimentStatus objects for the Experiment");
-            experimentEntity.getExperimentStatus().forEach(experimentStatusEntity -> experimentStatusEntity.setExperimentId(experimentId));
+            experimentEntity.getExperimentStatus().forEach(experimentStatusEntity -> {
+                if (experimentStatusEntity.getStatusId() == null) {
+                    experimentStatusEntity.setStatusId(AiravataUtils.getId("EXPERIMENT_STATE"));
+                }
+                experimentStatusEntity.setExperimentId(experimentId);
+            });
         }
 
         if (experimentEntity.getErrors() != null) {
@@ -97,6 +109,12 @@ public class ExperimentRepository extends ExpCatAbstractRepository<ExperimentMod
     }
 
     public String addExperiment(ExperimentModel experimentModel) throws RegistryException {
+
+        ExperimentStatus experimentStatus = new ExperimentStatus();
+        experimentStatus.setState(ExperimentState.CREATED);
+        experimentStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
+        experimentModel.addToExperimentStatus(experimentStatus);
+
         return saveExperimentModelData(experimentModel);
     }
 
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 a2c0f79..a09a024 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
@@ -57,7 +57,7 @@ public class ExperimentStatusRepository extends ExpCatAbstractRepository<Experim
 
         if (experimentStatus.getStatusId() == null) {
             logger.debug("Setting the ExperimentStatus's StatusId");
-            experimentStatus.setStatusId(ExpCatalogUtils.getID("STATUS"));
+            experimentStatus.setStatusId(ExpCatalogUtils.getID("EXPERIMENT_STATE"));
         }
 
         return saveExperimentStatus(experimentStatus, experimentId);
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepositoryTest.java b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepositoryTest.java
index e755919..9dff2b3 100644
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepositoryTest.java
+++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentRepositoryTest.java
@@ -24,6 +24,7 @@ import org.apache.airavata.model.experiment.ExperimentModel;
 import org.apache.airavata.model.experiment.ExperimentType;
 import org.apache.airavata.model.experiment.UserConfigurationDataModel;
 import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
+import org.apache.airavata.model.status.ExperimentState;
 import org.apache.airavata.model.workspace.Gateway;
 import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.registry.core.repositories.expcatalog.util.Initialize;
@@ -92,13 +93,17 @@ public class ExperimentRepositoryTest {
         String experimentId = experimentRepository.addExperiment(experimentModel);
         assertTrue(experimentId != null);
 
-        experimentModel.setDescription("description");
-        experimentRepository.updateExperiment(experimentModel, experimentId);
-
+        // Retrieve the experiment again to get ids populated on ExperimentStatus instances
         ExperimentModel retrievedExperimentModel = experimentRepository.getExperiment(experimentId);
-        assertEquals(experimentModel.getDescription(), retrievedExperimentModel.getDescription());
+        retrievedExperimentModel.setDescription("description");
+        experimentRepository.updateExperiment(retrievedExperimentModel, experimentId);
+
+        retrievedExperimentModel = experimentRepository.getExperiment(experimentId);
+        assertEquals("description", retrievedExperimentModel.getDescription());
         assertEquals(ExperimentType.SINGLE_APPLICATION, retrievedExperimentModel.getExperimentType());
         assertEquals("gateway-instance-id", retrievedExperimentModel.getGatewayInstanceId());
+        assertEquals(1, retrievedExperimentModel.getExperimentStatusSize());
+        assertEquals(ExperimentState.CREATED, retrievedExperimentModel.getExperimentStatus().get(0).getState());
 
         UserConfigurationDataModel userConfigurationDataModel = new UserConfigurationDataModel();
         userConfigurationDataModel.setAiravataAutoSchedule(true);

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.