Skip to content

Commit

Permalink
Merge pull request #257 from Open-MBEE/develop
Browse files Browse the repository at this point in the history
5.1.3
  • Loading branch information
dlamoris authored Jan 25, 2023
2 parents 4c525d5 + 02fbbc4 commit 3f0592a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.*;
Expand Down Expand Up @@ -84,7 +86,7 @@ private synchronized Changelog.Change<Element> convert(ObjectNode objectNode, Pr

protected List<PreProcessor> 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;
}
Expand Down Expand Up @@ -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<String, Project, Element> idToElementConverter) {
Expand Down

0 comments on commit 3f0592a

Please sign in to comment.