// Path: cda/plugins/org.openhealthtools.mdht.uml.cda.core/src/org/openhealthtools/mdht/uml/cda/core/util/CDAModelUtil.java
// public static class FindResourcesByNameVisitor implements IResourceVisitor {
// 
// 	private String resourceName;
// 
// 	private ArrayList<IResource> resources = new ArrayList<IResource>();
// 
// 	/**
// 	 * @return the resources
// 	 */
// 	public ArrayList<IResource> getResources() {
// 		return resources;
// 	}
// 
// 	/**
// 	 * @param resourceName
// 	 */
// 	public FindResourcesByNameVisitor(String resourceName) {
// 		super();
// 		this.resourceName = resourceName;
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 *
// 	 * @see org.eclipse.core.resources.IResourceVisitor#visit(org.eclipse.core.resources.IResource)
// 	 */
// 	public boolean visit(IResource arg0) throws CoreException {
// 
// 		if (resourceName != null && resourceName.equals(arg0.getName())) {
// 			resources.add(arg0);
// 		}
// 		return true;
// 	}
// 
// }


import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationOperation;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
import org.eclipse.ui.ide.IDE;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.resource.UML22UMLResource;
import org.openhealthtools.mdht.uml.cda.core.profile.CDATemplate;
import org.openhealthtools.mdht.uml.cda.core.profile.CodegenSupport;
import org.openhealthtools.mdht.uml.cda.core.util.CDAModelUtil.FindResourcesByNameVisitor;
import org.openhealthtools.mdht.uml.cda.ui.internal.Activator;
import org.openhealthtools.mdht.uml.cda.ui.internal.Logger;
import org.openhealthtools.mdht.uml.cda.ui.util.CDAUIUtil;
import org.osgi.framework.Bundle;

		Class cdaClass = templatePackage.createOwnedClass(newCDATemplatePage.getCDADocumentName(), false);

		CDATemplate template = (CDATemplate) cdaClass.applyStereotype(
			cdaClass.getApplicableStereotype("CDA::CDATemplate"));

		template.setBase_Class(cdaClass);

		template.setTemplateId(newCDATemplatePage.getTemplateId());

		template.setAssigningAuthorityName(newCDATemplatePage.getTemplateAssigningAuthority());

		Type t = cdaDocuments.get(newCDATemplatePage.getCDADocument());

		if (t instanceof Class) {
			Class documentClass = (Class) t;
			cdaClass.createGeneralization(documentClass);
			Package documentPackage = documentClass.getNearestPackage();
			EcoreUtil.resolveAll(documentPackage);
			templatePackage.createPackageImport(documentClass.getNearestPackage());
		}

		templatePackage.createPackageImport(vocabPackage);

		templatePackage.eResource().save(options);

	}

	void createTransformation(IProject project, String modelName) throws Exception {

// Path: cda/plugins/org.openhealthtools.mdht.uml.cda.core/src/org/openhealthtools/mdht/uml/cda/core/util/CDAModelUtil.java
// public static class FindResourcesByNameVisitor implements IResourceVisitor {
// 
// 	private String resourceName;
// 
// 	private ArrayList<IResource> resources = new ArrayList<IResource>();
// 
// 	/**
// 	 * @return the resources
// 	 */
// 	public ArrayList<IResource> getResources() {
// 		return resources;
// 	}
// 
// 	/**
// 	 * @param resourceName
// 	 */
// 	public FindResourcesByNameVisitor(String resourceName) {
// 		super();
// 		this.resourceName = resourceName;
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 *
// 	 * @see org.eclipse.core.resources.IResourceVisitor#visit(org.eclipse.core.resources.IResource)
// 	 */
// 	public boolean visit(IResource arg0) throws CoreException {
// 
// 		if (resourceName != null && resourceName.equals(arg0.getName())) {
// 			resources.add(arg0);
// 		}
// 		return true;
// 	}
// 
// }


// Path: cda/plugins/org.openhealthtools.mdht.uml.cda.ui/src/org/openhealthtools/mdht/uml/cda/ui/wizards/NewCDAModelProjectWizard.java
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationOperation;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
import org.eclipse.ui.ide.IDE;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Type;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.resource.UML22UMLResource;
import org.openhealthtools.mdht.uml.cda.core.profile.CDATemplate;
import org.openhealthtools.mdht.uml.cda.core.profile.CodegenSupport;
import org.openhealthtools.mdht.uml.cda.core.util.CDAModelUtil.FindResourcesByNameVisitor;
import org.openhealthtools.mdht.uml.cda.ui.internal.Activator;
import org.openhealthtools.mdht.uml.cda.ui.internal.Logger;
import org.openhealthtools.mdht.uml.cda.ui.util.CDAUIUtil;
import org.osgi.framework.Bundle;


		Class cdaClass = templatePackage.createOwnedClass(newCDATemplatePage.getCDADocumentName(), false);

		CDATemplate template = (CDATemplate) cdaClass.applyStereotype(
			cdaClass.getApplicableStereotype("CDA::CDATemplate"));

		template.setBase_Class(cdaClass);

		template.setTemplateId(newCDATemplatePage.getTemplateId());

		template.setAssigningAuthorityName(newCDATemplatePage.getTemplateAssigningAuthority());

		Type t = cdaDocuments.get(newCDATemplatePage.getCDADocument());

		if (t instanceof Class) {
			Class documentClass = (Class) t;
			cdaClass.createGeneralization(documentClass);
			Package documentPackage = documentClass.getNearestPackage();
			EcoreUtil.resolveAll(documentPackage);
			templatePackage.createPackageImport(documentClass.getNearestPackage());
		}

		templatePackage.createPackageImport(vocabPackage);

		templatePackage.eResource().save(options);

	}

	void createTransformation(IProject project, String modelName) throws Exception {

		FindResourcesByNameVisitor visitor = new FindResourcesByNameVisitor("transform-common.xml");