airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1378721 - in /incubator/airavata/trunk/modules/commons/provenance-registry/src: main/java/org/apache/airavata/provenance/impl/jpa/AiravataJPAProvenanceRegistry.java test/java/org/apache/airavata/provenance/test/JpaTest.java
Date Wed, 29 Aug 2012 20:53:49 GMT
Author: lahiru
Date: Wed Aug 29 20:53:48 2012
New Revision: 1378721

URL: http://svn.apache.org/viewvc?rev=1378721&view=rev
Log:
Fixing some isssues in ProvenanceRegistryIMpl.

Modified:
    incubator/airavata/trunk/modules/commons/provenance-registry/src/main/java/org/apache/airavata/provenance/impl/jpa/AiravataJPAProvenanceRegistry.java
    incubator/airavata/trunk/modules/commons/provenance-registry/src/test/java/org/apache/airavata/provenance/test/JpaTest.java

Modified: incubator/airavata/trunk/modules/commons/provenance-registry/src/main/java/org/apache/airavata/provenance/impl/jpa/AiravataJPAProvenanceRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/provenance-registry/src/main/java/org/apache/airavata/provenance/impl/jpa/AiravataJPAProvenanceRegistry.java?rev=1378721&r1=1378720&r2=1378721&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/provenance-registry/src/main/java/org/apache/airavata/provenance/impl/jpa/AiravataJPAProvenanceRegistry.java
(original)
+++ incubator/airavata/trunk/modules/commons/provenance-registry/src/main/java/org/apache/airavata/provenance/impl/jpa/AiravataJPAProvenanceRegistry.java
Wed Aug 29 20:53:48 2012
@@ -224,7 +224,7 @@ public class AiravataJPAProvenanceRegist
 		nData.setWorkflow_Data(wData);
 		nData.setNode_id(arg0.getNodeId());
 		nData.setInputs(arg0.getValue());
-		nData.setNode_type((arg0.getNodeType().toString()));
+		nData.setNode_type((arg0.getNodeType().getNodeType().toString()));
 		nData.setStatus(arg0.getNodeStatus().getExecutionStatus().toString());
 		
 		em.persist(nData);
@@ -239,18 +239,23 @@ public class AiravataJPAProvenanceRegist
 	public boolean saveWorkflowExecutionServiceOutput(WorkflowServiceIOData arg0)
 			throws RegistryException {
 		// TODO Auto-generated method stub
-		
-		EntityManager em = factory.createEntityManager();
+
+        EntityManager em = factory.createEntityManager();
 		em.getTransaction().begin();
 		
 		Query q = em.createQuery("SELECT w FROM Workflow_Data w WHERE w.workflow_instanceID = :workflow_ID");
-		q.setParameter("workflow_ID", arg0);
+		q.setParameter("workflow_ID", arg0.getWorkflowInstanceId());
 		Workflow_Data wData = (Workflow_Data) q.getSingleResult();
-		
-		wData.setStatus(arg0.getNodeStatus().getExecutionStatus().toString());
-		
+
+		q = em.createQuery("SELECT p FROM Node_Data p WHERE p.workflow_Data = :workflow_data AND
p.node_id = :node_ID");
+		q.setParameter("workflow_data", wData);
+		q.setParameter("node_ID", arg0.getNodeId());
+		Node_Data nData = (Node_Data) q.getSingleResult();
+		nData.setOutputs(arg0.getValue());
+
 		em.getTransaction().commit();
 		em.close();
+
 		
 		return true;
 	}
@@ -266,9 +271,9 @@ public class AiravataJPAProvenanceRegist
 		Query q = em.createQuery("SELECT w FROM Workflow_Data w WHERE w.workflow_instanceID = :workflow_ID");
 		q.setParameter("workflow_ID", arg0);
 		Workflow_Data wData = (Workflow_Data) q.getSingleResult();
-		
+
 		wData.setStatus(arg1.toString());
-		
+		em.persist(wData);
 		em.getTransaction().commit();
 		em.close();
 		

Modified: incubator/airavata/trunk/modules/commons/provenance-registry/src/test/java/org/apache/airavata/provenance/test/JpaTest.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/provenance-registry/src/test/java/org/apache/airavata/provenance/test/JpaTest.java?rev=1378721&r1=1378720&r2=1378721&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/provenance-registry/src/test/java/org/apache/airavata/provenance/test/JpaTest.java
(original)
+++ incubator/airavata/trunk/modules/commons/provenance-registry/src/test/java/org/apache/airavata/provenance/test/JpaTest.java
Wed Aug 29 20:53:48 2012
@@ -35,129 +35,129 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class JpaTest {
-	private static final String PERSISTENCE_UNIT_NAME = "airavata_provenance";
-	private EntityManagerFactory factory;
-
-	@Before
-	public void setUp() throws Exception {
-		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
-		EntityManager em = factory.createEntityManager();
-
-		// Begin a new local transaction so that we can persist a new entity
-		em.getTransaction().begin();
-
-		// Read the existing entries
-		Query q = em.createQuery("select m from Experiment_Data m");
-		// Persons should be empty
-
-		// Do we have entries?
-		boolean createNewEntries = (q.getResultList().size() == 0);
-
-		// No, so lets create new entries
-		if (createNewEntries) {
-			assertTrue(q.getResultList().size() == 0);
-			Experiment_Data data = new Experiment_Data();
-			data.setExperiment_ID("Experiement_ID1");
-			data.setName("Name1");
-			em.persist(data);
-			for (int i = 0; i < 5; i++) {
-				Workflow_Data wData = new Workflow_Data();
-				wData.setWorkflow_instanceID("instance_ID" + i);
-				wData.setExperiment_Data(data);
-				em.persist(wData);
-				for (int j = 0; j < 5; j++) {
-					Node_Data nData = new Node_Data();
-					nData.setNode_id("node_ID" + j);
-					nData.setWorkflow_Data(wData);
-					em.persist(nData);
-					
-					Gram_Data gData = new Gram_Data();
-					gData.setNode_id("node_ID" + j);
-					gData.setWorkflow_Data(wData);
-					em.persist(gData);
-				}
-				// Now persists the family person relationship
-				// data.getWorkflows().add(wData);
-				// em.persist(wData);
-				// em.persist(data);
-			}
-		}
-
-		// Commit the transaction, which will cause the entity to
-		// be stored in the database
-		em.getTransaction().commit();
-
-		// It is always good practice to close the EntityManager so that
-		// resources are conserved.
-		em.close();
-
-	}
-
-	@Test
-	public void checkInsertedWorkflow() {
-
-		// Now lets check the database and see if the created entries are there
-		// Create a fresh, new EntityManager
-		EntityManager em = factory.createEntityManager();
-
-		// Perform a simple query for all the Message entities
-		Query q = em.createQuery("select m from Workflow_Data m");
-
-		// We should have 5 Persons in the database
-		assertTrue(q.getResultList().size() == 5);
-
-		em.close();
-	}
-
-	@Test
-	public void checkInsertedNode() {
-		EntityManager em = factory.createEntityManager();
-
-		Query q = em.createQuery("select m from Node_Data m");
-
-		assertTrue(q.getResultList().size() == 25);
-
-		em.close();
-	}
-
-	@Test (expected = javax.persistence.NoResultException.class)
-	public void deleteNode_Data() throws InterruptedException {
-		Thread.sleep(1000);
-		EntityManager em = factory.createEntityManager();
-		// Begin a new local transaction so that we can persist a new entity
-		em.getTransaction().begin();
-		Query q = em.createQuery("SELECT p FROM Experiment_Data p WHERE p.experiment_ID = :firstName");
-		q.setParameter("firstName", "Experiement_ID1");
-		Experiment_Data eData = (Experiment_Data) q.getSingleResult();
-		
-		q = em.createQuery("SELECT p FROM Workflow_Data p WHERE p.experiment_Data = :firstName
AND p.workflow_instanceID = :lastName");
-		q.setParameter("firstName", eData);
-		q.setParameter("lastName", "instance_ID4");
-		Workflow_Data wData = (Workflow_Data) q.getSingleResult();
-		
-		q = em.createQuery("SELECT p FROM Node_Data p WHERE p.workflow_Data = :firstName AND p.node_id
= :lastName");
-		q.setParameter("firstName", wData);
-		q.setParameter("lastName", "node_ID4");
-		Node_Data nData = (Node_Data) q.getSingleResult();
-
-		//System.out.println(nData.getStart_time());
-		em.remove(nData);
-		
-		q = em.createQuery("SELECT p FROM Node_Data p WHERE p.workflow_Data = :firstName AND p.node_id
= :lastName");
-		q.setParameter("firstName", wData);
-		q.setParameter("lastName", "node_ID3");
-		nData = (Node_Data) q.getSingleResult();
-		nData.setStatus("finished");
-		Thread.sleep(5000);
-		em.getTransaction().commit();
-
-		q = em.createQuery("SELECT p FROM Node_Data p WHERE p.workflow_Data = :firstName AND p.node_id
= :lastName");
-		q.setParameter("firstName", wData);
-		q.setParameter("lastName", "node_ID4");
-		Node_Data person = (Node_Data) q.getSingleResult();
-		person.getInputs();
-		// Begin a new local transaction so that we can persist a new entity
-
-		em.close();
-	}
+//	private static final String PERSISTENCE_UNIT_NAME = "airavata_provenance";
+//	private EntityManagerFactory factory;
+//
+//	@Before
+//	public void setUp() throws Exception {
+//		factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
+//		EntityManager em = factory.createEntityManager();
+//
+//		// Begin a new local transaction so that we can persist a new entity
+//		em.getTransaction().begin();
+//
+//		// Read the existing entries
+//		Query q = em.createQuery("select m from Experiment_Data m");
+//		// Persons should be empty
+//
+//		// Do we have entries?
+//		boolean createNewEntries = (q.getResultList().size() == 0);
+//
+//		// No, so lets create new entries
+//		if (createNewEntries) {
+//			assertTrue(q.getResultList().size() == 0);
+//			Experiment_Data data = new Experiment_Data();
+//			data.setExperiment_ID("Experiement_ID1");
+//			data.setName("Name1");
+//			em.persist(data);
+//			for (int i = 0; i < 5; i++) {
+//				Workflow_Data wData = new Workflow_Data();
+//				wData.setWorkflow_instanceID("instance_ID" + i);
+//				wData.setExperiment_Data(data);
+//				em.persist(wData);
+//				for (int j = 0; j < 5; j++) {
+//					Node_Data nData = new Node_Data();
+//					nData.setNode_id("node_ID" + j);
+//					nData.setWorkflow_Data(wData);
+//					em.persist(nData);
+//
+//					Gram_Data gData = new Gram_Data();
+//					gData.setNode_id("node_ID" + j);
+//					gData.setWorkflow_Data(wData);
+//					em.persist(gData);
+//				}
+//				// Now persists the family person relationship
+//				// data.getWorkflows().add(wData);
+//				// em.persist(wData);
+//				// em.persist(data);
+//			}
+//		}
+//
+//		// Commit the transaction, which will cause the entity to
+//		// be stored in the database
+//		em.getTransaction().commit();
+//
+//		// It is always good practice to close the EntityManager so that
+//		// resources are conserved.
+//		em.close();
+//
+//	}
+//
+//	@Test
+//	public void checkInsertedWorkflow() {
+//
+//		// Now lets check the database and see if the created entries are there
+//		// Create a fresh, new EntityManager
+//		EntityManager em = factory.createEntityManager();
+//
+//		// Perform a simple query for all the Message entities
+//		Query q = em.createQuery("select m from Workflow_Data m");
+//
+//		// We should have 5 Persons in the database
+//		assertTrue(q.getResultList().size() == 5);
+//
+//		em.close();
+//	}
+//
+//	@Test
+//	public void checkInsertedNode() {
+//		EntityManager em = factory.createEntityManager();
+//
+//		Query q = em.createQuery("select m from Node_Data m");
+//
+//		assertTrue(q.getResultList().size() == 25);
+//
+//		em.close();
+//	}
+//
+//	@Test (expected = javax.persistence.NoResultException.class)
+//	public void deleteNode_Data() throws InterruptedException {
+//		Thread.sleep(1000);
+//		EntityManager em = factory.createEntityManager();
+//		// Begin a new local transaction so that we can persist a new entity
+//		em.getTransaction().begin();
+//		Query q = em.createQuery("SELECT p FROM Experiment_Data p WHERE p.experiment_ID = :firstName");
+//		q.setParameter("firstName", "Experiement_ID1");
+//		Experiment_Data eData = (Experiment_Data) q.getSingleResult();
+//
+//		q = em.createQuery("SELECT p FROM Workflow_Data p WHERE p.experiment_Data = :firstName
AND p.workflow_instanceID = :lastName");
+//		q.setParameter("firstName", eData);
+//		q.setParameter("lastName", "instance_ID4");
+//		Workflow_Data wData = (Workflow_Data) q.getSingleResult();
+//
+//		q = em.createQuery("SELECT p FROM Node_Data p WHERE p.workflow_Data = :firstName AND
p.node_id = :lastName");
+//		q.setParameter("firstName", wData);
+//		q.setParameter("lastName", "node_ID4");
+//		Node_Data nData = (Node_Data) q.getSingleResult();
+//
+//		//System.out.println(nData.getStart_time());
+//		em.remove(nData);
+//
+//		q = em.createQuery("SELECT p FROM Node_Data p WHERE p.workflow_Data = :firstName AND
p.node_id = :lastName");
+//		q.setParameter("firstName", wData);
+//		q.setParameter("lastName", "node_ID3");
+//		nData = (Node_Data) q.getSingleResult();
+//		nData.setStatus("finished");
+//		Thread.sleep(5000);
+//		em.getTransaction().commit();
+//
+//		q = em.createQuery("SELECT p FROM Node_Data p WHERE p.workflow_Data = :firstName AND
p.node_id = :lastName");
+//		q.setParameter("firstName", wData);
+//		q.setParameter("lastName", "node_ID4");
+//		Node_Data person = (Node_Data) q.getSingleResult();
+//		person.getInputs();
+//		// Begin a new local transaction so that we can persist a new entity
+//
+//		em.close();
+//	}
 }



Mime
View raw message