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

refactoring

- remove isInterface and isAbstract as parameter in sclass
parent 3c02f11e
No related branches found
No related tags found
No related merge requests found
Showing with 27 additions and 37 deletions
...@@ -76,7 +76,7 @@ class JoinGeneratingVisitor(joinExpression: ModelJoinExpression) extends SModelV ...@@ -76,7 +76,7 @@ class JoinGeneratingVisitor(joinExpression: ModelJoinExpression) extends SModelV
println("B: " + otherAttsBase) println("B: " + otherAttsBase)
println("O: " + otherAttsOther) println("O: " + otherAttsOther)
val joinObject = new SClass(j.getTarget().getResourceName + "Object", j.getTarget().getResourcePath) val joinObject = new SClass(j.getTarget().getResourceName + "Object", j.getTarget().getResourcePath, SClassType.normalObject)
val joinClass = new SJoinClass(j.getTarget().getResourceName, j.getTarget().getResourcePath, val joinClass = new SJoinClass(j.getTarget().getResourceName, j.getTarget().getResourcePath,
base = baseClass, other = otherClass, joinType = rsumJoinType, base = baseClass, other = otherClass, joinType = rsumJoinType,
joinAttributes = joinAtts, innerAttributes = joinAtts ++ otherAttsBase ++ otherAttsOther, joinObject) joinAttributes = joinAtts, innerAttributes = joinAtts ++ otherAttsBase ++ otherAttsOther, joinObject)
...@@ -122,7 +122,7 @@ class JoinGeneratingVisitor(joinExpression: ModelJoinExpression) extends SModelV ...@@ -122,7 +122,7 @@ class JoinGeneratingVisitor(joinExpression: ModelJoinExpression) extends SModelV
joinClass.addMethod(ToStringMethods.joinToStringMethod(joinClass.getName)) joinClass.addMethod(ToStringMethods.joinToStringMethod(joinClass.getName))
sModel.addJoinClass(joinClass) sModel.addJoinClass(joinClass)
sModel.addJoinObject(joinObject) sModel.addJoinClass(joinObject)
//add in Type Registry //add in Type Registry
STypeRegistry.addType(joinClass, null) STypeRegistry.addType(joinClass, null)
......
...@@ -88,8 +88,7 @@ class ModelJoinViewGeneratingVisitor(joinExpression: ModelJoinExpression) extend ...@@ -88,8 +88,7 @@ class ModelJoinViewGeneratingVisitor(joinExpression: ModelJoinExpression) extend
} else { } else {
refClasses = refClasses :+ cls refClasses = refClasses :+ cls
internalClass = new SInnerViewNaturalClass(cls.getName + PackageNames.viewRolePostName, internalClass = new SInnerViewNaturalClass(cls.getName + PackageNames.viewRolePostName,
_isAbstract = cls.isAbstract, _sClassType = cls.sClassType,
_isInterface = cls.isInterface,
_externalClass = viewCompartment, _externalClass = viewCompartment,
sumSource = cls) sumSource = cls)
newInternalRoles = newInternalRoles :+ internalClass newInternalRoles = newInternalRoles :+ internalClass
......
...@@ -24,8 +24,6 @@ class QueryGeneratingVisitor extends SModelVisitor { ...@@ -24,8 +24,6 @@ class QueryGeneratingVisitor extends SModelVisitor {
//Iterate over all Model classes and create natural internal role classes //Iterate over all Model classes and create natural internal role classes
sModel.getModelClasses.filter(!_.getName.startsWith(PackageNames.queryHelperPrefix)).foreach(cls => { sModel.getModelClasses.filter(!_.getName.startsWith(PackageNames.queryHelperPrefix)).foreach(cls => {
val internalClass = new SInnerViewNaturalClass(cls.getName + PackageNames.queryRolePostName, val internalClass = new SInnerViewNaturalClass(cls.getName + PackageNames.queryRolePostName,
_isAbstract = false,
_isInterface = false,
_externalClass = viewCompartment, _externalClass = viewCompartment,
sumSource = cls) sumSource = cls)
//sets the attributes from the source class //sets the attributes from the source class
......
...@@ -4,6 +4,7 @@ import org.rosi_project.model_sync.generator.acr_model._ ...@@ -4,6 +4,7 @@ import org.rosi_project.model_sync.generator.acr_model._
import org.rosi_project.model_sync.generator.PackageNames import org.rosi_project.model_sync.generator.PackageNames
import org.rosi_project.model_sync.generator.acr_model.types.PredefEcoreTypes import org.rosi_project.model_sync.generator.acr_model.types.PredefEcoreTypes
import org.rosi_project.model_sync.generator.acr_model.types.PredefTypes import org.rosi_project.model_sync.generator.acr_model.types.PredefTypes
import org.rosi_project.model_sync.generator.acr_model.types.GenericSequence
/** /**
* Read EMF and Ecore models. * Read EMF and Ecore models.
...@@ -98,6 +99,11 @@ class SumModelReadingVisitor() extends SModelVisitor { ...@@ -98,6 +99,11 @@ class SumModelReadingVisitor() extends SModelVisitor {
SMethodStatement(content = s"val s1 = mapping.get(s).get.asInstanceOf[${rc.sClass.getName}]"), SMethodStatement(content = s"val s1 = mapping.get(s).get.asInstanceOf[${rc.sClass.getName}]"),
SMethodStatement(content = s"val t1 = mapping.get(t).get.asInstanceOf[${rc.tClass.getName}]"), SMethodStatement(content = s"val t1 = mapping.get(t).get.asInstanceOf[${rc.tClass.getName}]"),
SMethodStatement(content = s"(new ${rc.getName}(s1, t1)).initialize()", usedTypes = Set(rc, rc.sClass, rc.tClass)))) SMethodStatement(content = s"(new ${rc.getName}(s1, t1)).initialize()", usedTypes = Set(rc, rc.sClass, rc.tClass))))
if (rc.connectedRef.getTypeElement.isInstanceOf[GenericSequence]) {
//add -> add method
} else {
//add -> set method
}
creator.addMethod(method) creator.addMethod(method)
createRefImpl = createRefImpl :+ SMethodStatement(content = s"""if (o1Name.contains("${rc.sClass.getName}") && sfName == "${rc.connectedRef.getName}" && o2Name.contains("${rc.tClass.getName}")) {""") createRefImpl = createRefImpl :+ SMethodStatement(content = s"""if (o1Name.contains("${rc.sClass.getName}") && sfName == "${rc.connectedRef.getName}" && o2Name.contains("${rc.tClass.getName}")) {""")
...@@ -115,8 +121,8 @@ class SumModelReadingVisitor() extends SModelVisitor { ...@@ -115,8 +121,8 @@ class SumModelReadingVisitor() extends SModelVisitor {
loader.addMethod(createRef) loader.addMethod(createRef)
//add the new classes as model classes //add the new classes as model classes
sModel.addModelClass(creator) sModel.addProviderClass(creator)
sModel.addModelClass(loader) sModel.addProviderClass(loader)
} }
override def visit(sClass: SClass): Unit = { override def visit(sClass: SClass): Unit = {
......
...@@ -16,8 +16,7 @@ class ViewGeneratingVisitor extends SModelVisitor { ...@@ -16,8 +16,7 @@ class ViewGeneratingVisitor extends SModelVisitor {
//Iterate over all Model classes and create natural internal role classes //Iterate over all Model classes and create natural internal role classes
sModel.getModelClasses.foreach(cls => { sModel.getModelClasses.foreach(cls => {
val internalClass = new SInnerViewNaturalClass(cls.getName + PackageNames.viewRolePostName, val internalClass = new SInnerViewNaturalClass(cls.getName + PackageNames.viewRolePostName,
_isAbstract = cls.isAbstract, _sClassType = cls.sClassType,
_isInterface = cls.isInterface,
_externalClass = viewCompartment, _externalClass = viewCompartment,
sumSource = cls) sumSource = cls)
//sets the attributes from the source class //sets the attributes from the source class
......
...@@ -44,74 +44,62 @@ object ApplicationTest extends App { ...@@ -44,74 +44,62 @@ object ApplicationTest extends App {
} }
def runTTCLive2019(cre: Creation.Value): Unit = { def runTTCLive2019(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/BibTeX.ecore", "assets/models/DocBook.ecore", "assets/models/NMetaChanges.ecore"), false, new File("assets/models")); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/BibTeX.ecore", "assets/models/DocBook.ecore", "assets/models/NMetaChanges.ecore"), false, new File("assets/models"), create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runTTC2019(cre: Creation.Value): Unit = { def runTTC2019(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/BDD.ecore", "assets/models/BDDv2.ecore", "assets/models/TT.ecore"), false, new File("assets/models")); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/BDD.ecore", "assets/models/BDDv2.ecore", "assets/models/TT.ecore"), false, new File("assets/models"), create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runShrinkingModel(cre: Creation.Value): Unit = { def runShrinkingModel(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ShrinkingModel.ecore"), false, new File("assets/models"), modelJoin = "assets/model_join/shrinking.modeljoin"); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ShrinkingModel.ecore"), false, new File("assets/models"), modelJoin = "assets/model_join/shrinking.modeljoin", create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runCombinedTest(cre: Creation.Value): Unit = { def runCombinedTest(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/IMDBDatabase.ecore", "assets/models/ModelJoinLibrary.ecore"), false, new File("assets/models"), modelJoin = "assets/model_join/simple.modeljoin"); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/IMDBDatabase.ecore", "assets/models/ModelJoinLibrary.ecore"), false, new File("assets/models"), modelJoin = "assets/model_join/simple.modeljoin", create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runTestFamily(cre: Creation.Value): Unit = { def runTestFamily(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Family.ecore"), false, new File("assets/models")); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Family.ecore"), false, new File("assets/models"), create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runTestSimplePerson(cre: Creation.Value): Unit = { def runTestSimplePerson(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/SimplePerson.ecore"), false, new File("assets/models")); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/SimplePerson.ecore"), false, new File("assets/models"), create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runTestPerson(cre: Creation.Value): Unit = { def runTestPerson(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Person.ecore"), false, new File("assets/models")); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Person.ecore"), false, new File("assets/models"), create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runTestLibrary(cre: Creation.Value): Unit = { def runTestLibrary(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Library.ecore"), false, new File("assets/models"), modelJoin = "assets/model_join/manager.modeljoin"); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Library.ecore"), false, new File("assets/models"), modelJoin = "assets/model_join/manager.modeljoin", create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runTestShrinkingModel(cre: Creation.Value): Unit = { def runTestShrinkingModel(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ShrinkingModel.ecore"), false, new File("assets/models")); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ShrinkingModel.ecore"), false, new File("assets/models"), create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runTestAML(cre: Creation.Value): Unit = { def runTestAML(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/AML.ecore"), false, new File("assets/models")); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/AML.ecore"), false, new File("assets/models"), create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runTestIMDB(cre: Creation.Value): Unit = { def runTestIMDB(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/IMDBDatabase.ecore"), false, new File("assets/models")); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/IMDBDatabase.ecore"), false, new File("assets/models"), create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
def runTestModelJoinLib(cre: Creation.Value): Unit = { def runTestModelJoinLib(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ModelJoinLibrary.ecore"), false, new File("assets/models")); var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ModelJoinLibrary.ecore"), false, new File("assets/models"), create = cre);
config.setCreate(cre)
new Generator(config).run() new Generator(config).run()
} }
......
...@@ -13,7 +13,7 @@ object SClassWriterTest/* extends App */{ ...@@ -13,7 +13,7 @@ object SClassWriterTest/* extends App */{
val stringType = SType("String") val stringType = SType("String")
val attrs = Seq(SAttribute("name", stringType)) val attrs = Seq(SAttribute("name", stringType))
val sayHelloMethod = new SMethod("sayHello", stringType, Seq.empty, Seq(SMethodStatement("s\"Hello $name\""))) val sayHelloMethod = new SMethod("sayHello", stringType, Seq.empty, Seq(SMethodStatement("s\"Hello $name\"")))
val modelClass = new SClass("Person", "", false, false) val modelClass = new SClass("Person", "foo")
modelClass.setAttributes(attrs) modelClass.setAttributes(attrs)
modelClass.addMethod(sayHelloMethod) modelClass.addMethod(sayHelloMethod)
...@@ -23,7 +23,7 @@ object SClassWriterTest/* extends App */{ ...@@ -23,7 +23,7 @@ object SClassWriterTest/* extends App */{
val syncNotificationVisitor = new SyncEnhancingVisitor val syncNotificationVisitor = new SyncEnhancingVisitor
modelClass.accept(syncNotificationVisitor) modelClass.accept(syncNotificationVisitor)
val writer = new SClassWriter(modelClass, false) val writer = new SClassWriter(modelClass)
println(writer.stringify) println(writer.stringify)
......
...@@ -14,7 +14,7 @@ object SModelFSWriterTest/* extends App */{ ...@@ -14,7 +14,7 @@ object SModelFSWriterTest/* extends App */{
val personAttrs = Seq(SAttribute("name", stringType)) val personAttrs = Seq(SAttribute("name", stringType))
val personSayHelloMethod = new SMethod("sayHello", stringType, Seq.empty, Seq(SMethodStatement("s\"Hello $name\""))) val personSayHelloMethod = new SMethod("sayHello", stringType, Seq.empty, Seq(SMethodStatement("s\"Hello $name\"")))
val personClass = new SClass("Person", "foo", false, false) val personClass = new SClass("Person", "foo")
personClass.setAttributes(personAttrs) personClass.setAttributes(personAttrs)
personClass.addMethod(personSayHelloMethod) personClass.addMethod(personSayHelloMethod)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment