Skip to content
Snippets Groups Projects
Commit 72dbe721 authored by Kevin Kassin's avatar Kevin Kassin
Browse files

Transformation or Role Groups and Compartment Types changed

Compartment Types can now be transformed by a RoleModel rule, if the
feature is not chosen,
removing the RoleGroup package now leads to placing roles inside the
compartment the role group is located in
parent c1e31002
No related branches found
No related tags found
No related merge requests found
...@@ -34,13 +34,37 @@ rule FulfillmentNoRoleGroups ...@@ -34,13 +34,37 @@ rule FulfillmentNoRoleGroups
fulfillmentFillsRoleGroup(s) and fulfillmentFillsRoleGroup(s) and
not(s.~features.get("Group_Constraints")) not(s.~features.get("Group_Constraints"))
var fulfillmentsToDelete : OrderedSet(target!Fulfillment);
for(fulfillment : target!Fulfillment in s.~transformed) { for(fulfillment : target!Fulfillment in s.~transformed) {
if(fulfillment.filled.instanceOf(target!RoleGroup)) if(fulfillment.filled.instanceOf(target!RoleGroup))
delete(fulfillment); fulfillmentsToDelete.add(fulfillment);
s.~transformed.remove(fulfillment);
} }
for(fulfillment : target!Fulfillment in fulfillmentsToDelete) {
delete(fulfillment);
s.~transformed.remove(fulfillment);
}
} }
@lazy
rule FulfillmentWithOutFiller
transform s : source!Relation
to t : Sequence(target!Fulfillment)
extends Fulfillment {
guard : s.target.getType==(source!Type#CompartmentType)
var fulfillmentsToDelete : OrderedSet(target!Fulfillment);
for(fulfillment : target!Fulfillment in s.~transformed) {
if(fulfillment.filled == null) {
fulfillment.filled.println();
fulfillmentsToDelete.add(fulfillment); }
}
for(fulfillment : target!Fulfillment in fulfillmentsToDelete) {
delete(fulfillment);
s.~transformed.remove(fulfillment);
}
}
operation fulfillmentFillsRoleGroup(s: source!Relation):Boolean { operation fulfillmentFillsRoleGroup(s: source!Relation):Boolean {
for(roles : source!Shape in s.getReferencedRoles) { for(roles : source!Shape in s.getReferencedRoles) {
if(roles.getType==source!Type#RoleGroup) if(roles.getType==source!Type#RoleGroup)
......
/**
* The abstract rule for compartment type outside of compartment types
*/
@lazy
rule RoleModel
transform s : source!Shape
to t : target!CompartmentType {
guard : s.getType==(source!Type#CompartmentType) and
not(s.~features.get("Compartment_Types")) and
(s.getContainer().getParent()==null or
not(s.getContainer().getParent().getType()==(source!Type#CompartmentType)))
//set the transformed target element to ensure the subrule work on the same target and only transform once
if(s.~transformed == null) {
s.~transformed = t;
//set the compartments name
t.name = s.name;
// iterate over all children of the compartment type
if(not(s.getModel() == null)) {
for (elem : source!ModelElement in s.getModel().elements) {
//propagate the features list and and the main model reference to all children
elem.~features = s.~features;
elem.~mainModel = s.~mainModel;
//transform all children
var e = elem.equivalent();
} } }
}
...@@ -6,6 +6,7 @@ rule CompartmentType ...@@ -6,6 +6,7 @@ rule CompartmentType
transform s : source!Shape transform s : source!Shape
to t : target!CompartmentType { to t : target!CompartmentType {
guard : s.getType==(source!Type#CompartmentType) and guard : s.getType==(source!Type#CompartmentType) and
s.~features.get("Compartment_Types") and
(s.getContainer().getParent()==null or (s.getContainer().getParent()==null or
not(s.getContainer().getParent().getType()==(source!Type#CompartmentType))) not(s.getContainer().getParent().getType()==(source!Type#CompartmentType)))
......
...@@ -10,7 +10,8 @@ rule RoleGroup ...@@ -10,7 +10,8 @@ rule RoleGroup
to t : target!RoleGroup { to t : target!RoleGroup {
guard : s.getType==(source!Type#RoleGroup) and guard : s.getType==(source!Type#RoleGroup) and
s.~features.get("Group_Constraints") //feature Group_Constraints implies feature Role_Constraints (not to check) s.~features.get("Group_Constraints") //feature Group_Constraints implies feature Role_Constraints (not to check)
//set the transformed target element to ensure the subrule work on the same target and only transform once //set the transformed target element to ensure the subrule work on the same target and only transform once
if(s.~transformed == null) { if(s.~transformed == null) {
s.~transformed = t; s.~transformed = t;
...@@ -59,7 +60,7 @@ rule RoleGroupNotTransformed ...@@ -59,7 +60,7 @@ rule RoleGroupNotTransformed
to t : target!RoleGroup { to t : target!RoleGroup {
guard : s.getType==(source!Type#RoleGroup) and guard : s.getType==(source!Type#RoleGroup) and
not(s.~features.get("Group_Constraints")) //feature Group_Constraints implies feature Role_Constraints (not to check) not(s.~features.get("Group_Constraints")) //feature Group_Constraints implies feature Role_Constraints (not to check)
//transform children //transform children
var children = s.`model`; var children = s.`model`;
if (not (children == null)) { if (not (children == null)) {
......
...@@ -9,7 +9,7 @@ rule RoleGroupInCompartmentType ...@@ -9,7 +9,7 @@ rule RoleGroupInCompartmentType
to t : target!RoleGroup to t : target!RoleGroup
extends RoleGroup { extends RoleGroup {
guard : not(s.getContainer().getParent() == null) and guard : not(s.getContainer().getParent() == null) and
s.getContainer().getParent().getType==(source!Type#CompartmentType) s.getContainer().getParent().getType==(source!Type#CompartmentType)
//get the crom equivalent to compartment type the role group is in //get the crom equivalent to compartment type the role group is in
var compartmentType = s.getContainer.getParent().equivalent(); var compartmentType = s.getContainer.getParent().equivalent();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment