airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject [1/3] airavata git commit: fixing JPA issues
Date Fri, 02 Oct 2015 15:33:57 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 25b85226c -> dea83926c


http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputResource.java
index 2502306..8789681 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentOutputResource.java
@@ -162,7 +162,12 @@ public class ExperimentOutputResource extends AbstractExpCatResource {
             experimentOutputPK.setExperimentId(experimentId);
             experimentOutputPK.setOutputName(outputName);
             ExperimentOutput existingExpOutput = em.find(ExperimentOutput.class, experimentOutputPK);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -187,7 +192,12 @@ public class ExperimentOutputResource extends AbstractExpCatResource {
                 em.merge(experimentOutput);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
index 6098770..7ccd652 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentResource.java
@@ -234,7 +234,12 @@ public class ExperimentResource extends AbstractExpCatResource {
                     break;
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);
@@ -264,7 +269,12 @@ public class ExperimentResource extends AbstractExpCatResource {
                     ExperimentStatus status = (ExperimentStatus) q.getSingleResult();
                     ExperimentStatusResource statusResource = (ExperimentStatusResource) Utils.getResource(ResourceType.EXPERIMENT_STATUS, status);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return statusResource;
                 case EXPERIMENT_ERROR:
                     generator = new QueryGenerator(EXPERIMENT_ERROR);
@@ -273,7 +283,12 @@ public class ExperimentResource extends AbstractExpCatResource {
                     ExperimentError experimentError = (ExperimentError) q.getSingleResult();
                     ExperimentErrorResource processErrorResource = (ExperimentErrorResource) Utils.getResource(ResourceType.EXPERIMENT_ERROR, experimentError);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return processErrorResource;
                 case EXPERIMENT_INPUT:
                     generator = new QueryGenerator(EXPERIMENT_INPUT);
@@ -283,7 +298,12 @@ public class ExperimentResource extends AbstractExpCatResource {
                     ExperimentInput experimentInput = (ExperimentInput) q.getSingleResult();
                     ExperimentInputResource experimentInputResource = (ExperimentInputResource) Utils.getResource(ResourceType.EXPERIMENT_INPUT, experimentInput);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return experimentInputResource;
                 case EXPERIMENT_OUTPUT:
                     generator = new QueryGenerator(EXPERIMENT_OUTPUT);
@@ -293,7 +313,12 @@ public class ExperimentResource extends AbstractExpCatResource {
                     ExperimentOutput experimentOutput = (ExperimentOutput) q.getSingleResult();
                     ExperimentOutputResource outputResource = (ExperimentOutputResource) Utils.getResource(ResourceType.EXPERIMENT_OUTPUT, experimentOutput);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return outputResource;
                 case USER_CONFIGURATION_DATA:
                     generator = new QueryGenerator(USER_CONFIGURATION_DATA);
@@ -303,7 +328,12 @@ public class ExperimentResource extends AbstractExpCatResource {
                     UserConfigurationDataResource configurationDataResource = (UserConfigurationDataResource)
                             Utils.getResource(ResourceType.USER_CONFIGURATION_DATA, configurationData);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return configurationDataResource;
                 case PROCESS:
                     generator = new QueryGenerator(PROCESS);
@@ -312,11 +342,21 @@ public class ExperimentResource extends AbstractExpCatResource {
                     Process process = (Process) q.getSingleResult();
                     ProcessResource processResource = (ProcessResource) Utils.getResource(ResourceType.PROCESS, process);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return processResource;
                 default:
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     logger.error("Unsupported resource type for experiment resource.", new IllegalArgumentException());
                     throw new IllegalArgumentException("Unsupported resource type for experiment resource.");
             }
@@ -417,7 +457,12 @@ public class ExperimentResource extends AbstractExpCatResource {
                     throw new UnsupportedOperationException();
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);
@@ -437,7 +482,13 @@ public class ExperimentResource extends AbstractExpCatResource {
         try {
             em = ExpCatResourceUtils.getEntityManager();
             Experiment existingExp = em.find(Experiment.class, experimentId);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+
             Experiment experiment;
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -464,7 +515,12 @@ public class ExperimentResource extends AbstractExpCatResource {
                 em.merge(experiment);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
index 3ea0b41..c9ddeb9 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ExperimentStatusResource.java
@@ -118,7 +118,12 @@ public class ExperimentStatusResource extends AbstractExpCatResource {
             experimentStatusPK.setStatusId(statusId);
             experimentStatusPK.setExperimentId(experimentId);
             ExperimentStatus existingStatus = em.find(ExperimentStatus.class, experimentStatusPK);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -138,7 +143,12 @@ public class ExperimentStatusResource extends AbstractExpCatResource {
                 em.merge(experimentStatus);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
index 941b267..c438ab8 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobResource.java
@@ -172,7 +172,12 @@ public class JobResource extends AbstractExpCatResource {
                     break;
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);
@@ -202,11 +207,21 @@ public class JobResource extends AbstractExpCatResource {
                     JobStatus status = (JobStatus) q.getSingleResult();
                     JobStatusResource statusResource = (JobStatusResource) Utils.getResource(ResourceType.JOB_STATUS, status);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return statusResource;
                 default:
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     logger.error("Unsupported resource type for Job resource.", new IllegalArgumentException());
                     throw new IllegalArgumentException("Unsupported resource type for Job resource.");
             }
@@ -254,7 +269,12 @@ public class JobResource extends AbstractExpCatResource {
                     throw new UnsupportedOperationException();
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);
@@ -278,7 +298,12 @@ public class JobResource extends AbstractExpCatResource {
             jobPK.setJobId(jobId);
             jobPK.setProcessId(processId);
             Job existingJob = em.find(Job.class, jobPK);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             Job job;
             em = ExpCatResourceUtils.getEntityManager();
@@ -311,7 +336,12 @@ public class JobResource extends AbstractExpCatResource {
                 em.merge(job);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
index 9ed1f31..97f2973 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/JobStatusResource.java
@@ -128,7 +128,12 @@ public class JobStatusResource extends AbstractExpCatResource {
             jobStatusPK.setStatusId(statusId);
             jobStatusPK.setProcessId(processId);
             JobStatus existingJobStatus = em.find(JobStatus.class, jobStatusPK);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -148,7 +153,12 @@ public class JobStatusResource extends AbstractExpCatResource {
                 em.merge(jobStatus);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
index 9d13705..4586295 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessErrorResource.java
@@ -136,7 +136,12 @@ public class ProcessErrorResource extends AbstractExpCatResource {
             processErrorPK.setProcessId(processId);
             processErrorPK.setErrorId(errorId);
             ProcessError existingPrError = em.find(ProcessError.class, processErrorPK);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -157,7 +162,12 @@ public class ProcessErrorResource extends AbstractExpCatResource {
                 em.merge(processError);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
index aff8ec8..a73b6e3 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessInputResource.java
@@ -180,7 +180,12 @@ public class ProcessInputResource extends AbstractExpCatResource {
             processInputPk.setProcessId(processId);
             processInputPk.setInputName(inputName);
             ProcessInput existingProInput = em.find(ProcessInput.class, processInputPk);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -207,7 +212,12 @@ public class ProcessInputResource extends AbstractExpCatResource {
                 em.merge(processInput);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java
index de93b63..71370c2 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessOutputResource.java
@@ -163,7 +163,12 @@ public class ProcessOutputResource extends AbstractExpCatResource {
             processOutputPK.setProcessId(processId);
             processOutputPK.setOutputName(outputName);
             ProcessOutput existingProcessOutput = em.find(ProcessOutput.class, processOutputPK);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -188,7 +193,12 @@ public class ProcessOutputResource extends AbstractExpCatResource {
                 em.merge(processOutput);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
index 1c89cba..5f79edf 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResource.java
@@ -243,7 +243,12 @@ public class ProcessResource extends AbstractExpCatResource {
                     break;
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);
@@ -273,7 +278,12 @@ public class ProcessResource extends AbstractExpCatResource {
                     ProcessStatus status = (ProcessStatus) q.getSingleResult();
                     ProcessStatusResource statusResource = (ProcessStatusResource) Utils.getResource(ResourceType.PROCESS_STATUS, status);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return statusResource;
                 case PROCESS_ERROR:
                     generator = new QueryGenerator(PROCESS_ERROR);
@@ -282,7 +292,12 @@ public class ProcessResource extends AbstractExpCatResource {
                     ProcessError processError = (ProcessError) q.getSingleResult();
                     ProcessErrorResource processErrorResource = (ProcessErrorResource) Utils.getResource(ResourceType.PROCESS_ERROR, processError);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return processErrorResource;
                 case PROCESS_INPUT:
                     generator = new QueryGenerator(PROCESS_INPUT);
@@ -292,7 +307,12 @@ public class ProcessResource extends AbstractExpCatResource {
                     ProcessInput processInput = (ProcessInput) q.getSingleResult();
                     ProcessInputResource processInputResource = (ProcessInputResource) Utils.getResource(ResourceType.PROCESS_INPUT, processInput);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return processInputResource;
                 case PROCESS_OUTPUT:
                     generator = new QueryGenerator(PROCESS_OUTPUT);
@@ -302,7 +322,12 @@ public class ProcessResource extends AbstractExpCatResource {
                     ProcessOutput processOutput = (ProcessOutput) q.getSingleResult();
                     ProcessOutputResource outputResource = (ProcessOutputResource) Utils.getResource(ResourceType.PROCESS_OUTPUT, processOutput);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return outputResource;
                 case PROCESS_RESOURCE_SCHEDULE:
                     generator = new QueryGenerator(PROCESS_RESOURCE_SCHEDULE);
@@ -312,7 +337,12 @@ public class ProcessResource extends AbstractExpCatResource {
                     ProcessResourceScheduleResource processResourceScheduleResource = (ProcessResourceScheduleResource)
                             Utils.getResource(ResourceType.PROCESS_RESOURCE_SCHEDULE, processResourceSchedule);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return processResourceScheduleResource;
                 case TASK:
                     generator = new QueryGenerator(TASK);
@@ -321,7 +351,12 @@ public class ProcessResource extends AbstractExpCatResource {
                     Task task = (Task) q.getSingleResult();
                     TaskResource taskResource = (TaskResource) Utils.getResource(ResourceType.TASK, task);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return taskResource;
 	            case JOB:
 		            generator = new QueryGenerator(JOB);
@@ -331,11 +366,21 @@ public class ProcessResource extends AbstractExpCatResource {
 		            Job job = (Job) q.getSingleResult();
 		            JobResource jobResource = (JobResource) Utils.getResource(ResourceType.JOB, job);
 		            em.getTransaction().commit();
-		            em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
 		            return jobResource;
 	            default:
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     logger.error("Unsupported resource type for process resource.", new IllegalArgumentException());
                     throw new IllegalArgumentException("Unsupported resource type for process resource.");
             }
@@ -451,7 +496,12 @@ public class ProcessResource extends AbstractExpCatResource {
                     throw new UnsupportedOperationException();
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);
@@ -472,7 +522,12 @@ public class ProcessResource extends AbstractExpCatResource {
         try {
             em = ExpCatResourceUtils.getEntityManager();
             Process existingProcess = em.find(Process.class, processId);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             Process process;
             em = ExpCatResourceUtils.getEntityManager();
@@ -500,7 +555,12 @@ public class ProcessResource extends AbstractExpCatResource {
                 em.merge(process);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java
index 2513213..dda4b54 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessResourceScheduleResource.java
@@ -140,7 +140,12 @@ public class ProcessResourceScheduleResource extends AbstractExpCatResource {
             em = ExpCatResourceUtils.getEntityManager();
             ProcessResourceSchedule processResourceSchedule;
             ProcessResourceSchedule existingSchedule = em.find(ProcessResourceSchedule.class, processId);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -163,7 +168,12 @@ public class ProcessResourceScheduleResource extends AbstractExpCatResource {
                 em.merge(processResourceSchedule);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
index 2e5e10c..8123f29 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/ProcessStatusResource.java
@@ -118,7 +118,12 @@ public class ProcessStatusResource extends AbstractExpCatResource {
             processStatusPK.setStatusId(statusId);
             processStatusPK.setProcessId(processId);
             ProcessStatus existingStatus = em.find(ProcessStatus.class, processStatusPK);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -137,7 +142,12 @@ public class ProcessStatusResource extends AbstractExpCatResource {
                 em.merge(processStatus);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java
index 8fd71f5..ea50dda 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskErrorResource.java
@@ -136,7 +136,12 @@ public class TaskErrorResource extends AbstractExpCatResource {
             taskErrorPK.setTaskId(taskId);
             taskErrorPK.setErrorId(errorId);
             TaskError existingTaskError = em.find(TaskError.class, taskErrorPK);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -157,7 +162,12 @@ public class TaskErrorResource extends AbstractExpCatResource {
                 em.merge(taskError);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
index 0226f30..bd6ff74 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskResource.java
@@ -148,7 +148,12 @@ public class TaskResource extends AbstractExpCatResource {
                     break;
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);
@@ -178,7 +183,12 @@ public class TaskResource extends AbstractExpCatResource {
                     TaskStatus status = (TaskStatus) q.getSingleResult();
                     TaskStatusResource statusResource = (TaskStatusResource) Utils.getResource(ResourceType.TASK_STATUS, status);
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return statusResource;
                 case TASK_ERROR:
                     generator = new QueryGenerator(TASK_ERROR);
@@ -189,11 +199,21 @@ public class TaskResource extends AbstractExpCatResource {
                             ResourceType.TASK_ERROR, error
                     );
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     return errorResource;
                 default:
                     em.getTransaction().commit();
-                    em.close();
+                    if (em.isOpen()) {
+                        if (em.getTransaction().isActive()){
+                            em.getTransaction().rollback();
+                        }
+                        em.close();
+                    }
                     logger.error("Unsupported resource type for Task resource.", new IllegalArgumentException());
                     throw new IllegalArgumentException("Unsupported resource type for Task resource.");
             }
@@ -254,7 +274,12 @@ public class TaskResource extends AbstractExpCatResource {
                     throw new UnsupportedOperationException();
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);
@@ -276,7 +301,12 @@ public class TaskResource extends AbstractExpCatResource {
             em = ExpCatResourceUtils.getEntityManager();
             Task task;
             Task existingTask = em.find(Task.class, taskId);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -298,7 +328,12 @@ public class TaskResource extends AbstractExpCatResource {
                 em.merge(task);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java
index dc59e83..900cc85 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/TaskStatusResource.java
@@ -118,7 +118,12 @@ public class TaskStatusResource extends AbstractExpCatResource {
             taskStatusPK.setTaskId(taskId);
             taskStatusPK.setStatusId(statusId);
             TaskStatus existingStatus = em.find(TaskStatus.class, taskStatusPK);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -138,7 +143,12 @@ public class TaskStatusResource extends AbstractExpCatResource {
                 em.merge(taskStatus);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserConfigurationDataResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserConfigurationDataResource.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserConfigurationDataResource.java
index ef670f2..bf2e553 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserConfigurationDataResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/UserConfigurationDataResource.java
@@ -194,7 +194,12 @@ public class UserConfigurationDataResource extends AbstractExpCatResource {
                 throw new RegistryException("Does not have the experiment id");
             }
             UserConfigurationData existingConf = em.find(UserConfigurationData.class, experimentId);
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
 
             em = ExpCatResourceUtils.getEntityManager();
             em.getTransaction().begin();
@@ -223,7 +228,12 @@ public class UserConfigurationDataResource extends AbstractExpCatResource {
                 em.merge(userConfigurationData);
             }
             em.getTransaction().commit();
-            em.close();
+            if (em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
         } catch (Exception e) {
             logger.error(e.getMessage(), e);
             throw new RegistryException(e);

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/QueryGenerator.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/QueryGenerator.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/QueryGenerator.java
index 53e6848..0e3e68d 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/QueryGenerator.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/QueryGenerator.java
@@ -22,6 +22,8 @@
 package org.apache.airavata.registry.core.experiment.catalog.utils;
 
 import org.apache.airavata.registry.cpi.ResultOrderType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
@@ -29,6 +31,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 public class QueryGenerator {
+    private final static Logger logger = LoggerFactory.getLogger(QueryGenerator.class);
 	private String tableName;
 	private Map<String,Object> matches=new HashMap<String, Object>();
 	private static final String SELECT_OBJ="p";
@@ -96,8 +99,7 @@ public class QueryGenerator {
 		return generateQueryWithParameters(entityManager, queryString);
 	}
 
-	private Query generateQueryWithParameters(EntityManager entityManager,
-			String queryString) {
+	private Query generateQueryWithParameters(EntityManager entityManager, String queryString) {
 		return generateQueryWithParameters(entityManager, queryString, "");
 	}
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/bb43bfdd/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
index 91c3a4b..134de39 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/utils/ThriftDataModelConversion.java
@@ -354,13 +354,20 @@ public class ThriftDataModelConversion {
             processModel.setProcessInputs(getProcessInputs(processResource.getProcessInputs()));
             processModel.setProcessOutputs(getProcessOutputs(processResource.getProcessOutputs()));
 
-            processModel.setProcessError(getErrorModel(processResource.getProcessError()));
-            processModel.setProcessStatus(getProcessStatus(processResource.getProcessStatus()));
-
-            processModel.setResourceSchedule(getProcessResourceSchedule(processResource.getProcessResourceSchedule()));
+            ErrorModel errorModel = getErrorModel(processResource.getProcessError());
+            if (errorModel != null){
+                processModel.setProcessError(errorModel);
+            }
+            ProcessStatus processStatus = getProcessStatus(processResource.getProcessStatus());
+            if (processStatus != null){
+                processModel.setProcessStatus(processStatus);
+            }
 
+            ComputationalResourceSchedulingModel schedule = getProcessResourceSchedule(processResource.getProcessResourceSchedule());
+            if (schedule != null){
+                processModel.setResourceSchedule(schedule);
+            }
             processModel.setTasks(getTaskModelList(processResource.getTaskList()));
-
             return processModel;
         }
         return null;
@@ -386,8 +393,14 @@ public class ThriftDataModelConversion {
         model.setTaskDetail(taskResource.getTaskDetail());
         model.setSubTaskModel(taskResource.getSubTaskModel());
 
-        model.setTaskStatus(getTaskStatus(taskResource.getTaskStatus()));
-        model.setTaskError(getErrorModel(taskResource.getTaskError()));
+        TaskStatus taskStatus = getTaskStatus(taskResource.getTaskStatus());
+        if (taskStatus != null){
+            model.setTaskStatus(taskStatus);
+        }
+        ErrorModel errorModel = getErrorModel(taskResource.getTaskError());
+        if (errorModel != null) {
+            model.setTaskError(errorModel);
+        }
 
         return model;
     }
@@ -402,7 +415,10 @@ public class ThriftDataModelConversion {
         model.setComputeResourceConsumed(jobResource.getComputeResourceConsumed());
         model.setJobName(jobResource.getJobName());
         model.setWorkingDir(jobResource.getWorkingDir());
-        model.setJobStatus(getJobStatus(jobResource.getJobStatus()));
+        JobStatus jobStatus = getJobStatus(jobResource.getJobStatus());
+        if (jobStatus != null){
+            model.setJobStatus(jobStatus);
+        }
         model.setExitCode(jobResource.getExitCode());
         model.setStdOut(jobResource.getStdOut());
         model.setStdErr(jobResource.getStdErr());


Mime
View raw message