New AmaltheaTransformer.transformMetaInfo() for inchron GeneralInfo

Signed-off-by: Stefan Quandt <stefan.quandt@inchron.com>
diff --git a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/AmaltheaTransformer.xtend b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/AmaltheaTransformer.xtend
index 79d202d..6b0b791 100644
--- a/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/AmaltheaTransformer.xtend
+++ b/eclipse-tools/model-transformation/examples/amlt2inchron/org.eclipse.app4mc.transform.to.inchron.m2m/src/templates/AmaltheaTransformer.xtend
@@ -5,9 +5,16 @@
 import com.inchron.realtime.root.model.Model
 import com.inchron.realtime.root.model.ModelFactory
 import java.io.File
+import java.lang.String
+import java.text.DateFormat;
+import java.text.SimpleDateFormat
+import java.util.Date
+import java.util.Locale
 import org.apache.log4j.ConsoleAppender
 import org.apache.log4j.PatternLayout
 import org.eclipse.app4mc.amalthea.model.Amalthea
+import org.eclipse.app4mc.amalthea.model.Value
+import org.eclipse.app4mc.amalthea.model.StringObject
 import org.eclipse.app4mc.transformation.extensions.base.templates.Model2ModelRootTransformer
 import org.eclipse.emf.common.util.URI
 import org.eclipse.emf.ecore.EObject
@@ -30,6 +37,8 @@
 	
 	@Inject extension StimuliTransformer stimuliTransformer
 
+	DateFormat dateFormat = new SimpleDateFormat("dd.MMMM.yyyy", Locale.ENGLISH)
+
 	/**
 	 * This method performs the transformation of AMALTHEA model to INCHRON model and saves the transformed model in the output directory.
 	 */
@@ -103,11 +112,42 @@
 	   def create inchronModelFactory.createModel createInchronModel(Amalthea amalthea) {
 
 		setRequiredAttributes(amalthea, it)
-		
+
+		transformMetaInfo(amalthea, it)
+
 		hwTransformer.transfromHWModel(amalthea.hwModel,it)
 
 	}
-	
+
+	/**
+	 * Create and fill the INCHRON model's GeneralInfo with meta information,
+	 * mainly from the Amalthea customProperties map.
+	 * @Note: customProperties keys used here are currently informal/not specified. 
+	 */
+	public def transformMetaInfo(Amalthea amalthea, Model inchronModel) {
+
+		var info = inchronModelFactory.createGeneralInfo()
+		info.setCreator(("Amlt2Inchron " + amalthea.getVersion() + " " + new Date()).toString())
+		info.setVersion("1")
+
+		val value = amalthea.getCustomProperties().get("Date_Last_Modified")
+		if (value instanceof StringObject) {
+			val date = (value as StringObject).getValue()
+			if (date != null)
+				info.setModifiedDate(dateFormat.parse(date))
+		}
+
+		val author = amalthea.getCustomProperties().get("Author")
+		if (author instanceof StringObject)
+   			info.setAuthor((author as StringObject).getValue())
+
+		val descr = amalthea.getCustomProperties().get("Description")
+		if (descr instanceof StringObject)
+			info.setDescription((descr as StringObject).getValue())
+
+		inchronModel.setGeneralInfo(info)
+	}
+
 	/**
 	 * Each transformation object should be set with the required attributes.
 	 * At present the required attributes are : amaltheaModel and inchronModel elements. In future this list can grow