[jboss-svn-commits] JBL Code SVN: r24953 - labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jan 27 13:10:20 EST 2009


Author: salaboy21
Date: 2009-01-27 13:10:20 -0500 (Tue, 27 Jan 2009)
New Revision: 24953

Added:
   labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAPersistedVariable.java
   labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAVariablePersister.java
   labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariableInstanceInfo.java
   labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariablePersister.java
Log:
Introducing VariableInstanceInfo concept with the parser and the specific JPAVariablePersister

Copied: labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAPersistedVariable.java (from rev 24910, labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/EJB3PersistedVariable.java)
===================================================================
--- labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAPersistedVariable.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAPersistedVariable.java	2009-01-27 18:10:20 UTC (rev 24953)
@@ -0,0 +1,79 @@
+/*
+ *  Copyright 2009 salaboy.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+
+package org.drools.persistence.processinstance;
+
+import javax.persistence.Entity;
+import javax.persistence.Transient;
+
+
+
+/**
+ *
+ * @author salaboy
+ */
+
+ at Entity
+public class JPAPersistedVariable extends VariableInstanceInfo {
+     @Transient
+     private Object realVariable;
+     private String vartype;
+     private Long varid;
+
+      /**
+     * @return the vartype
+     */
+    public String getVartype() {
+        return vartype;
+    }
+
+    /**
+     * @param vartype the vartype to set
+     */
+    public void setVartype(String vartype) {
+        this.vartype = vartype;
+    }
+
+    /**
+     * @return the varid
+     */
+    public Long getVarid() {
+        return varid;
+    }
+
+    /**
+     * @param varid the varid to set
+     */
+    public void setVarid(Long varid) {
+        this.varid = varid;
+    }
+
+    /**
+     * @return the realVariable
+     */
+    public Object getRealVariable() {
+        return realVariable;
+    }
+
+    /**
+     * @param realVariable the realVariable to set
+     */
+    public void setRealVariable(Object realVariable) {
+        this.realVariable = realVariable;
+    }
+
+}


Property changes on: labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAPersistedVariable.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAVariablePersister.java (from rev 24910, labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/EJB3VariableConverter.java)
===================================================================
--- labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAVariablePersister.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAVariablePersister.java	2009-01-27 18:10:20 UTC (rev 24953)
@@ -0,0 +1,79 @@
+/*
+ *  Copyright 2009 salaboy.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+
+package org.drools.persistence.processinstance;
+
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import org.drools.util.StringUtils;
+
+/**
+ *
+ * @author salaboy
+ */
+public class JPAVariablePersister implements VariablePersister {
+    private EntityManagerFactory emf;
+    private EntityManager em;
+
+    public JPAVariablePersister(){
+        emf = Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
+        em = emf.createEntityManager();
+
+    }
+
+    public VariableInstanceInfo persistExternalVariable(String name, Object o) {
+        VariableInstanceInfo variable = new JPAPersistedVariable();
+        variable.setName(name);
+        ((JPAPersistedVariable)variable).setRealVariable(o);
+
+
+     
+        
+        return variable;
+    }
+
+  
+
+    public VariableInstanceInfo getExternalPersistedVariable(String name, Long processInstanceId) {
+        try {
+
+            VariableInstanceInfo variableInfo = (VariableInstanceInfo)  em.createNamedQuery("getVariablesByName")
+                    .setParameter("name", name)
+                    .setParameter("processInstanceId", processInstanceId).getSingleResult();
+            
+            String varType = ((JPAPersistedVariable) variableInfo).getVartype();
+            return (VariableInstanceInfo) em.find(Class.forName(varType), variableInfo.getId());
+        } catch (ClassNotFoundException ex) {
+            Logger.getLogger(JPAVariablePersister.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return null;
+    }
+
+    public List<VariableInstanceInfo> getExternalPersistedVariables(Long processInstanceId) {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+}


Property changes on: labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/JPAVariablePersister.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariableInstanceInfo.java (from rev 24910, labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/PersistedVariable.java)
===================================================================
--- labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariableInstanceInfo.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariableInstanceInfo.java	2009-01-27 18:10:20 UTC (rev 24953)
@@ -0,0 +1,80 @@
+/*
+ *  Copyright 2009 salaboy.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+
+package org.drools.persistence.processinstance;
+
+import java.io.Serializable;
+
+
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorType;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+
+
+
+/**
+ *
+ * @author salaboy
+ */
+ at Entity
+ at Inheritance(strategy=InheritanceType.SINGLE_TABLE)
+ at DiscriminatorColumn(name="TYPE", discriminatorType=DiscriminatorType.STRING,length=50)
+ at DiscriminatorValue("GEN")
+public class VariableInstanceInfo implements Serializable {
+    @Id @GeneratedValue(strategy=GenerationType.AUTO)
+    private Long id;
+    private String name;
+   
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+   
+  
+
+   
+
+  
+
+  
+}


Property changes on: labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariableInstanceInfo.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariablePersister.java (from rev 24910, labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariableConverter.java)
===================================================================
--- labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariablePersister.java	                        (rev 0)
+++ labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariablePersister.java	2009-01-27 18:10:20 UTC (rev 24953)
@@ -0,0 +1,36 @@
+/*
+ *  Copyright 2009 salaboy.
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+
+package org.drools.persistence.processinstance;
+
+import java.util.List;
+
+/**
+ *
+ * @author salaboy
+ */
+
+public interface VariablePersister {
+    public VariableInstanceInfo persistExternalVariable(String name, Object o);
+
+    public VariableInstanceInfo getExternalPersistedVariable(String name, Long processInstanceId);
+
+    public List<VariableInstanceInfo> getExternalPersistedVariables(Long processInstanceId);
+
+    
+
+}


Property changes on: labs/jbossrules/branches/salaboy_VariablePersistenceStrategy/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/processinstance/VariablePersister.java
___________________________________________________________________
Name: svn:mergeinfo
   + 




More information about the jboss-svn-commits mailing list