[savara-commits] savara SVN: r475 - in trunk/bundles: org.jboss.savara.bpel and 17 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Nov 18 06:04:57 EST 2010
Author: objectiser
Date: 2010-11-18 06:04:51 -0500 (Thu, 18 Nov 2010)
New Revision: 475
Added:
trunk/bundles/org.jboss.savara.bpel/
trunk/bundles/org.jboss.savara.bpel/.classpath
trunk/bundles/org.jboss.savara.bpel/.project
trunk/bundles/org.jboss.savara.bpel/.settings/
trunk/bundles/org.jboss.savara.bpel/.settings/org.eclipse.jdt.core.prefs
trunk/bundles/org.jboss.savara.bpel/.settings/org.eclipse.pde.core.prefs
trunk/bundles/org.jboss.savara.bpel/Copyright.txt
trunk/bundles/org.jboss.savara.bpel/META-INF/
trunk/bundles/org.jboss.savara.bpel/META-INF/MANIFEST.MF
trunk/bundles/org.jboss.savara.bpel/build.properties
trunk/bundles/org.jboss.savara.bpel/pom.xml
trunk/bundles/org.jboss.savara.bpel/src/
trunk/bundles/org.jboss.savara.bpel/src/java/
trunk/bundles/org.jboss.savara.bpel/src/java/org/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/export/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/export/BPELLanguageModelStreamExportRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/generator/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/generator/GeneratorUtil.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/BPELLanguageModel.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/BPELNotation.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/DefaultBPELLanguageModel.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/AbstractBPELModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationInteractionModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/IfModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/InteractionPatterns.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/LanguageToConversationModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ModelChangeUtils.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/RunModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/SpawnModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/WhenModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/WhileModelChangeRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/AbstractCondition.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/AbstractInteraction.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELActivity.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElement.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElementFactory.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELGroupingConstruct.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Catch.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/CatchAll.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/CompensationHandler.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Condition.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ConversionContext.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/DefaultConversionContext.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Else.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Elseif.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/EventHandlers.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Exit.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/FaultHandlers.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Flow.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/For.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ForEach.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/If.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Import.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Invoke.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Link.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnAlarm.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnEvent.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnMessage.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/PartnerLink.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Pick.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Process.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Receive.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/RepeatUntil.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Reply.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Rethrow.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Scope.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ScopeActivity.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Sequence.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Source.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Target.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/TerminationHandler.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Throw.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Until.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Variable.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Wait.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/While.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/util/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/util/InteractionUtil.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/util/TypeReferenceUtil.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/osgi/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/osgi/Activator.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/parser/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/parser/BPELModelParserRule.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/parser/BPELTokenizer.java
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/util/
trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/util/XMLUtils.java
Modified:
trunk/bundles/pom.xml
Log:
Initial BPEL OSGi bundle implementation.
Added: trunk/bundles/org.jboss.savara.bpel/.classpath
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/.classpath (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/.classpath 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/bundles/org.jboss.savara.bpel/.project
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/.project (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/.project 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.savara.bpel</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/bundles/org.jboss.savara.bpel/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/.settings/org.eclipse.jdt.core.prefs 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,8 @@
+#Thu Nov 18 09:33:42 GMT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/bundles/org.jboss.savara.bpel/.settings/org.eclipse.pde.core.prefs
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/.settings/org.eclipse.pde.core.prefs (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/.settings/org.eclipse.pde.core.prefs 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,5 @@
+#Thu Nov 18 09:33:42 GMT 2010
+eclipse.preferences.version=1
+pluginProject.equinox=false
+pluginProject.extensions=false
+resolve.requirebundle=false
Added: trunk/bundles/org.jboss.savara.bpel/Copyright.txt
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/Copyright.txt (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/Copyright.txt 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,17 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
Added: trunk/bundles/org.jboss.savara.bpel/META-INF/MANIFEST.MF
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/META-INF/MANIFEST.MF (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/META-INF/MANIFEST.MF 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,34 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss SAVARA BPEL
+Bundle-SymbolicName: org.jboss.savara.bpel
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.jboss.savara.bpel.osgi.Activator
+Bundle-Vendor: www.savara.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.lang.model;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.eclipse;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.parser;bundle-version="[1.0.0,2.0.0)",
+ org.apache.commons.logging,
+ org.scribble.expression.xpath;bundle-version="[1.0.0,2.0.0)",
+ org.jboss.savara.pi4soa.cdm;resolution:=optional,
+ org.jboss.savara.contract.model,
+ org.jboss.savara.wsdl
+Scribble-Extensions: org.jboss.savara.bpel.parser.BPELTokenizer,
+ org.jboss.savara.bpel.parser.BPELModelParserRule,
+ org.jboss.savara.bpel.model.BPELNotation,
+ org.jboss.savara.bpel.model.change.LanguageToConversationModelChangeRule,
+ org.jboss.savara.bpel.model.change.ConversationChangeRule,
+ org.jboss.savara.bpel.model.change.WhileModelChangeRule,
+ org.jboss.savara.bpel.model.change.WhenModelChangeRule,
+ org.jboss.savara.bpel.model.change.IfModelChangeRule,
+ org.jboss.savara.bpel.model.change.RunModelChangeRule,
+ org.jboss.savara.bpel.model.change.SpawnModelChangeRule,
+ org.jboss.savara.bpel.model.change.ConversationInteractionModelChangeRule
+Export-Package: org.jboss.savara.bpel.model;x-friends:="org.jboss.savara.tools.bpel.tests",
+ org.jboss.savara.bpel.model.change;x-friends:="org.jboss.savara.tools.bpel.tests",
+ org.jboss.savara.bpel.model.component;x-friends:="org.jboss.savara.tools.bpel.tests",
+ org.jboss.savara.bpel.util;x-friends:="org.jboss.savara.tools.bpel.tests"
Added: trunk/bundles/org.jboss.savara.bpel/build.properties
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/build.properties (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/build.properties 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,4 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/bundles/org.jboss.savara.bpel/pom.xml
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/pom.xml (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/pom.xml 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,16 @@
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.savara.bundles</groupId>
+ <artifactId>org.jboss.savara.bpel</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Savara::Bundles::BPEL</name>
+
+ <parent>
+ <groupId>org.jboss.savara</groupId>
+ <artifactId>bundles</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+</project>
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/export/BPELLanguageModelStreamExportRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/export/BPELLanguageModelStreamExportRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/export/BPELLanguageModelStreamExportRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.export;
+
+import java.io.IOException;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.jboss.savara.bpel.model.BPELNotation;
+import org.jboss.savara.bpel.util.XMLUtils;
+import org.scribble.export.ExportRule;
+import org.scribble.export.ExporterContext;
+import org.scribble.export.Formatter;
+import org.scribble.export.stream.AbstractModelStreamExportRule;
+import org.scribble.export.stream.StreamFormatter;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelObject;
+
+/**
+ * This class implements the stream based export rule for the
+ * BPELLanguageModel entity.
+ */
+ at RegistryInfo(extension=ExportRule.class,notation=BPELNotation.NOTATION_CODE)
+public class BPELLanguageModelStreamExportRule extends AbstractModelStreamExportRule {
+
+ /**
+ * This method determines whether the exporter rule is appropriate
+ * for the supplied model object and format.
+ *
+ * @param modelObject The model object
+ * @param format The format
+ * @return Whether the rule is appropriate for the model object and
+ * format
+ */
+ public boolean isSupported(ModelObject modelObject, Formatter format) {
+ return(super.isSupported(modelObject, format) &&
+ BPELLanguageModel.class.isAssignableFrom(modelObject.getClass()));
+ }
+
+ /**
+ * This method exports the model object.
+ *
+ * @param modelObject The model object
+ * @param context The context
+ * @throws IOException Failed to record export information
+ */
+ public void export(ModelObject modelObject, ExporterContext context)
+ throws java.io.IOException {
+ BPELLanguageModel model=(BPELLanguageModel)modelObject;
+ StreamFormatter formatter=(StreamFormatter)context.getFormatter();
+
+ try {
+ String text=XMLUtils.toText(model.getBPELProcess().getDOMElement());
+ formatter.record(text.getBytes());
+
+ } catch(Exception e) {
+ throw new java.io.IOException("Failed to get BPEL process text");
+ }
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/generator/GeneratorUtil.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/generator/GeneratorUtil.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/generator/GeneratorUtil.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.generator;
+
+import org.scribble.model.Role;
+
+/**
+ * This class provides general utility functions for
+ * use when generating artefacts.
+ */
+public class GeneratorUtil {
+
+ /**
+ * This method returns the WSDL file name for the supplied role and local
+ * conversation model.
+ *
+ * @param role The role
+ * @param localcm The local conversation model
+ * @param fileNum The file name (zero being the main wsdl file)
+ * @return The file name
+ */
+ public static String getWSDLFileName(Role role, String modelName, String suffix) {
+ return(modelName+"_"+role.getName()+suffix+".wsdl");
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/BPELLanguageModel.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/BPELLanguageModel.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/BPELLanguageModel.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model;
+
+import org.jboss.savara.bpel.model.component.Process;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This class represents a BPEL model.
+ *
+ * @author gary
+ */
+public interface BPELLanguageModel {
+
+ /**
+ * This method validates the ESB model and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l);
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getModelReference();
+
+ /**
+ * This textual contents of the model.
+ *
+ * @return The textual contents
+ */
+ public String getOriginalContents();
+
+ /**
+ * This method returns the BPEL Process.
+ *
+ * @return The BPEL Process
+ */
+ public Process getBPELProcess();
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/BPELNotation.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/BPELNotation.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/BPELNotation.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * The notation class for the BPEL language.
+ */
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class BPELNotation extends org.scribble.model.AbstractNotation {
+
+ public static final String NOTATION_CODE = "bpel";
+
+ /**
+ * This is the default constructor for the BPEL notation.
+ */
+ public BPELNotation() {
+ super(NOTATION_CODE, "BPEL", false);
+ }
+
+ /**
+ * This method returns the initial description associated
+ * with the supplied reference.
+ *
+ * @param ref The reference
+ * @return The initial description, or null if no description
+ */
+ @Override
+ public String getInitialDescription(ModelReference ref) {
+ StringBuffer buf=new StringBuffer();
+
+ return(buf.toString());
+ }
+
+ /**
+ * This method returns the optional 'super' notation.
+ * If defined, then this notation is a derived notation
+ * from the 'super' notation.
+ *
+ * @return The optional 'super' notation
+ */
+ @Override
+ public Notation getSuperNotation() {
+ return(m_superNotation);
+ }
+
+ private Notation m_superNotation=new org.scribble.conversation.model.ConversationNotation();
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/DefaultBPELLanguageModel.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/DefaultBPELLanguageModel.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/DefaultBPELLanguageModel.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,188 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model;
+
+//import org.apache.commons.logging.*;
+import org.jboss.savara.bpel.model.component.Process;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.model.*;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.model.resolutions.*;
+
+/**
+ * This class represents a BPEL model.
+ *
+ * @author gary
+ */
+public class DefaultBPELLanguageModel extends org.scribble.lang.model.LanguageModel
+ implements BPELLanguageModel {
+
+ private static final long serialVersionUID = 7625564863751533521L;
+
+ public static final String BPEL_NOTATION = "bpel";
+
+ /**
+ * This constructor is initialized with the BPEL description.
+ *
+ * @param source The model reference for the BPEL source
+ * @param elem The BPEL document
+ * @param contents The textual contents
+ */
+ public DefaultBPELLanguageModel(ModelReference source, org.w3c.dom.Element elem,
+ String contents, Context context) {
+ m_source = source;
+ m_contents = contents;
+ m_bpelProcess = new Process(this, elem);
+
+ Namespace ns=new Namespace();
+ ns.setName(source.getNamespace());
+ setNamespace(ns);
+
+ // Initialize the existing model
+ Conversation conv=m_bpelProcess.convert(context);
+
+ if (conv != null) {
+ getConversations().add(conv);
+ } else {
+ // Log error?
+ }
+ }
+
+ /**
+ * This constructor initializes a new BPEL process.
+ *
+ * @param source The model reference for the BPEL description
+ */
+ public DefaultBPELLanguageModel(ModelReference source) {
+ m_source = source;
+
+ m_bpelProcess = new Process(this);
+ }
+
+ /**
+ * This method returns the source model reference.
+ *
+ * @return The source model reference
+ */
+ public ModelReference getModelReference() {
+ return(m_source);
+ }
+
+ /**
+ * Generate a key for use in accessing the service related to
+ * the supplied category and name.
+ *
+ * @param category The category
+ * @param name The service name
+ * @return The key
+ */
+ protected String getKey(String category, String name) {
+ return(category+"/"+name);
+ }
+
+ /**
+ * This method validates the ESB model and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l) {
+
+ }
+
+ /**
+ * This textual contents of the model.
+ *
+ * @return The textual contents
+ */
+ public String getOriginalContents() {
+ return(m_contents);
+ }
+
+ /**
+ * This method returns the BPEL Process.
+ *
+ * @return The BPEL Process
+ */
+ public Process getBPELProcess() {
+ return(m_bpelProcess);
+ }
+
+ //private static Log logger = LogFactory.getLog(DefaultBPELLanguageModel.class);
+
+ private ModelReference m_source=null;
+ private Process m_bpelProcess=null;
+ private String m_contents=null;
+
+ public class InnerModelListener implements ModelListener {
+
+ public InnerModelListener(ModelListener l) {
+ m_listener = l;
+ }
+
+ public void error(ModelIssue issue) {
+
+ /*
+ issue.getProperties().put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL, m_source);
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_START_POSITION,
+ issue.getModelObject().getSource().getStartPosition());
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_END_POSITION,
+ issue.getModelObject().getSource().getEndPosition());
+ if (issue.getModelObject().getSource().getComponentURI() != null) {
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_COMPONENT,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ */
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_source);
+ res.setSourceReference(issue.getModelObject().getSource());
+
+ issue.getResolutions().add(res);
+
+ m_listener.error(issue);
+ }
+
+ public void warning(ModelIssue issue) {
+ /*
+ issue.getProperties().put(ModelListener.RESOLUTIONS, ModelListener.SHOW_REFERENCE_DESCRIPTION_RESOLUTION);
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL, m_source);
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_START_POSITION,
+ issue.getModelObject().getSource().getStartPosition());
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_END_POSITION,
+ issue.getModelObject().getSource().getEndPosition());
+ if (issue.getModelObject().getSource().getComponentURI() != null) {
+ issue.getProperties().put(ModelListener.REFERENCE_MODEL_COMPONENT,
+ issue.getModelObject().getSource().getComponentURI());
+ }
+ */
+
+ ShowReferencedDescription res=new ShowReferencedDescription();
+ res.setModel(m_source);
+ res.setSourceReference(issue.getModelObject().getSource());
+
+ issue.getResolutions().add(res);
+
+ m_listener.warning(issue);
+ }
+
+ private ModelListener m_listener=null;
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/AbstractBPELModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/AbstractBPELModelChangeRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/AbstractBPELModelChangeRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.component.Sequence;
+
+/**
+ * This is the abstract ESB model change rule.
+ */
+public abstract class AbstractBPELModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (context.getParent() instanceof Sequence &&
+ model instanceof BPELLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ return(ret);
+ }
+
+ /**
+ * This method removes the supplied model object from the
+ * supplied model. The model object representation must
+ * contain the necessary model specific to remove the
+ * object from the underlying model representation.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object to be deleted
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean delete(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ return(ret);
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationChangeRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationChangeRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,243 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import org.jboss.savara.bpel.generator.GeneratorUtil;
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.component.*;
+import org.jboss.savara.bpel.model.component.Import;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.jboss.savara.contract.model.Contract;
+import org.jboss.savara.contract.model.Interface;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Conversation.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class ConversationChangeRule extends AbstractModelChangeRule {
+
+ //private static final String NAME_SUFFIX = "_main";
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Conversation &&
+ model instanceof DefaultBPELLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+ Conversation conv=(Conversation)mobj;
+ String roleNamespace=null;
+
+ Sequence seq=new Sequence(bpelModel);
+
+ // Check if root conversation
+ if (conv.getParent() instanceof Model) {
+
+ // Set the name of the process
+ bpelModel.getBPELProcess().setName(conv.getLocatedName().getName()+"_"+
+ conv.getLocatedName().getRole().getName());
+
+ // Get contract
+ Contract contract=ModelChangeUtils.getContract(context, conv.getLocatedName().getRole().getName());
+
+ if (contract != null) {
+ roleNamespace = contract.getNamespace();
+
+ // Set namespace
+ bpelModel.getBPELProcess().setTargetNamespace(contract.getNamespace());
+
+ // Add other namespaces
+ for (org.jboss.savara.contract.model.Namespace ns : contract.getNamespaces()) {
+ bpelModel.getBPELProcess().initNamespace(ns.getURI(), ns.getPrefix());
+ }
+ }
+
+ String namespace=((Model)conv.getModel()).
+ getNamespace().getName();
+
+ String ctype=null;
+
+ // Check if conversation has a 'conforms to' reference
+ if (conv.getConformsTo().size() > 0) {
+ // Set conversation type based on first 'conforms to'
+ // reference
+ ConformanceReference cref=conv.getConformsTo().get(0);
+
+ ctype = cref.getNamespace()+"."+
+ cref.getLocalpart()+"@"+
+ cref.getLocatedRole();
+ } else {
+ // Set conversation type based on conversation
+ // namespace and name
+ ctype = namespace+"."+
+ conv.getLocatedName().getName()+"@"+
+ conv.getLocatedName().getRole().getName();
+ }
+
+ if (ctype != null) {
+ bpelModel.getBPELProcess().setConversationType(ctype);
+ }
+
+ // Add import for this role
+ addImport(context, bpelModel, conv, context.getRole());
+
+ // Add import statements for partner roles
+ java.util.List<Role> roles=conv.getRoles();
+
+ for (int i=0; i < roles.size(); i++) {
+ addImport(context, bpelModel, conv, roles.get(i));
+ }
+
+ // Add import for partner link types
+ Import imp=new Import(bpelModel);
+ imp.setLocation(bpelModel.getBPELProcess().getName()+"Artifacts.wsdl");
+ imp.setNamespace(roleNamespace);
+ imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
+
+ bpelModel.getBPELProcess().addImport(imp, -1);
+
+ // Add sequence to model
+ bpelModel.getBPELProcess().setActivity(seq);
+
+ } else if (context.getParent() instanceof Sequence) {
+
+ // Create a scope
+ Scope scope=new Scope(bpelModel);
+
+ ((Sequence)context.getParent()).addActivity(scope, -1);
+
+ // NOTE: Currently needs to be added after adding scope
+ // to parent sequence, as otherwise the DOM element
+ // associated with the 'seq' sequence becomes
+ // disconnected from the actual document - due to
+ // the fact that added elements are copied (in
+ // turn due to an xml parser exception).
+ scope.setActivity(seq);
+ }
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=conv.getBlock().getContents();
+
+ Object parent=context.getParent();
+
+ context.setParent(seq);
+
+ for (int i=0; i < acts.size(); i++) {
+ if ((acts.get(i) instanceof Definition) == false) {
+ context.insert(model, acts.get(i), null);
+ }
+ }
+
+ // Reset old parent
+ context.setParent(parent);
+
+ return(true);
+ }
+
+ /**
+ * This method adds an import statement for the contract associated with the
+ * supplied role.
+ *
+ * @param context The context
+ * @param bpelModel The model
+ * @param conv The conversation
+ * @param role The role
+ */
+ protected void addImport(ModelChangeContext context, DefaultBPELLanguageModel bpelModel,
+ Conversation conv, Role role) {
+ if (role.getAnnotations().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)role.getAnnotations().get(Contract.class.getName());
+
+ boolean gen=false;
+
+ java.util.Iterator<Interface> iter=contract.getInterfaces().iterator();
+
+ while (gen == false && iter.hasNext()) {
+ Interface intf=iter.next();
+
+ if (intf.getMessageExchangePatterns().size() > 0) {
+ gen = true;
+ }
+ }
+
+ if (gen) {
+ String fileName=GeneratorUtil.getWSDLFileName(role,
+ conv.getLocatedName().getName(), "");
+
+ Import imp=new Import(bpelModel);
+
+ imp.setLocation(fileName);
+ imp.setNamespace(contract.getNamespace());
+ imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
+
+ bpelModel.getBPELProcess().addImport(imp, -1);
+ }
+ }
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationInteractionModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationInteractionModelChangeRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ConversationInteractionModelChangeRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,472 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.component.*;
+import org.jboss.savara.bpel.model.util.*;
+import org.jboss.savara.wsdl.generator.WSDLGeneratorUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.jboss.savara.contract.model.Contract;
+import org.jboss.savara.contract.model.Interface;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Conversation Interaction.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class ConversationInteractionModelChangeRule extends AbstractBPELModelChangeRule {
+
+ private static final String INTERFACE_NAME = "interfaceName";
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj,
+ ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationInteraction &&
+ super.isInsertSupported(context, model, mobj, ref)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ BPELLanguageModel bpelModel=(BPELLanguageModel)model;
+ ConversationInteraction interaction=(ConversationInteraction)mobj;
+ boolean ret=false;
+ AbstractInteraction act=null;
+ PartnerLink pl=new PartnerLink(bpelModel);
+ Role role=null;
+ String portType=null;
+ String varName=null; //InteractionPatterns.getVariableName(interaction);
+ Interface intf=null;
+
+ if (interaction.getEnclosingDefinition() != null) {
+ role = interaction.getEnclosingDefinition().
+ getLocatedName().getRole();
+ }
+
+ // Identify port type role
+ String prefix=null;
+
+ String mainPrefix=null;
+
+ Contract contract=ModelChangeUtils.getContract(context, context.getRole().getName());
+ if (contract != null) {
+ mainPrefix = bpelModel.getBPELProcess().addNamespace(contract.getNamespace());
+ }
+
+ Role roleType=null;
+
+ if (InteractionUtil.isRequest(interaction)) {
+ roleType = interaction.getToRole();
+ if (roleType == null) {
+ roleType = role;
+ }
+ } else {
+ roleType = interaction.getFromRole();
+ if (roleType == null) {
+ roleType = role;
+ }
+ }
+
+ if (roleType != null) {
+ contract = ModelChangeUtils.getContract(context, roleType.getName());
+
+ if (contract != null) {
+ if (interaction.getAnnotations().containsKey(INTERFACE_NAME)) {
+ String intfName=(String)interaction.getAnnotations().get(INTERFACE_NAME);
+ intf = contract.getInterface(intfName);
+
+ if (intf == null) {
+ // Try localpart
+ javax.xml.namespace.QName qname=javax.xml.namespace.QName.valueOf(intfName);
+ intf = contract.getInterface(qname.getLocalPart());
+ }
+ } else if (contract.getInterfaces().size() > 0) {
+ intf = contract.getInterfaces().iterator().next();
+ }
+ }
+ }
+
+ if (intf != null) {
+ portType = intf.getName();
+
+ prefix = bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ portType = prefix+":"+portType;
+ }
+ }
+
+ // Create variable
+ //if (varName != null) {
+ QName qname=null;
+ if (InteractionUtil.isRequest(interaction)) {
+ qname = WSDLGeneratorUtil.getRequestMessageType(contract.getNamespace(),
+ interaction.getMessageSignature().getOperation());
+ } else if (InteractionPatterns.isFaultResponse(interaction)) {
+ qname = WSDLGeneratorUtil.getFaultMessageType(contract.getNamespace(),
+ InteractionPatterns.getFaultName(interaction));
+ } else {
+ qname = WSDLGeneratorUtil.getResponseMessageType(contract.getNamespace(),
+ interaction.getMessageSignature().getOperation());
+ }
+
+ varName = qname.getLocalPart()+"Var";
+
+ org.jboss.savara.bpel.model.component.Variable var=
+ bpelModel.getBPELProcess().getVariable(varName);
+
+ if (var == null) {
+ var = new org.jboss.savara.bpel.model.component.Variable(bpelModel);
+ var.setName(varName);
+
+ String mesgType=qname.getLocalPart();
+
+ // Find namespace prefix
+ if (qname.getNamespaceURI() != null) {
+ String pfix=bpelModel.getBPELProcess().addNamespace(qname.getNamespaceURI());
+
+ if (pfix != null) {
+ mesgType = pfix+":"+mesgType;
+ }
+ }
+
+ var.setMessageType(mesgType);
+
+ bpelModel.getBPELProcess().addVariable(var, -1);
+ }
+ //}
+
+ // Check if send or receive
+ if (InteractionUtil.isSend(interaction)) {
+
+ // TODO: Record variables against relevant interaction
+ // based activity - probably only mechanism for
+ // establishing message type
+
+ if (InteractionUtil.isRequest(interaction)) {
+
+ if (InteractionPatterns.isFaultHandlerRequired(interaction)) {
+
+ Scope scope=new Scope(bpelModel);
+
+ if (context.getParent() instanceof Sequence) {
+ ((Sequence)context.getParent()).addActivity(scope, -1);
+ }
+
+ FaultHandlers fhs=new FaultHandlers(bpelModel);
+
+ Sequence seq=new Sequence(bpelModel);
+
+ scope.setActivity(seq);
+ scope.setFaultHandlers(fhs);
+
+ context.setParent(scope.getActivity());
+ }
+
+ act = new Invoke(bpelModel);
+
+ pl.setPartnerRole(interaction.getToRole().getName()+"Requester");
+ pl.setName(role.getName()+"To"+interaction.getToRole().getName());
+
+ String plt=role.getName()+"To"+interaction.getToRole().getName()+"LT";
+
+ if (mainPrefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
+
+ //portType = interaction.getToRole().getName()+"PT";
+
+ if (varName != null) {
+ ((Invoke)act).setInputVariable(varName);
+ }
+
+ } else {
+ act = new Reply(bpelModel);
+
+ pl.setMyRole(role.getName()+"Service");
+ pl.setName(interaction.getToRole().getName()+"To"+role.getName());
+
+ String plt=interaction.getToRole().getName()+"To"+role.getName()+"Service"+"LT";
+
+ if (mainPrefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
+
+ //portType = role.getName()+"PT";
+
+ if (InteractionPatterns.isFaultResponse(interaction)) {
+ String faultName=InteractionPatterns.getFaultName(interaction);
+
+ // Find namespace prefix
+ //if (intf != null) {
+ // String prefix=bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ faultName = prefix+":"+faultName;
+ }
+ //}
+
+ ((Reply)act).setFaultName(faultName);
+ }
+
+ if (varName != null) {
+ ((Reply)act).setVariable(varName);
+ }
+ }
+ } else if (InteractionPatterns.isResponseInFaultHandler(interaction) == false) {
+
+ if (InteractionPatterns.isSyncNormalResponse(interaction)) {
+
+ //System.out.println("ADD RESP VAR TO PRECEDING");
+ if (context.getParent() instanceof Sequence) {
+ java.util.List<BPELActivity> acts=
+ ((Sequence)context.getParent()).getActivities();
+
+ if (acts.size() > 0 &&
+ acts.get(acts.size()-1) instanceof Invoke) {
+ Invoke invoke=(Invoke)acts.get(acts.size()-1);
+
+ invoke.setOutputVariable(varName);
+ }
+ }
+
+ } else if (InteractionPatterns.isInteractionPickPathTrigger(interaction) == false) {
+ act = new Receive(bpelModel);
+
+ String intfName=(String)interaction.getAnnotations().get("interfaceName");
+
+ if (intfName != null && intfName.trim().length() > 0) {
+ intfName = javax.xml.namespace.QName.valueOf(intfName).getLocalPart();
+ } else {
+ intfName = role.getName();
+ }
+
+ if (InteractionUtil.isRequest(interaction)) {
+
+ pl.setMyRole(intfName); //role.getName()+"Service");
+ //pl.setPartnerRole(interaction.getToRole().getName());
+ pl.setName(interaction.getFromRole().getName()+"To"+role.getName());
+
+ String plt=interaction.getFromRole().getName()+"To"+role.getName()+"Service"+"LT";
+
+ if (mainPrefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
+
+ //portType = role.getName()+"PT";
+ } else {
+ pl.setMyRole(intfName); //role.getName()+"Requester");
+ pl.setPartnerRole(interaction.getFromRole().getName()+"Service");
+ pl.setName(role.getName()+"To"+interaction.getFromRole().getName());
+
+ String plt=role.getName()+"To"+interaction.getFromRole().getName()+"Requester"+"LT";
+
+ if (mainPrefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
+
+ //portType = role.getName()+
+ // interaction.getFromRole().getName()+"CallbackPT";
+ }
+
+ if (varName != null) {
+ ((Receive)act).setVariable(varName);
+ }
+
+ // Check if create instance
+ if (org.scribble.model.util.InteractionUtil.isInitialInteraction(interaction)) {
+ ((Receive)act).setCreateInstance(true);
+ }
+ }
+ }
+
+ // TODO: Possibly if the channel is set, then
+ // might be a callback channel, so could use
+ // channel name to reflect callback port
+
+ // TODO: If both myRole and partnerRole are specified
+ // then one is a callback porttype
+
+ if (act != null) {
+
+ // Set the name
+ act.setName(InteractionUtil.getName(interaction));
+
+ if (context.getParent() instanceof Sequence) {
+ ((Sequence)context.getParent()).addActivity(act, -1);
+
+ ret = true;
+ }
+
+ // Create partner link
+ PartnerLink other=
+ bpelModel.getBPELProcess().getPartnerLink(pl.getName());
+ if (other == null) {
+ bpelModel.getBPELProcess().addPartnerLink(pl, -1);
+ } else {
+ if (other.getPartnerRole() == null &&
+ pl.getPartnerRole() != null) {
+ other.setPartnerRole(pl.getPartnerRole());
+ }
+ if (other.getMyRole() == null &&
+ pl.getMyRole() != null) {
+ other.setMyRole(pl.getMyRole());
+ }
+ }
+
+ // Set details on interaction
+ act.setPartnerLink(pl.getName());
+
+ act.setPortType(portType);
+
+ if (interaction.getMessageSignature() != null) {
+ act.setOperation(interaction.getMessageSignature().getOperation());
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and modified model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isUpdateSupported(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof ConversationInteraction &&
+ toObj instanceof ConversationInteraction &&
+ model instanceof BPELLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param fromObj The source model object
+ * @param toObj The model object to be updated
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean update(ModelChangeContext context,
+ Model model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+ //BPELLanguageModel bpelModel=(BPELLanguageModel)model;
+ //ConversationInteraction fromInteraction=(ConversationInteraction)fromObj;
+ //ConversationInteraction toInteraction=(ConversationInteraction)toObj;
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context)
+ * and deleted model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object to be removed
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isDeleteSupported(ModelChangeContext context,
+ Model model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationInteraction &&
+ super.isDeleteSupported(context, model, mobj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/IfModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/IfModelChangeRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/IfModelChangeRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,483 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.component.*;
+import org.jboss.savara.bpel.model.util.InteractionUtil;
+import org.jboss.savara.wsdl.generator.WSDLGeneratorUtil;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.jboss.savara.contract.model.Contract;
+import org.jboss.savara.contract.model.Interface;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the If.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class IfModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof org.scribble.conversation.model.If &&
+ model instanceof DefaultBPELLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+ org.scribble.conversation.model.If elem=
+ (org.scribble.conversation.model.If)mobj;
+ java.util.List<Block> paths=elem.getPaths();
+
+ // Check if the 'If' construct is to handle responses
+ // to a preceding request being sent
+ if (InteractionPatterns.isResponseAndFaultHandler(elem)) {
+
+ if (context.getParent() instanceof Sequence) {
+ // Find fault handler
+ Sequence seq=(Sequence)context.getParent();
+ Scope scope=new Scope(bpelModel,
+ (org.w3c.dom.Element)seq.getDOMElement().getParentNode());
+ FaultHandlers fh=scope.getFaultHandlers();
+
+ for (int i=0; i < paths.size(); i++) {
+ Block path=paths.get(i);
+
+ if (path.getContents().size() > 0) {
+ Activity act=path.getContents().get(0);
+ Sequence subseq=null;
+
+ if (act instanceof Interaction &&
+ InteractionPatterns.isFaultResponse(
+ (Interaction)act)) {
+ String faultName=InteractionPatterns.getFaultName((Interaction)act);
+
+ Contract contract = ModelChangeUtils.getContract(context,
+ ((Interaction)act).getFromRole().getName());
+
+ // Define fault message type
+ QName qname= WSDLGeneratorUtil.getFaultMessageType(contract.getNamespace(),
+ faultName);
+
+ String faultVarName=qname.getLocalPart()+"Var";
+ String mesgType=InteractionPatterns.getMessageTypeLocalPart((Interaction)act);
+ //String namespace=InteractionPatterns.getMessageTypeNameSpace((Interaction)act);
+
+ Catch c=new Catch(bpelModel);
+ c.setFaultVariable(faultVarName);
+
+ // Find namespace prefix
+ if (qname != null) {
+ String prefix=bpelModel.getBPELProcess().addNamespace(qname.getNamespaceURI());
+
+ if (prefix != null) {
+ mesgType = prefix+":"+qname.getLocalPart();
+ faultName = prefix+":"+faultName;
+ }
+ }
+
+ c.setFaultName(faultName);
+ c.setFaultMessageType(mesgType);
+
+ // Add catch to fault handler
+ fh.addCatch(c);
+
+ subseq = new Sequence(bpelModel);
+ c.setActivity(subseq);
+ } else {
+ subseq = seq;
+
+ java.util.List<BPELActivity> acts=
+ ((Sequence)context.getParent()).getActivities();
+
+ if (acts.size() > 0 && act instanceof Interaction &&
+ acts.get(acts.size()-1) instanceof Invoke) {
+ Contract contract = ModelChangeUtils.getContract(context,
+ ((Interaction)act).getFromRole().getName());
+
+ QName qname=null;
+ if (InteractionUtil.isRequest((Interaction)act)) {
+ qname = WSDLGeneratorUtil.getRequestMessageType(contract.getNamespace(),
+ ((Interaction)act).getMessageSignature().getOperation());
+ } else if (InteractionPatterns.isFaultResponse((Interaction)act)) {
+ qname = WSDLGeneratorUtil.getFaultMessageType(contract.getNamespace(),
+ InteractionPatterns.getFaultName((Interaction)act));
+ } else {
+ qname = WSDLGeneratorUtil.getResponseMessageType(contract.getNamespace(),
+ ((Interaction)act).getMessageSignature().getOperation());
+ }
+
+ String varName=qname.getLocalPart()+"Var"; //InteractionPatterns.getVariableName((Interaction)act);
+ Invoke invoke=(Invoke)acts.get(acts.size()-1);
+
+ invoke.setOutputVariable(varName);
+
+ // Create variable
+ if (varName != null) {
+ createVariable(context, varName, (Interaction)act, bpelModel);
+ }
+ }
+ }
+
+ Object parent=context.getParent();
+
+ context.setParent(subseq);
+
+ for (int j=1; j < path.getContents().size(); j++) {
+ context.insert(model, path.getContents().get(j), null);
+ }
+
+ context.setParent(parent);
+ }
+ }
+ } else {
+ // TODO: Error handling
+ }
+ } else if (InteractionPatterns.isSwitch(elem)) {
+ Pick act=new Pick(bpelModel);
+
+ if (context.getParent() instanceof Sequence) {
+ ((Sequence)context.getParent()).addActivity(act, -1);
+ }
+
+ Role role=null;
+
+ if (elem.getEnclosingDefinition() != null) {
+ role = elem.getEnclosingDefinition().
+ getLocatedName().getRole();
+ }
+
+ for (int i=0; i < paths.size(); i++) {
+ Block path=paths.get(i);
+
+ Sequence seq=new Sequence(bpelModel);
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=path.getContents();
+
+ Object parent=context.getParent();
+
+ context.setParent(seq);
+
+ for (int j=0; j < acts.size(); j++) {
+ context.insert(model, acts.get(j), null);
+ }
+
+ context.setParent(parent);
+
+ Interaction recv=InteractionPatterns.getPickPathInteraction(path);
+
+ OnMessage onm=new OnMessage(bpelModel);
+ onm.setActivity(seq);
+
+ PartnerLink pl=new PartnerLink(bpelModel);
+ String portType=null;
+
+ String prevPLName=role.getName()+"To"+recv.getFromRole().getName();
+
+ String mainPrefix=null;
+
+ Contract contract=ModelChangeUtils.getContract(context, context.getRole().getName());
+ if (contract != null) {
+ mainPrefix = bpelModel.getBPELProcess().addNamespace(contract.getNamespace());
+ }
+
+ // Check if partner link already exists in
+ // other direction
+ PartnerLink prev=
+ bpelModel.getBPELProcess().getPartnerLink(prevPLName);
+
+ if (InteractionUtil.isRequest(recv) && prev == null) {
+
+ pl.setMyRole(role.getName()+"Service");
+ //pl.setPartnerRole(interaction.getToRole().getName());
+ pl.setName(recv.getFromRole().getName()+"To"+role.getName());
+
+ String plt=recv.getFromRole().getName()+"To"+role.getName()+"Service"+"LT";
+
+ if (mainPrefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
+
+ contract = ModelChangeUtils.getContract(context, role.getName());
+
+ if (contract != null && contract.getInterfaces().size() > 0) {
+ Interface intf = contract.getInterfaces().iterator().next();
+
+ portType = intf.getName();
+
+ String prefix = bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ portType = prefix+":"+portType;
+ }
+ }
+ } else {
+ pl.setMyRole(role.getName()+"Requester");
+ pl.setPartnerRole(recv.getFromRole().getName()+"Service");
+ pl.setName(role.getName()+"To"+recv.getFromRole().getName());
+
+ String plt=role.getName()+"To"+recv.getFromRole().getName()+"Requester"+"LT";
+
+ if (mainPrefix != null) {
+ plt = mainPrefix+":"+plt;
+ }
+
+ pl.setPartnerLinkType(plt);
+
+ //portType = role.getName()+
+ // recv.getFromRole().getName()+"CallbackPT";
+
+ contract = ModelChangeUtils.getContract(context, recv.getFromRole().getName());
+ if (contract != null && contract.getInterfaces().size() > 0) {
+ Interface intf = contract.getInterfaces().iterator().next();
+
+ portType = intf.getName();
+
+ String prefix = bpelModel.getBPELProcess().addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ portType = prefix+":"+portType;
+ }
+ }
+ }
+
+ QName qname=null;
+ if (InteractionUtil.isRequest(recv)) {
+ qname = WSDLGeneratorUtil.getRequestMessageType(contract.getNamespace(),
+ recv.getMessageSignature().getOperation());
+ } else if (InteractionPatterns.isFaultResponse(recv)) {
+ qname = WSDLGeneratorUtil.getFaultMessageType(contract.getNamespace(),
+ InteractionPatterns.getFaultName(recv));
+ } else {
+ qname = WSDLGeneratorUtil.getResponseMessageType(contract.getNamespace(),
+ recv.getMessageSignature().getOperation());
+ }
+
+ String varName=qname.getLocalPart()+"Var"; //InteractionPatterns.getVariableName(recv);
+
+ if (varName != null) {
+ onm.setVariable(varName);
+ }
+
+ // Create partner link
+ PartnerLink other=
+ bpelModel.getBPELProcess().getPartnerLink(pl.getName());
+
+ if (other == null) {
+ bpelModel.getBPELProcess().addPartnerLink(pl, -1);
+ } else {
+ if (other.getPartnerRole() == null &&
+ pl.getPartnerRole() != null) {
+ other.setPartnerRole(pl.getPartnerRole());
+ }
+ if (other.getMyRole() == null &&
+ pl.getMyRole() != null) {
+ other.setMyRole(pl.getMyRole());
+ }
+ }
+
+ // Create variable
+ if (varName != null) {
+ createVariable(context, varName, recv, bpelModel);
+ }
+
+ // Check if create instance
+ if (org.scribble.model.util.InteractionUtil.isInitialInteraction(recv)) {
+ act.setCreateInstance(true);
+ }
+
+ // Set details on interaction
+ onm.setPartnerLink(pl.getName());
+ onm.setPortType(portType);
+
+ MessageSignature ms=recv.getMessageSignature();
+ if (ms.getOperation() != null) {
+ onm.setOperation(ms.getOperation());
+ }
+
+ act.addOnMessage(onm, -1);
+ }
+
+ } else {
+ If act=new If(bpelModel);
+
+ if (context.getParent() instanceof Sequence) {
+ ((Sequence)context.getParent()).addActivity(act, -1);
+ }
+
+ for (int i=0; i < paths.size(); i++) {
+ Block path=paths.get(i);
+
+ Sequence seq=new Sequence(bpelModel);
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=path.getContents();
+
+ Object parent=context.getParent();
+
+ context.setParent(seq);
+
+ for (int j=0; j < acts.size(); j++) {
+ context.insert(model, acts.get(j), null);
+ }
+
+ context.setParent(parent);
+
+ if (i == 0) {
+ act.setActivity(seq);
+ } else if (i == elem.getPaths().size()-1) {
+ Else construct=new Else(bpelModel);
+ construct.setActivity(seq);
+
+ act.setElsePath(construct);
+ } else {
+ Elseif construct=new Elseif(bpelModel);
+
+ construct.setActivity(seq);
+
+ act.addElseIfPath(construct);
+ }
+ }
+ }
+
+ return(true);
+ }
+
+ /**
+ * This method creates a variable, if one does not already exist for the
+ * supplied name, with the message type associated with the supplied
+ * interaction.
+ *
+ * @param varName The variable name
+ * @param interaction The interaction associated with the variable
+ * @param bpelModel The BPEL model
+ */
+ protected void createVariable(ModelChangeContext context, String varName,
+ Interaction interaction, BPELLanguageModel bpelModel) {
+ org.jboss.savara.bpel.model.component.Variable var=
+ bpelModel.getBPELProcess().getVariable(varName);
+
+ if (var == null) {
+ Role role=null;
+
+ if (interaction.getEnclosingDefinition() != null) {
+ role = interaction.getEnclosingDefinition().
+ getLocatedName().getRole();
+ }
+
+ var = new org.jboss.savara.bpel.model.component.Variable(bpelModel);
+ var.setName(varName);
+
+ Role roleType=null;
+ Contract contract=null;
+
+ if (InteractionUtil.isRequest(interaction)) {
+ roleType = interaction.getToRole();
+ if (roleType == null) {
+ roleType = role;
+ }
+ } else {
+ roleType = interaction.getFromRole();
+ if (roleType == null) {
+ roleType = role;
+ }
+ }
+
+ if (roleType != null) {
+ contract = ModelChangeUtils.getContract(context, roleType.getName());
+ }
+
+ QName qname=null;
+ if (InteractionUtil.isRequest(interaction)) {
+ qname = WSDLGeneratorUtil.getRequestMessageType(contract.getNamespace(),
+ interaction.getMessageSignature().getOperation());
+ } else {
+ qname = WSDLGeneratorUtil.getResponseMessageType(contract.getNamespace(),
+ interaction.getMessageSignature().getOperation());
+ }
+
+ String mesgType=qname.getLocalPart();
+
+ // Find namespace prefix
+ if (qname.getNamespaceURI() != null) {
+ String pfix=bpelModel.getBPELProcess().addNamespace(qname.getNamespaceURI());
+
+ if (pfix != null) {
+ mesgType = pfix+":"+mesgType;
+ }
+ }
+
+ var.setMessageType(mesgType);
+
+ bpelModel.getBPELProcess().addVariable(var, -1);
+ }
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/InteractionPatterns.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/InteractionPatterns.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/InteractionPatterns.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,382 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import org.jboss.savara.bpel.model.util.InteractionUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+/**
+ * This class provides utility functions for detecting
+ * patterns related to interactions.
+ */
+public class InteractionPatterns {
+
+ private static final String FAULT_NAME = "faultName";
+ private static final String MESSAGE_TYPE_LOCALPART = "messageTypeLocalPart";
+ private static final String MESSAGE_TYPE_NAMESPACE = "messageTypeNameSpace";
+
+ /**
+ * This method checks whether the supplied interaction
+ * is a request that requires a scope with associated
+ * fault handlers.
+ *
+ * @param interaction The interaction
+ * @return Whether the interaction is a request requiring
+ * an outer fault handler
+ */
+ public static boolean isFaultHandlerRequired(org.scribble.model.Interaction interaction) {
+ boolean ret=false;
+
+ // Check if interaction is an invoke, and followed
+ // by a choice representing a normal and multiple
+ // fault responses
+ if (InteractionUtil.isRequest(interaction) &&
+ interaction.getRequestLabel() != null) {
+
+ if (interaction.getParent() instanceof
+ org.scribble.model.Block) {
+ org.scribble.model.Block block=
+ (org.scribble.model.Block)interaction.getParent();
+
+ int pos=block.getContents().indexOf(interaction);
+
+ if (pos != -1 && pos < block.getContents().size()-1) {
+ org.scribble.model.Activity act=
+ block.getContents().get(pos+1);
+
+ if (act instanceof org.scribble.conversation.model.If) {
+
+ // Need to check if each path receives a
+ // response (normal and fault)
+ org.scribble.conversation.model.If choice=
+ (org.scribble.conversation.model.If)act;
+
+ if (choice.getPaths().size() > 0) {
+ ret = true;
+ }
+
+ for (int i=0; ret &&
+ i < choice.getPaths().size(); i++) {
+
+ org.scribble.model.Block path=
+ choice.getPaths().get(i);
+
+ if (path.getContents().size() == 0 ||
+ (path.getContents().get(0) instanceof Interaction) == false ||
+ InteractionUtil.isRequest((Interaction)
+ path.getContents().get(0))) {
+ ret = false;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ // TODO: Method to detect if normal response, which needs
+ // to enhance the invoke (and subsequent activities following
+ // the invoke), or a fault response needing to
+ // place itself and subsequent activities in a fault handler.
+ // Methods need to return (and set) the relevant sequence
+ // to use for subsequent activities.
+
+ public static boolean isResponseAndFaultHandler(If choice) {
+ boolean ret=false;
+
+ // Obtain interaction prior to 'If'
+ if (choice.getPaths().size() > 0 &&
+ choice.getParent() instanceof
+ org.scribble.model.Block) {
+ org.scribble.model.Block block=
+ (org.scribble.model.Block)choice.getParent();
+
+ int pos=block.getContents().indexOf(choice);
+
+ if (pos != -1 && pos > 0) {
+ org.scribble.model.Activity act=
+ block.getContents().get(pos-1);
+
+ if (act instanceof Interaction &&
+ InteractionUtil.isSend((Interaction)act) &&
+ InteractionUtil.isRequest((Interaction)act) &&
+ ((Interaction)act).getRequestLabel() != null) {
+
+ // Check if each path has a response/fault associated
+ // with the preceding request
+ String requestLabel=
+ ((Interaction)act).getRequestLabel();
+
+ java.util.List<Block> paths=choice.getPaths();
+ int matched=0;
+
+ for (int i=0; i < paths.size(); i++) {
+ if (paths.get(i).getContents().size() > 0) {
+ Interaction in=getPickPathInteraction(paths.get(i));
+
+ if (in != null &&
+ InteractionUtil.isResponse(in) &&
+ in.getReplyToLabel().equals(requestLabel)) {
+ matched++;
+ }
+ }
+ }
+
+ if (matched == paths.size()) {
+ ret = true;
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method obtains the interaction that triggers a
+ * specified path in a BPEL pick activity.
+ *
+ * @param path The path
+ * @return The interaction that triggers the path in
+ * the pick activity
+ */
+ public static Interaction getPickPathInteraction(Block path) {
+ Interaction ret=null;
+
+ // TODO: This method is the opposite of the
+ // 'isInteractionPickPathTrigger', so needs to be
+ // updated to reflect any changes to that method
+
+ if (path.getContents().size() > 0) {
+ org.scribble.model.Activity sub=
+ path.getContents().get(0);
+
+ // Check if scope
+ if (sub instanceof Compose) {
+ Definition defn=((Compose)sub).getDefinition();
+ org.scribble.model.Behaviour b=null;
+
+ for (int j=0; b == null &&
+ j < defn.getBlock().getContents().size(); j++) {
+ if (defn.getBlock().getContents().get(j) instanceof org.scribble.model.Behaviour) {
+ b = (org.scribble.model.Behaviour)
+ defn.getBlock().getContents().get(j);
+ }
+ }
+
+ if (b != null) {
+ sub = b;
+ }
+ }
+
+ if (sub instanceof Interaction) {
+ ret = (Interaction)sub;
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied interaction
+ * is the trigger interaction within a BPEL pick activity.
+ *
+ * @param in The interaction
+ * @return Whether the interaction is a pick trigger activity
+ */
+ public static boolean isInteractionPickPathTrigger(Interaction in) {
+ boolean ret=false;
+
+ // TODO: Need to determine all situations and ensure
+ // is generic enough to cope with extensions to Scribble
+ // model
+
+ Block path=(Block)in.getParent();
+
+ if (path.getParent() instanceof If &&
+ InteractionPatterns.isSwitch((If)path.getParent())) {
+ ret = true;
+
+ // Check if receive is directly contained within a
+ // sub-definition
+ } else if (InteractionUtil.isSend(in) == false &&
+ path.getParent() instanceof org.scribble.model.Definition &&
+ path.getParent().getParent() instanceof Block &&
+ path.getParent().getParent().getParent() instanceof
+ org.scribble.model.Definition) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public static boolean isSwitch(If choice) {
+ boolean ret=false;
+
+ if (choice.getPaths().size() > 0) {
+ java.util.List<Block> paths=choice.getPaths();
+ int matched=0;
+
+ for (int i=0; i < paths.size(); i++) {
+ if (paths.get(i).getContents().size() > 0) {
+ Interaction in=getPickPathInteraction(paths.get(i));
+
+ if (in != null &&
+ InteractionUtil.isSend(in) == false) {
+ matched++;
+ }
+ }
+ }
+
+ if (matched == paths.size()) {
+ ret = true;
+ }
+ }
+
+ return(ret);
+ }
+
+ public static Interaction getRequestForResponseInFaultHandler(Interaction interaction) {
+ Interaction ret=null;
+
+ if (InteractionUtil.isRequest(interaction) == false &&
+ interaction.getReplyToLabel() != null) {
+
+ // Find if contained in 'if' path
+ if (interaction.getParent() instanceof Block &&
+ interaction.getParent().getParent() instanceof If) {
+
+ If choice=(If)interaction.getParent().getParent();
+
+ // Obtain interaction prior to 'If'
+ if (choice.getParent() instanceof
+ org.scribble.model.Block) {
+ org.scribble.model.Block block=
+ (org.scribble.model.Block)choice.getParent();
+
+ int pos=block.getContents().indexOf(choice);
+
+ if (pos != -1 && pos > 0) {
+ org.scribble.model.Activity act=
+ block.getContents().get(pos-1);
+
+ if (act instanceof Interaction &&
+ InteractionUtil.isRequest((Interaction)act) &&
+ ((Interaction)act).getRequestLabel() != null &&
+ interaction.getReplyToLabel().equals(
+ ((Interaction)act).getRequestLabel())) {
+ ret = (Interaction)act;
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ public static boolean isResponseInFaultHandler(Interaction interaction) {
+ return(getRequestForResponseInFaultHandler(interaction) != null);
+ }
+
+ public static boolean isFaultResponse(Interaction interaction) {
+ boolean ret=false;
+
+ if (InteractionUtil.isRequest(interaction) == false &&
+ interaction.getMessageSignature().getAnnotations().
+ keySet().contains(FAULT_NAME)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public static String getFaultName(Interaction interaction) {
+ return((String)interaction.
+ getMessageSignature().getAnnotations().get(FAULT_NAME));
+ }
+
+ public static String getMessageTypeLocalPart(Interaction interaction) {
+ return((String)interaction.
+ getMessageSignature().getAnnotations().get(MESSAGE_TYPE_LOCALPART));
+ }
+
+ public static String getMessageTypeNameSpace(Interaction interaction) {
+ return((String)interaction.
+ getMessageSignature().getAnnotations().get(MESSAGE_TYPE_NAMESPACE));
+ }
+
+ /*
+ public static String getVariableName(Interaction interaction) {
+ String varName=getMessageTypeLocalPart(interaction);
+
+ if (varName != null) {
+ int ind=varName.lastIndexOf('}');
+
+ if (ind != -1) {
+ varName = varName.substring(ind+1);
+ }
+
+ varName += "Var";
+
+ if (Character.isLowerCase(varName.charAt(0)) == false) {
+ varName = Character.toLowerCase(varName.charAt(0))+
+ varName.substring(1);
+ }
+ }
+
+ return(varName);
+ }
+ */
+
+ public static boolean isSyncNormalResponse(Interaction interaction) {
+ boolean ret=false;
+
+ if (InteractionUtil.isResponse(interaction) &&
+ interaction.getParent() instanceof Block) {
+ Block block=(Block)interaction.getParent();
+
+ int pos=block.getContents().indexOf(interaction);
+
+ if (pos > 0 && block.getContents().get(pos-1) instanceof Interaction) {
+ Interaction req=(Interaction)block.getContents().get(pos-1);
+
+ ret = isResponseForRequest(interaction, req);
+ }
+ }
+
+ return(ret);
+ }
+
+ public static boolean isResponseForRequest(Interaction resp,
+ Interaction req) {
+ boolean ret=false;
+
+ if (InteractionUtil.isRequest(req) &&
+ InteractionUtil.isResponse(resp) &&
+ resp.getReplyToLabel().equals(
+ req.getRequestLabel())) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/LanguageToConversationModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/LanguageToConversationModelChangeRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/LanguageToConversationModelChangeRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import org.jboss.savara.bpel.model.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Language Model to
+ * Conversation Model.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class LanguageToConversationModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and inserted
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object being inserted
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof ConversationModel &&
+ model instanceof BPELLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ ConversationModel cm=(ConversationModel)mobj;
+
+ if (cm.getConversation() != null) {
+ ModelChangeUtils.addContracts(context, cm.getConversation(), true);
+
+ context.insert(model, cm.getConversation(), null);
+
+ ModelChangeUtils.removeContracts(context, cm.getConversation(), true);
+ }
+
+ return(true);
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ModelChangeUtils.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ModelChangeUtils.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/ModelChangeUtils.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,239 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.jboss.savara.contract.model.Contract;
+import org.scribble.conversation.model.*;
+
+/**
+ * Model change utilities.
+ */
+public class ModelChangeUtils {
+
+ /**
+ * This method adds any contracts associated with roles defined in the
+ * supplied conversation.
+ *
+ * @param context The context
+ * @param conv The conversation
+ * @param root Whether this is the root conversation
+ */
+ @SuppressWarnings("unchecked")
+ public static void addContracts(ModelChangeContext context, Conversation conv, boolean root) {
+
+ java.util.Map<String,Contract> contracts=(java.util.Map<String,Contract>)
+ context.getProperties().get(Contract.class.getName());
+
+ if (contracts == null) {
+ contracts = new java.util.HashMap<String, Contract>();
+
+ context.getProperties().put(Contract.class.getName(), contracts);
+ }
+
+ if (conv.getLocatedName().getRole() != null && root) {
+ addRoleContract(conv.getLocatedName().getRole(), contracts);
+ }
+
+ // Get list of roles
+ java.util.List<Role> roles=getRoles(conv);
+
+ for (Role r : roles) {
+ addRoleContract(r, contracts);
+ }
+ }
+
+ // NOTE: Return all the roles defined in the scope of this conversation
+ // Would be better to incrementally add contracts for roles, as defined
+ // in their own scope, but need to refactor how blocks are dealt with
+ // first - which is different in some cases, so not straightforward.
+ protected static java.util.List<Role> getRoles(final Conversation conv) {
+ final java.util.List<Role> roles=new java.util.Vector<Role>();
+
+ conv.visit(new Visitor() {
+
+ public boolean visit(ModelObject obj) {
+ boolean ret=true;
+
+ if (obj instanceof RoleList) {
+ roles.addAll(((RoleList)obj).getRoles());
+ } else if (obj instanceof Conversation &&
+ obj != conv) {
+ ret = false;
+ }
+
+ return(ret);
+ }
+ });
+
+ return(roles);
+ }
+
+ /**
+ * This method initializes the contract associated with the supplied role.
+ *
+ * @param role The role
+ * @param contracts The map of roles to contracts
+ */
+ protected static void addRoleContract(Role role, java.util.Map<String,Contract> contracts) {
+ if (role != null && role.getAnnotations().containsKey(Contract.class.getName())) {
+ contracts.put(role.getName(),
+ (Contract)role.getAnnotations().get(Contract.class.getName()));
+ }
+ }
+
+ /**
+ * This method removes the contract associated with the supplied role.
+ *
+ * @param role The role
+ * @param contracts The map of roles to contracts
+ */
+ protected static void removeRoleContract(Role role, java.util.Map<String,Contract> contracts) {
+ if (role != null && role.getAnnotations().containsKey(Contract.class.getName())) {
+ contracts.remove(role.getName());
+ }
+ }
+
+ /**
+ * This method removes any contracts associated with roles defined in the
+ * supplied conversation.
+ *
+ * @param context The context
+ * @param conv The conversation
+ * @param root Whether this is the root conversation
+ */
+ @SuppressWarnings("unchecked")
+ public static void removeContracts(ModelChangeContext context, Conversation conv, boolean root) {
+
+ java.util.Map<String,Contract> contracts=(java.util.Map<String,Contract>)
+ context.getProperties().get(Contract.class.getName());
+
+ if (contracts != null) {
+
+ if (conv.getLocatedName().getRole() != null && root) {
+ removeRoleContract(conv.getLocatedName().getRole(), contracts);
+ }
+
+ // Get list of roles
+ java.util.List<Role> roles=getRoles(conv);
+
+ for (Role r : roles) {
+ removeRoleContract(r, contracts);
+ }
+ }
+ }
+
+ /**
+ * This method returns the contract associated with the supplied role.
+ *
+ * @param contezt The context
+ * @param roleName The role name
+ * @return The contract, or null if not found
+ */
+ @SuppressWarnings("unchecked")
+ public static Contract getContract(ModelChangeContext context, String roleName) {
+ Contract ret=null;
+
+ if (context.getProperties().containsKey(Contract.class.getName())) {
+ java.util.Map<String,Contract> contracts=
+ (java.util.Map<String,Contract>)
+ context.getProperties().get(Contract.class.getName());
+
+ ret = contracts.get(roleName);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method updates the role mapping based on the supplied list of
+ * declaration bindings.
+ *
+ * @param context The context
+ * @param run The run construct
+ */
+ @SuppressWarnings("unchecked")
+ public static void pushRoleContractMapping(ModelChangeContext context,
+ Compose run) {
+
+ if (context.getProperties().containsKey(Contract.class.getName())) {
+ java.util.Map<String,Contract> contracts=
+ (java.util.Map<String,Contract>)
+ context.getProperties().get(Contract.class.getName());
+
+ if (run.getEnclosingDefinition().getLocatedName().getRole() != null &&
+ run.getDefinition().getLocatedName().getRole() != null) {
+ Contract c=contracts.remove(run.getEnclosingDefinition().getLocatedName().getRole().getName());
+
+ if (c != null) {
+ contracts.put(run.getDefinition().getLocatedName().getRole().getName(), c);
+ }
+ }
+
+ for (DeclarationBinding db : run.getBindings()) {
+ if (db.getDeclaration() instanceof Role) {
+ Contract c=contracts.remove(db.getDeclaration().getName());
+
+ if (c != null) {
+ contracts.put(db.getBoundName(), c);
+ }
+ }
+ }
+
+ }
+ }
+
+ /**
+ * This method resets the role mapping based on the supplied list of
+ * declaration bindings.
+ *
+ * @param context The context
+ * @param run The run construct
+ */
+ @SuppressWarnings("unchecked")
+ public static void popRoleContractMapping(ModelChangeContext context,
+ Compose run) {
+
+ if (context.getProperties().containsKey(Contract.class.getName())) {
+ java.util.Map<String,Contract> contracts=
+ (java.util.Map<String,Contract>)
+ context.getProperties().get(Contract.class.getName());
+
+ if (run.getEnclosingDefinition().getLocatedName().getRole() != null &&
+ run.getDefinition().getLocatedName().getRole() != null) {
+ Contract c=contracts.remove(run.getDefinition().getLocatedName().getRole().getName());
+
+ if (c != null) {
+ contracts.put(run.getEnclosingDefinition().getLocatedName().getRole().getName(), c);
+ }
+ }
+
+ for (DeclarationBinding db : run.getBindings()) {
+ if (db.getDeclaration() instanceof Role) {
+ Contract c=contracts.remove(db.getBoundName());
+
+ if (c != null) {
+ contracts.put(db.getDeclaration().getName(), c);
+ }
+ }
+ }
+
+ }
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/RunModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/RunModelChangeRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/RunModelChangeRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.component.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Run.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class RunModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Run &&
+ model instanceof DefaultBPELLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+ Run elem=(Run)mobj;
+
+ if (elem.getDefinition() != null) {
+
+ ModelChangeUtils.pushRoleContractMapping(context, elem);
+
+ ModelChangeUtils.addContracts(context, elem.getDefinition(), false);
+
+ context.insert(bpelModel, elem.getDefinition(), ref);
+
+ ModelChangeUtils.removeContracts(context, elem.getDefinition(), false);
+
+ ModelChangeUtils.popRoleContractMapping(context, elem);
+ }
+
+ return(true);
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/SpawnModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/SpawnModelChangeRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/SpawnModelChangeRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.component.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the Run.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class SpawnModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Spawn &&
+ model instanceof DefaultBPELLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+ Spawn elem=(Spawn)mobj;
+
+ if (elem.getDefinition() != null) {
+ ModelChangeUtils.pushRoleContractMapping(context, elem);
+
+ ModelChangeUtils.addContracts(context, elem.getDefinition(), false);
+
+ context.insert(bpelModel, elem.getDefinition(), ref);
+
+ ModelChangeUtils.removeContracts(context, elem.getDefinition(), false);
+
+ ModelChangeUtils.popRoleContractMapping(context, elem);
+ }
+
+ return(true);
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/WhenModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/WhenModelChangeRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/WhenModelChangeRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.component.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.conversation.model.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the When.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class WhenModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof When &&
+ model instanceof DefaultBPELLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+ When elem=(When)mobj;
+
+ // TODO: Need to decide best way to deal with single
+ // and multi-path when constructs.
+
+ if (elem.getPaths().size() == 1) {
+ // Single path - so ignore it for now
+ Block path=elem.getPaths().get(0);
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=path.getContents();
+
+ for (int i=0; i < acts.size(); i++) {
+ context.insert(model, acts.get(i), null);
+ }
+ }
+
+ return(true);
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/WhileModelChangeRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/WhileModelChangeRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/change/WhileModelChangeRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.change;
+
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.component.*;
+import org.scribble.model.*;
+import org.scribble.model.change.*;
+import org.scribble.extensions.RegistryInfo;
+
+/**
+ * This is the model change rule for the While.
+ */
+ at RegistryInfo(extension=ModelChangeRule.class,notation=BPELNotation.NOTATION_CODE)
+public class WhileModelChangeRule extends AbstractModelChangeRule {
+
+ /**
+ * This method determines whether the rule is appropriate
+ * for the supplied type of model, parent (in the context) and
+ * model object.
+ *
+ * @param context The context
+ * @param model The model
+ * @param mobj The model object causing the change
+ * @param ref The optional reference model object
+ * @return Whether the rule supports the supplied information
+ */
+ @Override
+ public boolean isInsertSupported(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof org.scribble.conversation.model.While &&
+ model instanceof DefaultBPELLanguageModel) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a new model object, within a
+ * parent model object, with the details supplied in
+ * another model object. The supplied model object
+ * will usually be from a different model representation
+ * (e.g. due to a merge), so the details will be
+ * copied and placed in the representation associated
+ * with the supplied model and parent model object.<p>
+ * <p>
+ * If a reference model object is supplied, then the
+ * insertion will occur relative to it. If the reference
+ * object is a block, then it means that the insertion
+ * should occur at the end of the block. Otherwise the
+ * new model object should be inserted before the
+ * reference object, within the containing block.<p>
+ * <p>
+ * If the reference object is not supplied, then the
+ * new model object should be inserted at the end of
+ * the behaviour associated with the parent in the model
+ * change context.
+ *
+ * @param context The context
+ * @param model The model being changed
+ * @param mobj The model object details to be inserted
+ * @param ref The optional reference model object
+ * @return Whether the change has been applied
+ */
+ @Override
+ public boolean insert(ModelChangeContext context,
+ Model model, ModelObject mobj, ModelObject ref) {
+ DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+ org.scribble.conversation.model.While elem=
+ (org.scribble.conversation.model.While)mobj;
+
+ While act=new While(bpelModel);
+
+ Sequence seq=new Sequence(bpelModel);
+
+ if (context.getParent() instanceof Sequence) {
+ ((Sequence)context.getParent()).addActivity(act, -1);
+ }
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=elem.getBlock().getContents();
+
+ Object parent=context.getParent();
+
+ context.setParent(seq);
+
+ for (int i=0; i < acts.size(); i++) {
+ context.insert(model, acts.get(i), null);
+ }
+
+ act.setActivity(seq);
+
+ // Reset old parent
+ context.setParent(parent);
+
+ return(true);
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/AbstractCondition.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/AbstractCondition.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/AbstractCondition.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the BPEL condition element.
+ */
+public abstract class AbstractCondition extends BPELElement {
+
+ private static final long serialVersionUID = 178873060670041144L;
+
+ private static final String EXPRESSION_LANGUAGE = "expressionLanguage";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public AbstractCondition(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elemName The condition's element name
+ */
+ public AbstractCondition(BPELLanguageModel model, String elemName) {
+ super(model, elemName);
+ }
+
+ /**
+ * This method returns the expression associated
+ * with the condition.
+ *
+ * @return The expression
+ */
+ public String getExpression() {
+ String ret=null;
+
+ getDOMElement().normalize();
+
+ if (getDOMElement().getFirstChild() instanceof org.w3c.dom.Text) {
+ org.w3c.dom.Text text=(org.w3c.dom.Text)
+ getDOMElement().getFirstChild();
+
+ ret = text.getNodeValue();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the expression.
+ *
+ * @param expr The expression
+ */
+ public void setExpression(String expr) {
+
+ getDOMElement().normalize();
+
+ if (getDOMElement().getFirstChild() == null) {
+ org.w3c.dom.Text text=
+ getDOMElement().getOwnerDocument().createTextNode(expr);
+
+ getDOMElement().appendChild(text);
+
+ } else if (getDOMElement().getFirstChild() instanceof org.w3c.dom.Text) {
+ org.w3c.dom.Text text=(org.w3c.dom.Text)
+ getDOMElement().getFirstChild();
+
+ text.setNodeValue(expr);
+ }
+ }
+
+ /**
+ * This method returns the expression language associated
+ * with the condition.
+ *
+ * @return The expression language
+ */
+ public String getExpressionLanguage() {
+ return(getDOMElement().hasAttribute(EXPRESSION_LANGUAGE)?
+ getDOMElement().getAttribute(EXPRESSION_LANGUAGE):null);
+ }
+
+ /**
+ * This method sets the expression language.
+ *
+ * @param lang The expression language
+ */
+ public void setExpressionLanguage(String lang) {
+ getDOMElement().setAttribute(EXPRESSION_LANGUAGE, lang);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/AbstractInteraction.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/AbstractInteraction.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/AbstractInteraction.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import javax.xml.namespace.QName;
+
+import org.scribble.model.TypeReference;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents an abstract interaction activity.
+ *
+ * @author gary
+ */
+public abstract class AbstractInteraction extends BPELActivity {
+
+ private static final String PARTNER_LINK = "partnerLink";
+ private static final String PORT_TYPE = "portType";
+ private static final String OPERATION = "operation";
+
+ private static final long serialVersionUID = -5048477859609625462L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public AbstractInteraction(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public AbstractInteraction(BPELLanguageModel model,
+ String name) {
+ super(model, name);
+ }
+
+ /**
+ * This method sets the operation.
+ *
+ * @param op The operation
+ */
+ public void setOperation(String op) {
+ getDOMElement().setAttribute(OPERATION, op);
+ }
+
+ /**
+ * This method returns the operation.
+ *
+ * @return The operation
+ */
+ public String getOperation() {
+ return(getDOMElement().hasAttribute(OPERATION)?
+ getDOMElement().getAttribute(OPERATION):null);
+ }
+
+ /**
+ * This method sets the partner link.
+ *
+ * @param pl The partner link
+ */
+ public void setPartnerLink(String pl) {
+ getDOMElement().setAttribute(PARTNER_LINK, pl);
+ }
+
+ /**
+ * This method returns the partner link.
+ *
+ * @return The partner link
+ */
+ public String getPartnerLink() {
+ return(getDOMElement().hasAttribute(PARTNER_LINK)?
+ getDOMElement().getAttribute(PARTNER_LINK):null);
+ }
+
+ /**
+ * This method sets the port type.
+ *
+ * @param pt The port type
+ */
+ public void setPortType(String pt) {
+ getDOMElement().setAttribute(PORT_TYPE, pt);
+ }
+
+ /**
+ * This method returns the port type.
+ *
+ * @return The port type
+ */
+ public String getPortType() {
+ return(getDOMElement().hasAttribute(PORT_TYPE)?
+ getDOMElement().getAttribute(PORT_TYPE):null);
+ }
+
+ /**
+ * This method attempts to identify the client's partner role name.
+ *
+ * @return The partner role
+ */
+ protected String getClientPartnerRole() {
+ String ret=getPartnerLink();
+ int index=-1;
+
+ if (ret != null && (index=ret.indexOf("To")) != -1) {
+ ret = ret.substring(index+2);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method attempts to identify the server's partner role name.
+ *
+ * @return The partner role
+ */
+ protected String getServerPartnerRole() {
+ String ret=getPartnerLink();
+ int index=-1;
+
+ if (ret != null && (index=ret.indexOf("To")) != -1) {
+ ret = ret.substring(0, index);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELActivity.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELActivity.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELActivity.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,405 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the base class for all BPEL
+ * activities.
+ */
+public abstract class BPELActivity extends BPELElement {
+
+ private static final String SOURCES = "sources";
+
+ private static final String TARGETS = "targets";
+
+ private static final String SUPPRESS_JOIN_FAILURE = "suppressJoinFailure";
+
+ private static final String NAME = "name";
+
+ private static final long serialVersionUID = 2885165314780298048L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public BPELActivity(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ org.w3c.dom.Element targets=findChildElement(TARGETS);
+
+ if (targets != null) {
+ org.w3c.dom.NodeList nl=targets.getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getLocalName().equals(Target.TARGET)
+ && nl.item(i) instanceof org.w3c.dom.Element) {
+ m_targets.add(new Target(model,
+ (org.w3c.dom.Element)nl.item(i)));
+ }
+ }
+ }
+
+ org.w3c.dom.Element sources=findChildElement(SOURCES);
+
+ if (sources != null) {
+ org.w3c.dom.NodeList nl=sources.getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getLocalName().equals(Source.SOURCE)
+ && nl.item(i) instanceof org.w3c.dom.Element) {
+ m_sources.add(new Source(model,
+ (org.w3c.dom.Element)nl.item(i)));
+ }
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public BPELActivity(BPELLanguageModel model,
+ String name) {
+ super(model, name);
+ }
+
+ /**
+ * This method identifies whether the BPEL element
+ * is an activity.
+ *
+ * @return Whether the element is an activity
+ */
+ @Override
+ public boolean isActivity() {
+ return(true);
+ }
+
+ /**
+ * This method sets the name.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ getDOMElement().setAttribute(NAME, name);
+ }
+
+ /**
+ * This method returns the name.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(getDOMElement().hasAttribute(NAME)?
+ getDOMElement().getAttribute(NAME):null);
+ }
+
+ /**
+ * This method sets the 'suppress join failure'
+ * attribute.
+ *
+ * @param b Whether to suppress join failure
+ */
+ public void setSuppressJoinFailure(boolean b) {
+ String suppress=(b?"yes":"no");
+
+ getDOMElement().setAttribute(SUPPRESS_JOIN_FAILURE, suppress);
+ }
+
+ /**
+ * This method returns whether the join should
+ * be suppressed.
+ *
+ * @return Whether the join should be suppressed
+ */
+ public boolean getSuppressJoinFailure() {
+ boolean ret=false;
+ String suppress=
+ getDOMElement().getAttribute(SUPPRESS_JOIN_FAILURE);
+
+ if (suppress != null &&
+ suppress.equals("yes")) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a target to the activity.
+ *
+ * @param target The target to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addTarget(Target target, int pos) {
+
+ org.w3c.dom.Element targets=null;
+
+ if (m_targets.size() == 0) {
+ targets = getDOMElement().getOwnerDocument().
+ createElementNS(BPEL_NS, TARGETS);
+
+ if (getDOMElement().getFirstChild() == null) {
+ getDOMElement().appendChild(targets);
+ } else {
+ getDOMElement().insertBefore(targets,
+ getDOMElement().getFirstChild());
+ }
+ } else {
+ targets = findChildElement(TARGETS);
+ }
+
+ org.w3c.dom.Node newNode=target.getDOMElement().cloneNode(true);
+
+ getDOMElement().getOwnerDocument().adoptNode(newNode);
+
+ target.setDOMElement((org.w3c.dom.Element)newNode);
+
+ if (pos == -1 && pos < m_targets.size()) {
+ m_targets.add(target);
+
+ targets.appendChild(newNode);
+ } else {
+
+ Target cur=m_targets.get(pos);
+
+ m_targets.add(pos, target);
+
+ if (cur != null) {
+ targets.insertBefore(newNode,
+ cur.getDOMElement());
+ } else {
+ targets.appendChild(newNode);
+ }
+ }
+ }
+
+ /**
+ * This method removes a target from the activity.
+ *
+ * @param target The target to be removed
+ * @return Whether the target was removed
+ */
+ public boolean removeTarget(Target target) {
+ boolean ret=m_targets.remove(target);
+
+ if (ret) {
+ org.w3c.dom.Element targets=
+ findChildElement(TARGETS);
+
+ if (targets != null) {
+ targets.removeChild(target.getDOMElement());
+
+ if (m_targets.size() == 0) {
+ getDOMElement().removeChild(targets);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of targets associated
+ * with the activity.
+ *
+ * @return The list of targets
+ */
+ public java.util.List<Target> getTargets() {
+ return(m_targets);
+ }
+
+ /**
+ * This method adds a source to the activity.
+ *
+ * @param source The source to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addSource(Source source, int pos) {
+
+ org.w3c.dom.Element sources=null;
+
+ if (m_sources.size() == 0) {
+ sources = getDOMElement().getOwnerDocument().
+ createElementNS(BPEL_NS, SOURCES);
+
+ if (getDOMElement().getFirstChild() == null) {
+ getDOMElement().appendChild(sources);
+ } else {
+ getDOMElement().insertBefore(sources,
+ getDOMElement().getFirstChild());
+ }
+ } else {
+ sources = findChildElement(SOURCES);
+ }
+
+ org.w3c.dom.Node newNode=source.getDOMElement().cloneNode(true);
+
+ getDOMElement().getOwnerDocument().adoptNode(newNode);
+
+ source.setDOMElement((org.w3c.dom.Element)newNode);
+
+ if (pos == -1 && pos < m_sources.size()) {
+ m_sources.add(source);
+
+ sources.appendChild(newNode);
+ } else {
+
+ Source cur=m_sources.get(pos);
+
+ m_sources.add(pos, source);
+
+ if (cur != null) {
+ sources.insertBefore(newNode,
+ cur.getDOMElement());
+ } else {
+ sources.appendChild(newNode);
+ }
+ }
+ }
+
+ /**
+ * This method removes a source from the activity.
+ *
+ * @param source The source to be removed
+ * @return Whether the source was removed
+ */
+ public boolean removesource(Source source) {
+ boolean ret=m_sources.remove(source);
+
+ if (ret) {
+ org.w3c.dom.Element sources=
+ findChildElement(SOURCES);
+
+ if (sources != null) {
+ sources.removeChild(source.getDOMElement());
+
+ if (m_sources.size() == 0) {
+ getDOMElement().removeChild(sources);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of sources associated
+ * with the activity.
+ *
+ * @return The list of sources
+ */
+ public java.util.List<Source> getSources() {
+ return(m_sources);
+ }
+
+ /**
+ * This method converts the BPEL activity into an equivalent
+ * behavioural description for conformance checking.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ public void convert(java.util.List<Activity> activities,
+ ConversionContext context) {
+
+ if (getTargets().size() > 0) {
+
+ // Create 'when' construct to wait for inbound links
+ // to be satisfied
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ String query="";
+
+ for (int i=0; i < getTargets().size(); i++) {
+ if (i > 0) {
+ query += " and ";
+ }
+ query += "$"+getTargets().get(i).getLinkName();
+ }
+
+ expr.setQuery(query);
+
+ org.scribble.conversation.model.When elem=
+ new org.scribble.conversation.model.When();
+
+ org.scribble.conversation.model.ConditionalBlock block=
+ new org.scribble.conversation.model.ConditionalBlock();
+ block.setExpression(expr);
+
+ elem.getConditionalBlocks().add(block);
+
+ activities.add(elem);
+
+ activities = block.getContents();
+ }
+
+ convertActivity(activities, context);
+
+ // If sources, then set boolean variable
+ for (int i=0; i < getSources().size(); i++) {
+
+ org.scribble.conversation.model.Assignment assign=
+ new org.scribble.conversation.model.Assignment();
+
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+
+ var.setName(getSources().get(i).getLinkName());
+
+ assign.setVariable(var);
+
+ org.scribble.expression.xpath.model.XPathExpression expr=
+ new org.scribble.expression.xpath.model.XPathExpression();
+
+ expr.setQuery("true()");
+ assign.setExpression(expr);
+
+ activities.add(assign);
+ }
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected abstract void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context);
+
+ private java.util.List<Target> m_targets=
+ new java.util.Vector<Target>();
+ private java.util.List<Source> m_sources=
+ new java.util.Vector<Source>();
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElement.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElement.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElement.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,404 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.apache.commons.logging.*;
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.util.XMLUtils;
+
+/**
+ * This is the generic BPEL element class.
+ *
+ * @author gary
+ */
+public abstract class BPELElement extends ModelObject {
+
+ public static final String BPEL_NS = "http://docs.oasis-open.org/wsbpel/2.0/process/executable";
+
+ private static final long serialVersionUID = -7306844554703224704L;
+
+ /**
+ * The constructor for initializing the BPEL element based on
+ * an existing DOM element.
+ */
+ protected BPELElement(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ m_model = model;
+
+ m_element = elem;
+
+ // Set the start/end position information
+ // in the source details
+ XMLUtils.setStartAndEndPosition(this, model.getOriginalContents(), elem);
+
+ getSource().setObject(this);
+ }
+
+ /**
+ * The contructor for initializing a new element.
+ */
+ protected BPELElement(BPELLanguageModel model,
+ String elemName) {
+ m_model = model;
+
+ org.w3c.dom.Document doc=null;
+
+ if (model.getBPELProcess() == null) {
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.
+ newInstance();
+ factory.setNamespaceAware(true);
+
+ doc = factory.newDocumentBuilder().newDocument();
+ } catch(Exception e) {
+ logger.error("Failed to create document", e);
+ }
+ } else {
+ doc = model.getBPELProcess().getDOMElement().
+ getOwnerDocument();
+ }
+
+ m_element = doc.createElementNS(BPEL_NS, elemName);
+
+ getSource().setObject(this);
+ }
+
+ /**
+ * This method validates the ESB action and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method returns the XML configuration representation
+ * of the activity.
+ *
+ * @return The XML configuration for the BPEL node
+ */
+ public org.w3c.dom.Element getDOMElement() {
+ return(m_element);
+ }
+
+ /**
+ * This method sets the XML configuration representation
+ * of the activity.
+ *
+ * @param elem The XML configuration
+ */
+ protected void setDOMElement(org.w3c.dom.Element elem) {
+ m_element = elem;
+ }
+
+ /**
+ * This method identifies whether the BPEL element
+ * is an activity.
+ *
+ * @return Whether the element is an activity
+ */
+ public boolean isActivity() {
+ return(false);
+ }
+
+ /**
+ * This method returns the model.
+ *
+ * @return The model
+ */
+ protected BPELLanguageModel getModel() {
+ return(m_model);
+ }
+
+ /**
+ * This method returns the BPEL process in which the BPEL element
+ * is contained.
+ *
+ * @return The BPEL process, or null if not found
+ */
+ protected Process getProcess() {
+ Process ret=null;
+ ModelObject cur=this;
+
+ while (ret == null && cur != null) {
+ if (cur instanceof Process) {
+ ret = (Process)cur;
+ } else {
+ cur = cur.getParent();
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the element associated with
+ * the supplied name.
+ *
+ * @param name The name
+ * @return The element, or null if not found
+ */
+ public org.w3c.dom.Element findChildElement(String name) {
+ org.w3c.dom.Element ret=null;
+
+ org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+
+ for (int i=0; ret == null && i < nl.getLength(); i++) {
+ org.w3c.dom.Node n=nl.item(i);
+
+ if (n instanceof org.w3c.dom.Element &&
+ n.getLocalName() != null &&
+ n.getLocalName().equals(name)) {
+ ret = (org.w3c.dom.Element)nl.item(i);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the first child BPEL activity
+ * found within the DOM element.
+ *
+ * @return The child BPEL activity, or null if not found
+ */
+ public BPELActivity findChildActivity() {
+ BPELActivity ret=null;
+
+ org.w3c.dom.NodeList nl=getDOMElement().getChildNodes();
+
+ for (int i=0; ret == null &&
+ i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ BPELElement elem = BPELElementFactory.createBPELElement(m_model,
+ (org.w3c.dom.Element)nl.item(i));
+
+ if (elem != null && elem.isActivity() &&
+ elem instanceof BPELActivity) {
+ ret = (BPELActivity)elem;
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the child elements that conform to
+ * the supplied class.
+ *
+ * @param cls The class
+ * @return The list of child elements of the type specified
+ * by the supplied class
+ */
+ public java.util.List<BPELElement> findChildElements(Class<? extends BPELElement> cls) {
+ return(findChildElements(getDOMElement(), cls));
+ }
+
+ /**
+ * This method returns the child elements that conform to
+ * the supplied class.
+ *
+ * @param root The root element
+ * @param cls The class
+ * @return The list of child elements of the type specified
+ * by the supplied class
+ */
+ public java.util.List<BPELElement> findChildElements(org.w3c.dom.Element root,
+ Class<? extends BPELElement> cls) {
+ java.util.List<BPELElement> ret=new java.util.Vector<BPELElement>();
+
+ org.w3c.dom.NodeList nl=root.getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ BPELElement elem=BPELElementFactory.createBPELElement(m_model,
+ (org.w3c.dom.Element)nl.item(i));
+
+ if (elem != null &&
+ cls.isAssignableFrom(elem.getClass())) {
+ ret.add(elem);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets a new element. If an existing element
+ * is specified, then it is replaced with the new element.
+ * Otherwise if an insertBefore node is specified, then
+ * the new element is inserted before it. If no existing
+ * or insertBefore parameters are specified, then the
+ * new element will be appended.<b>
+ * <b>
+ * The new BPEL element will be updated to be associated
+ * with a DOM element that is adopted by the document
+ * into which it is being added.
+ *
+ * @param existing The optional existing element to be
+ * replaced
+ * @param newelem The new element
+ * @param insertBefore Optional location to insert new element
+ */
+ public void setChildElement(org.w3c.dom.Element existing,
+ BPELElement newelem, org.w3c.dom.Node insertBefore) {
+
+ setChildElement(getDOMElement(), existing, newelem, insertBefore);
+ }
+
+ /**
+ * This method sets a new element. If an existing element
+ * is specified, then it is replaced with the new element.
+ * Otherwise if an insertBefore node is specified, then
+ * the new element is inserted before it. If no existing
+ * or insertBefore parameters are specified, then the
+ * new element will be appended.<b>
+ * <b>
+ * The new BPEL element will be updated to be associated
+ * with a DOM element that is adopted by the document
+ * into which it is being added.
+ *
+ * @param root The root element to add child to
+ * @param existing The optional existing element to be
+ * replaced
+ * @param newelem The new element
+ * @param insertBefore Optional location to insert new element
+ */
+ public void setChildElement(org.w3c.dom.Element root,
+ org.w3c.dom.Element existing,
+ BPELElement newelem, org.w3c.dom.Node insertBefore) {
+
+ if (newelem != null) {
+ org.w3c.dom.Node newNode=newelem.getDOMElement().cloneNode(true);
+
+ root.getOwnerDocument().adoptNode(newNode);
+
+ newelem.setDOMElement((org.w3c.dom.Element)newNode);
+
+ if (existing != null) {
+ root.replaceChild(newNode, existing);
+ } else if (insertBefore != null) {
+ root.insertBefore(newNode, insertBefore);
+ } else {
+ root.appendChild(newNode);
+ }
+ }
+ }
+
+ /**
+ * This method converts the BPEL activity into an equivalent
+ * behavioural description for conformance checking.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ public abstract void convert(java.util.List<Activity> activities,
+ ConversionContext context);
+
+ /**
+ * This method returns the URI fragment to the activity within the
+ * BPEL model.
+ *
+ * @return The URI
+ */
+ public String getURI() {
+ String ret="";
+
+ BPELElement parent=null;
+
+ if (getParent() != null) {
+ if (getParent() instanceof BPELElement) {
+ parent = (BPELElement)getParent();
+ }
+ } else if (getDOMElement().getParentNode() instanceof org.w3c.dom.Element) {
+ parent = BPELElementFactory.createBPELElement(getModel(),
+ (org.w3c.dom.Element)getDOMElement().getParentNode());
+ }
+
+ if (parent != null) {
+ ret = parent.getParentURI(this);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method recursively builds up the URI using the local URI
+ * parts for each BPEL element up to the root node.
+ *
+ * @param elem The child element
+ * @return The URI for the parent element
+ */
+ protected String getParentURI(BPELElement elem) {
+ String ret="";
+
+ BPELElement parent=null;
+
+ if (getParent() != null) {
+ if (getParent() instanceof BPELElement) {
+ parent = (BPELElement)getParent();
+ }
+ } else if (elem.getDOMElement().getParentNode() instanceof org.w3c.dom.Element) {
+ parent = BPELElementFactory.createBPELElement(getModel(),
+ (org.w3c.dom.Element)getDOMElement().getParentNode());
+ }
+
+ if (parent != null) {
+ ret = parent.getParentURI(this)+"/"+getLocalURIPart(elem);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the URI part associated with the supplied child element.
+ *
+ * @param elem The child element
+ * @return The URI part
+ */
+ protected String getLocalURIPart(BPELElement elem) {
+ return("");
+ }
+
+ public int hashCode() {
+ return(m_element.hashCode());
+ }
+
+ public boolean equals(Object obj) {
+ boolean ret=false;
+
+ if (obj instanceof BPELElement) {
+ ret = m_element.equals(((BPELElement)obj).getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ private static Log logger = LogFactory.getLog(BPELElement.class);
+
+ private BPELLanguageModel m_model=null;
+ private org.w3c.dom.Element m_element=null;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElementFactory.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElementFactory.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELElementFactory.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.apache.commons.logging.*;
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+
+public class BPELElementFactory {
+
+ public static final String MODEL_COMPONENTS_PACKAGE =
+ "org.jboss.savara.tools.bpel.model.component";
+
+ /**
+ * This method creates a BPELElement instance relevant to the
+ * supplied JBossESB action, associated with the supplied
+ * service.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration of the BPEL activity
+ * @return The BPEL element instance
+ */
+ public static BPELElement createBPELElement(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ BPELElement ret=null;
+ String activityType=elem.getNodeName();
+
+ // Make first character capitalised
+ char ch=Character.toUpperCase(activityType.charAt(0));
+
+ activityType = ch+activityType.substring(1);
+
+ String clsName=MODEL_COMPONENTS_PACKAGE+"."+activityType;
+
+ try {
+ Class<?> cls=(Class<?>)
+ Class.forName(clsName);
+
+ java.lang.reflect.Constructor<?> con=
+ cls.getConstructor(new Class<?>[]{BPELLanguageModel.class,
+ org.w3c.dom.Element.class});
+
+ ret = (BPELElement)con.newInstance(new Object[]{model, elem});
+
+ } catch(Exception e) {
+ logger.warn("Unable to find BPEL element class '"+
+ clsName+"'");
+ }
+
+ return(ret);
+ }
+
+ private static Log logger = LogFactory.getLog(BPELElementFactory.class);
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELGroupingConstruct.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELGroupingConstruct.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/BPELGroupingConstruct.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.apache.commons.logging.*;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This is the generic BPEL activity class.
+ *
+ * @author gary
+ */
+public abstract class BPELGroupingConstruct extends BPELActivity {
+
+ private static final long serialVersionUID = -5550042312010190598L;
+
+ /**
+ * The constructor for initializing the activity based on
+ * an existing DOM element.
+ */
+ protected BPELGroupingConstruct(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The contructor for initializing a new activity.
+ */
+ protected BPELGroupingConstruct(BPELLanguageModel model,
+ String activityName) {
+ super(model, activityName);
+ }
+
+ /**
+ * This method sets the contained activity.
+ *
+ * @param act The contained activity
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ getDOMElement().appendChild(act.getDOMElement());
+ }
+
+ /**
+ * This method returns the contained activity.
+ *
+ * @return The contained activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ private static Log logger = LogFactory.getLog(BPELGroupingConstruct.class);
+
+ private BPELElement m_activity=null;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Catch.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Catch.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Catch.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'catch' construct contained
+ * within the 'faultHandlers' element.
+ */
+public class Catch extends BPELElement {
+
+ private static final long serialVersionUID = 8191152745680660045L;
+
+ public static final String CATCH="catch";
+
+ private static final String FAULT_NAME = "faultName";
+ private static final String FAULT_VARIABLE = "faultVariable";
+ private static final String FAULT_MESSAGE_TYPE = "faultMessageType";
+ private static final String FAULT_MESSAGE_ELEMENT = "faultMessageElement";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public Catch(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Catch(BPELLanguageModel model) {
+ super(model, CATCH);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // Catch is not directly converted, only its contents indirectly as
+ // a fault response in a scope
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELActivity act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELActivity getActivity() {
+ return(m_activity);
+ }
+
+ /**
+ * This method sets the fault name.
+ *
+ * @param faultName The fault name
+ */
+ public void setFaultName(String faultName) {
+ getDOMElement().setAttribute(FAULT_NAME, faultName);
+ }
+
+ /**
+ * This method returns the fault name.
+ *
+ * @return The fault name
+ */
+ public String getFaultName() {
+ return(getDOMElement().hasAttribute(FAULT_NAME)?
+ getDOMElement().getAttribute(FAULT_NAME):null);
+ }
+
+ /**
+ * This method sets the fault variable.
+ *
+ * @param faultVariable The fault variable
+ */
+ public void setFaultVariable(String faultVariable) {
+ getDOMElement().setAttribute(FAULT_VARIABLE, faultVariable);
+ }
+
+ /**
+ * This method returns the fault variable.
+ *
+ * @return The fault variable
+ */
+ public String getFaultVariable() {
+ return(getDOMElement().hasAttribute(FAULT_VARIABLE)?
+ getDOMElement().getAttribute(FAULT_VARIABLE):null);
+ }
+
+ /**
+ * This method sets the fault message type.
+ *
+ * @param faultName The fault message type
+ */
+ public void setFaultMessageType(String faultMessageType) {
+ getDOMElement().setAttribute(FAULT_MESSAGE_TYPE, faultMessageType);
+ }
+
+ /**
+ * This method returns the fault message type.
+ *
+ * @return The fault message type
+ */
+ public String getFaultMessageType() {
+ return(getDOMElement().hasAttribute(FAULT_MESSAGE_TYPE)?
+ getDOMElement().getAttribute(FAULT_MESSAGE_TYPE):null);
+ }
+
+ /**
+ * This method sets the fault message element.
+ *
+ * @param faultName The fault message element
+ */
+ public void setFaultMessageElement(String faultMessageElement) {
+ getDOMElement().setAttribute(FAULT_MESSAGE_ELEMENT, faultMessageElement);
+ }
+
+ /**
+ * This method returns the fault message element.
+ *
+ * @return The fault message element
+ */
+ public String getFaultMessageElement() {
+ return(getDOMElement().hasAttribute(FAULT_MESSAGE_ELEMENT)?
+ getDOMElement().getAttribute(FAULT_MESSAGE_ELEMENT):null);
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof BPELActivity) {
+ ret = "@activity";
+ }
+
+ return(ret);
+ }
+
+ private BPELActivity m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/CatchAll.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/CatchAll.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/CatchAll.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'catchAll' construct contained
+ * within the 'faultHandlers' element.
+ */
+public class CatchAll extends BPELElement {
+
+ private static final long serialVersionUID = 975038289163694699L;
+
+ public static final String CATCHALL="catchAll";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public CatchAll(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public CatchAll(BPELLanguageModel model) {
+ super(model, CATCHALL);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELActivity act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELActivity getActivity() {
+ return(m_activity);
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof BPELActivity) {
+ ret = "@activity";
+ }
+
+ return(ret);
+ }
+
+ private BPELActivity m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/CompensationHandler.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/CompensationHandler.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/CompensationHandler.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'compensationHandler' construct contained
+ * within the 'scope' activity.
+ */
+public class CompensationHandler extends BPELElement {
+
+ private static final long serialVersionUID = -1994083560689296558L;
+
+ public static final String COMPENSATIONHANDLER="compensationHandler";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public CompensationHandler(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public CompensationHandler(BPELLanguageModel model) {
+ super(model, COMPENSATIONHANDLER);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ private BPELElement m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Condition.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Condition.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Condition.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+
+/**
+ * This class represents the BPEL condition element.
+ */
+public class Condition extends AbstractCondition {
+
+ private static final long serialVersionUID = 8666349106632652777L;
+
+ public static final String CONDITION="condition";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public Condition(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Condition(BPELLanguageModel model) {
+ super(model, CONDITION);
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ConversionContext.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ConversionContext.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ConversionContext.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.admin.Context;
+
+public interface ConversionContext {
+
+ /**
+ * This method returns a reference to the environment context.
+ *
+ * @return The environment context
+ */
+ public Context getEnvironmentContext();
+
+ /**
+ * This method returns the process.
+ *
+ * @return The process
+ */
+ public Process getProcess();
+
+ /**
+ * This method returns the role associated with the
+ * endpoint being converted.
+ *
+ *@return The role
+ */
+ public String getRole();
+
+ /**
+ * This method returns the variable associated with the
+ * supplied name.
+ *
+ * @param name The name
+ * @return The variable, or null if not found
+ */
+ public Variable getVariable(String name);
+
+ /**
+ * This method adds a variable to the context.
+ *
+ * @param var The variable
+ */
+ public void addVariable(Variable var);
+
+ /**
+ * This method removes a variable from the context.
+ *
+ * @param var The variable
+ */
+ public void removeVariable(Variable var);
+
+ /**
+ * This method returns the namespace for the supplied prefix.
+ *
+ * @param prefix The prefix
+ * @return The namespace, or null if not found
+ */
+ public String getNamespace(String prefix);
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/DefaultConversionContext.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/DefaultConversionContext.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/DefaultConversionContext.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.admin.Context;
+
+/**
+ * This class provides a default implementation of the conversation
+ * context.
+ */
+public class DefaultConversionContext implements ConversionContext {
+
+ /**
+ * This is the constructor for the conversion context, initialised
+ * with the role being played by the converted BPEL process.
+ *
+ * @param role The role
+ * @param proc The process
+ * @param envContext The environment context
+ */
+ public DefaultConversionContext(String role, Process proc, Context envContext) {
+ m_role = role;
+ m_process = proc;
+ m_environmentContext = envContext;
+ }
+
+ /**
+ * This method returns a reference to the environment context.
+ *
+ * @return The environment context
+ */
+ public Context getEnvironmentContext() {
+ return(m_environmentContext);
+ }
+
+ /**
+ * This method returns the process.
+ *
+ * @return The process
+ */
+ public Process getProcess() {
+ return(m_process);
+ }
+
+ /**
+ * This method returns the role associated with the
+ * endpoint being converted.
+ *
+ *@return The role
+ */
+ public String getRole() {
+ return(m_role);
+ }
+
+ /**
+ * This method returns the variable associated with the
+ * supplied name.
+ *
+ * @param name The name
+ * @return The variable, or null if not found
+ */
+ public Variable getVariable(String name) {
+ return(m_variables.get(name));
+ }
+
+ /**
+ * This method adds a variable to the context.
+ *
+ * @param var The variable
+ */
+ public void addVariable(Variable var) {
+ m_variables.put(var.getName(), var);
+ }
+
+ /**
+ * This method removes a variable from the context.
+ *
+ * @param var The variable
+ */
+ public void removeVariable(Variable var) {
+ m_variables.remove(var.getName());
+ }
+
+ /**
+ * This method returns the namespace for the supplied prefix.
+ *
+ * @param prefix The prefix
+ * @return The namespace, or null if not found
+ */
+ public String getNamespace(String prefix) {
+ return(m_process.getNamespace(prefix));
+ }
+
+ private String m_role=null;
+ private Process m_process=null;
+ private Context m_environmentContext=null;
+ private java.util.Map<String,Variable> m_variables=
+ new java.util.HashMap<String,Variable>();
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Else.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Else.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Else.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'else' construct contained
+ * within the 'if' activity.
+ */
+public class Else extends BPELElement {
+
+ private static final long serialVersionUID = 1243775332210724718L;
+
+ public static final String ELSE="else";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public Else(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Else(BPELLanguageModel model) {
+ super(model, ELSE);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+
+ if (getActivity() != null) {
+ getActivity().convert(activities, context);
+ }
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof BPELActivity) {
+ ret = "@activity";
+ }
+
+ return(ret);
+ }
+
+ private BPELElement m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Elseif.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Elseif.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Elseif.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'elseif' construct contained
+ * within the 'if' activity.
+ */
+public class Elseif extends BPELElement {
+
+ private static final long serialVersionUID = 6371029130621912170L;
+
+ public static final String ELSEIF="elseif";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public Elseif(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ org.w3c.dom.Element cond=
+ findChildElement(Condition.CONDITION);
+
+ if (cond == null) {
+ m_condition = new Condition(model);
+ } else {
+ m_condition = new Condition(model, cond);
+ }
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Elseif(BPELLanguageModel model) {
+ super(model, ELSEIF);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+
+ if (getActivity() != null) {
+ getActivity().convert(activities, context);
+ }
+ }
+
+ /**
+ * This method sets the condition.
+ *
+ * @param cond The condition
+ */
+ public void setCondition(Condition cond) {
+ m_condition = cond;
+
+ setChildElement(findChildElement(Condition.CONDITION),
+ cond, getDOMElement().getFirstChild());
+ }
+
+ /**
+ * This method returns the condition.
+ *
+ * @return The condition
+ */
+ public Condition getCondition() {
+ return(m_condition);
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof BPELActivity) {
+ ret = "@activity";
+ }
+
+ return(ret);
+ }
+
+ private Condition m_condition;
+ private BPELElement m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/EventHandlers.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/EventHandlers.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/EventHandlers.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,230 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents the 'eventHandlers' component within
+ * a 'scope' element.
+ *
+ * @author gary
+ */
+public class EventHandlers extends BPELElement {
+
+ private static final long serialVersionUID = 118381918664522750L;
+
+ public static final String EVENTHANDLERS = "eventHandlers";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public EventHandlers(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ java.util.List<BPELElement> onevts=
+ findChildElements(OnEvent.class);
+
+ for (int i=0; i < onevts.size(); i++) {
+ if (onevts.get(i) instanceof OnEvent) {
+ m_onEvents.add((OnEvent)onevts.get(i));
+ }
+ }
+
+ java.util.List<BPELElement> onalrms=
+ findChildElements(OnAlarm.class);
+
+ for (int i=0; i < onalrms.size(); i++) {
+ if (onalrms.get(i) instanceof OnAlarm) {
+ m_onAlarms.add((OnAlarm)onalrms.get(i));
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public EventHandlers(BPELLanguageModel model) {
+ super(model, EVENTHANDLERS);
+ }
+
+ /**
+ * This method adds an 'onEvent' to the grouping construct.
+ *
+ * @param on The 'onEvent' to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addOnEvent(OnEvent on, int pos) {
+ if (pos == -1 || pos >= m_onEvents.size()) {
+ m_onEvents.add(on);
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_onAlarms.size() > 0) {
+ insertBefore = m_onAlarms.get(0).getDOMElement();
+ }
+
+ setChildElement(null, on, insertBefore);
+ } else {
+
+ OnEvent cur=m_onEvents.get(pos);
+
+ m_onEvents.add(pos, on);
+
+ if (cur != null) {
+ setChildElement(null, on,
+ cur.getDOMElement());
+ } else {
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_onAlarms.size() > 0) {
+ insertBefore = m_onAlarms.get(0).getDOMElement();
+ }
+
+ setChildElement(null, on, insertBefore);
+ }
+ }
+ }
+
+ /**
+ * This method removes an 'onEvent' from the grouping
+ * construct.
+ *
+ * @param on The 'onEvent' to be removed
+ * @return Whether the 'onEvent' was removed
+ */
+ public boolean removeOnEvent(OnEvent on) {
+ boolean ret=m_onEvents.remove(on);
+
+ if (ret) {
+ getDOMElement().removeChild(on.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of 'onEvent' associated
+ * with the grouping construct.
+ *
+ * @return The list of 'onEvent' elements
+ */
+ public java.util.List<OnEvent> getOnEvents() {
+ return(m_onEvents);
+ }
+
+ /**
+ * This method adds an 'onAlarm' to the grouping construct.
+ *
+ * @param on The 'onAlarm' to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addOnAlarm(OnAlarm on, int pos) {
+ if (pos == -1 || pos >= m_onAlarms.size()) {
+ m_onAlarms.add(on);
+
+ setChildElement(null, on, null);
+ } else {
+
+ OnAlarm cur=m_onAlarms.get(pos);
+
+ m_onAlarms.add(pos, on);
+
+ if (cur != null) {
+ setChildElement(null, on,
+ cur.getDOMElement());
+ } else {
+ setChildElement(null, on, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes an 'onAlarm' from the grouping
+ * construct.
+ *
+ * @param on The 'onAlarm' to be removed
+ * @return Whether the 'onAlarm' was removed
+ */
+ public boolean removeOnAlarm(OnAlarm on) {
+ boolean ret=m_onAlarms.remove(on);
+
+ if (ret) {
+ getDOMElement().removeChild(on.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of 'onAlarm' associated
+ * with the grouping construct.
+ *
+ * @return The list of 'onAlarm' elements
+ */
+ public java.util.List<OnAlarm> getOnAlarms() {
+ return(m_onAlarms);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method converts the BPEL activity into an equivalent
+ * behavioural description for conformance checking.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ public void convert(java.util.List<Activity> activities,
+ ConversionContext context) {
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof OnEvent) {
+ ret += "@onEvent."+getOnEvents().indexOf(elem);
+ } else if (elem instanceof OnAlarm) {
+ ret += "@onAlarm."+getOnAlarms().indexOf(elem);
+ }
+
+ return(ret);
+ }
+
+ private java.util.List<OnEvent> m_onEvents=
+ new java.util.Vector<OnEvent>();
+ private java.util.List<OnAlarm> m_onAlarms=
+ new java.util.Vector<OnAlarm>();
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Exit.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Exit.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Exit.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents the exit activity.
+ *
+ * @author gary
+ */
+public class Exit extends BPELActivity {
+
+ private static final long serialVersionUID = -5261386654111234711L;
+
+ public static final String EXIT = "exit";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Exit(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Exit(BPELLanguageModel model) {
+ super(model, EXIT);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ // Don't validate unsupported actions
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/FaultHandlers.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/FaultHandlers.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/FaultHandlers.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.apache.commons.logging.*;
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'faultHandlers' construct contained
+ * within the 'scope' activity.
+ */
+public class FaultHandlers extends BPELElement {
+
+ private static final long serialVersionUID = 4136137332367247503L;
+
+ public static final String FAULTHANDLERS="faultHandlers";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public FaultHandlers(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ java.util.List<BPELElement> paths=
+ findChildElements(Catch.class);
+
+ for (int i=0; i < paths.size(); i++) {
+ m_catchPaths.add((Catch)paths.get(i));
+ }
+
+ paths = findChildElements(CatchAll.class);
+
+ if (paths.size() > 0) {
+ m_catchAll = (CatchAll)paths.get(0);
+
+ if (paths.size() > 1) {
+ logger.error("BPEL 'faultHandlers' has multiple 'catchAll' constructs");
+ }
+ }
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public FaultHandlers(BPELLanguageModel model) {
+ super(model, FAULTHANDLERS);
+ }
+
+ /**
+ * This method adds a 'catch' path.
+ *
+ * @param act The 'catch' path
+ */
+ public void addCatch(Catch act) {
+ m_catchPaths.add(act);
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_catchAll != null) {
+ insertBefore = m_catchAll.getDOMElement();
+ }
+
+ setChildElement(null, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the list of 'catch' paths.
+ *
+ * @return The list of 'catch' paths
+ */
+ public java.util.List<Catch> getCatchPaths() {
+ return(m_catchPaths);
+ }
+
+ /**
+ * This method sets the 'catchAll' path.
+ *
+ * @param act The 'catchAll' path
+ */
+ public void setCatchAll(CatchAll act) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_catchAll != null) {
+ existingElem = m_catchAll.getDOMElement();
+ }
+
+ m_catchAll = act;
+
+ setChildElement(existingElem, act,
+ null);
+ }
+
+ /**
+ * This method returns the 'catchAll' path.
+ *
+ * @return The 'catchAll' path
+ */
+ public CatchAll getCatchAll() {
+ return(m_catchAll);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof Catch) {
+ ret += "@catch."+getCatchPaths().indexOf(elem);
+ } else if (elem instanceof CatchAll) {
+ ret += "@catchAll";
+ }
+
+ return(ret);
+ }
+
+ private static Log logger=LogFactory.getLog(FaultHandlers.class);
+
+ private CatchAll m_catchAll=null;
+ private java.util.List<Catch> m_catchPaths=
+ new java.util.Vector<Catch>();
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Flow.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Flow.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Flow.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,287 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents a flow grouping activity.
+ *
+ */
+public class Flow extends BPELActivity {
+
+ private static final long serialVersionUID = -5165269453306785719L;
+
+ public static final String FLOW = "flow";
+ public static final String LINKS = "links";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Flow(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ org.w3c.dom.Element links=findChildElement("links");
+
+ if (links != null) {
+ org.w3c.dom.NodeList nl=links.getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element &&
+ nl.item(i).getLocalName().equals(Link.LINK)
+ && nl.item(i) instanceof org.w3c.dom.Element) {
+ m_links.add(new Link(model,
+ (org.w3c.dom.Element)nl.item(i)));
+ }
+ }
+ }
+
+ java.util.List<BPELElement> acts=
+ findChildElements(BPELActivity.class);
+
+ for (int i=0; i < acts.size(); i++) {
+ if (acts.get(i).isActivity() &&
+ acts.get(i) instanceof BPELActivity) {
+ m_activities.add((BPELActivity)acts.get(i));
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Flow(BPELLanguageModel model) {
+ super(model, FLOW);
+ }
+
+ /**
+ * This method adds a link to the grouping construct.
+ *
+ * @param link The link to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addLink(Link link, int pos) {
+
+ org.w3c.dom.Element links=null;
+
+ if (m_links.size() == 0) {
+ links = getDOMElement().getOwnerDocument().
+ createElementNS(BPEL_NS, LINKS);
+
+ if (getDOMElement().getFirstChild() == null) {
+ getDOMElement().appendChild(links);
+ } else {
+ getDOMElement().insertBefore(links,
+ getDOMElement().getFirstChild());
+ }
+ } else {
+ links = findChildElement(LINKS);
+ }
+
+ org.w3c.dom.Node newNode=link.getDOMElement().cloneNode(true);
+
+ getDOMElement().getOwnerDocument().adoptNode(newNode);
+
+ link.setDOMElement((org.w3c.dom.Element)newNode);
+
+ if (pos == -1 && pos < m_links.size()) {
+ m_links.add(link);
+
+ links.appendChild(newNode);
+ } else {
+
+ Link cur=m_links.get(pos);
+
+ m_links.add(pos, link);
+
+ if (cur != null) {
+ links.insertBefore(newNode,
+ cur.getDOMElement());
+ } else {
+ links.appendChild(newNode);
+ }
+ }
+ }
+
+ /**
+ * This method removes a link from the grouping
+ * construct.
+ *
+ * @param link The link to be removed
+ * @return Whether the link was removed
+ */
+ public boolean removeLink(Link link) {
+ boolean ret=m_links.remove(link);
+
+ if (ret) {
+ org.w3c.dom.Element links=
+ findChildElement(LINKS);
+
+ if (links != null) {
+ links.removeChild(link.getDOMElement());
+
+ if (m_links.size() == 0) {
+ getDOMElement().removeChild(links);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of links associated
+ * with the grouping construct.
+ *
+ * @return The list of links
+ */
+ public java.util.List<Link> getLinks() {
+ return(m_links);
+ }
+
+ /**
+ * This method adds an activity to the grouping construct.
+ *
+ * @param act The activity to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addActivity(BPELActivity act, int pos) {
+ if (pos == -1 && pos < m_activities.size()) {
+ m_activities.add(act);
+
+ setChildElement(null, act, null);
+ } else {
+
+ BPELActivity cur=m_activities.get(pos);
+
+ m_activities.add(pos, act);
+
+ if (cur != null) {
+ setChildElement(null, act,
+ cur.getDOMElement());
+ } else {
+ setChildElement(null, act, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes an activity from the grouping
+ * construct.
+ *
+ * @param act The activity to be removed
+ * @return Whether the activity was removed
+ */
+ public boolean removeActivity(BPELActivity act) {
+ boolean ret=m_activities.remove(act);
+
+ if (ret) {
+ getDOMElement().removeChild(act.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of activities associated
+ * with the grouping construct.
+ *
+ * @return The list of activities
+ */
+ public java.util.List<BPELActivity> getActivities() {
+ return(m_activities);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+
+ // If links have been defined, represent them as boolean
+ // variables that can be tested using a 'when' clause
+ if (getLinks().size() > 0) {
+ org.scribble.conversation.model.VariableList vl=
+ new org.scribble.conversation.model.VariableList();
+
+ org.scribble.model.TypeReference tref=
+ new org.scribble.model.TypeReference();
+ tref.setLocalpart("boolean");
+
+ vl.setType(tref);
+
+ for (int i=0; i < getLinks().size(); i++) {
+ Link l=getLinks().get(i);
+
+ org.scribble.conversation.model.Variable var=
+ new org.scribble.conversation.model.Variable();
+
+ var.setName(l.getName());
+
+ vl.getVariables().add(var);
+ }
+
+ activities.add(vl);
+ }
+
+ org.scribble.conversation.model.Parallel parallel=
+ new org.scribble.conversation.model.Parallel();
+
+ for (int i=0; i < getActivities().size(); i++) {
+ Block b=new Block();
+
+ getActivities().get(i).convert(b.getContents(), context);
+
+ parallel.getBlocks().add(b);
+ }
+
+ activities.add(parallel);
+ }
+
+ private java.util.List<Link> m_links=
+ new java.util.Vector<Link>();
+ private java.util.List<BPELActivity> m_activities=
+ new java.util.Vector<BPELActivity>();
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/For.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/For.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/For.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+
+/**
+ * This class represents the BPEL 'for' element.
+ */
+public class For extends AbstractCondition {
+
+ private static final long serialVersionUID = -3123540793706121742L;
+
+ public static final String FOR="for";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public For(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public For(BPELLanguageModel model) {
+ super(model, FOR);
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ForEach.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ForEach.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ForEach.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents a forEach grouping activity.
+ *
+ * @author gary
+ */
+public class ForEach extends BPELGroupingConstruct {
+
+ private static final long serialVersionUID = -4302270930464272401L;
+
+ public static final String FOREACH = "forEach";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public ForEach(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ org.w3c.dom.Element scopeElem=
+ findChildElement(Scope.SCOPE);
+
+ if (scopeElem == null) {
+ m_scope = new Scope(model);
+ } else {
+ m_scope = new Scope(model, scopeElem);
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public ForEach(BPELLanguageModel model) {
+ super(model, FOREACH);
+ }
+
+ /**
+ * This method sets the scope.
+ *
+ * @param scope The scope
+ */
+ public void setScope(Scope scope) {
+ m_scope = scope;
+
+ org.w3c.dom.Element existingElem=this.findChildElement(Scope.SCOPE);
+
+ setChildElement(existingElem, scope,
+ null);
+ }
+
+ /**
+ * This method returns the scope.
+ *
+ * @return The scope
+ */
+ public Scope getScope() {
+ return(m_scope);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof Scope) {
+ ret += "@scope";
+ }
+
+ return(ret);
+ }
+
+ private Scope m_scope=null;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/If.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/If.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/If.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,290 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.conversation.model.ConditionalBlock;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.apache.commons.logging.*;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents an 'if' grouping construct.
+ *
+ * @author gary
+ */
+public class If extends BPELActivity {
+
+ private static final long serialVersionUID = -763221632866464831L;
+
+ public static final String IF = "if";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public If(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ org.w3c.dom.Element cond=
+ findChildElement(Condition.CONDITION);
+
+ if (cond == null) {
+ m_condition = new Condition(model);
+ } else {
+ m_condition = new Condition(model, cond);
+ }
+
+ m_activity = findChildActivity();
+
+ java.util.List<BPELElement> paths=
+ findChildElements(Elseif.class);
+
+ for (int i=0; i < paths.size(); i++) {
+ m_elseIfPaths.add((Elseif)paths.get(i));
+ }
+
+ paths = findChildElements(Else.class);
+
+ if (paths.size() > 0) {
+ m_elsePath = (Else)paths.get(0);
+
+ if (paths.size() > 1) {
+ logger.error("BPEL 'if' has multiple 'else' constructs");
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public If(BPELLanguageModel model) {
+ super(model, IF);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+
+ org.scribble.conversation.model.If elem=
+ new org.scribble.conversation.model.If();
+
+ ConditionalBlock cb=new ConditionalBlock();
+
+ // TODO: Convert the conditional expression
+
+ if (getActivity() != null) {
+ getActivity().convert(cb.getContents(), context);
+ }
+
+ elem.getConditionalBlocks().add(cb);
+
+ // Convert 'else if' paths
+ for (int i=0; i < getElseIfPaths().size(); i++) {
+ Elseif elseIfElem=getElseIfPaths().get(i);
+
+ cb = new ConditionalBlock();
+
+ elseIfElem.convert(cb.getContents(), context);
+
+ elem.getConditionalBlocks().add(cb);
+ }
+
+ // Convert 'else' path
+ if (getElsePath() != null) {
+ cb = new ConditionalBlock();
+
+ getElsePath().convert(cb.getContents(), context);
+
+ elem.getConditionalBlocks().add(cb);
+ }
+
+ activities.add(elem);
+ }
+
+ /**
+ * This method sets the condition.
+ *
+ * @param cond The condition
+ */
+ public void setCondition(Condition cond) {
+ m_condition = cond;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_activity != null) {
+ insertBefore = m_activity.getDOMElement();
+ } else if (m_elseIfPaths.size() > 0) {
+ insertBefore = m_elseIfPaths.get(0).getDOMElement();
+ } else if (m_elsePath != null) {
+ insertBefore = m_elsePath.getDOMElement();
+ }
+
+ setChildElement(findChildElement(Condition.CONDITION),
+ cond, insertBefore);
+ }
+
+ /**
+ * This method returns the condition.
+ *
+ * @return The condition
+ */
+ public Condition getCondition() {
+ return(m_condition);
+ }
+
+ /**
+ * This method sets the main 'if' activity.
+ *
+ * @param act The activity associated with the 'if'
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_elseIfPaths.size() > 0) {
+ insertBefore = m_elseIfPaths.get(0).getDOMElement();
+ } else if (m_elsePath != null) {
+ insertBefore = m_elsePath.getDOMElement();
+ }
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'if' path.
+ *
+ * @return The 'if' activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ /**
+ * This method adds an 'else if' path.
+ *
+ * @param act The 'else if' path
+ */
+ public void addElseIfPath(Elseif act) {
+ m_elseIfPaths.add(act);
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_elsePath != null) {
+ insertBefore = m_elsePath.getDOMElement();
+ }
+
+ setChildElement(null, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the list of 'else if' paths.
+ *
+ * @return The list of 'else if' paths
+ */
+ public java.util.List<Elseif> getElseIfPaths() {
+ return(m_elseIfPaths);
+ }
+
+ /**
+ * This method sets the 'else' path.
+ *
+ * @param act The 'else' path
+ */
+ public void setElsePath(Else act) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_elsePath != null) {
+ existingElem = m_elsePath.getDOMElement();
+ }
+
+ m_elsePath = act;
+
+ setChildElement(existingElem, act,
+ null);
+ }
+
+ /**
+ * This method returns the 'else' path.
+ *
+ * @return The 'else' path
+ */
+ public Else getElsePath() {
+ return(m_elsePath);
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof Elseif) {
+ int pos=getElseIfPaths().indexOf(elem);
+ ret = "@elseif."+pos;
+ } else if (elem instanceof Else) {
+ ret = "@else";
+ } else {
+ ret = "@activity";
+ }
+
+ return(ret);
+ }
+
+ private static Log logger=LogFactory.getLog(If.class);
+
+ private Condition m_condition=null;
+ private BPELElement m_activity=null;
+ private Else m_elsePath=null;
+ private java.util.List<Elseif> m_elseIfPaths=
+ new java.util.Vector<Elseif>();
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Import.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Import.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Import.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'import' construct.
+ */
+public class Import extends BPELElement {
+
+ private static final long serialVersionUID = -7103589689575940289L;
+
+ private static final String IMPORT_TYPE = "importType";
+ private static final String NAMESPACE = "namespace";
+ private static final String LOCATION = "location";
+
+ public static final String IMPORT="import";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public Import(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Import(BPELLanguageModel model) {
+ super(model, IMPORT);
+ }
+
+ /**
+ * This method sets the import type.
+ *
+ * @param importType The import type
+ */
+ public void setImportType(String importType) {
+ getDOMElement().setAttribute(IMPORT_TYPE, importType);
+ }
+
+ /**
+ * This method returns the iport type.
+ *
+ * @return The import type
+ */
+ public String getImportType() {
+ return(getDOMElement().hasAttribute(IMPORT_TYPE)?
+ getDOMElement().getAttribute(IMPORT_TYPE):null);
+ }
+
+ /**
+ * This method sets the namespace.
+ *
+ * @param ns The namespace
+ */
+ public void setNamespace(String ns) {
+ getDOMElement().setAttribute(NAMESPACE, ns);
+ }
+
+ /**
+ * This method returns the namespace.
+ *
+ * @return The namespace
+ */
+ public String getNamespace() {
+ return(getDOMElement().hasAttribute(NAMESPACE)?
+ getDOMElement().getAttribute(NAMESPACE):null);
+ }
+
+ /**
+ * This method sets the location.
+ *
+ * @param location The location
+ */
+ public void setLocation(String location) {
+ getDOMElement().setAttribute(LOCATION, location);
+ }
+
+ /**
+ * This method returns the location.
+ *
+ * @return The location
+ */
+ public String getLocation() {
+ return(getDOMElement().hasAttribute(LOCATION)?
+ getDOMElement().getAttribute(LOCATION):null);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Invoke.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Invoke.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Invoke.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,319 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.util.TypeReferenceUtil;
+import org.jboss.savara.bpel.util.XMLUtils;
+
+/**
+ * This class represents an unsupported (or custom) action within
+ * the conversation based ESB service descriptor.
+ *
+ * @author gary
+ */
+public class Invoke extends AbstractInteraction {
+
+ private static final String INPUT_VARIABLE = "inputVariable";
+ private static final String OUTPUT_VARIABLE = "outputVariable";
+ public static final String INVOKE = "invoke";
+
+ private static final long serialVersionUID = 928076947383263387L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Invoke(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Invoke(BPELLanguageModel model) {
+ super(model, INVOKE);
+ }
+
+ /**
+ * This method sets the input variable.
+ *
+ * @param var The input variable
+ */
+ public void setInputVariable(String var) {
+ getDOMElement().setAttribute(INPUT_VARIABLE, var);
+ }
+
+ /**
+ * This method returns the input variable.
+ *
+ * @return The input variable
+ */
+ public String getInputVariable() {
+ return(getDOMElement().hasAttribute(INPUT_VARIABLE)?
+ getDOMElement().getAttribute(INPUT_VARIABLE):null);
+ }
+
+ /**
+ * This method sets the output variable.
+ *
+ * @param var The output variable
+ */
+ public void setOutputVariable(String var) {
+ getDOMElement().setAttribute(OUTPUT_VARIABLE, var);
+ }
+
+ /**
+ * This method returns the output variable.
+ *
+ * @return The output variable
+ */
+ public String getOutputVariable() {
+ return(getDOMElement().hasAttribute(OUTPUT_VARIABLE)?
+ getDOMElement().getAttribute(OUTPUT_VARIABLE):null);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+
+ convertRequest(activities, context);
+
+ // Check if invoke is contained within a scope that defines
+ // fault handlers. If so, then generate choice to throw
+ // fault exceptions.
+ ScopeActivity scope=null;
+ org.w3c.dom.Element cur=getDOMElement();
+
+ while (cur != null && cur.getParentNode() instanceof org.w3c.dom.Element &&
+ scope == null) {
+ cur = (org.w3c.dom.Element)cur.getParentNode();
+
+ if (cur != null) {
+ BPELElement elem=BPELElementFactory.createBPELElement(getModel(),
+ cur);
+
+ if (elem instanceof ScopeActivity) {
+ scope = (ScopeActivity)elem;
+ }
+ }
+ }
+
+ if (scope != null && scope.getFaultHandlers() != null &&
+ (scope.getFaultHandlers().getCatchPaths().size() > 0 ||
+ scope.getFaultHandlers().getCatchAll() != null)) {
+ org.scribble.conversation.model.If te=
+ new org.scribble.conversation.model.If();
+ te.derivedFrom(this);
+
+ activities.add(te);
+
+ org.scribble.conversation.model.ConditionalBlock cb=
+ new org.scribble.conversation.model.ConditionalBlock();
+ te.getConditionalBlocks().add(cb);
+
+ activities = cb.getContents();
+
+ for (int i=0; i < scope.getFaultHandlers().getCatchPaths().size(); i++) {
+ Catch catchBlock=scope.getFaultHandlers().getCatchPaths().get(i);
+
+ org.scribble.conversation.model.ConditionalBlock fcb=
+ new org.scribble.conversation.model.ConditionalBlock();
+
+ String mesgType=catchBlock.getFaultMessageType();
+
+ if (mesgType == null) {
+ mesgType = catchBlock.getFaultMessageElement();
+ }
+
+ Variable faultVar=null;
+
+ if (catchBlock.getFaultVariable() != null) {
+ faultVar = new Variable(getModel());
+ faultVar.setName(catchBlock.getFaultVariable());
+ faultVar.setMessageType(catchBlock.getFaultMessageType());
+ faultVar.setElement(catchBlock.getFaultMessageElement());
+ context.addVariable(faultVar);
+ }
+
+ convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
+ mesgType, context);
+
+ org.scribble.conversation.model.Raise raise=
+ new org.scribble.conversation.model.Raise();
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(catchBlock.getFaultName()));
+ raise.setType(tref);
+
+ fcb.getContents().add(raise);
+
+ te.getConditionalBlocks().add(fcb);
+
+ if (faultVar != null) {
+ context.removeVariable(faultVar);
+ }
+ }
+ }
+
+ if (getOutputVariable() != null) {
+
+ convertResponse(activities, context);
+ }
+ }
+
+ protected void convertRequest(java.util.List<Activity> activities,
+ ConversionContext context) {
+ // Create interaction for request
+ ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
+
+ Variable var=context.getVariable(getInputVariable());
+
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+
+ MessageSignature ms=new MessageSignature();
+ ms.setOperation(getOperation());
+ ms.getTypes().add(tref);
+
+ if (context.getRole() != null) {
+ interaction.setFromRole(new Role(context.getRole()));
+ }
+
+ String toRole=getClientPartnerRole();
+
+ if (toRole != null) {
+ interaction.setToRole(new Role(toRole));
+ }
+
+ interaction.setMessageSignature(ms);
+
+ activities.add(interaction);
+ }
+
+ protected void convertResponse(java.util.List<Activity> activities,
+ ConversionContext context) {
+
+ // Create interaction for request
+ ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
+
+ Variable var=context.getVariable(getOutputVariable());
+
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+
+ MessageSignature ms=new MessageSignature();
+ ms.setOperation(getOperation());
+ ms.getTypes().add(tref);
+
+ String fromRole=getClientPartnerRole();
+
+ if (fromRole != null) {
+ interaction.setFromRole(new Role(fromRole));
+ }
+
+ if (context.getRole() != null) {
+ interaction.setToRole(new Role(context.getRole()));
+ }
+
+ interaction.setMessageSignature(ms);
+
+ activities.add(interaction);
+ }
+
+ protected void convertFaultResponse(java.util.List<Activity> activities,
+ String faultVar, String faultMesgType, ConversionContext context) {
+
+ // Create interaction for request
+ ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
+
+ TypeReference tref=null;
+
+ // TODO: Not sure if fault variable is supposed to be declared
+ // in catch scope, or reused from outer scope?? If declared,
+ // then without the message type/element, may be difficult to
+ // define the message signature.
+
+ Variable var=context.getVariable(faultVar);
+
+ if (var != null) {
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ tref = TypeReferenceUtil.createTypeReference(xmlType, context);
+ //tref.setLocalpart(var.getMessageType());
+ } else if (faultMesgType != null) {
+ tref = TypeReferenceUtil.createTypeReference(faultMesgType, context);
+ //tref.setLocalpart(faultMesgType);
+ }
+
+ MessageSignature ms=new MessageSignature();
+ ms.setOperation(getOperation());
+ ms.getTypes().add(tref);
+
+ String fromRole=getClientPartnerRole();
+
+ if (fromRole != null) {
+ interaction.setFromRole(new Role(fromRole));
+ }
+
+ if (context.getRole() != null) {
+ interaction.setToRole(new Role(context.getRole()));
+ }
+
+ interaction.setMessageSignature(ms);
+
+ activities.add(interaction);
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Link.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Link.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Link.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the BPEL link element, contained within
+ * the flow activity.
+ */
+public class Link extends BPELElement {
+
+ private static final long serialVersionUID = 6889776538490515074L;
+
+ private static final String NAME = "name";
+
+ public static final String LINK="link";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public Link(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Link(BPELLanguageModel model) {
+ super(model, LINK);
+ }
+
+ /**
+ * This method returns the name associated
+ * with the link.
+ *
+ * @return The link name
+ */
+ public String getName() {
+ return(getDOMElement().getAttribute(NAME));
+ }
+
+ /**
+ * This method sets the link name.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ getDOMElement().setAttribute(NAME, name);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnAlarm.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnAlarm.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnAlarm.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'onAlarm' construct contained
+ * within the 'pick' activity.
+ */
+public class OnAlarm extends BPELElement {
+
+ private static final long serialVersionUID = 271323368015539L;
+
+ public static final String ONALARM="onAlarm";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public OnAlarm(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public OnAlarm(BPELLanguageModel model) {
+ super(model, ONALARM);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * This method sets the 'until' condition.
+ *
+ * @param cond The 'until' condition
+ */
+ public void setUntil(Until cond) {
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_activity != null) {
+ insertBefore = m_activity.getDOMElement();
+ }
+
+ setChildElement(findChildElement(Until.UNTIL),
+ cond, insertBefore);
+
+ org.w3c.dom.Element elem=findChildElement(For.FOR);
+ if (elem != null) {
+ getDOMElement().removeChild(elem);
+ }
+ }
+
+ /**
+ * This method returns the 'until' condition.
+ *
+ * @return The 'until' condition
+ */
+ public Until getUntil() {
+ Until ret=null;
+
+ org.w3c.dom.Element elem=findChildElement(Until.UNTIL);
+ if (elem != null) {
+ ret = new Until(getModel(), elem);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the 'for' condition.
+ *
+ * @param cond The 'for' condition
+ */
+ public void setFor(For cond) {
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_activity != null) {
+ insertBefore = m_activity.getDOMElement();
+ }
+
+ setChildElement(findChildElement(For.FOR),
+ cond, insertBefore);
+
+ org.w3c.dom.Element elem=findChildElement(Until.UNTIL);
+ if (elem != null) {
+ getDOMElement().removeChild(elem);
+ }
+ }
+
+ /**
+ * This method returns the 'for' condition.
+ *
+ * @return The 'for' condition
+ */
+ public For getFor() {
+ For ret=null;
+
+ org.w3c.dom.Element elem=findChildElement(For.FOR);
+ if (elem != null) {
+ ret = new For(getModel(), elem);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof Scope) {
+ ret = "@scope";
+ } else {
+ ret = "@activity";
+ }
+
+ return(ret);
+ }
+
+ private BPELElement m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnEvent.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnEvent.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnEvent.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,191 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'onEvent' construct contained
+ * within the 'EventHandler' element.
+ */
+public class OnEvent extends BPELElement {
+
+ private static final long serialVersionUID = -2444989267977027500L;
+
+ private static final String PARTNER_LINK = "partnerLink";
+ private static final String PORT_TYPE = "portType";
+ private static final String OPERATION = "operation";
+ private static final String VARIABLE = "variable";
+
+ public static final String ONEVENT="onEvent";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public OnEvent(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ BPELElement elem=findChildActivity();
+
+ if (elem instanceof Scope) {
+ m_scope = (Scope)elem;
+ }
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public OnEvent(BPELLanguageModel model) {
+ super(model, ONEVENT);
+ }
+
+ /**
+ * This method sets the operation.
+ *
+ * @param op The operation
+ */
+ public void setOperation(String op) {
+ getDOMElement().setAttribute(OPERATION, op);
+ }
+
+ /**
+ * This method returns the operation.
+ *
+ * @return The operation
+ */
+ public String getOperation() {
+ return(getDOMElement().hasAttribute(OPERATION)?
+ getDOMElement().getAttribute(OPERATION):null);
+ }
+
+ /**
+ * This method sets the partner link.
+ *
+ * @param pl The partner link
+ */
+ public void setPartnerLink(String pl) {
+ getDOMElement().setAttribute(PARTNER_LINK, pl);
+ }
+
+ /**
+ * This method returns the partner link.
+ *
+ * @return The partner link
+ */
+ public String getPartnerLink() {
+ return(getDOMElement().hasAttribute(PARTNER_LINK)?
+ getDOMElement().getAttribute(PARTNER_LINK):null);
+ }
+
+ /**
+ * This method sets the port type.
+ *
+ * @param pt The port type
+ */
+ public void setPortType(String pt) {
+ getDOMElement().setAttribute(PORT_TYPE, pt);
+ }
+
+ /**
+ * This method returns the port type.
+ *
+ * @return The port type
+ */
+ public String getPortType() {
+ return(getDOMElement().hasAttribute(PORT_TYPE)?
+ getDOMElement().getAttribute(PORT_TYPE):null);
+ }
+
+ /**
+ * This method sets the variable.
+ *
+ * @param var The variable
+ */
+ public void setVariable(String var) {
+ getDOMElement().setAttribute(VARIABLE, var);
+ }
+
+ /**
+ * This method returns the variable.
+ *
+ * @return The variable
+ */
+ public String getVariable() {
+ return(getDOMElement().hasAttribute(VARIABLE)?
+ getDOMElement().getAttribute(VARIABLE):null);
+ }
+
+ /**
+ * This method sets the scope associated with
+ * the 'onEvent' construct.
+ *
+ * @param scope The scope
+ */
+ public void setScope(Scope scope) {
+ m_scope = scope;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, scope,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the scope associated with
+ * the 'onEvent' construct.
+ *
+ * @return The scope
+ */
+ public Scope getScope() {
+ return(m_scope);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof Scope) {
+ ret += "@scope";
+ }
+
+ return(ret);
+ }
+
+ private Scope m_scope;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnMessage.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnMessage.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/OnMessage.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,237 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.jboss.savara.bpel.model.util.TypeReferenceUtil;
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.Activity;
+import org.scribble.model.MessageSignature;
+import org.scribble.model.Role;
+import org.scribble.model.TypeReference;
+
+/**
+ * This class represents the 'onMessage' construct contained
+ * within the 'pick' activity.
+ */
+public class OnMessage extends BPELElement {
+
+ private static final long serialVersionUID = -827946684365823245L;
+
+ private static final String PARTNER_LINK = "partnerLink";
+ private static final String PORT_TYPE = "portType";
+ private static final String OPERATION = "operation";
+ private static final String VARIABLE = "variable";
+
+ public static final String ONMESSAGE="onMessage";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public OnMessage(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public OnMessage(BPELLanguageModel model) {
+ super(model, ONMESSAGE);
+ }
+
+ /**
+ * This method sets the operation.
+ *
+ * @param op The operation
+ */
+ public void setOperation(String op) {
+ getDOMElement().setAttribute(OPERATION, op);
+ }
+
+ /**
+ * This method returns the operation.
+ *
+ * @return The operation
+ */
+ public String getOperation() {
+ return(getDOMElement().hasAttribute(OPERATION)?
+ getDOMElement().getAttribute(OPERATION):null);
+ }
+
+ /**
+ * This method sets the partner link.
+ *
+ * @param pl The partner link
+ */
+ public void setPartnerLink(String pl) {
+ getDOMElement().setAttribute(PARTNER_LINK, pl);
+ }
+
+ /**
+ * This method returns the partner link.
+ *
+ * @return The partner link
+ */
+ public String getPartnerLink() {
+ return(getDOMElement().hasAttribute(PARTNER_LINK)?
+ getDOMElement().getAttribute(PARTNER_LINK):null);
+ }
+
+ /**
+ * This method sets the port type.
+ *
+ * @param pt The port type
+ */
+ public void setPortType(String pt) {
+ getDOMElement().setAttribute(PORT_TYPE, pt);
+ }
+
+ /**
+ * This method returns the port type.
+ *
+ * @return The port type
+ */
+ public String getPortType() {
+ return(getDOMElement().hasAttribute(PORT_TYPE)?
+ getDOMElement().getAttribute(PORT_TYPE):null);
+ }
+
+ /**
+ * This method sets the variable.
+ *
+ * @param var The variable
+ */
+ public void setVariable(String var) {
+ getDOMElement().setAttribute(VARIABLE, var);
+ }
+
+ /**
+ * This method returns the variable.
+ *
+ * @return The variable
+ */
+ public String getVariable() {
+ return(getDOMElement().hasAttribute(VARIABLE)?
+ getDOMElement().getAttribute(VARIABLE):null);
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ /**
+ * This method attempts to identify the server's partner role name.
+ *
+ * @return The partner role
+ */
+ protected String getServerPartnerRole() {
+ String ret=getPartnerLink();
+ int index=-1;
+
+ if (ret != null && (index=ret.indexOf("To")) != -1) {
+ ret = ret.substring(0, index);
+ }
+
+ return(ret);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+
+ ConversationInteraction interaction=new ConversationInteraction();
+
+ Variable var=context.getVariable(getVariable());
+
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+
+ MessageSignature ms=new MessageSignature();
+ ms.setOperation(getOperation());
+ ms.getTypes().add(tref);
+
+ String fromRole=getServerPartnerRole();
+
+ if (fromRole != null) {
+ interaction.setFromRole(new Role(fromRole));
+ }
+
+ if (context.getRole() != null) {
+ interaction.setToRole(new Role(context.getRole()));
+ }
+
+ interaction.setMessageSignature(ms);
+
+ activities.add(interaction);
+
+ if (getActivity() != null) {
+ getActivity().convert(activities, context);
+ }
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof BPELActivity) {
+ ret = "@activity";
+ }
+
+ return(ret);
+ }
+
+ private BPELElement m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/PartnerLink.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/PartnerLink.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/PartnerLink.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'partnerLink' construct.
+ */
+public class PartnerLink extends BPELElement {
+
+ private static final long serialVersionUID = 8342639172267763736L;
+
+ private static final String NAME = "name";
+ private static final String PARTNER_LINK_TYPE = "partnerLinkType";
+ private static final String MY_ROLE = "myRole";
+ private static final String PARTNER_ROLE = "partnerRole";
+
+ public static final String PARTNERLINK="partnerLink";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public PartnerLink(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public PartnerLink(BPELLanguageModel model) {
+ super(model, PARTNERLINK);
+ }
+
+ /**
+ * This method sets the name.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ getDOMElement().setAttribute(NAME, name);
+ }
+
+ /**
+ * This method returns the name.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(getDOMElement().hasAttribute(NAME)?
+ getDOMElement().getAttribute(NAME):null);
+ }
+
+ /**
+ * This method sets the partner link type.
+ *
+ * @param pl The partner link type
+ */
+ public void setPartnerLinkType(String pl) {
+ getDOMElement().setAttribute(PARTNER_LINK_TYPE, pl);
+ }
+
+ /**
+ * This method returns the partner link type.
+ *
+ * @return The partner link type
+ */
+ public String getPartnerLinkType() {
+ return(getDOMElement().hasAttribute(PARTNER_LINK_TYPE)?
+ getDOMElement().getAttribute(PARTNER_LINK_TYPE):null);
+ }
+
+ /**
+ * This method sets my role.
+ *
+ * @param role My role
+ */
+ public void setMyRole(String role) {
+ getDOMElement().setAttribute(MY_ROLE, role);
+ }
+
+ /**
+ * This method returns my role.
+ *
+ * @return My role
+ */
+ public String getMyRole() {
+ return(getDOMElement().hasAttribute(MY_ROLE)?
+ getDOMElement().getAttribute(MY_ROLE):null);
+ }
+
+ /**
+ * This method sets partner role.
+ *
+ * @param role Partner role
+ */
+ public void setPartnerRole(String role) {
+ getDOMElement().setAttribute(PARTNER_ROLE, role);
+ }
+
+ /**
+ * This method returns partner role.
+ *
+ * @return Partner role
+ */
+ public String getPartnerRole() {
+ return(getDOMElement().hasAttribute(PARTNER_ROLE)?
+ getDOMElement().getAttribute(PARTNER_ROLE):null);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Pick.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Pick.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Pick.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,284 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.conversation.model.ConditionalBlock;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents a pick grouping activity.
+ *
+ * @author gary
+ */
+public class Pick extends BPELActivity {
+
+ private static final long serialVersionUID = -2235972351406517577L;
+
+ public static final String PICK = "pick";
+ public static final String CREATE_INSTANCE = "createInstance";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Pick(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ java.util.List<BPELElement> onmesgs=
+ findChildElements(OnMessage.class);
+
+ for (int i=0; i < onmesgs.size(); i++) {
+ if (onmesgs.get(i) instanceof OnMessage) {
+ m_onMessages.add((OnMessage)onmesgs.get(i));
+ }
+ }
+
+ java.util.List<BPELElement> onalrms=
+ findChildElements(OnAlarm.class);
+
+ for (int i=0; i < onalrms.size(); i++) {
+ if (onalrms.get(i) instanceof OnAlarm) {
+ m_onAlarms.add((OnAlarm)onalrms.get(i));
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Pick(BPELLanguageModel model) {
+ super(model, PICK);
+ }
+
+ /**
+ * This method sets the 'create instance'
+ * attribute.
+ *
+ * @param b Whether to create instance
+ */
+ public void setCreateInstance(boolean b) {
+ String create=(b?"yes":"no");
+
+ getDOMElement().setAttribute(CREATE_INSTANCE, create);
+ }
+
+ /**
+ * This method returns whether to create instance.
+ *
+ * @return Whether to create instance
+ */
+ public boolean getCreateInstance() {
+ boolean ret=false;
+ String create=
+ getDOMElement().getAttribute(CREATE_INSTANCE);
+
+ if (create != null &&
+ create.equals("yes")) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds an 'onMessage' to the grouping construct.
+ *
+ * @param on The 'onMessage' to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addOnMessage(OnMessage on, int pos) {
+ if (pos == -1 || pos >= m_onMessages.size()) {
+ m_onMessages.add(on);
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_onAlarms.size() > 0) {
+ insertBefore = m_onAlarms.get(0).getDOMElement();
+ }
+
+ setChildElement(null, on, insertBefore);
+ } else {
+
+ OnMessage cur=m_onMessages.get(pos);
+
+ m_onMessages.add(pos, on);
+
+ if (cur != null) {
+ setChildElement(null, on,
+ cur.getDOMElement());
+ } else {
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_onAlarms.size() > 0) {
+ insertBefore = m_onAlarms.get(0).getDOMElement();
+ }
+
+ setChildElement(null, on, insertBefore);
+ }
+ }
+ }
+
+ /**
+ * This method removes an 'onMessage' from the grouping
+ * construct.
+ *
+ * @param on The 'onMessage' to be removed
+ * @return Whether the 'onMessage' was removed
+ */
+ public boolean removeOnMessage(OnMessage on) {
+ boolean ret=m_onMessages.remove(on);
+
+ if (ret) {
+ getDOMElement().removeChild(on.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of 'onMessage' associated
+ * with the grouping construct.
+ *
+ * @return The list of 'onMessage' elements
+ */
+ public java.util.List<OnMessage> getOnMessages() {
+ return(m_onMessages);
+ }
+
+ /**
+ * This method adds an 'onAlarm' to the grouping construct.
+ *
+ * @param on The 'onAlarm' to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addOnAlarm(OnAlarm on, int pos) {
+ if (pos == -1 || pos >= m_onAlarms.size()) {
+ m_onAlarms.add(on);
+
+ setChildElement(null, on, null);
+ } else {
+
+ OnAlarm cur=m_onAlarms.get(pos);
+
+ m_onAlarms.add(pos, on);
+
+ if (cur != null) {
+ setChildElement(null, on,
+ cur.getDOMElement());
+ } else {
+ setChildElement(null, on, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes an 'onAlarm' from the grouping
+ * construct.
+ *
+ * @param on The 'onAlarm' to be removed
+ * @return Whether the 'onAlarm' was removed
+ */
+ public boolean removeOnAlarm(OnAlarm on) {
+ boolean ret=m_onAlarms.remove(on);
+
+ if (ret) {
+ getDOMElement().removeChild(on.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of 'onAlarm' associated
+ * with the grouping construct.
+ *
+ * @return The list of 'onAlarm' elements
+ */
+ public java.util.List<OnAlarm> getOnAlarms() {
+ return(m_onAlarms);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+
+ org.scribble.conversation.model.If elem=
+ new org.scribble.conversation.model.If();
+
+ // Convert 'onMessage' paths
+ for (int i=0; i < getOnMessages().size(); i++) {
+ OnMessage onMessageElem=getOnMessages().get(i);
+
+ ConditionalBlock cb = new ConditionalBlock();
+
+ onMessageElem.convert(cb.getContents(), context);
+
+ elem.getConditionalBlocks().add(cb);
+ }
+
+ // TODO: If alarms defined, then model these using a
+ // try/catch with interrupt?
+
+ activities.add(elem);
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof OnMessage) {
+ ret += "@onMessage."+getOnMessages().indexOf(elem);
+ } else if (elem instanceof OnAlarm) {
+ ret += "@onAlarm."+getOnAlarms().indexOf(elem);
+ }
+
+ return(ret);
+ }
+
+ private java.util.List<OnMessage> m_onMessages=
+ new java.util.Vector<OnMessage>();
+ private java.util.List<OnAlarm> m_onAlarms=
+ new java.util.Vector<OnAlarm>();
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Process.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Process.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Process.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,977 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.scribble.conversation.model.ConditionalBlock;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.conversation.model.ConversationNotation;
+import org.scribble.model.*;
+import org.scribble.model.admin.Context;
+import org.scribble.model.admin.ModelListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.util.InteractionUtil;
+import org.jboss.savara.bpel.util.XMLUtils;
+
+/**
+ * This class represents a BPEL process.
+ *
+ * @author gary
+ */
+public class Process extends BPELElement implements ScopeActivity {
+
+ private static final long serialVersionUID = 3400962966628415184L;
+
+ public static final String PROCESS = "process";
+ public static final String NAME = "name";
+ public static final String TARGET_NAMESPACE = "targetNamespace";
+ public static final String CONVERSATION_TYPE = "conversationType";
+ public static final String BPEL_PREFIX = "bpel";
+
+ public static final String CONVERSATION_NS="http://www.scribble.org/conversation";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Process(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ java.util.List<BPELElement> imports=findChildElements(Import.class);
+ for (BPELElement elem : imports) {
+ m_imports.add((Import)elem);
+ }
+
+ m_partnerLinksElem = findChildElement("partnerLinks");
+
+ if (m_partnerLinksElem != null) {
+ java.util.List<BPELElement> elems=
+ findChildElements(m_partnerLinksElem,
+ PartnerLink.class);
+
+ for (int i=0; i < elems.size(); i++) {
+ m_partnerLinks.add((PartnerLink)elems.get(i));
+ }
+ }
+
+ m_variablesElem = findChildElement("variables");
+
+ if (m_variablesElem != null) {
+ java.util.List<BPELElement> elems=
+ findChildElements(m_variablesElem,
+ Variable.class);
+
+ for (int i=0; i < elems.size(); i++) {
+ m_variables.add((Variable)elems.get(i));
+ }
+ }
+
+ //m_messageExchangesElem = findChildElement("messageExchanges");
+ //m_correlationSetsElem = findChildElement("correlationSets");
+
+ org.w3c.dom.Element ehs=findChildElement(EventHandlers.EVENTHANDLERS);
+ if (ehs != null) {
+ m_eventHandlers = new EventHandlers(model, ehs);
+ }
+
+ org.w3c.dom.Element fhs=findChildElement(FaultHandlers.FAULTHANDLERS);
+ if (fhs != null) {
+ m_faultHandlers = new FaultHandlers(model, fhs);
+ }
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Process(BPELLanguageModel model) {
+ super(model, PROCESS);
+
+ initNamespace(BPEL_NS, BPEL_PREFIX);
+ }
+
+ /**
+ * This method adds an import to the scope.
+ *
+ * @param imp The import to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addImport(Import imp, int pos) {
+
+ if (pos != -1 && pos < m_imports.size()) {
+ m_imports.add(pos, imp);
+ } else {
+ m_imports.add(imp);
+ }
+
+ java.util.List<BPELElement> children=findChildElements(BPELElement.class);
+
+ org.w3c.dom.Node newNode=imp.getDOMElement().cloneNode(true);
+
+ getDOMElement().getOwnerDocument().adoptNode(newNode);
+
+ if (pos != -1 && pos < children.size()) {
+ getDOMElement().insertBefore(newNode, children.get(pos).getDOMElement());
+ } else {
+ getDOMElement().appendChild(newNode);
+ }
+ }
+
+ /**
+ * This method removes a partner link from the grouping
+ * construct.
+ *
+ * @param pl The partner link to be removed
+ * @return Whether the partner link was removed
+ */
+ public boolean removeImport(Import imp) {
+ boolean ret=m_imports.remove(imp);
+
+ if (ret) {
+ getDOMElement().removeChild(imp.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of imports.
+ *
+ * @return The imports
+ */
+ public java.util.List<Import> getImports() {
+ return(m_imports);
+ }
+
+ /**
+ * This method searches the defined WSDL definitions to identify
+ * the underlying XML element/type associated with the supplied
+ * WSDL message type.
+ *
+ * @param wsdlMessageType The WSDL message type
+ * @param context The context
+ * @return The underlying XML element/type, or null if not found
+ */
+ public String getXMLType(String wsdlMessageType, Context context) {
+ String ret=null;
+
+ // Resolve the namespace prefix
+ int index=wsdlMessageType.indexOf(':');
+
+ if (index != -1 && context != null) {
+ String prefix=wsdlMessageType.substring(0, index);
+
+ String namespace=getNamespace(prefix);
+
+ wsdlMessageType = wsdlMessageType.substring(index+1);
+
+ for (Import imp : getImports()) {
+
+ // Check if import relates to the correct namespace
+ if (imp.getNamespace() != null &&
+ imp.getNamespace().equals(namespace) &&
+ imp.getLocation() != null &&
+ imp.getLocation().endsWith(".wsdl")) {
+
+ java.net.URI uri=
+ context.getResourceURI(getModel().getModelReference(),
+ imp.getLocation());
+
+ if (uri != null) {
+ ret = getXMLType(imp.getNamespace(), wsdlMessageType, uri);
+
+ if (ret != null) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ protected String getXMLType(String namespace, String wsdlMessageType, java.net.URI uri) {
+ String ret=null;
+
+ try {
+ WSDLReader reader=javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
+
+ javax.wsdl.Definition defn=reader.readWSDL(uri.toString());
+
+ if (defn != null) {
+ javax.wsdl.Message mesg=defn.getMessage(new QName(namespace, wsdlMessageType));
+
+ if (mesg != null && mesg.getParts().size() == 1) {
+ javax.wsdl.Part part=(javax.wsdl.Part)
+ mesg.getParts().values().iterator().next();
+
+ if (part.getElementName() != null) {
+ ret = part.getElementName().toString();
+ } else if (part.getTypeName() != null) {
+ ret = part.getTypeName().toString();
+ }
+ }
+ }
+
+ } catch(Exception e) {
+ logger.error("Failed to read WSDL", e);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of partner links.
+ *
+ * @return The partner links
+ */
+ public java.util.List<PartnerLink> getPartnerLinks() {
+ return(m_partnerLinks);
+ }
+
+ /**
+ * This method returns the partner link associated
+ * with the supplied name.
+ *
+ * @param name The name
+ * @return The partner link, or null if not found
+ */
+ public PartnerLink getPartnerLink(String name) {
+ PartnerLink ret=null;
+
+ for (int i=0; ret == null && i < m_partnerLinks.size(); i++) {
+ if (m_partnerLinks.get(i).getName().equals(name)) {
+ ret = m_partnerLinks.get(i);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a partner link to the scope.
+ *
+ * @param pl The partner link to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addPartnerLink(PartnerLink pl, int pos) {
+
+ if (m_partnerLinksElem == null) {
+ m_partnerLinksElem = getDOMElement().getOwnerDocument().
+ createElementNS(BPEL_NS, "partnerLinks");
+
+ // Add to parent
+ org.w3c.dom.Element insertBefore=
+ findChildElement("messageExchanges");
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("variables");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("correlationSets");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("faultHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("eventHandlers");
+ }
+
+ if (insertBefore == null) {
+ BPELElement elem=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = elem.getDOMElement();
+ }
+ }
+
+ if (insertBefore != null) {
+ getDOMElement().insertBefore(m_partnerLinksElem, insertBefore);
+ } else {
+ getDOMElement().appendChild(m_partnerLinksElem);
+ }
+ }
+
+ if (pos == -1 || pos >= m_partnerLinks.size()) {
+ m_partnerLinks.add(pl);
+
+ setChildElement(m_partnerLinksElem, null, pl, null);
+ } else {
+
+ PartnerLink cur=m_partnerLinks.get(pos);
+
+ m_partnerLinks.add(pos, pl);
+
+ if (cur != null) {
+ setChildElement(m_partnerLinksElem, null, pl,
+ cur.getDOMElement());
+ } else {
+ setChildElement(m_partnerLinksElem, null, pl, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes a partner link from the grouping
+ * construct.
+ *
+ * @param pl The partner link to be removed
+ * @return Whether the partner link was removed
+ */
+ public boolean removePartnerLink(PartnerLink pl) {
+ boolean ret=m_partnerLinks.remove(pl);
+
+ if (ret) {
+ m_partnerLinksElem.removeChild(pl.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the name.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ getDOMElement().setAttribute(NAME, name);
+ }
+
+ /**
+ * This method returns the name.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(getDOMElement().hasAttribute(NAME)?
+ getDOMElement().getAttribute(NAME):null);
+ }
+
+ /**
+ * This method sets the target namespace.
+ *
+ * @param tns The target namespace
+ */
+ public void setTargetNamespace(String tns) {
+ getDOMElement().setAttribute(TARGET_NAMESPACE, tns);
+ }
+
+ /**
+ * This method returns the target namespace.
+ *
+ * @return The target namespace
+ */
+ public String getTargetNamespace() {
+ return(getDOMElement().hasAttribute(TARGET_NAMESPACE)?
+ getDOMElement().getAttribute(TARGET_NAMESPACE):null);
+ }
+
+ /**
+ * This method sets the conversation type.
+ *
+ * @param ctype The conversation type
+ */
+ public void setConversationType(String ctype) {
+ getDOMElement().setAttributeNS(CONVERSATION_NS, CONVERSATION_TYPE, ctype);
+ }
+
+ /**
+ * This method returns the conversation type.
+ *
+ * @return The conversation type
+ */
+ public String getConversationType() {
+ return(getDOMElement().hasAttributeNS(CONVERSATION_NS, CONVERSATION_TYPE)?
+ getDOMElement().getAttributeNS(CONVERSATION_NS, CONVERSATION_TYPE):null);
+ }
+
+ /**
+ * This method returns the prefix associated with the
+ * supplied namespace.
+ *
+ * @param namespace The namespace
+ * @return The prefix, or null if not found
+ */
+ public String getPrefix(String namespace) {
+ String ret=null;
+
+ org.w3c.dom.NamedNodeMap map=getDOMElement().getAttributes();
+
+ for (int i=0; ret == null && i < map.getLength(); i++) {
+ org.w3c.dom.Node node=map.item(i);
+
+ if (node instanceof org.w3c.dom.Attr) {
+ org.w3c.dom.Attr attr=(org.w3c.dom.Attr)node;
+
+ if (attr.getNodeValue().equals(namespace) &&
+ attr.getNodeName().startsWith("xmlns:")) {
+ ret = attr.getNodeName().substring(6);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the namespace for the supplied prefix.
+ *
+ * @param prefix The prefix
+ * @return The namespace, or null if not found
+ */
+ public String getNamespace(String prefix) {
+ String ret=null;
+
+ org.w3c.dom.NamedNodeMap map=getDOMElement().getAttributes();
+
+ for (int i=0; ret == null && i < map.getLength(); i++) {
+ org.w3c.dom.Node node=map.item(i);
+
+ if (node instanceof org.w3c.dom.Attr) {
+ org.w3c.dom.Attr attr=(org.w3c.dom.Attr)node;
+
+ if (attr.getNodeName().equals("xmlns:"+prefix) ||
+ attr.getNodeName().equals(prefix)) {
+ ret = attr.getNodeValue();
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method initialises the prefix associated with the supplied
+ * namespace.
+ *
+ * @param namespace
+ * @param prefix
+ */
+ public void initNamespace(String namespace, String prefix) {
+ getDOMElement().setAttribute("xmlns:"+prefix, namespace);
+ }
+
+ /**
+ * This method adds a new namespace and returns the
+ * prefix allocated to it.
+ *
+ * @param namespace The namespace to be added
+ * @return The prefix
+ */
+ public String addNamespace(String namespace) {
+ String ret=getPrefix(namespace);
+ int i=1;
+
+ while (ret == null) {
+ String prefix="ns"+(i++);
+
+ if (getDOMElement().hasAttribute("xmlns:"+prefix) == false) {
+ ret = prefix;
+
+ getDOMElement().setAttribute("xmlns:"+prefix, namespace);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method adds a variable to the scope.
+ *
+ * @param var The variable to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addVariable(Variable var, int pos) {
+
+ if (m_variablesElem == null) {
+ m_variablesElem = getDOMElement().getOwnerDocument().
+ createElementNS(BPEL_NS, "variables");
+
+ // Add to parent
+ org.w3c.dom.Element insertBefore=
+ findChildElement("correlationSets");
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("faultHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("eventHandlers");
+ }
+
+ if (insertBefore == null) {
+ BPELElement elem=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = elem.getDOMElement();
+ }
+ }
+
+ if (insertBefore != null) {
+ getDOMElement().insertBefore(m_variablesElem, insertBefore);
+ } else {
+ getDOMElement().appendChild(m_variablesElem);
+ }
+ }
+
+ if (pos == -1 || pos >= m_variables.size()) {
+ m_variables.add(var);
+
+ setChildElement(m_variablesElem, null, var, null);
+ } else {
+
+ Variable cur=m_variables.get(pos);
+
+ m_variables.add(pos, var);
+
+ if (cur != null) {
+ setChildElement(m_variablesElem, null, var,
+ cur.getDOMElement());
+ } else {
+ setChildElement(m_variablesElem, null, var, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes an activity from the grouping
+ * construct.
+ *
+ * @param act The activity to be removed
+ * @return Whether the activity was removed
+ */
+ public boolean removeVariable(Variable var) {
+ boolean ret=m_variables.remove(var);
+
+ if (ret) {
+ m_variablesElem.removeChild(var.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of variables.
+ *
+ * @return The
+ */
+ public java.util.List<Variable> getVariables() {
+ return(m_variables);
+ }
+
+ /**
+ * This method returns the variable associated
+ * with the supplied name.
+ *
+ * @param name The name
+ * @return The variable, or null if not found
+ */
+ public Variable getVariable(String name) {
+ Variable ret=null;
+
+ for (int i=0; ret == null && i < m_variables.size(); i++) {
+ if (m_variables.get(i).getName().equals(name)) {
+ ret = m_variables.get(i);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELActivity act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELActivity getActivity() {
+ return(m_activity);
+ }
+
+ /**
+ * This method sets the 'eventHandlers' path.
+ *
+ * @param elem The 'eventHandlers' path
+ */
+ public void setEventHandlers(EventHandlers elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_eventHandlers != null) {
+ existingElem = m_eventHandlers.getDOMElement();
+ }
+
+ m_eventHandlers = elem;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (insertBefore == null) {
+ BPELElement act=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = act.getDOMElement();
+ }
+ }
+
+ setChildElement(existingElem, elem,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the 'eventHandlers' path.
+ *
+ * @return The 'eventHandlers' path
+ */
+ public EventHandlers getEventHandlers() {
+ return(m_eventHandlers);
+ }
+
+ /**
+ * This method sets the 'faultHandlers' path.
+ *
+ * @param elem The 'faultHandlers' path
+ */
+ public void setFaultHandlers(FaultHandlers elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_faultHandlers != null) {
+ existingElem = m_faultHandlers.getDOMElement();
+ }
+
+ m_faultHandlers = elem;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("eventHandlers");
+ }
+
+ if (insertBefore == null) {
+ BPELElement act=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = act.getDOMElement();
+ }
+ }
+
+ setChildElement(existingElem, elem,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the 'faultHandlers' path.
+ *
+ * @return The 'faultHandlers' path
+ */
+ public FaultHandlers getFaultHandlers() {
+ return(m_faultHandlers);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ public void convert(java.util.List<Activity> activities,
+ ConversionContext context) {
+
+ // Add variables to the context
+ for (int i=0; i < m_variables.size(); i++) {
+ context.addVariable(m_variables.get(i));
+ }
+
+ // Count number of invoke activities
+ int invokeCount=InteractionUtil.countInvokes(getActivity().getDOMElement());
+
+ // Check whether scope has been defined to represent
+ // an interaction with one or more fault responses and
+ // no event handlers
+ Invoke invoke=null;
+
+ if (invokeCount == 1 &&
+ m_faultHandlers != null && (m_faultHandlers.getCatchPaths().size() > 0 ||
+ m_faultHandlers.getCatchAll() != null) &&
+ (m_eventHandlers == null || (m_eventHandlers.getOnEvents().size() == 0 &&
+ m_eventHandlers.getOnAlarms().size() == 0)) &&
+ (invoke = InteractionUtil.getInvoke(m_activity)) != null) {
+
+ invoke.convertRequest(activities, context);
+
+ // Create choice with normal response and fault paths
+ org.scribble.conversation.model.If choice=new org.scribble.conversation.model.If();
+
+ ConditionalBlock cb=new ConditionalBlock();
+
+ invoke.convertResponse(cb.getContents(), context);
+
+ // Include remaining activities
+ if (m_activity instanceof Sequence) {
+ for (int i=1; i < ((Sequence)m_activity).getActivities().size(); i++) {
+ ((Sequence)m_activity).getActivities().get(i).convert(cb.getContents(), context);
+ }
+ }
+
+ choice.getConditionalBlocks().add(cb);
+
+ // Process fault handlers
+ for (int i=0; i < m_faultHandlers.getCatchPaths().size(); i++) {
+ Catch catchBlock=m_faultHandlers.getCatchPaths().get(i);
+
+ ConditionalBlock fcb=new ConditionalBlock();
+
+ String mesgType=catchBlock.getFaultMessageType();
+
+ if (mesgType == null) {
+ mesgType = catchBlock.getFaultMessageElement();
+ }
+
+ Variable faultVar=null;
+
+ if (catchBlock.getFaultVariable() != null) {
+ faultVar = new Variable(getModel());
+ faultVar.setName(catchBlock.getFaultVariable());
+ faultVar.setMessageType(catchBlock.getFaultMessageType());
+ faultVar.setElement(catchBlock.getFaultMessageElement());
+ context.addVariable(faultVar);
+ }
+
+ invoke.convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
+ mesgType, context);
+
+ if (catchBlock.getActivity() != null) {
+ catchBlock.getActivity().convert(fcb.getContents(), context);
+ }
+
+ choice.getConditionalBlocks().add(fcb);
+
+ if (faultVar != null) {
+ context.removeVariable(faultVar);
+ }
+ }
+
+ activities.add(choice);
+ } else {
+ // Store in local var, in case try/catch block needs to be
+ // added
+ java.util.List<Activity> acts=activities;
+
+ // Check if try/catch block is required
+ if (getFaultHandlers() != null &&
+ (getFaultHandlers().getCatchPaths().size() > 0 ||
+ getFaultHandlers().getCatchAll() != null)) {
+ org.scribble.conversation.model.TryEscape te=
+ new org.scribble.conversation.model.TryEscape();
+ te.derivedFrom(this);
+ te.getBlock().derivedFrom(this);
+
+ acts.add(te);
+
+ acts = te.getBlock().getContents();
+
+ for (int i=0; i < getFaultHandlers().getCatchPaths().size(); i++) {
+ Catch catchPath=getFaultHandlers().getCatchPaths().get(i);
+
+ org.scribble.conversation.model.CatchBlock cb=
+ new org.scribble.conversation.model.CatchBlock();
+ cb.derivedFrom(catchPath);
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(catchPath.getFaultName()));
+ cb.setType(tref);
+
+ Variable faultVar=null;
+
+ if (catchPath.getFaultVariable() != null) {
+ faultVar = new Variable(getModel());
+ faultVar.setName(catchPath.getFaultVariable());
+ faultVar.setMessageType(catchPath.getFaultMessageType());
+ faultVar.setElement(catchPath.getFaultMessageElement());
+ context.addVariable(faultVar);
+ }
+
+ if (catchPath.getActivity() != null) {
+ catchPath.getActivity().convert(cb.getContents(), context);
+ }
+
+ if (faultVar != null) {
+ context.removeVariable(faultVar);
+ }
+
+ te.getEscapeBlocks().add(cb);
+ }
+ }
+
+ // Convert normal activities in scope
+ if (getActivity() != null) {
+ getActivity().convert(acts, context);
+ }
+ }
+ }
+
+ /**
+ * This method returns the conversion associated with the
+ * BPEL process.
+ *
+ * @param envContext The environment context
+ * @return The conversation
+ */
+ public Conversation convert(Context envContext) {
+ Conversation ret=new Conversation();
+
+ ret.derivedFrom(this);
+ ret.getBlock().derivedFrom(this);
+
+ // Configure model name
+ LocatedName modelName=new LocatedName();
+ modelName.setName(getName());
+
+ ret.setLocatedName(modelName);
+
+ // Define implements reference for conversation type
+ String convType=getConversationType();
+ String role=null;
+
+ if (convType != null) {
+ int index=convType.indexOf('@');
+
+ if (index != -1) {
+ // TODO: Need to think whether this should be
+ // 'implements' reference. If so, then need to change
+ // Java Lang Model parser and also Lang Model conformance
+ // rule.
+ ImplementsReference iref=
+ new ImplementsReference(ConversationNotation.NOTATION_CODE);
+
+ role = convType.substring(index+1);
+
+ iref.setLocatedRole(role);
+
+ // Need to locate the model name
+ modelName.setRole(new Role(iref.getLocatedRole()));
+
+ String mainpart=convType.substring(0, index);
+
+ index = mainpart.lastIndexOf(".");
+
+ if (index == -1) {
+ iref.setNamespace("");
+ iref.setLocalpart(mainpart);
+ } else {
+ iref.setNamespace(mainpart.substring(0, index));
+ iref.setLocalpart(mainpart.substring(index+1));
+ }
+
+ ret.getImplements().add(iref);
+
+ } else {
+ logger.warn("Conversation type does not " +
+ "contain '@' located role separator");
+ }
+ }
+
+ // Convert the process contents
+ DefaultConversionContext context=new DefaultConversionContext(role, this, envContext);
+
+ // Add variables to the context
+ for (int i=0; i < m_variables.size(); i++) {
+ context.addVariable(m_variables.get(i));
+ }
+
+ convert(ret.getBlock().getContents(), context);
+
+ return(ret);
+ }
+
+ protected String getParentURI(BPELElement elem) {
+ String ret="//";
+
+ if (elem instanceof BPELActivity) {
+ ret += "@activity";
+ } else if (elem instanceof FaultHandlers) {
+ ret += "@faultHandlers";
+ } else if (elem instanceof EventHandlers) {
+ ret += "@eventHandlers";
+ }
+
+ return(ret);
+ }
+
+ private static Log logger = LogFactory.getLog(Process.class);
+
+ private org.w3c.dom.Element m_partnerLinksElem=null;
+ //private org.w3c.dom.Element m_messageExchangesElem=null;
+ private org.w3c.dom.Element m_variablesElem=null;
+ //private org.w3c.dom.Element m_correlationSetsElem=null;
+ private java.util.List<Import> m_imports=new java.util.Vector<Import>();
+ private java.util.List<PartnerLink> m_partnerLinks=new java.util.Vector<PartnerLink>();
+ private java.util.List<Variable> m_variables=new java.util.Vector<Variable>();
+ private EventHandlers m_eventHandlers=null;
+ private FaultHandlers m_faultHandlers=null;
+ private BPELActivity m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Receive.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Receive.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Receive.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.util.TypeReferenceUtil;
+
+/**
+ * This class represents an unsupported (or custom) action within
+ * the conversation based ESB service descriptor.
+ *
+ * @author gary
+ */
+public class Receive extends AbstractInteraction {
+
+ private static final String CREATE_INSTANCE = "createInstance";
+ private static final String VARIABLE = "variable";
+
+ public static final String RECEIVE = "receive";
+
+ private static final long serialVersionUID = -3041725198724191842L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Receive(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Receive(BPELLanguageModel model) {
+ super(model, RECEIVE);
+ }
+
+ /**
+ * This method sets the variable.
+ *
+ * @param var The variable
+ */
+ public void setVariable(String var) {
+ getDOMElement().setAttribute(VARIABLE, var);
+ }
+
+ /**
+ * This method returns the variable.
+ *
+ * @return The variable
+ */
+ public String getVariable() {
+ return(getDOMElement().hasAttribute(VARIABLE)?
+ getDOMElement().getAttribute(VARIABLE):null);
+ }
+
+ /**
+ * This method sets the 'create instance'
+ * attribute.
+ *
+ * @param b Whether to create instance
+ */
+ public void setCreateInstance(boolean b) {
+ String create=(b?"yes":"no");
+
+ getDOMElement().setAttribute(CREATE_INSTANCE, create);
+ }
+
+ /**
+ * This method returns whether to create instance.
+ *
+ * @return Whether to create instance
+ */
+ public boolean getCreateInstance() {
+ boolean ret=false;
+ String create=
+ getDOMElement().getAttribute(CREATE_INSTANCE);
+
+ if (create != null &&
+ create.equals("yes")) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ // Don't validate unsupported actions
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+
+ ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
+
+ Variable var=context.getVariable(getVariable());
+
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+
+ MessageSignature ms=new MessageSignature();
+ ms.derivedFrom(this);
+
+ ms.setOperation(getOperation());
+ ms.getTypes().add(tref);
+
+ String fromRole=getServerPartnerRole();
+
+ if (fromRole != null && fromRole.equals(context.getRole())) {
+ fromRole = getClientPartnerRole();
+ }
+
+ if (fromRole != null) {
+ interaction.setFromRole(new Role(fromRole));
+ }
+
+ if (context.getRole() != null) {
+ interaction.setToRole(new Role(context.getRole()));
+ }
+
+ interaction.setMessageSignature(ms);
+
+ activities.add(interaction);
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/RepeatUntil.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/RepeatUntil.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/RepeatUntil.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,160 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents a RepeatUntil grouping activity.
+ *
+ * @author gary
+ */
+public class RepeatUntil extends BPELGroupingConstruct {
+
+ private static final long serialVersionUID = -4479515591509703188L;
+
+ public static final String REPEATUNTIL = "repeatUntil";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public RepeatUntil(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+
+ org.w3c.dom.Element cond=
+ findChildElement(Condition.CONDITION);
+
+ if (cond == null) {
+ m_condition = new Condition(model);
+ } else {
+ m_condition = new Condition(model, cond);
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public RepeatUntil(BPELLanguageModel model) {
+ super(model, REPEATUNTIL);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+ }
+
+ /**
+ * This method sets the condition.
+ *
+ * @param cond The condition
+ */
+ public void setCondition(Condition cond) {
+ m_condition = cond;
+
+ setChildElement(findChildElement(Condition.CONDITION),
+ cond, null);
+ }
+
+ /**
+ * This method returns the condition.
+ *
+ * @return The condition
+ */
+ public Condition getCondition() {
+ return(m_condition);
+ }
+
+ /**
+ * This method sets the main 'if' activity.
+ *
+ * @param act The activity associated with the 'if'
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_condition != null) {
+ insertBefore = m_condition.getDOMElement();
+ }
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'if' path.
+ *
+ * @return The 'if' activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof BPELActivity) {
+ ret = "@activity";
+ }
+
+ return(ret);
+ }
+
+ private Condition m_condition=null;
+ private BPELElement m_activity=null;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Reply.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Reply.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Reply.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.conversation.model.ConversationInteraction;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.util.TypeReferenceUtil;
+
+/**
+ * This class represents a BPEL reply activity.
+ *
+ * @author gary
+ */
+public class Reply extends AbstractInteraction {
+
+ private static final String VARIABLE = "variable";
+ private static final String FAULT_NAME = "faultName";
+
+ public static final String REPLY = "reply";
+
+ private static final long serialVersionUID = 8582738107125170604L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Reply(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Reply(BPELLanguageModel model) {
+ super(model, REPLY);
+ }
+
+ /**
+ * This method sets the variable.
+ *
+ * @param var The variable
+ */
+ public void setVariable(String var) {
+ getDOMElement().setAttribute(VARIABLE, var);
+ }
+
+ /**
+ * This method returns the variable.
+ *
+ * @return The variable
+ */
+ public String getVariable() {
+ return(getDOMElement().hasAttribute(VARIABLE)?
+ getDOMElement().getAttribute(VARIABLE):null);
+ }
+
+ /**
+ * This method sets the fault name.
+ *
+ * @param fname The fault name
+ */
+ public void setFaultName(String fname) {
+ getDOMElement().setAttribute(FAULT_NAME, fname);
+ }
+
+ /**
+ * This method returns the fault name.
+ *
+ * @return The fault name
+ */
+ public String getFaultName() {
+ return(getDOMElement().hasAttribute(FAULT_NAME)?
+ getDOMElement().getAttribute(FAULT_NAME):null);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ // Don't validate unsupported actions
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+
+ ConversationInteraction interaction=new ConversationInteraction();
+ interaction.derivedFrom(this);
+
+ Variable var=context.getVariable(getVariable());
+
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ TypeReference tref=TypeReferenceUtil.createTypeReference(xmlType, context);
+
+ MessageSignature ms=new MessageSignature();
+ ms.derivedFrom(this);
+
+ ms.setOperation(getOperation());
+ ms.getTypes().add(tref);
+
+ if (context.getRole() != null) {
+ interaction.setFromRole(new Role(context.getRole()));
+ }
+
+ String toRole=getServerPartnerRole();
+
+ if (toRole != null) {
+ interaction.setToRole(new Role(toRole));
+ }
+
+ interaction.setMessageSignature(ms);
+
+ activities.add(interaction);
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Rethrow.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Rethrow.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Rethrow.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents the rethrow activity.
+ *
+ * @author gary
+ */
+public class Rethrow extends BPELActivity {
+
+ private static final long serialVersionUID = 9187657888490480490L;
+
+ public static final String RETHROW = "rethrow";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Rethrow(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Rethrow(BPELLanguageModel model) {
+ super(model, RETHROW);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ // Don't validate unsupported actions
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Scope.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Scope.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Scope.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,690 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.conversation.model.ConditionalBlock;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+import org.jboss.savara.bpel.model.util.InteractionUtil;
+import org.jboss.savara.bpel.util.XMLUtils;
+
+/**
+ * This class represents a scope grouping activity.
+ *
+ * @author gary
+ */
+public class Scope extends BPELActivity implements ScopeActivity {
+
+ private static final long serialVersionUID = 7132062003047468101L;
+
+ public static final String SCOPE = "scope";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Scope(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_partnerLinksElem = findChildElement("partnerLinks");
+
+ if (m_partnerLinksElem != null) {
+ java.util.List<BPELElement> elems=
+ findChildElements(m_partnerLinksElem,
+ PartnerLink.class);
+
+ for (int i=0; i < elems.size(); i++) {
+ m_partnerLinks.add((PartnerLink)elems.get(i));
+ }
+ }
+
+ m_variablesElem = findChildElement("variables");
+
+ if (m_variablesElem != null) {
+ java.util.List<BPELElement> elems=
+ findChildElements(m_variablesElem,
+ Variable.class);
+
+ for (int i=0; i < elems.size(); i++) {
+ m_variables.add((Variable)elems.get(i));
+ }
+ }
+
+ m_messageExchangesElem = findChildElement("messageExchanges");
+ m_correlationSetsElem = findChildElement("correlationSets");
+
+ org.w3c.dom.Element ehs=findChildElement(EventHandlers.EVENTHANDLERS);
+ if (ehs != null) {
+ m_eventHandlers = new EventHandlers(model, ehs);
+ }
+
+ org.w3c.dom.Element fhs=findChildElement(FaultHandlers.FAULTHANDLERS);
+ if (fhs != null) {
+ m_faultHandlers = new FaultHandlers(model, fhs);
+ }
+
+ org.w3c.dom.Element ch=findChildElement(CompensationHandler.COMPENSATIONHANDLER);
+ if (ch != null) {
+ m_compensationHandler = new CompensationHandler(model, ch);
+ }
+
+ org.w3c.dom.Element th=findChildElement(TerminationHandler.TERMINATIONHANDLER);
+ if (th != null) {
+ m_terminationHandler = new TerminationHandler(model, th);
+ }
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Scope(BPELLanguageModel model) {
+ super(model, SCOPE);
+ }
+
+ /**
+ * This method adds a variable to the scope.
+ *
+ * @param var The variable to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addVariable(Variable var, int pos) {
+
+ if (m_variablesElem == null) {
+ m_variablesElem = getDOMElement().getOwnerDocument().
+ createElementNS(BPEL_NS, "variables");
+
+ // Add to parent
+ org.w3c.dom.Element insertBefore=
+ findChildElement("partnerLinks");
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("messageExchanges");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("correlationSets");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("eventHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("faultHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("compensationHandler");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("terminationHandler");
+ }
+
+ if (insertBefore == null) {
+ BPELElement elem=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = elem.getDOMElement();
+ }
+ }
+
+ if (insertBefore != null) {
+ getDOMElement().insertBefore(m_variablesElem, insertBefore);
+ } else {
+ getDOMElement().appendChild(m_variablesElem);
+ }
+ }
+
+ if (pos == -1 || pos >= m_variables.size()) {
+ m_variables.add(var);
+
+ setChildElement(m_variablesElem, null, var, null);
+ } else {
+
+ Variable cur=m_variables.get(pos);
+
+ m_variables.add(pos, var);
+
+ if (cur != null) {
+ setChildElement(m_variablesElem, null, var,
+ cur.getDOMElement());
+ } else {
+ setChildElement(m_variablesElem, null, var, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes an activity from the grouping
+ * construct.
+ *
+ * @param act The activity to be removed
+ * @return Whether the activity was removed
+ */
+ public boolean removeVariable(Variable var) {
+ boolean ret=m_variables.remove(var);
+
+ if (ret) {
+ m_variablesElem.removeChild(var.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of variables.
+ *
+ * @return The
+ */
+ public java.util.List<Variable> getVariables() {
+ return(m_variables);
+ }
+
+ /**
+ * This method adds a partner link to the scope.
+ *
+ * @param pl The partner link to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addPartnerLink(PartnerLink pl, int pos) {
+
+ if (m_partnerLinksElem == null) {
+ m_partnerLinksElem = getDOMElement().getOwnerDocument().
+ createElementNS(BPEL_NS, "partnerLinks");
+
+ // Add to parent
+ org.w3c.dom.Element insertBefore=
+ findChildElement("messageExchanges");
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("correlationSets");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("eventHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("faultHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("compensationHandler");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("terminationHandler");
+ }
+
+ if (insertBefore == null) {
+ BPELElement elem=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = elem.getDOMElement();
+ }
+ }
+
+ if (insertBefore != null) {
+ getDOMElement().insertBefore(m_partnerLinksElem, insertBefore);
+ } else {
+ getDOMElement().appendChild(m_partnerLinksElem);
+ }
+ }
+
+ if (pos == -1 || pos >= m_partnerLinks.size()) {
+ m_partnerLinks.add(pl);
+
+ setChildElement(m_partnerLinksElem, null, pl, null);
+ } else {
+
+ PartnerLink cur=m_partnerLinks.get(pos);
+
+ m_partnerLinks.add(pos, pl);
+
+ if (cur != null) {
+ setChildElement(m_partnerLinksElem, null, pl,
+ cur.getDOMElement());
+ } else {
+ setChildElement(m_partnerLinksElem, null, pl, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes a partner link from the grouping
+ * construct.
+ *
+ * @param pl The partner link to be removed
+ * @return Whether the partner link was removed
+ */
+ public boolean removePartnerLink(PartnerLink pl) {
+ boolean ret=m_partnerLinks.remove(pl);
+
+ if (ret) {
+ m_partnerLinksElem.removeChild(pl.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of partner links.
+ *
+ * @return The partner links
+ */
+ public java.util.List<PartnerLink> getPartnerLinks() {
+ return(m_partnerLinks);
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELActivity act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELActivity getActivity() {
+ return(m_activity);
+ }
+
+ /**
+ * This method sets the 'eventHandlers' path.
+ *
+ * @param elem The 'eventHandlers' path
+ */
+ public void setEventHandlers(EventHandlers elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_eventHandlers != null) {
+ existingElem = m_eventHandlers.getDOMElement();
+ }
+
+ m_eventHandlers = elem;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("faultHandlers");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("compensationHandler");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("terminationHandler");
+ }
+
+ if (insertBefore == null) {
+ BPELElement act=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = act.getDOMElement();
+ }
+ }
+
+ setChildElement(existingElem, elem,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the 'eventHandlers' path.
+ *
+ * @return The 'eventHandlers' path
+ */
+ public EventHandlers getEventHandlers() {
+ return(m_eventHandlers);
+ }
+
+ /**
+ * This method sets the 'faultHandlers' path.
+ *
+ * @param elem The 'faultHandlers' path
+ */
+ public void setFaultHandlers(FaultHandlers elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_faultHandlers != null) {
+ existingElem = m_faultHandlers.getDOMElement();
+ }
+
+ m_faultHandlers = elem;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("compensationHandler");
+ }
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("terminationHandler");
+ }
+
+ if (insertBefore == null) {
+ BPELElement act=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = act.getDOMElement();
+ }
+ }
+
+ setChildElement(existingElem, elem,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the 'faultHandlers' path.
+ *
+ * @return The 'faultHandlers' path
+ */
+ public FaultHandlers getFaultHandlers() {
+ return(m_faultHandlers);
+ }
+
+ /**
+ * This method sets the 'compensationHandler' path.
+ *
+ * @param elem The 'compensationHandler' path
+ */
+ public void setCompensationHandler(CompensationHandler elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_compensationHandler != null) {
+ existingElem = m_compensationHandler.getDOMElement();
+ }
+
+ m_compensationHandler = elem;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (insertBefore == null) {
+ insertBefore = findChildElement("terminationHandler");
+ }
+
+ if (insertBefore == null) {
+ BPELElement act=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = act.getDOMElement();
+ }
+ }
+
+ setChildElement(existingElem, elem,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the 'compensationHandler' path.
+ *
+ * @return The 'compensationHandler' path
+ */
+ public CompensationHandler getCompensationHandler() {
+ return(m_compensationHandler);
+ }
+
+ /**
+ * This method sets the 'terminationHandler' path.
+ *
+ * @param elem The 'terminationHandler' path
+ */
+ public void setTerminationHandler(TerminationHandler elem) {
+ org.w3c.dom.Element existingElem=null;
+
+ if (m_terminationHandler != null) {
+ existingElem = m_terminationHandler.getDOMElement();
+ }
+
+ m_terminationHandler = elem;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (insertBefore == null) {
+ BPELElement act=findChildActivity();
+
+ if (elem != null) {
+ insertBefore = act.getDOMElement();
+ }
+ }
+
+ setChildElement(existingElem, elem,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the 'terminationHandler' path.
+ *
+ * @return The 'terminationHandler' path
+ */
+ public TerminationHandler getTerminationHandler() {
+ return(m_terminationHandler);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+
+ // Add variables to the context
+ for (int i=0; i < m_variables.size(); i++) {
+ context.addVariable(m_variables.get(i));
+ }
+
+ // Count number of invoke activities
+ int invokeCount=InteractionUtil.countInvokes(getActivity().getDOMElement());
+
+ // Check whether scope has been defined to represent
+ // an interaction with one or more fault responses and
+ // no event handlers
+ Invoke invoke=null;
+
+ if (invokeCount == 1 &&
+ m_faultHandlers != null && (m_faultHandlers.getCatchPaths().size() > 0 ||
+ m_faultHandlers.getCatchAll() != null) &&
+ (m_eventHandlers == null || (m_eventHandlers.getOnEvents().size() == 0 &&
+ m_eventHandlers.getOnAlarms().size() == 0)) &&
+ (invoke = InteractionUtil.getInvoke(m_activity)) != null) {
+
+ invoke.convertRequest(activities, context);
+
+ // Create choice with normal response and fault paths
+ org.scribble.conversation.model.If choice=new org.scribble.conversation.model.If();
+
+ ConditionalBlock cb=new ConditionalBlock();
+
+ invoke.convertResponse(cb.getContents(), context);
+
+ // Include remaining activities
+ if (m_activity instanceof Sequence) {
+ for (int i=1; i < ((Sequence)m_activity).getActivities().size(); i++) {
+ ((Sequence)m_activity).getActivities().get(i).convert(cb.getContents(), context);
+ }
+ }
+
+ choice.getConditionalBlocks().add(cb);
+
+ // Process fault handlers
+ for (int i=0; i < m_faultHandlers.getCatchPaths().size(); i++) {
+ Catch catchBlock=m_faultHandlers.getCatchPaths().get(i);
+
+ ConditionalBlock fcb=new ConditionalBlock();
+
+ String mesgType=catchBlock.getFaultMessageType();
+
+ if (mesgType == null) {
+ mesgType = catchBlock.getFaultMessageElement();
+ }
+
+ Variable faultVar=null;
+
+ if (catchBlock.getFaultVariable() != null) {
+ faultVar = new Variable(getModel());
+ faultVar.setName(catchBlock.getFaultVariable());
+ faultVar.setMessageType(catchBlock.getFaultMessageType());
+ faultVar.setElement(catchBlock.getFaultMessageElement());
+ context.addVariable(faultVar);
+ }
+
+ invoke.convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
+ mesgType, context);
+
+ if (catchBlock.getActivity() != null) {
+ catchBlock.getActivity().convert(fcb.getContents(), context);
+ }
+
+ choice.getConditionalBlocks().add(fcb);
+
+ if (faultVar != null) {
+ context.removeVariable(faultVar);
+ }
+ }
+
+ activities.add(choice);
+ } else {
+ // Store in local var, in case try/catch block needs to be
+ // added
+ java.util.List<Activity> acts=activities;
+
+ // Check if try/catch block is required
+ if (getFaultHandlers() != null &&
+ (getFaultHandlers().getCatchPaths().size() > 0 ||
+ getFaultHandlers().getCatchAll() != null)) {
+ org.scribble.conversation.model.TryEscape te=
+ new org.scribble.conversation.model.TryEscape();
+ te.derivedFrom(this);
+ te.getBlock().derivedFrom(this);
+
+ acts.add(te);
+
+ acts = te.getBlock().getContents();
+
+ for (int i=0; i < getFaultHandlers().getCatchPaths().size(); i++) {
+ Catch catchPath=getFaultHandlers().getCatchPaths().get(i);
+
+ org.scribble.conversation.model.CatchBlock cb=
+ new org.scribble.conversation.model.CatchBlock();
+ cb.derivedFrom(catchPath);
+
+ TypeReference tref=new TypeReference();
+ tref.setLocalpart(XMLUtils.getLocalname(catchPath.getFaultName()));
+ cb.setType(tref);
+
+ Variable faultVar=null;
+
+ if (catchPath.getFaultVariable() != null) {
+ faultVar = new Variable(getModel());
+ faultVar.setName(catchPath.getFaultVariable());
+ faultVar.setMessageType(catchPath.getFaultMessageType());
+ faultVar.setElement(catchPath.getFaultMessageElement());
+ context.addVariable(faultVar);
+ }
+
+ if (catchPath.getActivity() != null) {
+ catchPath.getActivity().convert(cb.getContents(), context);
+ }
+
+ if (faultVar != null) {
+ context.removeVariable(faultVar);
+ }
+
+ te.getEscapeBlocks().add(cb);
+ }
+ }
+
+ // Convert normal activities in scope
+ if (getActivity() != null) {
+ getActivity().convert(acts, context);
+ }
+ }
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof BPELActivity) {
+ ret += "@activity";
+ } else if (elem instanceof FaultHandlers) {
+ ret += "@faultHandlers";
+ } else if (elem instanceof EventHandlers) {
+ ret += "@eventHandlers";
+ }
+
+ return(ret);
+ }
+
+ private org.w3c.dom.Element m_partnerLinksElem=null;
+ private org.w3c.dom.Element m_variablesElem=null;
+ private org.w3c.dom.Element m_messageExchangesElem=null;
+ private org.w3c.dom.Element m_correlationSetsElem=null;
+ private java.util.List<PartnerLink> m_partnerLinks=new java.util.Vector<PartnerLink>();
+ private java.util.List<Variable> m_variables=new java.util.Vector<Variable>();
+ private EventHandlers m_eventHandlers=null;
+ private FaultHandlers m_faultHandlers=null;
+ private CompensationHandler m_compensationHandler=null;
+ private TerminationHandler m_terminationHandler=null;
+ private BPELActivity m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ScopeActivity.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ScopeActivity.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/ScopeActivity.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.admin.ModelListener;
+
+/**
+ * This interface represents a scope activity.
+ *
+ * @author gary
+ */
+public interface ScopeActivity {
+
+ /**
+ * This method adds a variable to the scope.
+ *
+ * @param var The variable to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addVariable(Variable var, int pos);
+
+ /**
+ * This method removes an activity from the grouping
+ * construct.
+ *
+ * @param act The activity to be removed
+ * @return Whether the activity was removed
+ */
+ public boolean removeVariable(Variable var);
+
+ /**
+ * This method returns the list of variables.
+ *
+ * @return The
+ */
+ public java.util.List<Variable> getVariables();
+
+ /**
+ * This method adds a partner link to the scope.
+ *
+ * @param pl The partner link to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addPartnerLink(PartnerLink pl, int pos);
+
+ /**
+ * This method removes a partner link from the grouping
+ * construct.
+ *
+ * @param pl The partner link to be removed
+ * @return Whether the partner link was removed
+ */
+ public boolean removePartnerLink(PartnerLink pl);
+
+ /**
+ * This method returns the list of partner links.
+ *
+ * @return The partner links
+ */
+ public java.util.List<PartnerLink> getPartnerLinks() ;
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELActivity act) ;
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELActivity getActivity() ;
+
+ /**
+ * This method sets the 'eventHandlers' path.
+ *
+ * @param elem The 'eventHandlers' path
+ */
+ public void setEventHandlers(EventHandlers elem);
+
+ /**
+ * This method returns the 'eventHandlers' path.
+ *
+ * @return The 'eventHandlers' path
+ */
+ public EventHandlers getEventHandlers();
+
+ /**
+ * This method sets the 'faultHandlers' path.
+ *
+ * @param elem The 'faultHandlers' path
+ */
+ public void setFaultHandlers(FaultHandlers elem);
+
+ /**
+ * This method returns the 'faultHandlers' path.
+ *
+ * @return The 'faultHandlers' path
+ */
+ public FaultHandlers getFaultHandlers();
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ public void validate(ModelListener l);
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Sequence.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Sequence.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Sequence.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents a sequence grouping activity.
+ *
+ * @author gary
+ */
+public class Sequence extends BPELActivity {
+
+ public static final String SEQUENCE = "sequence";
+
+ private static final long serialVersionUID = 6656299352423612770L;
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Sequence(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ java.util.List<BPELElement> acts=
+ findChildElements(BPELActivity.class);
+
+ for (int i=0; i < acts.size(); i++) {
+ if (acts.get(i).isActivity() &&
+ acts.get(i) instanceof BPELActivity) {
+ m_activities.add((BPELActivity)acts.get(i));
+ }
+ }
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Sequence(BPELLanguageModel model) {
+ super(model, SEQUENCE);
+ }
+
+ /**
+ * This method adds an activity to the grouping construct.
+ *
+ * @param act The activity to be added
+ * @param pos The position to add, or -1 if at the end
+ */
+ public void addActivity(BPELActivity act, int pos) {
+ if (pos == -1 || pos >= m_activities.size()) {
+ m_activities.add(act);
+
+ setChildElement(null, act, null);
+ } else {
+
+ BPELActivity cur=m_activities.get(pos);
+
+ m_activities.add(pos, act);
+
+ if (cur != null) {
+ setChildElement(null, act,
+ cur.getDOMElement());
+ } else {
+ setChildElement(null, act, null);
+ }
+ }
+ }
+
+ /**
+ * This method removes an activity from the grouping
+ * construct.
+ *
+ * @param act The activity to be removed
+ * @return Whether the activity was removed
+ */
+ public boolean removeActivity(BPELActivity act) {
+ boolean ret=m_activities.remove(act);
+
+ if (ret) {
+ getDOMElement().removeChild(act.getDOMElement());
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the list of activities associated
+ * with the grouping construct.
+ *
+ * @return The list of activities
+ */
+ public java.util.List<BPELActivity> getActivities() {
+ return(m_activities);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+
+ for (int i=0; i < m_activities.size(); i++) {
+ m_activities.get(i).convert(activities, context);
+ }
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ int pos=getActivities().indexOf(elem);
+ return("@activities."+pos);
+ }
+
+ private java.util.List<BPELActivity> m_activities=
+ new java.util.Vector<BPELActivity>();
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Source.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Source.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Source.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the BPEL source element, contained within
+ * any BPEL activity.
+ */
+public class Source extends BPELElement {
+
+ private static final long serialVersionUID = 4878669992635772776L;
+
+ private static final String LINK_NAME = "linkName";
+
+ public static final String SOURCE="source";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public Source(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Source(BPELLanguageModel model) {
+ super(model, SOURCE);
+ }
+
+ /**
+ * This method returns the name associated
+ * with the link.
+ *
+ * @return The link name
+ */
+ public String getLinkName() {
+ return(getDOMElement().getAttribute(LINK_NAME));
+ }
+
+ /**
+ * This method sets the link name.
+ *
+ * @param name The name
+ */
+ public void setLinkName(String name) {
+ getDOMElement().setAttribute(LINK_NAME, name);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Target.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Target.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Target.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the BPEL target element, contained within
+ * any BPEL activity.
+ */
+public class Target extends BPELElement {
+
+ private static final long serialVersionUID = -8813636777020840433L;
+
+ private static final String LINK_NAME = "linkName";
+
+ public static final String TARGET="target";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public Target(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Target(BPELLanguageModel model) {
+ super(model, TARGET);
+ }
+
+ /**
+ * This method returns the name associated
+ * with the link.
+ *
+ * @return The link name
+ */
+ public String getLinkName() {
+ return(getDOMElement().getAttribute(LINK_NAME));
+ }
+
+ /**
+ * This method sets the link name.
+ *
+ * @param name The name
+ */
+ public void setLinkName(String name) {
+ getDOMElement().setAttribute(LINK_NAME, name);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/TerminationHandler.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/TerminationHandler.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/TerminationHandler.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import java.util.List;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+import org.scribble.model.Activity;
+
+/**
+ * This class represents the 'terminationHandler' construct contained
+ * within the 'scope' activity.
+ */
+public class TerminationHandler extends BPELElement {
+
+ private static final long serialVersionUID = 7316551859410369824L;
+
+ public static final String TERMINATIONHANDLER="terminationHandler";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the element
+ */
+ public TerminationHandler(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public TerminationHandler(BPELLanguageModel model) {
+ super(model, TERMINATIONHANDLER);
+ }
+
+ /**
+ * This method sets the activity associated with
+ * the 'else' construct.
+ *
+ * @param act The activity
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'else' construct.
+ *
+ * @return The activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ @Override
+ public void convert(List<Activity> activities, ConversionContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private BPELElement m_activity;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Throw.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Throw.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Throw.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents the throw activity.
+ *
+ * @author gary
+ */
+public class Throw extends BPELActivity {
+
+ private static final long serialVersionUID = 9187657888490480490L;
+
+ public static final String THROW = "throw";
+
+ private static final String FAULT_NAME = "faultName";
+ private static final String FAULT_VARIABLE = "faultVariable";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Throw(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Throw(BPELLanguageModel model) {
+ super(model, THROW);
+ }
+
+ /**
+ * This method sets the fault name.
+ *
+ * @param faultName The fault name
+ */
+ public void setFaultName(String faultName) {
+ getDOMElement().setAttribute(FAULT_NAME, faultName);
+ }
+
+ /**
+ * This method returns the fault name.
+ *
+ * @return The fault name
+ */
+ public String getFaultName() {
+ return(getDOMElement().hasAttribute(FAULT_NAME)?
+ getDOMElement().getAttribute(FAULT_NAME):null);
+ }
+
+ /**
+ * This method sets the fault variable.
+ *
+ * @param faultVariable The fault variable
+ */
+ public void setFaultVariable(String faultVariable) {
+ getDOMElement().setAttribute(FAULT_VARIABLE, faultVariable);
+ }
+
+ /**
+ * This method returns the fault variable.
+ *
+ * @return The fault variable
+ */
+ public String getFaultVariable() {
+ return(getDOMElement().hasAttribute(FAULT_VARIABLE)?
+ getDOMElement().getAttribute(FAULT_VARIABLE):null);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ // Don't validate unsupported actions
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Until.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Until.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Until.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.jboss.savara.bpel.model.BPELLanguageModel;
+
+/**
+ * This class represents the BPEL 'until' element.
+ */
+public class Until extends AbstractCondition {
+
+ private static final long serialVersionUID = 5398291987513467996L;
+
+ public static final String UNTIL="until";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param elem The XML configuration details for the element
+ */
+ public Until(BPELLanguageModel model,
+ org.w3c.dom.Element elem) {
+ super(model, elem);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Until(BPELLanguageModel model) {
+ super(model, UNTIL);
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Variable.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Variable.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Variable.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents the variable.
+ *
+ * @author gary
+ */
+public class Variable extends BPELElement {
+
+ private static final long serialVersionUID = -3824104482191549444L;
+
+ public static final String VARIABLE = "variable";
+
+ private static final String NAME = "name";
+ private static final String TYPE = "type";
+ private static final String ELEMENT = "element";
+ private static final String MESSAGE_TYPE = "messageType";
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ * @param element The XML configuration details for the element
+ */
+ public Variable(BPELLanguageModel model,
+ org.w3c.dom.Element element) {
+ super(model, element);
+ }
+
+ /**
+ * The constructor for the element.
+ *
+ * @param model The BPEL model
+ */
+ public Variable(BPELLanguageModel model) {
+ super(model, VARIABLE);
+ }
+
+ /**
+ * This method sets the name.
+ *
+ * @param name The name
+ */
+ public void setName(String name) {
+ getDOMElement().setAttribute(NAME, name);
+ }
+
+ /**
+ * This method returns the name.
+ *
+ * @return The name
+ */
+ public String getName() {
+ return(getDOMElement().hasAttribute(NAME)?
+ getDOMElement().getAttribute(NAME):null);
+ }
+
+ /**
+ * This method sets the variable type.
+ *
+ * @param type The type
+ */
+ public void setType(String type) {
+ getDOMElement().setAttribute(TYPE, type);
+ }
+
+ /**
+ * This method returns the variable type.
+ *
+ * @return The type
+ */
+ public String getType() {
+ return(getDOMElement().hasAttribute(TYPE)?
+ getDOMElement().getAttribute(TYPE):null);
+ }
+
+ /**
+ * This method sets the variable element.
+ *
+ * @param element The element
+ */
+ public void setElement(String element) {
+ getDOMElement().setAttribute(ELEMENT, element);
+ }
+
+ /**
+ * This method returns the variable element.
+ *
+ * @return The element
+ */
+ public String getElement() {
+ return(getDOMElement().hasAttribute(ELEMENT)?
+ getDOMElement().getAttribute(ELEMENT):null);
+ }
+
+ /**
+ * This method sets the variable message type.
+ *
+ * @param type The message type
+ */
+ public void setMessageType(String type) {
+ getDOMElement().setAttribute(MESSAGE_TYPE, type);
+ }
+
+ /**
+ * This method returns the variable message type.
+ *
+ * @return The message type
+ */
+ public String getMessageType() {
+ return(getDOMElement().hasAttribute(MESSAGE_TYPE)?
+ getDOMElement().getAttribute(MESSAGE_TYPE):null);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ // Don't validate unsupported actions
+ }
+
+ /**
+ * This method converts the BPEL activity into an equivalent
+ * behavioural description for conformance checking.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ public void convert(java.util.List<Activity> activities,
+ ConversionContext context) {
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Wait.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Wait.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/Wait.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents the wait activity.
+ *
+ * @author gary
+ */
+public class Wait extends BPELActivity {
+
+ private static final String FOR = "for";
+
+ private static final String UNTIL = "until";
+
+ private static final long serialVersionUID = -3934422332929710337L;
+
+ public static final String WAIT = "wait";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public Wait(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public Wait(BPELLanguageModel model) {
+ super(model, WAIT);
+ }
+
+ /**
+ * This method sets the 'until' condition.
+ *
+ * @param cond The 'until' condition
+ */
+ public void setUntil(Condition cond) {
+ setChildElement(findChildElement(UNTIL),
+ cond, null);
+
+ org.w3c.dom.Element elem=findChildElement(FOR);
+ if (elem != null) {
+ getDOMElement().removeChild(elem);
+ }
+ }
+
+ /**
+ * This method returns the 'until' condition.
+ *
+ * @return The 'until' condition
+ */
+ public Condition getUntil() {
+ Condition ret=null;
+
+ org.w3c.dom.Element elem=findChildElement(UNTIL);
+ if (elem != null) {
+ ret = new Condition(getModel(), elem);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method sets the 'for' condition.
+ *
+ * @param cond The 'for' condition
+ */
+ public void setFor(Condition cond) {
+ setChildElement(findChildElement(FOR),
+ cond, null);
+
+ org.w3c.dom.Element elem=findChildElement(UNTIL);
+ if (elem != null) {
+ getDOMElement().removeChild(elem);
+ }
+ }
+
+ /**
+ * This method returns the 'for' condition.
+ *
+ * @return The 'for' condition
+ */
+ public Condition getFor() {
+ Condition ret=null;
+
+ org.w3c.dom.Element elem=findChildElement(FOR);
+ if (elem != null) {
+ ret = new Condition(getModel(), elem);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ // Don't validate unsupported actions
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/While.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/While.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/component/While.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.component;
+
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.jboss.savara.bpel.model.*;
+
+/**
+ * This class represents a while grouping activity.
+ *
+ * @author gary
+ */
+public class While extends BPELGroupingConstruct {
+
+ private static final long serialVersionUID = -4173984531470466407L;
+
+ public static final String WHILE = "while";
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ * @param activity The XML configuration details for the activity
+ */
+ public While(BPELLanguageModel model,
+ org.w3c.dom.Element activity) {
+ super(model, activity);
+
+ org.w3c.dom.Element cond=
+ findChildElement(Condition.CONDITION);
+
+ if (cond == null) {
+ m_condition = new Condition(model);
+ } else {
+ m_condition = new Condition(model, cond);
+ }
+
+ m_activity = findChildActivity();
+ }
+
+ /**
+ * The constructor for the activity.
+ *
+ * @param model The BPEL model
+ */
+ public While(BPELLanguageModel model) {
+ super(model, WHILE);
+ }
+
+ /**
+ * This method validates the BPEL activity and reports warnings or
+ * errors to the supplied model listener.
+ *
+ * @param l The model listener
+ */
+ @Override
+ public void validate(ModelListener l) {
+ }
+
+ /**
+ * This method does the actual work of converting the specific
+ * BPEL activity into an equivalent behavioural description for
+ * conformance checking. The 'convert' method provides
+ * a wrapper around this method, to handle the standard elements
+ * that can be associated with any BPEL activity.
+ *
+ * @param activities The list of activities that will contain
+ * the converted action(s)
+ * @param context The conversion context
+ */
+ protected void convertActivity(java.util.List<Activity> activities,
+ ConversionContext context) {
+ getSource().setComponentURI(getURI());
+
+ org.scribble.conversation.model.While elem=
+ new org.scribble.conversation.model.While();
+
+ // TODO: Convert while expression
+
+ if (getActivity() != null) {
+ getActivity().convert(elem.getBlock().getContents(), context);
+ }
+
+ activities.add(elem);
+ }
+
+ /**
+ * This method sets the condition.
+ *
+ * @param cond The condition
+ */
+ public void setCondition(Condition cond) {
+ m_condition = cond;
+
+ org.w3c.dom.Element insertBefore=null;
+
+ if (m_activity != null) {
+ insertBefore = m_activity.getDOMElement();
+ }
+
+ setChildElement(findChildElement(Condition.CONDITION),
+ cond, insertBefore);
+ }
+
+ /**
+ * This method returns the condition.
+ *
+ * @return The condition
+ */
+ public Condition getCondition() {
+ return(m_condition);
+ }
+
+ /**
+ * This method sets the main 'if' activity.
+ *
+ * @param act The activity associated with the 'if'
+ */
+ public void setActivity(BPELElement act) {
+ m_activity = act;
+
+ BPELElement existing=findChildActivity();
+ org.w3c.dom.Element existingElem=null;
+
+ if (existing != null) {
+ existingElem = existing.getDOMElement();
+ }
+
+ org.w3c.dom.Element insertBefore=null;
+
+ setChildElement(existingElem, act,
+ insertBefore);
+ }
+
+ /**
+ * This method returns the activity associated with
+ * the 'if' path.
+ *
+ * @return The 'if' activity
+ */
+ public BPELElement getActivity() {
+ return(m_activity);
+ }
+
+ protected String getLocalURIPart(BPELElement elem) {
+ String ret="";
+
+ if (elem instanceof BPELActivity) {
+ ret = "@activity";
+ }
+
+ return(ret);
+ }
+
+ private Condition m_condition=null;
+ private BPELElement m_activity=null;
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/util/InteractionUtil.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/util/InteractionUtil.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/util/InteractionUtil.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.util;
+
+import org.jboss.savara.bpel.model.component.BPELActivity;
+import org.jboss.savara.bpel.model.component.Invoke;
+import org.jboss.savara.bpel.model.component.Sequence;
+import org.scribble.model.*;
+
+/**
+ * This class contains utility functions for dealing with Interactions.
+ */
+public class InteractionUtil {
+
+ /**
+ * This method returns the name associated with the interaction.
+ *
+ * @param interaction The interaction
+ * @return The name
+ */
+ public static String getName(Interaction interaction) {
+ String ret=null;
+
+ if (isSend(interaction)) {
+ ret = "Send";
+ } else {
+ ret = "Receive";
+ }
+
+ for (TypeReference ref : interaction.getMessageSignature().getTypes()) {
+ ret += "_"+ref.getLocalpart();
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied interaction
+ * is a send.
+ *
+ * @param interaction The interaction
+ * @return Whether the interaction is a send
+ */
+ public static boolean isSend(Interaction interaction) {
+ boolean ret=false;
+ Role role=null;
+
+ if (interaction.getEnclosingDefinition() != null) {
+ role = interaction.getEnclosingDefinition().
+ getLocatedName().getRole();
+ }
+
+ if (role != null && ((interaction.getFromRole() != null &&
+ interaction.getFromRole().equals(
+ role)) ||
+ (interaction.getToRole() != null &&
+ interaction.getToRole().equals(
+ role) == false))) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied interaction
+ * is a request.
+ *
+ * @param interaction The interaction
+ * @return Whether the interaction is a request
+ */
+ public static boolean isRequest(Interaction interaction) {
+ boolean ret=false;
+
+ if (interaction.getRequestLabel() != null ||
+ interaction.getReplyToLabel() == null) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether the supplied interaction
+ * is a response.
+ *
+ * @param interaction The interaction
+ * @return Whether the interaction is a response
+ */
+ public static boolean isResponse(Interaction interaction) {
+ boolean ret=false;
+
+ if (interaction.getReplyToLabel() != null) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method determines whether this is the first interaction
+ * associated with the conversation.
+ *
+ * @param interaction The interaction
+ * @return Whether the interaction is the first in the conversation
+ */
+ /**
+ * This method determines whether the supplied activity
+ * is either an invoke, or a sequence that has an
+ * invoke as its first element.
+ *
+ * @param act The activity
+ * @return The invoke, or null if not found
+ */
+ public static Invoke getInvoke(BPELActivity act) {
+ Invoke ret=null;
+
+ if (act instanceof Invoke) {
+ ret = (Invoke)act;
+ } else if (act instanceof Sequence &&
+ ((Sequence)act).getActivities().size() > 0 &&
+ ((Sequence)act).getActivities().get(0) instanceof Invoke) {
+ ret = (Invoke)((Sequence)act).getActivities().get(0);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method recursively counts the number of 'invoke' activities
+ * contained within a DOM element.
+ *
+ * @param elem The current element
+ * @return The number of invokes contained within the element
+ */
+ public static int countInvokes(org.w3c.dom.Element elem) {
+ int ret=0;
+
+ if (elem.getLocalName().equals("invoke")) {
+ ret = 1;
+ } else {
+ org.w3c.dom.NodeList nl=elem.getChildNodes();
+
+ for (int i=0; i < nl.getLength(); i++) {
+ if (nl.item(i) instanceof org.w3c.dom.Element) {
+ ret += countInvokes((org.w3c.dom.Element)nl.item(i));
+ }
+ }
+ }
+
+ return(ret);
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/util/TypeReferenceUtil.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/util/TypeReferenceUtil.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/model/util/TypeReferenceUtil.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.model.util;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.savara.bpel.model.component.ConversionContext;
+import org.scribble.model.TypeReference;
+
+public class TypeReferenceUtil {
+
+ public static TypeReference createTypeReference(String type, ConversionContext context) {
+ TypeReference ret=new TypeReference();
+ //ret.derivedFrom(this);
+
+ if (type != null) {
+ int index=-1;
+
+ if (type.charAt(0) == '{') {
+ // Assume a qname
+ QName qname=QName.valueOf(type);
+
+ ret.setLocalpart(qname.getLocalPart());
+ ret.setNamespace(qname.getNamespaceURI());
+
+ } else if ((index=type.indexOf(':')) == -1) {
+ ret.setLocalpart(type);
+
+ } else {
+ ret.setLocalpart(type.substring(index+1));
+
+ String prefix=type.substring(0, index);
+ String ns=context.getNamespace(prefix);
+
+ if (ns != null) {
+ ret.setNamespace(ns);
+ } else {
+ // TODO: Log error
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/osgi/Activator.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/osgi/Activator.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/osgi/Activator.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,30 @@
+package org.jboss.savara.bpel.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/parser/BPELModelParserRule.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/parser/BPELModelParserRule.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/parser/BPELModelParserRule.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.parser;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.Model;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.ParserContext;
+import org.scribble.parser.ParserRule;
+import org.scribble.parser.Token;
+import org.jboss.savara.bpel.model.BPELNotation;
+import org.jboss.savara.bpel.model.DefaultBPELLanguageModel;
+
+/**
+ * This class provides the model parser for the BPEL notation.
+ *
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=BPELNotation.NOTATION_CODE)
+public class BPELModelParserRule extends org.scribble.conversation.parser.ConversationModelParserRule {
+
+ /**
+ * The default constructor.
+ */
+ public BPELModelParserRule() {
+ //super(ParserRuleType.File);
+ }
+
+ /**
+ * This method determines whether the parser rules is
+ * appropriate to return a model object of the required
+ * type.
+ *
+ * @param type The required type
+ * @return Whether the parser rule returns a
+ * model object of the required type
+ */
+ public boolean isSupported(Class<?> type) {
+ return(type.isAssignableFrom(Model.class));
+ }
+
+ /**
+ * This method parses the description to obtain
+ * a model object of the appropriate type.
+ *
+ * @param context The context
+ * @param l The listener
+ * @return The model object
+ */
+ public Object parse(ParserContext context, ModelListener l) {
+ DefaultBPELLanguageModel ret=null;
+
+ Token t=context.nextToken();
+
+ if (t != null && t.getObject() instanceof String) {
+ try {
+ String str=(String)t.getObject();
+
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+
+ // Need to load original input stream and then
+ // provide a second input stream, as some input stream
+ // implementations don't support 'reset' operation,
+ // and therefore this was the only way to extract the
+ // content and also provide the stream to the XML
+ // document builder.
+ java.io.ByteArrayInputStream bais=
+ new java.io.ByteArrayInputStream(str.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(bais);
+
+ // Identify the model associated with the
+ // changed resource
+ ret = new DefaultBPELLanguageModel(context.getSource(),
+ doc.getDocumentElement(), str, context.getEnvironmentContext());
+
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to load model", e);
+ }
+ }
+
+ return(ret);
+ }
+
+ private static Logger logger = Logger.getLogger("org.jboss.savara.tools.bpel.parser");
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/parser/BPELTokenizer.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/parser/BPELTokenizer.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/parser/BPELTokenizer.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.parser;
+
+import org.jboss.savara.bpel.model.BPELNotation;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.parser.*;
+
+/**
+ * This is the BPEL based implementation of the tokenizer
+ * interface.
+ */
+ at RegistryInfo(extension=Tokenizer.class,notation=BPELNotation.NOTATION_CODE)
+public class BPELTokenizer extends DefaultTokenizer {
+
+ /**
+ * The default constructor.
+ */
+ public BPELTokenizer() {
+ }
+
+ /**
+ * This method obtains a list of tokens based on the
+ * contents of the input stream.
+ *
+ * @param ref The model reference for the input source
+ * @param is The input stream
+ * @return The list of tokens
+ * @throws java.io.IOException Failed to derive
+ */
+ public java.util.List<Token> getTokens(ModelReference ref,
+ java.io.InputStream is) throws java.io.IOException {
+ java.util.List<Token> ret=new java.util.Vector<Token>();
+
+ byte[] b=new byte[is.available()];
+ is.read(b);
+
+ Token t=new Token(new String(b));
+ ret.add(t);
+
+ return(ret);
+ }
+}
Added: trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/util/XMLUtils.java
===================================================================
--- trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/util/XMLUtils.java (rev 0)
+++ trunk/bundles/org.jboss.savara.bpel/src/java/org/jboss/savara/bpel/util/XMLUtils.java 2010-11-18 11:04:51 UTC (rev 475)
@@ -0,0 +1,300 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.savara.bpel.util;
+
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.scribble.model.ModelObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
+ * This class defines a set of XML related utility functions.
+ */
+public final class XMLUtils {
+
+ private static final String NS_LABEL = "ns";
+
+ /**
+ * This class converts a DOM representation node to text.
+ * @param node
+ * @return
+ * @throws Exception
+ */
+ public static final String toText(Node node) throws Exception {
+ String ret = null;
+ try {
+ // Transform the DOM represent to text
+ ByteArrayOutputStream xmlstr= new ByteArrayOutputStream();
+ DOMSource source=new DOMSource(node);
+ //source.setNode(node);
+
+ StreamResult result=new StreamResult(xmlstr);
+ Transformer trans= TransformerFactory.newInstance().newTransformer();
+ trans.transform(source, result);
+
+ xmlstr.close();
+
+ ret = new String(xmlstr.toByteArray());
+
+ if ((node instanceof Document) == false) {
+ // Strip off any <?xml> header
+ int index=ret.indexOf("<?xml");
+ if (index != -1) {
+ index = ret.indexOf("<", 1);
+ if (index != -1) {
+ ret = ret.substring(index);
+ } else {
+ index = ret.indexOf("?>");
+ if (index != -1) {
+ index += 2;
+
+ // Remove any trailing whitespaces after XML header
+ while (index < ret.length() &&
+ Character.isWhitespace(ret.charAt(index))) {
+ index++;
+ }
+
+ ret = ret.substring(index);
+ }
+ }
+ }
+ }
+
+ } catch(Exception e) {
+ throw new Exception("Failed to transform DOM representation into text", e);
+ }
+ if (ret != null) {
+ return format(ret);
+ }
+ return ret;
+ }
+
+
+ /**
+ * Format the xml to well print.
+ *
+ * @param xmltext
+ * @return
+ */
+ public static final String format(String xmltext) {
+ String ret=xmltext;
+ int pos=0;
+ int prevpos=0;
+ StringBuffer buf=new StringBuffer();
+ int level=0;
+
+ while ((pos=ret.indexOf('<', prevpos)) != -1) {
+
+ if (prevpos < pos &&
+ ret.substring(prevpos, pos).trim().length() > 0 &&
+ ret.charAt(prevpos-1) != '?') {
+
+ if (ret.charAt(prevpos) == '\r' &&
+ ret.charAt(prevpos+1) == '\n') {
+ prevpos += 2;
+ }
+ for (int i=0; i < level; i++) {
+ buf.append(" ");
+ }
+
+ buf.append(ret.substring(prevpos, pos).trim());
+ buf.append("\r\n");
+ }
+
+ int endpos=ret.indexOf('>', pos);
+
+ if (endpos > 0) {
+ boolean noreturn=false;
+
+ if (pos > 0 && ret.charAt(pos+1) == '/') {
+ level--;
+ }
+
+ for (int i=0; i < level; i++) {
+ buf.append(" ");
+ }
+ buf.append(ret.substring(pos, endpos+1));
+
+ if (ret.charAt(endpos-1)== '?') {
+ //noreturn = true;
+
+ } else if (ret.charAt(endpos-1) == '/') {
+ // Ignore
+ } else if (pos > 0 && ret.charAt(pos+1) == '/') {
+ // Ignore
+
+ } else if (pos > 0 && ret.charAt(pos+1) == '!') {
+ // Ignore
+
+ } else {
+ level++;
+ }
+
+ if (noreturn == false) {
+ buf.append("\r\n");
+ }
+
+ pos = endpos+1;
+ }
+
+ prevpos = pos;
+ }
+
+ if (prevpos != -1 &&
+ ret.substring(prevpos).trim().length() > 0) {
+ buf.append(ret.substring(prevpos));
+ }
+
+ ret = buf.toString();
+
+ return(ret);
+ }
+
+ public static Node getNode(String text) throws Exception {
+ Node ret=null;
+
+ // Transform the text representation to DOM
+ DocumentBuilderFactory fact=DocumentBuilderFactory.newInstance();
+ fact.setNamespaceAware(true);
+
+ java.io.InputStream xmlstr=
+ new java.io.ByteArrayInputStream(text.getBytes());
+
+ DocumentBuilder builder=fact.newDocumentBuilder();
+ org.w3c.dom.Document doc=builder.parse(xmlstr);
+
+ ret = doc.getDocumentElement();
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the localname part of the supplied
+ * qualified name.
+ *
+ * @param qname The qualified name
+ * @return The localname part
+ */
+ public static String getLocalname(String qname) {
+ String ret=qname;
+ int pos=0;
+
+ if (qname != null && ((pos=qname.indexOf(':')) != -1)) {
+ ret = qname.substring(pos+1);
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns the prefix associated with the supplied namespace.
+ *
+ * @param namespace The namespace
+ * @param nsMap The existing namespace prefix mappings
+ * @return The prefix
+ */
+ public static String getPrefix(String namespace, java.util.Map<String,String> nsMap) {
+ String prefix=null;
+
+ prefix = nsMap.get(namespace);
+
+ if (prefix == null) {
+ prefix = NS_LABEL+(nsMap.size()+1);
+ nsMap.put(namespace, prefix);
+ }
+
+ return(prefix);
+ }
+
+ /**
+ * This method calculates the start and end position of a supplied DOM element, within
+ * the supplied text contents, and sets the values on the supplied ModelObject.
+ *
+ * @param obj The ModelObject to be initialized
+ * @param contents The text contents
+ * @param elem The DOM element to be located in the text
+ */
+ public static void setStartAndEndPosition(ModelObject obj, String contents, org.w3c.dom.Element elem) {
+
+ if (contents != null) {
+ org.w3c.dom.NodeList nl=elem.getOwnerDocument().getElementsByTagName(elem.getNodeName());
+ int elempos=-1;
+
+ for (int i=0; elempos == -1 && i < nl.getLength(); i++) {
+ if (nl.item(i) == elem) {
+ elempos = i;
+ }
+ }
+
+ if (elempos != -1) {
+ int startpos=-1;
+
+ for (int i=0; i <= elempos; i++) {
+ int val1=contents.indexOf("<"+elem.getNodeName()+">", startpos+1);
+ int val2=contents.indexOf("<"+elem.getNodeName()+" ", startpos+1);
+
+ if (val1 == -1 && val2 != -1) {
+ startpos = val2;
+ } else if (val1 != -1 && val2 == -1) {
+ startpos = val1;
+ } else if (val1 == -1 && val2 == -1) {
+ // TODO: Error condition
+ break;
+ } else if (val1 > val2) {
+ startpos = val2;
+ } else {
+ startpos = val1;
+ }
+ }
+
+ if (startpos != -1) {
+ obj.getSource().setStartPosition(startpos);
+
+ // Check if single node
+ int p1=contents.indexOf('>', startpos);
+
+ if (p1 != -1 && contents.charAt(p1-1) == '/') {
+ obj.getSource().setEndPosition(p1);
+ } else {
+
+ org.w3c.dom.NodeList enl=elem.getElementsByTagName(elem.getNodeName());
+
+ int endpos=startpos;
+ String nodetxt="</"+elem.getNodeName()+">";
+
+ for (int i=0; endpos != -1 && i <= enl.getLength(); i++) {
+ endpos = contents.indexOf(nodetxt, endpos+1);
+ }
+
+ if (endpos != -1) {
+ obj.getSource().setEndPosition(endpos+nodetxt.length()-1);
+ }
+ }
+ }
+ }
+ }
+ }
+}
Modified: trunk/bundles/pom.xml
===================================================================
--- trunk/bundles/pom.xml 2010-11-18 09:12:07 UTC (rev 474)
+++ trunk/bundles/pom.xml 2010-11-18 11:04:51 UTC (rev 475)
@@ -32,6 +32,7 @@
<modules>
<module>org.jboss.savara.wsdl</module>
+ <module>org.jboss.savara.bpel</module>
</modules>
More information about the savara-commits
mailing list