[savara-commits] savara SVN: r482 - in trunk/tools/plugins: org.jboss.savara.pi4soa.cdm and 14 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Nov 18 09:07:11 EST 2010


Author: objectiser
Date: 2010-11-18 09:07:09 -0500 (Thu, 18 Nov 2010)
New Revision: 482

Added:
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.classpath
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.project
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/Copyright.txt
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/build.properties
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/pom.xml
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/CDMDefinitions.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/CDMNotation.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/Activator.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMModelParserRule.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMTokenizer.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterContext.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRule.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/
   trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java
Log:
Re-commit the pi4soa cdm plugin.

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.classpath
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.classpath	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.classpath	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src/java"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.project
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.project	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/.project	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.jboss.savara.pi4soa.cdm</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/Copyright.txt
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/Copyright.txt	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/Copyright.txt	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,17 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ */

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/META-INF/MANIFEST.MF	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss SAVARA pi4soa CDM
+Bundle-SymbolicName: org.jboss.savara.pi4soa.cdm
+Bundle-Version: 1.2.0.qualifier
+Bundle-Activator: org.jboss.savara.pi4soa.cdm.osgi.Activator
+Bundle-Vendor: www.jboss.org
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: org.osgi.framework;version="1.3.0"
+Require-Bundle: org.pi4soa.cdl,
+ org.pi4soa.common,
+ org.scribble.core;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.model;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.conversation.parser;bundle-version="[1.0.0,2.0.0)",
+ org.eclipse.ui;resolution:=optional,
+ org.eclipse.core.resources;resolution:=optional,
+ org.eclipse.core.runtime;resolution:=optional,
+ org.pi4soa.designer;resolution:=optional,
+ org.eclipse.ui.views.properties.tabbed;resolution:=optional,
+ org.scribble.expression.xpath;bundle-version="[1.0.0,2.0.0)",
+ org.scribble.eclipse;bundle-version="[1.0.0,2.0.0)";resolution:=optional,
+ org.jboss.savara.contract.model
+Scribble-Extensions: org.jboss.savara.pi4soa.cdm.parser.CDMTokenizer,
+  org.jboss.savara.pi4soa.cdm.parser.CDMModelParserRule,
+  org.jboss.savara.pi4soa.cdm.model.CDMNotation,
+  org.jboss.savara.pi4soa.cdm.model.SCNNotation,
+  org.jboss.savara.pi4soa.cdm.validation.TypeReferenceValidationRule,
+  org.jboss.savara.pi4soa.cdm.editor.CDMEditorManager,
+  org.jboss.savara.pi4soa.cdm.editor.SCNEditorManager
+Export-Package: org.jboss.savara.pi4soa.cdm.model,
+ org.jboss.savara.pi4soa.cdm.parser

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/build.properties
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/build.properties	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/build.properties	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,4 @@
+source.. = src/java/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/pom.xml
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/pom.xml	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/pom.xml	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,26 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.jboss.savara.tools</groupId>
+	<artifactId>org.jboss.savara.pi4soa.cdm</artifactId> 
+	<version>1.2.0-SNAPSHOT</version>
+	<packaging>eclipse-plugin</packaging>
+	<name>Savara::Tools::Plugins::Pi4SOACDM</name>
+
+	<parent>
+		<groupId>org.jboss.savara.tools</groupId>
+		<artifactId>plugins</artifactId>
+		<version>1.2.0-SNAPSHOT</version>
+	</parent>
+  
+<!--
+	<dependencies>
+		<dependency>
+			<groupId></groupId>
+			<artifactId></artifactId>
+			<version></version>
+		</dependency>
+	</dependencies>
+-->
+
+</project>

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/CDMDefinitions.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/CDMDefinitions.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/CDMDefinitions.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,30 @@
+/*
+ * 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:
+ * 17 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm;
+
+/**
+ * This class provides common definitions used in the Scribble
+ * transformation of the CDM file.
+ */
+public class CDMDefinitions {
+
+	public static final String CDM_NOTATION="cdm";
+	
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/CDMEditorManager.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,114 @@
+/*
+ * 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:
+ * 19 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.editor;
+
+import org.eclipse.emf.ecore.EValidator;
+import org.jboss.savara.pi4soa.cdm.model.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the CDM designer's implementation of the EditorManager
+ * interface.
+ */
+ at RegistryInfo(extension=EditorManager.class,notation=CDMNotation.NOTATION_CODE) //preference=10,
+public class CDMEditorManager extends AbstractEditorManager {
+
+	/**
+	 * This method focuses the editor on the specified source,
+	 * identified by the model reference and source reference.
+	 * 
+	 * @param mref The model reference
+	 * @param sref The component source reference
+	 * @param prop Additional properties
+	 */
+	public void focus(ModelReference mref, SourceRef sref,
+					java.util.Map<String,Object> props) {
+		String uri=null;
+		org.eclipse.core.resources.IFile file=
+			org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+	
+		if (file == null || file.exists() == false) {
+			file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+		}
+	
+		if (file != null && file.exists()) {
+			uri = file.getFullPath().toPortableString();
+		}
+		
+		if (uri != null) {
+			org.eclipse.ui.IWorkbenchPage page=
+						org.eclipse.ui.PlatformUI.getWorkbench().
+							getActiveWorkbenchWindow().getActivePage();
+			
+			org.eclipse.core.resources.IResource res=
+				org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+			
+			if (res instanceof org.eclipse.core.resources.IFile) {
+				org.eclipse.ui.part.FileEditorInput input=
+						new org.eclipse.ui.part.FileEditorInput(
+								(org.eclipse.core.resources.IFile)res);
+			
+				try {
+					org.eclipse.ui.IEditorPart part=page.openEditor(input,
+								"org.pi4soa.designer.Pi4SOADesignerID");
+					
+					if (part instanceof org.pi4soa.designer.editor.ChoreographyDescriptionEditor) {
+						org.pi4soa.designer.editor.ChoreographyDescriptionEditor editor=
+							(org.pi4soa.designer.editor.ChoreographyDescriptionEditor)part;
+						
+						/* Other approach using marker - can be used if editor does not
+						 * provide alternative way to focus on component.
+						org.eclipse.core.resources.IMarker marker=res.createMarker(EValidator.MARKER);
+						marker.setAttribute(EValidator.URI_ATTRIBUTE, ref.getComponentURI());
+						editor.gotoMarker(marker);
+						marker.delete();
+						*/
+						
+						editor.showComponent(sref.getComponentURI());
+					}
+					
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+	
+	/**
+	 * This method enriches the set of properties required
+	 * by the editor, using the properties associated with
+	 * the model issue.
+	 * 
+	 * @param issue The model issue
+	 */
+	@Override
+	public void enrich(ModelIssue issue) {
+		
+		if (issue.getModelObject() != null) {
+			// Set the EMF URI attribute
+			issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+					issue.getModelObject().getSource().getComponentURI());
+		}
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/editor/SCNEditorManager.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,114 @@
+/*
+ * 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:
+ * 19 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.editor;
+
+import org.eclipse.emf.ecore.EValidator;
+import org.jboss.savara.pi4soa.cdm.model.*;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.model.SourceRef;
+import org.scribble.model.admin.ModelIssue;
+import org.scribble.editor.*;
+
+/**
+ * This is the CDM designer's implementation of the EditorManager
+ * interface.
+ */
+ at RegistryInfo(extension=EditorManager.class,notation=SCNNotation.NOTATION_CODE) //preference=10,
+public class SCNEditorManager extends AbstractEditorManager {
+
+	/**
+	 * This method focuses the editor on the specified source,
+	 * identified by the model reference and source reference.
+	 * 
+	 * @param mref The model reference
+	 * @param sref The component source reference
+	 * @param prop Additional properties
+	 */
+	public void focus(ModelReference mref, SourceRef sref,
+					java.util.Map<String,Object> props) {
+		String uri=null;
+		org.eclipse.core.resources.IFile file=
+			org.scribble.eclipse.model.admin.OSGIModelRepository.getFile(mref);
+	
+		if (file == null || file.exists() == false) {
+			file = org.scribble.eclipse.model.admin.OSGIModelRepository.getGlobalFile(mref);
+		}
+	
+		if (file != null && file.exists()) {
+			uri = file.getFullPath().toPortableString();
+		}
+		
+		if (uri != null) {
+			org.eclipse.ui.IWorkbenchPage page=
+						org.eclipse.ui.PlatformUI.getWorkbench().
+							getActiveWorkbenchWindow().getActivePage();
+			
+			org.eclipse.core.resources.IResource res=
+				org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().findMember(uri);
+			
+			if (res instanceof org.eclipse.core.resources.IFile) {
+				org.eclipse.ui.part.FileEditorInput input=
+						new org.eclipse.ui.part.FileEditorInput(
+								(org.eclipse.core.resources.IFile)res);
+			
+				try {
+					org.eclipse.ui.IEditorPart part=page.openEditor(input,
+								"org.pi4soa.scenario.designer.Pi4SOAScenarioDesignerID");
+					
+					if (part instanceof org.pi4soa.designer.editor.ChoreographyDescriptionEditor) {
+						org.pi4soa.designer.editor.ChoreographyDescriptionEditor editor=
+							(org.pi4soa.designer.editor.ChoreographyDescriptionEditor)part;
+						
+						/* Other approach using marker - can be used if editor does not
+						 * provide alternative way to focus on component.
+						org.eclipse.core.resources.IMarker marker=res.createMarker(EValidator.MARKER);
+						marker.setAttribute(EValidator.URI_ATTRIBUTE, ref.getComponentURI());
+						editor.gotoMarker(marker);
+						marker.delete();
+						*/
+						
+						editor.showComponent(sref.getComponentURI());
+					}
+					
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+	
+	/**
+	 * This method enriches the set of properties required
+	 * by the editor, using the properties associated with
+	 * the model issue.
+	 * 
+	 * @param issue The model issue
+	 */
+	@Override
+	public void enrich(ModelIssue issue) {
+		
+		if (issue.getModelObject() != null) {
+			// Set the EMF URI attribute
+			issue.getProperties().put(EValidator.URI_ATTRIBUTE,
+					issue.getModelObject().getSource().getComponentURI());
+		}
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/CDMNotation.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/CDMNotation.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/CDMNotation.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,67 @@
+/*
+ * 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:
+ * 17 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * This class represents the CDM notation implementation.
+ */
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class CDMNotation extends org.scribble.model.AbstractNotation {
+
+	public static final String NOTATION_CODE="cdm";
+	
+	/**
+	 * This is the constructor for the CDM notation.
+	 */
+	public CDMNotation() {
+		super(NOTATION_CODE, "CDM", false);
+	}
+	
+	/**
+	 * This method returns the initial description associated
+	 * with the supplied reference.
+	 * 
+	 * @param ref The reference
+	 * @return The initial description, or null if no description
+	 */
+	public String getInitialDescription(ModelReference ref) {
+		StringBuffer buf=new StringBuffer();
+				
+		return(buf.toString());
+	}
+
+	/**
+	 * This method returns the optional 'super' notation.
+	 * If defined, then this notation is a derived notation
+	 * from the 'super' notation.
+	 * 
+	 * @return The optional 'super' notation
+	 */
+	@Override
+	public Notation getSuperNotation() {
+		return(m_superNotation);
+	}
+
+	private Notation m_superNotation=new org.scribble.conversation.model.ConversationNotation();
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/model/SCNNotation.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,67 @@
+/*
+ * 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:
+ * 17 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.model;
+
+import org.scribble.extensions.*;
+import org.scribble.model.ModelReference;
+import org.scribble.model.Notation;
+
+/**
+ * This class represents the SCN notation implementation.
+ */
+ at RegistryInfo(extension=org.scribble.model.Notation.class)
+public class SCNNotation extends org.scribble.model.AbstractNotation {
+
+	public static final String NOTATION_CODE="scn";
+	
+	/**
+	 * This is the constructor for the CDM notation.
+	 */
+	public SCNNotation() {
+		super(NOTATION_CODE, "SCN", false);
+	}
+	
+	/**
+	 * This method returns the initial description associated
+	 * with the supplied reference.
+	 * 
+	 * @param ref The reference
+	 * @return The initial description, or null if no description
+	 */
+	public String getInitialDescription(ModelReference ref) {
+		StringBuffer buf=new StringBuffer();
+				
+		return(buf.toString());
+	}
+
+	/**
+	 * This method returns the optional 'super' notation.
+	 * If defined, then this notation is a derived notation
+	 * from the 'super' notation.
+	 * 
+	 * @return The optional 'super' notation
+	 */
+	@Override
+	public Notation getSuperNotation() {
+		return(m_superNotation);
+	}
+
+	private Notation m_superNotation=new org.scribble.conversation.model.ConversationNotation();
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/Activator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/Activator.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/osgi/Activator.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,22 @@
+package org.jboss.savara.pi4soa.cdm.osgi;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+	}
+
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMModelParserRule.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMModelParserRule.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMModelParserRule.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2007-9 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:
+ * 6 May 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.savara.pi4soa.cdm.model.CDMNotation;
+import org.jboss.savara.pi4soa.cdm.parser.rules.ConverterContext;
+import org.jboss.savara.pi4soa.cdm.parser.rules.ConverterRule;
+import org.jboss.savara.pi4soa.cdm.parser.rules.ConverterRuleFactory;
+import org.jboss.savara.pi4soa.cdm.parser.rules.DefaultConverterContext;
+import org.scribble.conversation.model.ConversationModel;
+import org.scribble.extensions.RegistryFactory;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.Model;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.parser.ParserContext;
+import org.scribble.parser.ParserRule;
+import org.scribble.parser.Token;
+
+/**
+ * This class provides the model parser for the CDM notation.
+ * 
+ */
+ at RegistryInfo(extension=ParserRule.class,notation=CDMNotation.NOTATION_CODE)
+public class CDMModelParserRule extends org.scribble.conversation.parser.ConversationModelParserRule {
+
+	/**
+	 * The default constructor.
+	 */
+	public CDMModelParserRule() {
+		//super(ParserRuleType.File);
+	}
+	
+	/**
+	 * This method determines whether the parser rules is
+	 * appropriate to return a model object of the required
+	 * type.
+	 * 
+	 * @param type The required type
+	 * @return Whether the parser rule returns a
+	 * 				model object of the required type
+	 */
+	public boolean isSupported(Class<?> type) {
+		return(type.isAssignableFrom(Model.class));
+	}
+	
+	/**
+	 * This method parses the description to obtain
+	 * a model object of the appropriate type.
+	 * 
+	 * @param context The context
+	 * @param l The listener
+	 * @return The model object
+	 */
+	public Object parse(ParserContext context, ModelListener l) {
+		ConversationModel ret=null;
+		
+		Token t=context.nextToken();
+		
+		if (t != null && t.getObject() instanceof org.pi4soa.cdl.Package) {
+			try {						
+				org.pi4soa.cdl.Package cdlpack=
+					(org.pi4soa.cdl.Package)t.getObject();
+			
+				ConverterRule rule=ConverterRuleFactory.getConverter(ConversationModel.class,
+									cdlpack);
+			
+				if (rule != null) {
+					ConverterContext cctxt=
+						new DefaultConverterContext(context.getSource());
+					
+					ret = (ConversationModel)rule.convert(cctxt,
+							ConversationModel.class, cdlpack);
+				}
+			
+			} catch(Exception e) {
+				logger.log(Level.SEVERE,
+						"Failed to load model", e);
+			}
+		
+			if (logger.isLoggable(java.util.logging.Level.FINEST)) {
+				
+				org.scribble.export.Exporter exporter=
+					(org.scribble.export.Exporter)
+					RegistryFactory.getRegistry().getExtension(
+							org.scribble.export.Exporter.class, null);
+				
+				try {
+					org.scribble.export.text.TextFormatter formatter=
+						new org.scribble.export.text.TextFormatter();
+					
+					java.io.ByteArrayOutputStream os=
+						new java.io.ByteArrayOutputStream();
+					
+					formatter.setOutputStream(os);
+					
+					exporter.export(context.getSource(), ret, formatter);
+					
+					String str=new String(os.toByteArray());
+					
+					System.out.println("EXPORTED CDM TEXT:");
+					System.out.println(str);
+					
+				} catch(Exception e) {
+					e.printStackTrace();
+				}
+			}
+		}
+
+		return(ret);
+	}
+
+	private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser");
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMTokenizer.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMTokenizer.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/CDMTokenizer.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005-9 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:
+ * 6 May 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser;
+
+import org.jboss.savara.pi4soa.cdm.model.CDMNotation;
+import org.scribble.extensions.RegistryInfo;
+import org.scribble.model.ModelReference;
+import org.scribble.parser.*;
+
+/**
+ * This is the CDM based implementation of the tokenizer
+ * interface.
+ */
+ at RegistryInfo(extension=Tokenizer.class,notation=CDMNotation.NOTATION_CODE)
+public class CDMTokenizer extends DefaultTokenizer {
+
+	/**
+	 * The default constructor.
+	 */
+	public CDMTokenizer() {
+	}
+	
+	/**
+	 * This method obtains a list of tokens based on the
+	 * contents of the input stream.
+	 * 
+	 * @param ref The model reference for the input source
+	 * @param is The input stream
+	 * @return The list of tokens
+	 * @throws java.io.IOException Failed to derive 
+	 */
+	public java.util.List<Token> getTokens(ModelReference ref,
+			java.io.InputStream is)	throws java.io.IOException {
+		java.util.List<Token> ret=new java.util.Vector<Token>();
+		
+		org.pi4soa.cdl.Package cdlpack=
+					org.pi4soa.cdl.CDLManager.load(is);
+		
+		if (cdlpack != null) {
+			Token t=new Token(cdlpack);
+			ret.add(t);
+		}			
+
+		return(ret);
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/AssignConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2005-9 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:
+ * 3 Jun 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.cdl.util.PackageUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class AssignConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.Assign);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.model.Block ret=
+					new org.scribble.model.Block();
+		org.pi4soa.cdl.Assign cdl=(org.pi4soa.cdl.Assign)cdlType;
+		java.util.List<Raise> exceptions=new java.util.Vector<Raise>();
+		
+		for (int i=0; i < cdl.getCopyDetails().size(); i++) {
+			org.pi4soa.cdl.CopyDetails details=cdl.getCopyDetails().get(i);
+			
+			Assignment assign=new Assignment();
+			
+			assign.getSource().setComponentURI(
+					CDLTypeUtil.getURIFragment(details));
+			
+			// Set role
+			Role role=new Role();
+			
+			if (cdl.getParticipant() != null) {
+				role.setName(cdl.getParticipant().getName());
+			} else if (cdl.getRoleType() != null) {
+				org.pi4soa.cdl.ParticipantType ptype=
+					PackageUtil.getParticipantForRoleType(cdl.getRoleType());
+				
+				if (ptype != null) {
+					role.setName(ptype.getName());
+				}
+			}
+			
+			assign.getRoles().add(role);
+			
+			// Set variable
+			org.scribble.conversation.model.Variable var=
+					new org.scribble.conversation.model.Variable();
+			var.setName(details.getTargetVariable().getName());
+			
+			assign.setVariable(var);
+			
+			org.scribble.expression.xpath.model.XPathExpression expr=
+				new org.scribble.expression.xpath.model.XPathExpression();
+			
+			if (details.getSourceExpression() != null) {
+				expr.setQuery(details.getSourceExpression());
+			} else if (details.getSourceVariable() != null) {
+				expr.setQuery("cdl:getVariable('"+details.getSourceVariable().getName()+"','','')");
+			}
+			
+			assign.setExpression(expr);
+			
+			ret.getContents().add(assign);
+			
+			if (details.getCauseException() != null &&
+					details.getCauseException().trim().length() > 0) {
+				Raise raise=new Raise();
+				
+				Role raiseRole=new Role();
+				raiseRole.setName(role.getName());
+				raise.getRoles().add(raiseRole);
+				
+				TypeReference tref=new TypeReference();
+				tref.setLocalpart(XMLUtils.getLocalname(details.getCauseException()));
+				raise.setType(tref);
+				
+				exceptions.add(raise);
+			}
+		}
+		
+		if (exceptions.size() > 0) {
+			ret.getContents().addAll(exceptions);
+		}
+
+		if (ret.getContents().size() > 1) {
+			return(ret);
+		} else if (ret.getContents().size() == 1) {
+			return(ret.getContents().get(0));
+		} else {
+			return(null);
+		}
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,781 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.Interaction;
+import org.pi4soa.cdl.interfaces.InterfaceDefinition;
+import org.pi4soa.cdl.interfaces.InterfaceVisitor;
+import org.pi4soa.cdl.interfaces.MessageDefinition;
+import org.pi4soa.cdl.interfaces.OperationDefinition;
+import org.pi4soa.cdl.interfaces.RoleTypeDefinition;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.cdl.util.PackageUtil;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.scribble.model.*;
+import org.jboss.savara.contract.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.*;
+
+public class ConversationConverterRuleImpl implements ConverterRule {
+
+	private static final String CONVERSATION_TYPE = "conversationType";
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == Conversation.class &&
+				cdlType instanceof Choreography);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		Conversation ret=new Conversation();
+		Choreography choreo=(Choreography)cdlType;
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(choreo));
+			
+		context.pushScope();
+		
+		LocatedName modelName=new LocatedName();
+		modelName.setName(choreo.getName());
+		
+		ret.setLocatedName(modelName);
+		
+		// Define roles
+		defineRoles(context, choreo, ret);
+		
+		// Check if root, then need to project other sibling choreos
+		if (choreo.getRoot() == Boolean.TRUE) {
+			
+			java.util.Iterator<Choreography> citer=
+				choreo.getPackage().getChoreographies().iterator();
+	
+			while (citer.hasNext()) {
+				Choreography subchoreo=citer.next();
+				
+				if (subchoreo != choreo) {
+					Conversation subconv=(Conversation)
+							convert(context, Conversation.class, subchoreo);
+					
+					ret.getBlock().getContents().add(subconv);
+					
+					context.addConversation(subconv);
+				}
+				
+				for (int i=0; i < subchoreo.getFinalizers().size(); i++) {
+					FinalizerHandler finalizer=subchoreo.getFinalizers().get(i);
+					
+					ConverterRule rule=ConverterRuleFactory.getConverter(
+							Conversation.class, finalizer);
+					
+					if (rule != null) {
+						
+						Conversation subconv=(Conversation)
+							rule.convert(context, Conversation.class, finalizer);
+					
+						ret.getBlock().getContents().add(subconv);
+					
+						context.addConversation(subconv);
+					}
+				}
+			}
+		}
+		
+		// Process any sub-choreographies	
+		java.util.Iterator<Choreography> citer=
+					choreo.getEnclosedChoreographies().iterator();
+		
+		while (citer.hasNext()) {
+			Choreography subchoreo=citer.next();
+
+			Conversation subconv=(Conversation)
+					convert(context, Conversation.class, subchoreo);
+			
+			ret.getBlock().getContents().add(subconv);
+			
+			context.addConversation(subconv);
+			
+			for (int i=0; i < subchoreo.getFinalizers().size(); i++) {
+				FinalizerHandler finalizer=subchoreo.getFinalizers().get(i);
+				
+				ConverterRule rule=ConverterRuleFactory.getConverter(
+						Conversation.class, finalizer);
+				
+				if (rule != null) {
+					
+					subconv = (Conversation)
+						rule.convert(context, Conversation.class, finalizer);
+				
+					ret.getBlock().getContents().add(subconv);
+				
+					context.addConversation(subconv);
+				}
+			}
+		}
+		
+		// Convert variables
+		convertVariables(context, choreo, ret.getBlock());
+		
+		// Define identities
+		convertIdentities(context, choreo, ret);
+		
+		// Check if exception handlers have been defined
+		// and/or completion condition
+		if (NamesUtil.isSet(choreo.getCompletionCondition()) ||
+			(choreo.getExceptionHandler() != null &&
+					choreo.getExceptionHandler().getExceptionWorkUnits().size() > 0)) {
+			
+			TryEscape te=new TryEscape();
+			ret.getBlock().getContents().add(te);
+			
+			// Process all of the activities within the
+			// choreography
+			convertActivities(context, choreo.getActivities(),
+						te.getBlock());
+			
+			for (int i=0; choreo.getExceptionHandler() != null &&
+						i < choreo.getExceptionHandler().
+						getExceptionWorkUnits().size(); i++) {
+				ExceptionWorkUnit ewu=choreo.getExceptionHandler().
+					getExceptionWorkUnits().get(i);
+				
+				CatchBlock catchPath=new CatchBlock();
+
+				if (NamesUtil.isSet(ewu.getExceptionType())) {
+					TypeReference ref=new TypeReference();
+					ref.setLocalpart(XMLUtils.getLocalname(ewu.getExceptionType()));
+					ref.setNamespace(CDLTypeUtil.getNamespace(
+							ewu.getExceptionType(), choreo));
+					
+					catchPath.setType(ref);					
+				}
+				
+				te.getEscapeBlocks().add(catchPath);
+				
+				convertActivities(context, ewu.getActivities(),
+								catchPath);
+			}
+			
+			if (NamesUtil.isSet(choreo.getCompletionCondition())) {
+				InterruptBlock interrupt=new InterruptBlock();
+				
+				te.getEscapeBlocks().add(interrupt);
+				
+				// Set expression from completion condition
+				// using xpath
+				XPathExpression exp=new XPathExpression();
+				
+				exp.setQuery(choreo.getCompletionCondition());
+				
+				interrupt.setExpression(exp);
+
+				// No activities
+			}
+		} else {
+		
+			// Process all of the activities within the
+			// choreography
+			convertActivities(context, choreo.getActivities(), ret.getBlock());
+		}
+		
+		// Transfer sub-conversations to end of block
+		if (ret.getBlock().getContents().size() > 0) {
+			org.scribble.model.Activity lastAct=
+				ret.getBlock().getContents().get(ret.getBlock().getContents().size()-1);
+			int pos=0;
+			while (ret.getBlock().getContents().get(pos) != lastAct) {
+				if (ret.getBlock().getContents().get(pos) instanceof Conversation) {
+					Conversation c=(Conversation)ret.getBlock().getContents().get(pos);
+	
+					ret.getBlock().getContents().remove(pos);
+					ret.getBlock().getContents().add(c);
+					
+					context.removeConversation(c);
+				} else {
+					pos++;
+				}
+			}
+		}
+		
+		context.popScope();
+		
+		return(ret);
+	}
+
+	
+	protected void defineRoles(ConverterContext context,
+			final Choreography choreo, Conversation conv) {
+	
+		org.pi4soa.cdl.interfaces.InterfaceDeriver intfDeriver=
+					org.pi4soa.cdl.interfaces.InterfaceFactory.getInterfaceDeriver();
+		
+		final java.util.List<ParticipantType> partTypes=new java.util.Vector<ParticipantType>();
+		final java.util.List<Participant> partInstances=new java.util.Vector<Participant>();
+		
+		choreo.visit(new DefaultCDLVisitor() {
+			
+			public void interaction(Interaction interaction) {
+				
+				if (interaction.getEnclosingChoreography() != choreo) {
+					return;
+				}
+				
+				if (interaction.getFromParticipant() != null) {
+					if (partInstances.contains(interaction.getFromParticipant()) == false) {
+						partInstances.add(interaction.getFromParticipant());
+					}
+				} else {
+					ParticipantType ptype=
+						org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+								interaction.getFromRoleType());
+					
+					if (ptype != null &&
+							partTypes.contains(ptype) == false) {
+						partTypes.add(ptype);
+					}
+				}
+				
+				if (interaction.getToParticipant() != null) {
+					if (partInstances.contains(interaction.getToParticipant()) == false) {
+						partInstances.add(interaction.getToParticipant());
+					}
+				} else {
+					ParticipantType ptype=
+						org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+								interaction.getToRoleType());
+					
+					if (ptype != null &&
+							partTypes.contains(ptype) == false) {
+						partTypes.add(ptype);
+					}
+				}
+			}
+		});
+		
+		// Define roles
+		java.util.Iterator<Participant> piter=partInstances.iterator();
+		
+		RoleList roleList=null;
+		
+		while (piter.hasNext()) {
+			Role role=new Role();
+			Participant pinst=piter.next();
+			role.setName(pinst.getName());
+			
+			if (roleList == null) {
+				roleList = new RoleList();
+				conv.getBlock().getContents().add(roleList);
+			}
+			
+			roleList.getRoles().add(role);
+			
+			context.setState(role.getName(), role);
+
+			registerRole(context, choreo, conv, roleList, role, pinst);
+			
+			// Setup interfaces
+			for (int i=0; i < pinst.getRoleTypes().size(); i++) {
+				Contract contract=null;
+				
+				if (role.getAnnotations().containsKey(Contract.class.getName())) {
+					contract = (Contract)role.getAnnotations().get(
+								Contract.class.getName());
+				} else {
+					contract = new Contract();
+					
+					java.util.List<?> ptypes=
+							PackageUtil.getParticipantsForRoleTypes(choreo.getPackage(),
+									pinst.getRoleTypes());
+					
+					if (ptypes.size() == 1) {
+						ParticipantType pt=(ParticipantType)ptypes.get(0);
+						
+						contract.setName(XMLUtils.getLocalname(pt.getName()));
+						contract.setNamespace(CDLTypeUtil.getNamespace(pt.getName(), pt));
+					} else {
+						
+						logger.warning("Could not find single participant type for participant instance '"+
+								pinst.getName()+"'");
+						contract.setName(XMLUtils.getLocalname(pinst.getName()));
+						contract.setNamespace(CDLTypeUtil.getNamespace(pinst.getName(), pinst));
+					}
+					
+					// Setup namespace to prefix mappings
+					java.util.List<NameSpace> nspaces=pinst.getPackage().getTypeDefinitions().getNameSpaces();
+					
+					for (int j=0; j < nspaces.size(); j++) {
+						org.jboss.savara.contract.model.Namespace ns=
+									new org.jboss.savara.contract.model.Namespace();
+						
+						ns.setPrefix(nspaces.get(j).getPrefix());
+						ns.setURI(nspaces.get(j).getURI());
+						ns.setSchemaLocation(nspaces.get(j).getSchemaLocation());
+						
+						contract.getNamespaces().add(ns);
+					}
+					
+					role.getAnnotations().put(Contract.class.getName(),
+												contract);
+				}
+				
+				setupInterfaces((org.pi4soa.cdl.RoleType)pinst.getRoleTypes().get(i),
+								contract, intfDeriver);
+			}
+		}
+
+		java.util.Iterator<ParticipantType> ptiter=partTypes.iterator();
+
+		if (choreo.getRoot() != Boolean.TRUE) {
+			roleList = null;
+		} else {
+			ptiter = choreo.getPackage().getTypeDefinitions().getParticipantTypes().iterator();
+		}
+	
+		while (ptiter.hasNext()) {
+			Role role=new Role();
+			ParticipantType ptype=ptiter.next();
+			role.setName(XMLUtils.getLocalname(ptype.getName()));
+			
+			if (roleList == null) {
+				roleList = new RoleList();
+				
+				roleList.setOpen(choreo.getRoot() != Boolean.TRUE);
+				
+				conv.getBlock().getContents().add(roleList);
+			}
+			
+			roleList.getRoles().add(role);
+			
+			context.setState(role.getName(), role);
+
+			if (choreo.getRoot() == Boolean.TRUE) {
+				registerRole(context, choreo, conv, roleList, role, ptype);
+				
+				// Setup interfaces
+				for (int i=0; i < ptype.getRoleTypes().size(); i++) {
+					Contract contract=null;
+					
+					if (role.getAnnotations().containsKey(Contract.class.getName())) {
+						contract = (Contract)role.getAnnotations().get(
+									Contract.class.getName());
+					} else {
+						contract = new Contract();
+						
+						contract.setName(XMLUtils.getLocalname(ptype.getName()));
+						contract.setNamespace(CDLTypeUtil.getNamespace(ptype.getName(), ptype, true));
+						
+						// Setup namespace to prefix mappings
+						java.util.List<NameSpace> nspaces=ptype.getPackage().getTypeDefinitions().getNameSpaces();
+						
+						for (int j=0; j < nspaces.size(); j++) {
+							org.jboss.savara.contract.model.Namespace ns=
+										new org.jboss.savara.contract.model.Namespace();
+							
+							ns.setPrefix(nspaces.get(j).getPrefix());
+							ns.setURI(nspaces.get(j).getURI());
+							ns.setSchemaLocation(nspaces.get(j).getSchemaLocation());
+							
+							contract.getNamespaces().add(ns);
+						}
+						
+						role.getAnnotations().put(Contract.class.getName(),
+													contract);
+					}
+
+					setupInterfaces((org.pi4soa.cdl.RoleType)ptype.getRoleTypes().get(i),
+									contract, intfDeriver);
+				}
+			}
+		}
+	}
+	
+	protected void setupInterfaces(org.pi4soa.cdl.RoleType roleType, Contract contract,
+					org.pi4soa.cdl.interfaces.InterfaceDeriver intfDeriver) {
+		
+		org.pi4soa.cdl.interfaces.RoleTypeDefinition rtd=
+						intfDeriver.getRoleTypeDefinition(roleType);
+				
+		InterfaceVisitorImpl iv=new InterfaceVisitorImpl(contract);
+		
+		rtd.visit(iv);
+	}
+	
+	protected void convertVariables(ConverterContext context,
+			Choreography choreo, Block block) {
+		
+		java.util.List<org.pi4soa.cdl.Variable> vars=
+					choreo.getVariableDefinitions();
+		
+		for (int i=0; i < vars.size(); i++) {
+			org.pi4soa.cdl.Variable var=(org.pi4soa.cdl.Variable)vars.get(i);
+			
+			if (var.getType() instanceof InformationType) {				
+				java.util.List<RoleType> roleTypes=var.getRoleTypes();
+				
+				if (roleTypes.size() == 0) {
+					roleTypes = choreo.getPackage().getTypeDefinitions().getRoleTypes();
+				}
+				
+				VariableList vlist=new VariableList();
+				TypeReference ref=new TypeReference();
+				
+				String qname=((InformationType)var.getType()).getElementName();
+				
+				if (NamesUtil.isSet(qname)==false) {
+					qname=((InformationType)var.getType()).getTypeName();
+				}
+				
+				ref.setNamespace(CDLTypeUtil.getNamespace(qname, var));
+				ref.setLocalpart(XMLUtils.getLocalname(qname));
+				
+				vlist.setType(ref);
+				
+				/* TODO: See if variables should be located?
+				for (int j=0; j < roleTypes.size(); j++) {
+					org.scribble.conversation.model.Variable newVar=
+						new org.scribble.conversation.model.Variable();
+					
+					newVar.setName(var.getName());
+				}
+				*/
+				
+				org.scribble.conversation.model.Variable newVar=
+					new org.scribble.conversation.model.Variable();
+				
+				newVar.setName(var.getName());
+				
+				vlist.getVariables().add(newVar);
+				
+				block.getContents().add(vlist);
+				
+			} else if (var.getType() instanceof ChannelType) {	
+				
+				// TODO: Only convert if channel is explicitly defined
+				
+
+			}
+		}
+	}
+	
+	protected void convertActivities(ConverterContext context,
+				java.util.List<org.pi4soa.cdl.Activity> acts, Block block) {
+		
+		java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+						acts.iterator();
+		
+		while (actiter.hasNext()) {
+			org.pi4soa.cdl.Activity act=actiter.next();
+			
+			ConverterRule rule=ConverterRuleFactory.getConverter(
+					org.scribble.model.Activity.class, act);
+			
+			if (rule != null) {
+				org.scribble.model.Activity activity=
+					(org.scribble.model.Activity)
+					rule.convert(context,
+							org.scribble.model.Activity.class, act);
+				
+				if (activity != null) {
+					
+					if (activity instanceof Block) {
+						block.getContents().addAll(((Block)activity).getContents());
+					} else {
+						block.getContents().add(activity);
+					}
+				}
+			}
+		}
+	}
+	
+	protected void convertIdentities(ConverterContext context,
+					Choreography choreo, Conversation conv) {
+		
+		// Define identities
+		java.util.List<org.pi4soa.cdl.Variable> vars=
+					choreo.getVariableDefinitions();
+		java.util.List<org.scribble.conversation.model.Identity> ids=
+			new java.util.Vector<org.scribble.conversation.model.Identity>();
+
+		for (int i=0; i < vars.size(); i++) {
+			if (vars.get(i).getType() instanceof org.pi4soa.cdl.ChannelType) {
+				org.pi4soa.cdl.ChannelType ctype=
+						(org.pi4soa.cdl.ChannelType)vars.get(i).getType();
+				
+				java.util.Iterator<org.pi4soa.cdl.Identity> cids=
+						ctype.getIdentities().iterator();
+				
+				while (cids.hasNext()) {
+					org.pi4soa.cdl.Identity cid=cids.next();
+					org.scribble.conversation.model.Identity id=
+						new org.scribble.conversation.model.Identity();
+					
+					if (cid.getType() == KeyType.ASSOCIATION) {
+						id.setIdentityType(IdentityType.Association);
+					} else if (cid.getType() == KeyType.DERIVED) {
+						id.setIdentityType(IdentityType.Derived);
+					} else {
+						id.setIdentityType(IdentityType.Primary);
+					}
+					
+					for (int j=0; j < cid.getTokens().size(); j++) {
+						id.getNames().add(cid.getTokens().get(j).getName());
+					}
+					
+					if (ids.contains(id) == false) {
+						ids.add(id);
+					}
+				}
+			}
+		}
+		
+		conv.getIdentities().addAll(ids);		
+	}
+	
+	private void registerRole(ConverterContext context,
+			Choreography choreo,
+			Conversation conv, RoleList roleList,
+				Role role, CDLType cdlType) {
+		
+		if (cdlType.getSemanticAnnotations().size() > 0) {
+			java.util.Iterator<SemanticAnnotation> iter=
+					cdlType.getSemanticAnnotations().iterator();
+			
+			while (iter.hasNext()) {
+				SemanticAnnotation annotation=iter.next();
+				
+				if (annotation.getName() != null &&
+						annotation.getName().equals(CONVERSATION_TYPE)) {
+					String convType=annotation.getAnnotation();
+					
+					if (convType != null) {
+						int index=convType.indexOf('@');
+					
+						if (index != -1) {
+							ConformanceReference ref=
+								new ConformanceReference(ConversationNotation.NOTATION_CODE);
+						
+							ref.setLocatedRole(convType.substring(index+1));
+							
+							String mainpart=convType.substring(0, index);
+							
+							index = mainpart.lastIndexOf(".");
+							
+							String namespace="";
+							String localpart=mainpart;
+							
+							if (index != -1) {
+								namespace=mainpart.substring(0, index);								
+								localpart=mainpart.substring(index+1);
+							}
+							
+							String[] elems=localpart.split("\\$");
+							if (elems.length > 1) {
+								localpart = elems[0];
+								
+								for (int i=1; i < elems.length; i++) {
+									ref.getSubDefinitionPath().addPathElement(elems[i]);
+								}
+							}
+							
+							ref.setNamespace(namespace);
+							ref.setLocalpart(localpart);
+							
+							ref.setFullyQualified(true);
+							
+							conv.getConformsTo().add(ref);
+							
+							ModelReference sref=context.getSource();
+							
+							// If not the root choreography, then
+							// identify the sub definition path
+							// in the source reference
+							if (choreo.getRoot() != Boolean.TRUE) {
+								sref = new ModelReference(sref);
+								Choreography sub=choreo;
+								
+								while (sub != null && sub.getRoot() != Boolean.TRUE) {
+									sref.getSubDefinitionPath().addPathElement(0, sub.getName());
+									
+									sub = sub.getParent().getEnclosingChoreography();
+								}
+							}
+							
+							// Establish 'conforms to' dependency
+							// between source (which could be a
+							// sub definition) and the identified
+							// conversation type
+							
+							// GPB: TO REMOVE dm.recordDependency(sref, ref,
+							//		DependencyType.ConformsTo);
+
+						} else {
+							logger.warning("Conversation type '"+
+									convType+"' does not " +
+									"contain '@' located role separator");
+						}
+					}
+					
+				}
+			}
+		}
+	}
+
+	private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+	
+	public static class InterfaceVisitorImpl implements InterfaceVisitor,
+							java.io.Serializable {
+		
+		private static final long serialVersionUID = 4068744630125720449L;
+		
+		private org.jboss.savara.contract.model.Contract m_contract=null;
+		private org.jboss.savara.contract.model.Interface m_currentInterface=null;
+		private org.jboss.savara.contract.model.MessageExchangePattern m_currentMEP=null;
+
+		public InterfaceVisitorImpl(Contract contract) {
+			m_contract = contract;
+		}
+		
+		public Contract getContract() {
+			return(m_contract);
+		}
+		
+		public void interfaceEnd(InterfaceDefinition defn) {
+			m_currentInterface = null;
+		}
+
+		public void interfaceStart(InterfaceDefinition defn) {
+			m_currentInterface = new org.jboss.savara.contract.model.Interface();
+			
+			m_currentInterface.setNamespace(defn.getNamespace());
+
+			if (defn.getInterfaceName() != null &&
+					defn.getInterfaceName().trim().length() > 0) {
+				m_currentInterface.setName(defn.getInterfaceName());
+			} else {
+				m_currentInterface.setName(defn.getBehaviorName());
+			}
+			
+			m_contract.getInterfaces().add(m_currentInterface);
+		}
+
+		public void message(MessageDefinition defn) {
+			
+			if (defn.getClassification() == MessageDefinition.INPUT) {
+				m_currentMEP.getTypes().add(createType(defn));
+				
+			} else if (m_currentMEP instanceof RequestResponseMEP) {
+				RequestResponseMEP mep=(RequestResponseMEP)m_currentMEP;
+				
+				if (defn.getClassification() == MessageDefinition.OUTPUT) {
+					mep.getResponseTypes().add(createType(defn));
+					
+				} else if (defn.getClassification() == MessageDefinition.OUTFAULT) {
+					FaultDetails fault=new FaultDetails();
+					
+					fault.setName(defn.getFaultName());
+					fault.setNamespace(defn.getFaultNamespace());
+					
+					fault.getTypes().add(createType(defn));
+					
+					mep.getFaultDetails().add(fault);
+				}
+			}
+		}
+		
+		protected Type createType(MessageDefinition defn) {
+			Type ret=new Type();
+			TypeDefinition td=new TypeDefinition();
+			ret.getTypeDefinitions().add(td);
+			
+			if (defn.getElement() != null && defn.getElement().trim().length() > 0) {
+				td.setName(defn.getElement());
+				
+				if (defn.getElementNamespace() != null) {
+					td.setNamespace(defn.getElementNamespace());
+				}
+				
+				td.setTypeSystem(TypeDefinition.XSD_ELEMENT);
+
+			} else if (defn.getType() != null && defn.getType().trim().length() > 0) {
+				td.setName(defn.getType());
+				
+				if (defn.getTypeNamespace() != null) {
+					td.setNamespace(defn.getTypeNamespace());
+				}
+				
+				td.setTypeSystem(TypeDefinition.XSD_TYPE);
+			}
+			
+			ret.setName(td.getName());
+			
+			return(ret);
+		}
+
+		public void operationEnd(OperationDefinition defn) {
+			m_currentMEP = null;
+		}
+
+		public void operationStart(OperationDefinition defn) {
+			if (defn.getMessages().size() == 1 &&
+					((MessageDefinition)defn.getMessages().get(0)).getClassification()
+							== MessageDefinition.INPUT) {
+				m_currentMEP = new OneWayRequestMEP();
+			} else {
+				m_currentMEP = new RequestResponseMEP();
+			}
+			
+			m_currentMEP.setOperation(defn.getOperationName());
+			
+			m_currentInterface.getMessageExchangePatterns().add(m_currentMEP);
+		}
+
+		public void roleTypeEnd(RoleTypeDefinition defn) {
+			// TODO Auto-generated method stub
+			
+		}
+
+		public void roleTypeStart(RoleTypeDefinition defn) {
+			// TODO Auto-generated method stub
+			
+		}	
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationInteractionConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,698 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.Interaction;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.XPathExpression;
+import org.pi4soa.cdl.util.*;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.NameSpaceUtil;
+import org.pi4soa.common.xml.XMLUtils;
+
+public class ConversationInteractionConverterRuleImpl implements ConverterRule {
+
+	private static final String INTERFACE_NAME = "interfaceName";
+	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 determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.Interaction);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.model.Block ret=new org.scribble.model.Block();
+		org.pi4soa.cdl.Interaction cdl=
+				(org.pi4soa.cdl.Interaction)cdlType;
+		Role fromRole=null;
+		Role toRole=null;
+		
+		if (cdl.getFromParticipant() != null) {
+			fromRole = (Role)
+				context.getState(XMLUtils.getLocalname(cdl.getFromParticipant().getName()));
+			
+			if (fromRole == null) {
+				logger.severe("Failed to get 'from' role '"+XMLUtils.getLocalname(cdl.getFromParticipant().getName())+"'");
+			}
+		} else if (cdl.getFromRoleType() != null) {			
+			ParticipantType ptype=
+				PackageUtil.getParticipantForRoleType(cdl.getFromRoleType());
+			
+			fromRole = (Role)
+				context.getState(XMLUtils.getLocalname(ptype.getName()));
+			
+			if (fromRole == null) {
+				logger.severe("Failed to get 'from' role '"+XMLUtils.getLocalname(ptype.getName())+"'");
+			}
+		}
+		
+		if (cdl.getToParticipant() != null) {
+			toRole = (Role)
+				context.getState(XMLUtils.getLocalname(cdl.getToParticipant().getName()));
+
+			if (toRole == null) {
+				logger.severe("Failed to get 'to' role '"+XMLUtils.getLocalname(cdl.getFromParticipant().getName())+"'");
+			}
+		} else if (cdl.getToRoleType() != null) {
+			ParticipantType ptype=
+				PackageUtil.getParticipantForRoleType(cdl.getToRoleType());
+			
+			toRole = (Role)
+				context.getState(XMLUtils.getLocalname(ptype.getName()));
+			
+			if (toRole == null) {
+				logger.severe("Failed to get 'to' role '"+XMLUtils.getLocalname(ptype.getName())+"'");
+			}
+		}
+		
+		// Determine if interaction may result in
+		// a timeout
+		Block block=ret;
+		
+		if (NamesUtil.isSet(cdl.getTimeToComplete())) {
+			TryEscape te=new TryEscape();
+			
+			ret.getContents().add(te);
+			
+			block = te.getBlock();
+			
+			InterruptBlock interrupt=new InterruptBlock();
+			
+			te.getEscapeBlocks().add(interrupt);
+			
+			// Set expression from 'time to complete'
+			// using xpath
+			XPathExpression exp=new XPathExpression();
+			
+			exp.setQuery("cdl:hasDurationPassed('"+
+					cdl.getTimeToComplete()+"')");
+			
+			interrupt.setExpression(exp);
+			
+			// Perform assignments associated with timeout
+			for (int i=0; i < cdl.getRecordDetails().size(); i++) {
+				org.pi4soa.cdl.RecordDetails rd=
+							cdl.getRecordDetails().get(i);
+				
+				if (rd.getWhen() == WhenType.TIMEOUT) {
+					
+					// TODO: Record variable - but which role??? May need to
+					// be part of the following conditions, so depends on
+					// whether the record details are in the from/to timeout record details
+				
+					if (cdl.getTimeoutFromRoleTypeRecordDetails().contains(rd)) {
+						
+						if (rd.getCauseException() != null &&
+								rd.getCauseException().trim().length() > 0) {
+							Raise raise=new Raise();
+							raise.getRoles().add(new Role(fromRole.getName()));
+							
+							TypeReference tref=new TypeReference();
+							tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+							raise.setType(tref);
+							
+							interrupt.getContents().add(raise);
+						}
+					}
+					
+					if (cdl.getTimeoutToRoleTypeRecordDetails().contains(rd)) {
+						
+						if (rd.getCauseException() != null &&
+								rd.getCauseException().trim().length() > 0) {
+							Raise raise=new Raise();
+							raise.getRoles().add(new Role(toRole.getName()));
+							
+							TypeReference tref=new TypeReference();
+							tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+							raise.setType(tref);
+							
+							interrupt.getContents().add(raise);
+						}
+					}
+				}
+			}
+		}
+		
+		java.util.Iterator<ExchangeDetails> iter=
+					cdl.getExchangeDetails().iterator();
+		java.util.List<ConditionalBlock> cbs=
+					new java.util.Vector<ConditionalBlock>();
+				
+		while (iter.hasNext()) {
+			ExchangeDetails details=iter.next();
+			ConditionalBlock cb=new ConditionalBlock();
+			
+			// Convert 'before' send and receive record details
+			for (int i=0; i < details.getSendRecordDetails().size(); i++) {
+				RecordDetails rd=details.getSendRecordDetails().get(i);
+				
+				if (rd.getWhen() == WhenType.BEFORE) {
+					String fromRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+							fromRole.getName():toRole.getName());
+					
+					// Define record expression
+					Assignment assign=new Assignment();
+					
+					assign.getSource().setComponentURI(
+							CDLTypeUtil.getURIFragment(rd));
+					
+					// Set role
+					Role role=new Role(fromRoleName);
+					
+					assign.getRoles().add(role);
+					
+					// Set variable
+					org.scribble.conversation.model.Variable var=
+							new org.scribble.conversation.model.Variable();
+					var.setName(rd.getTargetVariable().getName());
+					
+					assign.setVariable(var);
+					
+					org.scribble.expression.xpath.model.XPathExpression expr=
+						new org.scribble.expression.xpath.model.XPathExpression();
+					
+					if (rd.getSourceExpression() != null) {
+						expr.setQuery(rd.getSourceExpression());
+					} else if (rd.getSourceVariable() != null) {
+						expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+					}
+					
+					assign.setExpression(expr);
+					
+					cb.getContents().add(assign);
+										
+					// Check for cause exception
+					if (rd.getCauseException() != null &&
+							rd.getCauseException().trim().length() > 0) {
+						
+						Raise raise=new Raise();
+						raise.getRoles().add(new Role(fromRoleName));
+						
+						TypeReference tref=new TypeReference();
+						tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+						raise.setType(tref);
+						
+						cb.getContents().add(raise);
+					}
+				}
+			}
+			
+			for (int i=0; i < details.getReceiveRecordDetails().size(); i++) {
+				RecordDetails rd=details.getReceiveRecordDetails().get(i);
+				
+				if (rd.getWhen() == WhenType.BEFORE) {
+					String toRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+							toRole.getName():fromRole.getName());
+					
+					// Define record expression
+					Assignment assign=new Assignment();
+					
+					assign.getSource().setComponentURI(
+							CDLTypeUtil.getURIFragment(rd));
+					
+					// Set role
+					Role role=new Role(toRoleName);
+					
+					assign.getRoles().add(role);
+					
+					// Set variable
+					org.scribble.conversation.model.Variable var=
+							new org.scribble.conversation.model.Variable();
+					var.setName(rd.getTargetVariable().getName());
+					
+					assign.setVariable(var);
+					
+					org.scribble.expression.xpath.model.XPathExpression expr=
+						new org.scribble.expression.xpath.model.XPathExpression();
+					
+					if (rd.getSourceExpression() != null) {
+						expr.setQuery(rd.getSourceExpression());
+					} else if (rd.getSourceVariable() != null) {
+						expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+					}
+					
+					assign.setExpression(expr);
+					
+					cb.getContents().add(assign);
+										
+					// Check for cause exception
+					if (rd.getCauseException() != null &&
+							rd.getCauseException().trim().length() > 0) {
+						
+						Raise raise=new Raise();
+						raise.getRoles().add(new Role(toRoleName));
+						
+						TypeReference tref=new TypeReference();
+						tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+						raise.setType(tref);
+						
+						cb.getContents().add(raise);
+					}
+				}
+			}
+
+			// Convert the interaction
+			ConversationInteraction interaction=
+					new ConversationInteraction();
+			
+			interaction.getSource().setComponentURI(
+						CDLTypeUtil.getURIFragment(details));
+			
+			// Check if interaction's channel has been explicitly defined
+			Object ch=context.getState(cdl.getChannelVariable().getName());
+			
+			if (ch instanceof Channel) {
+				interaction.setChannel((Channel)ch);
+			}
+			
+			// Define message signature
+			MessageSignature ms=new MessageSignature();
+			ms.setOperation(cdl.getOperation());
+			
+			if (NamesUtil.isSet(details.getFaultName())) {
+				ms.getAnnotations().put(FAULT_NAME,
+						details.getFaultName());
+			}
+
+			interaction.setMessageSignature(ms);
+			
+			// Define interaction message type
+			if (details.getType() instanceof InformationType) {
+				InformationType itype=(InformationType)details.getType();
+				
+				TypeReference ref=ConverterUtil.getTypeReference(itype);
+				
+				ms.getTypes().add(ref);
+				
+				if (NamesUtil.isSet(itype.getTypeName())) {
+					String ns=CDLTypeUtil.getNamespace(itype.getTypeName(),
+									cdl);
+					String lp=XMLUtils.getLocalname(itype.getTypeName());
+					
+					if (lp != null) {
+						ms.getAnnotations().put(MESSAGE_TYPE_LOCALPART,
+										lp);
+					}
+					if (ns != null) {
+						ms.getAnnotations().put(MESSAGE_TYPE_NAMESPACE,
+										ns);
+					}
+				} else if (NamesUtil.isSet(itype.getElementName())) {
+					String ns=CDLTypeUtil.getNamespace(itype.getElementName(),
+							cdl);
+					String lp=XMLUtils.getLocalname(itype.getElementName());
+			
+					if (lp != null) {
+						ms.getAnnotations().put(MESSAGE_TYPE_LOCALPART,
+										lp);
+					}
+					if (ns != null) {
+						ms.getAnnotations().put(MESSAGE_TYPE_NAMESPACE,
+										ns);
+					}
+				}
+			}
+			
+			cb.getContents().add(interaction);
+
+			// Set interface name
+			if (cdl.getToRoleType() != null) {
+				// TODO: Deal with interfaces that have multiple behaviours
+				interaction.getAnnotations().put(INTERFACE_NAME,
+						getInterfaceName(cdl));
+			}
+			
+			if (details.getAction() == ExchangeActionType.REQUEST) {
+				interaction.setFromRole(fromRole);
+				interaction.setToRole(toRole);
+				
+				if (details.getSendVariable() != null) {
+					org.scribble.conversation.model.Variable var=
+							new org.scribble.conversation.model.Variable();
+					var.setName(details.getSendVariable().getName());
+					interaction.setFromVariable(var);
+				}
+				
+				if (details.getReceiveVariable() != null) {
+					org.scribble.conversation.model.Variable var=
+							new org.scribble.conversation.model.Variable();
+					var.setName(details.getReceiveVariable().getName());
+					interaction.setToVariable(var);
+				}
+				
+				// Check if request has response/fault exchanges
+				java.util.List<ExchangeDetails> resps=
+						InteractionUtil.getResponseExchangeDetails(details);
+				
+				if (resps != null && resps.size() > 0) {
+					interaction.setRequestLabel(getLabel(details));
+				}
+				
+				// Check if fault thrown
+				if (details.getSendCauseException() != null &&
+						details.getSendCauseException().trim().length() > 0) {
+					Raise raise=new Raise();
+					raise.getRoles().add(new Role(fromRole.getName()));
+					
+					TypeReference tref=new TypeReference();
+					tref.setLocalpart(XMLUtils.getLocalname(details.getSendCauseException()));
+					raise.setType(tref);
+					
+					cb.getContents().add(raise);
+				}
+				
+				if (details.getReceiveCauseException() != null &&
+						details.getReceiveCauseException().trim().length() > 0) {
+					Raise raise=new Raise();
+					raise.getRoles().add(new Role(toRole.getName()));
+					
+					TypeReference tref=new TypeReference();
+					tref.setLocalpart(XMLUtils.getLocalname(details.getReceiveCauseException()));
+					raise.setType(tref);
+					
+					cb.getContents().add(raise);
+				}
+			} else {
+				interaction.setFromRole(toRole);
+				interaction.setToRole(fromRole);
+				
+				if (details.getReceiveVariable() != null) {
+					org.scribble.conversation.model.Variable var=
+							new org.scribble.conversation.model.Variable();
+					var.setName(details.getReceiveVariable().getName());
+					interaction.setFromVariable(var);
+				}
+				
+				if (details.getSendVariable() != null) {
+					org.scribble.conversation.model.Variable var=
+							new org.scribble.conversation.model.Variable();
+					var.setName(details.getSendVariable().getName());
+					interaction.setToVariable(var);
+				}
+				
+				if (details.getAction() == ExchangeActionType.RESPOND) {
+					interaction.setReplyToLabel(getLabel(details));
+				}
+
+				// Check if fault thrown
+				if (details.getSendCauseException() != null &&
+						details.getSendCauseException().trim().length() > 0) {
+					Raise raise=new Raise();
+					raise.getRoles().add(new Role(toRole.getName()));
+					
+					TypeReference tref=new TypeReference();
+					tref.setLocalpart(XMLUtils.getLocalname(details.getSendCauseException()));
+					raise.setType(tref);
+					
+					cb.getContents().add(raise);
+				}
+				
+				if (details.getReceiveCauseException() != null &&
+						details.getReceiveCauseException().trim().length() > 0) {
+					Raise raise=new Raise();
+					raise.getRoles().add(new Role(fromRole.getName()));
+					
+					TypeReference tref=new TypeReference();
+					tref.setLocalpart(XMLUtils.getLocalname(details.getReceiveCauseException()));
+					raise.setType(tref);
+					
+					cb.getContents().add(raise);
+				}
+			}
+			
+			// Convert 'after' send and receive record details
+			for (int i=0; i < details.getSendRecordDetails().size(); i++) {
+				RecordDetails rd=details.getSendRecordDetails().get(i);
+				
+				if (rd.getWhen() == WhenType.AFTER) {
+					String fromRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+							fromRole.getName():toRole.getName());
+					
+					// Define record expression
+					Assignment assign=new Assignment();
+					
+					assign.getSource().setComponentURI(
+							CDLTypeUtil.getURIFragment(rd));
+					
+					// Set role
+					Role role=new Role(fromRoleName);
+					
+					assign.getRoles().add(role);
+					
+					// Set variable
+					org.scribble.conversation.model.Variable var=
+							new org.scribble.conversation.model.Variable();
+					var.setName(rd.getTargetVariable().getName());
+					
+					assign.setVariable(var);
+					
+					org.scribble.expression.xpath.model.XPathExpression expr=
+						new org.scribble.expression.xpath.model.XPathExpression();
+					
+					if (rd.getSourceExpression() != null) {
+						expr.setQuery(rd.getSourceExpression());
+					} else if (rd.getSourceVariable() != null) {
+						expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+					}
+					
+					assign.setExpression(expr);
+					
+					cb.getContents().add(assign);
+										
+					// Check for cause exception
+					if (rd.getCauseException() != null &&
+							rd.getCauseException().trim().length() > 0) {
+						
+						Raise raise=new Raise();
+						raise.getRoles().add(new Role(fromRoleName));
+						
+						TypeReference tref=new TypeReference();
+						tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+						raise.setType(tref);
+						
+						cb.getContents().add(raise);
+					}
+				}
+			}
+			
+			for (int i=0; i < details.getReceiveRecordDetails().size(); i++) {
+				RecordDetails rd=details.getReceiveRecordDetails().get(i);
+				
+				if (rd.getWhen() == WhenType.AFTER) {
+					String toRoleName=(details.getAction() == ExchangeActionType.REQUEST?
+							toRole.getName():fromRole.getName());
+					
+					// Define record expression
+					Assignment assign=new Assignment();
+					
+					assign.getSource().setComponentURI(
+							CDLTypeUtil.getURIFragment(rd));
+					
+					// Set role
+					Role role=new Role(toRoleName);
+					
+					assign.getRoles().add(role);
+					
+					// Set variable
+					org.scribble.conversation.model.Variable var=
+							new org.scribble.conversation.model.Variable();
+					var.setName(rd.getTargetVariable().getName());
+					
+					assign.setVariable(var);
+					
+					// If target variable is a channel, then make explicit
+					if (rd.getTargetVariable().getType() instanceof ChannelType) {
+						Object state=context.getState(rd.getTargetVariable().getName());
+						
+						if (state == null) {
+							Channel newch=new Channel();
+							newch.setName(rd.getTargetVariable().getName());
+							
+							context.setState(newch.getName(), newch);
+							
+							//
+						}
+					}
+					
+					// Convert source expression
+					org.scribble.expression.xpath.model.XPathExpression expr=
+						new org.scribble.expression.xpath.model.XPathExpression();
+					
+					if (rd.getSourceExpression() != null) {
+						expr.setQuery(rd.getSourceExpression());
+					} else if (rd.getSourceVariable() != null) {
+						expr.setQuery("cdl:getVariable('"+rd.getSourceVariable().getName()+"','','')");
+					}
+					
+					assign.setExpression(expr);
+					
+					cb.getContents().add(assign);
+					
+					// Check for cause exception
+					if (rd.getCauseException() != null &&
+							rd.getCauseException().trim().length() > 0) {
+						
+						Raise raise=new Raise();
+						raise.getRoles().add(new Role(toRoleName));
+						
+						TypeReference tref=new TypeReference();
+						tref.setLocalpart(XMLUtils.getLocalname(rd.getCauseException()));
+						raise.setType(tref);
+						
+						cb.getContents().add(raise);
+					}
+				}
+			}
+
+			cbs.add(cb);
+		}
+		
+		if (cbs.size() > 2) {
+			block.getContents().addAll(cbs.remove(0).getContents());
+			
+			If choice=new If();
+			
+			choice.getRoles().add(new Role(toRole.getName()));
+			
+			for (int i=0; i < cbs.size(); i++) {
+				ConditionalBlock cb=cbs.get(i);
+				
+				choice.getConditionalBlocks().add(cb);
+			}
+			
+			block.getContents().add(choice);			
+		} else {
+			for (int i=0; i < cbs.size(); i++) {
+				ConditionalBlock cb=cbs.get(i);
+				block.getContents().addAll(cb.getContents());
+			}
+		}
+
+		return(ret);
+	}
+	
+	/**
+	 * This method creates a label appropriate for the request
+	 * response correlation associated with the supplied exchange.
+	 * 
+	 * @param details The exchange
+	 * @return The label
+	 */
+	protected String getLabel(ExchangeDetails details) {
+		String ret=null;
+		
+		if (details.getInteraction() != null) {
+			ret = details.getInteraction().getOperation();
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the interface name associated with the
+	 * supplied role type.
+	 * 
+	 * @param interaction The interaction
+	 * @return The interface name
+	 */
+	protected String getInterfaceName(org.pi4soa.cdl.Interaction interaction) {
+		String ret=null;
+		
+		if (interaction != null) {
+			String intfName=getInterface(interaction);
+			
+			String ns=CDLTypeUtil.getNamespace(intfName, interaction, true);
+			String lp=XMLUtils.getLocalname(intfName);
+			
+			ret = NameSpaceUtil.getFullyQualifiedName(ns, lp);
+		}
+		
+		return(ret);
+	}
+	
+	/**
+	 * This method returns the interaction's interface.
+	 * 
+	 * @param interaction The interaction
+	 * @return The interface
+	 */
+	public static String getInterface(Interaction interaction) {
+		String ret=null;
+			
+		if (interaction != null &&
+				interaction.getChannelVariable() != null &&
+				interaction.getChannelVariable().getType() instanceof
+						ChannelType) {
+			ChannelType ctype=(ChannelType)
+					interaction.getChannelVariable().getType();
+			
+			if (ctype.getBehavior() != null) {
+				ret = ctype.getBehavior().getInterface();
+				
+				if (NamesUtil.isSet(ret)==false) {
+					ret = ctype.getBehavior().getName();
+				}
+			} else if (ctype.getRoleType() != null) {
+				
+				// Attempt to find default behavior
+				org.pi4soa.cdl.Behavior behavior=
+					ctype.getRoleType().getBehavior(null);
+				
+				if (behavior != null) {
+					ret = behavior.getInterface();
+					
+					if (NamesUtil.isSet(ret)==false) {
+						ret = behavior.getName();
+					}
+				}
+			}
+		}
+		
+		return(ret);
+	}
+
+	private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConversationModelConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,177 @@
+/*
+ * 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:
+ * 31 Jul 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class ConversationModelConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == ConversationModel.class &&
+				cdlType instanceof org.pi4soa.cdl.Package);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		ConversationModel ret=new ConversationModel();
+		org.pi4soa.cdl.Package cdlpack=(org.pi4soa.cdl.Package)cdlType;
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(cdlpack));
+			
+		ret.setNamespace(getNamespace(cdlpack));
+		
+		// Convert token locators
+		java.util.Iterator<TokenLocator> locators=
+				cdlpack.getTypeDefinitions().getTokenLocators().iterator();
+		
+		while (locators.hasNext()) {
+			TokenLocator locator=locators.next();
+			
+			IdentityLocator idLocator=new IdentityLocator();
+			idLocator.setLocator(locator.getToken().getName(),
+						locator.getQuery());
+			
+			TypeReference typeRef=ConverterUtil.getTypeReference(locator.getInformationType());
+			idLocator.setType(typeRef);
+			
+			ret.getIdentityLocators().add(idLocator);
+		}
+		
+		// Convert root choreography
+		java.util.Iterator<org.pi4soa.cdl.Choreography> iter=
+					cdlpack.getChoreographies().iterator();
+		org.pi4soa.cdl.Choreography choreo=null;
+	
+		while (choreo == null && iter.hasNext()) {
+			choreo = iter.next();
+			
+			if (choreo.getRoot() != Boolean.TRUE) {
+				choreo = null;
+			}
+		}
+			
+		ConverterRule rule=ConverterRuleFactory.getConverter(Conversation.class,
+					choreo);
+		
+		if (rule != null) {
+			ret.setConversation((Conversation)rule.convert(context,
+					Conversation.class, choreo));
+		} else {
+			logger.severe("Failed to find conversation conversion rule");
+		}
+		
+		// Clear the inner definition for any Compose activities
+		// The inner definitions are temporarily established to
+		// help internal analysis, e.g. to determine initiator
+		// roles
+		for (int i=0; i < context.getComposeActivities().size(); i++) {
+			// Save parent
+			Definition defn=context.getComposeActivities().get(i).getInlineDefinition();
+			ModelObject parent=defn.getParent();
+			
+			context.getComposeActivities().get(i).setInlineDefinition(null);
+			
+			// Re-establish parent
+			defn.setParent(parent);
+		}
+		
+		return(ret);
+	}
+
+
+	/**
+	 * This method generates a namespace associated with
+	 * the supplied CDL package.
+	 * 
+	 * @param cdlpack The choreography package
+	 * @return The namespace
+	 */
+	protected static org.scribble.model.Namespace getNamespace(
+							org.pi4soa.cdl.Package cdlpack) {
+		org.scribble.model.Namespace ret=new org.scribble.model.Namespace();
+		
+		String ns=cdlpack.getTargetNamespace()+"/"+cdlpack.getName();
+		
+		if (ns.startsWith("http://")) {
+			ns = ns.substring(7);
+		}
+		
+		if (ns.startsWith("www.")) {
+			ns = ns.substring(4);
+		}
+		
+		java.util.StringTokenizer st=new java.util.StringTokenizer(ns, "/");
+		boolean f_first=true;
+		String namespace=null;
+		
+		while (st.hasMoreTokens()) {
+			String token=st.nextToken();
+			
+			if (f_first) {
+				java.util.StringTokenizer innerst=
+						new java.util.StringTokenizer(token, ".");
+				while (innerst.hasMoreTokens()) {
+					if (namespace == null) {
+						namespace = innerst.nextToken();
+					} else {
+						namespace = innerst.nextToken()+"."+namespace;
+					}
+				}
+				
+				f_first = false;
+			} else {
+				namespace += "."+token;
+			}
+		}
+		
+		if (namespace != null) {
+			ret.setName(namespace.toLowerCase());
+		}
+		
+		return(ret);
+	}
+
+	private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterContext.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterContext.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterContext.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,113 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public interface ConverterContext {
+
+	/**
+	 * This method returns the source model reference.
+	 * 
+	 * @return The source model reference
+	 */
+	public ModelReference getSource();
+	
+	/**
+	 * This method returns the declaration associated
+	 * with the supplied name.
+	 * 
+	 * @param name The name
+	 * @return The declaration, or null if not found
+	 */
+	public Object getState(String name);
+	
+	/**
+	 * This method sets the declaration associated with
+	 * the supplied name.
+	 * 
+	 * @param name The name
+	 * @param decl The declaration
+	 */
+	public void setState(String name, Object decl);
+	
+	/**
+	 * This method pushes the scope, to clear the current
+	 * state associated with a parent scope.
+	 */
+	public void pushScope();
+	
+	/**
+	 * This method pops the scope associated with a parent
+	 * conversation.
+	 * 
+	 */
+	public void popScope();
+	
+	/**
+	 * This method pushes the current state onto a stack,
+	 * to create a local scope where further roles or
+	 * variables may be declared.
+	 */
+	public void pushState();
+	
+	/**
+	 * This method pops a previous state from the stack
+	 * to clear any local declarations made within a
+	 * local scope as part of a conversation definition.
+	 */
+	public void popState();
+	
+	/**
+	 * This method adds a conversation to the context,
+	 * for use when processing activities within its
+	 * scope.
+	 * 
+	 * @param conv The conversation
+	 */
+	public void addConversation(Conversation conv);
+	
+	/**
+	 * This method removes the conversation from the
+	 * context.
+	 * 
+	 * @param conv The conversation
+	 */
+	public void removeConversation(Conversation conv);
+	
+	/**
+	 * This method retrieves the conversation associated
+	 * with the supplied model reference.
+	 * 
+	 * @param ref The model reference
+	 * @return The conversation
+	 */
+	public Conversation getConversation(ModelReference ref);
+
+	/**
+	 * This method returns the list of Compose activities
+	 * within the model.
+	 * 
+	 * @return The list of compose activities
+	 */
+	public java.util.List<Compose> getComposeActivities();
+	
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRule.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRule.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRule.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+/**
+ * This interface represents a CDM to Scribble conversation
+ * rule.
+ */
+public interface ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						org.pi4soa.cdl.CDLType cdlType);
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public org.scribble.model.ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, org.pi4soa.cdl.CDLType cdlType);
+	
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterRuleFactory.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,63 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+/**
+ * This class represents a factory for converter rules.
+ */
+public class ConverterRuleFactory {
+
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converter rule, or null if not found
+	 */
+	public static ConverterRule getConverter(Class<?> scribbleType,
+						org.pi4soa.cdl.CDLType cdlType) {
+		ConverterRule ret=null;
+		
+		for (int i=0; ret == null && i < m_rules.length; i++) {
+			if (m_rules[i].isSupported(scribbleType, cdlType)) {
+				ret = m_rules[i];
+			}
+		}
+		
+		return(ret);
+	}
+	
+	private static ConverterRule[] m_rules={
+		new ConversationModelConverterRuleImpl(),
+		new ConversationConverterRuleImpl(),
+		new ParallelConverterRuleImpl(),
+		new IfOrWhenConverterRuleImpl(),
+		new IfConverterRuleImpl(),
+		new WhenConverterRuleImpl(),
+		new WhileConverterRuleImpl(),
+		new ConversationInteractionConverterRuleImpl(),
+		new FinalizeConverterRuleImpl(),
+		new FinalizerHandlerConverterRuleImpl(),
+		new AssignConverterRuleImpl(),
+		new SequenceConverterRuleImpl(),
+		new PerformConverterRuleImpl()
+	};
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterUtil.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterUtil.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ConverterUtil.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,63 @@
+/*
+ * 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:
+ * 31 Jul 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.scribble.model.*;
+
+/**
+ * This class defines some converter utility functions.
+ */
+public class ConverterUtil {
+
+	/**
+	 * This method converts the supplied information type into a
+	 * type reference.
+	 * 
+	 * @param infoType The information type
+	 * @return The type reference
+	 */
+	public static TypeReference getTypeReference(org.pi4soa.cdl.InformationType infoType) {
+		TypeReference ret=new TypeReference();
+		
+		// TODO: Establish 'implements' dependency between
+		// XML type and an abstract type derived from the
+		// XML namespace and localpart.
+		
+		org.pi4soa.common.xml.XMLPrefixResolver resolver=
+			org.pi4soa.cdl.util.CDLTypeUtil.getPrefixResolver(infoType.getPackage());
+		String typeName=null;
+		
+		// TODO: Need to have general way to convert
+		// namespace scoped type into a type reference
+		
+		if (org.pi4soa.common.util.NamesUtil.isSet(infoType.getTypeName())) {
+			typeName = infoType.getTypeName();
+		} else if (org.pi4soa.common.util.NamesUtil.isSet(infoType.getElementName())) {
+			typeName = infoType.getElementName();
+		}
+		
+		if (typeName != null) {
+			ret.setLocalpart(org.pi4soa.common.xml.XMLUtils.getLocalname(typeName));
+			ret.setNamespace(org.pi4soa.common.xml.XMLUtils.getNamespace(typeName, resolver, null));
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/DefaultConverterContext.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,184 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+import org.scribble.util.Scope;
+
+import org.scribble.conversation.model.Compose;
+import org.scribble.conversation.model.Conversation;
+import org.scribble.model.*;
+
+/**
+ * The default implementation of the converter context.
+ */
+public class DefaultConverterContext implements ConverterContext {
+
+	/**
+	 * Default constructor.
+	 */
+	public DefaultConverterContext() {
+	}
+	
+	/**
+	 * This is the constructor for the converter context, initialized
+	 * with the source reference.
+	 * 
+	 * @param ref The source model reference
+	 */
+	public DefaultConverterContext(ModelReference ref) {
+		m_source = ref;
+	}
+	
+	/**
+	 * This method returns the source model reference.
+	 * 
+	 * @return The source model reference
+	 */
+	public ModelReference getSource() {
+		return(m_source);
+	}
+	
+	/**
+	 * This method returns the declaration associated
+	 * with the supplied name.
+	 * 
+	 * @param name The name
+	 * @return The declaration, or null if not found
+	 */
+	public Object getState(String name) {
+		return(m_scope.getState(name));
+	}
+	
+	/**
+	 * This method sets the declaration associated with
+	 * the supplied name.
+	 * 
+	 * @param name The name
+	 * @param decl The declaration
+	 */
+	public void setState(String name, Object decl) {
+		m_scope.setState(name, decl);
+	}
+	
+	/**
+	 * This method pushes the current state onto a stack.
+	 */
+	public void pushState() {
+		m_scope.pushState();
+	}
+	
+	/**
+	 * This method pops the current state from the stack.
+	 */
+	public void popState() {
+		m_scope.popState();
+	}
+		
+	/**
+	 * This method pushes the current scope onto a stack.
+	 */
+	public void pushScope() {
+		m_scopeStack.add(0, m_scope);
+		m_scope = new Scope();
+	}
+	
+	/**
+	 * This method pops the current scope from the stack.
+	 */
+	public void popScope() {
+		if (m_scopeStack.size() > 0) {
+			m_scope = m_scopeStack.remove(0);
+		} else {
+			logger.severe("No state entry to pop from stack");
+		}
+	}
+	
+	/**
+	 * This method adds a conversation to the context,
+	 * for use when processing activities within its
+	 * scope.
+	 * 
+	 * @param conv The conversation
+	 */
+	public void addConversation(Conversation conv) {
+		m_conversations.add(conv);
+	}
+	
+	/**
+	 * This method removes the conversation from the
+	 * context.
+	 * 
+	 * @param conv The conversation
+	 */
+	public void removeConversation(Conversation conv) {
+		m_conversations.remove(conv);
+	}
+	
+	/**
+	 * This method retrieves the conversation associated
+	 * with the supplied model reference.
+	 * 
+	 * @param ref The model reference
+	 * @return The conversation
+	 */
+	public Conversation getConversation(ModelReference ref) {
+		Conversation ret=null;
+		
+		for (int i=0; ret == null && i < m_conversations.size(); i++) {
+			Conversation subconv=(Conversation)
+							m_conversations.get(i);
+
+			if (subconv.getLocatedName() != null &&
+					subconv.getLocatedName().getName() != null &&
+						ref.getAlias().equals(
+					subconv.getLocatedName().getName()) &&
+						((ref.getLocatedRole() == null &&
+					subconv.getLocatedName().getRole() == null) ||
+						((ref.getLocatedRole() != null &&
+					subconv.getLocatedName().getRole() != null &&
+						ref.getLocatedRole().equals(
+					subconv.getLocatedName().getRole().getName()))))) {
+			
+				ret = subconv;
+			}
+		}
+
+		return(ret);
+	}
+
+	/**
+	 * This method returns the list of Compose activities
+	 * within the model.
+	 * 
+	 * @return The list of compose activities
+	 */
+	public java.util.List<Compose> getComposeActivities() {
+		return(m_composeActivities);
+	}
+	
+	private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+
+	private ModelReference m_source=null;
+	private Scope m_scope=new Scope();
+	private java.util.List<Scope> m_scopeStack=new java.util.Vector<Scope>();
+	private java.util.List<Compose> m_composeActivities=new java.util.Vector<Compose>();
+	private java.util.List<Conversation> m_conversations=new java.util.Vector<Conversation>();
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizeConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,95 @@
+/*
+ * 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:
+ * 1 Jun 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class FinalizeConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.Finalize);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.conversation.model.Run ret=
+					new org.scribble.conversation.model.Run();
+		org.pi4soa.cdl.Finalize cdl=(org.pi4soa.cdl.Finalize)cdlType;
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(cdl));
+
+		ConversationReference ref=new ConversationReference();
+		ref.setLocalpart(cdl.getChoreography().getName()+"_"+cdl.getFinalizer().getName());
+		ref.setInner(true);
+		
+		ret.setReference(ref);
+		
+		// Find conversation related to reference, and use
+		// as inner definition initially - to help with
+		// subsequent processing (e.g. locating initiator
+		// roles). The inner definition will be cleared when
+		// the model is fully converted.
+		Conversation conv=context.getConversation(ref);
+		
+		if (conv != null) {
+			ret.setInlineDefinition(conv);
+			context.getComposeActivities().add(ret);
+		
+			// Bind roles
+			java.util.List<Role> roles=conv.getRoles();
+			
+			for (int i=0; i < roles.size(); i++) {
+				Role role=roles.get(i);
+				
+				Object decl=context.getState(role.getName());
+				
+				if (decl instanceof Declaration) {
+					ret.getBindings().add(new DeclarationBinding((Declaration)decl, role.getName()));
+				}
+			}
+		}
+				
+		return(ret);
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/FinalizerHandlerConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2005-9 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:
+ * 1 Jun 2009 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.Interaction;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.pi4soa.common.util.NamesUtil;
+import org.pi4soa.common.xml.XMLUtils;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.*;
+
+public class FinalizerHandlerConverterRuleImpl implements ConverterRule {
+
+	private static final String CONVERSATION_TYPE = "conversationType";
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == Conversation.class &&
+				cdlType instanceof FinalizerHandler);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		Conversation ret=new Conversation();
+		FinalizerHandler choreo=(FinalizerHandler)cdlType;
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(choreo));
+			
+		context.pushScope();
+		
+		LocatedName modelName=new LocatedName();
+		modelName.setName(choreo.getEnclosingChoreography().getName()+"_"+choreo.getName());
+		
+		ret.setLocatedName(modelName);
+		
+		// Define roles
+		defineRoles(context, choreo, ret);
+		
+		// Convert variables
+		convertVariables(context, choreo, ret.getBlock());
+		
+		// Define identities
+		convertIdentities(context, choreo, ret);
+		
+		// Process all of the activities within the
+		// choreography
+		convertActivities(context, choreo.getActivities(), ret.getBlock());
+
+		context.popScope();
+		
+		return(ret);
+	}
+
+	
+	protected void defineRoles(ConverterContext context,
+			final FinalizerHandler choreo, Conversation conv) {
+	
+		final java.util.List<ParticipantType> partTypes=new java.util.Vector<ParticipantType>();
+		final java.util.List<Participant> partInstances=new java.util.Vector<Participant>();
+		
+		choreo.visit(new DefaultCDLVisitor() {
+			
+			public void interaction(Interaction interaction) {
+				
+				if (interaction.getEnclosingChoreography() != choreo.getEnclosingChoreography()) {
+					return;
+				}
+				
+				if (interaction.getFromParticipant() != null) {
+					if (partInstances.contains(interaction.getFromParticipant()) == false) {
+						partInstances.add(interaction.getFromParticipant());
+					}
+				} else {
+					ParticipantType ptype=
+						org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+								interaction.getFromRoleType());
+					
+					if (ptype != null &&
+							partTypes.contains(ptype) == false) {
+						partTypes.add(ptype);
+					}
+				}
+				
+				if (interaction.getToParticipant() != null) {
+					if (partInstances.contains(interaction.getToParticipant()) == false) {
+						partInstances.add(interaction.getToParticipant());
+					}
+				} else {
+					ParticipantType ptype=
+						org.pi4soa.cdl.util.PackageUtil.getParticipantForRoleType(
+								interaction.getToRoleType());
+					
+					if (ptype != null &&
+							partTypes.contains(ptype) == false) {
+						partTypes.add(ptype);
+					}
+				}
+			}
+		});
+		
+		// Define roles
+		java.util.Iterator<Participant> piter=partInstances.iterator();
+		
+		RoleList roleList=null;
+		
+		while (piter.hasNext()) {
+			Role role=new Role();
+			Participant pinst=piter.next();
+			role.setName(pinst.getName());
+			
+			if (roleList == null) {
+				roleList = new RoleList();
+				conv.getBlock().getContents().add(roleList);
+			}
+			
+			roleList.getRoles().add(role);
+			
+			context.setState(role.getName(), role);
+		}
+
+		java.util.Iterator<ParticipantType> ptiter=partTypes.iterator();
+
+		/*
+		if (choreo.getRoot() != Boolean.TRUE) {
+			roleList = null;
+		} else {
+			ptiter = choreo.getPackage().getTypeDefinitions().getParticipantTypes().iterator();
+		}
+		*/
+	
+		while (ptiter.hasNext()) {
+			Role role=new Role();
+			ParticipantType ptype=ptiter.next();
+			role.setName(ptype.getName());
+			
+			if (roleList == null) {
+				roleList = new RoleList();
+				
+				roleList.setOpen(choreo.getEnclosingChoreography().getRoot() != Boolean.TRUE);
+				
+				conv.getBlock().getContents().add(roleList);
+			}
+			
+			roleList.getRoles().add(role);
+			
+			context.setState(role.getName(), role);
+		}
+	}
+	
+	protected void convertVariables(ConverterContext context,
+			FinalizerHandler choreo, Block block) {
+		
+		java.util.List<org.pi4soa.cdl.Variable> vars=
+					choreo.getEnclosingChoreography().getVariableDefinitions();
+		
+		for (int i=0; i < vars.size(); i++) {
+			org.pi4soa.cdl.Variable var=(org.pi4soa.cdl.Variable)vars.get(i);
+			
+			if (var.getType() instanceof InformationType) {				
+				java.util.List<RoleType> roleTypes=var.getRoleTypes();
+				
+				if (roleTypes.size() == 0) {
+					roleTypes = choreo.getPackage().getTypeDefinitions().getRoleTypes();
+				}
+				
+				VariableList vlist=new VariableList();
+				TypeReference ref=new TypeReference();
+				
+				String qname=((InformationType)var.getType()).getElementName();
+				
+				if (NamesUtil.isSet(qname)==false) {
+					qname=((InformationType)var.getType()).getTypeName();
+				}
+				
+				ref.setNamespace(CDLTypeUtil.getNamespace(qname, var));
+				ref.setLocalpart(XMLUtils.getLocalname(qname));
+				
+				vlist.setType(ref);
+				
+				/* TODO: See if variables should be located?
+				for (int j=0; j < roleTypes.size(); j++) {
+					org.scribble.conversation.model.Variable newVar=
+						new org.scribble.conversation.model.Variable();
+					
+					newVar.setName(var.getName());
+				}
+				*/
+				
+				org.scribble.conversation.model.Variable newVar=
+					new org.scribble.conversation.model.Variable();
+				
+				newVar.setName(var.getName());
+				
+				vlist.getVariables().add(newVar);
+				
+				block.getContents().add(vlist);
+			}
+		}
+	}
+	
+	protected void convertActivities(ConverterContext context,
+				java.util.List<org.pi4soa.cdl.Activity> acts, Block block) {
+		
+		java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+						acts.iterator();
+		
+		while (actiter.hasNext()) {
+			org.pi4soa.cdl.Activity act=actiter.next();
+			
+			ConverterRule rule=ConverterRuleFactory.getConverter(
+					org.scribble.model.Activity.class, act);
+			
+			if (rule != null) {
+				org.scribble.model.Activity activity=
+					(org.scribble.model.Activity)
+					rule.convert(context,
+							org.scribble.model.Activity.class, act);
+				
+				if (activity != null) {
+					
+					if (activity instanceof Block) {
+						block.getContents().addAll(((Block)activity).getContents());
+					} else {
+						block.getContents().add(activity);
+					}
+				}
+			}
+		}
+	}
+	
+	protected void convertIdentities(ConverterContext context,
+			FinalizerHandler choreo, Conversation conv) {
+		
+		// Define identities
+		java.util.List<org.pi4soa.cdl.Variable> vars=
+					choreo.getEnclosingChoreography().getVariableDefinitions();
+		java.util.List<org.scribble.conversation.model.Identity> ids=
+			new java.util.Vector<org.scribble.conversation.model.Identity>();
+
+		for (int i=0; i < vars.size(); i++) {
+			if (vars.get(i).getType() instanceof org.pi4soa.cdl.ChannelType) {
+				org.pi4soa.cdl.ChannelType ctype=
+						(org.pi4soa.cdl.ChannelType)vars.get(i).getType();
+				
+				java.util.Iterator<org.pi4soa.cdl.Identity> cids=
+						ctype.getIdentities().iterator();
+				
+				while (cids.hasNext()) {
+					org.pi4soa.cdl.Identity cid=cids.next();
+					org.scribble.conversation.model.Identity id=
+						new org.scribble.conversation.model.Identity();
+					
+					if (cid.getType() == KeyType.ASSOCIATION) {
+						id.setIdentityType(IdentityType.Association);
+					} else if (cid.getType() == KeyType.DERIVED) {
+						id.setIdentityType(IdentityType.Derived);
+					} else {
+						id.setIdentityType(IdentityType.Primary);
+					}
+					
+					for (int j=0; j < cid.getTokens().size(); j++) {
+						id.getNames().add(cid.getTokens().get(j).getName());
+					}
+					
+					if (ids.contains(id) == false) {
+						ids.add(id);
+					}
+				}
+			}
+		}
+		
+		conv.getIdentities().addAll(ids);		
+	}
+
+	private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,111 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.XPathExpression;
+
+public class IfConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.Conditional);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.conversation.model.If ret=
+				new org.scribble.conversation.model.If();
+		org.pi4soa.cdl.Conditional cdl=(org.pi4soa.cdl.Conditional)cdlType;
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(cdl));
+	
+		ConditionalBlock block=new ConditionalBlock();
+		ret.getConditionalBlocks().add(block);
+		
+		context.pushState();
+		
+		// Set the expression if defined in the 'conditional'
+		if (cdl.getExpression() != null) {
+			XPathExpression exp=new XPathExpression();
+		
+			exp.setQuery(cdl.getExpression());
+		
+			block.setExpression(exp);
+		}
+		
+		// Process all of the activities within the
+		// choreography
+		java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+					cdl.getActivities().iterator();
+		while (actiter.hasNext()) {
+			org.pi4soa.cdl.Activity act=actiter.next();
+			
+			ConverterRule rule=ConverterRuleFactory.getConverter(
+					org.scribble.model.Activity.class, act);
+		
+			if (rule != null) {
+				org.scribble.model.Activity activity=
+					(org.scribble.model.Activity)
+					rule.convert(context,
+							org.scribble.model.Activity.class, act);
+				
+				if (activity != null) {
+					if (activity instanceof Block) {
+						block.getContents().addAll(((Block)activity).getContents());
+					} else {
+						block.getContents().add(activity);
+					}
+				}
+			}
+		}
+		
+		// Get initiator role(s) for first activity in body and
+		// associated with If
+		ret.getRoles().addAll(block.getInitiatorRoles());
+		
+		context.popState();
+		
+		return(ret);
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/IfOrWhenConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,152 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class IfOrWhenConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.Choice);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.model.Activity ret=null;
+		org.pi4soa.cdl.Choice cdl=(org.pi4soa.cdl.Choice)cdlType;
+		java.util.List<ConditionalBlock> blocks=new java.util.Vector<ConditionalBlock>();
+		boolean f_when=false;
+		
+		// Process all of the activities within the
+		// choreography
+		java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+					cdl.getActivities().iterator();
+		while (actiter.hasNext()) {
+			org.pi4soa.cdl.Activity act=actiter.next();
+			
+			ConverterRule rule=ConverterRuleFactory.getConverter(
+					org.scribble.model.Activity.class, act);
+		
+			if (rule != null) {
+				
+				context.pushState();
+				
+				org.scribble.model.Activity activity=
+					(org.scribble.model.Activity)
+					rule.convert(context,
+							org.scribble.model.Activity.class, act);
+				
+				if (activity != null) {
+					if (activity instanceof If) {
+						blocks.addAll(((If)activity).getConditionalBlocks());
+					} else if (activity instanceof 
+								org.scribble.conversation.model.When) {
+						blocks.addAll(((org.scribble.conversation.model.When)activity).getConditionalBlocks());
+						f_when = true;
+					} else {
+						ConditionalBlock block=new ConditionalBlock();
+						
+						if (activity instanceof Block) {
+							block.getContents().addAll(((Block)activity).getContents());
+						} else {
+							block.getContents().add(activity);							
+						}
+						
+						blocks.add(block);
+					}
+				}
+				
+				context.popState();
+			}
+		}
+		
+		// Build up initiator role list
+		java.util.List<Role> roles=null;
+		
+		for (int i=0; i < blocks.size(); i++) {
+			Block b=blocks.get(i);
+			
+			java.util.List<Role> blockRoles=
+					b.getInitiatorRoles();
+				
+			if (blockRoles != null) {
+				if (roles == null) {
+					roles = blockRoles;
+				} else {
+					for (int j=0; j < blockRoles.size(); j++) {
+						if (roles.contains(blockRoles.get(j)) == false) {
+							roles.add(blockRoles.get(j));
+						}
+					}
+				}
+			}
+		}
+		
+		if (f_when) {
+			ret = new org.scribble.conversation.model.When();
+			((org.scribble.conversation.model.When)ret).
+					getConditionalBlocks().addAll(blocks);
+			
+			if (roles != null) {
+				((org.scribble.conversation.model.When)ret).
+						getRoles().addAll(roles);
+			}
+		} else {
+			ret = new org.scribble.conversation.model.If();
+			((org.scribble.conversation.model.If)ret).
+					getConditionalBlocks().addAll(blocks);
+			
+			if (roles != null) {
+				((org.scribble.conversation.model.If)ret).
+						getRoles().addAll(roles);
+			}
+		}
+		
+		if (ret != null) {
+			ret.getSource().setComponentURI(
+					CDLTypeUtil.getURIFragment(cdl));
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/ParallelConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,96 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+
+public class ParallelConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.Parallel);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.conversation.model.Parallel ret=
+				new org.scribble.conversation.model.Parallel();
+		org.pi4soa.cdl.Parallel cdl=(org.pi4soa.cdl.Parallel)cdlType;
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(cdl));
+
+		// Process all of the activities within the
+		// choreography
+		java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+					cdl.getActivities().iterator();
+		while (actiter.hasNext()) {
+			org.pi4soa.cdl.Activity act=actiter.next();
+			
+			ConverterRule rule=ConverterRuleFactory.getConverter(
+					org.scribble.model.Activity.class, act);
+		
+			if (rule != null) {
+				
+				context.pushState();
+				
+				org.scribble.model.Activity activity=
+					(org.scribble.model.Activity)
+					rule.convert(context,
+							org.scribble.model.Activity.class, act);
+				
+				if (activity != null) {
+					if (activity instanceof Block) {
+						ret.getBlocks().add((Block)activity);
+					} else {
+						Block block=new Block();
+						block.getContents().add(activity);
+						ret.getBlocks().add(block);
+					}
+				}
+				
+				context.popState();
+			}
+		}
+		
+		return(ret);
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/PerformConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,127 @@
+/*
+ * 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:
+ * 27 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import java.util.logging.Logger;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+
+public class PerformConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.Perform);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.conversation.model.Compose ret=null;
+		org.pi4soa.cdl.Perform cdl=(org.pi4soa.cdl.Perform)cdlType;
+		
+		if (cdl.getWaitForCompletion() == Boolean.TRUE) {
+			ret = new org.scribble.conversation.model.Run();
+		} else {
+			ret = new org.scribble.conversation.model.Spawn();
+		}
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(cdl));
+
+		ConversationReference ref=new ConversationReference();
+		ref.setLocalpart(cdl.getChoreography().getName());
+		ref.setInner(true);
+		
+		ret.setReference(ref);
+		
+		// Find conversation related to reference, and use
+		// as inner definition initially - to help with
+		// subsequent processing (e.g. locating initiator
+		// roles). The inner definition will be cleared when
+		// the model is fully converted.
+		Conversation conv=context.getConversation(ref);
+		
+		if (conv != null) {
+			ret.setInlineDefinition(conv);
+			context.getComposeActivities().add(ret);
+		
+			// Bind roles
+			java.util.List<Role> roles=conv.getRoles();
+			
+			for (int i=0; i < roles.size(); i++) {
+				Role role=roles.get(i);
+				
+				Object decl=context.getState(role.getName());
+				
+				if (decl instanceof Declaration) {
+					ret.getBindings().add(new DeclarationBinding((Declaration)decl, role.getName()));
+				}
+			}
+		}
+		
+		// Convert binding parameters
+		java.util.List<BindDetails> bds=cdl.getBindDetails();
+		
+		for (int i=0; i < bds.size(); i++) {
+			
+			// Only convert if a variable, not a channel
+			// TODO: Need to also convert explicit channels
+			if (bds.get(i).getThisVariable() instanceof org.pi4soa.cdl.Variable) {
+				DeclarationBinding db=new DeclarationBinding();
+				
+				Object state=context.getState(bds.get(i).getThisVariable().getName());
+				
+				if (state instanceof Declaration) {
+					db.setDeclaration((Declaration)state);
+					db.setBoundName(bds.get(i).getFreeVariable().getName());
+				
+					ret.getBindings().add(db);
+				} else {
+					logger.finer("State not found for '"+bds.get(i).getThisVariable().getName()+"'");
+				}
+			}
+		}
+				
+		return(ret);
+	}
+	
+	private static Logger logger = Logger.getLogger("org.pi4soa.scribble.cdm.parser.rules");
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/SequenceConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,94 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+
+public class SequenceConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.Sequence);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.model.Block ret=
+				new org.scribble.model.Block();
+		org.pi4soa.cdl.Sequence cdl=(org.pi4soa.cdl.Sequence)cdlType;
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(cdl));
+
+		context.pushState();
+		
+		// Process all of the activities within the
+		// choreography
+		java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+					cdl.getActivities().iterator();
+		while (actiter.hasNext()) {
+			org.pi4soa.cdl.Activity act=actiter.next();
+			
+			ConverterRule rule=ConverterRuleFactory.getConverter(
+					org.scribble.model.Activity.class, act);
+		
+			if (rule != null) {
+				org.scribble.model.Activity activity=
+					(org.scribble.model.Activity)
+					rule.convert(context,
+							org.scribble.model.Activity.class, act);
+				
+				if (activity != null) {
+					if (activity instanceof Block) {
+						ret.getContents().addAll(
+								((Block)activity).getContents());
+					} else {
+						ret.getContents().add(activity);
+					}
+				}
+			}
+		}
+		
+		context.popState();
+		
+		return(ret);
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhenConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,111 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.model.*;
+import org.scribble.conversation.model.*;
+import org.scribble.expression.xpath.model.XPathExpression;
+
+public class WhenConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.When);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.conversation.model.When ret=
+				new org.scribble.conversation.model.When();
+		org.pi4soa.cdl.When cdl=(org.pi4soa.cdl.When)cdlType;
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(cdl));
+
+		ConditionalBlock block=new ConditionalBlock();
+		ret.getConditionalBlocks().add(block);
+		
+		context.pushState();
+		
+		// Set the expression if defined in the 'when'
+		if (cdl.getExpression() != null) {
+			XPathExpression exp=new XPathExpression();
+		
+			exp.setQuery(cdl.getExpression());
+		
+			block.setExpression(exp);
+		}
+				
+		// Process all of the activities within the
+		// choreography
+		java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+					cdl.getActivities().iterator();
+		while (actiter.hasNext()) {
+			org.pi4soa.cdl.Activity act=actiter.next();
+			
+			ConverterRule rule=ConverterRuleFactory.getConverter(
+					org.scribble.model.Activity.class, act);
+		
+			if (rule != null) {
+				org.scribble.model.Activity activity=
+					(org.scribble.model.Activity)
+					rule.convert(context,
+							org.scribble.model.Activity.class, act);
+				
+				if (activity != null) {
+					if (activity instanceof Block) {
+						block.getContents().addAll(((Block)activity).getContents());
+					} else {
+						block.getContents().add(activity);
+					}
+				}
+			}
+		}
+		
+		// Get initiator role(s) for first activity in body and
+		// associated with When
+		ret.getRoles().addAll(block.getInitiatorRoles());
+		
+		context.popState();
+				
+		return(ret);
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/parser/rules/WhileConverterRuleImpl.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,108 @@
+/*
+ * 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:
+ * 6 Jun 2008 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.parser.rules;
+
+import org.pi4soa.cdl.*;
+import org.pi4soa.cdl.util.CDLTypeUtil;
+import org.scribble.expression.xpath.model.XPathExpression;
+import org.scribble.model.*;
+
+public class WhileConverterRuleImpl implements ConverterRule {
+
+	/**
+	 * This method determines whether the rule can be applied
+	 * to the supplied CDL type.
+	 * 
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type
+	 * @return Whether the rule is appropriate to convert
+	 * 					the CDL type
+	 */
+	public boolean isSupported(Class<?> scribbleType,
+						CDLType cdlType) {
+		return(scribbleType == org.scribble.model.Activity.class &&
+				cdlType instanceof org.pi4soa.cdl.While);
+	}
+	
+	/**
+	 * This method converts the supplied CDL type into a
+	 * Scribble model object.
+	 * 
+	 * @param context The converters context
+	 * @param scribbleType The Scribble target type
+	 * @param cdlType The CDL type to be converted
+	 * @return The converted Scribble model object
+	 */
+	public ModelObject convert(ConverterContext context,
+			Class<?> scribbleType, CDLType cdlType) {
+		org.scribble.conversation.model.While ret=
+				new org.scribble.conversation.model.While();
+		org.pi4soa.cdl.While cdl=(org.pi4soa.cdl.While)cdlType;
+		
+		ret.getSource().setComponentURI(
+				CDLTypeUtil.getURIFragment(cdl));
+
+		context.pushState();
+		
+		// Set the expression if defined in the 'while'
+		if (cdl.getExpression() != null &&
+				cdl.getExpression().trim().length() > 0) {
+			XPathExpression exp=new XPathExpression();
+		
+			exp.setQuery(cdl.getExpression());
+		
+			ret.getBlock().setExpression(exp);
+		}
+				
+		// Process all of the activities within the
+		// choreography
+		java.util.Iterator<org.pi4soa.cdl.Activity> actiter=
+					cdl.getActivities().iterator();
+		while (actiter.hasNext()) {
+			org.pi4soa.cdl.Activity act=actiter.next();
+			
+			ConverterRule rule=ConverterRuleFactory.getConverter(
+					org.scribble.model.Activity.class, act);
+		
+			if (rule != null) {
+				org.scribble.model.Activity activity=
+					(org.scribble.model.Activity)
+					rule.convert(context,
+							org.scribble.model.Activity.class, act);
+				
+				if (activity != null) {
+					if (activity instanceof Block) {
+						ret.getBlock().getContents().addAll(((Block)activity).getContents());
+					} else {
+						ret.getBlock().getContents().add(activity);
+					}
+				}
+			}
+		}
+		
+		// Get initiator role(s) for first activity in body and
+		// associated with While
+		ret.getRoles().addAll(ret.getBlock().getInitiatorRoles());
+		
+		context.popState();
+		
+		return(ret);
+	}
+}

Added: trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java	                        (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.pi4soa.cdm/src/java/org/jboss/savara/pi4soa/cdm/validation/TypeReferenceValidationRule.java	2010-11-18 14:07:09 UTC (rev 482)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007 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:
+ * 2 Nov 2007 : Initial version created by gary
+ */
+package org.jboss.savara.pi4soa.cdm.validation;
+
+import org.jboss.savara.pi4soa.cdm.model.CDMNotation;
+import org.scribble.extensions.*;
+import org.scribble.model.*;
+import org.scribble.model.admin.ModelListener;
+import org.scribble.validation.*;
+
+/**
+ * This class implements the validation rule for the
+ * type reference. This rule overrides the type
+ * reference validation in the core scribble plugin.
+ */
+ at RegistryInfo(extension=ValidationRule.class,notation=CDMNotation.NOTATION_CODE)
+public class TypeReferenceValidationRule extends org.scribble.validation.TypeReferenceValidationRule {
+
+	/**
+	 * This is the default constructor.
+	 */
+	public TypeReferenceValidationRule() {
+	}
+
+	/**
+	 * This method determines whether the rule is appropriate for
+	 * the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @return Whether the rule is appropriate
+	 */
+	public boolean isSupported(ModelObject obj) {
+		return(obj.getClass() == TypeReference.class);
+	}
+
+	/**
+	 * This method validates the supplied model object.
+	 * 
+	 * @param obj The model object
+	 * @param context The context
+	 * @param l The listener
+	 */
+	public void validate(ModelObject obj, ValidationContext context,
+			ModelListener l) {
+		// Ignore type references - these will be represented
+		// as XML type or elements
+		
+		// TODO: Eventually may want to validate if the XML
+		// schemas are located in the project
+	}
+}



More information about the savara-commits mailing list