Author: spagop
Date: 2008-11-22 14:45:51 -0500 (Sat, 22 Nov 2008)
New Revision: 644
Added:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3AssignmentMetadata.java
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3MetadataConstants.java
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3SwimlaneMetadata.java
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3TaskMetadata.java
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3TaskNodeMetadata.java
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/gpd.xml
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/processimage.jpg
Modified:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3Metadata.java
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/java/org/jboss/dna/sequencer/jpdl3/JPDL3MetadataTest.java
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/processdefinition.xml
Log:
support for swimlane and tasknode parsing
Added:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3AssignmentMetadata.java
===================================================================
---
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3AssignmentMetadata.java
(rev 0)
+++
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3AssignmentMetadata.java 2008-11-22
19:45:51 UTC (rev 644)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.jpdl3;
+
+/**
+ * @author Serge Pagop
+ */
+public class JPDL3AssignmentMetadata {
+
+ /**
+ * The full qualified class name.
+ */
+ private String fqClassName = "";
+
+ /**
+ * The expression.
+ */
+ private String expression = "";
+
+ /**
+ * The config type.
+ */
+ private String configType = "";
+
+ /**
+ * Get the full qualified name of the class delegation.
+ *
+ * @return the fqClassName.
+ */
+ public String getFqClassName() {
+ return this.fqClassName;
+ }
+
+ /**
+ * Set the full qualified name of the class delegation.
+ *
+ * @param fqClassName Sets fqClassName to the specified value.
+ */
+ public void setFqClassName( String fqClassName ) {
+ this.fqClassName = fqClassName;
+ }
+
+ /**
+ * Get the assignment expression for the jpdl identity component.
+ *
+ * @return the expression.
+ */
+ public String getExpression() {
+ return this.expression;
+ }
+
+ /**
+ * Set the expression.
+ *
+ * @param expression Sets expression to the specified value.
+ */
+ public void setExpression( String expression ) {
+ this.expression = expression;
+ }
+
+ /**
+ * Get the configType.
+ *
+ * @return configType
+ */
+ public String getConfigType() {
+ return this.configType;
+ }
+
+ /**
+ * @param configType Sets configType to the specified value.
+ */
+ public void setConfigType( String configType ) {
+ this.configType = configType;
+ }
+
+}
Modified:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3Metadata.java
===================================================================
---
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3Metadata.java 2008-11-20
19:15:17 UTC (rev 643)
+++
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3Metadata.java 2008-11-22
19:45:51 UTC (rev 644)
@@ -24,11 +24,19 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.def.Transition;
import org.jbpm.graph.node.EndState;
import org.jbpm.graph.node.StartState;
+import org.jbpm.graph.node.TaskNode;
+import org.jbpm.instantiation.Delegation;
+import org.jbpm.taskmgmt.def.Swimlane;
+import org.jbpm.taskmgmt.def.Task;
+import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
+import static org.jboss.dna.sequencer.jpdl3.JPDL3MetadataConstants.*;
/**
* The jBPM Process definition language meta data.
@@ -36,11 +44,32 @@
* @author Serge Pagop
*/
public class JPDL3Metadata {
+
+ /**
+ * The process definition name.
+ */
private String pdName;
+
+ /**
+ * The start node of the process definition.
+ */
private JPDL3StartStateMetadata jPDL3StartStateMetadata;
+
+ /**
+ * The end node of the process definition.
+ */
private JPDL3EndStateMetadata jPDL3EndStateMetadata;
-
+ /**
+ * The swimlanes of the process definitions
+ */
+ List<JPDL3SwimlaneMetadata> swimlanes = new
ArrayList<JPDL3SwimlaneMetadata>();
+
+ /**
+ * The task nodes of the process definitions.
+ */
+ private List<JPDL3TaskNodeMetadata> taskNodes = new
ArrayList<JPDL3TaskNodeMetadata>();
+
private JPDL3Metadata() {
// prevent construction
}
@@ -54,12 +83,45 @@
@SuppressWarnings( {"unchecked", "cast"} )
public static JPDL3Metadata instance( InputStream stream ) {
ProcessDefinition processDefinition =
ProcessDefinition.parseXmlInputStream(stream);
+ List<JPDL3SwimlaneMetadata> swimlaneContainer = new
ArrayList<JPDL3SwimlaneMetadata>();
+ List<JPDL3TaskNodeMetadata> taskNodeContainer = new
ArrayList<JPDL3TaskNodeMetadata>();
+
if (processDefinition != null) {
JPDL3Metadata jplMetadata = new JPDL3Metadata();
if (processDefinition.getName() != null) {
jplMetadata.setPdName(processDefinition.getName());
}
+
+ TaskMgmtDefinition taskMgmtDefinition =
processDefinition.getTaskMgmtDefinition();
+ if (taskMgmtDefinition != null) {
+ // Get the swimlanes of the process definition, if there is one.
+ Map<String, Swimlane> mapOfSwimlanes =
taskMgmtDefinition.getSwimlanes();
+ Set<String> swimlaneKeys = mapOfSwimlanes.keySet();
+ for (String swimlaneKey : swimlaneKeys) {
+ Swimlane swimlane = mapOfSwimlanes.get(swimlaneKey);
+ JPDL3SwimlaneMetadata jPDL3SwimlaneMetadata = new
JPDL3SwimlaneMetadata();
+ jPDL3SwimlaneMetadata.setName(swimlane.getName());
+ if (swimlane.getActorIdExpression() != null)
jPDL3SwimlaneMetadata.setActorIdExpression(swimlane.getActorIdExpression());
+ if (swimlane.getPooledActorsExpression() != null)
jPDL3SwimlaneMetadata.setPooledActorsExpression(swimlane.getPooledActorsExpression());
+ Delegation delegation = swimlane.getAssignmentDelegation();
+ if (delegation != null) {
+ JPDL3AssignmentMetadata jPDL3AssignmentMetadata = new
JPDL3AssignmentMetadata();
+ // full qualified class name.
+
jPDL3AssignmentMetadata.setFqClassName(delegation.getClassName());
+ // config type
+ if (delegation.getConfigType() != null)
jPDL3AssignmentMetadata.setConfigType(delegation.getConfigType());
+ // expression assignment
+ if
(EXPRESSION_ASSIGNMENT_HANLDER_DELEGATION_CN.equals(delegation.getClassName()))
jPDL3AssignmentMetadata.setExpression(delegation.getConfiguration());
+ jPDL3SwimlaneMetadata.setAssignment(jPDL3AssignmentMetadata);
+ }
+ swimlaneContainer.add(jPDL3SwimlaneMetadata);
+ // with expression
+ }
+ }
+ jplMetadata.setSwimlanes(swimlaneContainer);
+
List<Node> nodes = (List<Node>)processDefinition.getNodes();
+
for (Node node : nodes) {
if (node instanceof StartState) {
StartState startState = (StartState)node;
@@ -91,6 +153,56 @@
}
jplMetadata.setEndStateMetadata(jPDL3EndStateMetadata);
}
+
+ // TaskNode
+ if (node instanceof TaskNode) {
+ TaskNode taskNode = (TaskNode)node;
+ JPDL3TaskNodeMetadata jPDL3TaskNodeMetadata = new
JPDL3TaskNodeMetadata();
+
+ if(taskNode.getName() != null) {
+ jPDL3TaskNodeMetadata.setName(taskNode.getName());
+ }
+
+ Map<String, Task> tasks = taskNode.getTasksMap();
+ List<JPDL3TaskMetadata> taskList = new
ArrayList<JPDL3TaskMetadata>();
+
+ if(!tasks.isEmpty()) {
+ Set<String> keys = tasks.keySet();
+ for (String key : keys) {
+ Task task = tasks.get(key);
+ JPDL3TaskMetadata jPDL3TaskMetadata = new
JPDL3TaskMetadata();
+ if(task.getName() != null)
+ jPDL3TaskMetadata.setName(task.getName());
+ if(task.getDueDate() != null)
+ jPDL3TaskMetadata.setDueDate(task.getDueDate());
+ taskList.add(jPDL3TaskMetadata);
+
+ if(task.getSwimlane() != null) {
+ Swimlane swimlane = task.getSwimlane();
+ jPDL3TaskMetadata.setSwimlane(swimlane.getName());
+ }
+ }
+ }
+ jPDL3TaskNodeMetadata.setTasks(taskList);
+
+ // transitions
+ List<JPDL3TransitionMetadata> transitions = new
ArrayList<JPDL3TransitionMetadata>();
+ for (Transition transition :
(List<Transition>)taskNode.getLeavingTransitions()) {
+ JPDL3TransitionMetadata jPDL3TransitionMetadata = new
JPDL3TransitionMetadata();
+ if (transition.getName() != null) {
+ jPDL3TransitionMetadata.setName(transition.getName());
+ }
+ Node toNode = transition.getTo();
+ if (toNode != null) {
+ jPDL3TransitionMetadata.setTo(toNode.getName());
+ }
+ transitions.add(jPDL3TransitionMetadata);
+ }
+ jPDL3TaskNodeMetadata.setTransitions(transitions);
+
+ taskNodeContainer.add(jPDL3TaskNodeMetadata);
+ jplMetadata.setTaskNodes(taskNodeContainer);
+ }
}
return jplMetadata;
}
@@ -119,18 +231,16 @@
* @return the jPDL3StartStateMetadata.
*/
public JPDL3StartStateMetadata getStartStateMetadata() {
- return jPDL3StartStateMetadata;
+ return this.jPDL3StartStateMetadata;
}
-
+
/**
- *
* @return the jPDL3EndStateMetadata.
*/
public JPDL3EndStateMetadata getEndStateMetadata() {
- return jPDL3EndStateMetadata;
+ return this.jPDL3EndStateMetadata;
}
-
-
+
/**
* @param jPDL3StartStateMetadata the jPDL3StartStateMetadata to set
*/
@@ -144,4 +254,36 @@
public void setEndStateMetadata( JPDL3EndStateMetadata jPDL3EndStateMetadata ) {
this.jPDL3EndStateMetadata = jPDL3EndStateMetadata;
}
+
+ /**
+ * Get a list of all swimlane of the process definition
+ *
+ * @return a list of all swimlane of the process definition. this can also be a empty
list.
+ */
+ public List<JPDL3SwimlaneMetadata> getSwimlanes() {
+ return this.swimlanes;
+ }
+
+ /**
+ * Set a list with some swimlanes for the process definition.
+ *
+ * @param swimlanes - the swimlanes.
+ */
+ public void setSwimlanes( List<JPDL3SwimlaneMetadata> swimlanes ) {
+ this.swimlanes = swimlanes;
+ }
+
+ /**
+ * @return the task nodes
+ */
+ public List<JPDL3TaskNodeMetadata> getTaskNodes() {
+ return this.taskNodes;
+ }
+
+ /**
+ * @param taskNodes Sets taskNodes to the specified value.
+ */
+ public void setTaskNodes( List<JPDL3TaskNodeMetadata> taskNodes ) {
+ this.taskNodes = taskNodes;
+ }
}
Added:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3MetadataConstants.java
===================================================================
---
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3MetadataConstants.java
(rev 0)
+++
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3MetadataConstants.java 2008-11-22
19:45:51 UTC (rev 644)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.jpdl3;
+
+/**
+ * @author Serge Pagop
+ */
+public class JPDL3MetadataConstants {
+ public static final String EXPRESSION_ASSIGNMENT_HANLDER_DELEGATION_CN =
"org.jbpm.identity.assignment.ExpressionAssignmentHandler";
+}
Added:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3SwimlaneMetadata.java
===================================================================
---
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3SwimlaneMetadata.java
(rev 0)
+++
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3SwimlaneMetadata.java 2008-11-22
19:45:51 UTC (rev 644)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.jpdl3;
+
+/**
+ * Metdata class represent a swimlane in a jpdl xml file.
+ *
+ * @author Serge Pagop
+ */
+public class JPDL3SwimlaneMetadata {
+
+ /**
+ * The name.
+ */
+ private String name;
+
+ /**
+ * The JPDL3AssignmentMetadata
+ */
+ private JPDL3AssignmentMetadata assignment;
+
+ /**
+ * The actor id expression.
+ */
+ private String actorIdExpression;
+
+ /**
+ * The pooledActorsExpression.
+ */
+ private String pooledActorsExpression;
+
+ /**
+ * Get the name of the specific swimlane.
+ *
+ * @return name of the swimlane.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Set the name of the swimlane.
+ *
+ * @param name - the name of the swimlane.
+ */
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ /**
+ * Get the delegated instance, the assignment.
+ *
+ * @return assignment - the delegated instance.
+ */
+ public JPDL3AssignmentMetadata getAssignment() {
+ return this.assignment;
+ }
+
+ /**
+ * Set the delegated instance, the assignment.
+ *
+ * @param assignment - the delegated instance.
+ */
+ public void setAssignment(JPDL3AssignmentMetadata assignment) {
+ this.assignment = assignment;
+ }
+
+ /**
+ * @param actorIdExpression
+ */
+ public void setActorIdExpression( String actorIdExpression ) {
+ this.actorIdExpression = actorIdExpression;
+ }
+
+ /**
+ * @return actorIdExpression
+ */
+ public String getActorIdExpression() {
+ return actorIdExpression;
+ }
+
+ /**
+ * @param pooledActorsExpression
+ */
+ public void setPooledActorsExpression( String pooledActorsExpression ) {
+ this.pooledActorsExpression = pooledActorsExpression;
+ }
+
+ /**
+ * @return pooledActorsExpression
+ */
+ public String getPooledActorsExpression() {
+ return pooledActorsExpression;
+ }
+
+}
Added:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3TaskMetadata.java
===================================================================
---
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3TaskMetadata.java
(rev 0)
+++
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3TaskMetadata.java 2008-11-22
19:45:51 UTC (rev 644)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.jpdl3;
+
+/**
+ * @author sp
+ *
+ */
+public class JPDL3TaskMetadata {
+
+ /**
+ * The name.
+ */
+ private String name;
+
+ /**
+ * The dueDate.
+ */
+ private String dueDate;
+
+ /**
+ * The swimlane.
+ */
+ private String swimlane;
+
+ /**
+ * @param name
+ */
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ /**
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param dueDate
+ */
+ public void setDueDate( String dueDate ) {
+ this.dueDate = dueDate;
+ }
+
+ /**
+ * @return dueDate
+ */
+ public String getDueDate() {
+ return dueDate;
+ }
+
+ /**
+ * @return swimlane.
+ */
+ public String getSwimlane() {
+ return this.swimlane;
+ }
+
+ /**
+ * @param swimlane Sets swimlane to the specified value.
+ */
+ public void setSwimlane( String swimlane ) {
+ this.swimlane = swimlane;
+ }
+
+}
Added:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3TaskNodeMetadata.java
===================================================================
---
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3TaskNodeMetadata.java
(rev 0)
+++
trunk/extensions/dna-sequencer-jbpm-jpdl/src/main/java/org/jboss/dna/sequencer/jpdl3/JPDL3TaskNodeMetadata.java 2008-11-22
19:45:51 UTC (rev 644)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.jpdl3;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Serge Pagop.
+ *
+ */
+public class JPDL3TaskNodeMetadata {
+
+ /**
+ * The name.
+ */
+ private String name;
+
+ /**
+ * The tasks.
+ */
+ private List<JPDL3TaskMetadata> tasks = new
ArrayList<JPDL3TaskMetadata>();
+
+ /**
+ * The transition.
+ */
+ private List<JPDL3TransitionMetadata> transitions = new
ArrayList<JPDL3TransitionMetadata>();
+
+ /**
+ * @param name
+ */
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ /**
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param tasks
+ */
+ public void setTasks( List<JPDL3TaskMetadata> tasks ) {
+ this.tasks = tasks;
+ }
+
+ /**
+ * @return tasks
+ */
+ public List<JPDL3TaskMetadata> getTasks() {
+ return tasks;
+ }
+
+ /**
+ * @param transitions
+ */
+ public void setTransitions( List<JPDL3TransitionMetadata> transitions ) {
+ this.transitions = transitions;
+ }
+
+ /**
+ * @return transitions
+ */
+ public List<JPDL3TransitionMetadata> getTransitions() {
+ return transitions;
+ }
+
+}
Modified:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/java/org/jboss/dna/sequencer/jpdl3/JPDL3MetadataTest.java
===================================================================
---
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/java/org/jboss/dna/sequencer/jpdl3/JPDL3MetadataTest.java 2008-11-20
19:15:17 UTC (rev 643)
+++
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/java/org/jboss/dna/sequencer/jpdl3/JPDL3MetadataTest.java 2008-11-22
19:45:51 UTC (rev 644)
@@ -21,13 +21,14 @@
*/
package org.jboss.dna.sequencer.jpdl3;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
import java.io.InputStream;
import java.util.List;
-import static org.junit.Assert.*;
-import org.jboss.dna.sequencer.jpdl3.JPDL3EndStateMetadata;
-import org.jboss.dna.sequencer.jpdl3.JPDL3Metadata;
-import org.jboss.dna.sequencer.jpdl3.JPDL3StartStateMetadata;
-import org.jboss.dna.sequencer.jpdl3.JPDL3TransitionMetadata;
import org.jbpm.util.ClassLoaderUtil;
import org.junit.After;
import org.junit.Before;
@@ -55,11 +56,39 @@
}
@Test
+ public void shouldHaveOneOrMoreSwimlaneNode() {
+ List<JPDL3SwimlaneMetadata> swimlanes = metadata.getSwimlanes();
+ assertThat(swimlanes.isEmpty(), is(false));
+ for (JPDL3SwimlaneMetadata swimlane : swimlanes) {
+ if (swimlane.getName().equals("SL1")) {
+ assertThat(swimlane.getAssignment(), is(notNullValue()));
+ assertThat(swimlane.getAssignment().getFqClassName(),
is("com.sample.assigned.Task1Handler"));
+ assertThat(swimlane.getAssignment().getConfigType(),
is("constructor"));
+ } else if (swimlane.getName().equals("SL2")) {
+ assertThat(swimlane.getAssignment(), is(notNullValue()));
+ assertNotNull(swimlane.getAssignment());
+ assertThat(swimlane.getAssignment().getFqClassName(),
is("com.sample.assigned.Task2Handler"));
+ } else if (swimlane.getName().equals("SL3")) {
+ assertThat(swimlane.getAssignment(), is(notNullValue()));
+ assertThat(swimlane.getAssignment().getFqClassName(),
+
is("org.jbpm.identity.assignment.ExpressionAssignmentHandler"));
+ assertThat(swimlane.getAssignment().getExpression(),
is("<expression>group(group1)</expression>"));
+ } else if (swimlane.getName().equals("SL4")) {
+ assertThat(swimlane.getAssignment(), is(nullValue()));
+ assertThat(swimlane.getActorIdExpression(),
is("bobthebuilder"));
+ } else if (swimlane.getName().equals("SL5")) {
+ assertThat(swimlane.getAssignment(), is(nullValue()));
+ assertThat(swimlane.getPooledActorsExpression(), is("hippies,hells
angles"));
+ }
+ }
+ }
+
+ @Test
public void shouldHaveStartState() {
JPDL3StartStateMetadata jPDL3StartStateMetadata =
metadata.getStartStateMetadata();
assertNotNull(jPDL3StartStateMetadata);
assertEquals("S0", jPDL3StartStateMetadata.getName());
- //Transitions
+ // Transitions
List<JPDL3TransitionMetadata> transitions =
jPDL3StartStateMetadata.getTransitions();
for (JPDL3TransitionMetadata jPDL3TransitionMetadata : transitions) {
assertEquals("Tr01_S01", jPDL3TransitionMetadata.getName());
@@ -74,6 +103,46 @@
assertEquals("S1", jPDL3EndStateMetadata.getName());
}
+ @Test
+ public void shouldHaveATaskNode() {
+ List<JPDL3TaskNodeMetadata> taskNodes = metadata.getTaskNodes();
+ assertThat(taskNodes.size() > 0, is(true));
+ for (JPDL3TaskNodeMetadata jPDL3TaskNodeMetadata : taskNodes) {
+
+ // task node 1
+ if (jPDL3TaskNodeMetadata.getName().equals("Phase01")) {
+ List<JPDL3TaskMetadata> tasks = jPDL3TaskNodeMetadata.getTasks();
+ assertThat(tasks.size() == 2, is(true));
+ for (JPDL3TaskMetadata jPDL3TaskMetadata : tasks) {
+ if (jPDL3TaskMetadata.getName().equals("Task01_Phase01"))
{
+ String swimlane = jPDL3TaskMetadata.getSwimlane();
+ assertThat(swimlane, is("SL1"));
+ }
+ }
+ }
+
+ List<JPDL3TransitionMetadata> transitions =
jPDL3TaskNodeMetadata.getTransitions();
+
+ for (JPDL3TransitionMetadata transitionMetadata : transitions) {
+ String transitionName = transitionMetadata.getName();
+ if (transitionName.equals("Tr01_Phase01")) {
+ assertThat(transitionMetadata.getTo(), is("Phase02"));
+ } else if (transitionName.equals("Tr01_Phase02")) {
+ assertThat(transitionMetadata.getTo(), is("Phase03"));
+ } else if (transitionName.equals("Tr01_Phase03")) {
+ assertThat(transitionMetadata.getTo(), is("Phase04"));
+ } else if (transitionName.equals("Tr01_Phase04")) {
+ assertThat(transitionMetadata.getTo(), is("Phase05"));
+ } else if (transitionName.equals("Tr01_Phase05")) {
+ assertThat(transitionMetadata.getTo(), is("Phase06"));
+ } else if (transitionName.equals("Tr01_Phase06")) {
+ assertThat(transitionMetadata.getTo(), is("S1"));
+ }
+
+ }
+ }
+ }
+
public static JPDL3Metadata createJPDLMetadata() {
InputStream stream =
ClassLoaderUtil.getStream("processdefinition.xml");
JPDL3Metadata metadata = JPDL3Metadata.instance(stream);
Added: trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/gpd.xml
===================================================================
--- trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/gpd.xml
(rev 0)
+++ trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/gpd.xml 2008-11-22
19:45:51 UTC (rev 644)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<root-container name="Pd-Name" width="718"
height="434">
+ <node name="S0" x="22" y="19" width="132"
height="36">
+ <edge>
+ <label x="-27" y="-14"/>
+ </edge>
+ </node>
+ <node name="Phase01" x="298" y="12"
width="132" height="36">
+ <edge>
+ <label x="-36" y="-14"/>
+ </edge>
+ </node>
+ <node name="Phase02" x="571" y="11"
width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="Phase03" x="570" y="126"
width="132" height="36">
+ <edge>
+ <label x="-30" y="-18"/>
+ </edge>
+ </node>
+ <node name="Phase04" x="299" y="122"
width="132" height="36">
+ <edge>
+ <label x="-36" y="-18"/>
+ </edge>
+ </node>
+ <node name="Phase05" x="28" y="120"
width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="S1" x="306" y="223" width="132"
height="36"/>
+ <node name="Phase06" x="30" y="227"
width="132" height="36">
+ <edge>
+ <label x="-55" y="-18"/>
+ </edge>
+ </node>
+</root-container>
Modified:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/processdefinition.xml
===================================================================
---
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/processdefinition.xml 2008-11-20
19:15:17 UTC (rev 643)
+++
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/processdefinition.xml 2008-11-22
19:45:51 UTC (rev 644)
@@ -1,43 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
-<process-definition xmlns="urn:jbpm.org:jpdl-3.2"
- name="Pd-Name">
-
- <!-- Process roles -->
- <swimlane name="SL1">
- <assignment class="com.sample.assigned.Task1Handler" />
+<!--
+ ~ JBoss, Home of Professional Open Source.
+ ~
+ ~ Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Middleware LLC.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+-->
+<process-definition xmlns="urn:jbpm.org:jpdl-3.2"
name="Pd-Name">
+
+ <!-- roles in this process definition-->
+ <swimlane name="SL1">
+ <assignment class="com.sample.assigned.Task1Handler"
config-type="constructor"/>
+ </swimlane>
+
+ <swimlane name="SL2">
+ <assignment class="com.sample.assigned.Task2Handler" />
+ </swimlane>
+
+ <swimlane name="SL3">
+ <assignment expression="group(group1)" />
+ </swimlane>
+
+ <swimlane name="SL4">
+ <assignment actor-id="bobthebuilder" />
+ </swimlane>
+
+ <swimlane name="SL5">
+ <assignment pooled-actors='hippies,hells angles' />
</swimlane>
- <swimlane name="SL2">
- <assignment class="com.sample.assigned.Task2Handler" />
- </swimlane>
- <start-state name="S0">
- <transition name="Tr01_S01" to="Phase01" />
- </start-state>
-
- <task-node name="Phase01">
- <task name="Task01_Phase01" swimlane="SL1"/>
- <transition name="Tr01_Phase01" to="Phase02" />
+ <!-- Start of the process -->
+ <start-state name="S0">
+ <transition to="Phase01" name="Tr01_S01"></transition>
+ </start-state>
+
+ <task-node name="Phase01">
+ <task name="Task01_Phase01" swimlane="SL1" />
+ <task name="Task01_Phase011" swimlane="SL1" />
+ <transition to="Phase02"
name="Tr01_Phase01"></transition>
+ </task-node>
+
+ <task-node name="Phase02">
+ <task name="Task01_Phase02" swimlane="SL2" />
+ <transition to="Phase03"
name="Tr01_Phase02"></transition>
+ </task-node>
+
+ <task-node name="Phase03">
+ <task name="Task_01_Phase03">
+ <assignment class="com.sample.assigned.Task3Handler" />
+ </task>
+ <transition to="Phase04"
name="Tr01_Phase03"></transition>
+ </task-node>
+
+ <task-node name="Phase04">
+ <task name="Task_01_Phase04" swimlane="SL4"/>
+ <transition to="Phase05"
name="Tr01_Phase04"></transition>
+ </task-node>
+
+ <task-node name="Phase05">
+ <task name="Task_01_Phase05" swimlane="SL5"/>
+ <transition name="Tr01_Phase05" to="Phase06" />
</task-node>
- <task-node name="Phase02">
- <task name="Task01_Phase02" swimlane="SL2"/>
- <transition name="Tr01_Phase02" to="Phase03" />
- </task-node>
-
- <task-node name="Phase03">
- <task name="Task_01_Phase03">
- <assignment class="com.sample.assigned.Task3Handler" />
- </task>
- <transition name="Tr01_Phase03" to="Phase04" />
- </task-node>
-
- <task-node name="Phase04">
- <task name="Task_01_Phase04">
- <assignment class="com.sample.assigned.Task4Hanlder" />
- </task>
- <transition name="Tr01_Phase04" to="S1" />
- </task-node>
-
- <end-state name="S1" />
-
+ <task-node name="Phase06">
+ <task name="Task_01_Phase06">
+ <assignment class="com.sample.assigned.Task6Hanlder" />
+ </task>
+ <transition name="Tr01_Phase06" to="S1" />
+ </task-node>
+
+ <!-- End node in the process definition -->
+ <end-state name="S1" />
+
</process-definition>
\ No newline at end of file
Added: trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/processimage.jpg
===================================================================
(Binary files differ)
Property changes on:
trunk/extensions/dna-sequencer-jbpm-jpdl/src/test/resources/processimage.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream