Commit 090f1561 authored by Rakshit Mittal's avatar Rakshit Mittal
Browse files

transformation rules updates and bug fixes

parent fb2bb954
......@@ -13,6 +13,7 @@ import fr.mem4csd.osatedim.viatra.queries.FindPropertyValue
import fr.mem4csd.osatedim.viatra.queries.FindSubcomponent
import fr.mem4csd.osatedim.viatra.queries.FindSystem
import fr.mem4csd.osatedim.viatra.utils.PropertyUtils
import fr.mem4csd.osatedim.viatra.queries.FindNullValueProperty
import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
import org.eclipse.viatra.transformation.evm.specific.Lifecycles
import org.eclipse.viatra.transformation.evm.specific.crud.CRUDActivationStateEnum
......@@ -24,6 +25,8 @@ import org.osate.aadl2.instance.SystemInstance
import org.osate.aadl2.modelsupport.FileNameConstants
import org.osate.aadl2.PropertySet
import org.eclipse.emf.common.util.URI
import org.osate.aadl2.instance.InstanceObject
import org.osate.aadl2.NamedElement
class DIMTransformationState extends DIMTransformationRules {
......@@ -54,7 +57,8 @@ class DIMTransformationState extends DIMTransformationRules {
private def createTransformation() {
this.manipulation = new SimpleModelManipulations(engine)
var fixedPriorityResolver = new InvertedDisappearancePriorityConflictResolver
fixedPriorityResolver.setPriority(cleanInstance2Declarative.ruleSpecification, 1)
fixedPriorityResolver.setPriority(cleanComponentInstance2Declarative.ruleSpecification, 1)
fixedPriorityResolver.setPriority(cleanPropertyInstance2Declarative.ruleSpecification, 1)
fixedPriorityResolver.setPriority(topSystemInstance2Declarative.ruleSpecification, 2)
fixedPriorityResolver.setPriority(componentInstance2Declarative.ruleSpecification, 3)
fixedPriorityResolver.setPriority(featureInstance2Declarative.ruleSpecification, 4)
......@@ -63,12 +67,14 @@ class DIMTransformationState extends DIMTransformationRules {
fixedPriorityResolver.setPriority(derivedModeInstance2Declarative.ruleSpecification, 7)
fixedPriorityResolver.setPriority(modeTransitionInstance2Declarative.ruleSpecification, 8)
fixedPriorityResolver.setPriority(propertyInstance2Declarative.ruleSpecification, 9)
fixedPriorityResolver.setPriority(modalProperty2Declarative.ruleSpecification, 9)
fixedPriorityResolver.setPriority(propertyValue2Declarative.ruleSpecification, 9)
fixedPriorityResolver.setPriority(modalProperty2Declarative.ruleSpecification, 10)
fixedPriorityResolver.setPriority(propertyValue2Declarative.ruleSpecification, 11)
fixedPriorityResolver.setPriority(cleanUpDeclarative.ruleSpecification, 12)
// fixedPriorityResolver.setPriority(flowspecinstance2declarative.ruleSpecification, 10)
transformation = EventDrivenTransformation.forEngine(engine).setConflictResolver(fixedPriorityResolver)
.addRule(cleanInstance2Declarative)
.addRule(cleanComponentInstance2Declarative)
.addRule(cleanPropertyInstance2Declarative)
.addRule(topSystemInstance2Declarative)
.addRule(componentInstance2Declarative)
.addRule(featureInstance2Declarative)
......@@ -79,17 +85,25 @@ class DIMTransformationState extends DIMTransformationRules {
.addRule(propertyInstance2Declarative)
.addRule(modalProperty2Declarative)
.addRule(propertyValue2Declarative)
.addRule(cleanUpDeclarative)
// .addRule(flowspecinstance2declarative)
.build
}
// Clean instance model
protected val cleanInstance2Declarative = createRule(FindComponent.instance)
// Clean instance model components
protected val cleanComponentInstance2Declarative = createRule(FindComponent.instance)
.action(CRUDActivationStateEnum.CREATED) [
compinst.set(componentInstance_Classifier, null)
compinst.set(componentInstance_Classifier, null)
println("DIM: Component instance "+compinst.name+" cleaned")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// Clean instance model properties
protected val cleanPropertyInstance2Declarative = createRule(FindProperty.instance)
.action(CRUDActivationStateEnum.CREATED) [
propinst.set(propertyAssociationInstance_PropertyAssociation, null)
println("DIM: Property association instance "+propinst.property.name+" cleaned")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// Top-level SystemInstance transformation
protected val topSystemInstance2Declarative = createRule(FindSystem.instance)
.action(CRUDActivationStateEnum.CREATED) [
......@@ -131,13 +145,13 @@ class DIMTransformationState extends DIMTransformationRules {
protected val modeInstance2Declarative = createRule(FindMode.instance)
.action(CRUDActivationStateEnum.CREATED) [
modeInstanceCreatedDIM(modeinst)
println("DIM: Mode instance "+modeinst.name+" de-instantiated")
println("DIM: Mode instance "+modeinst.name+" for component "+(modeinst.eContainer as InstanceObject).name+" de-instantiated")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
protected val derivedModeInstance2Declarative = createRule(FindDerivedMode.instance)
.action(CRUDActivationStateEnum.CREATED) [
modeInstanceCreatedDIM(modeinst)
println("DIM: Mode instance "+modeinst.name+" de-instantiated")
println("DIM: Mode instance "+modeinst.name+" for component "+(modeinst.eContainer as InstanceObject).name+" de-instantiated")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// ModeTransitionInstance Transformation
......@@ -152,21 +166,36 @@ class DIMTransformationState extends DIMTransformationRules {
.action(CRUDActivationStateEnum.CREATED) [
if (!PropertyUtils.isInheritedProperty(propinst)) {
propertyInstanceCreatedDIM(propinst, aadlPublicPackage)
println("DIM: Property instance "+propinst.property.name+" de-instantiated")
println("DIM: Property instance "+propinst.property.name+" attached to "+(propinst.eContainer as InstanceObject).name+" de-instantiated")
} else {
println("DIM: Property instance "+propinst.property.name+" inherited")
println("DIM: Property instance "+propinst.property.name+" attached to "+(propinst.eContainer as InstanceObject).name+" inherited")
}
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// ModalProperty Value Transformation
protected val modalProperty2Declarative = createRule(FindModalProperty.instance)
.action(CRUDActivationStateEnum.CREATED) [
modalPropertyCreatedDIM(modpropinst)
if (!PropertyUtils.isInheritedProperty(propinst)) {
modalPropertyCreatedDIM(modpropinst)
println("DIM: Modal property instance for property "+propinst.property.name+" attached to "+(propinst.eContainer as InstanceObject).name+" de-instantiated")
}
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// PropertyValue Transformation
protected val propertyValue2Declarative = createRule(FindPropertyValue.instance)
.action(CRUDActivationStateEnum.CREATED) [
propertyValueCreatedDIM(propinst, modpropinst, propvalinst)
if (!PropertyUtils.isInheritedProperty(propinst)) {
if (PropertyUtils.getDeclarativeModalPropertyValue(modpropinst,propinst.propertyAssociation).ownedValue === null) {
propertyValueCreatedDIM(propinst, modpropinst, propvalinst)
println("DIM: Value of property "+propinst.property.name+" (for "+(propinst.eContainer as InstanceObject).name+") de-instantiated")
}
}
].addLifeCycle(Lifecycles.getDefault(true, true)).build
// Clean up transformation
protected val cleanUpDeclarative = createRule(FindNullValueProperty.instance)
.action(CRUDActivationStateEnum.CREATED) [
println("DIM: "+propassoc.property.name+" in declarative object "+(propassoc.eContainer as NamedElement).name+" deleted because it has no owned value!")
propassoc.eContainer.remove(namedElement_OwnedPropertyAssociation, propassoc)
].addLifeCycle(Lifecycles.getDefault(true, true)).build
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment