[jboss-svn-commits] JBL Code SVN: r30068 - labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Nov 6 20:22:28 EST 2009


Author: KrisVerlaenen
Date: 2009-11-06 20:22:27 -0500 (Fri, 06 Nov 2009)
New Revision: 30068

Modified:
   labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/ItemDefinitionHandler.java
   labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/PropertyHandler.java
   labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/XmlBPMNProcessDumper.java
Log:
 - supporting classname in combination with object type for variables

Modified: labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/ItemDefinitionHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/ItemDefinitionHandler.java	2009-11-07 01:16:03 UTC (rev 30067)
+++ labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/ItemDefinitionHandler.java	2009-11-07 01:22:27 UTC (rev 30068)
@@ -38,15 +38,15 @@
 		String type = attrs.getValue("structureRef");
 
 		ProcessBuildData buildData = (ProcessBuildData) parser.getData();
-		Map<String, ItemDefinition> itemDefintions = (Map<String, ItemDefinition>)
-            ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
-        if (itemDefintions == null) {
-            itemDefintions = new HashMap<String, ItemDefinition>();
-            buildData.setMetaData("ItemDefinitions", itemDefintions);
+		Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>)
+            buildData.getMetaData("ItemDefinitions");
+        if (itemDefinitions == null) {
+            itemDefinitions = new HashMap<String, ItemDefinition>();
+            buildData.setMetaData("ItemDefinitions", itemDefinitions);
         }
         ItemDefinition itemDefinition = new ItemDefinition(id); 
         itemDefinition.setStructureRef(type);
-        itemDefintions.put(id, itemDefinition);
+        itemDefinitions.put(id, itemDefinition);
 		return itemDefinition;
 	}
 

Modified: labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/PropertyHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/PropertyHandler.java	2009-11-07 01:16:03 UTC (rev 30067)
+++ labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/PropertyHandler.java	2009-11-07 01:22:27 UTC (rev 30068)
@@ -1,10 +1,14 @@
 package org.drools.bpmn2.xml;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 
+import org.drools.bpmn2.core.ItemDefinition;
 import org.drools.bpmn2.core.SequenceFlow;
 import org.drools.process.core.context.variable.Variable;
+import org.drools.process.core.datatype.DataType;
 import org.drools.process.core.datatype.impl.type.ObjectDataType;
 import org.drools.ruleflow.core.RuleFlowProcess;
 import org.drools.workflow.core.Node;
@@ -12,6 +16,7 @@
 import org.drools.xml.BaseAbstractHandler;
 import org.drools.xml.ExtensibleXmlParser;
 import org.drools.xml.Handler;
+import org.drools.xml.ProcessBuildData;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
@@ -44,7 +49,7 @@
 		parser.startElementBuilder(localName, attrs);
 
 		final String id = attrs.getValue("id");
-//		final String itemSubjectRef = attrs.getValue("itemSubjectRef");
+		final String itemSubjectRef = attrs.getValue("itemSubjectRef");
 
 		Object parent = parser.getParent();
 		if (parent instanceof RuleFlowProcess) {
@@ -52,8 +57,17 @@
 			List variables = process.getVariableScope().getVariables();
 			Variable variable = new Variable();
 			variable.setName(id);
-			// TODO add object type
-			variable.setType(new ObjectDataType());
+			// retrieve type from item definition
+			DataType dataType = new ObjectDataType();
+			Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>)
+	            ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
+	        if (itemDefinitions != null) {
+	        	ItemDefinition itemDefinition = itemDefinitions.get(itemSubjectRef);
+	        	if (itemDefinition != null) {
+	        		dataType = new ObjectDataType(itemDefinition.getStructureRef());
+	        	}
+	        }
+			variable.setType(dataType);
 			variables.add(variable);
 			return variable;
 		}

Modified: labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/XmlBPMNProcessDumper.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/XmlBPMNProcessDumper.java	2009-11-07 01:16:03 UTC (rev 30067)
+++ labs/jbossrules/trunk/drools-process/drools-bpmn2/src/main/java/org/drools/bpmn2/xml/XmlBPMNProcessDumper.java	2009-11-07 01:22:27 UTC (rev 30068)
@@ -154,7 +154,7 @@
         for (Variable variable: variables) {
             xmlDump.append("    <property id=\"" + variable.getName() + "\" ");
             if (variable.getType() != null) {
-            	xmlDump.append("itemSubjectRef=\"tns:" + variable.getName() + "Item\"" );
+            	xmlDump.append("itemSubjectRef=\"" + variable.getName() + "Item\"" );
             }
             // TODO: value
             xmlDump.append("/>" + EOL);
@@ -280,7 +280,7 @@
                     xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</conditionExpression>");
         		}
         		xmlDump.append(EOL
-    		        + "   </sequenceFlow>" + EOL);
+    		        + "    </sequenceFlow>" + EOL);
         	} else {
             	xmlDump.append("/>" + EOL);
             }



More information about the jboss-svn-commits mailing list