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

refactored transformation rules due to xtend non-scalabaility lag

parent d2023e0b
......@@ -35,19 +35,19 @@ import org.osate.aadl2.instance.SystemOperationMode;
import org.osate.aadl2.modelsupport.FileNameConstants;
import fr.tpt.mem4csd.utils.osate.standalone.OsateStandaloneSetup;
public class InplaceModifications {
public class InplaceModifications{
public InplaceModifications(SystemInstance topSystemInst) {
this.resSet = topSystemInst.eResource().getResourceSet();
this.aadlProjectResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "AADL_Project" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
this.deploymentResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "Deployment_Properties" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
this.dataModelResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.ANNEX_CONTRIBUTION_PROPERTY_SETS_URI.appendSegment( "Data_Model" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
this.memoryResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "Memory_Properties" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
this.ramsesResource = (PropertySet) resSet.getResource(topSystemInst.eResource().getURI().trimSegments(3).appendSegment( "RAMSES" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
this.aadlRuntimeResource = (AadlPackage) resSet.getResource(topSystemInst.eResource().getURI().trimSegments(3).appendSegment( "AADL_Runtime" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
this.programmingResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "Programming_Properties" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
this.baseTypesResource = (AadlPackage) (AadlPackage) resSet.getResource(OsateStandaloneSetup.ANNEX_CONTRIBUTION_PACKAGES_URI.appendSegment( "Base_Types" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
this.threadResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "Thread_Properties" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true );
resSet = topSystemInst.eResource().getResourceSet();
aadlProjectResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "AADL_Project" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
deploymentResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "Deployment_Properties" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
dataModelResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.ANNEX_CONTRIBUTION_PROPERTY_SETS_URI.appendSegment( "Data_Model" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
memoryResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "Memory_Properties" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
ramsesResource = (PropertySet) resSet.getResource(topSystemInst.eResource().getURI().trimSegments(4).appendSegment( "RAMSES" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
aadlRuntimeResource = (AadlPackage) resSet.getResource(topSystemInst.eResource().getURI().trimSegments(4).appendSegment( "AADL_Runtime" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
programmingResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "Programming_Properties" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
baseTypesResource = (AadlPackage) (AadlPackage) resSet.getResource(OsateStandaloneSetup.ANNEX_CONTRIBUTION_PACKAGES_URI.appendSegment( "Base_Types" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
threadResource = (PropertySet) resSet.getResource(OsateStandaloneSetup.PREDECLARED_POPERTY_SETS_URI.appendSegment( "Thread_Properties" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
}
private final ResourceSet resSet;
......
......@@ -10,7 +10,7 @@ import fr.mem4csd.osatedim.viatra.transformations.DIMTransformationDeltaInplace;
public class TestDeltaInplace extends TestAbstract {
InplaceModifications modifications = new InplaceModifications((SystemInstance) aaxlResource.getContents().get(0));
InplaceModifications modifications;
protected DIMTransformationDeltaInplace initiateDIMTransformationDeltaInplace(String inputModelName) {
prepareTestDeltaInplaceResources(inputModelName);
......@@ -22,7 +22,9 @@ public class TestDeltaInplace extends TestAbstract {
private void prepareTestDeltaInplaceResources(String inputModelName) {
ResourceSet resSet = prepareTestResources(inputModelName);
aadlResource = resSet.createResource(((SystemInstance) aaxlResource.getContents().get(0)).getComponentImplementation().eResource().getURI());
aadlResource = resSet.getResource(((SystemInstance) aaxlResource.getContents().get(0)).getComponentImplementation().eResource().getURI(), true);
modifications = new InplaceModifications((SystemInstance) aaxlResource.getContents().get(0));
}
@Test
......@@ -36,6 +38,7 @@ public class TestDeltaInplace extends TestAbstract {
@Test
public void testRAMSESInplace() throws Exception {
InplaceModifications modifications = new InplaceModifications((SystemInstance) aaxlResource.getContents().get(0));
computeFinalBaseDirectory(1, 1);
DIMTransformationDeltaInplace transformation = initiateDIMTransformationDeltaInplace("sampled-communications-local-communications_refined_model_impl_Instance");
modifications.modifyRAMSESInplace(transformation.getTopSystemInst());
......
package fr.mem4csd.osatedim.tests;
import java.io.IOException;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.junit.jupiter.api.Test;
import org.osate.aadl2.AadlPackage;
import org.osate.aadl2.modelsupport.FileNameConstants;
import fr.mem4csd.osatedim.ui.utils.DeinstantiationUtils;
import fr.mem4csd.osatedim.viatra.utils.PackageUtils;
import fr.mem4csd.osatedim.viatra.utils.TransformationUtils;
......@@ -23,6 +22,7 @@ public class TestState extends TestAbstract {
protected static void prepareTestStateResources(String inputModelName) {
ResourceSet resSet = prepareTestResources(inputModelName);
resSet.getResource(topSystemInst.eResource().getURI().trimSegments(4).appendSegment( "RAMSES" ).appendFileExtension( FileNameConstants.SOURCE_FILE_EXT ), true ).getContents().get(0);
final URI declarativeModelUri = DeinstantiationUtils.computeDeclarativeUri(aaxlResource.getURI(), topSystemInst);
aadlResource = resSet.createResource(declarativeModelUri);
}
......
......@@ -10,6 +10,7 @@
<query-specification fqn="fr.mem4csd.osatedim.viatra.queries.findDerivedMode"/>
<query-specification fqn="fr.mem4csd.osatedim.viatra.queries.findModeTransition"/>
<query-specification fqn="fr.mem4csd.osatedim.viatra.queries.findProperty"/>
<query-specification fqn="fr.mem4csd.osatedim.viatra.queries.findModalProperty"/>
<query-specification fqn="fr.mem4csd.osatedim.viatra.queries.findPropertyValue"/>
</group>
</extension>
......
......@@ -68,19 +68,28 @@ pattern findProperty(propinst : PropertyAssociationInstance)
InstanceObject.ownedPropertyAssociation(_,propinst);
}
pattern findModalProperty(modpropinst : ModalPropertyValue)
{
PropertyAssociationInstance.ownedValue(_,modpropinst);
}
// Find property value attached to a property instance
pattern findPropertyValue(propvalinst : PropertyValue)
pattern findPropertyValue(propinst : PropertyAssociationInstance, modpropinst : ModalPropertyValue, propvalinst : PropertyValue)
{
PropertyAssociationInstance.ownedValue.ownedValue(_,propvalinst);
PropertyAssociationInstance.ownedValue(propinst,modpropinst);
ModalPropertyValue.ownedValue(modpropinst,propvalinst);
} or {
PropertyAssociationInstance.ownedValue.ownedValue(_,recvalinst);
PropertyAssociationInstance.ownedValue(propinst,modpropinst);
ModalPropertyValue.ownedValue(modpropinst,recvalinst);
RecordValue.ownedFieldValue.ownedValue(recvalinst,propvalinst);
} or {
PropertyAssociationInstance.ownedValue.ownedValue(_,listvalinst);
PropertyAssociationInstance.ownedValue(propinst,modpropinst);
ModalPropertyValue.ownedValue(modpropinst,listvalinst);
ListValue.ownedListElement(listvalinst,propvalinst);
neg RecordValue(propvalinst);
} or {
PropertyAssociationInstance.ownedValue.ownedValue(_,listvalinst);
PropertyAssociationInstance.ownedValue(propinst,modpropinst);
ModalPropertyValue.ownedValue(modpropinst,listvalinst);
ListValue.ownedListElement(listvalinst,listrecvalinst);
RecordValue.ownedFieldValue.ownedValue(listrecvalinst,propvalinst);
}
\ No newline at end of file
......@@ -23,21 +23,42 @@ import org.osate.aadl2.DirectionType
import org.osate.aadl2.PublicPackageSection
import org.osate.aadl2.instance.ComponentInstance
import org.osate.aadl2.instance.SystemInstance
import fr.mem4csd.osatedim.viatra.queries.FindModalProperty
import org.osate.aadl2.instance.PropertyAssociationInstance
import org.osate.aadl2.Mode
import fr.mem4csd.osatedim.viatra.utils.ModeUtils
import org.osate.aadl2.instance.InstanceObject
import org.osate.aadl2.instance.SystemOperationMode
import org.osate.aadl2.ModalPropertyValue
import org.osate.aadl2.modelsupport.util.AadlUtil
import org.osate.aadl2.PropertySet
import org.osate.aadl2.modelsupport.resources.OsateResourceUtil
class DIMTransformationDeltaInplace extends DIMTransformationRules{
extension EventDrivenTransformation transformation
extension DIMTransformationUtils transformationUtils
new(SystemInstance topSystemInst, ViatraQueryEngine engine) {
this.topSystemInst = topSystemInst
this.aadlPackage = topSystemInst.componentClassifier.owner as PublicPackageSection
this.engine = engine
componentRules = new DIMTransformationRulesComponent
featureRules = new DIMTransformationRulesFeature
connectionRules = new DIMTransformationRulesConnection
modeRules = new DIMTransformationRulesMode
propertyRules = new DIMTransformationRulesProperty
transformationUtils = new DIMTransformationUtils
prepare(engine)
createTransformation
}
DIMTransformationRulesComponent componentRules
DIMTransformationRulesFeature featureRules
DIMTransformationRulesConnection connectionRules
DIMTransformationRulesMode modeRules
DIMTransformationRulesProperty propertyRules
DIMTransformationUtils transformationUtils
def execute() {
transformation.executionSchema.startUnscheduledExecution
}
......@@ -60,7 +81,8 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
fixedPriorityResolver.setPriority(derivedModeInstance2Declarative.ruleSpecification, 6)
fixedPriorityResolver.setPriority(modeTransitionInstance2Declarative.ruleSpecification, 7)
fixedPriorityResolver.setPriority(propertyInstance2Declarative.ruleSpecification, 8)
fixedPriorityResolver.setPriority(propertyval2declarative.ruleSpecification, 9)
fixedPriorityResolver.setPriority(modalProperty2Declarative.ruleSpecification, 9)
fixedPriorityResolver.setPriority(propertyval2declarative.ruleSpecification, 10)
// fixedPriorityResolver.setPriority(flowspecinstance2declarative.ruleSpecification, 10)
transformation = EventDrivenTransformation
......@@ -74,6 +96,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
.addRule(derivedModeInstance2Declarative)
.addRule(modeTransitionInstance2Declarative)
.addRule(propertyInstance2Declarative)
.addRule(modalProperty2Declarative)
.addRule(propertyval2declarative)
// .addRule(flowspecinstance2declarative)
.build
......@@ -90,9 +113,9 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val componentInstance2Declarative = createRule(FindSubcomponent.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if (subcompinst.subcomponent === null) {
componentInstanceCreatedDIM(subcompinst)
if (transformationUtils.propertyInheritancePreference = true) {
transformationUtils.elementCreationPropertyInheritance(subcompinst)
componentRules.componentInstanceCreatedDIM(subcompinst)
if (getInheritProperty(OsateResourceUtil.toIFile(topSystemInst.eResource.URI).getProject())) {
transformationUtils.elementCreationPropertyInheritance(subcompinst, propertyRules)
}
println("DIM: Component instance "+subcompinst.name+" de-instantiated")
} else {
......@@ -106,7 +129,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
subcompinst.subcomponent.set(subcomponent_Classifier, subcompinst.classifier)
println("DIM: Component instance "+subcompinst.name+" updated")
].action(CRUDActivationStateEnum.DELETED) [
componentInstanceDeletedDIM(subcompinst)
componentRules.componentInstanceDeletedDIM(subcompinst)
println("DIM: Component instance "+subcompinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -114,9 +137,9 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val featureInstance2Declarative = createRule(FindFeature.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if (featinst.feature === null) {
featureInstanceCreatedDIM(featinst)
if (transformationUtils.propertyInheritancePreference = true) {
transformationUtils.elementCreationPropertyInheritance(featinst)
featureRules.featureInstanceCreatedDIM(featinst)
if (getInheritProperty(OsateResourceUtil.toIFile(topSystemInst.eResource.URI).getProject())) {
transformationUtils.elementCreationPropertyInheritance(featinst, propertyRules)
}
println("DIM: Feature instance "+featinst.name+" de-instantiated")
} else {
......@@ -139,7 +162,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
}
println("DIM: Feature instance "+featinst.name+" updated")
].action(CRUDActivationStateEnum.DELETED) [
featureInstanceDeletedDIM(featinst)
featureRules.featureInstanceDeletedDIM(featinst)
println("DIM: Feature instance "+featinst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -147,9 +170,9 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val connectionInstance2Declarative = createRule(FindConnection.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if (conninst.connectionReferences.size < InstanceHierarchyUtils.getPathBetweenComponentInstance(conninst.source.eContainer as ComponentInstance,conninst.destination.eContainer as ComponentInstance).size) {
connectionInstanceCreatedDIM(conninst)
if (transformationUtils.propertyInheritancePreference = true) {
transformationUtils.elementCreationPropertyInheritance(conninst)
connectionRules.connectionInstanceCreatedDIM(conninst, featureRules)
if (getInheritProperty(OsateResourceUtil.toIFile(topSystemInst.eResource.URI).getProject())) {
transformationUtils.elementCreationPropertyInheritance(conninst, propertyRules)
}
println("DIM: Connection instance "+conninst.name+" de-instantiated")
} else {
......@@ -158,7 +181,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
].action(CRUDActivationStateEnum.UPDATED) [
println("DIM: WARNING: Connection instance "+conninst.name+" updated. Connection instance update synchronization not supported in this version of OSATE-DIM!")
].action(CRUDActivationStateEnum.DELETED) [
connectionInstanceDeletedDIM(conninst)
connectionRules.connectionInstanceDeletedDIM(conninst)
println("DIM: Connection instance "+conninst.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......@@ -166,7 +189,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val modeInstance2Declarative = createRule(FindMode.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if(modeinst.mode === null) {
modeInstanceCreatedDIM(modeinst)
modeRules.modeInstanceCreatedDIM(modeinst)
println("DIM: Mode instance "+modeinst.name+" de-instantiated")
} else {
println("DIM: Declarative of mode instance "+modeinst.name+" already exists!")
......@@ -182,7 +205,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val derivedModeInstance2Declarative = createRule(FindDerivedMode.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if(modeinst.mode === null) {
modeInstanceCreatedDIM(modeinst)
modeRules.modeInstanceCreatedDIM(modeinst)
println("DIM: Mode instance "+modeinst.name+" de-instantiated")
} else {
println("DIM: Declarative of mode instance "+modeinst.name+" already exists!")
......@@ -199,9 +222,9 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
val modeTransitionInstance2Declarative = createRule(FindModeTransition.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
if(modetransinst.modeTransition === null) {
modeTransitionInstanceCreatedDIM(modetransinst)
if (transformationUtils.propertyInheritancePreference = true) {
transformationUtils.elementCreationPropertyInheritance(modetransinst)
modeRules.modeTransitionInstanceCreatedDIM(modetransinst)
if (getInheritProperty(OsateResourceUtil.toIFile(topSystemInst.eResource.URI).getProject())) {
transformationUtils.elementCreationPropertyInheritance(modetransinst, propertyRules)
}
println("DIM: ModeTransition instance "+modetransinst.name+" de-instantiated")
} else {
......@@ -220,7 +243,7 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
.action(CRUDActivationStateEnum.CREATED) [
if(propinst.propertyAssociation === null) {
if (!PropertyUtils.isInheritedProperty(propinst)) {
propertyInstanceCreatedDIM(propinst, aadlPackage)
propertyRules.propertyInstanceCreatedDIM(propinst)
println("DIM: Property instance "+propinst.property.name+" de-instantiated")
} else {
println("DIM: Property instance "+propinst.property.name+" inherited")
......@@ -228,18 +251,48 @@ class DIMTransformationDeltaInplace extends DIMTransformationRules{
} else {
println("DIM: Declarative of property instance "+propinst.property.name+" already exists!")
}
].action(CRUDActivationStateEnum.UPDATED)[
if (propinst.property !== null) {
if (!aadlPackage.importedUnits.contains(propinst.property.eContainer)) {
if (aadlPackage.noAnnexes === true) {
aadlPackage.set(packageSection_NoAnnexes, false)
}
if (!AadlUtil.isPredeclaredPropertySet((propinst.property.eContainer as PropertySet).name)) {
aadlPackage.add(packageSection_ImportedUnit, propinst.property.eContainer)
}
}
propinst.propertyAssociation.set(propertyAssociation_Property, propinst.property)
}
].action(CRUDActivationStateEnum.DELETED) [
propinst.propertyAssociation.eContainer.remove(namedElement_OwnedPropertyAssociation,propinst.propertyAssociation)
println("DIM: Property instance "+propinst.property.name+" deleted")
].addLifeCycle(Lifecycles.getDefault(true, true)).build
val modalProperty2Declarative = createRule(FindModalProperty.Matcher.querySpecification)
.action(CRUDActivationStateEnum.CREATED) [
propertyRules.modalPropertyCreatedDIM(modpropinst)
].action(CRUDActivationStateEnum.UPDATED) [
// ModalPropertyValue inModes
if (!(modpropinst.inModes.isEmpty())) {
val ModalPropertyValue modprop = PropertyUtils.getDeclarativeModalPropertyValue(modpropinst, (modpropinst.eContainer as PropertyAssociationInstance).propertyAssociation)
modprop.inModes.clear
for (Mode modpropmode : modpropinst.inModes) {
PropertyUtils.getDeclarativeModalPropertyValue(modpropinst, (modpropinst.eContainer as PropertyAssociationInstance).propertyAssociation).add(modalElement_InMode,ModeUtils.findObjectModeInstInSOM(modpropinst.eContainer.eContainer as InstanceObject, modpropmode as SystemOperationMode).mode)
}
}
].action(CRUDActivationStateEnum.DELETED) [
modpropinst.eContainer.remove(propertyAssociation_OwnedValue, PropertyUtils.getDeclarativeModalPropertyValue(modpropinst, (modpropinst.eContainer as PropertyAssociationInstance).propertyAssociation))
].addLifeCycle(Lifecycles.getDefault(true, true)).build
val propertyval2declarative = createRule(FindPropertyValue.Matcher.querySpecification)
.action(CRUDActivationStateEnum.UPDATED) [
.action(CRUDActivationStateEnum.CREATED)[
propertyRules.propertyValueCreatedDIM(propinst, modpropinst, propvalinst)
].action(CRUDActivationStateEnum.UPDATED) [
if (PropertyUtils.isInheritedProperty(PropertyUtils.getContainingPropertyAssociationInstance(propvalinst))) {
propertyInstanceCreatedDIM(PropertyUtils.getContainingPropertyAssociationInstance(propvalinst), aadlPackage)
propertyRules.propertyInstanceCreatedDIM(PropertyUtils.getContainingPropertyAssociationInstance(propvalinst))
println("DIM: Inherited property instance "+PropertyUtils.getContainingPropertyAssociationInstance(propvalinst).property.name+" value updated")
} else {
propertyValueUpdatedDIM(propvalinst, aadlPackage)
propertyRules.propertyValueUpdatedDIM(propvalinst, aadlPackage)
println("DIM: Property instance "+PropertyUtils.getContainingPropertyAssociationInstance(propvalinst).property.name+" value updated")
}
].addLifeCycle(Lifecycles.getDefault(true, true)).build
......
package fr.mem4csd.osatedim.viatra.transformations
import org.osate.aadl2.instance.ConnectionInstance
import fr.mem4csd.osatedim.viatra.utils.InstanceHierarchyUtils
import org.osate.aadl2.instance.ComponentInstance
import org.osate.aadl2.instance.FeatureInstance
import org.osate.aadl2.ComponentImplementation
import org.osate.aadl2.instance.ConnectionKind
import org.osate.aadl2.Feature
import org.osate.aadl2.instance.ConnectionReference
import org.osate.aadl2.ComponentCategory
import org.osate.aadl2.ComponentType
import org.osate.aadl2.DirectionType
class DIMTransformationRulesConnection extends DIMTransformationRules {
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) {
// Source Feature Selection
var currentsrcfeat = {
if (complist.indexOf(currentcompinst) == 0) {
(conninst.source as FeatureInstance).feature
} else {
(conninst.connectionReferences.get(conninst.connectionReferences.size - 1).destination as FeatureInstance).feature
}
}
// Destination Feature Selection/Creation
var ComponentInstance feataddcompinst
var currentdestfeat = {
if (complist.indexOf(currentcompinst) == complist.size-1) {
(conninst.destination as FeatureInstance).feature
} else {
feataddcompinst = {
if (complist.get(complist.indexOf(currentcompinst)+1).eContainer() == currentcompinst) {
complist.get(complist.indexOf(currentcompinst)+1)
} else {
currentcompinst
}
}
var feataddcomptype = (feataddcompinst.classifier as ComponentImplementation).type
featureRules.featureCreation(feataddcompinst, feataddcomptype, conninst.source as FeatureInstance)
}
}
if (!(complist.indexOf(currentcompinst) == complist.size-1)) {
currentdestfeat.set(namedElement_Name,conninst.name+"_feat")
currentdestfeat.set(directedFeature_In,true)
currentdestfeat.set(directedFeature_Out,true)
// Destination FeatureInstance Creation
var currentdestfeatinst = feataddcompinst.createChild(componentInstance_FeatureInstance,featureInstance)
currentdestfeatinst.set(featureInstance_Category, (conninst.source as FeatureInstance).category)
currentdestfeatinst.set(featureInstance_Direction, DirectionType.IN_OUT)
currentdestfeatinst.set(namedElement_Name, conninst.name+"_feat")
currentdestfeatinst.set(featureInstance_Feature, currentdestfeat)
}
// Connection Creation
var connadd = {
switch (conninst.kind) {
case ConnectionKind.ACCESS_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedAccessConnection, accessConnection)
case ConnectionKind.FEATURE_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedFeatureConnection, featureConnection)
case ConnectionKind.FEATURE_GROUP_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedFeatureGroupConnection, featureGroupConnection)
case ConnectionKind.PARAMETER_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedParameterConnection, parameterConnection)
case ConnectionKind.PORT_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedPortConnection, portConnection)
default : null
}
}
connadd.set(namedElement_Name, currentsrcfeat.name+"_"+(currentdestfeat as Feature).name)
var connaddsrcelem = connadd.createChild(connection_Source,connectedElement)
connaddsrcelem.set(connectedElement_ConnectionEnd, currentsrcfeat)
if (complist.indexOf(currentcompinst) == 0) {
connaddsrcelem.set(connectedElement_Context, (conninst.source.eContainer as ComponentInstance).subcomponent)
} else {
connaddsrcelem.set(connectedElement_Context, (conninst.connectionReferences.get(conninst.connectionReferences.size - 1).destination.eContainer as ComponentInstance).subcomponent)
}
var connadddestelem = connadd.createChild(connection_Destination,connectedElement)
connadddestelem.set(connectedElement_ConnectionEnd, currentdestfeat)
if (complist.indexOf(currentcompinst) == complist.size-1) {
connadddestelem.set(connectedElement_Context,(conninst.destination.eContainer as ComponentInstance).subcomponent)
} else if (complist.get(complist.indexOf(currentcompinst)+1).eContainer() == currentcompinst) {
connadddestelem.set(connectedElement_Context,complist.get(complist.indexOf(currentcompinst)+1).subcomponent)
} else {
connadddestelem.set(connectedElement_Context,currentcompinst.subcomponent)
}
connadd.set(connection_Bidirectional, conninst.bidirectional)
// Trace Creation
var connref = conninst.createChild(connectionInstance_ConnectionReference, connectionReference)
connref.set(connectionReference_Connection,connadd)
connref.set(connectionReference_Context,currentcompinst)
connref.set(connectionReference_Reverse, false)
connref.set(connectionReference_Source,conninst.source)
connref.set(connectionReference_Destination,conninst.destination)
}
}
protected def connectionInstanceFoundDIM(ConnectionInstance conninst) {
for (ConnectionReference connref: conninst.connectionReferences) {
var currentsrcfeat = (connref.source as FeatureInstance).feature
var currentdestfeat = (connref.destination as FeatureInstance).feature
var currentcompinst = connref.context
// ComponentImplementationCreation
if (currentcompinst.classifier instanceof ComponentType) {
var compimp = {
switch (currentcompinst.category) {
case ComponentCategory.ABSTRACT : aadlPackage.createChild(packageSection_OwnedClassifier,abstractImplementation)
case ComponentCategory.BUS : aadlPackage.createChild(packageSection_OwnedClassifier,busImplementation)
case ComponentCategory.DATA : aadlPackage.createChild(packageSection_OwnedClassifier,dataImplementation)
case ComponentCategory.DEVICE : aadlPackage.createChild(packageSection_OwnedClassifier,deviceImplementation)
case ComponentCategory.MEMORY : aadlPackage.createChild(packageSection_OwnedClassifier,memoryImplementation)
case ComponentCategory.PROCESS : aadlPackage.createChild(packageSection_OwnedClassifier,processImplementation)
case ComponentCategory.PROCESSOR : aadlPackage.createChild(packageSection_OwnedClassifier,processorImplementation)
case ComponentCategory.SUBPROGRAM : aadlPackage.createChild(packageSection_OwnedClassifier,subprogramImplementation)
case ComponentCategory.SUBPROGRAM_GROUP : aadlPackage.createChild(packageSection_OwnedClassifier,subprogramGroupImplementation)
case ComponentCategory.SYSTEM : aadlPackage.createChild(packageSection_OwnedClassifier,systemImplementation)
case ComponentCategory.THREAD : aadlPackage.createChild(packageSection_OwnedClassifier,threadImplementation)
case ComponentCategory.THREAD_GROUP : aadlPackage.createChild(packageSection_OwnedClassifier,threadGroupImplementation)
case ComponentCategory.VIRTUAL_BUS : aadlPackage.createChild(packageSection_OwnedClassifier,virtualBusImplementation)
case ComponentCategory.VIRTUAL_PROCESSOR : aadlPackage.createChild(packageSection_OwnedClassifier,virtualProcessorImplementation)
}
}
compimp.set(namedElement_Name, currentcompinst.classifier.name+".impl")
compimp.set(componentImplementation_Type,currentcompinst.classifier)
currentcompinst.set(componentInstance_Classifier, compimp)
switch (currentcompinst.category) {
case ComponentCategory.ABSTRACT : currentcompinst.subcomponent.set(abstractSubcomponent_AbstractSubcomponentType, compimp)
case ComponentCategory.BUS : currentcompinst.subcomponent.set(busSubcomponent_BusSubcomponentType, compimp)
case ComponentCategory.DATA : currentcompinst.subcomponent.set(dataSubcomponent_DataSubcomponentType, compimp)
case ComponentCategory.DEVICE : currentcompinst.subcomponent.set(deviceSubcomponent_DeviceSubcomponentType, compimp)
case ComponentCategory.MEMORY : currentcompinst.subcomponent.set(memorySubcomponent_MemorySubcomponentType, compimp)
case ComponentCategory.PROCESS : currentcompinst.subcomponent.set(processSubcomponent_ProcessSubcomponentType, compimp)
case ComponentCategory.PROCESSOR : currentcompinst.subcomponent.set(processorSubcomponent_ProcessorSubcomponentType, compimp)
case ComponentCategory.SUBPROGRAM : currentcompinst.subcomponent.set(subprogramSubcomponent_SubprogramSubcomponentType, compimp)
case ComponentCategory.SUBPROGRAM_GROUP : currentcompinst.subcomponent.set(subprogramGroupSubcomponent_SubprogramGroupSubcomponentType, compimp)
case ComponentCategory.SYSTEM : currentcompinst.subcomponent.set(systemSubcomponent_SystemSubcomponentType, compimp)
case ComponentCategory.THREAD : currentcompinst.subcomponent.set(threadSubcomponent_ThreadSubcomponentType, compimp)
case ComponentCategory.THREAD_GROUP : currentcompinst.subcomponent.set(threadGroupSubcomponent_ThreadGroupSubcomponentType, compimp)
case ComponentCategory.VIRTUAL_BUS : currentcompinst.subcomponent.set(virtualBusSubcomponent_VirtualBusSubcomponentType, compimp)
case ComponentCategory.VIRTUAL_PROCESSOR : currentcompinst.subcomponent.set(virtualProcessorSubcomponent_VirtualProcessorSubcomponentType, compimp)
}
}
var connadd = {
switch (conninst.kind) {
case ConnectionKind.ACCESS_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedAccessConnection, accessConnection)
case ConnectionKind.FEATURE_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedFeatureConnection, featureConnection)
case ConnectionKind.FEATURE_GROUP_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedFeatureGroupConnection, featureGroupConnection)
case ConnectionKind.PARAMETER_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedParameterConnection, parameterConnection)
case ConnectionKind.PORT_CONNECTION : (currentcompinst.classifier as ComponentImplementation).createChild(componentImplementation_OwnedPortConnection, portConnection)
default : null
}
}
connadd.set(namedElement_Name, (connref.source.eContainer as ComponentInstance).name+"_"+connref.source.name+"_"+(connref.destination.eContainer as ComponentInstance).name+"_"+connref.destination.name)
connadd.set(connection_Bidirectional, conninst.bidirectional)
var connaddsrcelem = connadd.createChild(connection_Source, connectedElement)
connaddsrcelem.set(connectedElement_ConnectionEnd, currentsrcfeat)
if (connref.source.eContainer != connref.context) {
connaddsrcelem.set(connectedElement_Context, (connref.source.eContainer as ComponentInstance).subcomponent)
}
var connadddestelem = connadd.createChild(connection_Destination, connectedElement)
connadddestelem.set(connectedElement_ConnectionEnd, currentdestfeat)
if (connref.destination.eContainer != connref.context) {
connadddestelem.set(connectedElement_Context, (connref.destination.eContainer as ComponentInstance).subcomponent)
}
// Trace Creation
connref.set(connectionReference_Connection,connadd)
}
}
protected def connectionInstanceDeletedDIM (ConnectionInstance conninst) {
for (connref : conninst.connectionReferences) {
var currentcompinst = connref.context
switch (conninst.kind) {
case ConnectionKind.ACCESS_CONNECTION : (currentcompinst.classifier as ComponentImplementation).remove(componentImplementation_OwnedAccessConnection, connref.connection)