Skip to content
Snippets Groups Projects
Commit a68f2ae3 authored by Chrissi's avatar Chrissi
Browse files

change package namings in ecore models

+ use ns prefix as package name in code generator
parent dd1ed191
No related branches found
No related tags found
No related merge requests found
<?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"/>
......
<?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"/>
......
<?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"
......
<?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>
......
<?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>
......@@ -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 => {
......
......@@ -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
}
......
......@@ -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))
......
......@@ -11,6 +11,7 @@ object ApplicationTest extends App {
//runShrinkingModel(Creation.rsum)
runTTC2019(Creation.rolecomb)
//runTTC2019(Creation.rolesync)
//runAllTests(Creation.rsum)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment