Author: objectiser
Date: 2010-12-16 11:32:57 -0500 (Thu, 16 Dec 2010)
New Revision: 506
Added:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/AbstractBPELModelChangeRule.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/BPELModelChangeContext.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ChoiceModelChangeRule.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionModelChangeRule.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionPatterns.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelChangeRule.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelModelChangeRule.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RepeatModelChangeRule.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/generator/
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/generator/ProtocolToBPELModelGenerator.java
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/AbstractModelChangeContext.java
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/generator/
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/generator/DefaultModelGenerator.java
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/generator/ModelGenerator.java
Removed:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/DefaultModelChangeContext.java
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/DefaultModelGenerator.java
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/ModelGenerator.java
Modified:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/generator/GeneratorUtil.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/InteractionUtil.java
branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java
branches/experimental/2.0.x/bundles/org.savara.core/META-INF/MANIFEST.MF
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/AbstractModelChangeRule.java
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/ModelChangeContext.java
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/ModelChangeRule.java
branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel/
branches/experimental/2.0.x/tools/plugins/org.savara.tools.wsdl/
Log:
Intermediate save - still refactoring.
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/AbstractBPELModelChangeRule.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/AbstractBPELModelChangeRule.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/AbstractBPELModelChangeRule.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/AbstractBPELModelChangeRule.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,98 @@
+/*
+ * 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.savara.bpel.model.change;
+
+import org.savara.bpel.BPELDefinitions;
+import org.savara.bpel.model.TProcess;
+import org.savara.bpel.model.TSequence;
+import org.savara.model.change.*;
+import org.scribble.protocol.model.*;
+
+/**
+ * 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (context.getParent() instanceof TSequence && isBPELModel(model)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ protected boolean isBPELModel(ProtocolModel model) {
+ return(model.getProperties().get(BPELDefinitions.BPEL_MODEL_PROPERTY) instanceof
TProcess);
+ }
+
+ protected TProcess getBPELModel(ProtocolModel model) {
+ return((TProcess)model.getProperties().get(BPELDefinitions.BPEL_MODEL_PROPERTY));
+ }
+
+ /**
+ * 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,
+ ProtocolModel 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,
+ ProtocolModel model, ModelObject mobj) {
+ boolean ret=false;
+
+ return(ret);
+ }
+}
Added:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/BPELModelChangeContext.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/BPELModelChangeContext.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/BPELModelChangeContext.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 24 Jul 2008 : Initial version created by gary
+ */
+package org.savara.bpel.model.change;
+
+import org.savara.model.change.AbstractModelChangeContext;
+import org.savara.model.change.ModelChangeRule;
+
+/**
+ * This class provides a default implementation for the model
+ * change context interface.
+ */
+public class BPELModelChangeContext extends AbstractModelChangeContext {
+
+ private static java.util.List<ModelChangeRule> m_rules=new
java.util.Vector<ModelChangeRule>();
+
+ static {
+ m_rules.add(new ChoiceModelChangeRule());
+ m_rules.add(new InteractionModelChangeRule());
+ m_rules.add(new ProtocolModelChangeRule());
+ m_rules.add(new ProtocolModelModelChangeRule());
+ m_rules.add(new RepeatModelChangeRule());
+ m_rules.add(new RunModelChangeRule());
+ }
+
+ /**
+ * This is the constructor for the model change context.
+ *
+ * @param role The role associated with the model
+ */
+ public BPELModelChangeContext() {
+ }
+
+ /**
+ * This method returns a list of model change rules appropriate
+ * for the notation being changed.
+ *
+ * @return The list of model change rules
+ */
+ public java.util.List<ModelChangeRule> getRules() {
+ return(m_rules);
+ }
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ChoiceModelChangeRule.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/ChoiceModelChangeRule.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ChoiceModelChangeRule.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ChoiceModelChangeRule.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,571 @@
+/*
+ * 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.savara.bpel.model.change;
+
+import javax.xml.namespace.QName;
+
+import org.savara.bpel.model.TActivityContainer;
+import org.savara.bpel.model.TBoolean;
+import org.savara.bpel.model.TCatch;
+import org.savara.bpel.model.TElseif;
+import org.savara.bpel.model.TFaultHandlers;
+import org.savara.bpel.model.TIf;
+import org.savara.bpel.model.TOnMessage;
+import org.savara.bpel.model.TPartnerLink;
+import org.savara.bpel.model.TPick;
+import org.savara.bpel.model.TProcess;
+import org.savara.bpel.model.TScope;
+import org.savara.bpel.model.TSequence;
+import org.savara.bpel.model.TVariable;
+import org.savara.bpel.model2.*;
+import org.savara.bpel.toprotocol.*;
+import org.savara.bpel.util.InteractionUtil;
+import org.savara.bpel.util.PartnerLinkUtil;
+import org.savara.bpel.util.VariableUtil;
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.model.change.ModelChangeContext;
+import org.savara.wsdl.util.WSDLGeneratorUtil;
+import org.scribble.protocol.model.*;
+
+/**
+ * This is the model change rule for the Choice.
+ */
+public class ChoiceModelChangeRule extends AbstractBPELModelChangeRule {
+
+ /**
+ * 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof org.scribble.protocol.model.Choice && isBPELModel(model))
{
+ 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ TProcess bpelModel=getBPELModel(model);
+ org.scribble.protocol.model.Choice elem=
+ (org.scribble.protocol.model.Choice)mobj;
+ java.util.List<When> paths=elem.getWhens();
+
+ // Check if the 'If' construct is to handle responses
+ // to a preceding request being sent
+ if (InteractionPatterns.isResponseAndFaultHandler(elem)) {
+
+ if (context.getParent() instanceof TSequence) {
+ // Find fault handler
+ TSequence seq=(TSequence)context.getParent();
+ TScope scope=new TScope();
+ TFaultHandlers fh=scope.getFaultHandlers();
+
+ for (int i=0; i < paths.size(); i++) {
+ When path=paths.get(i);
+
+ if (path.getBlock().getContents().size() > 0) {
+ Activity act=path.getBlock().getContents().get(0);
+ TSequence 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);
+
+ TCatch c=new TCatch();
+ c.setFaultVariable(faultVarName);
+
+ // Find namespace prefix
+ /* TODO: Sort out namespace prefix issue
+ if (qname != null) {
+ String prefix=bpelModel.addNamespace(qname.getNamespaceURI());
+
+ if (prefix != null) {
+ mesgType = prefix+":"+qname.getLocalPart();
+ faultName = prefix+":"+faultName;
+ }
+ }
+ */
+
+ c.setFaultName(new QName(qname.getNamespaceURI(), faultName));
+ c.setFaultMessageType(qname);
+
+ // Add catch to fault handler
+ fh.getCatch().add(c);
+
+ subseq = new TSequence();
+ c.setSequence(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.getBlock().getContents().size(); j++) {
+ context.insert(model, path.getBlock().getContents().get(j), null);
+ }
+
+ context.setParent(parent);
+ }
+ }
+ } else {
+ // TODO: Error handling
+ }
+ } else if (InteractionPatterns.isSwitch(elem)) {
+ TPick act=new TPick();
+
+ if (context.getParent() instanceof TSequence) {
+ ((TSequence)context.getParent()).getActivity().add(act);
+ }
+
+ Role role=null;
+
+ if (elem.enclosingProtocol() != null) {
+ role = elem.enclosingProtocol().getRole();
+ }
+
+ for (int i=0; i < paths.size(); i++) {
+ When path=paths.get(i);
+
+ TSequence seq=new TSequence();
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=path.getBlock().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);
+
+ TOnMessage onm=new TOnMessage();
+ onm.setSequence(seq);
+
+ TPartnerLink pl=new TPartnerLink();
+ String portType=null;
+ String namespace=null;
+
+ String prevPLName=role.getName()+"To"+elem.getFromRole().getName();
+
+ //String mainPrefix=null;
+
+ Contract contract=ModelChangeUtils.getContract(context,
context.getRole().getName());
+
+ /* TODO: namespace issue
+ if (contract != null) {
+ mainPrefix = bpelModel.addNamespace(contract.getNamespace());
+ }
+ */
+
+ // Check if partner link already exists in
+ // other direction
+ TPartnerLink prev=
+ PartnerLinkUtil.getPartnerLink(bpelModel, prevPLName);
+
+ if (InteractionUtil.isRequest(path) && prev == null) {
+
+ pl.setMyRole(role.getName()+"Service");
+ //pl.setPartnerRole(interaction.getToRole().getName());
+ pl.setName(elem.getFromRole().getName()+"To"+role.getName());
+
+ String
plt=elem.getFromRole().getName()+"To"+role.getName()+"Service"+"LT";
+
+ pl.setPartnerLinkType(new QName(contract.getNamespace(), plt));
+
+ contract = ModelChangeUtils.getContract(context, role.getName());
+
+ if (contract != null && contract.getInterfaces().size() > 0) {
+ Interface intf = contract.getInterfaces().iterator().next();
+
+ portType = intf.getName();
+ namespace = intf.getNamespace();
+
+ /* TODO: namespace issue
+ String prefix = bpelModel.addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ portType = prefix+":"+portType;
+ }
+ */
+ }
+ } else {
+ pl.setMyRole(role.getName()+"Requester");
+ pl.setPartnerRole(elem.getFromRole().getName()+"Service");
+ pl.setName(role.getName()+"To"+elem.getFromRole().getName());
+
+ String
plt=role.getName()+"To"+elem.getFromRole().getName()+"Requester"+"LT";
+
+ pl.setPartnerLinkType(new QName(contract.getNamespace(), plt));
+
+ //portType = role.getName()+
+ // recv.getFromRole().getName()+"CallbackPT";
+
+ contract = ModelChangeUtils.getContract(context, elem.getFromRole().getName());
+ if (contract != null && contract.getInterfaces().size() > 0) {
+ Interface intf = contract.getInterfaces().iterator().next();
+
+ portType = intf.getName();
+ namespace = intf.getNamespace();
+
+ /* TODO: Namespace issue
+ String prefix = bpelModel.addNamespace(intf.getNamespace());
+
+ if (prefix != null) {
+ portType = prefix+":"+portType;
+ }
+ */
+ }
+ }
+
+ QName qname=null;
+ if (InteractionUtil.isRequest(path)) {
+ qname = WSDLGeneratorUtil.getRequestMessageType(contract.getNamespace(),
+ path.getMessageSignature().getOperation());
+ } else if (InteractionPatterns.isFaultResponse(path)) {
+ qname = WSDLGeneratorUtil.getFaultMessageType(contract.getNamespace(),
+ InteractionPatterns.getFaultName(path));
+ } else {
+ qname = WSDLGeneratorUtil.getResponseMessageType(contract.getNamespace(),
+ path.getMessageSignature().getOperation());
+ }
+
+ String varName=qname.getLocalPart()+"Var";
//InteractionPatterns.getVariableName(recv);
+
+ if (varName != null) {
+ onm.setVariable(varName);
+ }
+
+ // Create partner link
+ TPartnerLink other=
+ PartnerLinkUtil.getPartnerLink(bpelModel, pl.getName());
+
+ if (other == null) {
+ bpelModel.getPartnerLinks().getPartnerLink().add(pl);
+ } 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, path, bpelModel);
+ }
+
+ // Check if create instance
+ if (org.scribble.protocol.util.InteractionUtil.isInitialInteraction(elem.getModel(),
path)) {
+ act.setCreateInstance(TBoolean.YES);
+ }
+
+ // Set details on interaction
+ onm.setPartnerLink(pl.getName());
+ onm.setPortType(new QName(namespace, portType));
+
+ MessageSignature ms=path.getMessageSignature();
+ if (ms.getOperation() != null) {
+ onm.setOperation(ms.getOperation());
+ }
+
+ act.getOnMessage().add(onm);
+ }
+
+ } else {
+ TIf act=new TIf();
+
+ if (context.getParent() instanceof TSequence) {
+ ((TSequence)context.getParent()).getActivity().add(act);
+ }
+
+ for (int i=0; i < paths.size(); i++) {
+ When path=paths.get(i);
+
+ TSequence seq=new TSequence();
+
+ // Process the activities within the conversation
+ java.util.List<Activity> acts=path.getBlock().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.setSequence(seq);
+ } else if (i == elem.getPaths().size()-1) {
+ TActivityContainer construct=new TActivityContainer();
+ construct.setSequence(seq);
+
+ act.setElse(construct);
+ } else {
+ TElseif construct=new TElseif();
+
+ construct.setSequence(seq);
+
+ act.getElseif().add(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, TProcess bpelModel) {
+ TVariable var=VariableUtil.getVariable(bpelModel, varName);
+
+ if (var == null) {
+ Role role=null;
+
+ if (interaction.enclosingProtocol() != null) {
+ role = interaction.enclosingProtocol().getRole();
+ }
+
+ var = new TVariable();
+ var.setName(varName);
+
+ Role roleType=null;
+ Contract contract=null;
+
+ if (InteractionUtil.isRequest(interaction)) {
+ // TODO: How to deal with multiple to roles
+ if (interaction.getToRoles().size() > 0) {
+ roleType = interaction.getToRoles().get(0);
+ }
+ 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(qname);
+
+ bpelModel.getVariables().getVariable().add(var);
+ }
+ }
+
+ /**
+ * 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,
+ When interaction, TProcess bpelModel) {
+ TVariable var=VariableUtil.getVariable(bpelModel, varName);
+ Choice choice=(Choice)interaction.getParent();
+
+ if (var == null) {
+ Role role=null;
+
+ if (choice.enclosingProtocol() != null) {
+ role = choice.enclosingProtocol().getRole();
+ }
+
+ var = new TVariable();
+ var.setName(varName);
+
+ Role roleType=null;
+ Contract contract=null;
+
+ if (InteractionUtil.isRequest(interaction)) {
+ roleType = choice.getToRole();
+ if (roleType == null) {
+ roleType = role;
+ }
+ } else {
+ roleType = choice.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(qname);
+
+ bpelModel.getVariables().getVariable().add(var);
+ }
+ }
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionModelChangeRule.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/InteractionModelChangeRule.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionModelChangeRule.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionModelChangeRule.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,470 @@
+/*
+ * 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.savara.bpel.model.change;
+
+import javax.xml.namespace.QName;
+
+import org.savara.bpel.model.util.*;
+import org.savara.bpel.model2.*;
+import org.savara.bpel.toprotocol.*;
+import org.savara.bpel.util.InteractionUtil;
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.model.change.ModelChangeContext;
+import org.savara.wsdl.util.WSDLGeneratorUtil;
+import org.scribble.protocol.model.*;
+
+/**
+ * This is the model change rule for the Conversation Interaction.
+ */
+public class InteractionModelChangeRule 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,
+ ProtocolModel model, ModelObject mobj,
+ ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Interaction &&
+ 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ BPELLanguageModel bpelModel=(BPELLanguageModel)model;
+ Interaction interaction=(Interaction)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.enclosingProtocol() != null) {
+ role = interaction.enclosingProtocol().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)) {
+ // TODO: What about if multiple 'to' roles
+ if (interaction.getToRoles().size() >= 1) {
+ roleType = interaction.getToRoles().get(0);
+ }
+ 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.getProperties().containsKey(INTERFACE_NAME)) {
+ String intfName=(String)interaction.getProperties().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.savara.bpel.toprotocol.Variable var=
+ bpelModel.getBPELProcess().getVariable(varName);
+
+ if (var == null) {
+ var = new org.savara.bpel.toprotocol.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);
+
+ // TODO: What about if multiple 'to' roles
+ pl.setPartnerRole(interaction.getToRoles().get(0).getName()+"Requester");
+ pl.setName(role.getName()+"To"+interaction.getToRoles().get(0).getName());
+
+ String
plt=role.getName()+"To"+interaction.getToRoles().get(0).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);
+
+ // TODO: What about if multiple 'to' roles
+ pl.setMyRole(role.getName()+"Service");
+ pl.setName(interaction.getToRoles().get(0).getName()+"To"+role.getName());
+
+ String
plt=interaction.getToRoles().get(0)+"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.getProperties().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.protocol.util.InteractionUtil.isInitialInteraction(interaction.getModel(),
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,
+ ProtocolModel model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ if (fromObj instanceof Interaction &&
+ toObj instanceof Interaction && isBPELModel(model)) {
+ 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,
+ ProtocolModel model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ 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,
+ ProtocolModel model, ModelObject mobj) {
+ boolean ret=false;
+
+ if (mobj instanceof Interaction &&
+ super.isDeleteSupported(context, model, mobj)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionPatterns.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/InteractionPatterns.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionPatterns.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/InteractionPatterns.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,421 @@
+/*
+ * 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.savara.bpel.model.change;
+
+import org.savara.bpel.util.InteractionUtil;
+import org.scribble.protocol.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.protocol.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) &&
+ getRequestLabel(interaction) != null) {
+
+ if (interaction.getParent() instanceof
+ org.scribble.protocol.model.Block) {
+ org.scribble.protocol.model.Block block=
+ (org.scribble.protocol.model.Block)interaction.getParent();
+
+ int pos=block.getContents().indexOf(interaction);
+
+ if (pos != -1 && pos < block.getContents().size()-1) {
+ org.scribble.protocol.model.Activity act=
+ block.getContents().get(pos+1);
+
+ if (act instanceof org.scribble.protocol.model.Choice) {
+
+ // Need to check if each path receives a
+ // response (normal and fault)
+ org.scribble.protocol.model.Choice choice=
+ (org.scribble.protocol.model.Choice)act;
+
+ if (choice.getPaths().size() > 0) {
+ ret = true;
+ }
+
+ for (int i=0; ret &&
+ i < choice.getPaths().size(); i++) {
+
+ org.scribble.protocol.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(Choice choice) {
+ boolean ret=false;
+
+ // Obtain interaction prior to 'If'
+ if (choice.getPaths().size() > 0 &&
+ choice.getParent() instanceof
+ org.scribble.protocol.model.Block) {
+ org.scribble.protocol.model.Block block=
+ (org.scribble.protocol.model.Block)choice.getParent();
+
+ int pos=block.getContents().indexOf(choice);
+
+ if (pos != -1 && pos > 0) {
+ org.scribble.protocol.model.Activity act=
+ block.getContents().get(pos-1);
+
+ if (act instanceof Interaction &&
+ InteractionUtil.isSend((Interaction)act) &&
+ InteractionUtil.isRequest((Interaction)act) &&
+ getRequestLabel((Interaction)act) != null) {
+
+ // Check if each path has a response/fault associated
+ // with the preceding request
+ String requestLabel=getRequestLabel((Interaction)act);
+
+ java.util.List<When> paths=choice.getWhens();
+ int matched=0;
+
+ for (int i=0; i < paths.size(); i++) {
+ if (paths.get(i).getBlock().getContents().size() > 0) {
+ Interaction in=getPickPathInteraction(paths.get(i).getBlock());
+
+ if (in != null &&
+ InteractionUtil.isResponse(in) &&
+ getReplyToLabel(in).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.protocol.model.Activity sub=
+ path.getContents().get(0);
+
+ // Check if scope
+ if (sub instanceof Run) {
+ Protocol defn=((Run)sub).getProtocol();
+ org.scribble.protocol.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.protocol.model.Behaviour) {
+ b = (org.scribble.protocol.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 Choice &&
+ InteractionPatterns.isSwitch((Choice)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.protocol.model.Protocol &&
+ path.getParent().getParent() instanceof Block &&
+ path.getParent().getParent().getParent() instanceof
+ org.scribble.protocol.model.Protocol) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public static boolean isSwitch(Choice choice) {
+ boolean ret=false;
+
+ // For a choice to be considered a 'switch', it only needs
+ // to be a receiver
+ if (choice.getFromRole() != null && choice.getToRole() == null) {
+ ret = true;
+ }
+
+ /*
+ if (choice.getPaths().size() > 0) {
+ java.util.List<When> paths=choice.getWhens();
+ 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 &&
+ getReplyToLabel(interaction) != null) {
+
+ // Find if contained in 'if' path
+ if (interaction.getParent() instanceof Block &&
+ interaction.getParent().getParent() instanceof Choice) {
+
+ Choice choice=(Choice)interaction.getParent().getParent();
+
+ // Obtain interaction prior to 'If'
+ if (choice.getParent() instanceof
+ org.scribble.protocol.model.Block) {
+ org.scribble.protocol.model.Block block=
+ (org.scribble.protocol.model.Block)choice.getParent();
+
+ int pos=block.getContents().indexOf(choice);
+
+ if (pos != -1 && pos > 0) {
+ org.scribble.protocol.model.Activity act=
+ block.getContents().get(pos-1);
+
+ if (act instanceof Interaction &&
+ InteractionUtil.isRequest((Interaction)act) &&
+ getRequestLabel((Interaction)act) != null &&
+ getReplyToLabel(interaction).equals(
+ getRequestLabel((Interaction)act))) {
+ 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().getProperties().
+ keySet().contains(FAULT_NAME)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public static boolean isFaultResponse(When interaction) {
+ boolean ret=false;
+
+ if (InteractionUtil.isRequest(interaction) == false &&
+ interaction.getMessageSignature().getProperties().
+ keySet().contains(FAULT_NAME)) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public static String getFaultName(Interaction interaction) {
+ return((String)interaction.
+ getMessageSignature().getProperties().get(FAULT_NAME));
+ }
+
+ public static String getFaultName(When interaction) {
+ return((String)interaction.
+ getMessageSignature().getProperties().get(FAULT_NAME));
+ }
+
+ public static String getMessageTypeLocalPart(Interaction interaction) {
+ return((String)interaction.
+ getMessageSignature().getProperties().get(MESSAGE_TYPE_LOCALPART));
+ }
+
+ public static String getMessageTypeNameSpace(Interaction interaction) {
+ return((String)interaction.
+ getMessageSignature().getProperties().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) &&
+ getReplyToLabel(resp).equals(
+ getRequestLabel(req))) {
+ ret = true;
+ }
+
+ return(ret);
+ }
+
+ public static String getRequestLabel(Interaction interaction) {
+ return((String)interaction.getProperties().get("RequestLabel"));
+ }
+
+ public static String getReplyToLabel(Interaction interaction) {
+ return((String)interaction.getProperties().get("ReplyToLabel"));
+ }
+
+ public static String getRequestLabel(When interaction) {
+ return((String)interaction.getProperties().get("RequestLabel"));
+ }
+
+ public static String getReplyToLabel(When interaction) {
+ return((String)interaction.getProperties().get("ReplyToLabel"));
+ }
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/ModelChangeUtils.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ModelChangeUtils.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,244 @@
+/*
+ * 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.savara.bpel.model.change;
+
+import org.savara.contract.model.Contract;
+import org.savara.model.change.ModelChangeContext;
+import org.scribble.protocol.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, Protocol 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.getRole() != null && root) {
+ addRoleContract(conv.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 Protocol conv) {
+ final java.util.List<Role> roles=new java.util.Vector<Role>();
+
+ conv.visit(new AbstractModelObjectVisitor() {
+
+ public boolean process(ModelObject obj) {
+ boolean ret=true;
+
+ if (obj instanceof RoleList) {
+ roles.addAll(((RoleList)obj).getRoles());
+ } else if (obj instanceof Protocol &&
+ 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.getProperties().containsKey(Contract.class.getName()))
{
+ contracts.put(role.getName(),
+ (Contract)role.getProperties().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.getProperties().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, Protocol 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.getRole() != null && root) {
+ removeRoleContract(conv.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,
+ Run 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.enclosingProtocol().getRole() != null &&
+ run.getProtocol().getRole() != null) {
+ Contract c=contracts.remove(run.enclosingProtocol().getRole().getName());
+
+ if (c != null) {
+ contracts.put(run.getProtocol().getRole().getName(), c);
+ }
+ }
+
+ /* GPB: NEED TO CONSIDER HOW ROLES/CONTRACTS WILL BE BOUND USING
+ * POSITIONAL INFO.
+ *
+ 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,
+ Run 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.enclosingProtocol().getRole() != null &&
+ run.getProtocol().getRole() != null) {
+ Contract c=contracts.remove(run.getProtocol().getRole().getName());
+
+ if (c != null) {
+ contracts.put(run.enclosingProtocol().getRole().getName(), c);
+ }
+ }
+
+ /* GPB: NEED TO CONSIDER HOW ROLES/CONTRACTS WILL BE BOUND USING
+ * POSITIONAL INFO.
+ *
+ 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);
+ }
+ }
+ }
+ */
+ }
+ }
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelChangeRule.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/ProtocolModelChangeRule.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelChangeRule.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelChangeRule.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,246 @@
+/*
+ * 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.savara.bpel.model.change;
+
+import org.savara.bpel.model.TImport;
+import org.savara.bpel.model.TProcess;
+import org.savara.bpel.model.TScope;
+import org.savara.bpel.model.TSequence;
+import org.savara.bpel.model.generator.GeneratorUtil;
+import org.savara.bpel.model2.*;
+import org.savara.bpel.toprotocol.*;
+import org.savara.contract.model.Contract;
+import org.savara.contract.model.Interface;
+import org.savara.model.change.AbstractModelChangeRule;
+import org.savara.model.change.ModelChangeContext;
+import org.scribble.protocol.model.*;
+
+/**
+ * This is the model change rule for the Conversation.
+ */
+public class ProtocolModelChangeRule extends AbstractBPELModelChangeRule {
+
+ //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
+ */
+ public boolean isInsertSupported(ModelChangeContext context,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Protocol && isBPELModel(model)) {
+ 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
+ */
+ public boolean insert(ModelChangeContext context,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ TProcess bpelModel=getBPELModel(model);
+ Protocol conv=(Protocol)mobj;
+ String roleNamespace=null;
+
+ TSequence seq=new TSequence();
+
+ // Check if root conversation
+ if (conv.getParent() instanceof ProtocolModel) {
+
+ // Set the name of the process
+ bpelModel.setName(conv.getName()+"_"+
+ conv.getRole().getName());
+
+ // Get contract
+ Contract contract=ModelChangeUtils.getContract(context, conv.getRole().getName());
+
+ if (contract != null) {
+ roleNamespace = contract.getNamespace();
+
+ // Set namespace
+ bpelModel.setTargetNamespace(contract.getNamespace());
+
+ /** GPB: NEED TO ESTABLISH NAMESPACE PREFIXES
+ *
+ *
+ // Add other namespaces
+ for (org.savara.contract.model.Namespace ns : contract.getNamespaces()) {
+ bpelModel.initNamespace(ns.getURI(), ns.getPrefix());
+ }
+ */
+ }
+
+ /*
+ String namespace="** GPB: NEED TO GET NAMESPACE FROM PROTOCOL MODEL **";
+
+ 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
+ TImport imp=new TImport();
+ imp.setLocation(bpelModel.getName()+"Artifacts.wsdl");
+ imp.setNamespace(roleNamespace);
+
imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
+
+ bpelModel.getImport().add(imp);
+
+ // Add sequence to model
+ bpelModel.setSequence(seq);
+
+ } else if (context.getParent() instanceof TSequence) {
+
+ // Create a scope
+ TScope scope=new TScope();
+
+ ((TSequence)context.getParent()).getActivity().add(scope);
+
+ // 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.setSequence(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, TProcess bpelModel,
+ Protocol conv, Role role) {
+ if (role.getProperties().containsKey(Contract.class.getName())) {
+ Contract contract=(Contract)role.getProperties().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.getName(), "");
+
+ TImport imp=new TImport();
+
+ imp.setLocation(fileName);
+ imp.setNamespace(contract.getNamespace());
+
imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
+
+ bpelModel.getImport().add(imp);
+ }
+ }
+ }
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelModelChangeRule.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/ProtocolModelModelChangeRule.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelModelChangeRule.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/ProtocolModelModelChangeRule.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,95 @@
+/*
+ * 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.savara.bpel.model.change;
+
+import org.savara.model.change.ModelChangeContext;
+import org.scribble.protocol.model.*;
+
+/**
+ * This is the model change rule for the Language Model to
+ * Conversation Model.
+ */
+public class ProtocolModelModelChangeRule extends AbstractBPELModelChangeRule {
+
+ /**
+ * 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof ProtocolModel && isBPELModel(model)) {
+ 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ ProtocolModel cm=(ProtocolModel)mobj;
+
+ if (cm.getProtocol() != null) {
+ ModelChangeUtils.addContracts(context, cm.getProtocol(), true);
+
+ context.insert(model, cm.getProtocol(), null);
+
+ ModelChangeUtils.removeContracts(context, cm.getProtocol(), true);
+ }
+
+ return(true);
+ }
+
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RepeatModelChangeRule.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/RepeatModelChangeRule.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RepeatModelChangeRule.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RepeatModelChangeRule.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -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.savara.bpel.model.change;
+
+import org.savara.bpel.model.TSequence;
+import org.savara.bpel.model.TWhile;
+import org.savara.model.change.ModelChangeContext;
+import org.scribble.protocol.model.*;
+
+/**
+ * This is the model change rule for the While.
+ */
+public class RepeatModelChangeRule extends AbstractBPELModelChangeRule {
+
+ /**
+ * 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof org.scribble.protocol.model.Repeat && isBPELModel(model))
{
+ 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ //DefaultBPELLanguageModel bpelModel=(DefaultBPELLanguageModel)model;
+ org.scribble.protocol.model.Repeat elem=
+ (org.scribble.protocol.model.Repeat)mobj;
+
+ TWhile act=new TWhile();
+
+ TSequence seq=new TSequence();
+
+ if (context.getParent() instanceof TSequence) {
+ ((TSequence)context.getParent()).getActivity().add(act);
+ }
+
+ // 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.setSequence(seq);
+
+ // Reset old parent
+ context.setParent(parent);
+
+ return(true);
+ }
+
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/change/RunModelChangeRule.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/change/RunModelChangeRule.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,99 @@
+/*
+ * 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.savara.bpel.model.change;
+
+import org.savara.model.change.ModelChangeContext;
+import org.scribble.protocol.model.*;
+
+/**
+ * This is the model change rule for the Run.
+ */
+public class RunModelChangeRule extends AbstractBPELModelChangeRule {
+
+ /**
+ * 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ if (mobj instanceof Run && isBPELModel(model)) {
+ 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,
+ ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ Run elem=(Run)mobj;
+
+ if (elem.getProtocol() != null) {
+
+ ModelChangeUtils.pushRoleContractMapping(context, elem);
+
+ ModelChangeUtils.addContracts(context, elem.getProtocol(), false);
+
+ context.insert(model, elem.getProtocol(), ref);
+
+ ModelChangeUtils.removeContracts(context, elem.getProtocol(), false);
+
+ ModelChangeUtils.popRoleContractMapping(context, elem);
+ }
+
+ return(true);
+ }
+
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/generator
(from rev 502,
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator)
Modified:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/generator/GeneratorUtil.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/generator/GeneratorUtil.java 2010-12-10
22:38:20 UTC (rev 502)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/generator/GeneratorUtil.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -15,7 +15,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
-package org.savara.bpel.generator;
+package org.savara.bpel.model.generator;
import org.scribble.protocol.model.Role;
Added:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/generator/ProtocolToBPELModelGenerator.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/generator/ProtocolToBPELModelGenerator.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/model/generator/ProtocolToBPELModelGenerator.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 24 Jul 2008 : Initial version created by gary
+ */
+package org.savara.bpel.model.generator;
+
+import org.savara.bpel.BPELDefinitions;
+import org.savara.bpel.model.TProcess;
+import org.savara.bpel.model.change.BPELModelChangeContext;
+import org.savara.model.generator.ModelGenerator;
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.model.*;
+
+/**
+ * This class represents the Protocol to BPEL implementation of the model
+ * generator interface.
+ */
+public class ProtocolToBPELModelGenerator implements ModelGenerator {
+
+ public boolean isSupported(String sourceType, String targetType) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Object generate(Object source, Journal journal) {
+ BPELModelChangeContext context=
+ new BPELModelChangeContext();
+ ProtocolModel pm=(ProtocolModel)source;
+
+ // Create BPEL model
+ TProcess bpel=new TProcess();
+
+ context.setParent(bpel);
+
+ ProtocolModel bpelModel=new ProtocolModel();
+ bpelModel.getProperties().put(BPELDefinitions.BPEL_MODEL_PROPERTY, bpel);
+
+ context.insert(bpelModel, pm, null);
+
+ return(bpel);
+ }
+
+}
Modified:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/InteractionUtil.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/InteractionUtil.java 2010-12-16
14:46:01 UTC (rev 505)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/main/java/org/savara/bpel/util/InteractionUtil.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -17,7 +17,7 @@
*/
package org.savara.bpel.util;
-import org.savara.bpel.change.InteractionPatterns;
+import org.savara.bpel.model.change.InteractionPatterns;
import org.savara.bpel.toprotocol.BPELActivity;
import org.savara.bpel.toprotocol.Invoke;
import org.savara.bpel.toprotocol.Sequence;
Modified:
branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java 2010-12-16
14:46:01 UTC (rev 505)
+++
branches/experimental/2.0.x/bundles/org.savara.bpel/src/test/java/org/savara/bpel/model/change/ModelChangeUtilsTest.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -35,7 +35,7 @@
private static final String MY_OTHER_LOCATED_ROLE = "MyOtherLocatedRole";
public void testInitialiseContracts() {
- ModelChangeContext context=new DefaultModelChangeContext(null, null);
+ ModelChangeContext context=new BPELModelChangeContext(null, null);
Conversation conv=new Conversation();
LocatedName ln=new LocatedName();
@@ -62,7 +62,7 @@
}
public void testInitialiseContractsTwice() {
- ModelChangeContext context=new DefaultModelChangeContext(null, null);
+ ModelChangeContext context=new BPELModelChangeContext(null, null);
Conversation conv=new Conversation();
LocatedName ln=new LocatedName();
@@ -112,7 +112,7 @@
}
public void testPushRoleContractMapping() {
- ModelChangeContext context=new DefaultModelChangeContext(null, null);
+ ModelChangeContext context=new BPELModelChangeContext(null, null);
Conversation conv=new Conversation();
LocatedName ln=new LocatedName();
@@ -186,7 +186,7 @@
}
public void testPopRoleContractMapping() {
- ModelChangeContext context=new DefaultModelChangeContext(null, null);
+ ModelChangeContext context=new BPELModelChangeContext(null, null);
Conversation conv=new Conversation();
LocatedName ln=new LocatedName();
Modified: branches/experimental/2.0.x/bundles/org.savara.core/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental/2.0.x/bundles/org.savara.core/META-INF/MANIFEST.MF 2010-12-16
14:46:01 UTC (rev 505)
+++ branches/experimental/2.0.x/bundles/org.savara.core/META-INF/MANIFEST.MF 2010-12-16
16:32:57 UTC (rev 506)
@@ -9,5 +9,5 @@
Import-Package: org.osgi.framework;version="1.3.0",
org.scribble.protocol.model
Require-Bundle: org.scribble.common
-Export-Package: org.savara.change,
+Export-Package: org.savara.model.change,
org.savara.util
Copied:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change)
Copied:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/AbstractModelChangeContext.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/DefaultModelChangeContext.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/AbstractModelChangeContext.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/AbstractModelChangeContext.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 24 Jul 2008 : Initial version created by gary
+ */
+package org.savara.model.change;
+
+import org.scribble.protocol.model.*;
+
+/**
+ * This class provides a default implementation for the model
+ * change context interface.
+ */
+public abstract class AbstractModelChangeContext implements ModelChangeContext {
+
+ private Object m_parent=null;
+ private java.util.Map<String,Object> m_properties=new
java.util.HashMap<String,Object>();
+
+ /**
+ * This is the constructor for the model change context.
+ *
+ * @param role The role associated with the model
+ */
+ public AbstractModelChangeContext() {
+ }
+
+ /**
+ * This method returns a list of model change rules appropriate
+ * for the notation being changed.
+ *
+ * @return The list of model change rules
+ */
+ public abstract java.util.List<ModelChangeRule> getRules();
+
+ /**
+ * This method returns the current parent component.
+ *
+ * @return The parent
+ */
+ public Object getParent() {
+ return(m_parent);
+ }
+
+ /**
+ * This method sets the new parent component.
+ *
+ * @param parent The parent
+ */
+ public void setParent(Object parent) {
+ m_parent = parent;
+ }
+
+ /**
+ * 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.
+ *
+ * @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
+ */
+ public boolean insert(ProtocolModel model, ModelObject mobj, ModelObject ref) {
+ boolean ret=false;
+
+ java.util.List<ModelChangeRule> rules=getRules();
+
+ for (int i=0; ret == false && i < rules.size(); i++) {
+ if (rules.get(i).isInsertSupported(this, model, mobj, ref)) {
+ ret = rules.get(i).insert(this, model,
+ mobj, ref);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method removes an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @param model The model being changed
+ * @param mobj The model object details to be deleted
+ * @param position The position, where relevant
+ * @return Whether the change has been applied
+ */
+ public boolean delete(ProtocolModel model, ModelObject mobj) {
+ boolean ret=false;
+
+ java.util.List<ModelChangeRule> rules=getRules();
+
+ for (int i=0; ret == false && i < rules.size(); i++) {
+ if (rules.get(i).isDeleteSupported(this, model, mobj)) {
+ ret = rules.get(i).delete(this, model, mobj);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method modifies an existing model object, within a
+ * parent model object, with the details supplied in
+ * another model object.
+ *
+ * @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
+ */
+ public boolean update(ProtocolModel model, ModelObject fromObj, ModelObject toObj) {
+ boolean ret=false;
+
+ java.util.List<ModelChangeRule> rules=getRules();
+
+ for (int i=0; ret == false && i < rules.size(); i++) {
+ if (rules.get(i).isUpdateSupported(this, model, fromObj, toObj)) {
+ ret = rules.get(i).update(this, model,
+ fromObj, toObj);
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method returns a set of properties used during model change
+ * processing.
+ *
+ * @return The properties
+ */
+ public java.util.Map<String,Object> getProperties() {
+ return(m_properties);
+ }
+}
Modified:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/AbstractModelChangeRule.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/AbstractModelChangeRule.java 2010-12-16
14:37:55 UTC (rev 504)
+++
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/AbstractModelChangeRule.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -17,7 +17,7 @@
* Change History:
* 28 Jul 2008 : Initial version created by gary
*/
-package org.savara.change;
+package org.savara.model.change;
import org.scribble.protocol.model.*;
Deleted:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/DefaultModelChangeContext.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/DefaultModelChangeContext.java 2010-12-16
14:37:55 UTC (rev 504)
+++
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/DefaultModelChangeContext.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -1,195 +0,0 @@
-/*
- * Copyright 2005-8 Pi4 Technologies Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- * Change History:
- * 24 Jul 2008 : Initial version created by gary
- */
-package org.savara.change;
-
-import org.scribble.protocol.model.*;
-
-/**
- * This class provides a default implementation for the model
- * change context interface.
- */
-public class DefaultModelChangeContext implements ModelChangeContext {
-
- /**
- * This is the constructor for the model change context.
- *
- * @param ref The reference for the model being changed
- * @param role The role associated with the model
- */
- public DefaultModelChangeContext(/*ModelReference ref,*/ Role role) {
-
- //m_reference = ref;
- m_role = role;
-
- // TODO: Need to initialise the model change rules
- // possibly make this class abstract with derived classes
- // providing the list of rules
-
- /*
- if (ref != null) {
- // Obtain the relevant rules
- java.util.List<Object> rules=
- org.scribble.extensions.RegistryFactory.getRegistry().
- getExtensions(ModelChangeRule.class,
- m_reference.getNotation());
-
- // Transfer to typed list
- for (int i=0; i < rules.size(); i++) {
- if (rules.get(i) instanceof ModelChangeRule) {
- m_rules.add((ModelChangeRule)rules.get(i));
- }
- }
- }
- */
- }
-
- /**
- * This method returns a list of model change rules appropriate
- * for the notation being changed.
- *
- * @return The list of model change rules
- */
- public java.util.List<ModelChangeRule> getRules() {
- return(m_rules);
- }
-
- /**
- * This method returns the role associated with the local
- * model.
- *
- * @return The role
- */
- public Role getRole() {
- return(m_role);
- }
-
- /**
- * This method returns the current parent component.
- *
- * @return The parent
- */
- public Object getParent() {
- return(m_parent);
- }
-
- /**
- * This method sets the new parent component.
- *
- * @param parent The parent
- */
- public void setParent(Object parent) {
- m_parent = parent;
- }
-
- /**
- * 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.
- *
- * @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
- */
- public boolean insert(ProtocolModel model, ModelObject mobj, ModelObject ref) {
- boolean ret=false;
-
- for (int i=0; ret == false && i < m_rules.size(); i++) {
- if (m_rules.get(i).isInsertSupported(this, model, mobj, ref)) {
- ret = m_rules.get(i).insert(this, model,
- mobj, ref);
- }
- }
-
- return(ret);
- }
-
- /**
- * This method removes an existing model object, within a
- * parent model object, with the details supplied in
- * another model object.
- *
- * @param model The model being changed
- * @param mobj The model object details to be deleted
- * @param position The position, where relevant
- * @return Whether the change has been applied
- */
- public boolean delete(ProtocolModel model, ModelObject mobj) {
- boolean ret=false;
-
- for (int i=0; ret == false && i < m_rules.size(); i++) {
- if (m_rules.get(i).isDeleteSupported(this, model, mobj)) {
- ret = m_rules.get(i).delete(this, model, mobj);
- }
- }
-
- return(ret);
- }
-
- /**
- * This method modifies an existing model object, within a
- * parent model object, with the details supplied in
- * another model object.
- *
- * @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
- */
- public boolean update(ProtocolModel model, ModelObject fromObj, ModelObject toObj) {
- boolean ret=false;
-
- for (int i=0; ret == false && i < m_rules.size(); i++) {
- if (m_rules.get(i).isUpdateSupported(this, model, fromObj, toObj)) {
- ret = m_rules.get(i).update(this, model,
- fromObj, toObj);
- }
- }
-
- return(ret);
- }
-
- /**
- * This method returns a set of properties used during model change
- * processing.
- *
- * @return The properties
- */
- public java.util.Map<String,Object> getProperties() {
- return(m_properties);
- }
-
- //private ModelReference m_reference=null;
- private Role m_role=null;
- private Object m_parent=null;
- private java.util.List<ModelChangeRule> m_rules=new
java.util.Vector<ModelChangeRule>();
- private java.util.Map<String,Object> m_properties=new
java.util.HashMap<String,Object>();
-}
Deleted:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/DefaultModelGenerator.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/DefaultModelGenerator.java 2010-12-16
14:37:55 UTC (rev 504)
+++
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/DefaultModelGenerator.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -1,51 +0,0 @@
-/*
- * Copyright 2005-8 Pi4 Technologies Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- * Change History:
- * 24 Jul 2008 : Initial version created by gary
- */
-package org.savara.change;
-
-import org.scribble.protocol.model.*;
-
-/**
- * This class represents a default implementation of the model
- * generator interface.
- */
-public class DefaultModelGenerator implements ModelGenerator {
-
- /**
- * This method generates the contents of the target
- * model using information in the source model. This
- * mechanism is used to create a new instance of the
- * model, but with a specific underlying representation.
- *
- * @param targetRef The target model's reference
- * @param role The role associated with the model
- * @param target The model being generated
- * @param source The reference model
- */
- public void generate(ModelReference targetRef, Role role,
- ProtocolModel target, ProtocolModel source) {
-
- DefaultModelChangeContext context=
- new DefaultModelChangeContext(targetRef, role);
- context.setParent(target);
-
- context.insert(target, source, null);
- }
-
-}
Modified:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/ModelChangeContext.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/ModelChangeContext.java 2010-12-16
14:37:55 UTC (rev 504)
+++
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/ModelChangeContext.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -17,7 +17,7 @@
* Change History:
* 24 Jul 2008 : Initial version created by gary
*/
-package org.savara.change;
+package org.savara.model.change;
import org.scribble.protocol.model.*;
@@ -28,14 +28,6 @@
public interface ModelChangeContext {
/**
- * This method returns the role associated with the local
- * model.
- *
- * @return The role
- */
- public Role getRole();
-
- /**
* This method returns the current parent component.
*
* @return The parent
Modified:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/ModelChangeRule.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/ModelChangeRule.java 2010-12-16
14:37:55 UTC (rev 504)
+++
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/ModelChangeRule.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -17,7 +17,7 @@
* Change History:
* 23 Jul 2008 : Initial version created by gary
*/
-package org.savara.change;
+package org.savara.model.change;
import org.scribble.protocol.model.*;
Deleted:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/ModelGenerator.java
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/ModelGenerator.java 2010-12-16
14:37:55 UTC (rev 504)
+++
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/change/ModelGenerator.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -1,43 +0,0 @@
-/*
- * Copyright 2005-8 Pi4 Technologies Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *
http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- * Change History:
- * 24 Jul 2008 : Initial version created by gary
- */
-package org.savara.change;
-
-import org.scribble.protocol.model.*;
-
-/**
- * This interface represents a model generator.
- */
-public interface ModelGenerator {
-
- /**
- * This method generates the contents of the target
- * model using information in the source model. This
- * mechanism is used to create a new instance of the
- * model, but with a specific underlying representation.
- *
- * @param targetRef The target model's reference
- * @param role The role associated with the model
- * @param target The model being generated
- * @param source The reference model
- */
- public void generate(ModelReference targetRef, Role role,
- ProtocolModel target, ProtocolModel source);
-
-}
Copied:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/generator/DefaultModelGenerator.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/DefaultModelGenerator.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/generator/DefaultModelGenerator.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/generator/DefaultModelGenerator.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 24 Jul 2008 : Initial version created by gary
+ */
+package org.savara.model.generator;
+
+import org.savara.model.change.AbstractModelChangeContext;
+import org.scribble.protocol.model.*;
+
+/**
+ * This class represents a default implementation of the model
+ * generator interface.
+ */
+public class DefaultModelGenerator implements ModelGenerator {
+
+ /**
+ * This method generates the contents of the target
+ * model using information in the source model. This
+ * mechanism is used to create a new instance of the
+ * model, but with a specific underlying representation.
+ *
+ * @param targetRef The target model's reference
+ * @param role The role associated with the model
+ * @param target The model being generated
+ * @param source The reference model
+ */
+ public void generate(ModelReference targetRef, Role role,
+ ProtocolModel target, ProtocolModel source) {
+
+ AbstractModelChangeContext context=
+ new AbstractModelChangeContext(targetRef, role);
+ context.setParent(target);
+
+ context.insert(target, source, null);
+ }
+
+}
Copied:
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/generator/ModelGenerator.java
(from rev 504,
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/change/ModelGenerator.java)
===================================================================
---
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/generator/ModelGenerator.java
(rev 0)
+++
branches/experimental/2.0.x/bundles/org.savara.core/src/main/java/org/savara/model/generator/ModelGenerator.java 2010-12-16
16:32:57 UTC (rev 506)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2005-8 Pi4 Technologies Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * Change History:
+ * 24 Jul 2008 : Initial version created by gary
+ */
+package org.savara.model.generator;
+
+import org.scribble.common.logging.Journal;
+import org.scribble.protocol.model.*;
+
+/**
+ * This interface represents a model generator.
+ */
+public interface ModelGenerator {
+
+ /**
+ * This method determines whether the generator is appropriate for
+ * the specified source and target types.
+ *
+ * @param sourceType The source type
+ * @param targetType The target type
+ * @return Whether the specified types are supported
+ */
+ public boolean isSupported(String sourceType, String targetType);
+
+ /**
+ * This method generates the contents of the target
+ * model using information in the source model.
+ *
+ * @param targetRef The target model's reference
+ * @param role The role associated with the model
+ * @param target The model being generated
+ * @param source The reference model
+ */
+ public Object generate(Object source, Journal journal);
+
+}
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.bpel
___________________________________________________________________
Name: svn:ignore
+ bin
Property changes on: branches/experimental/2.0.x/tools/plugins/org.savara.tools.wsdl
___________________________________________________________________
Name: svn:ignore
+ classes