Author: Grid.Qian
Date: 2008-12-26 02:38:06 -0500 (Fri, 26 Dec 2008)
New Revision: 12828
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.settings/attachedFile.properties
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/Constants.java
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/META-INF/MANIFEST.MF
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/build.properties
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.java
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.java
Log:
JBIDE-3447: change the default value of jpdl node name during bpmn -> jpdl
Added: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.settings/attachedFile.properties
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.settings/attachedFile.properties
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/.settings/attachedFile.properties 2008-12-26
07:38:06 UTC (rev 12828)
@@ -0,0 +1,2 @@
+## index of importer -> set(imports)
+#Fri Dec 26 15:31:28 CST 2008
Modified: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/META-INF/MANIFEST.MF 2008-12-25
00:22:03 UTC (rev 12827)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/META-INF/MANIFEST.MF 2008-12-26
07:38:06 UTC (rev 12828)
@@ -16,8 +16,7 @@
Bundle-Vendor: %PLUGIN_PROVIDER
Import-Package: org.eclipse.core.resources,
org.eclipse.ui.model
-Export-Package: org.dom4j,
- org.jboss.tools.jbpm.convert.b2j.translate,
+Export-Package: org.jboss.tools.jbpm.convert.b2j.translate,
org.jboss.tools.jbpm.convert.bpmnto,
org.jboss.tools.jbpm.convert.bpmnto.translate,
org.jboss.tools.jbpm.convert.bpmnto.util,
Modified: trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/build.properties
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/build.properties 2008-12-25 00:22:03
UTC (rev 12827)
+++ trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/build.properties 2008-12-26 07:38:06
UTC (rev 12828)
@@ -1,13 +1,13 @@
source.. = src/
output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- plugin.properties,\
- lib/dom4j-1.6.1.jar,\
- icons/,\
- about.html,\
- about.ini,\
- about.mappings,\
- about.properties,\
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ plugin.properties,\
+ lib/dom4j-1.6.1.jar,\
+ icons/,\
+ about.html,\
+ about.ini,\
+ about.mappings,\
+ about.properties,\
jboss_about.png
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2J.properties 2008-12-26
07:38:06 UTC (rev 12828)
@@ -1,32 +1,6 @@
-Loop_Decision=Loop_Decition
-To=to
-Space=
-Underline=_
-Folder_Name_Separator=.
-Dom_Element_Name=name
-Dom_Element_ID=id
-Width_Attribute_Name=width
-Height_Attribute_Name=height
-X_Attribute_Name=x
-Y_Attribute_Name=y
Label_Select_All=Select All
Label_Deselect_All=Deselect All
Label_Button_Browse=Browse...
-Bpmn_Diagram_Name_Suffix=_diagram
-Bpmn_Pool_Element_Name=pools
-Bpmn_Vertice_Element_Name=vertices
-Bpmn_SequenceFlow_Element_Name=sequenceEdges
-Bpmn_Href_Attribute_Name=href
-Bpmn_XmiType_Attribute_Name=type
-Bpmn_ActivityType_Attribute_Name=activityType
-Bpmn_InFlow_Attribute_Name=incomingEdges
-Bpmn_Looping_Attribute_Name=looping
-Bpmn_FlowSource_Attribute_Name=source
-Bpmn_FlowTarget_Attribute_Name=target
-Bpmn_FlowDefault_Attribute_Name=isDefault
-Bpmn_FlowOutgoings_Attribute_Name=outgoingEdges
-Bpmn_FlowIncomings_Attribute_Name=incomingEdges
-Bpmn_Element_ID=iD
Bpmn_Wizard_Title=BPMN to jPDL Conversion
Bpmn_File_Choose_WizardPage_Name=FileChoosePage
Bpmn_File_Choose_WizardPage_Title=BPMN Resources
@@ -45,37 +19,4 @@
Bpmn_Translate_Message_WizardPage_Title=Conversion Warnings and Errors
Bpmn_Translate_Message_WizardpageViewer_Title=Warnings and Errors
Bpmn_Translate_Message_WizardPage_Message=Warnings and Errors that occurred during
conversion
-Bpmn_EAnnotations_Element_Name=eAnnotations
-Bpmn_Details_Element_Name=details
-Bpmn_Value_Attribute_Name=value
-Jpdl_Suffix=jpdl
-Jpdl_Element_Decision_Suffix=Decision
-Jpdl_Element_Complete_Suffix=Complete
-Jpdl_Element_Cancel_Suffix=Cancel
-Jpdl_Element_Successful_Name=Successful?
-Jpdl_Process_Definition_Name=processdefinition.xml
-Jpdl_32_Namespace_Url=urn:jbpm.org:jpdl-3.2
-Jpdl_Process_Definition_Element_Name=process-definition
-Jpdl_Transition_Element=edge
-Jpdl_ProcessState_Element_Name=process-state
-Jpdl_SubProcess_Element_Name=sub-process
-Jpdl_Decision_Element_Name=decision
-Jpdl_Fork_Element_Name=fork
-Jpdl_Join_Element_Name=join
-Jpdl_Start_Element_Name=start-state
-Jpdl_State_Element_Name=state
-Jpdl_End_Element_Name=end-state
-Jpdl_Node_Element_Name=node
-Gpd_Definition_Name=gpd.xml
-Gpd_Layout_Element_Name=layoutConstraint
-Gpd_Element_Name=element
-Gpd_Process_Diagram_Name=root-container
-Gpd_Label_Element_Name=label
-Translate_Error_GpdFile_CanNotGenerate=Errror: Couldn't write gpd.xml:
-Translate_Error_GpdFile_CanNotWrite=Errror\: Couldn't write gpd definition to a
gpd.xml\:
-Translate_Error_JpdlProcess_Definition_Null=Errror: The JPDL process definition is null.
-Translate_Error_JpdlFile_CanNotGenerate=Errror\: Couldn't write process definition
xml\:
-Translate_Error_JpdlFile_CanNotWrite=Errror\: Couldn't write process definition to a
jpdl file\:
-Translate_Error_File_CanNotRead=Error\: Couldn't read or parse {0} file to a DOM
document\:
-Translate_Warning_Bpmn_Element_Name=Warning: The bpmn element's name is null or same
to another element's name:
-Translate_Warning_Bpmn_Element_Type=Warning\: The type of this bpmn element is not
translated to corresponding jpdl element\:
\ No newline at end of file
+Translate_Error_File_CanNotRead=Error\: Couldn't read or parse {0} file to a DOM
document\:
\ No newline at end of file
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.java 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/messages/B2JMessages.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -12,7 +12,6 @@
package org.jboss.tools.jbpm.convert.b2j.messages;
import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
/**
* @author Grid Qian
@@ -21,37 +20,9 @@
private static final String BUNDLE_NAME =
"org.jboss.tools.jbpm.convert.b2j.messages.B2J"; //$NON-NLS-1$
- private B2JMessages() {
- // Do not instantiate
- }
-
- public static String Loop_Decision;
- public static String To;
- public static String Folder_Name_Separator;
- public static String Space;
- public static String Underline;
- public static String Width_Attribute_Name;
- public static String Height_Attribute_Name;
- public static String X_Attribute_Name;
- public static String Y_Attribute_Name;
public static String Label_Select_All;
public static String Label_Deselect_All;
public static String Label_Button_Browse;
- public static String Bpmn_Diagram_Name_Suffix;
- public static String Bpmn_Pool_Element_Name;
- public static String Bpmn_Element_ID;
- public static String Bpmn_Vertice_Element_Name;
- public static String Bpmn_SequenceFlow_Element_Name;
- public static String Bpmn_Looping_Attribute_Name;
- public static String Bpmn_InFlow_Attribute_Name;
- public static String Bpmn_XmiType_Attribute_Name;
- public static String Bpmn_Href_Attribute_Name;
- public static String Bpmn_ActivityType_Attribute_Name;
- public static String Bpmn_FlowSource_Attribute_Name;
- public static String Bpmn_FlowTarget_Attribute_Name;
- public static String Bpmn_FlowDefault_Attribute_Name;
- public static String Bpmn_FlowOutgoings_Attribute_Name;
- public static String Bpmn_FlowIncomings_Attribute_Name;
public static String Bpmn_Wizard_Title;
public static String Bpmn_File_Choose_WizardPage_Name;
public static String Bpmn_File_Choose_WizardPage_Title;
@@ -70,42 +41,7 @@
public static String Bpmn_Translate_Message_WizardPage_Title;
public static String Bpmn_Translate_Message_WizardPage_Message;
public static String Bpmn_Translate_Message_WizardpageViewer_Title;
- public static String Bpmn_EAnnotations_Element_Name;
- public static String Bpmn_Details_Element_Name;
- public static String Bpmn_Value_Attribute_Name;
- public static String Jpdl_Element_Decision_Suffix;
- public static String Jpdl_Element_Complete_Suffix;
- public static String Jpdl_Element_Cancel_Suffix;
- public static String Jpdl_Element_Successful_Name;
- public static String Jpdl_Suffix;
- public static String Jpdl_Process_Definition_Name;
- public static String Jpdl_ProcessState_Element_Name;
- public static String Jpdl_SubProcess_Element_Name;
- public static String Jpdl_32_Namespace_Url;
- public static String Jpdl_Process_Definition_Element_Name;
- public static String Jpdl_Transition_Element;
- public static String Jpdl_Decision_Element_Name;
- public static String Jpdl_Fork_Element_Name;
- public static String Jpdl_Join_Element_Name;
- public static String Jpdl_Start_Element_Name;
- public static String Jpdl_State_Element_Name;
- public static String Jpdl_End_Element_Name;
- public static String Jpdl_Node_Element_Name;
- public static String Gpd_Definition_Name;
- public static String Gpd_Layout_Element_Name;
- public static String Gpd_Element_Name;
- public static String Gpd_Process_Diagram_Name;
- public static String Gpd_Label_Element_Name;
- public static String Dom_Element_Name;
- public static String Dom_Element_ID;
- public static String Translate_Error_JpdlProcess_Definition_Null;
- public static String Translate_Error_JpdlFile_CanNotWrite;
- public static String Translate_Error_JpdlFile_CanNotGenerate;
- public static String Translate_Error_GpdFile_CanNotGenerate;
- public static String Translate_Error_GpdFile_CanNotWrite;
public static String Translate_Error_File_CanNotRead;
- public static String Translate_Warning_Bpmn_Element_Name;
- public static String Translate_Warning_Bpmn_Element_Type;
static {
NLS.initializeMessages(BUNDLE_NAME, B2JMessages.class);
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.java 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/BPMN2JPDL.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -19,10 +19,9 @@
import org.dom4j.Document;
import org.dom4j.Element;
-import org.jboss.tools.jbpm.convert.bpmnto.BpmnToPlugin;
import org.jboss.tools.jbpm.convert.bpmnto.translate.BPMNTranslator;
+import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
import org.jboss.tools.jbpm.convert.bpmnto.util.DomXmlWriter;
-import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
import org.jboss.tools.jbpm.convert.b2j.translate.TranslateHelper;
/**
@@ -44,6 +43,10 @@
public BPMN2JPDL() {
}
+
+ public BPMN2JPDL(String bpmnFileName, String bpmnFilePath){
+ super(bpmnFileName, bpmnFilePath, null);
+ }
public BPMN2JPDL(String bpmnFileName, String bpmnFilePath,
Document bpmnDocument) {
@@ -69,7 +72,7 @@
strForProcessDefs[i] = DomXmlWriter.toString(def);
} catch (IOException e) {
this.errors
- .add(B2JMessages.Translate_Error_JpdlFile_CanNotGenerate
+ .add(Constants.Translate_Error_JpdlFile_CanNotGenerate
+ e.getMessage());
}
i++;
@@ -94,23 +97,11 @@
try {
TranslateHelper.createFiles(fileLocation, bpmnFileName,
strForProcessDefs, jpdlFileNames,
- B2JMessages.Jpdl_Process_Definition_Name, false);
+ Constants.Jpdl_Process_Definition_Name, false);
} catch (Exception e) {
- errors.add(B2JMessages.Translate_Error_JpdlFile_CanNotWrite
+ errors.add(Constants.Translate_Error_JpdlFile_CanNotWrite
+ e.getMessage());
}
-
- if (errors.size() != 0) {
- for (String str : errors) {
- BpmnToPlugin.getDefault().logError(str);
- }
- }
-
- if (warnings.size() != 0) {
- for (String str : warnings) {
- BpmnToPlugin.getDefault().logWarning(str);
- }
- }
}
/*
@@ -120,18 +111,27 @@
// set the namemap = null
TranslateHelper.setNameMap(new HashMap<String, Integer>());
-
+
+ if(bpmnDocument == null) {
+ try {
+ bpmnDocument = BPMNToUtil.parse(rootLocation, bpmnFileName);
+ } catch (Exception e) {
+ errors.add(Constants.Translate_Error_File_CanNotRead
+ + e.getMessage());
+ }
+ }
+
Element diagram = bpmnDocument.getRootElement();
if (this.poolIDList == null || this.poolIDList.size() == 0) {
for (Object pool : diagram
- .elements(B2JMessages.Bpmn_Pool_Element_Name)) {
+ .elements(Constants.Bpmn_Pool_Element_Name)) {
translateGraph((Element) pool);
}
} else {
for (Object pool : diagram
- .elements(B2JMessages.Bpmn_Pool_Element_Name)) {
+ .elements(Constants.Bpmn_Pool_Element_Name)) {
if (this.poolIDList.contains(((Element) pool)
- .attributeValue(B2JMessages.Bpmn_Element_ID))) {
+ .attributeValue(Constants.Bpmn_Element_ID))) {
translateGraph((Element) pool);
}
}
@@ -145,16 +145,16 @@
Document processDef = TranslateHelper.createJpdlDomTree(true);
Element processRoot = processDef.getRootElement();
- DomXmlWriter.addAttribute(processRoot, B2JMessages.Dom_Element_Name,
+ DomXmlWriter.addAttribute(processRoot, Constants.Dom_Element_Name,
TranslateHelper.generateProcessName(graph));
processDef.setName(processRoot
- .attributeValue(B2JMessages.Dom_Element_Name));
+ .attributeValue(Constants.Dom_Element_Name));
- map.put(graph.attributeValue(B2JMessages.Dom_Element_ID)
- + B2JMessages.Bpmn_Pool_Element_Name, processRoot);
+ map.put(graph.attributeValue(Constants.Dom_Element_ID)
+ + Constants.Bpmn_Pool_Element_Name, processRoot);
for (Object activity : graph.elements()) {
- if (B2JMessages.Bpmn_Vertice_Element_Name
+ if (Constants.Bpmn_Vertice_Element_Name
.equals(((Element) activity).getName())) {
translateActivity((Element) activity, processRoot);
getSequenceFlowInfo((Element)activity);
@@ -170,9 +170,9 @@
* get Incomingedges and Outgoingedges Map from the activity element
*/
private void getSequenceFlowInfo(Element activity) {
- String id = activity.attributeValue(B2JMessages.Dom_Element_ID);
- String ins = activity.attributeValue(B2JMessages.Bpmn_FlowIncomings_Attribute_Name);
- String outs = activity.attributeValue(B2JMessages.Bpmn_FlowOutgoings_Attribute_Name);
+ String id = activity.attributeValue(Constants.Dom_Element_ID);
+ String ins = activity.attributeValue(Constants.Bpmn_FlowIncomings_Attribute_Name);
+ String outs = activity.attributeValue(Constants.Bpmn_FlowOutgoings_Attribute_Name);
String[] inArray = null;
String[] outArray = null;
if(ins != null){
@@ -194,7 +194,7 @@
*/
private void translateActivity(Element activity, Element processRoot) {
String type = activity
- .attributeValue(B2JMessages.Bpmn_XmiType_Attribute_Name);
+ .attributeValue(Constants.Bpmn_XmiType_Attribute_Name);
Element element = null;
// According to bpmn activity type, map to different jpdl node
@@ -202,10 +202,10 @@
// a warining message for it.
if ("bpmn:Activity".equals(type)) {
String activityType = activity
- .attributeValue(B2JMessages.Bpmn_ActivityType_Attribute_Name);
+ .attributeValue(Constants.Bpmn_ActivityType_Attribute_Name);
if (activityType == null || "Task".equals(activityType)) {
element = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_Node_Element_Name);
+ Constants.Jpdl_Node_Element_Name);
} else if ("EventStartEmpty".equals(activityType)
|| "EventStartMessage".equals(activityType)
|| "EventStartRule".equals(activityType)
@@ -214,10 +214,10 @@
|| "EventStartMultiple".equals(activityType)
|| "EventStartSignal".equals(activityType)) {
element = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_Start_Element_Name);
+ Constants.Jpdl_Start_Element_Name);
if (!"EventStartEmpty".equals(activityType)) {
warnings
- .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ .add(Constants.Translate_Warning_Bpmn_Element_Type
+ activityType);
}
} else if ("EventIntermediateEmpty".equals(activityType)
@@ -232,10 +232,10 @@
|| "EventIntermediateSignal".equals(activityType)) {
element = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_State_Element_Name);
+ Constants.Jpdl_State_Element_Name);
if (!"EventIntermediateEmpty".equals(activityType)) {
warnings
- .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ .add(Constants.Translate_Warning_Bpmn_Element_Type
+ activityType);
}
} else if ("EventEndEmpty".equals(activityType)
@@ -249,56 +249,56 @@
|| "EventEndSignal".equals(activityType)) {
element = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_End_Element_Name);
+ Constants.Jpdl_End_Element_Name);
if (!"EventEndEmpty".equals(activityType)) {
warnings
- .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ .add(Constants.Translate_Warning_Bpmn_Element_Type
+ activityType);
}
} else if ("GatewayDataBasedExclusive".equals(activityType)
|| "GatewayEventBasedExclusive".equals(activityType)
|| "GatewayComplex".equals(activityType)) {
element = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_Decision_Element_Name);
+ Constants.Jpdl_Decision_Element_Name);
if (!"GatewayDataBasedExclusive".equals(activityType)) {
warnings
- .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ .add(Constants.Translate_Warning_Bpmn_Element_Type
+ activityType);
}
} else if ("GatewayParallel".equals(activityType)
|| "GatewayDataBasedInclusive".equals(activityType)) {
if (activity
- .attributeValue(B2JMessages.Bpmn_InFlow_Attribute_Name) == null
+ .attributeValue(Constants.Bpmn_InFlow_Attribute_Name) == null
|| activity.attributeValue(
- B2JMessages.Bpmn_InFlow_Attribute_Name).split(
- B2JMessages.Space).length == 1) {
+ Constants.Bpmn_InFlow_Attribute_Name).split(
+ Constants.Space).length == 1) {
element = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_Fork_Element_Name);
+ Constants.Jpdl_Fork_Element_Name);
} else {
element = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_Join_Element_Name);
+ Constants.Jpdl_Join_Element_Name);
}
if (!"GatewayDataBasedInclusive".equals(activityType)) {
warnings
- .add(B2JMessages.Translate_Warning_Bpmn_Element_Type
+ .add(Constants.Translate_Warning_Bpmn_Element_Type
+ activityType);
}
}
} else if ("bpmn:SubProcess".equals(type)) {
element = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_ProcessState_Element_Name);
+ Constants.Jpdl_ProcessState_Element_Name);
translateSubprocess(activity, element);
}
- if (!TranslateHelper.check_mapElementName(activity, element)) {
- warnings.add(B2JMessages.Translate_Warning_Bpmn_Element_Name
- + activity.attributeValue(B2JMessages.Bpmn_Element_ID));
+ if (!TranslateHelper.check_mapElementName(activity, element, false)) {
+ warnings.add(Constants.Translate_Warning_Bpmn_Element_Name
+ + activity.attributeValue(Constants.Bpmn_Element_ID));
}
- map.put(activity.attributeValue(B2JMessages.Dom_Element_ID), element);
+ map.put(activity.attributeValue(Constants.Dom_Element_ID), element);
// If bpmn activity is loop type, then create a structure to mock it.
if ("true".equals(activity
- .attributeValue(B2JMessages.Bpmn_Looping_Attribute_Name))) {
+ .attributeValue(Constants.Bpmn_Looping_Attribute_Name))) {
createMockLoop(activity, element);
}
}
@@ -310,20 +310,20 @@
private void translateSubprocess(Element subProcess, Element element) {
Element processRoot = translateGraph(subProcess);
Element ele = DomXmlWriter.addElement(element,
- B2JMessages.Jpdl_SubProcess_Element_Name);
- DomXmlWriter.mapAttribute(ele, B2JMessages.Dom_Element_Name,
+ Constants.Jpdl_SubProcess_Element_Name);
+ DomXmlWriter.mapAttribute(ele, Constants.Dom_Element_Name,
processRoot);
// translate the transaction of subprocess
Element eAnnot = subProcess
- .element(B2JMessages.Bpmn_EAnnotations_Element_Name);
+ .element(Constants.Bpmn_EAnnotations_Element_Name);
if (eAnnot != null) {
Element details = eAnnot
- .element(B2JMessages.Bpmn_Details_Element_Name);
+ .element(Constants.Bpmn_Details_Element_Name);
if (details != null
&& "true"
.equals(details
- .attributeValue(B2JMessages.Bpmn_Value_Attribute_Name))) {
+ .attributeValue(Constants.Bpmn_Value_Attribute_Name))) {
translateTransaction(processRoot);
}
}
@@ -340,10 +340,10 @@
}
// create a decision
Element decision = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_Decision_Element_Name);
+ Constants.Jpdl_Decision_Element_Name);
- DomXmlWriter.addAttribute(decision, B2JMessages.Dom_Element_Name,
- B2JMessages.Jpdl_Element_Successful_Name);
+ DomXmlWriter.addAttribute(decision, Constants.Dom_Element_Name,
+ Constants.Jpdl_Element_Successful_Name);
// get bpmn id from map
String bpmnId = null;
for (String key : map.keySet()) {
@@ -352,46 +352,46 @@
break;
}
}
- map.put(bpmnId + B2JMessages.Jpdl_Element_Decision_Suffix, decision);
+ map.put(bpmnId + Constants.Jpdl_Element_Decision_Suffix, decision);
// create a transition from element to decision
for (Element ele : lastEleList) {
Element transition = DomXmlWriter.addElement(ele,
- B2JMessages.Jpdl_Transition_Element);
- transition.addAttribute(B2JMessages.Dom_Element_Name, ele
- .attributeValue(B2JMessages.Dom_Element_Name)
- + B2JMessages.To + B2JMessages.Jpdl_Decision_Element_Name);
- transition.addAttribute(B2JMessages.To, decision
- .attributeValue(B2JMessages.Dom_Element_Name));
+ Constants.Jpdl_Transition_Element);
+ transition.addAttribute(Constants.Dom_Element_Name, ele
+ .attributeValue(Constants.Dom_Element_Name)
+ + Constants.To + Constants.Jpdl_Decision_Element_Name);
+ transition.addAttribute(Constants.To, decision
+ .attributeValue(Constants.Dom_Element_Name));
}
// create a complete element
Element complete = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_Node_Element_Name);
- DomXmlWriter.addAttribute(complete, B2JMessages.Dom_Element_Name,
- B2JMessages.Jpdl_Element_Complete_Suffix);
- map.put(bpmnId + B2JMessages.Jpdl_Element_Complete_Suffix, complete);
+ Constants.Jpdl_Node_Element_Name);
+ DomXmlWriter.addAttribute(complete, Constants.Dom_Element_Name,
+ Constants.Jpdl_Element_Complete_Suffix);
+ map.put(bpmnId + Constants.Jpdl_Element_Complete_Suffix, complete);
// create a cancel element
Element cancel = DomXmlWriter.addElement(processRoot,
- B2JMessages.Jpdl_Node_Element_Name);
- DomXmlWriter.addAttribute(cancel, B2JMessages.Dom_Element_Name,
- B2JMessages.Jpdl_Element_Cancel_Suffix);
- map.put(bpmnId + B2JMessages.Jpdl_Element_Cancel_Suffix, cancel);
+ Constants.Jpdl_Node_Element_Name);
+ DomXmlWriter.addAttribute(cancel, Constants.Dom_Element_Name,
+ Constants.Jpdl_Element_Cancel_Suffix);
+ map.put(bpmnId + Constants.Jpdl_Element_Cancel_Suffix, cancel);
// create transition from decision to complete element
Element toComplete = DomXmlWriter.addElement(decision,
- B2JMessages.Jpdl_Transition_Element);
- toComplete.addAttribute(B2JMessages.Dom_Element_Name, "true");
- toComplete.addAttribute(B2JMessages.To, complete
- .attributeValue(B2JMessages.Dom_Element_Name));
+ Constants.Jpdl_Transition_Element);
+ toComplete.addAttribute(Constants.Dom_Element_Name, "true");
+ toComplete.addAttribute(Constants.To, complete
+ .attributeValue(Constants.Dom_Element_Name));
// create transition from decision to cancel element
Element toCancel = DomXmlWriter.addElement(decision,
- B2JMessages.Jpdl_Transition_Element);
- toCancel.addAttribute(B2JMessages.Dom_Element_Name, "false");
- toCancel.addAttribute(B2JMessages.To, cancel
- .attributeValue(B2JMessages.Dom_Element_Name));
+ Constants.Jpdl_Transition_Element);
+ toCancel.addAttribute(Constants.Dom_Element_Name, "false");
+ toCancel.addAttribute(Constants.To, cancel
+ .attributeValue(Constants.Dom_Element_Name));
}
@@ -400,7 +400,7 @@
*/
private void translateSequenceFlows(Element graph, Element processRoot) {
for (Object edge : graph
- .elements(B2JMessages.Bpmn_SequenceFlow_Element_Name)) {
+ .elements(Constants.Bpmn_SequenceFlow_Element_Name)) {
translateSequenceFlow((Element) edge, processRoot);
}
}
@@ -410,25 +410,26 @@
*/
private void translateSequenceFlow(Element edge, Element processRoot) {
- Element source =
map.get(sourceMap.get(edge.attributeValue(B2JMessages.Dom_Element_ID)));
+ Element source =
map.get(sourceMap.get(edge.attributeValue(Constants.Dom_Element_ID)));
Element transition = null;
if ("true".equals(edge
- .attributeValue(B2JMessages.Bpmn_FlowDefault_Attribute_Name))
- && source.element(B2JMessages.Jpdl_Transition_Element) != null) {
+ .attributeValue(Constants.Bpmn_FlowDefault_Attribute_Name))
+ && source.element(Constants.Jpdl_Transition_Element) != null) {
// move default transition to the first of transition list
transition = DomXmlWriter.addElement(source,
- B2JMessages.Jpdl_Transition_Element, 0);
+ Constants.Jpdl_Transition_Element, 0);
} else {
transition = DomXmlWriter.addElement(source,
- B2JMessages.Jpdl_Transition_Element);
+ Constants.Jpdl_Transition_Element);
}
- if (!TranslateHelper.check_mapElementName(edge, transition)) {
- warnings.add(B2JMessages.Translate_Warning_Bpmn_Element_Name
- + edge.attributeValue(B2JMessages.Bpmn_Element_ID));
+ transition.addAttribute(Constants.To,map.get(targetMap.get(edge.attributeValue(Constants.Dom_Element_ID))).attributeValue(Constants.Dom_Element_Name));
+
+ if (!TranslateHelper.check_mapElementName(edge, transition, true)) {
+ warnings.add(Constants.Translate_Warning_Bpmn_Element_Name
+ + edge.attributeValue(Constants.Bpmn_Element_ID));
}
- transition.addAttribute(B2JMessages.To,map.get(targetMap.get(edge.attributeValue(B2JMessages.Dom_Element_ID))).attributeValue(B2JMessages.Dom_Element_Name));
}
/*
@@ -438,33 +439,33 @@
// create a decision
Element decision = DomXmlWriter.addElement(element.getParent(),
- B2JMessages.Jpdl_Decision_Element_Name);
+ Constants.Jpdl_Decision_Element_Name);
String name = TranslateHelper.generateElementName(activity)
- + B2JMessages.Underline + B2JMessages.Loop_Decision;
- DomXmlWriter.addAttribute(decision, B2JMessages.Dom_Element_Name, name);
+ + Constants.Underline + Constants.Loop_Decision;
+ DomXmlWriter.addAttribute(decision, Constants.Dom_Element_Name, name);
// use the decision to replace the activity in the map
- map.put(activity.attributeValue(B2JMessages.Dom_Element_ID), decision);
+ map.put(activity.attributeValue(Constants.Dom_Element_ID), decision);
// add the activity to map
- map.put(activity.attributeValue(B2JMessages.Dom_Element_ID)
- + B2JMessages.Bpmn_Vertice_Element_Name, element);
+ map.put(activity.attributeValue(Constants.Dom_Element_ID)
+ + Constants.Bpmn_Vertice_Element_Name, element);
// create a transition from element to decision
Element first = DomXmlWriter.addElement(element,
- B2JMessages.Jpdl_Transition_Element);
- first.addAttribute(B2JMessages.Dom_Element_Name, B2JMessages.To
- + B2JMessages.Underline + name);
- first.addAttribute(B2JMessages.To, decision
- .attributeValue(B2JMessages.Dom_Element_Name));
+ Constants.Jpdl_Transition_Element);
+ first.addAttribute(Constants.Dom_Element_Name, Constants.To
+ + Constants.Underline + name);
+ first.addAttribute(Constants.To, decision
+ .attributeValue(Constants.Dom_Element_Name));
// create a transition from decision to element
Element second = DomXmlWriter.addElement(decision,
- B2JMessages.Jpdl_Transition_Element);
- second.addAttribute(B2JMessages.Dom_Element_Name, B2JMessages.To
- + B2JMessages.Underline
- + element.attributeValue(B2JMessages.Dom_Element_Name));
- second.addAttribute(B2JMessages.To, element
- .attributeValue(B2JMessages.Dom_Element_Name));
+ Constants.Jpdl_Transition_Element);
+ second.addAttribute(Constants.Dom_Element_Name, Constants.To
+ + Constants.Underline
+ + element.attributeValue(Constants.Dom_Element_Name));
+ second.addAttribute(Constants.To, element
+ .attributeValue(Constants.Dom_Element_Name));
}
Added:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/Constants.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/Constants.java
(rev 0)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/Constants.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jbpm.convert.b2j.translate;
+
+/**
+ * @author Grid Qian
+ */
+public class Constants {
+
+ public static final String Loop_Decision = "Loop_Decition";
+ public static final String To = "to";
+ public static final String Space = " ";
+ public static final String Underline = "_";
+ public static final String Folder_Name_Separator = ".";
+ public static final String Dom_Element_Name = "name";
+ public static final String Dom_Element_ID = "id";
+ public static final String Width_Attribute_Name = "width";
+ public static final String Height_Attribute_Name = "height";
+ public static final String X_Attribute_Name = "x";
+ public static final String Y_Attribute_Name = "y";
+ public static final String Bpmn_Diagram_Name_Suffix = "_diagram";
+ public static final String Bpmn_Pool_Element_Name = "pools";
+ public static final String Bpmn_Vertice_Element_Name = "vertices";
+ public static final String Bpmn_SequenceFlow_Element_Name = "sequenceEdges";
+ public static final String Bpmn_Href_Attribute_Name = "href";
+ public static final String Bpmn_XmiType_Attribute_Name = "type";
+ public static final String Bpmn_ActivityType_Attribute_Name = "activityType";
+ public static final String Bpmn_InFlow_Attribute_Name = "incomingEdges";
+ public static final String Bpmn_Looping_Attribute_Name = "looping";
+ public static final String Bpmn_FlowSource_Attribute_Name = "source";
+ public static final String Bpmn_FlowTarget_Attribute_Name = "target";
+ public static final String Bpmn_FlowDefault_Attribute_Name = "isDefault";
+ public static final String Bpmn_FlowOutgoings_Attribute_Name =
"outgoingEdges";
+ public static final String Bpmn_FlowIncomings_Attribute_Name =
"incomingEdges";
+ public static final String Bpmn_Element_ID = "iD";
+ public static final String Bpmn_EAnnotations_Element_Name = "eAnnotations";
+ public static final String Bpmn_Details_Element_Name = "details";
+ public static final String Bpmn_Value_Attribute_Name = "value";
+ public static final String Jpdl_Suffix = "jpdl";
+ public static final String Jpdl_Element_Decision_Suffix = "Decision";
+ public static final String Jpdl_Element_Complete_Suffix = "Complete";
+ public static final String Jpdl_Element_Cancel_Suffix = "Cancel";
+ public static final String Jpdl_Element_Successful_Name = "Successful?";
+ public static final String Jpdl_Process_Definition_Name =
"processdefinition.xml";
+ public static final String Jpdl_32_Namespace_Url = "urn:jbpm.org:jpdl-3.2";
+ public static final String Jpdl_Process_Definition_Element_Name =
"process-definition";
+ public static final String Jpdl_Transition_Element = "transition";
+ public static final String Jpdl_ProcessState_Element_Name = "process-state";
+ public static final String Jpdl_SubProcess_Element_Name = "sub-process";
+ public static final String Jpdl_Decision_Element_Name = "decision";
+ public static final String Jpdl_Fork_Element_Name = "fork";
+ public static final String Jpdl_Join_Element_Name = "join";
+ public static final String Jpdl_Start_Element_Name = "start-state";
+ public static final String Jpdl_State_Element_Name = "state";
+ public static final String Jpdl_End_Element_Name = "end-state";
+ public static final String Jpdl_Node_Element_Name = "node";
+ public static final String Gpd_Transition_Element = "edge";
+ public static final String Gpd_Definition_Name = "gpd.xml";
+ public static final String Gpd_Layout_Element_Name = "layoutConstraint";
+ public static final String Gpd_Element_Name = "element";
+ public static final String Gpd_Process_Diagram_Name = "root-container";
+ public static final String Gpd_Label_Element_Name = "label";
+ public static final String Translate_Error_File_CanNotRead = "Error: Couldn't
read or parse the file to a DOM document:";
+ public static final String Translate_Error_JpdlFile_CanNotGenerate = "Error:
Couldn't write process definition xml: ";
+ public static final String Translate_Error_JpdlFile_CanNotWrite = "Error:
Couldn't write process definition to a jpdl file: ";
+ public static final String Translate_Warning_Bpmn_Element_Type = "Warning: The type
of this bpmn element is not translated to corresponding jpdl element: ";
+ public static final String Translate_Warning_Bpmn_Element_Name = "Warning: The bpmn
element's name is null or same to another element's name:";
+ public static final String Translate_Error_GpdFile_CanNotGenerate = "Error:
Couldn't write gpd.xml:";
+ public static final String Translate_Error_JpdlProcess_Definition_Null= "Error: The
JPDL process definition is null.";
+ public static final String Translate_Error_GpdFile_CanNotWrite="Error: Couldn't
write gpd definition to a gpd.xml:";
+
+}
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.java 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/GraphicalFileGenerator.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -19,10 +19,9 @@
import org.dom4j.Document;
import org.dom4j.Element;
-import org.jboss.tools.jbpm.convert.bpmnto.BpmnToPlugin;
import org.jboss.tools.jbpm.convert.bpmnto.translate.BPMNTranslator;
+import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
import org.jboss.tools.jbpm.convert.bpmnto.util.DomXmlWriter;
-import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
import org.jboss.tools.jbpm.convert.b2j.translate.TranslateHelper;
/**
@@ -41,11 +40,14 @@
public GraphicalFileGenerator(Document bpmnDiagramDocument,
Map<String, Element> map, String rootLocation, String bpmnFileName) {
- this.rootLocation = rootLocation;
- this.bpmnFileName = bpmnFileName;
+ super(bpmnFileName, rootLocation, null);
this.document = bpmnDiagramDocument;
this.map = map;
}
+
+ public GraphicalFileGenerator(Map<String, Element> map, String rootLocation,
String bpmnFileName) {
+ this(null, map, rootLocation, bpmnFileName);
+ }
/*
* translate a bpmn_diagram document to a gpd document string
@@ -59,7 +61,7 @@
strForProcessDefs[i] = DomXmlWriter.toString(def);
} catch (IOException e) {
this.errors
- .add(B2JMessages.Translate_Error_GpdFile_CanNotGenerate
+ .add(Constants.Translate_Error_GpdFile_CanNotGenerate
+ e.getMessage());
}
i++;
@@ -76,39 +78,37 @@
int i = 0;
for (Document def : gpdDefs) {
gpdFileNames[i] = def.getRootElement().attributeValue(
- B2JMessages.Dom_Element_Name);
+ Constants.Dom_Element_Name);
i++;
}
try {
TranslateHelper.createFiles(fileLocation, bpmnFileName,
strForGpdDefs, gpdFileNames,
- B2JMessages.Gpd_Definition_Name, false);
+ Constants.Gpd_Definition_Name, false);
} catch (Exception e) {
- errors.add(B2JMessages.Translate_Error_GpdFile_CanNotWrite
+ errors.add(Constants.Translate_Error_GpdFile_CanNotWrite
+ e.getMessage());
}
-
- if (errors.size() != 0) {
- for (String str : errors) {
- BpmnToPlugin.getDefault().logError(str);
- }
- }
-
- if (warnings.size() != 0) {
- for (String str : warnings) {
- BpmnToPlugin.getDefault().logWarning(str);
- }
- }
}
/*
* translate the graphical bpmn_diagram document
*/
public void translateDiagram() {
+
+ if(document == null) {
+ try {
+ document = BPMNToUtil.parse(rootLocation, bpmnFileName);
+ } catch (Exception e) {
+ errors.add(Constants.Translate_Error_File_CanNotRead
+ + e.getMessage());
+ }
+ }
+
Element rootElement = document.getRootElement();
List<Element> eleList = DomXmlWriter.getElementsByName(rootElement,
- B2JMessages.Gpd_Element_Name);
+ Constants.Gpd_Element_Name);
for (String bpmnID : map.keySet()) {
if (bpmnID != null) {
@@ -121,43 +121,43 @@
Element bpmnGpdEle = TranslateHelper.getDiagramLayoutElement(
bpmnID, eleList);
if (bpmnGpdEle == null) {
- if (bpmnID.endsWith(B2JMessages.Bpmn_Vertice_Element_Name)) {
+ if (bpmnID.endsWith(Constants.Bpmn_Vertice_Element_Name)) {
bpmnGpdEle = TranslateHelper.getDiagramLayoutElement(
TranslateHelper.getPureBpmnID(bpmnID,
- B2JMessages.Bpmn_Vertice_Element_Name),
+ Constants.Bpmn_Vertice_Element_Name),
eleList);
xIncre = 150;
yIncre = 50;
} else if (bpmnID
- .endsWith(B2JMessages.Jpdl_Element_Decision_Suffix)) {
+ .endsWith(Constants.Jpdl_Element_Decision_Suffix)) {
bpmnGpdEle = TranslateHelper
.getDiagramLayoutElement(
TranslateHelper
.getPureBpmnID(
bpmnID,
- B2JMessages.Jpdl_Element_Decision_Suffix),
+ Constants.Jpdl_Element_Decision_Suffix),
eleList);
xIncre = 150;
yIncre = 100;
} else if (bpmnID
- .endsWith(B2JMessages.Jpdl_Element_Complete_Suffix)) {
+ .endsWith(Constants.Jpdl_Element_Complete_Suffix)) {
bpmnGpdEle = TranslateHelper
.getDiagramLayoutElement(
TranslateHelper
.getPureBpmnID(
bpmnID,
- B2JMessages.Jpdl_Element_Complete_Suffix),
+ Constants.Jpdl_Element_Complete_Suffix),
eleList);
xIncre = 300;
yIncre = 0;
} else if (bpmnID
- .endsWith(B2JMessages.Jpdl_Element_Cancel_Suffix)) {
+ .endsWith(Constants.Jpdl_Element_Cancel_Suffix)) {
bpmnGpdEle = TranslateHelper
.getDiagramLayoutElement(
TranslateHelper
.getPureBpmnID(
bpmnID,
- B2JMessages.Jpdl_Element_Cancel_Suffix),
+ Constants.Jpdl_Element_Cancel_Suffix),
eleList);
xIncre = 300;
yIncre = 200;
@@ -181,8 +181,8 @@
// if not translate, then translate the pool of the element
if (!gpdPoolNames.contains(jpdlEle.getParent().attributeValue(
- B2JMessages.Dom_Element_Name))
- && B2JMessages.Jpdl_Process_Definition_Element_Name
+ Constants.Dom_Element_Name))
+ && Constants.Jpdl_Process_Definition_Element_Name
.equals(jpdlEle.getParent().getName())) {
translatePool(eleList, jpdlEle);
}
@@ -191,21 +191,21 @@
Element poolEle = null;
for (Document doc : gpdDefs) {
if (doc.getRootElement().attributeValue(
- B2JMessages.Dom_Element_Name).equals(
+ Constants.Dom_Element_Name).equals(
jpdlEle.getParent().attributeValue(
- B2JMessages.Dom_Element_Name))) {
+ Constants.Dom_Element_Name))) {
poolEle = doc.getRootElement();
}
}
Element pgdEle = TranslateHelper.createNode(poolEle,
- B2JMessages.Jpdl_Node_Element_Name, jpdlEle);
+ Constants.Jpdl_Node_Element_Name, jpdlEle);
TranslateHelper.mapXY(pgdEle, xy[0], xy[1]);
// translate the sequence flow of the element
- for (Object ele : jpdlEle.elements(B2JMessages.Jpdl_Transition_Element)) {
+ for (Object ele : jpdlEle.elements(Constants.Jpdl_Transition_Element)) {
TranslateHelper.createTransition(pgdEle,
- B2JMessages.Jpdl_Transition_Element, (Element) ele);
+ Constants.Gpd_Transition_Element, (Element) ele);
}
}
@@ -215,7 +215,7 @@
for (String id : map.keySet()) {
if (map.get(id) == jpdlEle.getParent()) {
poolBpmnID = TranslateHelper.getPureBpmnID(id,
- B2JMessages.Bpmn_Pool_Element_Name);
+ Constants.Bpmn_Pool_Element_Name);
break;
}
}
@@ -224,18 +224,18 @@
Element poolBpmnGpdEle = TranslateHelper.getDiagramLayoutElement(
poolBpmnID, eleList);
Document processDiagramDef = DomXmlWriter.createDomTree(false,
- null, B2JMessages.Gpd_Process_Diagram_Name);
+ null, Constants.Gpd_Process_Diagram_Name);
Element poolEle = processDiagramDef.getRootElement();
- DomXmlWriter.mapAttribute(poolEle, B2JMessages.Dom_Element_Name,
+ DomXmlWriter.mapAttribute(poolEle, Constants.Dom_Element_Name,
jpdlEle.getParent());
DomXmlWriter.mapAttribute(poolEle,
- B2JMessages.Width_Attribute_Name, poolBpmnGpdEle);
+ Constants.Width_Attribute_Name, poolBpmnGpdEle);
DomXmlWriter.mapAttribute(poolEle,
- B2JMessages.Height_Attribute_Name, poolBpmnGpdEle);
+ Constants.Height_Attribute_Name, poolBpmnGpdEle);
gpdDefs.add(processDiagramDef);
gpdPoolNames.add(poolEle
- .attributeValue(B2JMessages.Dom_Element_Name));
+ .attributeValue(Constants.Dom_Element_Name));
}
}
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.java 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/translate/TranslateHelper.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -20,8 +20,6 @@
import org.dom4j.Document;
import org.dom4j.Element;
-import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
-import org.jboss.tools.jbpm.convert.b2j.translate.TranslateHelper;
import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
import org.jboss.tools.jbpm.convert.bpmnto.util.DomXmlWriter;
@@ -43,7 +41,7 @@
* get the bpmn_diagram file name
*/
public static String getBpmnDiagramName(String bpmnFileName) {
- return bpmnFileName + B2JMessages.Bpmn_Diagram_Name_Suffix;
+ return bpmnFileName + Constants.Bpmn_Diagram_Name_Suffix;
}
/*
@@ -51,8 +49,8 @@
*/
public static Document createJpdlDomTree(boolean useNamespace) {
return DomXmlWriter.createDomTree(useNamespace,
- B2JMessages.Jpdl_32_Namespace_Url,
- B2JMessages.Jpdl_Process_Definition_Element_Name);
+ Constants.Jpdl_32_Namespace_Url,
+ Constants.Jpdl_Process_Definition_Element_Name);
}
@@ -63,7 +61,7 @@
String[] strsForGenerate, String[] fileFolders, String fileName,
boolean isOverWrite) throws IOException {
File jpdlFolder = BPMNToUtil.createFile(parentFolder,
- B2JMessages.Jpdl_Suffix, null, isOverWrite);
+ Constants.Jpdl_Suffix, null, isOverWrite);
File diagramFolder = BPMNToUtil.createFile(
jpdlFolder.getAbsolutePath(), bpmnFileName, null, false);
@@ -86,26 +84,26 @@
*/
public static String generateProcessName(Element graph) {
if ("BpmnDiagram".equals(graph.getName())) {
- return graph.attributeValue(B2JMessages.Dom_Element_Name);
+ return graph.attributeValue(Constants.Dom_Element_Name);
} else {
String str = generateProcessName(graph.getParent());
if (str == null) {
return generateElementName(graph);
} else {
- return str + B2JMessages.Folder_Name_Separator
+ return str + Constants.Folder_Name_Separator
+ generateElementName(graph);
}
}
}
-
+
/*
* generate a element name
*/
- public static String generateElementName(Element graph){
- String name = graph.attributeValue(B2JMessages.Dom_Element_Name);
+ public static String generateElementName(Element graph) {
+ String name = graph.attributeValue(Constants.Dom_Element_Name);
if (name == null || "".equals(name)) {
- name = "au_gen";
+ name = "eleName";
}
Integer i = nameMap.get(name);
if (i == null) {
@@ -120,22 +118,29 @@
* check the bpmn element name is null or "" or same to another element name
* and generate a different name
*/
- public static boolean check_mapElementName(Element graph, Element graphEle) {
+ public static boolean check_mapElementName(Element graph, Element graphEle,
+ boolean isTransition) {
boolean isOk = true;
- String name = graph.attributeValue(B2JMessages.Dom_Element_Name);
+ String name = graph.attributeValue(Constants.Dom_Element_Name);
if (name == null || "".equals(name)) {
- name = "to_nodename";
+ if (isTransition) {
+ name = Constants.To + Constants.Underline
+ + graphEle.attributeValue(Constants.To);
+ } else {
+ name = "eleName";
+ }
+
isOk = false;
}
Integer i = nameMap.get(name);
if (i == null) {
- DomXmlWriter.addAttribute(graphEle, B2JMessages.Dom_Element_Name,
+ DomXmlWriter.addAttribute(graphEle, Constants.Dom_Element_Name,
name);
nameMap.put(name, new Integer("1"));
} else {
- DomXmlWriter.addAttribute(graphEle, B2JMessages.Dom_Element_Name,
+ DomXmlWriter.addAttribute(graphEle, Constants.Dom_Element_Name,
name + "_" + i);
nameMap.put(name, ++i);
isOk = false;
@@ -152,23 +157,23 @@
public static List<Element> locateLastElements(Element processRoot) {
List<Element> list = new ArrayList<Element>();
- if (processRoot.element(B2JMessages.Jpdl_End_Element_Name) != null) {
+ if (processRoot.element(Constants.Jpdl_End_Element_Name) != null) {
Element endState = processRoot
- .element(B2JMessages.Jpdl_End_Element_Name);
+ .element(Constants.Jpdl_End_Element_Name);
for (Object ele : processRoot.elements()) {
Element subEle = ((Element) ele)
- .element(B2JMessages.Jpdl_Transition_Element);
+ .element(Constants.Jpdl_Transition_Element);
if (subEle != null
&& endState
- .attributeValue(B2JMessages.Dom_Element_Name)
- .equals(subEle.attributeValue(B2JMessages.To))) {
+ .attributeValue(Constants.Dom_Element_Name)
+ .equals(subEle.attributeValue(Constants.To))) {
list.add((Element) ele);
}
}
} else {
for (Object ele : processRoot.elements()) {
if (((Element) ele)
- .element(B2JMessages.Jpdl_Transition_Element) == null) {
+ .element(Constants.Jpdl_Transition_Element) == null) {
list.add((Element) ele);
}
}
@@ -185,7 +190,7 @@
Element element = null;
for (Element ele : eleList) {
String str = ele
- .attributeValue(B2JMessages.Bpmn_Href_Attribute_Name);
+ .attributeValue(Constants.Bpmn_Href_Attribute_Name);
if (str != null && str.contains(bpmnID)) {
element = ele;
break;
@@ -194,9 +199,9 @@
if (element != null
&& element.getParent().element(
- B2JMessages.Gpd_Layout_Element_Name) != null) {
+ Constants.Gpd_Layout_Element_Name) != null) {
return element.getParent().element(
- B2JMessages.Gpd_Layout_Element_Name);
+ Constants.Gpd_Layout_Element_Name);
}
return null;
@@ -208,10 +213,10 @@
public static Element createTransition(Element parentEle, String name,
Element jpdlEle) {
Element ele = DomXmlWriter.addElement(parentEle, name);
- DomXmlWriter.mapAttribute(ele, B2JMessages.Dom_Element_Name, jpdlEle);
+ DomXmlWriter.mapAttribute(ele, Constants.Dom_Element_Name, jpdlEle);
Element label = DomXmlWriter.addElement(ele,
- B2JMessages.Gpd_Label_Element_Name);
+ Constants.Gpd_Label_Element_Name);
TranslateHelper.mapXY(label, "5", "-10");
return ele;
}
@@ -222,8 +227,8 @@
private static Element createElement(Element parentEle, String name,
String width, String height) {
Element ele = DomXmlWriter.addElement(parentEle, name);
- DomXmlWriter.addAttribute(ele, B2JMessages.Width_Attribute_Name, width);
- DomXmlWriter.addAttribute(ele, B2JMessages.Height_Attribute_Name,
+ DomXmlWriter.addAttribute(ele, Constants.Width_Attribute_Name, width);
+ DomXmlWriter.addAttribute(ele, Constants.Height_Attribute_Name,
height);
return ele;
}
@@ -234,7 +239,7 @@
public static Element createNode(Element rootEle, String name,
Element jpdlEle) {
Element ele = TranslateHelper.createElement(rootEle, name, "100",
"40");
- DomXmlWriter.mapAttribute(ele, B2JMessages.Dom_Element_Name, jpdlEle);
+ DomXmlWriter.mapAttribute(ele, Constants.Dom_Element_Name, jpdlEle);
return ele;
}
@@ -242,9 +247,9 @@
* map bpmn x,y attribute to jpdl graphical element
*/
public static void mapXY(Element pgdEle, String x, String y) {
- DomXmlWriter.addAttribute(pgdEle, B2JMessages.X_Attribute_Name,
+ DomXmlWriter.addAttribute(pgdEle, Constants.X_Attribute_Name,
x == null ? "0" : x);
- DomXmlWriter.addAttribute(pgdEle, B2JMessages.Y_Attribute_Name,
+ DomXmlWriter.addAttribute(pgdEle, Constants.Y_Attribute_Name,
y == null ? "0" : y);
}
@@ -263,12 +268,12 @@
public static String[] getXY(Element bpmnGpdEle, int xIncre, int yIncre) {
String xy[] = new String[2];
xy[0] = String.valueOf(Integer.parseInt(bpmnGpdEle
- .attributeValue(B2JMessages.X_Attribute_Name) == null ? "0"
- : bpmnGpdEle.attributeValue(B2JMessages.X_Attribute_Name))
+ .attributeValue(Constants.X_Attribute_Name) == null ? "0"
+ : bpmnGpdEle.attributeValue(Constants.X_Attribute_Name))
+ xIncre);
xy[1] = String.valueOf(Integer.parseInt(bpmnGpdEle
- .attributeValue(B2JMessages.Y_Attribute_Name) == null ? "0"
- : bpmnGpdEle.attributeValue(B2JMessages.Y_Attribute_Name))
+ .attributeValue(Constants.Y_Attribute_Name) == null ? "0"
+ : bpmnGpdEle.attributeValue(Constants.Y_Attribute_Name))
+ yIncre);
return xy;
}
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.java 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/b2j/wizard/B2JExportWizard.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -22,7 +22,9 @@
import org.jboss.tools.jbpm.convert.b2j.translate.TranslateHelper;
import org.jboss.tools.jbpm.convert.bpmnto.BpmnToPlugin;
import org.jboss.tools.jbpm.convert.b2j.translate.BPMN2JPDL;
+import org.jboss.tools.jbpm.convert.b2j.translate.Constants;
import org.jboss.tools.jbpm.convert.b2j.translate.GraphicalFileGenerator;
+import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
import org.jboss.tools.jbpm.convert.bpmnto.wizard.BpmnToWizard;
/**
@@ -60,7 +62,7 @@
try {
TranslateHelper.createFiles(location, bpmnFileName, strs,
jpdlFolderNames,
- B2JMessages.Jpdl_Process_Definition_Name, isOverWrite);
+ Constants.Jpdl_Process_Definition_Name, isOverWrite);
} catch (Exception e) {
BpmnToPlugin.getDefault().logError(e.getMessage());
}
@@ -81,7 +83,7 @@
}
try {
TranslateHelper.createFiles(location, bpmnFileName, strs,
- jpdlFolderNames, B2JMessages.Gpd_Definition_Name, false);
+ jpdlFolderNames, Constants.Gpd_Definition_Name, false);
} catch (Exception e) {
BpmnToPlugin.getDefault().logError(e.getMessage());
}
@@ -95,7 +97,7 @@
Document bpmnDocument = null;
try {
- bpmnDocument = getDocument(bpmnFileParentPath, bpmnFileName);
+ bpmnDocument = BPMNToUtil.parse(bpmnFileParentPath, bpmnFileName);
} catch (Exception e) {
errorList.add(NLS.bind(B2JMessages.Translate_Error_File_CanNotRead,
bpmnFileName));
@@ -119,7 +121,7 @@
// generate jpdl gpd file from *.bpmn_diagram
Document bpmnDiagramDocument = null;
try {
- bpmnDiagramDocument = getDocument(bpmnFileParentPath,
+ bpmnDiagramDocument = BPMNToUtil.parse(bpmnFileParentPath,
TranslateHelper.getBpmnDiagramName(bpmnFileName));
} catch (Exception e) {
errorList.add(NLS.bind(B2JMessages.Translate_Error_File_CanNotRead,
@@ -132,7 +134,7 @@
this.setStrForGpdList(Arrays.asList(generator.translateToStrings()));
for (Document def : generator.getGpdDefs()) {
- this.generatedGpdFoldersList.add(def.getRootElement().attributeValue(B2JMessages.Dom_Element_Name));
+ this.generatedGpdFoldersList.add(def.getRootElement().attributeValue(Constants.Dom_Element_Name));
}
warningList.addAll(generator.getWarnings());
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.java 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/BPMNToUtil.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -19,7 +19,6 @@
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import javax.xml.parsers.SAXParser;
@@ -28,15 +27,7 @@
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.jboss.tools.jbpm.convert.b2j.messages.B2JMessages;
-import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
+import org.jboss.tools.jbpm.convert.b2j.translate.Constants;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -164,49 +155,14 @@
public static Map<String, String> getPoolIDsFromDocument(Document document) {
Map<String, String> poolIDMap = new HashMap<String, String>();
Element diagram = document.getRootElement();
- for (Object pool : diagram.elements(B2JMessages.Bpmn_Pool_Element_Name)) {
- if (((Element) pool).attributeValue(B2JMessages.Bpmn_Element_ID) != null) {
+ for (Object pool : diagram.elements(Constants.Bpmn_Pool_Element_Name)) {
+ if (((Element) pool).attributeValue(Constants.Bpmn_Element_ID) != null) {
poolIDMap.put(((Element) pool)
- .attributeValue(B2JMessages.Bpmn_Element_ID),
+ .attributeValue(Constants.Bpmn_Element_ID),
((Element) pool)
- .attributeValue(B2JMessages.Dom_Element_Name));
+ .attributeValue(Constants.Dom_Element_Name));
}
}
return poolIDMap;
}
-
- public static Composite createComposite(Composite parent, int numColumns) {
- Composite composite = new Composite(parent, SWT.NULL);
-
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- return composite;
- }
-
- @SuppressWarnings("unchecked")
- public static boolean checkSelectedResources(ISelection selectedResources) {
- boolean res = true;
- if (selectedResources instanceof IStructuredSelection
- && !selectedResources.isEmpty()) {
- IStructuredSelection ss = (IStructuredSelection) selectedResources;
- for (Iterator it = ss.iterator(); it.hasNext();) {
- Object o = it.next();
- if (o instanceof IFile) {
- if (!((IFile) o).getFileExtension()
- .equalsIgnoreCase("bpmn")) {
- res = false;
- break;
- }
- } else {
- res = false;
- break;
- }
- }
- } else {
- res = false;
- }
- return res;
- }
}
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.java 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/util/DomXmlWriter.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -17,7 +17,6 @@
import org.dom4j.*;
import org.dom4j.io.*;
-import org.jboss.tools.jbpm.convert.bpmnto.util.DomXmlWriter;
/**
* @author Grid Qian
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.java 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BPMNResourcesChoicePage.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -11,6 +11,8 @@
package org.jboss.tools.jbpm.convert.bpmnto.wizard;
+import java.util.Iterator;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@@ -29,7 +31,6 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.jboss.tools.jbpm.convert.bpmnto.util.BPMNToUtil;
/**
* @author Grid Qian
@@ -77,7 +78,7 @@
@Override
public boolean isPageComplete() {
if (viewer != null) {
- return BPMNToUtil.checkSelectedResources(viewer.getSelection());
+ return this.checkSelectedResources(viewer.getSelection());
}
return super.isPageComplete();
}
@@ -89,6 +90,31 @@
public ISelection getSelection() {
return currentSelection;
}
+
+ @SuppressWarnings("unchecked")
+ public boolean checkSelectedResources(ISelection selectedResources) {
+ boolean res = true;
+ if (selectedResources instanceof IStructuredSelection
+ && !selectedResources.isEmpty()) {
+ IStructuredSelection ss = (IStructuredSelection) selectedResources;
+ for (Iterator it = ss.iterator(); it.hasNext();) {
+ Object o = it.next();
+ if (o instanceof IFile) {
+ if (!((IFile) o).getFileExtension()
+ .equalsIgnoreCase("bpmn")) {
+ res = false;
+ break;
+ }
+ } else {
+ res = false;
+ break;
+ }
+ }
+ } else {
+ res = false;
+ }
+ return res;
+ }
}
class ProjectFilter extends ViewerFilter {
Modified:
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.java
===================================================================
---
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.java 2008-12-25
00:22:03 UTC (rev 12827)
+++
trunk/jbpm/plugins/org.jboss.tools.jbpm.convert/src/org/jboss/tools/jbpm/convert/bpmnto/wizard/BpmnToWizard.java 2008-12-26
07:38:06 UTC (rev 12828)
@@ -15,7 +15,6 @@
import java.util.List;
import java.util.Map;
-import org.dom4j.Document;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@@ -117,7 +116,7 @@
bpmnFileParentPath = bpmnFile.getParent().getLocation()
.toOSString();
try {
- idMap = BPMNToUtil.getPoolIDsFromDocument(getDocument(
+ idMap = BPMNToUtil.getPoolIDsFromDocument(BPMNToUtil.parse(
bpmnFileParentPath, bpmnFileName));
poolIdList.clear();
} catch (Exception e) {
@@ -173,15 +172,6 @@
return container.getLocation().toOSString();
}
- /*
- * get the dom document from a given path and file name
- */
- public Document getDocument(String bpmnFileParentPath, String bpmnFileName)
- throws Exception {
- Document bpmnDocument = null;
- bpmnDocument = BPMNToUtil.parse(bpmnFileParentPath, bpmnFileName);
- return bpmnDocument;
- }
/*
* refresh eclipse workspace