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

add dependency to model join project

+ add the creation of methods for references in the naturals (only getter named as references)
parent fe9c3ab4
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,8 @@ val gsonVersion = "2.8.5" ...@@ -9,6 +9,8 @@ val gsonVersion = "2.8.5"
val modelmanagementprovider = ProjectRef(uri("https://git-st.inf.tu-dresden.de/cwerner/role_model_management_provider.git#master"), "modelmanagementprovider") val modelmanagementprovider = ProjectRef(uri("https://git-st.inf.tu-dresden.de/cwerner/role_model_management_provider.git#master"), "modelmanagementprovider")
val uiProvider = ProjectRef(uri("https://git-st.inf.tu-dresden.de/cwerner/role_ui_provider.git#master"), "uiprovider") val uiProvider = ProjectRef(uri("https://git-st.inf.tu-dresden.de/cwerner/role_ui_provider.git#master"), "uiprovider")
val modeljoin = ProjectRef(uri("https://git-st.inf.tu-dresden.de/cwerner/model_join.git"), "model_join")
javacOptions ++= Seq("-encoding", "UTF-8") javacOptions ++= Seq("-encoding", "UTF-8")
...@@ -52,6 +54,7 @@ lazy val generator = (project in file(".")) ...@@ -52,6 +54,7 @@ lazy val generator = (project in file("."))
oldStrategy(x) oldStrategy(x)
}, },
).dependsOn( ).dependsOn(
modeljoin,
modelmanagementprovider, modelmanagementprovider,
uiProvider uiProvider
) )
File deleted
...@@ -81,6 +81,8 @@ class Generator(config: GeneratorConfig) { ...@@ -81,6 +81,8 @@ class Generator(config: GeneratorConfig) {
} }
else else
{ {
//add ref methods
new SModelCombiRefMethodService prepareModel (sm._1)
//remove references //remove references
new SModelSUMRemoveRefService prepareModel (sm._1) new SModelSUMRemoveRefService prepareModel (sm._1)
} }
......
package org.rosi_project.model_sync.generator package org.rosi_project.model_sync.generator
import org.rosi_project.model_sync.provider.DisplayableModel
import org.rosi_project.model_sync.provider.ModelSyncProvider
/** Representation of a model configuration (i.e. a number of corresponding models). It tells the /** Representation of a model configuration (i.e. a number of corresponding models). It tells the
* generator how the model looks like, which types are needed, etc. * generator how the model looks like, which types are needed, etc.
* *
......
package org.rosi_project.model_sync.generator
import org.rosi_project.model_sync.generator.acr_model.SModel
import org.rosi_project.model_sync.generator.sync.ReferenceMethodCreationVisitor
/**
* Add a method to get all references in the RSUM case.
* Sync functions necessary because we need compartment functions in the naturals.
*
* @author Christopher Werner
*/
class SModelCombiRefMethodService {
/**
* Remove reference from model classes.
*
* @param sModel the model to augment
*/
def prepareModel(sModel: SModel): Unit = {
val refMethodVisitor = new ReferenceMethodCreationVisitor
//order is important !!!!
sModel.accept(refMethodVisitor)
}
}
\ No newline at end of file
...@@ -7,6 +7,7 @@ import org.rosi_project.model_management.sum.IViewTypeInfo ...@@ -7,6 +7,7 @@ import org.rosi_project.model_management.sum.IViewTypeInfo
import org.rosi_project.model_management.sum.query._ import org.rosi_project.model_management.sum.query._
import org.rosi_project.model_management.sum.join._ import org.rosi_project.model_management.sum.join._
import org.rosi_project.model_management.sum.compartments._ import org.rosi_project.model_management.sum.compartments._
import org.rosi_project.model_management.sum.roles.IRelationRole
object PredefRsumTypes { object PredefRsumTypes {
...@@ -44,6 +45,9 @@ object PredefRsumTypes { ...@@ -44,6 +45,9 @@ object PredefRsumTypes {
val AQUERY_VIEW_ROLE_STYPE = SType(AQUERY_VIEW_ROLE_CLASS.getSimpleName) //, AQUERY_VIEW_ROLE_CLASS.getPackage.getName) val AQUERY_VIEW_ROLE_STYPE = SType(AQUERY_VIEW_ROLE_CLASS.getSimpleName) //, AQUERY_VIEW_ROLE_CLASS.getPackage.getName)
//RELATIONAL COMPARTMENT TYPES //RELATIONAL COMPARTMENT TYPES
private val IRELATIONROLE_CLASS = classOf[IRelationRole]
val IRELATIONROLE_STYPE = SType(IRELATIONROLE_CLASS.getSimpleName, IRELATIONROLE_CLASS.getPackage.getName)
private val IAGGREGTATION_CLASS = classOf[IAggregation] private val IAGGREGTATION_CLASS = classOf[IAggregation]
val IAGGREGTATION_STYPE = SType(IAGGREGTATION_CLASS.getSimpleName, IAGGREGTATION_CLASS.getPackage.getName) val IAGGREGTATION_STYPE = SType(IAGGREGTATION_CLASS.getSimpleName, IAGGREGTATION_CLASS.getPackage.getName)
......
package org.rosi_project.model_sync.generator.sync
import org.rosi_project.model_sync.generator.acr_model._
class ReferenceMethodCreationVisitor extends SModelVisitor {
override def visit(sModel: SModel): Unit = {
sModel.getRelationalCompartments.foreach(cls => {
val relComp = cls.asInstanceOf[SRelationalCompartmentClass]
//iterate over all relational compartments
val methodSrc = new SMethod(
name = relComp.connectedRef.getName,
result = relComp.connectedRef.getTypeElement,
params = Seq.empty,
implementation = Seq.empty)
var implSrc: Seq[SMethodStatement] = Seq.empty
implSrc :+ SMethodStatement(content = s"var result: ${relComp.connectedRef.getTypeElement} = Set.empty")
implSrc :+ SMethodStatement(content = s"""this.roles.filter(r => r.isInstanceOf[${PredefRsumTypes.IRELATIONROLE_STYPE.getName}] &&
r.asInstanceOf[${PredefRsumTypes.IRELATIONROLE_STYPE.getName}].getOuterCompartment.isInstanceOf[${relComp.getName}])
.foreach(r => {
list += r.asInstanceOf[${PredefRsumTypes.IRELATIONROLE_STYPE.getName}].getOuterCompartment.getTargetIns.asInstanceOf[${relComp.tClass.getName}]
})""")
implSrc :+ SMethodStatement(content = "result")
methodSrc.implementation = implSrc
relComp.sClass.asInstanceOf[SClass].addMethod(methodSrc)
//proof opposite reference
if (relComp.connectedRef.hasOpposite) {
val methodTrg = new SMethod(
name = relComp.connectedRef.oppositeRef.getName,
result = relComp.connectedRef.oppositeRef.getTypeElement,
params = Seq.empty,
implementation = Seq.empty)
var implTrg: Seq[SMethodStatement] = Seq.empty
implTrg :+ SMethodStatement(content = s"var result: ${relComp.connectedRef.oppositeRef.getTypeElement} = Set.empty")
implTrg :+ SMethodStatement(content = s"""this.roles.filter(r => r.isInstanceOf[${PredefRsumTypes.IRELATIONROLE_STYPE.getName}] &&
r.asInstanceOf[${PredefRsumTypes.IRELATIONROLE_STYPE.getName}].getOuterCompartment.isInstanceOf[${relComp.getName}])
.foreach(r => {
list += r.asInstanceOf[${PredefRsumTypes.IRELATIONROLE_STYPE.getName}].getOuterCompartment.getSourceIns.asInstanceOf[${relComp.sClass.getName}]
})""")
implTrg :+ SMethodStatement(content = "result")
methodTrg.implementation = implTrg
relComp.tClass.asInstanceOf[SClass].addMethod(methodTrg)
}
})
sModel.getModelClasses.foreach(cls => {
//iterate over all references and add new method to class
cls.getReferences().foreach(ref => {
val method = new SMethod(
name = ref.getName,
result = ref.getTypeElement,
params = Seq.empty,
implementation = Seq.empty)
var impl: Seq[SMethodStatement] = Seq.empty
impl :+ SMethodStatement(content = s"var result: ${ref.getTypeElement} = Set.empty")
impl :+ SMethodStatement(content = s"""this.roles.filter(r => r.isInstanceOf[IRelationRole] &&
r.asInstanceOf[${PredefRsumTypes.IRELATIONROLE_STYPE.getName}].getOuterCompartment.isInstanceOf[VideoCassetteCastPerson])
.foreach(r => {
list += r.asInstanceOf[${PredefRsumTypes.IRELATIONROLE_STYPE.getName}].getOuterCompartment.getTargetIns.asInstanceOf[Person]
})""")
impl :+ SMethodStatement(content = "result")
method.implementation = impl
cls.addMethod(method)
})
})
}
override def visit(sClass: SClass): Unit = {
// pass
}
override def visit(sAttr: SAttribute): Unit = {
// pass
}
override def visit(sMethod: SMethod): Unit = {
// pass
}
override def visit(sType: SType): Unit = {
// pass
}
override def visit(sRef: SReference): Unit = {
// pass
}
}
\ No newline at end of file
...@@ -8,9 +8,9 @@ import org.rosi_project.model_sync.generator.Creation ...@@ -8,9 +8,9 @@ import org.rosi_project.model_sync.generator.Creation
object ApplicationTest extends App { object ApplicationTest extends App {
//runTestLibrary(Creation.rolesum) //runTestLibrary(Creation.rolesum)
//runCombinedTest(Creation.rolesum) runCombinedTest(Creation.rolecomb)
//runShrinkingModel(Creation.rolesum) //runShrinkingModel(Creation.rolesum)
runTestAML(Creation.rolesum) //runTestAML(Creation.rolesum)
//TTC Case examples //TTC Case examples
//runTTC2019(Creation.rolecomb) //runTTC2019(Creation.rolecomb)
......
...@@ -3,12 +3,6 @@ package org.rosi_project.model_sync.generator.ui ...@@ -3,12 +3,6 @@ package org.rosi_project.model_sync.generator.ui
import org.rosi_project.model_sync.generator.acr_model.SType import org.rosi_project.model_sync.generator.acr_model.SType
import org.rosi_project.model_sync.provider._ import org.rosi_project.model_sync.provider._
import org.rosi_project.model_sync.instances._ import org.rosi_project.model_sync.instances._
import org.rosi_project.model_sync.instances.ModelInstanceConstructor
import org.rosi_project.model_sync.instances.ModelInstanceModifier
import org.rosi_project.model_sync.provider.DisplayableModel
import org.rosi_project.model_sync.provider.DisplayableModelForInitialization
import org.rosi_project.model_sync.provider.DisplayableModelForIntegration
import org.rosi_project.model_sync.provider.ModelSyncProvider
object PredefUiTypes { object PredefUiTypes {
...@@ -23,7 +17,7 @@ object PredefUiTypes { ...@@ -23,7 +17,7 @@ object PredefUiTypes {
private val DISPLAYABLE_MODEL_FOR_INTEGRATION_CLASS = classOf[DisplayableModelForIntegration] private val DISPLAYABLE_MODEL_FOR_INTEGRATION_CLASS = classOf[DisplayableModelForIntegration]
val DISPLAYABLE_MODEL_FOR_INTEGRATION_STYPE = SType(DISPLAYABLE_MODEL_FOR_INTEGRATION_CLASS.getSimpleName, DISPLAYABLE_MODEL_FOR_INTEGRATION_CLASS.getPackage.getName) val DISPLAYABLE_MODEL_FOR_INTEGRATION_STYPE = SType(DISPLAYABLE_MODEL_FOR_INTEGRATION_CLASS.getSimpleName, DISPLAYABLE_MODEL_FOR_INTEGRATION_CLASS.getPackage.getName)
private val MODEL_SYNC_PROVIDER_CLASS = classOf[ModelSyncProvider] private val MODEL_SYNC_PROVIDER_CLASS = classOf[SyncProvider]
val MODEL_SYNC_PROVIDER_STYPE = SType(MODEL_SYNC_PROVIDER_CLASS.getSimpleName, MODEL_SYNC_PROVIDER_CLASS.getPackage.getName) val MODEL_SYNC_PROVIDER_STYPE = SType(MODEL_SYNC_PROVIDER_CLASS.getSimpleName, MODEL_SYNC_PROVIDER_CLASS.getPackage.getName)
private val MODEL_REGISTRY_CLASS = ModelRegistry.getClass private val MODEL_REGISTRY_CLASS = ModelRegistry.getClass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment