### Eclipse Workspace Patch 1.0
#P org.teiid.designer.relational.ui
Index: plugin.properties
===================================================================
--- plugin.properties	(revision 1356)
+++ plugin.properties	(working copy)
@@ -8,3 +8,4 @@
 
 relationalUiTextImporter = Designer Relational Table Text Importer
 flatFileRelationalModelContributor = Generate File Translator Procedures
+webServiceRelationalModelContributor = Generate Web Service Translator Procedures
Index: src/com/metamatrix/modeler/relational/ui/webservice/WebServiceRelationalModelContributor.java
===================================================================
--- src/com/metamatrix/modeler/relational/ui/webservice/WebServiceRelationalModelContributor.java	(revision 0)
+++ src/com/metamatrix/modeler/relational/ui/webservice/WebServiceRelationalModelContributor.java	(revision 0)
@@ -0,0 +1,242 @@
+package com.metamatrix.modeler.relational.ui.webservice;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.wizard.IWizardPage;
+
+import com.metamatrix.metamodels.relational.Column;
+import com.metamatrix.metamodels.relational.Procedure;
+import com.metamatrix.metamodels.relational.ProcedureParameter;
+import com.metamatrix.metamodels.relational.ProcedureResult;
+import com.metamatrix.metamodels.relational.RelationalFactory;
+import com.metamatrix.metamodels.relational.RelationalPackage;
+import com.metamatrix.modeler.core.ModelerCore;
+import com.metamatrix.modeler.core.ModelerCoreException;
+import com.metamatrix.modeler.core.metamodel.MetamodelDescriptor;
+import com.metamatrix.modeler.core.types.DatatypeManager;
+import com.metamatrix.modeler.core.workspace.ModelResource;
+import com.metamatrix.modeler.core.workspace.ModelWorkspaceException;
+import com.metamatrix.modeler.relational.ui.UiConstants;
+import com.metamatrix.modeler.ui.wizards.INewModelWizardContributor;
+
+public class WebServiceRelationalModelContributor implements INewModelWizardContributor {
+
+
+    public static final String RELATIONAL_PACKAGE_URI	= RelationalPackage.eNS_URI;
+    public static final RelationalFactory factory = RelationalFactory.eINSTANCE;
+    public static final DatatypeManager datatypeManager = ModelerCore.getWorkspaceDatatypeManager();
+    
+    private static boolean isTransactionable = ModelerCore.getPlugin() != null;
+    //
+    // Instance variables:
+    //
+    private IWizardPage[] pages;
+    private WebServiceRelationalModelWizardPage webServiceProcedures;
+    /**
+     * Construct an instance of WebServiceRelationalModelContributor.
+     */
+    public WebServiceRelationalModelContributor() {
+    	super();
+    }
+    
+	@Override
+	public boolean canFinishEarly(IWizardPage theCurrentPage) {
+		return false;
+	}
+
+	@Override
+	public void createWizardPages(ISelection selection,
+			IResource targetResource, IPath targetFilePath,
+			MetamodelDescriptor descriptor, boolean isVirtual) {
+        pages = new IWizardPage[1];
+        webServiceProcedures = new WebServiceRelationalModelWizardPage(
+				"webServiceProceduresPage"); //$NON-NLS-1$
+        pages[0] = webServiceProcedures;
+
+	}
+	
+
+	@Override
+	public void currentPageChanged(IWizardPage page) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void doCancel() {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void doFinish(ModelResource modelResource, IProgressMonitor monitor) {
+		String transactionName = UiConstants.Util.getString("WebServiceRelationalModelContributor.transactionName"); //$NON-NLS-1$
+		boolean started = ModelerCore.startTxn(transactionName, this);
+        boolean succeeded = false;
+		try {
+
+			if( webServiceProcedures.doGenerateInvoke() ) {
+				addInvokeProcedure(modelResource);
+			}
+			
+			if( webServiceProcedures.doGenerateInvokeHttp() ) {
+				addInvokeHttpProcedure(modelResource);
+			}
+	    	
+            succeeded = true;
+        } catch (Exception ex) {
+            String message = UiConstants.Util.getString("WebServiceRelationalModelContributor.doFinishError",     //$NON-NLS-1$
+                                                      modelResource.getItemName()); 
+            UiConstants.Util.log(IStatus.ERROR, ex, message); 
+		} finally {
+			if (started) {
+                if(succeeded) {
+                    ModelerCore.commitTxn();
+                } else {
+                    ModelerCore.rollbackTxn();
+                }
+			}
+		}
+
+	}
+	
+	private void addInvokeProcedure(ModelResource mr) throws ModelerCoreException {
+		EObject stringType = datatypeManager.findDatatype("string"); //$NON-NLS-1$
+		EObject xmlLiteralType = datatypeManager.findDatatype("XMLLiteral"); //$NON-NLS-1$
+		
+    	Procedure proc = factory.createProcedure();
+    	proc.setName("invoke"); //$NON-NLS-1$
+    	ProcedureParameter param = factory.createProcedureParameter();
+    	param.setProcedure(proc);
+    	param.setName("binding"); //$NON-NLS-1$
+    	if( stringType != null) {
+    		param.setType(stringType);
+    	}
+    	
+    	param = factory.createProcedureParameter();
+    	param.setProcedure(proc);
+    	param.setName("action"); //$NON-NLS-1$
+    	if( stringType != null) {
+    		param.setType(stringType);
+    	}
+    	
+    	param = factory.createProcedureParameter();
+    	param.setProcedure(proc);
+    	param.setName("request"); //$NON-NLS-1$
+    	if( xmlLiteralType != null) {
+    		param.setType(xmlLiteralType);
+    	}
+    	
+    	param = factory.createProcedureParameter();
+    	param.setProcedure(proc);
+    	param.setName("endpoint"); //$NON-NLS-1$
+    	if( stringType != null) {
+    		param.setType(stringType);
+    	}
+    	
+    	ProcedureResult result = factory.createProcedureResult();
+    	result.setProcedure(proc);
+    	result.setName("result"); //$NON-NLS-1$
+    	Column column = factory.createColumn();
+    	column.setName("result");
+    	column.setOwner(result);
+    	if( xmlLiteralType != null) {
+    		column.setType(xmlLiteralType);
+    	}
+    	
+    	addValue(mr, proc, getModelResourceContents(mr));
+	}
+	
+	private void addInvokeHttpProcedure(ModelResource mr) throws ModelerCoreException {
+		EObject stringType = datatypeManager.findDatatype("string"); //$NON-NLS-1$
+		EObject blobType = datatypeManager.findDatatype("blob"); //$NON-NLS-1$
+		EObject objectType = datatypeManager.findDatatype("object"); //$NON-NLS-1$
+		
+    	Procedure proc = factory.createProcedure();
+    	proc.setName("invokeHttp"); //$NON-NLS-1$
+    	
+    	ProcedureParameter param = factory.createProcedureParameter();
+    	param.setProcedure(proc);
+    	param.setName("action"); //$NON-NLS-1$
+    	if( stringType != null) {
+    		param.setType(stringType);
+    	}
+    	
+    	param = factory.createProcedureParameter();
+    	param.setProcedure(proc);
+    	param.setName("request"); //$NON-NLS-1$
+    	if( objectType != null) {
+    		param.setType(objectType);
+    	}
+    	
+    	param = factory.createProcedureParameter();
+    	param.setProcedure(proc);
+    	param.setName("endpoint"); //$NON-NLS-1$
+    	if( objectType != null) {
+    		param.setType(stringType);
+    	}
+    	
+    	ProcedureResult result = factory.createProcedureResult();
+    	result.setProcedure(proc);
+    	result.setName("result"); //$NON-NLS-1$
+    	Column column = factory.createColumn();
+    	column.setName("result");
+    	column.setOwner(result);
+    	if( blobType != null) {
+    		column.setType(blobType);
+    	}
+    	
+    	param = factory.createProcedureParameter();
+    	param.setProcedure(proc);
+    	param.setName("contentType"); //$NON-NLS-1$
+    	if( stringType != null) {
+    		param.setType(stringType);
+    	}
+    	
+    	addValue(mr, proc, getModelResourceContents(mr));
+	}
+	
+    private void addValue(final Object owner, final Object value, EList feature) {
+        try {
+            if( isTransactionable ) {
+                ModelerCore.getModelEditor().addValue(owner, value, feature);
+            } else {
+                feature.add(value);
+            }
+        } catch (ModelerCoreException err) {
+            UiConstants.Util.log(IStatus.ERROR, err, 
+            		UiConstants.Util.getString("FlatFileRelationalModelContributor.addValueError", value, owner)); //$NON-NLS-1$
+        }
+    }
+	
+    private EList getModelResourceContents(ModelResource resource ) {
+    	EList eList = null;
+    	
+    	try {
+			eList = resource.getEmfResource().getContents();
+		} catch (ModelWorkspaceException e) {
+			 UiConstants.Util.log(IStatus.ERROR, e, 
+					 UiConstants.Util.getString("FlatFileRelationalModelContributor.getModelContentsError", resource.getItemName())); //$NON-NLS-1$
+		}
+		
+		return eList;
+    }
+
+	@Override
+	public IWizardPage[] getWizardPages() {
+		 return pages;
+	}
+
+	@Override
+	public void inputChanged(ISelection selection, IResource targetResource,
+			MetamodelDescriptor descriptor, boolean isVirtual) {
+		// TODO Auto-generated method stub
+
+	}
+
+}
Index: src/com/metamatrix/modeler/relational/ui/webservice/WebServiceRelationalModelWizardPage.java
===================================================================
--- src/com/metamatrix/modeler/relational/ui/webservice/WebServiceRelationalModelWizardPage.java	(revision 0)
+++ src/com/metamatrix/modeler/relational/ui/webservice/WebServiceRelationalModelWizardPage.java	(revision 0)
@@ -0,0 +1,83 @@
+package com.metamatrix.modeler.relational.ui.webservice;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+import com.metamatrix.modeler.relational.ui.UiConstants;
+import com.metamatrix.ui.internal.util.WidgetFactory;
+
+public class WebServiceRelationalModelWizardPage extends WizardPage implements UiConstants{
+	
+	private Button invokeCB;
+	private Button invokeHttpCB;
+	
+	boolean invokeMethod;
+	boolean invokeHttpMethod;
+	
+	////////////////////////////////////////////////////////////////////////////////
+	// Constructors
+	////////////////////////////////////////////////////////////////////////////////
+	/**
+     * Construct an instance of WebServiceRelationalModelWizardPage.
+     * @param pageName
+     */
+    public WebServiceRelationalModelWizardPage(String pageName) {
+        super(pageName);
+
+        setTitle(Util.getString("WebServiceRelationalModelWizardPage.title")); //$NON-NLS-1$
+        setDescription(Util.getString("WebServiceRelationalModelWizardPage.description")); //$NON-NLS-1$
+    }
+
+	@Override
+	public void createControl(Composite parent) {
+		// 
+		
+        final Composite mainPanel = new Composite(parent, SWT.NONE);
+        mainPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
+        mainPanel.setLayout(new GridLayout(2, false));
+
+        final Group optionsGroup = WidgetFactory.createGroup(mainPanel, 
+        		Util.getString("WebServiceRelationalModelWizardPage.optionsGroup.title"),  //$NON-NLS-1$
+        		GridData.FILL_HORIZONTAL, 2, 1);
+        
+        invokeCB = WidgetFactory.createCheckBox(optionsGroup, "invokeHttp(binding in String, action in STRING, request in OBJECT, endpoint in STRING) returns XML", 0, 2, true); //$NON-NLS-1$
+        invokeCB.addSelectionListener(new SelectionAdapter() {
+
+            @Override
+            public void widgetSelected( final SelectionEvent event ) {
+            	invokeMethod = invokeCB.getSelection();
+            }
+        });
+        
+        invokeHttpCB = WidgetFactory.createCheckBox(optionsGroup, "invokeHttp(action in STRING, request in OBJECT, endpoint in STRING, contentType out STRING) returns BLOB", 0, 2, true); //$NON-NLS-1$
+        invokeHttpCB.addSelectionListener(new SelectionAdapter() {
+
+            @Override
+            public void widgetSelected( final SelectionEvent event ) {
+            	invokeHttpMethod = invokeHttpCB.getSelection();
+            }
+        });
+        
+
+        super.setControl(mainPanel);
+        
+        invokeMethod = invokeCB.getSelection();
+        invokeHttpMethod = invokeHttpCB.getSelection();
+		
+	}
+
+	public boolean doGenerateInvoke() {
+		return invokeMethod;
+	}
+
+	public boolean doGenerateInvokeHttp() {
+		return invokeHttpMethod;
+	}
+}
Index: plugin.xml
===================================================================
--- plugin.xml	(revision 1356)
+++ plugin.xml	(working copy)
@@ -32,4 +32,18 @@
             isVirtual="false">
       </metamodelDescriptorType>
    </extension>
+   <extension
+         id="webServiceRelationalModelContributor"
+         name="%webServiceRelationalModelContributor"
+         point="org.teiid.designer.ui.newModelWizardContributor">
+      <class
+            name="com.metamatrix.modeler.relational.ui.webservice.WebServiceRelationalModelContributor"
+            icon="icons/full/ctool16/newmodel_wiz.gif">
+      </class>
+      <metamodelDescriptorType
+            name="http://www.metamatrix.com/metamodels/Relational"
+            isPhysical="true"
+            isVirtual="false">
+      </metamodelDescriptorType>
+   </extension>
 </plugin>
Index: src/com/metamatrix/modeler/relational/ui/i18n.properties
===================================================================
--- src/com/metamatrix/modeler/relational/ui/i18n.properties	(revision 1356)
+++ src/com/metamatrix/modeler/relational/ui/i18n.properties	(working copy)
@@ -85,7 +85,17 @@
 FlatFileRelationalModelContributor.doFinishError=Error finishing creation of flat file relational procedures for {0}
 FlatFileRelationalModelContributor.addValueError=Error adding {0} as child to {1}
 FlatFileRelationalModelContributor.getModelContentsError=Error finding model contents object for {0}
+FlatFileRelationalModelContributor.transactionName=Generate Flat File Translator Relational Procedures
 
 FlatFileRelationalModelWizardPage.optionsGroup.title=Available File Translator Procedures
 FlatFileRelationalModelWizardPage.title=Generate File Translator Procedures
-FlatFileRelationalModelWizardPage.description=Generate default relational procedures compatible with Teiid File translator. Select desired procedures and 'Finish' 
\ No newline at end of file
+FlatFileRelationalModelWizardPage.description=Generate default relational procedures compatible with Teiid File translator. Select desired procedures and 'Finish'
+
+WebServiceRelationalModelContributor.doFinishError=Error finishing creation of web service relational procedures for {0}
+WebServiceRelationalModelContributor.addValueError=Error adding {0} as child to {1}
+WebServiceRelationalModelContributor.getModelContentsError=Error finding model contents object for {0}
+WebServiceRelationalModelContributor.transactionName=Generate Web Service Translator Relational Procedures
+
+WebServiceRelationalModelWizardPage.optionsGroup.title=Available Web Service Translator Procedures
+WebServiceRelationalModelWizardPage.title=Generate Web Service Translator Procedures
+WebServiceRelationalModelWizardPage.description=Generate default relational procedures compatible with Teiid Web Service translator. Select desired procedures and 'Finish' 
\ No newline at end of file
