Commit dea461ff authored by Rakshit Mittal's avatar Rakshit Mittal
Browse files

fixed bug in transformation by adding manipulations extension to rules

classes
parent 84e3926e
......@@ -39,19 +39,19 @@ import org.osate.aadl2.ModeBinding
class DIMTransformationDeltaInplace extends DIMTransformationRules{
public extension EventDrivenTransformation transformation
protected extension EventDrivenTransformation transformation
new(SystemInstance topSystemInst, ViatraQueryEngine engine, DIMPreferences preferences) {
this.topSystemInst = topSystemInst
this.aadlPublicPackage = topSystemInst.componentClassifier.owner as PublicPackageSection
this.engine = engine
this.preferences = preferences;
componentRules = new DIMTransformationRulesComponent
featureRules = new DIMTransformationRulesFeature
connectionRules = new DIMTransformationRulesConnection
modeRules = new DIMTransformationRulesMode
propertyRules = new DIMTransformationRulesProperty
transformationUtils = new DIMTransformationRulesExtension
componentRules = new DIMTransformationRulesComponent(manipulation)
featureRules = new DIMTransformationRulesFeature(manipulation)
connectionRules = new DIMTransformationRulesConnection(manipulation)
modeRules = new DIMTransformationRulesMode(manipulation)
propertyRules = new DIMTransformationRulesProperty(manipulation)
transformationUtils = new DIMTransformationRulesExtension(manipulation)
prepare(engine)
createTransformation
}
......@@ -267,6 +267,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: Derived value of mode instance "+modeinst.name+" updated")
}
].action(CRUDActivationStateEnum.DELETED) [
modeRules.modeChangedParentSubcomponentDefinition(modeinst)
(modeinst.mode.eContainer as ComponentClassifier).remove(componentClassifier_OwnedMode, modeinst.mode)
println("DIM: Mode instance "+modeinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -280,9 +281,39 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: Declarative of mode instance "+modeinst.name+" already exists!")
}
].action(CRUDActivationStateEnum.UPDATED) [
modeinst.mode.set(namedElement_Name, modeinst.name)
println("DIM: Mode instance "+modeinst.name+" updated")
modeRules.modeChangedParentSubcomponentDefinition(modeinst)
// Mode name change
if (modeinst.name !== modeinst.mode.name) {
modeinst.mode.set(namedElement_Name, modeinst.name)
println("DIM: Name of mode instance "+modeinst.name+" updated")
}
// Mode initial boolean changed
if (modeinst.initial !== modeinst.mode.initial) {
modeinst.mode.set(mode_Initial, modeinst.initial)
println("DIM: Initial value of mode instance "+modeinst.name+" updated")
}
// Mode binding added/changed
var compinst = modeinst.eContainer as ComponentInstance
if (modeinst.derived !== compinst.classifier.derivedModes) {
if (modeinst.derived == true) {
(modeinst.mode.eContainer as ComponentClassifier).set(componentClassifier_DerivedModes, true)
var modebind = compinst.subcomponent.createChild(subcomponent_OwnedModeBinding, modeBinding)
modebind.set(modeBinding_DerivedMode, modeinst.mode)
if (!modeinst.parents.isEmpty) {
modebind.set(modeBinding_ParentMode, modeinst.parents.get(0).mode)
}
} else {
(modeinst.mode.eContainer as ComponentClassifier).set(componentClassifier_DerivedModes, false)
for (ModeBinding modeBind : compinst.subcomponent.ownedModeBindings) {
if (modeBind.derivedMode == modeinst.mode) {
modeBind.eContainer.remove(subcomponent_OwnedModeBinding, modeBind)
}
}
}
println("DIM: Derived value of mode instance "+modeinst.name+" updated")
}
].action(CRUDActivationStateEnum.DELETED) [
modeRules.modeChangedParentSubcomponentDefinition(modeinst)
(modeinst.mode.eContainer as ComponentClassifier).remove(componentClassifier_OwnedMode, modeinst.mode)
println("DIM: Mode instance "+modeinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -302,9 +333,24 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
println("DIM: Declarative of mode transition instance "+modetransinst.name+" already exists!")
}
].action(CRUDActivationStateEnum.UPDATED) [
modetransinst.modeTransition.set(namedElement_Name, modetransinst.name)
println("DIM: ModeTransition instance "+modetransinst.name+" updated")
modeRules.modeTransChangedParentSubcomponentDefinition(modetransinst)
// Mode transition name change
if (modetransinst.name !== modetransinst.modeTransition.name) {
modetransinst.modeTransition.set(namedElement_Name, modetransinst.name)
println("DIM: Name of mode transition instance "+modetransinst.name+" updated")
}
// Mode transition source change
if (modetransinst.source.mode !== modetransinst.modeTransition.source) {
modetransinst.modeTransition.set(modeTransition_Source, modetransinst.source.mode)
println("DIM: Source of mode transition instance "+modetransinst.name+" updated")
}
// Mode transition destination change
if (modetransinst.destination.mode !== modetransinst.modeTransition.destination) {
modetransinst.modeTransition.set(modeTransition_Destination, modetransinst.destination.mode)
println("DIM: Destination of mode transition instance "+modetransinst.name+" updated")
}
].action(CRUDActivationStateEnum.DELETED) [
modeRules.modeTransChangedParentSubcomponentDefinition(modetransinst)
(modetransinst.modeTransition.eContainer as ComponentClassifier).remove(componentClassifier_OwnedModeTransition, modetransinst.modeTransition)
println("DIM: ModeTransition instance "+modetransinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......
......@@ -22,12 +22,16 @@ import org.osate.aadl2.ThreadImplementation
import org.osate.aadl2.VirtualBusImplementation
import org.osate.aadl2.VirtualProcessorImplementation
import org.osate.aadl2.instance.ComponentInstance
import org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.IModelManipulations
class DIMTransformationRulesComponent extends DIMTransformationRules {
private def DIMTransformationRulesComponent() {
new(IModelManipulations manipulation) {
this.manipulation = manipulation
}
extension IModelManipulations manipulation
def void componentInstanceCreatedDIM(ComponentInstance subcompinst) {
val compinst = subcompinst.eContainer as ComponentInstance
// Parent Component Implementation Creation
......
......@@ -14,9 +14,16 @@ import org.osate.aadl2.DirectionType
import fr.mem4csd.osatedim.viatra.utils.LibraryUtils
import org.osate.aadl2.ModelUnit
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.IModelManipulations
class DIMTransformationRulesConnection extends DIMTransformationRules {
new(IModelManipulations manipulation) {
this.manipulation = manipulation
}
extension IModelManipulations manipulation
protected def connectionInstanceCreatedDIM(ConnectionInstance conninst, DIMTransformationRulesFeature featureRules) {
var complist = InstanceHierarchyUtils.getPathBetweenComponentInstance(conninst.source.eContainer as ComponentInstance,conninst.destination.eContainer as ComponentInstance)
for (ComponentInstance currentcompinst : complist) {
......
......@@ -3,9 +3,16 @@ package fr.mem4csd.osatedim.viatra.transformations
import org.osate.aadl2.instance.InstanceObject
import org.osate.aadl2.PropertyAssociation
import org.osate.aadl2.instance.ComponentInstance
import org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.IModelManipulations
class DIMTransformationRulesExtension extends DIMTransformationRules {
new(IModelManipulations manipulation) {
this.manipulation = manipulation
}
extension IModelManipulations manipulation
protected def elementCreationPropertyInheritance (InstanceObject instanceObj, DIMTransformationRulesProperty propertyRules) {
for (PropertyAssociation propinst : (instanceObj.eContainer as InstanceObject).ownedPropertyAssociations) {
if (propinst.property.inherit || instanceObj.acceptsProperty(propinst.property)) {
......
......@@ -25,12 +25,16 @@ import org.osate.aadl2.instance.ComponentInstance
import org.osate.aadl2.instance.FeatureCategory
import org.osate.aadl2.instance.FeatureInstance
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.IModelManipulations
class DIMTransformationRulesFeature extends DIMTransformationRules {
private def DIMTransformationRulesFeature() {
new(IModelManipulations manipulation) {
this.manipulation = manipulation
}
extension IModelManipulations manipulation
def featureInstanceCreatedDIM(FeatureInstance featinst) {
var compinst = featinst.eContainer as ComponentInstance
var ComponentType comptype;
......
......@@ -38,9 +38,16 @@ import org.osate.aadl2.ReferenceValue
import fr.mem4csd.osatedim.viatra.utils.TraceUtils
import org.osate.aadl2.PublicPackageSection
import org.osate.aadl2.NamedElement
import org.eclipse.viatra.transformation.runtime.emf.modelmanipulation.IModelManipulations
class DIMTransformationRulesProperty extends DIMTransformationRules {
new(IModelManipulations manipulation) {
this.manipulation = manipulation
}
extension IModelManipulations manipulation
protected def propertyInstanceCreatedDIM(PropertyAssociationInstance propinst, PublicPackageSection aadlPackage) {
//Property PropertySet Addition
if (propinst.property !== null) {
......
......@@ -33,11 +33,11 @@ class DIMTransformationState extends DIMTransformationRules {
this.engine = engine
this.preferences = preferences
prepare(engine)
componentRules = new DIMTransformationRulesComponent
featureRules = new DIMTransformationRulesFeature
connectionRules = new DIMTransformationRulesConnection
modeRules = new DIMTransformationRulesMode
propertyRules = new DIMTransformationRulesProperty
componentRules = new DIMTransformationRulesComponent(manipulation)
featureRules = new DIMTransformationRulesFeature(manipulation)
connectionRules = new DIMTransformationRulesConnection(manipulation)
modeRules = new DIMTransformationRulesMode(manipulation)
propertyRules = new DIMTransformationRulesProperty(manipulation)
createTransformation
}
......
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