From f890c0a16b017e3bb63d745cc0ec2dd1dc7b172f Mon Sep 17 00:00:00 2001 From: tkuehn <thomas.kuehn3@tu-dresden.de> Date: Thu, 20 Sep 2018 17:00:00 +0200 Subject: [PATCH] fixed bug with missing occurence constraints on role groups --- .../roletype/group_constraints/RoleGroup.etl | 19 ++++++++++++++++++- .../RoleGroupOccurenceConstraints.etl | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/org.framed.iorm.ui/modules/roletype/group_constraints/RoleGroup.etl b/org.framed.iorm.ui/modules/roletype/group_constraints/RoleGroup.etl index 98af55d6..cbcffea0 100644 --- a/org.framed.iorm.ui/modules/roletype/group_constraints/RoleGroup.etl +++ b/org.framed.iorm.ui/modules/roletype/group_constraints/RoleGroup.etl @@ -31,7 +31,24 @@ rule RoleGroup if(cards.size()>1) { t.upper = cards[1]; } - } + } + //only transform if the role type is in a compartment type + if(s.getContainer().getParent().getType==(source!Type#CompartmentType)) { + //get the crom equivalent to compartment type the role type is in + var compartmentType = s.getContainer.getParent().equivalent(); + //check if a part with that role does not already is added to the compartment type + var partAlreadyAdded = false; + for(alreadyAddedPart : target!Part in compartmentType.getParts()) { + if(alreadyAddedPart.role == s.~transformed) partAlreadyAdded = true; + } + if(not(partAlreadyAdded)) { + //create a new part with the role + var part = new target!Part; + part.role = s.~transformed; + part.whole = compartmentType; + //add the part to the compartment type the role type + compartmentType.getParts().add(part); + } } //transform children var children = s.`model`; if (not (children == null)) { diff --git a/org.framed.iorm.ui/modules/roletype/group_constraints/RoleGroupOccurenceConstraints.etl b/org.framed.iorm.ui/modules/roletype/group_constraints/RoleGroupOccurenceConstraints.etl index 5556ce74..2a7b3066 100644 --- a/org.framed.iorm.ui/modules/roletype/group_constraints/RoleGroupOccurenceConstraints.etl +++ b/org.framed.iorm.ui/modules/roletype/group_constraints/RoleGroupOccurenceConstraints.etl @@ -25,7 +25,7 @@ rule RoleGroupWithOccurenceConstraints guard : not(s.getContainer().getParent() == null) and s.getContainer().getParent().getType==(source!Type#CompartmentType) and s.~features.get("Occurrence_Constraints") - + //parse the lower and upper bound from the role var desc = s.description; if (not (desc == null)) { -- GitLab