Author: objectiser
Date: 2009-06-23 18:35:38 -0400 (Tue, 23 Jun 2009)
New Revision: 650
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Process.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeActivity.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/parser/results/LoanApprovalService(a)Service.scv
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ProcessTest.java
Removed:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcess.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcessTest.java
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/IfModelChangeRule.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Catch.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Invoke.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Scope.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/util/InteractionUtil.java
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/parser/results/ESBBroker(a)Broker.scv
Log:
Sorted out derivation of fault handling behaviour when more than one invoke in the
scope/process.
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/BPELLanguageModel.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -17,7 +17,7 @@
*/
package org.jboss.tools.overlord.cdl.bpel.model;
-import org.jboss.tools.overlord.cdl.bpel.model.component.BPELProcess;
+import org.jboss.tools.overlord.cdl.bpel.model.component.Process;
import org.scribble.model.*;
import org.scribble.model.admin.ModelListener;
@@ -55,6 +55,6 @@
*
* @return The BPEL Process
*/
- public BPELProcess getBPELProcess();
+ public Process getBPELProcess();
}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/DefaultBPELLanguageModel.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -18,7 +18,7 @@
package org.jboss.tools.overlord.cdl.bpel.model;
import org.apache.commons.logging.*;
-import org.jboss.tools.overlord.cdl.bpel.model.component.BPELProcess;
+import org.jboss.tools.overlord.cdl.bpel.model.component.Process;
import org.scribble.conversation.model.Conversation;
import org.scribble.model.*;
import org.scribble.model.admin.ModelIssue;
@@ -47,7 +47,7 @@
public DefaultBPELLanguageModel(ModelReference source, org.w3c.dom.Element elem,
String contents) {
m_source = source;
- m_bpelProcess = new BPELProcess(this, elem);
+ m_bpelProcess = new Process(this, elem);
m_contents = contents;
Namespace ns=new Namespace();
@@ -72,7 +72,7 @@
public DefaultBPELLanguageModel(ModelReference source) {
m_source = source;
- m_bpelProcess = new BPELProcess(this);
+ m_bpelProcess = new Process(this);
}
/**
@@ -120,14 +120,14 @@
*
* @return The BPEL Process
*/
- public BPELProcess getBPELProcess() {
+ public Process getBPELProcess() {
return(m_bpelProcess);
}
private static Log logger = LogFactory.getLog(DefaultBPELLanguageModel.class);
private ModelReference m_source=null;
- private BPELProcess m_bpelProcess=null;
+ private Process m_bpelProcess=null;
private String m_contents=null;
public class InnerModelListener implements ModelListener {
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/IfModelChangeRule.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/IfModelChangeRule.java 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/change/IfModelChangeRule.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -117,6 +117,10 @@
c.setFaultName(faultName);
c.setFaultVariable(faultVarName);
+ // TODO: Maybe variable should not be created - just
+ // defined in the scope of the catch? But would then
+ // need to define the fault message type/element.
+
// Create variable
if (faultVarName != null) {
createVariable(faultVarName, (Interaction)act, bpelModel);
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcess.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcess.java 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcess.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -1,640 +0,0 @@
-/*
- * 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.tools.overlord.cdl.bpel.model.component;
-
-import org.scribble.conversation.model.Conversation;
-import org.scribble.conversation.model.ConversationNotation;
-import org.scribble.model.*;
-import org.scribble.model.admin.DependencyType;
-import org.scribble.model.admin.ModelListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.tools.overlord.cdl.bpel.model.*;
-
-/**
- * This class represents a BPEL process.
- *
- * @author gary
- */
-public class BPELProcess extends BPELElement {
-
- private static final long serialVersionUID = 3400962966628415184L;
-
- public static final String PROCESS = "process";
- public static final String NAME = "name";
- public static final String CONVERSATION_TYPE = "conversationType";
-
- 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 BPELProcess(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);
- }
-
- m_activity = findChildActivity();
- }
-
- /**
- * The constructor for the activity.
- *
- * @param model The BPEL model
- */
- public BPELProcess(BPELLanguageModel model) {
- super(model, PROCESS);
- }
-
- /**
- * 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 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 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 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(7);
- }
- }
- }
-
- return(ret);
- }
-
- /**
- * 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(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 BPELElement 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 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) {
-
- // TODO: Deal with fault and event handlers
-
- if (m_activity != null) {
- m_activity.convert(activities, context);
- }
- }
-
- /**
- * This method returns the conversion associated with the
- * BPEL process.
- *
- * @return The conversation
- */
- public Conversation convert() {
- Conversation ret=new Conversation();
-
- ret.derivedFrom(this);
- ret.getBlock().derivedFrom(this);
-
- // Configure model name
- ModelName modelName=new ModelName();
- modelName.setName(getName());
-
- ret.setModelName(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.setLocatedRole(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);
- //ret.getConformsTo().add(iref);
-
- org.scribble.model.admin.DependencyManager dm=
- (org.scribble.model.admin.DependencyManager)
- org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
- org.scribble.model.admin.DependencyManager.class, null);
-
- if (dm != null) {
- dm.recordDependency(getModel().getModelReference(),
- iref, DependencyType.Implements);
- }
-
- } else {
- logger.warn("Conversation type does not " +
- "contain '@' located role separator");
- }
- }
-
- // Convert the process contents
- DefaultConversionContext context=new DefaultConversionContext(role);
-
- // 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);
- }
-
- private static Log logger = LogFactory.getLog(BPELProcess.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<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;
-}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Catch.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Catch.java 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Catch.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -34,6 +34,8 @@
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.
@@ -133,5 +135,43 @@
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);
+ }
+
private BPELElement m_activity;
}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Invoke.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Invoke.java 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Invoke.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -123,7 +123,7 @@
// Check if invoke is contained within a scope that defines
// fault handlers. If so, then generate choice to throw
// fault exceptions.
- Scope scope=null;
+ ScopeActivity scope=null;
org.w3c.dom.Element cur=getDOMElement();
while (cur != null && cur.getParentNode() instanceof org.w3c.dom.Element
&&
@@ -134,8 +134,8 @@
BPELElement elem=BPELElementFactory.createBPELElement(getModel(),
cur);
- if (elem instanceof Scope) {
- scope = (Scope)elem;
+ if (elem instanceof ScopeActivity) {
+ scope = (ScopeActivity)elem;
}
}
}
@@ -160,8 +160,15 @@
org.scribble.conversation.model.ConditionalBlock fcb=
new org.scribble.conversation.model.ConditionalBlock();
- convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(), context);
+ String mesgType=catchBlock.getFaultMessageType();
+ if (mesgType == null) {
+ mesgType = catchBlock.getFaultMessageElement();
+ }
+
+ convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
+ mesgType, context);
+
org.scribble.conversation.model.Raise raise=
new org.scribble.conversation.model.Raise();
@@ -247,26 +254,40 @@
}
protected void convertFaultResponse(java.util.List<Activity> activities,
- String faultVar, ConversionContext context) {
+ String faultVar, String faultMesgType, ConversionContext context) {
// Create interaction for request
ConversationInteraction interaction=new ConversationInteraction();
TypeReference tref=new TypeReference();
+ // 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) {
- tref.setAlias(var.getMessageType());
+ tref.setAlias(var.getMessageType());
+ } else if (faultMesgType != null) {
+ tref.setAlias(faultMesgType);
}
MessageSignature ms=new MessageSignature();
ms.setOperation(getOperation());
ms.getTypes().add(tref);
- interaction.setFromRole(new Role(getClientPartnerRole()));
- interaction.setToRole(new Role(context.getRole()));
+ 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);
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Process.java
(from rev 643,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcess.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Process.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Process.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -0,0 +1,739 @@
+/*
+ * 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.tools.overlord.cdl.bpel.model.component;
+
+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.DependencyType;
+import org.scribble.model.admin.ModelListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.tools.overlord.cdl.bpel.model.*;
+import org.jboss.tools.overlord.cdl.bpel.model.util.InteractionUtil;
+
+/**
+ * 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 CONVERSATION_TYPE = "conversationType";
+
+ 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);
+
+ 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);
+ }
+
+ /**
+ * 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 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 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 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(7);
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * 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(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();
+ }
+
+ invoke.convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
+ mesgType, context);
+
+ if (catchBlock.getActivity() != null) {
+ catchBlock.getActivity().convert(fcb.getContents(), context);
+ }
+
+ choice.getConditionalBlocks().add(fcb);
+ }
+
+ 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();
+
+ acts.add(te);
+
+ acts = te.getBlock().getContents();
+
+ for (int i=0; i < getFaultHandlers().getCatchPaths().size(); i++) {
+ org.scribble.conversation.model.CatchBlock cb=
+ new org.scribble.conversation.model.CatchBlock();
+
+ TypeReference tref=new TypeReference();
+ tref.setAlias(getFaultHandlers().getCatchPaths().get(i).getFaultName());
+ cb.setType(tref);
+
+ if (getFaultHandlers().getCatchPaths().get(i).getActivity() != null) {
+ getFaultHandlers().getCatchPaths().get(i).getActivity().
+ convert(cb.getContents(), context);
+ }
+
+ 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.
+ *
+ * @return The conversation
+ */
+ public Conversation convert() {
+ Conversation ret=new Conversation();
+
+ ret.derivedFrom(this);
+ ret.getBlock().derivedFrom(this);
+
+ // Configure model name
+ ModelName modelName=new ModelName();
+ modelName.setName(getName());
+
+ ret.setModelName(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.setLocatedRole(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);
+ //ret.getConformsTo().add(iref);
+
+ org.scribble.model.admin.DependencyManager dm=
+ (org.scribble.model.admin.DependencyManager)
+ org.scribble.extensions.RegistryFactory.getRegistry().getExtension(
+ org.scribble.model.admin.DependencyManager.class, null);
+
+ if (dm != null) {
+ dm.recordDependency(getModel().getModelReference(),
+ iref, DependencyType.Implements);
+ }
+
+ } else {
+ logger.warn("Conversation type does not " +
+ "contain '@' located role separator");
+ }
+ }
+
+ // Convert the process contents
+ DefaultConversionContext context=new DefaultConversionContext(role);
+
+ // 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);
+ }
+
+ 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<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;
+}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Scope.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Scope.java 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/Scope.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -24,13 +24,14 @@
import org.scribble.model.*;
import org.scribble.model.admin.ModelListener;
import org.jboss.tools.overlord.cdl.bpel.model.*;
+import org.jboss.tools.overlord.cdl.bpel.model.util.InteractionUtil;
/**
* This class represents a scope grouping activity.
*
* @author gary
*/
-public class Scope extends BPELActivity {
+public class Scope extends BPELActivity implements ScopeActivity {
private static final long serialVersionUID = 7132062003047468101L;
@@ -534,8 +535,8 @@
context.addVariable(m_variables.get(i));
}
- // TODO: Count number of invoke activities
- int invokeCount=countInvokes(getActivity().getDOMElement());
+ // 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
@@ -547,7 +548,7 @@
m_faultHandlers.getCatchAll() != null) &&
(m_eventHandlers == null || (m_eventHandlers.getOnEvents().size() == 0 &&
m_eventHandlers.getOnAlarms().size() == 0)) &&
- (invoke = getInvoke(m_activity)) != null) {
+ (invoke = InteractionUtil.getInvoke(m_activity)) != null) {
invoke.convertRequest(activities, context);
@@ -573,8 +574,15 @@
ConditionalBlock fcb=new ConditionalBlock();
- invoke.convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
context);
+ String mesgType=catchBlock.getFaultMessageType();
+ if (mesgType == null) {
+ mesgType = catchBlock.getFaultMessageElement();
+ }
+
+ invoke.convertFaultResponse(fcb.getContents(), catchBlock.getFaultVariable(),
+ mesgType, context);
+
if (catchBlock.getActivity() != null) {
catchBlock.getActivity().convert(fcb.getContents(), context);
}
@@ -623,45 +631,6 @@
}
}
- protected Invoke getInvoke(BPELActivity act) {
- Invoke ret=null;
-
- if (act instanceof Invoke) {
- ret = (Invoke)act;
- } else if (act instanceof Sequence &&
- ((Sequence)m_activity).getActivities().size() > 0 &&
- ((Sequence)m_activity).getActivities().get(0) instanceof Invoke) {
- ret = (Invoke)((Sequence)m_activity).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
- */
- protected 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);
- }
-
private org.w3c.dom.Element m_partnerLinksElem=null;
private org.w3c.dom.Element m_variablesElem=null;
private org.w3c.dom.Element m_messageExchangesElem=null;
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeActivity.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeActivity.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/component/ScopeActivity.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -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.tools.overlord.cdl.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);
+
+}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/util/InteractionUtil.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/util/InteractionUtil.java 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/java/org/jboss/tools/overlord/cdl/bpel/model/util/InteractionUtil.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -17,6 +17,9 @@
*/
package org.jboss.tools.overlord.cdl.bpel.model.util;
+import org.jboss.tools.overlord.cdl.bpel.model.component.BPELActivity;
+import org.jboss.tools.overlord.cdl.bpel.model.component.Invoke;
+import org.jboss.tools.overlord.cdl.bpel.model.component.Sequence;
import org.scribble.model.*;
/**
@@ -86,4 +89,51 @@
return(ret);
}
+
+ /**
+ * 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);
+ }
}
Modified:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/parser/results/ESBBroker(a)Broker.scv
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/parser/results/ESBBroker(a)Broker.scv 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/parser/results/ESBBroker(a)Broker.scv 2009-06-23
22:35:38 UTC (rev 650)
@@ -9,14 +9,23 @@
makeEnquiry(quoteList) from Broker to Buyer;
if {
buy(buy) from Buyer to Broker;
- checkCredit(CreditCheckRequest) from Broker to CreditAgency;
- if {
- checkCredit(CreditCheckOk) from CreditAgency to Broker;
+ try {
+ checkCredit(CreditCheckRequest) from Broker to CreditAgency;
+ if {
+ checkCredit(CreditCheckOk) from CreditAgency to Broker;
+ } else if {
+ checkCredit(CreditCheckInvalid) from CreditAgency to Broker;
+ raise invalidCredit;
+ }
confirm(orderConfirmed) from Broker to SupplierTxnProcessor;
- confirm(bookingReference) from SupplierTxnProcessor to Broker;
+ if {
+ confirm(bookingReference) from SupplierTxnProcessor to Broker;
+ } else if {
+ confirm(CreditCheckInvalid) from SupplierTxnProcessor to Broker;
+ raise invalidCredit;
+ }
buy(bookingReference) from Broker to Buyer;
- } else if {
- checkCredit(CreditCheckInvalid) from CreditAgency to Broker;
+ } catch invalidCredit {
buy(orderRejected) from Broker to Buyer;
}
} else if {
Added:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/parser/results/LoanApprovalService(a)Service.scv
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/parser/results/LoanApprovalService(a)Service.scv
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/plugintest/org/jboss/tools/overlord/cdl/bpel/parser/results/LoanApprovalService(a)Service.scv 2009-06-23
22:35:38 UTC (rev 650)
@@ -0,0 +1,41 @@
+namespace null;
+
+conversation loanApprovalProcess {
+ try {
+ boolean receive-to-assess, receive-to-approval, approval-to-reply,
assess-to-setMessage, setMessage-to-reply, assess-to-approval;
+ parallel {
+ request(lns:creditInformationMessage) from customer;
+ receive-to-assess = xpath[true()];
+ receive-to-approval = xpath[true()];
+ } and {
+ when (xpath[$receive-to-assess]) {
+ check(lns:creditInformationMessage) to assessor;
+ if {
+ check(lns:riskAssessmentMessage) from assessor;
+ } else if {
+ check(lns:errorMessage) from assessor;
+ raise lns:loanProcessFault;
+ }
+ assess-to-setMessage = xpath[true()];
+ assess-to-approval = xpath[true()];
+ }
+ } and {
+ when (xpath[$receive-to-approval and $assess-to-approval]) {
+ approve(lns:creditInformationMessage) to approver;
+ if {
+ approve(lns:approvalMessage) from approver;
+ } else if {
+ approve(lns:errorMessage) from approver;
+ raise lns:loanProcessFault;
+ }
+ approval-to-reply = xpath[true()];
+ }
+ } and {
+ when (xpath[$setMessage-to-reply and $approval-to-reply]) {
+ request(lns:approvalMessage) to customer;
+ }
+ }
+ } catch lns:loanProcessFault {
+ request() to customer;
+ }
+}
\ No newline at end of file
Deleted:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcessTest.java
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcessTest.java 2009-06-22
23:10:42 UTC (rev 649)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcessTest.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -1,376 +0,0 @@
-/*
- * 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.tools.overlord.cdl.bpel.model.component;
-
-import org.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
-import org.jboss.tools.overlord.cdl.bpel.model.DefaultBPELLanguageModel;
-
-import junit.framework.TestCase;
-
-public class BPELProcessTest extends TestCase {
-
- public void testIsActivity() {
- BPELProcess act=new BPELProcess(new DefaultBPELLanguageModel(null));
-
- if (act.isActivity() == true) {
- fail("Should NOT be an activity");
- }
- }
-
- public void testProcessFromDOM() {
- BPELLanguageModel model=new DefaultBPELLanguageModel(null);
-
- String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
- "<partnerLinks><partnerLink/></partnerLinks>"+
- "<messageExchanges/>"+
- "<variables><variable/></variables>"+
- "<correlationSets/>"+
- "<faultHandlers/>"+
- "<eventHandlers/>"+
- "<sequence/>"+
- "</scope>";
-
- org.w3c.dom.Element elem=null;
-
- try {
- javax.xml.parsers.DocumentBuilderFactory factory=
- javax.xml.parsers.DocumentBuilderFactory.newInstance();
-
- factory.setNamespaceAware(true);
-
- javax.xml.parsers.DocumentBuilder builder=
- factory.newDocumentBuilder();
-
- java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
-
- org.w3c.dom.Document doc=builder.parse(is);
- elem = doc.getDocumentElement();
-
- is.close();
- } catch(Exception e) {
- fail("Failed to convert to doc");
- }
-
- BPELProcess component=new BPELProcess(model, elem);
-
- if (component.getPartnerLinks().size() != 1) {
- fail("Expecting 1 partner link: "+component.getPartnerLinks().size());
- }
-
- if (component.getVariables().size() != 1) {
- fail("Expecting 1 variable: "+component.getVariables().size());
- }
-
- if (component.getActivity() == null) {
- fail("Activity not defined");
- }
-
- if (component.getEventHandlers() == null) {
- fail("Event handlers not defined");
- }
-
- if (component.getFaultHandlers() == null) {
- fail("Fault handlers not defined");
- }
- }
-
- public void testAddVariable() {
- BPELLanguageModel model=new DefaultBPELLanguageModel(null);
-
- String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
- "<partnerLinks><partnerLink/></partnerLinks>"+
- "<messageExchanges/>"+
- "<correlationSets/>"+
- "<faultHandlers/>"+
- "<eventHandlers/>"+
- "<sequence/>"+
- "</scope>";
-
- org.w3c.dom.Element ifelem=null;
-
- try {
- javax.xml.parsers.DocumentBuilderFactory factory=
- javax.xml.parsers.DocumentBuilderFactory.newInstance();
-
- factory.setNamespaceAware(true);
-
- javax.xml.parsers.DocumentBuilder builder=
- factory.newDocumentBuilder();
-
- java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
-
- org.w3c.dom.Document doc=builder.parse(is);
- ifelem = doc.getDocumentElement();
-
- is.close();
- } catch(Exception e) {
- fail("Failed to convert to doc");
- }
-
- BPELProcess component=new BPELProcess(model, ifelem);
-
- if (component.getVariables().size() != 0) {
- fail("Should be no variables");
- }
-
- Variable var=new Variable(model);
- component.addVariable(var, 0);
-
- if (component.getVariables().size() != 1) {
- fail("Should be one variable: "+component.getVariables().size());
- }
-
- if (component.getDOMElement().getChildNodes().
- item(2).getLocalName().equals("variables") == false) {
- fail("Child 2 not as expected: "+component.getDOMElement().getChildNodes().
- item(2).getLocalName());
- }
- }
-
- public void testAddPartnerLink() {
- BPELLanguageModel model=new DefaultBPELLanguageModel(null);
-
- String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
- "<messageExchanges/>"+
- "<variables><variable/></variables>"+
- "<correlationSets/>"+
- "<faultHandlers/>"+
- "<eventHandlers/>"+
- "<sequence/>"+
- "</scope>";
-
- org.w3c.dom.Element elem=null;
-
- try {
- javax.xml.parsers.DocumentBuilderFactory factory=
- javax.xml.parsers.DocumentBuilderFactory.newInstance();
-
- factory.setNamespaceAware(true);
-
- javax.xml.parsers.DocumentBuilder builder=
- factory.newDocumentBuilder();
-
- java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
-
- org.w3c.dom.Document doc=builder.parse(is);
- elem = doc.getDocumentElement();
-
- is.close();
- } catch(Exception e) {
- fail("Failed to convert to doc");
- }
-
- BPELProcess component=new BPELProcess(model, elem);
-
- if (component.getPartnerLinks().size() != 0) {
- fail("Should be no partner links");
- }
-
- PartnerLink pl=new PartnerLink(model);
- component.addPartnerLink(pl, 0);
-
- if (component.getPartnerLinks().size() != 1) {
- fail("Should be one partner link: "+component.getPartnerLinks().size());
- }
-
- if (component.getDOMElement().getChildNodes().
- item(0).getLocalName().equals("partnerLinks") == false) {
- fail("Child 0 not as expected: "+component.getDOMElement().getChildNodes().
- item(0).getLocalName());
- }
- }
-
- public void testGetPartnerLink() {
- BPELLanguageModel model=new DefaultBPELLanguageModel(null);
-
- BPELProcess component=new BPELProcess(model);
- String name="testName";
-
- PartnerLink pl=new PartnerLink(model);
- pl.setName(name);
-
- component.addPartnerLink(pl, 0);
-
- if (component.getPartnerLink(name) == null) {
- fail("Failed to get partner link for '"+name+"'");
- }
-
- if (component.getPartnerLink("unknown") != null) {
- fail("Should not have returned a partner link");
- }
- }
-
- public void testSetEventHandlers() {
- BPELLanguageModel model=new DefaultBPELLanguageModel(null);
-
- String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
- "<partnerLinks><partnerLink/></partnerLinks>"+
- "<messageExchanges/>"+
- "<variables><variable/></variables>"+
- "<correlationSets/>"+
- "<faultHandlers/>"+
- "<sequence/>"+
- "</scope>";
-
- org.w3c.dom.Element ifelem=null;
-
- try {
- javax.xml.parsers.DocumentBuilderFactory factory=
- javax.xml.parsers.DocumentBuilderFactory.newInstance();
-
- factory.setNamespaceAware(true);
-
- javax.xml.parsers.DocumentBuilder builder=
- factory.newDocumentBuilder();
-
- java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
-
- org.w3c.dom.Document doc=builder.parse(is);
- ifelem = doc.getDocumentElement();
-
- is.close();
- } catch(Exception e) {
- fail("Failed to convert to doc");
- }
-
- BPELProcess component=new BPELProcess(model, ifelem);
-
- if (component.getEventHandlers() != null) {
- fail("Should be null");
- }
-
- EventHandlers elem=new EventHandlers(model);
- component.setEventHandlers(elem);
-
- if (component.getEventHandlers() == null) {
- fail("Should NOT be null");
- }
-
- if (component.getDOMElement().getChildNodes().
- item(5).getLocalName().equals("eventHandlers") == false) {
- fail("Child 5 not as expected: "+component.getDOMElement().getChildNodes().
- item(5).getLocalName());
- }
- }
-
- public void testSetFaultHandlers() {
- BPELLanguageModel model=new DefaultBPELLanguageModel(null);
-
- String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
- "<partnerLinks><partnerLink/></partnerLinks>"+
- "<messageExchanges/>"+
- "<variables><variable/></variables>"+
- "<correlationSets/>"+
- "<eventHandlers/>"+
- "<sequence/>"+
- "</scope>";
-
- org.w3c.dom.Element ifelem=null;
-
- try {
- javax.xml.parsers.DocumentBuilderFactory factory=
- javax.xml.parsers.DocumentBuilderFactory.newInstance();
-
- factory.setNamespaceAware(true);
-
- javax.xml.parsers.DocumentBuilder builder=
- factory.newDocumentBuilder();
-
- java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
-
- org.w3c.dom.Document doc=builder.parse(is);
- ifelem = doc.getDocumentElement();
-
- is.close();
- } catch(Exception e) {
- fail("Failed to convert to doc");
- }
-
- BPELProcess component=new BPELProcess(model, ifelem);
-
- if (component.getFaultHandlers() != null) {
- fail("Should be null");
- }
-
- FaultHandlers elem=new FaultHandlers(model);
- component.setFaultHandlers(elem);
-
- if (component.getFaultHandlers() == null) {
- fail("Should NOT be null");
- }
-
- if (component.getDOMElement().getChildNodes().
- item(4).getLocalName().equals("faultHandlers") == false) {
- fail("Child 4 not as expected: "+component.getDOMElement().getChildNodes().
- item(4).getLocalName());
- }
- }
-
- public void testSetActivity() {
- BPELLanguageModel model=new DefaultBPELLanguageModel(null);
-
- String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
- "<partnerLinks><partnerLink/></partnerLinks>"+
- "<messageExchanges/>"+
- "<variables><variable/></variables>"+
- "<correlationSets/>"+
- "<faultHandlers/>"+
- "<eventHandlers/>"+
- "</scope>";
-
- org.w3c.dom.Element ifelem=null;
-
- try {
- javax.xml.parsers.DocumentBuilderFactory factory=
- javax.xml.parsers.DocumentBuilderFactory.newInstance();
-
- factory.setNamespaceAware(true);
-
- javax.xml.parsers.DocumentBuilder builder=
- factory.newDocumentBuilder();
-
- java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
-
- org.w3c.dom.Document doc=builder.parse(is);
- ifelem = doc.getDocumentElement();
-
- is.close();
- } catch(Exception e) {
- fail("Failed to convert to doc");
- }
-
- BPELProcess component=new BPELProcess(model, ifelem);
-
- if (component.getActivity() != null) {
- fail("Should be null");
- }
-
- Sequence elem=new Sequence(model);
- component.setActivity(elem);
-
- if (component.getActivity() == null) {
- fail("Should NOT be null");
- }
-
- if (component.getDOMElement().getChildNodes().
- item(6).getLocalName().equals(Sequence.SEQUENCE) == false) {
- fail("Child 6 not as expected: "+component.getDOMElement().getChildNodes().
- item(6).getLocalName());
- }
- }
-}
Copied:
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ProcessTest.java
(from rev 641,
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/BPELProcessTest.java)
===================================================================
---
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ProcessTest.java
(rev 0)
+++
cdl/trunk/tools/plugins/org.jboss.tools.overlord.cdl.bpel/src/test/org/jboss/tools/overlord/cdl/bpel/model/component/ProcessTest.java 2009-06-23
22:35:38 UTC (rev 650)
@@ -0,0 +1,376 @@
+/*
+ * 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.tools.overlord.cdl.bpel.model.component;
+
+import org.jboss.tools.overlord.cdl.bpel.model.BPELLanguageModel;
+import org.jboss.tools.overlord.cdl.bpel.model.DefaultBPELLanguageModel;
+
+import junit.framework.TestCase;
+
+public class ProcessTest extends TestCase {
+
+ public void testIsActivity() {
+ Process act=new Process(new DefaultBPELLanguageModel(null));
+
+ if (act.isActivity() == true) {
+ fail("Should NOT be an activity");
+ }
+ }
+
+ public void testProcessFromDOM() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<eventHandlers/>"+
+ "<sequence/>"+
+ "</scope>";
+
+ org.w3c.dom.Element elem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ elem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Process component=new Process(model, elem);
+
+ if (component.getPartnerLinks().size() != 1) {
+ fail("Expecting 1 partner link: "+component.getPartnerLinks().size());
+ }
+
+ if (component.getVariables().size() != 1) {
+ fail("Expecting 1 variable: "+component.getVariables().size());
+ }
+
+ if (component.getActivity() == null) {
+ fail("Activity not defined");
+ }
+
+ if (component.getEventHandlers() == null) {
+ fail("Event handlers not defined");
+ }
+
+ if (component.getFaultHandlers() == null) {
+ fail("Fault handlers not defined");
+ }
+ }
+
+ public void testAddVariable() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<eventHandlers/>"+
+ "<sequence/>"+
+ "</scope>";
+
+ org.w3c.dom.Element ifelem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ ifelem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Process component=new Process(model, ifelem);
+
+ if (component.getVariables().size() != 0) {
+ fail("Should be no variables");
+ }
+
+ Variable var=new Variable(model);
+ component.addVariable(var, 0);
+
+ if (component.getVariables().size() != 1) {
+ fail("Should be one variable: "+component.getVariables().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(2).getLocalName().equals("variables") == false) {
+ fail("Child 2 not as expected: "+component.getDOMElement().getChildNodes().
+ item(2).getLocalName());
+ }
+ }
+
+ public void testAddPartnerLink() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<eventHandlers/>"+
+ "<sequence/>"+
+ "</scope>";
+
+ org.w3c.dom.Element elem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ elem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Process component=new Process(model, elem);
+
+ if (component.getPartnerLinks().size() != 0) {
+ fail("Should be no partner links");
+ }
+
+ PartnerLink pl=new PartnerLink(model);
+ component.addPartnerLink(pl, 0);
+
+ if (component.getPartnerLinks().size() != 1) {
+ fail("Should be one partner link: "+component.getPartnerLinks().size());
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(0).getLocalName().equals("partnerLinks") == false) {
+ fail("Child 0 not as expected: "+component.getDOMElement().getChildNodes().
+ item(0).getLocalName());
+ }
+ }
+
+ public void testGetPartnerLink() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ Process component=new Process(model);
+ String name="testName";
+
+ PartnerLink pl=new PartnerLink(model);
+ pl.setName(name);
+
+ component.addPartnerLink(pl, 0);
+
+ if (component.getPartnerLink(name) == null) {
+ fail("Failed to get partner link for '"+name+"'");
+ }
+
+ if (component.getPartnerLink("unknown") != null) {
+ fail("Should not have returned a partner link");
+ }
+ }
+
+ public void testSetEventHandlers() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<sequence/>"+
+ "</scope>";
+
+ org.w3c.dom.Element ifelem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ ifelem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Process component=new Process(model, ifelem);
+
+ if (component.getEventHandlers() != null) {
+ fail("Should be null");
+ }
+
+ EventHandlers elem=new EventHandlers(model);
+ component.setEventHandlers(elem);
+
+ if (component.getEventHandlers() == null) {
+ fail("Should NOT be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(5).getLocalName().equals("eventHandlers") == false) {
+ fail("Child 5 not as expected: "+component.getDOMElement().getChildNodes().
+ item(5).getLocalName());
+ }
+ }
+
+ public void testSetFaultHandlers() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<eventHandlers/>"+
+ "<sequence/>"+
+ "</scope>";
+
+ org.w3c.dom.Element ifelem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ ifelem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Process component=new Process(model, ifelem);
+
+ if (component.getFaultHandlers() != null) {
+ fail("Should be null");
+ }
+
+ FaultHandlers elem=new FaultHandlers(model);
+ component.setFaultHandlers(elem);
+
+ if (component.getFaultHandlers() == null) {
+ fail("Should NOT be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(4).getLocalName().equals("faultHandlers") == false) {
+ fail("Child 4 not as expected: "+component.getDOMElement().getChildNodes().
+ item(4).getLocalName());
+ }
+ }
+
+ public void testSetActivity() {
+ BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+ String xml="<scope
xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\&qu...
+ "<partnerLinks><partnerLink/></partnerLinks>"+
+ "<messageExchanges/>"+
+ "<variables><variable/></variables>"+
+ "<correlationSets/>"+
+ "<faultHandlers/>"+
+ "<eventHandlers/>"+
+ "</scope>";
+
+ org.w3c.dom.Element ifelem=null;
+
+ try {
+ javax.xml.parsers.DocumentBuilderFactory factory=
+ javax.xml.parsers.DocumentBuilderFactory.newInstance();
+
+ factory.setNamespaceAware(true);
+
+ javax.xml.parsers.DocumentBuilder builder=
+ factory.newDocumentBuilder();
+
+ java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+
+ org.w3c.dom.Document doc=builder.parse(is);
+ ifelem = doc.getDocumentElement();
+
+ is.close();
+ } catch(Exception e) {
+ fail("Failed to convert to doc");
+ }
+
+ Process component=new Process(model, ifelem);
+
+ if (component.getActivity() != null) {
+ fail("Should be null");
+ }
+
+ Sequence elem=new Sequence(model);
+ component.setActivity(elem);
+
+ if (component.getActivity() == null) {
+ fail("Should NOT be null");
+ }
+
+ if (component.getDOMElement().getChildNodes().
+ item(6).getLocalName().equals(Sequence.SEQUENCE) == false) {
+ fail("Child 6 not as expected: "+component.getDOMElement().getChildNodes().
+ item(6).getLocalName());
+ }
+ }
+}