diff --git a/gradle.properties b/gradle.properties index a66c834a5..7710ce00b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=5.1.2 +version=5.1.3 group=org.openmbee.mdk.magic descriptorFile=MDR_Plugin_Model_Development_Kit_91110_descriptor.xml magicdDrawGroupName=gov.nasa.jpl.cae.magicdraw.mdk diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/api/incubating/MDKConstants.java b/src/main/java/gov/nasa/jpl/mbee/mdk/api/incubating/MDKConstants.java index 08b7b25b8..854f9b144 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/api/incubating/MDKConstants.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/api/incubating/MDKConstants.java @@ -70,7 +70,8 @@ public class MDKConstants { SOURCE_FIELD = "source", DELETED_FIELD = "deleted", MAGICDRAW_SOURCE_VALUE = "magicdraw", - ELEMENT_TYPE_VALUE = "Element"; + ELEMENT_TYPE_VALUE = "Element", + OWNED_RULE_IDS = "ownedRuleIds"; @Deprecated public static final String diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFExporter.java b/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFExporter.java index 6e484e038..c9801796d 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFExporter.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFExporter.java @@ -287,6 +287,19 @@ private enum Processor { }, Type.PRE ), + VIEW_POST( + (element, project, objectNode) -> { + Stereotype viewStereotype = Utils.getViewStereotype(project); + JsonNode node = objectNode.get(MDKConstants.OWNED_RULE_IDS); + if (viewStereotype == null || !StereotypesHelper.hasStereotypeOrDerived(element, viewStereotype) || + node == null || !node.isArray() || node.size() == 0) { + return objectNode; + } + ((ArrayNode)node).removeAll(); + return objectNode; + }, + Type.POST + ), MOUNT_POST( (element, project, objectNode) -> { if (!objectNode.get(MDKConstants.TYPE_KEY).asText().equals("Mount")) { diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFImporter.java b/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFImporter.java index 3720eb58f..e1afbd7a9 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFImporter.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFImporter.java @@ -8,6 +8,7 @@ import com.nomagic.magicdraw.openapi.uml.ModelElementsManager; import com.nomagic.magicdraw.openapi.uml.ReadOnlyElementException; import com.nomagic.uml2.ext.jmi.helpers.ModelHelper; +import com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper; import com.nomagic.uml2.ext.jmi.reflect.AbstractRepository; import com.nomagic.uml2.ext.magicdraw.auxiliaryconstructs.mdmodels.Model; import com.nomagic.uml2.ext.magicdraw.auxiliaryconstructs.mdtemplates.ParameterableElement; @@ -24,6 +25,7 @@ import gov.nasa.jpl.mbee.mdk.json.ImportException; import gov.nasa.jpl.mbee.mdk.json.ReferenceException; import gov.nasa.jpl.mbee.mdk.util.Changelog; +import gov.nasa.jpl.mbee.mdk.util.Utils; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.UniqueEList; import org.eclipse.emf.ecore.*; @@ -84,7 +86,7 @@ private synchronized Changelog.Change convert(ObjectNode objectNode, Pr protected List getPreProcessors() { if (preProcessors == null) { - preProcessors = Arrays.asList(PreProcessor.CREATE, PreProcessor.EDITABLE, PreProcessor.DOCUMENTATION, PreProcessor.SYSML_ID_VALIDATION); + preProcessors = Arrays.asList(PreProcessor.CREATE, PreProcessor.EDITABLE, PreProcessor.DOCUMENTATION, PreProcessor.SYSML_ID_VALIDATION, PreProcessor.VIEW_OWNED_RULE_ID); } return preProcessors; } @@ -123,6 +125,19 @@ public static class PreProcessor { } return element; } + ), + VIEW_OWNED_RULE_ID = new PreProcessor( + (objectNode, project, strict, element) -> { + JsonNode jsonNode = objectNode.get(MDKConstants.OWNED_RULE_IDS); + if (jsonNode == null || !jsonNode.isArray()) { + return element; + } + // if element is a view, remove ownedRuleIds + if (StereotypesHelper.hasStereotypeOrDerived(element, Utils.getViewStereotype(project))) { + objectNode.remove(MDKConstants.OWNED_RULE_IDS); + } + return element; + } ); static PreProcessor getCreatePreProcessor(BiFunction idToElementConverter) {