[jbpm-commits] JBoss JBPM SVN: r5330 - in jbpm4/trunk/modules: bpmn and 20 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Jul 21 16:08:12 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-07-21 16:08:11 -0400 (Tue, 21 Jul 2009)
New Revision: 5330
Added:
jbpm4/trunk/modules/bpmn/
jbpm4/trunk/modules/bpmn/.classpath
jbpm4/trunk/modules/bpmn/.project
jbpm4/trunk/modules/bpmn/pom.xml
jbpm4/trunk/modules/bpmn/src/
jbpm4/trunk/modules/bpmn/src/main/
jbpm4/trunk/modules/bpmn/src/main/java/
jbpm4/trunk/modules/bpmn/src/main/java/org/
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/deployer/
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flowobjects/
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
jbpm4/trunk/modules/bpmn/src/main/resources/
jbpm4/trunk/modules/bpmn/src/test/
jbpm4/trunk/modules/bpmn/src/test/java/
jbpm4/trunk/modules/bpmn/src/test/java/org/
jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/
jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/
jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/test/
jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/test/ShipmentTest.java
jbpm4/trunk/modules/bpmn/src/test/resources/
jbpm4/trunk/modules/bpmn/src/test/resources/org/
jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/
jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/
jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/test/
jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/test/shipment.bpmn.xml
jbpm4/trunk/modules/bpmn/target/
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java
Log:
initial bpmn parsing setup
Added: jbpm4/trunk/modules/bpmn/.classpath
===================================================================
--- jbpm4/trunk/modules/bpmn/.classpath (rev 0)
+++ jbpm4/trunk/modules/bpmn/.classpath 2009-07-21 20:08:11 UTC (rev 5330)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Property changes on: jbpm4/trunk/modules/bpmn/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/bpmn/.project
===================================================================
--- jbpm4/trunk/modules/bpmn/.project (rev 0)
+++ jbpm4/trunk/modules/bpmn/.project 2009-07-21 20:08:11 UTC (rev 5330)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>bpmn</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Property changes on: jbpm4/trunk/modules/bpmn/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/bpmn/pom.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/pom.xml (rev 0)
+++ jbpm4/trunk/modules/bpmn/pom.xml 2009-07-21 20:08:11 UTC (rev 5330)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 5246 2009-07-06 11:07:48Z tom.baeyens at jboss.com $ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!-- Module Info -->
+ <modelVersion>4.0.0</modelVersion>
+ <name>jBPM 4 - BPMN</name>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-bpmn</artifactId>
+ <packaging>jar</packaging>
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm</artifactId>
+ <version>4.1-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-test-base</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-jpdl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-test-base</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/bpmn/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2009-07-21 20:08:11 UTC (rev 5330)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbpm.bpmn.parser;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class BpmnParser extends Parser {
+
+ public Object parseDocumentElement(Element documentElement, Parse parse) {
+ List<ProcessDefinitionImpl> processDefinitions = new ArrayList<ProcessDefinitionImpl>();
+ for (Element processElement: XmlUtil.elements(documentElement, "process")) {
+ ProcessDefinitionImpl processDefinition = parseProcess(processElement, parse);
+ processDefinitions.add(processDefinition);
+ }
+
+ // TODO unify document object of JpdlParser with BpmnParser so that ProcessDeployer can be refactored accordingly
+
+ return processDefinitions;
+ }
+
+ public ProcessDefinitionImpl parseProcess(Element processElement, Parse parse) {
+ ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl();
+
+ parse.pushObject(processDefinition);
+ try {
+
+ // process attribues
+ String name = XmlUtil.attribute(processElement, "name", true, parse);
+ processDefinition.setName(name);
+
+ // TODO finish rest of parsing
+
+
+ } finally {
+ parse.popObject();
+ }
+
+ return processDefinition;
+ }
+}
Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/test/ShipmentTest.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/test/ShipmentTest.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/test/ShipmentTest.java 2009-07-21 20:08:11 UTC (rev 5330)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbpm.bpmn.test;
+
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ShipmentTest extends JbpmTestCase {
+
+ public void testShipment() {
+ repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/bpmn/test/shipment.bpmn.xml")
+ .deploy();
+
+ // todo
+ }
+}
Property changes on: jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/test/ShipmentTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/test/shipment.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/test/shipment.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/test/shipment.bpmn.xml 2009-07-21 20:08:11 UTC (rev 5330)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions id="ShipmentDefinitions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 D:\Projekte\workspace\jbpm4\BPMN-2.0\src\resource\BPMN20.xsd" xmlns:bpmn="http://schema.omg.org/spec/BPMN/2.0" xmlns:sample="http://sample.bpmn.camunda.com/" xmlns:xbpmn="http://bpmn.camunda.com/" xmlns:tns="http://sample.bpmn.camunda.com/" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://sample.bpmn.camunda.com/">
+ <!-- imports -->
+ <bpmn:import namespace="http://sample.bpmn.camunda.com/" location="D:\Projekte\workspace\jbpm4\BPMN-2.0\src\resource\SampleService.xsd" importType="http://www.w3.org/2001/XMLSchema"/>
+ <bpmn:import namespace="http://sample.bpmn.camunda.com/" location="D:\Projekte\workspace\jbpm4\BPMN-2.0\src\resource\SampleService.wsdl" importType="http://schemas.xmlsoap.org/wsdl/soap/"/>
+ <bpmn:import namespace="http://sample.bpmn.camunda.com/" location="D:\Projekte\workspace\jbpm4\BPMN-2.0\src\resource\ShipmentProcessService.wsdl" importType="http://schemas.xmlsoap.org/wsdl/soap/"/>
+ <!-- definition structures for process variables -->
+ <bpmn:itemDefinition id="lieferungDef" itemKind="Information" structureRef="sample:shipment"/>
+ <!-- definition structures for messages -->
+ <bpmn:itemDefinition id="ProzessStartenDef" itemKind="Information" structureRef="sample:startShipmentProces"/>
+ <bpmn:itemDefinition id="LieferungAnlegenDef" itemKind="Information" structureRef="sample:createShipment"/>
+ <bpmn:itemDefinition id="KommissioniertDef" itemKind="Information" structureRef="sample:notifyShipmentConsigned"/>
+ <!-- messages -->
+ <bpmn:message name="ProzessStarten" id="ProzessStartenNachricht" structureRef="tns:ProzessStartenDef"/>
+ <bpmn:message name="LieferungAnlegen" id="LieferungAnlegenNachricht" structureRef="tns:LieferungAnlegenDef"/>
+ <bpmn:message name="Kommissioniert" id="KommissioniertNachricht" structureRef="tns:KommissioniertDef"/>
+ <!-- Services -->
+ <!-- serivceReference ?? -->
+ <!-- conversation? Participant? -->
+ <bpmn:endPoint id="ProzessEndpoint">
+ <xbpmn:url/>
+ </bpmn:endPoint>
+ <bpmn:endPoint id="LiefersystemEndpoint">
+ <xbpmn:url/>
+ </bpmn:endPoint>
+ <!-- interfaces -->
+ <bpmn:interface id="ProzessInterface" name="Lieferprozess Schnittstelle">
+ <bpmn:operation name="startShipmentProcess">
+ <bpmn:inMessageRef>tns:ProzessStartenNachricht</bpmn:inMessageRef>
+ </bpmn:operation>
+ <bpmn:operation name="notifyShipmentConsigned">
+ <bpmn:inMessageRef>tns:KommissioniertNachricht</bpmn:inMessageRef>
+ </bpmn:operation>
+ </bpmn:interface>
+ <bpmn:interface id="LiefersystemInterface" name="Liefersystem Schnittstelle">
+ <bpmn:operation name="createShiptment">
+ <bpmn:inMessageRef>tns:LieferungAnlegenNachricht</bpmn:inMessageRef>
+ </bpmn:operation>
+ </bpmn:interface>
+ <!-- Resources / Performers -->
+ <bpmn:resource id="VertriebResource" name="Vertrieb"/>
+ <!-- process definition -->
+ <bpmn:process id="Shipment" name="Shipment">
+ <bpmn:documentation id="doc1">Teilprozess der Lieferung</bpmn:documentation>
+ <!-- process variables -->
+ <bpmn:dataObject id="lieferungVariable" name="Lieferung" itemSubjectRef="tns:lieferungDef"/>
+ <!-- Start-Event -->
+ <bpmn:startEvent id="Start">
+ <bpmn:dataOutput id="ProzessStartOutput" itemSubjectRef="tns:ProzessStartenNachricht"/>
+ <bpmn:dataOutputAssociation>
+ <bpmn:assignment>
+ <bpmn:from xsi:type="bpmn:tFormalExpression">getDataOutput('ProzessStartOutput')/shipment</bpmn:from>
+ <bpmn:to xsi:type="bpmn:tFormalExpression">getDataObject('lieferungVariable')</bpmn:to>
+ </bpmn:assignment>
+ <bpmn:sourceRef>ProzessStartOutput</bpmn:sourceRef>
+ <bpmn:targetRef>tns:lieferungVariable</bpmn:targetRef>
+ </bpmn:dataOutputAssociation>
+ <bpmn:messageEventDefinition messageRef="tns:ProzessStartenNachricht">
+ <bpmn:operationRef>tns:startShipmentProcess</bpmn:operationRef>
+ </bpmn:messageEventDefinition>
+ </bpmn:startEvent>
+ <!-- Activity 1: Service Task -->
+ <bpmn:serviceTask id="LieferungBuchen" name="Lieferung buchen" implementation="WebService" operationRef="createShipment">
+ <xbpmn:url/>
+ <bpmn:ioSpecification>
+ <bpmn:dataInput id="LieferungBuchenInput" isCollection="false" itemSubjectRef="tns:LieferungAnlegenNachricht"/>
+ <bpmn:inputSet>
+ <bpmn:dataInputRefs>LieferungBuchenInput</bpmn:dataInputRefs>
+ </bpmn:inputSet>
+ <bpmn:outputSet/>
+ </bpmn:ioSpecification>
+ <bpmn:dataInputAssociation>
+ <bpmn:assignment>
+ <bpmn:from xsi:type="bpmn:tFormalExpression">bpmn:getDataObject('lieferungVariable')</bpmn:from>
+ <bpmn:to xsi:type="bpmn:tFormalExpression">bpmn:getDataInput('LieferungBuchenInput'/shipment/</bpmn:to>
+ </bpmn:assignment>
+ <bpmn:sourceRef>tns:lieferungVariable</bpmn:sourceRef>
+ <bpmn:targetRef>LieferungBuchenInput</bpmn:targetRef>
+ </bpmn:dataInputAssociation>
+ </bpmn:serviceTask>
+ <!-- Activity 2: Receive Task -->
+ <bpmn:receiveTask id="WartenAufLieferung" name="Warten auf Lieferung" instantiate="false" implementation="WebService" operationRef="notifyShipmentConsigned" messageRef="tns:Kommissioniert">
+ <bpmn:ioSpecification>
+ <bpmn:dataOutput id="KommissioniertOutput" itemSubjectRef="tns:KommissioniertNachricht"/>
+ <bpmn:inputSet/>
+ <bpmn:outputSet>
+ <bpmn:dataOutputRefs>KommissioniertOutput</bpmn:dataOutputRefs>
+ </bpmn:outputSet>
+ </bpmn:ioSpecification>
+
+ <bpmn:dataOutputAssociation>
+ <bpmn:assignment>
+ <bpmn:from xsi:type="bpmn:tFormalExpression">getDataOutput('KommissioniertOutput')/shipment</bpmn:from>
+ <bpmn:to xsi:type="bpmn:tFormalExpression">getDataObject('lieferungVariable')</bpmn:to>
+ </bpmn:assignment>
+ <bpmn:sourceRef>KommissioniertOutput</bpmn:sourceRef>
+ <bpmn:targetRef>tns:lieferungVariable</bpmn:targetRef>
+ </bpmn:dataOutputAssociation>
+ </bpmn:receiveTask>
+ <!-- Gateway -->
+ <bpmn:exclusiveGateway id="PruefeAvisierung" name="Avisierung benoetigt?"/>
+ <!-- Activity 3: User Task -->
+ <bpmn:userTask id="LieferterminAvisieren" name="Liefertermin avisieren" implementation="other">
+ <!-- <bpmn:humanPerformer resourceRef="tns:Vertrieb"></bpmn:humanPerformer>-->
+ <bpmn:potentialOwner resourceRef="tns:VertriebResource"/>
+ </bpmn:userTask>
+ <!-- End Events -->
+ <bpmn:endEvent id="End" name="End"/>
+ <!-- Sequence Flow -->
+ <bpmn:sequenceFlow id="flow1" sourceRef="Start" targetRef="LieferungBuchen" name="Start->LieferungBuchen"/>
+ <bpmn:sequenceFlow id="flow2" sourceRef="LieferungBuchen" targetRef="WartenAufLieferung"/>
+ <bpmn:sequenceFlow id="flow3" sourceRef="WartenAufLieferung" targetRef="PruefeAvisierung"/>
+ <bpmn:sequenceFlow id="flow4" sourceRef="PruefeAvisierung" targetRef="LieferterminAvisieren">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">getDataObject('lieferungVariable')/confirmationRequired=true</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="flow5" sourceRef="PruefeAvisierung" targetRef="End">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">not( getDataObject('lieferungVariable')/confirmationRequired=true )</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:sequenceFlow id="flow6" sourceRef="LieferterminAvisieren" targetRef="End"/>
+ </bpmn:process>
+
+<!--
+ <bpmn:correlationSubscription>
+ </bpmn:correlationSubscription>
+-->
+
+ <!-- TODO: Correlation / Conversation -->
+ <bpmn:conversation>
+ <bpmn:correlationKey>
+ <bpmn:correlationPropertyRef>test</bpmn:correlationPropertyRef>
+ </bpmn:correlationKey>
+ </bpmn:conversation>
+</bpmn:definitions>
Property changes on: jbpm4/trunk/modules/bpmn/src/test/resources/org/jbpm/bpmn/test/shipment.bpmn.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java 2009-07-21 10:13:21 UTC (rev 5329)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java 2009-07-21 20:08:11 UTC (rev 5330)
@@ -21,152 +21,19 @@
*/
package org.jbpm.jpdl.internal.repository;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.List;
-
-import org.jbpm.api.ProcessDefinition;
-import org.jbpm.api.ProcessDefinitionQuery;
-import org.jbpm.internal.log.Log;
-import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
import org.jbpm.jpdl.internal.xml.JpdlParser;
-import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.internal.repository.Deployer;
-import org.jbpm.pvm.internal.repository.DeploymentImpl;
-import org.jbpm.pvm.internal.session.RepositorySession;
-import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.repository.ProcessDeployer;
-
/**
* @author Tom Baeyens
*/
-public class JpdlDeployer implements Deployer {
+public class JpdlDeployer extends ProcessDeployer {
- private static Log log = Log.getLog(JpdlDeployer.class.getName());
-
static JpdlParser jpdlParser = new JpdlParser();
-
- public void deploy(DeploymentImpl deployment) {
-
- for (String resourceName: deployment.getResourceNames()) {
-
- if (resourceName.endsWith(".jpdl.xml")) {
- byte[] bytes = deployment.getBytes(resourceName);
- InputStream inputStream = new ByteArrayInputStream(bytes);
- Parse parse = jpdlParser.createParse();
- parse.setProblems(deployment.getProblems());
- parse.setInputStream(inputStream);
- parse.execute();
- JpdlProcessDefinition processDefinition = (JpdlProcessDefinition) parse.getDocumentObject();
- if ((processDefinition != null) && (processDefinition.getName() != null)) {
- String processDefinitionName = processDefinition.getName();
-
- processDefinition.setSuspended(deployment.isSuspended());
-
- String imageResourceName = resourceName.substring(0, resourceName.lastIndexOf(".jpdl.xml"))+".png";
- if (deployment.getResourceNames().contains(imageResourceName)) {
- processDefinition.setImageResourceName(imageResourceName);
- }
-
- processDefinition.setDeploymentDbid(deployment.getDbid());
-
- if (deployment.hasObjectProperties(processDefinitionName)) {
- String key = deployment.getProcessDefinitionKey(processDefinitionName);
- String id = deployment.getProcessDefinitionId(processDefinitionName);
- Long version = deployment.getProcessDefinitionVersion(processDefinitionName);
- processDefinition.setId(id);
- processDefinition.setKey(key);
- processDefinition.setVersion(version.intValue());
-
- } else {
- checkKey(processDefinition, deployment);
- checkVersion(processDefinition, deployment);
- checkId(processDefinition, deployment);
-
- deployment.setProcessDefinitionId(processDefinitionName, processDefinition.getId());
- deployment.setProcessDefinitionKey(processDefinitionName, processDefinition.getKey());
- deployment.setProcessDefinitionVersion(processDefinitionName, new Long(processDefinition.getVersion()));
- }
-
- deployment.addObject(processDefinitionName, processDefinition);
- }
- }
- }
- }
+ static final String jpdlExtension = ".jpdl.xml";
- protected void checkKey(ProcessDefinitionImpl processDefinition, DeploymentImpl deployment) {
- String processDefinitionName = processDefinition.getName();
- String processDefinitionKey = processDefinition.getKey();
-
- // if no key was specified in the jpdl process file
- if (processDefinitionKey==null) {
- // derive the key from the name
- // replace any non-word character with an underscore
- processDefinitionKey = processDefinitionName.replaceAll("\\W", "_");
- processDefinition.setKey(processDefinitionKey);
- }
-
- RepositorySession repositorySession = Environment.getFromCurrent(RepositorySession.class);
-
- List<ProcessDefinition> existingProcesses = repositorySession.createProcessDefinitionQuery()
- .processDefinitionName(processDefinitionName)
- .list();
-
- for (ProcessDefinition existingProcess: existingProcesses) {
- if (!processDefinitionKey.equals(existingProcess.getKey())) {
- deployment.addProblem("invalid key '"+processDefinitionKey+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
- }
- }
-
- existingProcesses = repositorySession.createProcessDefinitionQuery()
- .processDefinitionKey(processDefinitionKey)
- .list();
-
- for (ProcessDefinition existingProcess: existingProcesses) {
- if (!processDefinitionName.equals(existingProcess.getName())) {
- deployment.addProblem("invalid name '"+processDefinitionName+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
- }
- }
+ public JpdlDeployer() {
+ super(jpdlExtension, jpdlParser);
}
- protected void checkId(ProcessDefinitionImpl processDefinition, DeploymentImpl deployment) {
- String id = processDefinition.getId();
- if (id==null) {
- id = processDefinition.getKey()+"-"+processDefinition.getVersion();
- if (log.isTraceEnabled()) log.trace("created id '"+id+"' for "+processDefinition);
- processDefinition.setId(id);
- }
-
- RepositorySession repositorySession = Environment.getFromCurrent(RepositorySession.class);
- ProcessDefinition existingProcessDefinition = repositorySession.createProcessDefinitionQuery()
- .processDefinitionId(id)
- .uniqueResult();
- if (existingProcessDefinition != null) {
- deployment.addProblem("process '" + id + "' already exists");
- }
- }
-
- protected void checkVersion(ProcessDefinitionImpl processDefinition, DeploymentImpl deployment) {
- int version = processDefinition.getVersion();
- String key = processDefinition.getKey();
- if (version==ProcessDefinitionImpl.UNASSIGNED_VERSION) {
- RepositorySession repositorySession = Environment.getFromCurrent(RepositorySession.class);
-
- ProcessDefinition latestDeployedVersion = repositorySession
- .createProcessDefinitionQuery()
- .processDefinitionKey(key)
- .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
- .page(0, 1)
- .uniqueResult();
-
- if (latestDeployedVersion!=null) {
- version = latestDeployedVersion.getVersion() + 1;
- } else {
- version = 1;
- }
- if (log.isTraceEnabled()) log.trace("assigning version "+version+" to process definition "+key);
- processDefinition.setVersion(version);
- }
- }
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java 2009-07-21 20:08:11 UTC (rev 5330)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jbpm.pvm.internal.repository;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.List;
+
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessDefinitionQuery;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.session.RepositorySession;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDeployer implements Deployer {
+
+ private static final Log log = Log.getLog(ProcessDeployer.class.getName());
+
+ protected String extension;
+ protected Parser parser;
+
+ public ProcessDeployer(String extension, Parser parser) {
+ this.extension = extension;
+ this.parser = parser;
+ }
+
+ public void deploy(DeploymentImpl deployment) {
+
+ for (String resourceName: deployment.getResourceNames()) {
+
+ if (resourceName.endsWith(extension)) {
+ byte[] bytes = deployment.getBytes(resourceName);
+ InputStream inputStream = new ByteArrayInputStream(bytes);
+ Parse parse = parser.createParse();
+ parse.setProblems(deployment.getProblems());
+ parse.setInputStream(inputStream);
+ parse.execute();
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) parse.getDocumentObject();
+ if ((processDefinition != null) && (processDefinition.getName() != null)) {
+ String processDefinitionName = processDefinition.getName();
+
+ processDefinition.setSuspended(deployment.isSuspended());
+
+ String imageResourceName = resourceName.substring(0, resourceName.lastIndexOf(extension))+".png";
+ if (deployment.getResourceNames().contains(imageResourceName)) {
+ processDefinition.setImageResourceName(imageResourceName);
+ }
+
+ processDefinition.setDeploymentDbid(deployment.getDbid());
+
+ if (deployment.hasObjectProperties(processDefinitionName)) {
+ String key = deployment.getProcessDefinitionKey(processDefinitionName);
+ String id = deployment.getProcessDefinitionId(processDefinitionName);
+ Long version = deployment.getProcessDefinitionVersion(processDefinitionName);
+ processDefinition.setId(id);
+ processDefinition.setKey(key);
+ processDefinition.setVersion(version.intValue());
+
+ } else {
+ checkKey(processDefinition, deployment);
+ checkVersion(processDefinition, deployment);
+ checkId(processDefinition, deployment);
+
+ deployment.setProcessDefinitionId(processDefinitionName, processDefinition.getId());
+ deployment.setProcessDefinitionKey(processDefinitionName, processDefinition.getKey());
+ deployment.setProcessDefinitionVersion(processDefinitionName, new Long(processDefinition.getVersion()));
+ }
+
+ deployment.addObject(processDefinitionName, processDefinition);
+ }
+ }
+ }
+ }
+
+ protected void checkKey(ProcessDefinitionImpl processDefinition, DeploymentImpl deployment) {
+ String processDefinitionName = processDefinition.getName();
+ String processDefinitionKey = processDefinition.getKey();
+
+ // if no key was specified in the jpdl process file
+ if (processDefinitionKey==null) {
+ // derive the key from the name
+ // replace any non-word character with an underscore
+ processDefinitionKey = processDefinitionName.replaceAll("\\W", "_");
+ processDefinition.setKey(processDefinitionKey);
+ }
+
+ RepositorySession repositorySession = Environment.getFromCurrent(RepositorySession.class);
+
+ List<ProcessDefinition> existingProcesses = repositorySession.createProcessDefinitionQuery()
+ .processDefinitionName(processDefinitionName)
+ .list();
+
+ for (ProcessDefinition existingProcess: existingProcesses) {
+ if (!processDefinitionKey.equals(existingProcess.getKey())) {
+ deployment.addProblem("invalid key '"+processDefinitionKey+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
+ }
+ }
+
+ existingProcesses = repositorySession.createProcessDefinitionQuery()
+ .processDefinitionKey(processDefinitionKey)
+ .list();
+
+ for (ProcessDefinition existingProcess: existingProcesses) {
+ if (!processDefinitionName.equals(existingProcess.getName())) {
+ deployment.addProblem("invalid name '"+processDefinitionName+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
+ }
+ }
+ }
+
+ protected void checkId(ProcessDefinitionImpl processDefinition, DeploymentImpl deployment) {
+ String id = processDefinition.getId();
+ if (id==null) {
+ id = processDefinition.getKey()+"-"+processDefinition.getVersion();
+ if (log.isTraceEnabled()) log.trace("created id '"+id+"' for "+processDefinition);
+ processDefinition.setId(id);
+ }
+
+ RepositorySession repositorySession = Environment.getFromCurrent(RepositorySession.class);
+ ProcessDefinition existingProcessDefinition = repositorySession.createProcessDefinitionQuery()
+ .processDefinitionId(id)
+ .uniqueResult();
+ if (existingProcessDefinition != null) {
+ deployment.addProblem("process '" + id + "' already exists");
+ }
+ }
+
+ protected void checkVersion(ProcessDefinitionImpl processDefinition, DeploymentImpl deployment) {
+ int version = processDefinition.getVersion();
+ String key = processDefinition.getKey();
+ if (version==ProcessDefinitionImpl.UNASSIGNED_VERSION) {
+ RepositorySession repositorySession = Environment.getFromCurrent(RepositorySession.class);
+
+ ProcessDefinition latestDeployedVersion = repositorySession
+ .createProcessDefinitionQuery()
+ .processDefinitionKey(key)
+ .orderDesc(ProcessDefinitionQuery.PROPERTY_VERSION)
+ .page(0, 1)
+ .uniqueResult();
+
+ if (latestDeployedVersion!=null) {
+ version = latestDeployedVersion.getVersion() + 1;
+ } else {
+ version = 1;
+ }
+ if (log.isTraceEnabled()) log.trace("assigning version "+version+" to process definition "+key);
+ processDefinition.setVersion(version);
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jbpm-commits
mailing list