diff --git a/assets/models/IMDBDatabase.ecore b/assets/models/IMDBDatabase.ecore index b5f9b26f8411d33a06f2e9c6336f37481be42b37..e97c1c4f8c409e15d51506b80cadaea050dcec16 100644 --- a/assets/models/IMDBDatabase.ecore +++ b/assets/models/IMDBDatabase.ecore @@ -33,14 +33,14 @@ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> <eStructuralFeatures xsi:type="ecore:EReference" name="film" eType="#//Film" eOpposite="#//Film/figures"/> <eStructuralFeatures xsi:type="ecore:EReference" name="playedBy" lowerBound="1" - upperBound="-1" eType="#//Actor" eOpposite="#//Actor/plays"/> + upperBound="-1" eType="#//Actor" eOpposite="#//Actor/playsIn"/> </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="Person"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="dob" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDouble"/> </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="Actor" eSuperTypes="#//Person"> - <eStructuralFeatures xsi:type="ecore:EReference" name="plays" upperBound="-1" + <eStructuralFeatures xsi:type="ecore:EReference" name="playsIn" upperBound="-1" eType="#//Figure" eOpposite="#//Figure/playedBy"/> <eStructuralFeatures xsi:type="ecore:EReference" name="library" eType="#//IMDB" eOpposite="#//IMDB/actors"/> diff --git a/assets/models/Library.sync.json b/assets/models/Library.sync.json index 5073d1696a900695d737b023481724087d99de03..99a95134654a9aa038ce37aa92e3d92283222794 100644 --- a/assets/models/Library.sync.json +++ b/assets/models/Library.sync.json @@ -1 +1 @@ -{"name":"Library","init":{"name":"Library","primaryClass":"LibraryExample.Library","image":"Library.png","nested":[{"name":"Person","primaryClass":"LibraryExample.Person","additionalClasses":["LibraryExample.Employee"]}]}} \ No newline at end of file +{"name":"Library","init":{"name":"Library","primaryClass":"sync.lib.Library","image":"Library.png","nested":[{"name":"Person","primaryClass":"sync.lib.Person","additionalClasses":["sync.lib.Employee"]}]}} \ No newline at end of file diff --git a/assets/models/ModelJoinLibrary.ecore b/assets/models/ModelJoinLibrary.ecore index d61f6714269948a8b96af965647770daa6cde0ab..e5669ac1ca777b8cc9bd5df581aba778559cd473 100644 --- a/assets/models/ModelJoinLibrary.ecore +++ b/assets/models/ModelJoinLibrary.ecore @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="eclipselibrary" nsURI="http://www.example.org/eclipselibrary" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="Eclipselibrary" nsURI="http://www.example.org/eclipselibrary" nsPrefix="elib"> <eClassifiers xsi:type="ecore:EClass" name="Item" abstract="true"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="publicationDate" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/> diff --git a/src/main/scala/org/rosi_project/model_sync/generator/Generator.scala b/src/main/scala/org/rosi_project/model_sync/generator/Generator.scala index 1473fa09947980c6f24c01fe83d7e54a68b4618b..e27f9fd70f612f009c9a7a37b35f564231a2d42a 100644 --- a/src/main/scala/org/rosi_project/model_sync/generator/Generator.scala +++ b/src/main/scala/org/rosi_project/model_sync/generator/Generator.scala @@ -25,6 +25,14 @@ class Generator(config: GeneratorConfig) { * Starts the generation. */ def run(): Unit = { + //set package name of scala model files + if (config.create == Creation.rolesum) + PackageNames.sourcePkgPrefix = "sum." + if (config.create == Creation.rolesync) + PackageNames.sourcePkgPrefix = "sync." + if (config.create == Creation.rolecomb) + PackageNames.sourcePkgPrefix = "" + try { if (config.sources.isEmpty) { println("Error: There must be any source file to generate something!!!") @@ -79,8 +87,10 @@ class Generator(config: GeneratorConfig) { if (sm._2.obj != null) { new SModelCombiInstanceService prepareModel (sm._1, sm._2) } - //add ref methods - new SModelCombiRefMethodService prepareModel (sm._1) + if (config.create == Creation.rolecomb) { + //add ref methods + new SModelCombiRefMethodService prepareModel (sm._1) + } //remove references new SModelSUMRemoveRefService prepareModel (sm._1) //create view and query stuff diff --git a/src/main/scala/org/rosi_project/model_sync/generator/PackageNames.scala b/src/main/scala/org/rosi_project/model_sync/generator/PackageNames.scala index d16632e5d0a0dd77ad50fc5bde43795de91250fc..60e87abbbfda997b4e850fba0f649a5c4985c1ef 100644 --- a/src/main/scala/org/rosi_project/model_sync/generator/PackageNames.scala +++ b/src/main/scala/org/rosi_project/model_sync/generator/PackageNames.scala @@ -4,7 +4,7 @@ object PackageNames { val multiInhertitanceWithTraits = false - val sourcePkgPrefix: String = "" //sync. , sum. + var sourcePkgPrefix: String = "" //sync. , sum. val viewPkgName: String = "view" val viewPostName: String = "View" diff --git a/src/main/scala/org/rosi_project/model_sync/generator/sync/ReferenceMethodCreationVisitor.scala b/src/main/scala/org/rosi_project/model_sync/generator/sync/ReferenceMethodCreationVisitor.scala index b7edd70c85258c5786c55284098685bf93324788..257523f0826ad8466a8e814e3263b68311385354 100644 --- a/src/main/scala/org/rosi_project/model_sync/generator/sync/ReferenceMethodCreationVisitor.scala +++ b/src/main/scala/org/rosi_project/model_sync/generator/sync/ReferenceMethodCreationVisitor.scala @@ -3,6 +3,9 @@ package org.rosi_project.model_sync.generator.sync import org.rosi_project.model_sync.generator.acr_model._ import org.rosi_project.model_sync.generator.acr_model.types.GenericSequence +/** + * Create the methods to get the references from each instance. Is only possible in combination with sync, because of role functionality. + */ class ReferenceMethodCreationVisitor extends SModelVisitor { override def visit(sModel: SModel): Unit = { diff --git a/src/main/scala/org/rosi_project/model_sync/generator/test/ApplicationTest.scala b/src/main/scala/org/rosi_project/model_sync/generator/test/ApplicationTest.scala index 783f243e88610320d3583f7ad32a3d9a9d5e110e..10c6275f5b2321b1c3d5229e7c224d385dfe40cc 100644 --- a/src/main/scala/org/rosi_project/model_sync/generator/test/ApplicationTest.scala +++ b/src/main/scala/org/rosi_project/model_sync/generator/test/ApplicationTest.scala @@ -6,9 +6,11 @@ import java.io.File import org.rosi_project.model_sync.generator.Creation object ApplicationTest extends App { + + runLibraries() //runTestLibrary(Creation.rolesum) - runCombinedTest(Creation.rolecomb) + //runCombinedTest(Creation.rolecomb) //runShrinkingModel(Creation.rolesum) //runTestAML(Creation.rolesum) @@ -22,6 +24,20 @@ object ApplicationTest extends App { //runAllTests(Creation.rsum) //runAllTests(Creation.rsync) + def runLibraries(): Unit = { + println("SUMM #####################################################################################") + runCombinedTest(Creation.rolesum) + runTestLibrary(Creation.rolesum) + + println("SYNC #####################################################################################") + runCombinedTest(Creation.rolesync) + runTestLibrary(Creation.rolesync) + + println("COMB #####################################################################################") + runCombinedTest(Creation.rolecomb) + runTestLibrary(Creation.rolecomb) + } + def runAllTests(cre: Creation.Value): Unit = { println("#####################################################################################") runTestFamily(cre)