From b1c789e9a46cff00902ba1e289338d98bb33f5a3 Mon Sep 17 00:00:00 2001
From: Kevin Kassin <kevinkassin@gmx.de>
Date: Sat, 9 Sep 2017 22:54:13 +0200
Subject: [PATCH] Commit 9.9 22:55

changed java version in build path and manifest to java 1.8,
integrated first version of transformation (not fully working yet)
---
 org.framed.iorm.ui/META-INF/MANIFEST.MF       |  3 +-
 .../iorm/ui/multipage/MultipageEditor.java    | 33 +++++++++++++++++++
 org.framed.orm.transformation/.classpath      | 14 ++++----
 .../.settings/org.eclipse.jdt.core.prefs      |  6 ++--
 .../META-INF/MANIFEST.MF                      |  2 +-
 .../epsilon/Inheritance.etl                   |  2 +-
 .../epsilon/Type.etl                          |  4 +--
 .../TransformationExecutor.java               |  2 +-
 8 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/org.framed.iorm.ui/META-INF/MANIFEST.MF b/org.framed.iorm.ui/META-INF/MANIFEST.MF
index 0908a0ae..c1fcbf23 100644
--- a/org.framed.iorm.ui/META-INF/MANIFEST.MF
+++ b/org.framed.iorm.ui/META-INF/MANIFEST.MF
@@ -29,4 +29,5 @@ Import-Package: de.ovgu.featureide.fm.ui.editors.configuration,
  org.eclipse.graphiti.features;version="0.13.2",
  org.framed.iorm.featuremodel,
  org.framed.iorm.model,
- org.framed.iorm.model.provider
+ org.framed.iorm.model.provider,
+ org.framed.orm.transformation
diff --git a/org.framed.iorm.ui/src/org/framed/iorm/ui/multipage/MultipageEditor.java b/org.framed.iorm.ui/src/org/framed/iorm/ui/multipage/MultipageEditor.java
index 644a6dc3..177c13a9 100644
--- a/org.framed.iorm.ui/src/org/framed/iorm/ui/multipage/MultipageEditor.java
+++ b/org.framed.iorm.ui/src/org/framed/iorm/ui/multipage/MultipageEditor.java
@@ -1,10 +1,19 @@
 package org.framed.iorm.ui.multipage;
 
+import java.io.IOException;
+import java.util.Collections;
+
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
 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.graphiti.features.ICreateFeature;
 import org.eclipse.graphiti.features.context.impl.CreateContext;
 import org.eclipse.graphiti.mm.pictograms.Diagram;
@@ -41,6 +50,7 @@ import org.framed.iorm.ui.util.PropertyUtil;
 import org.framed.iorm.ui.providers.DiagramTypeProvider; //*import for javadoc link
 import org.framed.iorm.ui.providers.ToolBehaviorProvider;
 import org.framed.iorm.ui.wizards.RoleModelWizard; //*import for javadoc link
+import org.framed.orm.transformation.TransformationExecutor;
 
 /**
  * This class is creates the overall editor to edit the role model. 
@@ -362,6 +372,9 @@ public class MultipageEditor extends FormEditor implements ISelectionListener, I
 			if(editorFeatures != null)
 				editorFeatures.synchronizeConfigurationEditorAndModelConfiguration();
 			refreshFile();
+			//TEST AREA
+			transformModel();
+			//TEST AREA
 			MultipageEditorSynchronizationService.synchronize();
 		}
 	}	
@@ -389,6 +402,26 @@ public class MultipageEditor extends FormEditor implements ISelectionListener, I
 		} else throw new NullPointerException(MUTLIPAGE_EDITOR_ERROR_NULLPOINTER_ON_FILE_EDITOR_INPUT);
 	}
 	
+	//TODO
+	public void transformModel() {
+		Resource diagram_resource = EditorInputUtil.getResourceFromEditorInput(getEditorInput());
+		URI sourceURI = diagram_resource.getURI();
+		sourceURI = sourceURI.trimFileExtension();
+		sourceURI = sourceURI.appendFileExtension("crom");
+		Path path = new Path(sourceURI.toFileString());
+		IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+		URI targetURI =	URI.createPlatformResourceURI(iFile.getFullPath().toString(), true);
+		ResourceSet set = new ResourceSetImpl();
+		Resource crom_resource = set.createResource(targetURI);
+		TransformationExecutor exe = new TransformationExecutor();
+		exe.setSourceModelFile(diagram_resource);
+		exe.setTargetModelFile(crom_resource);
+		try {
+			crom_resource.save(Collections.EMPTY_MAP);
+			exe.execute();
+		} catch (Exception e) { e.printStackTrace(); }
+	}
+	
 	/**
 	 * informs the user that there are unsaved changes in multipage editors different to the active one 
 	 * after a selection change 
diff --git a/org.framed.orm.transformation/.classpath b/org.framed.orm.transformation/.classpath
index 46cec6ed..54f561c7 100644
--- a/org.framed.orm.transformation/.classpath
+++ b/org.framed.orm.transformation/.classpath
@@ -1,7 +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/JavaSE-1.7"/>
-	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="src" path="src/"/>
-	<classpathentry kind="output" path="target/classes"/>
-</classpath>
+<?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/JavaSE-1.8"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.framed.orm.transformation/.settings/org.eclipse.jdt.core.prefs b/org.framed.orm.transformation/.settings/org.eclipse.jdt.core.prefs
index 443e0859..6e80039d 100644
--- a/org.framed.orm.transformation/.settings/org.eclipse.jdt.core.prefs
+++ b/org.framed.orm.transformation/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,8 @@
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/org.framed.orm.transformation/META-INF/MANIFEST.MF b/org.framed.orm.transformation/META-INF/MANIFEST.MF
index e1cdeb54..ce2af287 100644
--- a/org.framed.orm.transformation/META-INF/MANIFEST.MF
+++ b/org.framed.orm.transformation/META-INF/MANIFEST.MF
@@ -11,6 +11,6 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.epsilon.eol.dt;bundle-version="1.2.0",
  org.eclipse.epsilon.etl.engine,
  org.rosi.crom.metamodel;bundle-version="0.1.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Export-Package: org.framed.orm.transformation
diff --git a/org.framed.orm.transformation/epsilon/Inheritance.etl b/org.framed.orm.transformation/epsilon/Inheritance.etl
index a8e1ddb3..b3ffb2ea 100644
--- a/org.framed.orm.transformation/epsilon/Inheritance.etl
+++ b/org.framed.orm.transformation/epsilon/Inheritance.etl
@@ -5,7 +5,7 @@
  * It is assumed that source and target reference are valid, i.e., are of the same type and correspond
  * to the inheritance. For instance, a NaturalInheritance has source and target elements of type NaturalType.
  */
-operation Any transformInheritance(s : source!Relation, t : target!Inheritance) {
+operation transformInheritance(s : source!Relation, t : target!Inheritance) {
 	var relationSource = s.getSource.equivalent();
 	var relationTarget = s.getTarget.equivalent();
 	
diff --git a/org.framed.orm.transformation/epsilon/Type.etl b/org.framed.orm.transformation/epsilon/Type.etl
index 2c1c6012..40238b6a 100644
--- a/org.framed.orm.transformation/epsilon/Type.etl
+++ b/org.framed.orm.transformation/epsilon/Type.etl
@@ -83,7 +83,7 @@ operation source!Shape addOperations(n : target!Type) {
 				
 				var parameter = new target!Parameter;
 				parameter.name = paramName;
-				
+
 				var pt = findTypeForName(paramType);			
 				if (not (pt == null)) {
 					parameter.type = pt;
@@ -102,7 +102,7 @@ operation source!Shape addOperations(n : target!Type) {
  * Searches the source model for a shape element with the given name and returns the equivalent target model element 
  * if a shape of given name was found, or null otherwise.
  */
-operation Any findTypeForName(str : String) : target!Type {
+operation findTypeForName(str : String) : target!Type {
 	var shape = source!Shape.allInstances().select(s|s.name = str).first;
 	if (shape.isDefined()) {
 		return shape.equivalent();
diff --git a/org.framed.orm.transformation/src/org/framed/orm/transformation/TransformationExecutor.java b/org.framed.orm.transformation/src/org/framed/orm/transformation/TransformationExecutor.java
index f455cddd..86e104f3 100644
--- a/org.framed.orm.transformation/src/org/framed/orm/transformation/TransformationExecutor.java
+++ b/org.framed.orm.transformation/src/org/framed/orm/transformation/TransformationExecutor.java
@@ -62,7 +62,7 @@ public class TransformationExecutor extends EpsilonStandalone {
     List<IModel> models = new ArrayList<IModel>();
 
     EmfModel emfModel = new EmfModel();
-    emfModel.setMetamodelUri("http://orm/1.0");
+    emfModel.setMetamodelUri("http://iorm/1.0");
     emfModel.setModelFileUri(sourceModelFile.getURI());
     emfModel.setReadOnLoad(true);
     emfModel.setStoredOnDisposal(true);
-- 
GitLab