[jbpm-commits] JBoss JBPM SVN: r5064 - in jbpm4/branches/jimma/modules/migration: scripts and 2 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Jun 19 06:59:06 EDT 2009
Author: jim.ma
Date: 2009-06-19 06:59:06 -0400 (Fri, 19 Jun 2009)
New Revision: 5064
Removed:
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Reader.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl4Writer.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ProblemCollector.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/
jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
Modified:
jbpm4/branches/jimma/modules/migration/pom.xml
jbpm4/branches/jimma/modules/migration/scripts/assembly-distro.xml
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ActionConverterTypes.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverterTool.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/NodeConverterTypes.java
jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterToolTest.java
Log:
Removed JAXB and Jpdl3 dependenceis;fixed the converted file name issue according to Joram's suggestion
Modified: jbpm4/branches/jimma/modules/migration/pom.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/pom.xml 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/pom.xml 2009-06-19 10:59:06 UTC (rev 5064)
@@ -48,60 +48,31 @@
<!-- Dependencies -->
<dependencies>
- <dependency>
- <groupId>org.jbpm.jbpm3</groupId>
- <artifactId>jbpm-jpdl</artifactId>
- <version>3.3.1-SNAPSHOT</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>xml-apis</artifactId>
+ <groupId>xml-apis</groupId>
+ </exclusion>
+ </exclusions>
+ <version>1.6.1</version>
+ </dependency>
- <!-- 3rd Party -->
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.0</version>
- <exclusions>
- <exclusion>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jsr173_api</artifactId>
- </exclusion>
-
- </exclusions>
-
-
- </dependency>
-
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>2.0.3</version>
- </dependency>
-
-
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
@@ -133,30 +104,6 @@
</dependencies>
- <!-- Plugins -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxb2-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <goals>
- <goal>xjc</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <includeSchemas>
- <includeSchema>**/*.xsd</includeSchema>
- </includeSchemas>
- <packageName>org.jbpm.jpdl4.model</packageName>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
<!-- Profiles -->
<profiles>
<!--
Modified: jbpm4/branches/jimma/modules/migration/scripts/assembly-distro.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/scripts/assembly-distro.xml 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/scripts/assembly-distro.xml 2009-06-19 10:59:06 UTC (rev 5064)
@@ -8,22 +8,8 @@
<finalName>jbpm-migration-${version}</finalName>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
- <format>zip</format>
<format>dir</format>
</formats>
-
-
-<!--fileSets>
- <fileSet>
- <directory>target</directory>
- <outputDirectory>jbpm-migration-${version}</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
-</fileSets-->
-
-
<!-- Dependency Sets -->
<dependencySets>
<dependencySet>
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ActionConverterTypes.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ActionConverterTypes.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ActionConverterTypes.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -33,7 +33,6 @@
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jbpm.jpdl.internal.convert.action.Action;
-import org.jbpm.jpdl.internal.convert.node.Node;
public class ActionConverterTypes {
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReader.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -21,9 +21,13 @@
*/
package org.jbpm.jpdl.internal.convert;
+import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -35,25 +39,14 @@
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
-
-import org.jbpm.graph.def.Transition;
import org.jbpm.jpdl.internal.convert.action.Action;
import org.jbpm.jpdl.internal.convert.node.Node;
+import org.jbpm.jpdl.internal.convert.node.StartState;
import org.jbpm.jpdl.internal.convert.node.TaskNode;
-import org.jbpm.jpdl.internal.convert.node.StartState;
-import org.jbpm.jpdl.internal.convert.util.EventsConverter;
-import org.jbpm.jpdl.internal.convert.util.TransitionConverter;
-import org.jbpm.jpdl4.model.ObjectFactory;
-import org.jbpm.jpdl4.model.On;
-import org.jbpm.jpdl4.model.Process;
-import org.jbpm.jpdl4.model.WireObjectType;
-import org.jbpm.taskmgmt.def.Task;
import org.xml.sax.InputSource;
-import bsh.This;
-
public class Jpdl3ConverterReader implements ProblemListener {
- private static final Log logger = LogFactory.getLog(JpdlConverter.class);
+ private static final Log logger = LogFactory.getLog(Jpdl3ConverterReader.class);
private static String JPDL4NS = "http://jbpm.org/4.0/jpdl";
private static final long serialVersionUID = 1L;
protected Document document;
@@ -69,6 +62,19 @@
protected Map<String,Element> swimlanesCollection = new java.util.concurrent.ConcurrentHashMap<String, Element>();
//for autonumbering anonymous timers.
private int timerNumber;
+
+
+ public Jpdl3ConverterReader(URL url)
+ {
+ try {
+ File file = new File(url.toURI());
+ FileReader reader = new FileReader(file);
+ this.inputSource = new InputSource(reader);
+ } catch (Exception e) {
+ //Do nothing , we validated it before
+ }
+ }
+
public Jpdl3ConverterReader(InputSource inputSource)
{
Deleted: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Reader.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Reader.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Reader.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -1,57 +0,0 @@
-/*
- * 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.jpdl.internal.convert;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.jbpm.jpdl.xml.JpdlXmlReader;
-import org.jbpm.jpdl.xml.Problem;
-import org.jbpm.jpdl.xml.ProblemListener;
-import org.xml.sax.InputSource;
-
-public class Jpdl3Reader extends JpdlXmlReader {
-
- public Jpdl3Reader(InputSource ins) {
- super(ins);
- }
-
- public Jpdl3Reader(InputSource inputSource, ProblemListener problemListener) {
- super(inputSource, problemListener);
- }
-
- public boolean isValid() {
- Iterator iter = problems.iterator();
- while (iter.hasNext()) {
- Problem problem = (Problem) iter.next();
- if (problem.getLevel() < problem.LEVEL_WARNING) {
- return false;
- }
- }
- return true;
- }
-
- public List<Problem> getProblems() {
- return problems;
- }
-
-}
Deleted: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl4Writer.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl4Writer.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl4Writer.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -1,59 +0,0 @@
-/*
- * 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.jpdl.internal.convert;
-
-import java.io.OutputStream;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import org.jbpm.jpdl4.model.ObjectFactory;
-import org.jbpm.jpdl4.model.Process;
-public class Jpdl4Writer {
- private Marshaller marshaller = null;
-
- public void write(Process process, OutputStream out, boolean formatedOutput) throws ConvertException {
- try {
- getMarshaller();
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(formatedOutput));
- marshaller.marshal(process, out);
- } catch (JAXBException e) {
- throw new ConvertException("Failed to write converted process file to", e);
- }
- }
-
-
- public void write(Process process, OutputStream out) throws ConvertException {
- write(process, out, false);
- }
-
- private Marshaller getMarshaller() throws JAXBException {
- if (marshaller == null) {
- JAXBContext jc = JAXBContext.newInstance(new Class[] { ObjectFactory.class });
- marshaller = jc.createMarshaller();
-
- }
- return marshaller;
-
- }
-
-}
Deleted: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -1,203 +0,0 @@
-/*
- * 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.jpdl.internal.convert;
-
-import static org.jbpm.graph.def.Node.NodeType.StartState;
-import static org.jbpm.graph.def.Node.NodeType.State;
-import static org.jbpm.graph.def.Node.NodeType.Decision;
-import static org.jbpm.graph.def.Node.NodeType.EndState;
-import static org.jbpm.graph.def.Node.NodeType.Fork;
-import static org.jbpm.graph.def.Node.NodeType.Join;
-import static org.jbpm.graph.def.Node.NodeType.Node;
-import static org.jbpm.graph.def.Node.NodeType.Task;
-
-import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jbpm.graph.def.Event;
-import org.jbpm.graph.def.Node;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.def.SuperState;
-import org.jbpm.graph.node.EndState;
-import org.jbpm.graph.node.Fork;
-import org.jbpm.graph.node.Join;
-import org.jbpm.graph.node.MailNode;
-import org.jbpm.graph.node.StartState;
-import org.jbpm.graph.node.State;
-import org.jbpm.graph.node.TaskNode;
-import org.jbpm.jpdl.internal.convert.util.DecisionConverter;
-import org.jbpm.jpdl.internal.convert.util.EndStateConverter;
-import org.jbpm.jpdl.internal.convert.util.EventsConverter;
-import org.jbpm.jpdl.internal.convert.util.ExceptionHandlersConverter;
-import org.jbpm.jpdl.internal.convert.util.ForkConverter;
-import org.jbpm.jpdl.internal.convert.util.JoinConverter;
-import org.jbpm.jpdl.internal.convert.util.MailNodeConverter;
-import org.jbpm.jpdl.internal.convert.util.NodeConverter;
-import org.jbpm.jpdl.internal.convert.util.StartStateConverter;
-import org.jbpm.jpdl.internal.convert.util.StateConverter;
-import org.jbpm.jpdl.internal.convert.util.SuperStateConverter;
-import org.jbpm.jpdl.internal.convert.util.SwimlaneConverter;
-import org.jbpm.jpdl.internal.convert.util.TaskNodeConverter;
-import org.jbpm.jpdl.xml.JpdlXmlReader;
-import org.jbpm.jpdl.xml.Problem;
-
-import org.jbpm.jpdl4.model.On;
-import org.jbpm.jpdl4.model.Process;
-import org.jbpm.taskmgmt.def.Swimlane;
-import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
-import org.xml.sax.InputSource;
-
-public class JpdlConverter implements ProblemCollector {
- public List<Problem> problems = new CopyOnWriteArrayList<Problem>();
-
- private static final long serialVersionUID = 1L;
- private static final Log logger = LogFactory.getLog(JpdlConverter.class);
-
- public Process run(URL url) throws ConvertException {
- Jpdl3Reader reader = new Jpdl3Reader(new InputSource(url.toString()), this);
- ProcessDefinition processDef = reader.readProcessDefinition();
- return mapProcessDef(processDef);
- }
-
- public Process mapProcessDef(ProcessDefinition def) throws ConvertException {
- Process process = new Process();
- process.setName(def.getName());
-
- //convert swimlane
- TaskMgmtDefinition taskMgmtDefinition = def.getTaskMgmtDefinition();
- Map swimlanesMap = taskMgmtDefinition.getSwimlanes();
- if (swimlanesMap != null) {
- Iterator iterator = swimlanesMap.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry<String, Swimlane> entry = (Map.Entry<String, Swimlane>) iterator
- .next();
- org.jbpm.jpdl4.model.Swimlane item = SwimlaneConverter
- .run(entry.getValue(), this);
- process.getSwimlaneAndOnAndTimer().add(item);
- }
- }
-
- for (Node node : def.getNodes()) {
- if (node instanceof SuperState) {
- SuperState superState = (SuperState)node;
- SuperStateConverter.run(superState, this);
- continue;
- }
-
- if (node instanceof MailNode) {
- MailNode mailNode = (MailNode)node;
- MailNodeConverter.run(mailNode, this);
- }
- Node.NodeType nodeType = node.getNodeType();
- switch(node.getNodeType()) {
- case StartState :
- org.jbpm.graph.node.StartState jpdl3start = ( org.jbpm.graph.node.StartState) node;
- Process.Start start = StartStateConverter.run(jpdl3start, this);
- process.getSwimlaneAndOnAndTimer().add(start);
- break;
- case State:
- org.jbpm.graph.node.State jpdl3state = (org.jbpm.graph.node.State) node;
- Process.State state = StateConverter.run(jpdl3state, this);
- process.getSwimlaneAndOnAndTimer().add(state);
- break;
- case EndState:
- org.jbpm.graph.node.EndState jpdl3end = (org.jbpm.graph.node.EndState) node;
- Process.End end = EndStateConverter.run(jpdl3end, this);
- process.getSwimlaneAndOnAndTimer().add(end);
- break;
- case Task:
- //TaskNode
- if (node instanceof TaskNode) {
- org.jbpm.graph.node.TaskNode taskNode = (org.jbpm.graph.node.TaskNode)node;
- Set<Process.Task> tasks = TaskNodeConverter.run(taskNode, this);
- process.getSwimlaneAndOnAndTimer().addAll(tasks);
- }
- break;
- case Fork:
- org.jbpm.graph.node.Fork fork = (org.jbpm.graph.node.Fork)node;
- process.getSwimlaneAndOnAndTimer().add(ForkConverter.run(fork, this));
- break;
- case Join:
- org.jbpm.graph.node.Join join = (org.jbpm.graph.node.Join)node;
- process.getSwimlaneAndOnAndTimer().add(JoinConverter.run(join, this));
- break;
- case Node:
- org.jbpm.graph.def.Node tmpNode = (org.jbpm.graph.def.Node)node;
- process.getSwimlaneAndOnAndTimer().add(NodeConverter.run(tmpNode, this));
- break;
- case Decision :
- try {
- org.jbpm.graph.node.Decision decision = (org.jbpm.graph.node.Decision) node;
- process.getSwimlaneAndOnAndTimer().add(DecisionConverter.run(decision, this));
- } catch (ConvertException exe) {
- this.addError(exe.getMessage(), exe);
- throw exe;
- }
- break;
-
- }
-
-
- }
-
- //Process Event
- List<On> ons = EventsConverter.run(def.getEvents(), this);
- process.getSwimlaneAndOnAndTimer().addAll(ons);
- ExceptionHandlersConverter.run(def, this);
- return process;
- }
-
-
- public void addProblem(Problem problem) {
- this.problems.add(problem);
- }
-
- public List<Problem> getProblems() {
- return problems;
- }
-
-
- public void addError(String description)
- {
- logger.error(description);
- addProblem(new Problem(Problem.LEVEL_ERROR, description));
- }
-
- public void addError(String description, Throwable exception)
- {
- logger.error(description, exception);
- addProblem(new Problem(Problem.LEVEL_ERROR, description, exception));
- }
-
- public void addWarning(String description)
- {
- logger.warn(description);
- addProblem(new Problem(Problem.LEVEL_WARNING, description));
- }
-
-}
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverterTool.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverterTool.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverterTool.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -22,12 +22,14 @@
package org.jbpm.jpdl.internal.convert;
import java.io.File;
-
+import java.io.FileWriter;
+import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
-import org.jbpm.jpdl.xml.Problem;
-import org.jbpm.jpdl4.model.Process;
+import org.dom4j.Document;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
public class JpdlConverterTool {
public static void main(String[] args) {
@@ -48,13 +50,13 @@
if (context.get(ConverterContext.VERBOSE) != null) {
verbose = true;
}
- JpdlConverter jpdlConverter = new JpdlConverter();
- Jpdl4Writer writer = new Jpdl4Writer();
+ Jpdl3ConverterReader jpdlConverter = new Jpdl3ConverterReader((URL)context.get(context.PROCESS_FILE_URL));
+
try {
if (verbose) {
System.out.println("Loading process file from URL [" + context.get(context.PROCESS_FILE_URL) + "]...");
}
- Process process = jpdlConverter.run((URL)context.get(context.PROCESS_FILE_URL));
+ Document jpdl4Doc = jpdlConverter.readAndConvert();
if (verbose) {
System.out.println("Converting the process file to jPDL4 version....");
@@ -62,16 +64,22 @@
String outputFilePath = (String)context.get(context.OUPUTFILE);
File outputFile = new File(outputFilePath);
- java.io.OutputStream out = new java.io.FileOutputStream(outputFile);
- writer.write(process, out, true);
+ //well print xml to file
+ Writer fileWriter = new FileWriter(outputFile);
+ OutputFormat format = OutputFormat.createPrettyPrint();
+ XMLWriter writer = new XMLWriter( fileWriter, format );
+ writer.write(jpdl4Doc);
+ writer.close();
+
+
if (verbose) {
- System.out.println("Generating converted file :" + (outputFile.isAbsolute() ? outputFile.getCanonicalPath() : outputFile.getName()));
+ System.out.println("Generating converted file to:" + (outputFile.isAbsolute() ? outputFile.getAbsolutePath() : outputFile.getName()));
}
} catch (Exception e) {
- for (Problem problem : jpdlConverter.getProblems()) {
+ for (Problem problem : jpdlConverter.problems) {
if (problem.getLevel() == problem.LEVEL_WARNING) {
System.err.println(problem);
}
@@ -136,18 +144,16 @@
File tmpFile = new File(processURL.getFile());
String fileName = tmpFile.getName();
String baseName = fileName;
- String extensionName = "";
+
int index = fileName.lastIndexOf(".");
if (index > -1) {
baseName = fileName.substring(0, index);
- extensionName = index+1 < fileName.length() ? fileName.substring(index+1) : extensionName;
} else {
baseName = fileName;
}
- String outputFileName = extensionName.equals("") ? baseName + ".converted.jpdl"
- : baseName + ".converted.jpdl." + extensionName;
+ String outputFileName = baseName + ".converted.jpdl.xml";
File outFile = new File(".", outputFileName);
context.put(ConverterContext.OUPUTFILE, outFile.getAbsolutePath());
} else {
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/NodeConverterTypes.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/NodeConverterTypes.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/NodeConverterTypes.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -31,8 +31,8 @@
import org.apache.commons.logging.LogFactory;
import org.dom4j.DocumentException;
import org.dom4j.Element;
+import org.dom4j.io.SAXReader;
import org.jbpm.jpdl.internal.convert.node.Node;
-import org.dom4j.io.SAXReader;
public class NodeConverterTypes {
Deleted: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ProblemCollector.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ProblemCollector.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/ProblemCollector.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -1,30 +0,0 @@
-/*
- * 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.jpdl.internal.convert;
-
-import org.jbpm.jpdl.xml.ProblemListener;
-
-public interface ProblemCollector extends ProblemListener{
- public void addError(String description, Throwable exception);
- public void addError(String description);
- public void addWarning(String description);
-}
Deleted: jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -1,104 +0,0 @@
-/*
- * 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.jpdl.internal.convert;
-
-import java.net.URL;
-import java.util.List;
-
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
-import org.jbpm.api.Problem;
-import org.jbpm.api.env.EnvironmentFactory;
-import org.jbpm.jpdl.internal.xml.JpdlParser;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class JpdlConverterTest {
- @Test
- public void runSimpleProcessFile() throws Exception {
- testConvert("simple.xml");
- }
- @Test
- public void runAssignmentProcessFile() throws Exception {
- testConvert("assignment.xml");
- }
- @Test
- public void runBusinessTrip() throws Exception {
- testConvert("businesstrip.xml");
- }
- @Test
- public void testDescision() throws Exception {
- testConvert("testDecision.xml");
- }
- @Test
- public void testEvent() throws Exception {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString("<jbpm-configuration>"
- + " <process-engine-context>"
- + " <script-manager default-expression-language='juel'"
- + " default-script-language='juel'"
- + " read-contexts='execution, environment, process-engine' "
- + " write-context='execution'>"
- + " <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />"
- + " </script-manager>"
- + " </process-engine-context> </jbpm-configuration>");
-
- environmentFactory.openEnvironment();
- testConvert("process-event.xml");
- }
-
- @Ignore
- public void testTimer() throws Exception {
- testConvert("timer.xml");
- }
-
-
-
- @Test
- public void testWarning() throws Exception {
- URL url = getClass().getClassLoader().getResource("superstate-mail.xml");
- //Convert to process file to jpdl4
- JpdlConverter converter = new JpdlConverter();
- org.jbpm.jpdl4.model.Process process = converter.run(url);
- Assert.assertNotNull(process);
- Assert.assertEquals(converter.getProblems().size(), 3);
-
- }
-
-
- public void testConvert(String resourcefile) throws Exception {
- URL url = getClass().getClassLoader().getResource(resourcefile);
- //Convert to process file to jpdl4
- JpdlConverter converter = new JpdlConverter();
- org.jbpm.jpdl4.model.Process process = converter.run(url);
- Jpdl4Writer writer = new Jpdl4Writer();
- java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
- writer.write(process, bout, false);
-
-
- //Validate it with Jpdl4Parser
- String jpdl4xml = new String(bout.toByteArray());
- //System.out.println(jpdl4xml);
- List<Problem> problems = new JpdlParser().createParse().setString(jpdl4xml).execute().getProblems();
- Assert.assertEquals(problems.toString(), 0, problems.size());
- }
-
-}
Modified: jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterToolTest.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterToolTest.java 2009-06-18 20:34:01 UTC (rev 5063)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterToolTest.java 2009-06-19 10:59:06 UTC (rev 5064)
@@ -158,12 +158,13 @@
String fileName = getResource("simple.xml");
URL url = new URL(fileName);
File tmpFile = new File(url.getFile());
- File outputfile = new File(tmpFile.getParentFile(), "output.xml");
+ File outputfile = new File(tmpFile.getParentFile(), "tmp-output.xml");
String args[] = new String[]{"-v","-o", outputfile.getAbsolutePath(),fileName};
JpdlConverterTool.main(args);
Assert.assertTrue(outputfile.exists());
+ Assert.assertTrue(outputfile.length() > 0);
}
@Test
More information about the jbpm-commits
mailing list