[jboss-svn-commits] JBL Code SVN: r26800 - in labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src: main/java/org/drools/persistence/processinstance/variabletypes and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jun 1 14:09:14 EDT 2009
Author: salaboy21
Date: 2009-06-01 14:09:14 -0400 (Mon, 01 Jun 2009)
New Revision: 26800
Modified:
labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/ProcessInstanceInfo.java
labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/JPAPersistedVariable.java
labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/SerializablePersistedVariable.java
labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/VariableInstanceInfo.java
labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/test/java/org/drools/persistence/session/SingleSessionCommandServiceTest.java
Log:
add equals and hashcode methods / pre persist in process instance info.. not sure
Modified: labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/ProcessInstanceInfo.java
===================================================================
--- labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/ProcessInstanceInfo.java 2009-06-01 18:02:00 UTC (rev 26799)
+++ labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/ProcessInstanceInfo.java 2009-06-01 18:09:14 UTC (rev 26800)
@@ -28,6 +28,7 @@
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Transient;
import javax.persistence.Version;
@@ -185,6 +186,7 @@
}
@PreUpdate
+ @PrePersist
public void update() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
@@ -281,4 +283,75 @@
public void setSerializeVariables(boolean serializeVariables) {
this.serializeVariables = serializeVariables;
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ProcessInstanceInfo other = (ProcessInstanceInfo) obj;
+ if (this.processInstanceId != other.processInstanceId && (this.processInstanceId == null || !this.processInstanceId.equals(other.processInstanceId))) {
+ return false;
+ }
+ if (this.version != other.version) {
+ return false;
+ }
+ if ((this.processId == null) ? (other.processId != null) : !this.processId.equals(other.processId)) {
+ return false;
+ }
+ if (this.startDate != other.startDate && (this.startDate == null || !this.startDate.equals(other.startDate))) {
+ return false;
+ }
+ if (this.lastReadDate != other.lastReadDate && (this.lastReadDate == null || !this.lastReadDate.equals(other.lastReadDate))) {
+ return false;
+ }
+ if (this.lastModificationDate != other.lastModificationDate && (this.lastModificationDate == null || !this.lastModificationDate.equals(other.lastModificationDate))) {
+ return false;
+ }
+ if (this.state != other.state) {
+ return false;
+ }
+ if (!Arrays.equals(this.processInstanceByteArray, other.processInstanceByteArray)) {
+ return false;
+ }
+ if (this.eventTypes != other.eventTypes && (this.eventTypes == null || !this.eventTypes.equals(other.eventTypes))) {
+ return false;
+ }
+ if (this.processInstance != other.processInstance && (this.processInstance == null || !this.processInstance.equals(other.processInstance))) {
+ return false;
+ }
+ if (this.env != other.env && (this.env == null || !this.env.equals(other.env))) {
+ return false;
+ }
+ if (this.serializeVariables != other.serializeVariables) {
+ return false;
+ }
+ if (this.variables != other.variables && (this.variables == null || !this.variables.equals(other.variables))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 61 * hash + (this.processInstanceId != null ? this.processInstanceId.hashCode() : 0);
+ hash = 61 * hash + this.version;
+ hash = 61 * hash + (this.processId != null ? this.processId.hashCode() : 0);
+ hash = 61 * hash + (this.startDate != null ? this.startDate.hashCode() : 0);
+ hash = 61 * hash + (this.lastReadDate != null ? this.lastReadDate.hashCode() : 0);
+ hash = 61 * hash + (this.lastModificationDate != null ? this.lastModificationDate.hashCode() : 0);
+ hash = 61 * hash + this.state;
+ hash = 61 * hash + Arrays.hashCode(this.processInstanceByteArray);
+ hash = 61 * hash + (this.eventTypes != null ? this.eventTypes.hashCode() : 0);
+ hash = 61 * hash + (this.processInstance != null ? this.processInstance.hashCode() : 0);
+ hash = 61 * hash + (this.env != null ? this.env.hashCode() : 0);
+ hash = 61 * hash + (this.serializeVariables ? 1 : 0);
+ hash = 61 * hash + (this.variables != null ? this.variables.hashCode() : 0);
+ return hash;
+ }
+
}
Modified: labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/JPAPersistedVariable.java
===================================================================
--- labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/JPAPersistedVariable.java 2009-06-01 18:02:00 UTC (rev 26799)
+++ labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/JPAPersistedVariable.java 2009-06-01 18:09:14 UTC (rev 26800)
@@ -80,4 +80,35 @@
this.realVariable = realVariable;
}
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final JPAPersistedVariable other = (JPAPersistedVariable) obj;
+ if (this.realVariable != other.realVariable && (this.realVariable == null || !this.realVariable.equals(other.realVariable))) {
+ return false;
+ }
+ if ((this.vartype == null) ? (other.vartype != null) : !this.vartype.equals(other.vartype)) {
+ return false;
+ }
+ if (this.varid != other.varid && (this.varid == null || !this.varid.equals(other.varid))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 17 * hash + (this.realVariable != null ? this.realVariable.hashCode() : 0);
+ hash = 17 * hash + (this.vartype != null ? this.vartype.hashCode() : 0);
+ hash = 17 * hash + (this.varid != null ? this.varid.hashCode() : 0);
+ return hash;
+ }
+
+
}
Modified: labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/SerializablePersistedVariable.java
===================================================================
--- labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/SerializablePersistedVariable.java 2009-06-01 18:02:00 UTC (rev 26799)
+++ labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/SerializablePersistedVariable.java 2009-06-01 18:09:14 UTC (rev 26800)
@@ -17,6 +17,7 @@
package org.drools.persistence.processinstance.variabletypes;
+import java.util.Arrays;
import javax.persistence.Entity;
import javax.persistence.Lob;
@@ -47,4 +48,27 @@
this.content = content;
}
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final SerializablePersistedVariable other = (SerializablePersistedVariable) obj;
+ if (!Arrays.equals(this.content, other.content)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 59 * hash + Arrays.hashCode(this.content);
+ return hash;
+ }
+
+
}
Modified: labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/VariableInstanceInfo.java
===================================================================
--- labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/VariableInstanceInfo.java 2009-06-01 18:02:00 UTC (rev 26799)
+++ labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/main/java/org/drools/persistence/processinstance/variabletypes/VariableInstanceInfo.java 2009-06-01 18:09:14 UTC (rev 26800)
@@ -102,4 +102,39 @@
public void setProcessInstanceInfo(ProcessInstanceInfo processInstanceInfo) {
this.processInstanceInfo = processInstanceInfo;
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final VariableInstanceInfo other = (VariableInstanceInfo) obj;
+ if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
+ return false;
+ }
+ if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
+ return false;
+ }
+ if (this.processInstanceInfo != other.processInstanceInfo && (this.processInstanceInfo == null || !this.processInstanceInfo.equals(other.processInstanceInfo))) {
+ return false;
+ }
+ if ((this.persister == null) ? (other.persister != null) : !this.persister.equals(other.persister)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
+ hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
+ hash = 97 * hash + (this.processInstanceInfo != null ? this.processInstanceInfo.hashCode() : 0);
+ hash = 97 * hash + (this.persister != null ? this.persister.hashCode() : 0);
+ return hash;
+ }
+
}
Modified: labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/test/java/org/drools/persistence/session/SingleSessionCommandServiceTest.java
===================================================================
--- labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/test/java/org/drools/persistence/session/SingleSessionCommandServiceTest.java 2009-06-01 18:02:00 UTC (rev 26799)
+++ labs/jbossrules/branches/salaboy_RelationalVariablePersistence/drools-persistence-jpa/src/test/java/org/drools/persistence/session/SingleSessionCommandServiceTest.java 2009-06-01 18:09:14 UTC (rev 26800)
@@ -64,26 +64,26 @@
protected void setUp() {
ds1 = new PoolingDataSource();
ds1.setUniqueName( "jdbc/testDS1" );
- ds1.setClassName( "org.h2.jdbcx.JdbcDataSource" );
+// ds1.setClassName( "org.h2.jdbcx.JdbcDataSource" );
+// ds1.setMaxPoolSize( 3 );
+// ds1.setAllowLocalTransactions( true );
+// ds1.getDriverProperties().put( "user",
+// "sa" );
+// ds1.getDriverProperties().put( "password",
+// "sasa" );
+// ds1.getDriverProperties().put( "URL",
+// "jdbc:h2:mem:mydb" );
+
+ ds1.setClassName( "org.postgresql.xa.PGXADataSource" );
ds1.setMaxPoolSize( 3 );
ds1.setAllowLocalTransactions( true );
ds1.getDriverProperties().put( "user",
- "sa" );
+ "salaboy" );
ds1.getDriverProperties().put( "password",
- "sasa" );
- ds1.getDriverProperties().put( "URL",
- "jdbc:h2:mem:mydb" );
+ "salaboy" );
+ ds1.getDriverProperties().put( "serverName",
+ "localhost:5432/droolsPersistence" );
-// ds1.setClassName( "org.postgresql.xa.PGXADataSource" );
-// ds1.setMaxPoolSize( 3 );
-// ds1.setAllowLocalTransactions( true );
-// ds1.getDriverProperties().put( "user",
-// "salaboy" );
-// ds1.getDriverProperties().put( "password",
-// "salaboy" );
-// ds1.getDriverProperties().put( "serverName",
-// "localhost:5432/droolsPersistence" );
-
ds1.init();
emf = Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" );
@@ -832,7 +832,31 @@
assertNotNull(var2);
assertEquals("This is a test SerializableObject", var2.getText());
+ assertEquals("WorkItem1",((RuleFlowProcessInstance)processInstance).getNodeInstances().iterator().next().getNodeName());
+ TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
+ WorkItem workItem = handler.getWorkItem();
+ assertNotNull( workItem );
+ CompleteWorkItemCommand completeWorkItemCommand = new CompleteWorkItemCommand();
+ completeWorkItemCommand.setWorkItemId( workItem.getId() );
+ service.execute( completeWorkItemCommand );
+ service = new SingleSessionCommandService(kbase, config,env);
+ getProcessInstanceCommand = new GetProcessInstanceCommand();
+ getProcessInstanceCommand.setProcessInstanceId(processInstance.getId());
+ processInstance = (ProcessInstance) service.execute(getProcessInstanceCommand);
+ assertNotNull(processInstance);
+
+ assertEquals("WorkItem2",((RuleFlowProcessInstance)processInstance).getNodeInstances().iterator().next().getNodeName());
+
+ variableScopeInstance = (VariableScopeInstance)
+ ((RuleFlowProcessInstance)processInstance).getContextInstance(VariableScope.VARIABLE_SCOPE);
+ variableScopeInstance.setVariable("var1", new MyEntity("This is a test Entity MODIFIED"));
+ variableScopeInstance.setVariable("var2", new MyVariableSerializable("This is a test SerializableObject"));
+
+
+ service = new SingleSessionCommandService(kbase, config,env);
+
+
}
}
More information about the jboss-svn-commits
mailing list