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
println("B: " + otherAttsBase)
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,
base = baseClass, other = otherClass, joinType = rsumJoinType,
joinAttributes = joinAtts, innerAttributes = joinAtts ++ otherAttsBase ++ otherAttsOther, joinObject)
......@@ -122,7 +122,7 @@ class JoinGeneratingVisitor(joinExpression: ModelJoinExpression) extends SModelV
joinClass.addMethod(ToStringMethods.joinToStringMethod(joinClass.getName))
sModel.addJoinClass(joinClass)
sModel.addJoinObject(joinObject)
sModel.addJoinClass(joinObject)
//add in Type Registry
STypeRegistry.addType(joinClass, null)
......
......@@ -88,8 +88,7 @@ class ModelJoinViewGeneratingVisitor(joinExpression: ModelJoinExpression) extend
} else {
refClasses = refClasses :+ cls
internalClass = new SInnerViewNaturalClass(cls.getName + PackageNames.viewRolePostName,
_isAbstract = cls.isAbstract,
_isInterface = cls.isInterface,
_sClassType = cls.sClassType,
_externalClass = viewCompartment,
sumSource = cls)
newInternalRoles = newInternalRoles :+ internalClass
......
......@@ -24,8 +24,6 @@ class QueryGeneratingVisitor extends SModelVisitor {
//Iterate over all Model classes and create natural internal role classes
sModel.getModelClasses.filter(!_.getName.startsWith(PackageNames.queryHelperPrefix)).foreach(cls => {
val internalClass = new SInnerViewNaturalClass(cls.getName + PackageNames.queryRolePostName,
_isAbstract = false,
_isInterface = false,
_externalClass = viewCompartment,
sumSource = cls)
//sets the attributes from the source class
......
......@@ -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.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.GenericSequence
/**
* Read EMF and Ecore models.
......@@ -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 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))))
if (rc.connectedRef.getTypeElement.isInstanceOf[GenericSequence]) {
//add -> add method
} else {
//add -> set method
}
creator.addMethod(method)
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 {
loader.addMethod(createRef)
//add the new classes as model classes
sModel.addModelClass(creator)
sModel.addModelClass(loader)
sModel.addProviderClass(creator)
sModel.addProviderClass(loader)
}
override def visit(sClass: SClass): Unit = {
......
......@@ -16,8 +16,7 @@ class ViewGeneratingVisitor extends SModelVisitor {
//Iterate over all Model classes and create natural internal role classes
sModel.getModelClasses.foreach(cls => {
val internalClass = new SInnerViewNaturalClass(cls.getName + PackageNames.viewRolePostName,
_isAbstract = cls.isAbstract,
_isInterface = cls.isInterface,
_sClassType = cls.sClassType,
_externalClass = viewCompartment,
sumSource = cls)
//sets the attributes from the source class
......
......@@ -44,74 +44,62 @@ object ApplicationTest extends App {
}
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"));
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/BibTeX.ecore", "assets/models/DocBook.ecore", "assets/models/NMetaChanges.ecore"), false, new File("assets/models"), create = cre);
new Generator(config).run()
}
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"));
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/BDD.ecore", "assets/models/BDDv2.ecore", "assets/models/TT.ecore"), false, new File("assets/models"), create = cre);
new Generator(config).run()
}
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");
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ShrinkingModel.ecore"), false, new File("assets/models"), modelJoin = "assets/model_join/shrinking.modeljoin", create = cre);
new Generator(config).run()
}
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");
config.setCreate(cre)
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);
new Generator(config).run()
}
def runTestFamily(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Family.ecore"), false, new File("assets/models"));
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Family.ecore"), false, new File("assets/models"), create = cre);
new Generator(config).run()
}
def runTestSimplePerson(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/SimplePerson.ecore"), false, new File("assets/models"));
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/SimplePerson.ecore"), false, new File("assets/models"), create = cre);
new Generator(config).run()
}
def runTestPerson(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Person.ecore"), false, new File("assets/models"));
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Person.ecore"), false, new File("assets/models"), create = cre);
new Generator(config).run()
}
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");
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/Library.ecore"), false, new File("assets/models"), modelJoin = "assets/model_join/manager.modeljoin", create = cre);
new Generator(config).run()
}
def runTestShrinkingModel(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ShrinkingModel.ecore"), false, new File("assets/models"));
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ShrinkingModel.ecore"), false, new File("assets/models"), create = cre);
new Generator(config).run()
}
def runTestAML(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/AML.ecore"), false, new File("assets/models"));
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/AML.ecore"), false, new File("assets/models"), create = cre);
new Generator(config).run()
}
def runTestIMDB(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/IMDBDatabase.ecore"), false, new File("assets/models"));
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/IMDBDatabase.ecore"), false, new File("assets/models"), create = cre);
new Generator(config).run()
}
def runTestModelJoinLib(cre: Creation.Value): Unit = {
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ModelJoinLibrary.ecore"), false, new File("assets/models"));
config.setCreate(cre)
var config: GeneratorConfig = GeneratorConfig(Seq("assets/models/ModelJoinLibrary.ecore"), false, new File("assets/models"), create = cre);
new Generator(config).run()
}
......
......@@ -13,7 +13,7 @@ object SClassWriterTest/* extends App */{
val stringType = SType("String")
val attrs = Seq(SAttribute("name", stringType))
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.addMethod(sayHelloMethod)
......@@ -23,7 +23,7 @@ object SClassWriterTest/* extends App */{
val syncNotificationVisitor = new SyncEnhancingVisitor
modelClass.accept(syncNotificationVisitor)
val writer = new SClassWriter(modelClass, false)
val writer = new SClassWriter(modelClass)
println(writer.stringify)
......
......@@ -14,7 +14,7 @@ object SModelFSWriterTest/* extends App */{
val personAttrs = Seq(SAttribute("name", stringType))
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.addMethod(personSayHelloMethod)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment