diff --git a/assets/models/AML.ecore b/assets/models/AML.ecore index 488c44fe6b015dcb5e3eec24aa8eb997ad7cb316..db85f69458ae54611481c3a96161fc528a4dbcc3 100644 --- a/assets/models/AML.ecore +++ b/assets/models/AML.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="amlanguage" nsURI="http://www.example.org/aml" nsPrefix="aml"> + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="AMLLanguage" nsURI="http://www.example.org/aml" nsPrefix="org.rosi_project.example.mm.aml"> <eClassifiers xsi:type="ecore:EClass" name="CAEXObject" abstract="true"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> diff --git a/assets/models/IMDBDatabase.ecore b/assets/models/IMDBDatabase.ecore index 952ef853cc826538074f8cc659ba7562e6901ed6..9c09d12ff26d7593d2b0013e6e171e31a83f9b32 100644 --- a/assets/models/IMDBDatabase.ecore +++ b/assets/models/IMDBDatabase.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="imdbdatabase" nsURI="http://www.example.org/database" nsPrefix="database"> + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="IMDBdatabase" nsURI="http://www.example.org/database" nsPrefix="org.rosi_project.example.mm.database"> <eClassifiers xsi:type="ecore:EClass" name="IMDB"> <eStructuralFeatures xsi:type="ecore:EReference" name="users" upperBound="-1" eType="#//User" containment="true" eOpposite="#//User/library"/> diff --git a/assets/models/Library.ecore b/assets/models/Library.ecore index 68c34fc96191d99a0c61f94ab6f77cb7fcb89450..33179128b33c0c1f4d0b2396714ae0d3d708b16e 100644 --- a/assets/models/Library.ecore +++ b/assets/models/Library.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="library" nsURI="http://www.example.org/library" nsPrefix="lib"> + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="Library" nsURI="http://www.example.org/library" nsPrefix="org.rosi_project.example.mm.lib"> <eClassifiers xsi:type="ecore:EClass" name="Library"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> <eStructuralFeatures xsi:type="ecore:EReference" name="employees" upperBound="-1" diff --git a/assets/models/ModelJoinLibrary.ecore b/assets/models/ModelJoinLibrary.ecore index f038003363384d8f2a19ee139df5c47c22d30788..d98f470601c41211e6f57ec4b4355e968aee255d 100644 --- a/assets/models/ModelJoinLibrary.ecore +++ b/assets/models/ModelJoinLibrary.ecore @@ -1,7 +1,7 @@ <?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" - nsPrefix="elib"> + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="EclipseLibrary" nsURI="http://www.example.org/eclipselibrary" + nsPrefix="org.rosi_project.example.mm.elib"> <eClassifiers xsi:type="ecore:EClass" name="Item"> <eStructuralFeatures xsi:type="ecore:EAttribute" name="publicationDate" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/> </eClassifiers> diff --git a/assets/models/TT.ttmodel b/assets/models/TT.ttmodel index 98d2058f07f17458a9e9aef08bad19dcf077e66d..55150aa0af2efcc0a0f34af8990c77233dfa900d 100644 --- a/assets/models/TT.ttmodel +++ b/assets/models/TT.ttmodel @@ -1,66 +1,137 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<TruthTable xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.transformation-tool-contest.eu/2019/tt" name="Test"> - <ports xsi:type="InputPort" name="a" cells="//@rows.0/@cells.0 //@rows.1/@cells.0 //@rows.2/@cells.0 //@rows.3/@cells.0 //@rows.4/@cells.0 //@rows.5/@cells.0 //@rows.6/@cells.0 //@rows.7/@cells.0 //@rows.8/@cells.0"/> - <ports xsi:type="InputPort" name="b" cells="//@rows.0/@cells.1 //@rows.1/@cells.1 //@rows.2/@cells.1 //@rows.3/@cells.1 //@rows.4/@cells.1 //@rows.5/@cells.1 //@rows.7/@cells.1 //@rows.8/@cells.1"/> - <ports xsi:type="InputPort" name="c" cells="//@rows.1/@cells.2 //@rows.2/@cells.2 //@rows.3/@cells.2 //@rows.4/@cells.2 //@rows.5/@cells.2 //@rows.7/@cells.2 //@rows.8/@cells.2"/> - <ports xsi:type="InputPort" name="d" cells="//@rows.1/@cells.3 //@rows.2/@cells.3 //@rows.4/@cells.3 //@rows.5/@cells.3 //@rows.6/@cells.1 //@rows.7/@cells.3 //@rows.8/@cells.3"/> - <ports xsi:type="OutputPort" name="s" cells="//@rows.0/@cells.2 //@rows.1/@cells.4 //@rows.2/@cells.4 //@rows.3/@cells.3 //@rows.4/@cells.4 //@rows.5/@cells.4 //@rows.6/@cells.2 //@rows.7/@cells.4 //@rows.8/@cells.4"/> +<?xml version="1.0" encoding="ASCII"?> +<tt:TruthTable xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tt="https://www.transformation-tool-contest.eu/2019/tt" name="TableI4O2Seed42"> + <ports xsi:type="tt:InputPort" name="I0" cells="//@rows.0/@cells.0 //@rows.1/@cells.0 //@rows.2/@cells.0 //@rows.3/@cells.0 //@rows.4/@cells.0 //@rows.5/@cells.0 //@rows.6/@cells.0 //@rows.7/@cells.0 //@rows.8/@cells.0 //@rows.9/@cells.0 //@rows.10/@cells.0 //@rows.11/@cells.0 //@rows.12/@cells.0 //@rows.13/@cells.0 //@rows.14/@cells.0 //@rows.15/@cells.0"/> + <ports xsi:type="tt:InputPort" name="I1" cells="//@rows.0/@cells.1 //@rows.1/@cells.1 //@rows.2/@cells.1 //@rows.3/@cells.1 //@rows.4/@cells.1 //@rows.5/@cells.1 //@rows.6/@cells.1 //@rows.7/@cells.1 //@rows.8/@cells.1 //@rows.9/@cells.1 //@rows.10/@cells.1 //@rows.11/@cells.1 //@rows.12/@cells.1 //@rows.13/@cells.1 //@rows.14/@cells.1 //@rows.15/@cells.1"/> + <ports xsi:type="tt:InputPort" name="I2" cells="//@rows.0/@cells.2 //@rows.1/@cells.2 //@rows.2/@cells.2 //@rows.3/@cells.2 //@rows.4/@cells.2 //@rows.5/@cells.2 //@rows.6/@cells.2 //@rows.7/@cells.2 //@rows.8/@cells.2 //@rows.9/@cells.2 //@rows.10/@cells.2 //@rows.11/@cells.2 //@rows.12/@cells.2 //@rows.13/@cells.2 //@rows.14/@cells.2 //@rows.15/@cells.2"/> + <ports xsi:type="tt:InputPort" name="I3" cells="//@rows.0/@cells.3 //@rows.1/@cells.3 //@rows.2/@cells.3 //@rows.3/@cells.3 //@rows.4/@cells.3 //@rows.5/@cells.3 //@rows.6/@cells.3 //@rows.7/@cells.3 //@rows.8/@cells.3 //@rows.9/@cells.3 //@rows.10/@cells.3 //@rows.11/@cells.3 //@rows.12/@cells.3 //@rows.13/@cells.3 //@rows.14/@cells.3 //@rows.15/@cells.3"/> + <ports xsi:type="tt:OutputPort" name="O0" cells="//@rows.0/@cells.4 //@rows.1/@cells.4 //@rows.2/@cells.4 //@rows.3/@cells.4 //@rows.4/@cells.4 //@rows.5/@cells.4 //@rows.6/@cells.4 //@rows.7/@cells.4 //@rows.8/@cells.4 //@rows.9/@cells.4 //@rows.10/@cells.4 //@rows.11/@cells.4 //@rows.12/@cells.4 //@rows.13/@cells.4 //@rows.14/@cells.4 //@rows.15/@cells.4"/> + <ports xsi:type="tt:OutputPort" name="O1" cells="//@rows.0/@cells.5 //@rows.1/@cells.5 //@rows.2/@cells.5 //@rows.3/@cells.5 //@rows.4/@cells.5 //@rows.5/@cells.5 //@rows.6/@cells.5 //@rows.7/@cells.5 //@rows.8/@cells.5 //@rows.9/@cells.5 //@rows.10/@cells.5 //@rows.11/@cells.5 //@rows.12/@cells.5 //@rows.13/@cells.5 //@rows.14/@cells.5 //@rows.15/@cells.5"/> <rows> - <cells value="false" port="//@ports.0"/> - <cells value="false" port="//@ports.1"/> - <cells value="false" port="//@ports.4"/> + <cells port="//@ports.0"/> + <cells port="//@ports.1"/> + <cells port="//@ports.2"/> + <cells port="//@ports.3"/> + <cells value="true" port="//@ports.4"/> + <cells port="//@ports.5"/> </rows> <rows> - <cells value="false" port="//@ports.0"/> - <cells value="true" port="//@ports.1"/> - <cells value="false" port="//@ports.2"/> - <cells value="false" port="//@ports.3"/> + <cells value="true" port="//@ports.0"/> + <cells port="//@ports.1"/> + <cells port="//@ports.2"/> + <cells port="//@ports.3"/> <cells value="true" port="//@ports.4"/> + <cells port="//@ports.5"/> </rows> <rows> - <cells value="false" port="//@ports.0"/> + <cells port="//@ports.0"/> <cells value="true" port="//@ports.1"/> - <cells value="false" port="//@ports.2"/> - <cells value="true" port="//@ports.3"/> - <cells value="false" port="//@ports.4"/> + <cells port="//@ports.2"/> + <cells port="//@ports.3"/> + <cells port="//@ports.4"/> + <cells value="true" port="//@ports.5"/> </rows> <rows> - <cells value="false" port="//@ports.0"/> + <cells value="true" port="//@ports.0"/> <cells value="true" port="//@ports.1"/> + <cells port="//@ports.2"/> + <cells port="//@ports.3"/> + <cells port="//@ports.4"/> + <cells value="true" port="//@ports.5"/> + </rows> + <rows> + <cells port="//@ports.0"/> + <cells port="//@ports.1"/> <cells value="true" port="//@ports.2"/> - <cells value="false" port="//@ports.4"/> + <cells port="//@ports.3"/> + <cells value="true" port="//@ports.4"/> + <cells port="//@ports.5"/> </rows> <rows> <cells value="true" port="//@ports.0"/> - <cells value="false" port="//@ports.1"/> - <cells value="false" port="//@ports.2"/> - <cells value="false" port="//@ports.3"/> - <cells value="false" port="//@ports.4"/> + <cells port="//@ports.1"/> + <cells value="true" port="//@ports.2"/> + <cells port="//@ports.3"/> + <cells value="true" port="//@ports.4"/> + <cells port="//@ports.5"/> + </rows> + <rows> + <cells port="//@ports.0"/> + <cells value="true" port="//@ports.1"/> + <cells value="true" port="//@ports.2"/> + <cells port="//@ports.3"/> + <cells port="//@ports.4"/> + <cells port="//@ports.5"/> </rows> <rows> <cells value="true" port="//@ports.0"/> - <cells value="false" port="//@ports.1"/> + <cells value="true" port="//@ports.1"/> <cells value="true" port="//@ports.2"/> - <cells value="false" port="//@ports.3"/> - <cells value="true" port="//@ports.4"/> + <cells port="//@ports.3"/> + <cells port="//@ports.4"/> + <cells value="true" port="//@ports.5"/> + </rows> + <rows> + <cells port="//@ports.0"/> + <cells port="//@ports.1"/> + <cells port="//@ports.2"/> + <cells value="true" port="//@ports.3"/> + <cells port="//@ports.4"/> + <cells value="true" port="//@ports.5"/> </rows> <rows> <cells value="true" port="//@ports.0"/> + <cells port="//@ports.1"/> + <cells port="//@ports.2"/> + <cells value="true" port="//@ports.3"/> + <cells value="true" port="//@ports.4"/> + <cells value="true" port="//@ports.5"/> + </rows> + <rows> + <cells port="//@ports.0"/> + <cells value="true" port="//@ports.1"/> + <cells port="//@ports.2"/> <cells value="true" port="//@ports.3"/> - <cells value="false" port="//@ports.4"/> + <cells value="true" port="//@ports.4"/> + <cells port="//@ports.5"/> </rows> <rows> <cells value="true" port="//@ports.0"/> <cells value="true" port="//@ports.1"/> - <cells value="false" port="//@ports.2"/> - <cells value="false" port="//@ports.3"/> + <cells port="//@ports.2"/> + <cells value="true" port="//@ports.3"/> + <cells port="//@ports.4"/> + <cells port="//@ports.5"/> + </rows> + <rows> + <cells port="//@ports.0"/> + <cells port="//@ports.1"/> + <cells value="true" port="//@ports.2"/> + <cells value="true" port="//@ports.3"/> <cells value="true" port="//@ports.4"/> + <cells value="true" port="//@ports.5"/> + </rows> + <rows> + <cells value="true" port="//@ports.0"/> + <cells port="//@ports.1"/> + <cells value="true" port="//@ports.2"/> + <cells value="true" port="//@ports.3"/> + <cells port="//@ports.4"/> + <cells value="true" port="//@ports.5"/> + </rows> + <rows> + <cells port="//@ports.0"/> + <cells value="true" port="//@ports.1"/> + <cells value="true" port="//@ports.2"/> + <cells value="true" port="//@ports.3"/> + <cells port="//@ports.4"/> + <cells port="//@ports.5"/> </rows> <rows> <cells value="true" port="//@ports.0"/> <cells value="true" port="//@ports.1"/> <cells value="true" port="//@ports.2"/> - <cells value="false" port="//@ports.3"/> - <cells value="false" port="//@ports.4"/> + <cells value="true" port="//@ports.3"/> + <cells value="true" port="//@ports.4"/> + <cells port="//@ports.5"/> </rows> -</TruthTable> +</tt:TruthTable> 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 c81f2580a69b093bf5bd6150dab8b5dde7689f58..04d810063c93453a1e6734de30e34ca3743ab62d 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 @@ -32,7 +32,7 @@ class Generator(config: GeneratorConfig) { } //read the ecore models - var ecoreModels: Map[String, ClassAndInstance] = Map.empty + var ecoreModels: Map[String, ClassAndInstance] = Map.empty try { config.sources.foreach(s => { ecoreModels = ecoreModels + (s -> (new EcoreLoader loadEcore s)) diff --git a/src/main/scala/org/rosi_project/model_sync/generator/conversion/SClassConverter.scala b/src/main/scala/org/rosi_project/model_sync/generator/conversion/SClassConverter.scala index b162a3bc1ddcd1a30cd9a1899a0cacfea36588bc..346a2f2b1646d03defeff92ac7200566e6b2d4a4 100644 --- a/src/main/scala/org/rosi_project/model_sync/generator/conversion/SClassConverter.scala +++ b/src/main/scala/org/rosi_project/model_sync/generator/conversion/SClassConverter.scala @@ -20,14 +20,14 @@ class SClassConverter extends Converter[EClass, SClass] { (source.getEAttributes: List[EAttribute]).foreach(eAttr => { val attrType: STypedElement = STypeRegistry // check if the attribute type is already known and registered - .query(eAttr.getEAttributeType.getName, eAttr.getEAttributeType.getEPackage.getName) + .query(eAttr.getEAttributeType.getName, eAttr.getEAttributeType.getEPackage.getNsPrefix) // otherwise create a new type .getOrElse { val newAttr = EmfTypeTranslator // if the type is wrapped by EMF (such as EString), use the corresponding scala type .getSClassFromEmf(eAttr.getEAttributeType) // otherwise create a new class (as the attribute should instance of a class rather than a type in this case) - .getOrElse(new SClass(eAttr.getEAttributeType.getName, eAttr.getEAttributeType.getEPackage.getName)) + .getOrElse(new SClass(eAttr.getEAttributeType.getName, eAttr.getEAttributeType.getEPackage.getNsPrefix)) // finally save the type STypeRegistry.addType(newAttr, null) @@ -41,7 +41,7 @@ class SClassConverter extends Converter[EClass, SClass] { .foreach(eRef => { val refName: String = eRef.getName //Attribute name val refType: String = eRef.getEReferenceType.getName //Name of the attribute type - val refTypePckg: String = eRef.getEReferenceType.getEPackage.getName //Package name of the attribute type + val refTypePckg: String = eRef.getEReferenceType.getEPackage.getNsPrefix //Package name of the attribute type val containment: Boolean = eRef.isContainment() //Containment relation or not val oppositeERef: EReference = eRef.getEOpposite() //Opposite reference var oppositeRef: SReference = null //Opposite reference @@ -106,7 +106,7 @@ class SClassConverter extends Converter[EClass, SClass] { .queryForName(p.getName) // otherwise we need to create and register it .getOrElse { - val parentSClass: SClass = new SClass(p.getName, p.getEPackage.getName) + val parentSClass: SClass = new SClass(p.getName, p.getEPackage.getNsPrefix) // register the parent (it will be visited and completely inflated later on) STypeRegistry.addType(parentSClass, null) parentSClass @@ -119,7 +119,7 @@ class SClassConverter extends Converter[EClass, SClass] { .queryForName(p.getName) // otherwise we need to create and register it .getOrElse { - val parentSClass: SClass = new SClass(p.getName, sPackage = p.getEPackage.getName) + val parentSClass: SClass = new SClass(p.getName, sPackage = p.getEPackage.getNsPrefix) // register the parent (it will be visited and completely inflated later on) STypeRegistry.addType(parentSClass) parentSClass @@ -136,7 +136,7 @@ class SClassConverter extends Converter[EClass, SClass] { * have the type known). Therefore we will set these now. */ - val currentClass: Option[STypedElement] = STypeRegistry.query(source.getName, source.getEPackage.getName) + val currentClass: Option[STypedElement] = STypeRegistry.query(source.getName, source.getEPackage.getNsPrefix) currentClass.map { case clazz: SClass => @@ -149,7 +149,7 @@ class SClassConverter extends Converter[EClass, SClass] { case sType => sys.error(s"sType should have been a class: $sType") }.getOrElse { - val createdClass: SClass = new SClass(source.getName, source.getEPackage.getName, source.isAbstract, source.isInterface) + val createdClass: SClass = new SClass(source.getName, source.getEPackage.getNsPrefix, source.isAbstract, source.isInterface) createdClass.setAttributes(attrs) createdClass.setReferences(refs) pars.foreach(p => { diff --git a/src/main/scala/org/rosi_project/model_sync/generator/conversion/SEnumConverter.scala b/src/main/scala/org/rosi_project/model_sync/generator/conversion/SEnumConverter.scala index ba54c91da717325a91531f2ecadabf42f4cea874..127ac5bc818ae9c889e846d9732bf58a26d194fb 100644 --- a/src/main/scala/org/rosi_project/model_sync/generator/conversion/SEnumConverter.scala +++ b/src/main/scala/org/rosi_project/model_sync/generator/conversion/SEnumConverter.scala @@ -16,7 +16,7 @@ class SEnumConverter extends Converter[EEnum, SEnum] { strings += elit.getName }) - val createdEnum: SEnum = new SEnum(source.getName, source.getEPackage.getName, strings) + val createdEnum: SEnum = new SEnum(source.getName, source.getEPackage.getNsPrefix, strings) STypeRegistry.addType(createdEnum, null) createdEnum } diff --git a/src/main/scala/org/rosi_project/model_sync/generator/conversion/SModelGenerator.scala b/src/main/scala/org/rosi_project/model_sync/generator/conversion/SModelGenerator.scala index 4a824559d012b9763410263ca7f294c2b42a4442..a8ed626e83a3684a8c298bd7a312442c4003157e 100644 --- a/src/main/scala/org/rosi_project/model_sync/generator/conversion/SModelGenerator.scala +++ b/src/main/scala/org/rosi_project/model_sync/generator/conversion/SModelGenerator.scala @@ -14,7 +14,7 @@ import org.eclipse.emf.ecore.EEnum class SModelGenerator extends Converter[EPackage, SModel] { override def convert(source: EPackage, sourceName: String): SModel = { - val packageName = if (source.getName != null) source.getName else "" + //val packageName = if (source.getName != null) source.getName else "" var contents = source.eAllContents().asScala val model = new ComplexSModel(source.getName, sourceName) @@ -22,8 +22,7 @@ class SModelGenerator extends Converter[EPackage, SModel] { println("First run creates all classes, important for abstract and interface relations") contents.foreach { case ec: EClass => - //println(ec) - STypeRegistry.addType(new SClass(ec.getName, ec.getEPackage.getName, ec.isAbstract, ec.isInterface), ec) + STypeRegistry.addType(new SClass(ec.getName, ec.getEPackage.getNsPrefix, ec.isAbstract, ec.isInterface), ec) case ee: EEnum => //prinltn(ee) model.addModelEnums(new SEnumConverter convert (ee, sourceName)) 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 e8870355984dbfd6d9b6773000e2d3fbde6628f0..664b0c6392727e6ac48a076deef97a85f691bc6d 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 @@ -11,6 +11,7 @@ object ApplicationTest extends App { //runShrinkingModel(Creation.rsum) runTTC2019(Creation.rolecomb) + //runTTC2019(Creation.rolesync) //runAllTests(Creation.rsum)