From 5989a106503bc619a785eea39fbc2916052ef998 Mon Sep 17 00:00:00 2001 From: Ivan Gomes Date: Mon, 31 May 2021 16:06:18 -0700 Subject: [PATCH 1/3] MDK-60 MDK-12 feat: multiply support for Systems Reasoner #resolve MDK-59 fix: stop erroneous rename of nested specialization #resolve --- .../mdk/systems_reasoner/SRConfigurator.java | 13 +- .../actions/AspectRemedyAction.java | 2 +- .../actions/CreateSpecializedTypeAction.java | 76 +----- .../actions/ImportCSVAction.java | 4 +- .../actions/RedefineAttributeAction.java | 253 ++++++++++++++++++ .../SetOrCreateRedefinableElementAction.java | 208 -------------- .../actions/SpecializeClassifierAction.java | 2 +- .../actions/SpecializeStructureAction.java | 41 ++- .../actions/SubsetRedefinedProperty.java | 23 +- .../validation/SRValidationSuite.java | 73 ++--- 10 files changed, 357 insertions(+), 338 deletions(-) create mode 100644 src/main/java/org/openmbee/mdk/systems_reasoner/actions/RedefineAttributeAction.java delete mode 100644 src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetOrCreateRedefinableElementAction.java diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/SRConfigurator.java b/src/main/java/org/openmbee/mdk/systems_reasoner/SRConfigurator.java index 5a5c0a9..add572a 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/SRConfigurator.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/SRConfigurator.java @@ -22,7 +22,8 @@ public class SRConfigurator implements BrowserContextAMConfigurator, DiagramCont public static final String ID = "Specialize Structure"; public static final String ID_RECURSIVE = "Specialize Structure Recursively"; public static final String ID_RECURSIVE_INDIVIDUAL = "Specialize Recursively & Individually"; - private SRAction validateAction, importCSVAction, specializeStructureRecursiveAction, specializeStructureAction, specializeStructureRecursivelyIndividuallyAction, createInstanceMenuAction, selectAspectAction; + public static final String ID_RECURSIVE_INDIVIDUAL_MULTIPLY = "Specialize Recursively, Individually & Multiply"; + private SRAction validateAction, importCSVAction, specializeStructureRecursiveAction, specializeStructureAction, specializeStructureRecursivelyIndividuallyAction, specializeStructureRecursivelyIndividuallyMultiplyAction, createInstanceMenuAction, selectAspectAction; @Override public int getPriority() { @@ -57,6 +58,7 @@ protected void configure(ActionsManager manager, List elements) { specializeStructureRecursiveAction = null; specializeStructureAction = null; specializeStructureRecursivelyIndividuallyAction = null; + specializeStructureRecursivelyIndividuallyMultiplyAction = null; createInstanceMenuAction = null; importCSVAction = null; selectAspectAction = null; @@ -89,6 +91,7 @@ else if (elements.size() == 1) { category.addAction(specializeStructureAction); category.addAction(specializeStructureRecursiveAction); category.addAction(specializeStructureRecursivelyIndividuallyAction); + category.addAction(specializeStructureRecursivelyIndividuallyMultiplyAction); category.addAction(selectAspectAction); category.addAction(createInstanceMenuAction); @@ -140,9 +143,11 @@ public ActionsCategory handleSingleNode(ActionsCategory category, ActionsManager final Classifier classifier = (Classifier) element; validateAction = new ValidateAction(classifier); importCSVAction = new ImportCSVAction(classifier); - specializeStructureAction = new SpecializeStructureAction(classifier, false, ID, false, false); - specializeStructureRecursiveAction = new SpecializeStructureAction(classifier, false, ID_RECURSIVE, true, false); - specializeStructureRecursivelyIndividuallyAction = new SpecializeStructureAction(classifier, false, ID_RECURSIVE_INDIVIDUAL, true, true); + specializeStructureAction = new SpecializeStructureAction(classifier, false, ID, false, false, false); + specializeStructureRecursiveAction = new SpecializeStructureAction(classifier, false, ID_RECURSIVE, true, false, false); + specializeStructureRecursivelyIndividuallyAction = new SpecializeStructureAction(classifier, false, ID_RECURSIVE_INDIVIDUAL, true, true, false); + specializeStructureRecursivelyIndividuallyMultiplyAction = new SpecializeStructureAction(classifier, false, ID_RECURSIVE_INDIVIDUAL_MULTIPLY, true, true, true); + createInstanceMenuAction = new CreateInstanceMenuAction(classifier); if (!ProjectUtilities.isElementInAttachedProject(classifier)) { diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AspectRemedyAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AspectRemedyAction.java index 433175a..8bba5bf 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AspectRemedyAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AspectRemedyAction.java @@ -18,7 +18,7 @@ public AspectRemedyAction(Classifier classifier, Classifier aspect) { } public void run() { - Classifier realization = new SpecializeStructureAction(aspect, false, null, true, true).createSpecialClassifier(classifier, new ArrayList<>(), new ArrayList<>()); + Classifier realization = new SpecializeStructureAction(aspect, false, null, true, true, false).createSpecialClassifier(classifier, new ArrayList<>(), new ArrayList<>()); if (realization != null) { Property property = Project.getProject(classifier).getElementsFactory().createPropertyInstance(); property.setClassifier(classifier); diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateSpecializedTypeAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateSpecializedTypeAction.java index 65c40c5..b57e9dd 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateSpecializedTypeAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateSpecializedTypeAction.java @@ -1,6 +1,5 @@ package org.openmbee.mdk.systems_reasoner.actions; -import com.nomagic.magicdraw.copypaste.CopyPasting; import com.nomagic.magicdraw.core.Application; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; @@ -20,28 +19,30 @@ public class CreateSpecializedTypeAction extends GenericRuleViolationAction { } private static final String DEFAULT_NAME = "Create Specialized Classifier"; - private final boolean isRecursive; - private Property property; - private Classifier parent; - private String name; - private boolean isIndividual; + private final Property property; + private final Classifier parent; + private final String name; + private final boolean isIndividual; + private final boolean isRecursive; + private final boolean isMultiply; - public CreateSpecializedTypeAction(final Property property, final Classifier parent, final String name, boolean isIndividual, boolean isRecursive) { + public CreateSpecializedTypeAction(final Property property, final Classifier parent, final String name, boolean isIndividual, boolean isRecursive, boolean isMultiply) { super(name); this.property = property; this.parent = parent; this.name = name; this.isIndividual = isIndividual; this.isRecursive = isRecursive; + this.isMultiply = isMultiply; } - public static final void createSpecializedType(final Property property, final Classifier parent, boolean isIndividual, boolean isRecursive) { - createSpecializedType(property, parent, new ArrayList(), new ArrayList(), isIndividual, isRecursive); + public static void createSpecializedType(final Property property, final Classifier parent, boolean isIndividual, boolean isRecursive, boolean isMultiply) { + createSpecializedType(property, parent, new ArrayList<>(), new ArrayList<>(), isIndividual, isRecursive, isMultiply); } - public static final boolean createSpecializedType(final StructuralFeature redefinedAttribute, final Classifier parent, final List traveled, List visited, boolean isIndividual, boolean isRecursive) { + public static boolean createSpecializedType(final StructuralFeature redefinedAttribute, final Classifier parent, final List traveled, List visited, boolean isIndividual, boolean isRecursive, boolean isMultiply) { if (!parent.isEditable()) { Application.getInstance().getGUILog().log(parent.getQualifiedName() + " is not editable. Skipping creating specialization."); return true; @@ -70,7 +71,7 @@ public static final boolean createSpecializedType(final StructuralFeature redefi final Classifier general = (Classifier) redefinedAttribute.getType(); Type special = null; if (isIndividual || (isRecursive && getExistingSpecial(redefinedAttribute) == null)) { - SpecializeStructureAction speca = new SpecializeStructureAction(general, false, "", isRecursive, isIndividual); + SpecializeStructureAction speca = new SpecializeStructureAction(general, false, "", isRecursive, isIndividual, isMultiply); special = speca.createSpecialClassifier(parent, new ArrayList<>(traveled), visited); } else if (getExistingSpecial(redefinedAttribute) != null) { @@ -85,28 +86,16 @@ else if (visited.contains(general)) { return true; } redefinedAttribute.setType(special); - - -// if (isRecursive) { -// if (special instanceof Classifier) { -// for (final NamedElement ne : ((Classifier) special).getInheritedMember()) { -// if (ne instanceof RedefinableElement && !((RedefinableElement) ne).isLeaf()) { -// SetOrCreateRedefinableElementAction.redefineRedefinableElement((Classifier) special, (RedefinableElement) ne, traveled, visited, isIndividual, isRecursive); -// } -// } -// } -// } } return true; } private static Type getExistingSpecial(StructuralFeature structuralFeature) { - Set types = new HashSet(); + Set types = new HashSet<>(); Element owner = structuralFeature.getOwner(); for (RedefinableElement redef : structuralFeature.getRedefinedElement()) { if (redef instanceof TypedElement) { types.add(((TypedElement) redef).getType()); - //System.out.println("Found type: "+((TypedElement) redef).getType().getName() +" id "+ ((TypedElement) redef).getType().toString() + " for SF " + structuralFeature.getName() + " " + structuralFeature.toString()); } } for (Element oe : owner.getOwnedElement()) { @@ -115,7 +104,6 @@ private static Type getExistingSpecial(StructuralFeature structuralFeature) { for (RedefinableElement redef : ((Property) oe).getRedefinedElement()) { if (redef instanceof TypedElement) { if (types.contains(((TypedElement) redef).getType())) { - //System.out.println("Found type: "+((TypedElement) oe).getType().getName() +" id "+ ((TypedElement) oe).getType().toString() + " for SF " + redef.getName() + " " + redef.toString()); return ((Property) oe).getType(); } } @@ -127,45 +115,9 @@ private static Type getExistingSpecial(StructuralFeature structuralFeature) { return null; } - public static final Classifier createSpecializedClassifier(final Classifier general, final Classifier parent, final StructuralFeature structuralFeature) { - for (final Class c : UNSPECIALIZABLE_CLASSIFIERS) { - if (c.isAssignableFrom(general.getClass())) { - Application.getInstance().getGUILog() - .log("[WARNING] " + (structuralFeature != null ? structuralFeature.getQualifiedName() : "< >") + " is a " + c.getSimpleName() + ", which is not specializable."); - return null; - } - } - // System.out.println(general.getQualifiedName()); - // final Classifier special = (Classifier) CopyPasting.copyPasteElement(general, parent, true); - - // Collection emptyCollection = new ArrayList(); - // special.getOwnedMember().retainAll(emptyCollection); - // special.getGeneralization().retainAll(emptyCollection); - - - Classifier specific = (Classifier) CopyPasting.copyPasteElement(general, parent, true); - if (specific == null) { - return null; - } - - ArrayList members = new ArrayList<>(); - for (NamedElement ne : specific.getOwnedMember()) { - members.add(ne); - } - for (NamedElement member : members) { - if (member instanceof RedefinableElement) { - specific.getOwnedMember().remove(member); - member.dispose(); - } - } - specific.getGeneralization().clear(); - SpecializeClassifierAction.specialize(specific, general); - return specific; - } - @Override public void run() { - CreateSpecializedTypeAction.createSpecializedType(property, parent, isIndividual, isRecursive); + CreateSpecializedTypeAction.createSpecializedType(property, parent, isIndividual, isRecursive, isMultiply); } @Override diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/ImportCSVAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/ImportCSVAction.java index 0c4e046..5c205cc 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/ImportCSVAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/ImportCSVAction.java @@ -129,7 +129,7 @@ private void checkForRedefinedElements(HashSet createdElements) { } } if (!redefined) { - SetOrCreateRedefinableElementAction action = new SetOrCreateRedefinableElementAction(ns, (RedefinableElement) mem, false); + RedefineAttributeAction action = new RedefineAttributeAction(ns, (RedefinableElement) mem, false, false, false); action.run(); } } @@ -328,7 +328,7 @@ private void setPropertyValue(String valueFromCSV, RedefinableElement el, HashMa prop.setType(linkedElement); if (el instanceof Property) { if (((Property) el).getAssociation() != null) { - SetOrCreateRedefinableElementAction.createInheritingAssociation((Property) el, owner, prop); + RedefineAttributeAction.createInheritingAssociation((Property) el, owner, prop); } } } diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RedefineAttributeAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RedefineAttributeAction.java new file mode 100644 index 0000000..44a35dd --- /dev/null +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RedefineAttributeAction.java @@ -0,0 +1,253 @@ +package org.openmbee.mdk.systems_reasoner.actions; + +import com.nomagic.magicdraw.copypaste.CopyPasting; +import com.nomagic.magicdraw.core.Application; +import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; +import com.nomagic.uml2.ext.magicdraw.compositestructures.mdinternalstructures.Connector; +import com.nomagic.uml2.ext.magicdraw.metadata.UMLFactory; +import gov.nasa.jpl.mbee.mdk.util.Utils; +import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.systems_reasoner.validation.SRValidationSuite; + +import java.util.*; +import java.util.stream.IntStream; + +public class RedefineAttributeAction extends GenericRuleViolationAction { + private static final String DEFAULT_NAME = "Redefine Attribute"; + + private final Classifier target; + private final RedefinableElement redefinedAttribute; + private final boolean isIndividual; + private final boolean isRecursive; + private final boolean isMultiply; + + public RedefineAttributeAction(Classifier target, RedefinableElement redefinedAttribute, boolean isIndividual, boolean isRecursive, boolean isMultiply) { + this(target, redefinedAttribute, isIndividual, isRecursive, isMultiply, DEFAULT_NAME); + } + + public RedefineAttributeAction(Classifier target, RedefinableElement redefinedAttribute, boolean isIndividual, boolean isRecursive, boolean isMultiply, String name) { + super(name); + + this.target = target; + this.redefinedAttribute = redefinedAttribute; + this.isRecursive = isRecursive; + this.isIndividual = isIndividual; + this.isMultiply = isMultiply; + } + + public static RedefinableElement redefineRedefinableElement(final Classifier target, final RedefinableElement redefinedAttribute, boolean isIndividual, boolean isRecursive, boolean isMultiply) { + return redefineRedefinableElement(target, redefinedAttribute, new ArrayList<>(), new ArrayList<>(), isIndividual, isRecursive, isMultiply); + } + + public static RedefinableElement redefineRedefinableElement(final Classifier target, final RedefinableElement redefinedAttribute, final List traveled, List visited, boolean isIndividual, boolean isRecursive, boolean isMultiply) { + if (isNotRedefinable(target, redefinedAttribute)) { + return null; + } + + RedefinableElement redefiningElement = findExistingRedefiningElement(target, redefinedAttribute); + if (redefiningElement == null) { + redefiningElement = (RedefinableElement) CopyPasting.copyPasteElement(redefinedAttribute, target, false); + if (redefiningElement == null) { + return null; + } + } + redefiningElement.getRedefinedElement().removeAll(getRedefinedElementsRecursively(redefinedAttribute, new HashSet<>())); + redefiningElement.getRedefinedElement().add(redefinedAttribute); + + if (redefinedAttribute instanceof Property) { + if (((Property) redefinedAttribute).getAssociation() != null) { + if (!existingAssociationInheritsFromGeneralAssociation(redefiningElement, (Property) redefinedAttribute)) { + createInheritingAssociation((Property) redefinedAttribute, target, (Property) redefiningElement); + } + } + } + if (redefiningElement instanceof Property && ((TypedElement) redefiningElement).getType() != null) { + Property partProperty = (Property) redefiningElement; + + if (isRecursive) { + CreateSpecializedTypeAction.createSpecializedType(partProperty, target, traveled, visited, isIndividual, true, isMultiply); + } + + if (isMultiply) { + int multiplicity = getExplicitMultiplicity(partProperty); + if (multiplicity > 1) { + if (partProperty.get_propertyOfSubsettedProperty().isEmpty()) { + for (int i = 1; i <= multiplicity; i++) { + // find existing subsetting property in general for redefinition by name collision in the absence of a better technique + int finalI = i; + Property existingSubsettingProperty = redefinedAttribute instanceof Property && ((Property) redefinedAttribute).getClassifier() != null ? + ((Property) redefinedAttribute).getClassifier().getMember().stream() + .filter(m -> m instanceof Property) + .map(m -> (Property) m) + .filter(p -> p.getSubsettedProperty().contains(redefinedAttribute)) + .filter(p -> Objects.equals(p.getName(), partProperty.getName() + finalI)) + .findAny() + .orElse(null) : + null; + Property multipliedProperty = existingSubsettingProperty != null ? + (Property) redefineRedefinableElement(target, existingSubsettingProperty, false, false, false) : + (Property) CopyPasting.copyPasteElement(partProperty, target, false); + if (multipliedProperty != null) { + multipliedProperty.setName(partProperty.getName() + i); + multipliedProperty.getSubsettedProperty().clear(); + multipliedProperty.getSubsettedProperty().add(partProperty); + multipliedProperty.getRedefinedElement().removeAll(getRedefinedElementsRecursively(redefinedAttribute, new HashSet<>())); + if (existingSubsettingProperty != null) { + multipliedProperty.getRedefinedElement().add(existingSubsettingProperty); + } + // unset multiplicity to yield SysML's default multiplicity of 1 + // ref https://www.omg.org/spec/SysML/1.5/PDF#8.3.1.1.9 + multipliedProperty.setLowerValue(null); + multipliedProperty.setUpperValue(null); + if (isRecursive) { + List copiedVisited = new ArrayList<>(visited); + CreateSpecializedTypeAction.createSpecializedType(multipliedProperty, target, traveled, copiedVisited, isIndividual, true, true); + } + } + } + } + else { + Application.getInstance().getGUILog().log("[WARNING] " + partProperty.getQualifiedName() + " is already subsetted. Multiply skipped."); + } + } + } + } + + return redefiningElement; + } + + public static int getExplicitMultiplicity(Property property) { + return property.getLower() == property.getUpper() ? property.getLower() : -1; + } + + private static boolean existingAssociationInheritsFromGeneralAssociation(RedefinableElement redefinedElement, Property elementToBeRedefined) { + if (redefinedElement instanceof Property) { + Association association = ((Property) redefinedElement).getAssociation(); + Association general = elementToBeRedefined.getAssociation(); + if (association != null) { + return eventuallyInherits(association, general); + } + else { + return false; + } + + } + return false; + } + + private static boolean eventuallyInherits(Classifier association, Classifier general) { + if (association.getGeneral().contains(general)) { + return true; + } + else { + for (Classifier specific : association.getGeneral()) { + if (eventuallyInherits(specific, general)) { + return true; + } + } + return false; + } + } + + public static RedefinableElement findExistingRedefiningElement(Classifier subClassifier, RedefinableElement elementToBeRedefined) { + RedefinableElement existingRedefiningElement = null; + for (NamedElement p : subClassifier.getOwnedMember()) { + if (p instanceof RedefinableElement && SRValidationSuite.doesEventuallyRedefine((RedefinableElement) p, elementToBeRedefined)) { + existingRedefiningElement = (RedefinableElement) p; + break; + } + else if (p instanceof RedefinableElement) { + if (isMatchingTypedElement((RedefinableElement) p, elementToBeRedefined)) { + existingRedefiningElement = (RedefinableElement) p; + break; + } + else if (p instanceof Connector && elementToBeRedefined instanceof Connector) { + Connector c1 = (Connector) p; + Connector c2 = (Connector) elementToBeRedefined; + if (c1.getEnd() == null || c2.getEnd() == null) { + continue; + } + if (c1.getEnd().size() != 2 || c2.getEnd().size() != 2) { + continue; + } + if (c1.getEnd().stream().anyMatch(e -> !(e.getRole() instanceof RedefinableElement)) || c2.getEnd().stream().anyMatch(e -> !(e.getRole() instanceof RedefinableElement))) { + continue; + } + if (IntStream.range(0, 2).anyMatch(i -> !isMatchingTypedElement((RedefinableElement) c1.getEnd().get(i).getRole(), (RedefinableElement) c2.getEnd().get(i).getRole()))) { + continue; + } + existingRedefiningElement = (RedefinableElement) p; + break; + } + } + } + return existingRedefiningElement; + } + + public static boolean isNotRedefinable(Classifier subClassifier, RedefinableElement elementToBeRedefined) { + if (elementToBeRedefined.isLeaf()) { + Application.getInstance().getGUILog().log("[WARNING] " + elementToBeRedefined.getQualifiedName() + " is a leaf. Cannot redefine further."); + return true; + } + if (!subClassifier.isEditable()) { + Application.getInstance().getGUILog().log("[WARNING] " + subClassifier.getQualifiedName() + " is not editable. Skipping redefinition."); + return true; + } + return false; + } + + static void createInheritingAssociation(Property generalProperty, Classifier classifierOfnewProperty, Property newProperty) { + Association generalAssociation = generalProperty.getAssociation(); + Association newAssociation = UMLFactory.eINSTANCE.createAssociation(); + newAssociation.setName(generalAssociation.getName()); + Property ownedEnd = UMLFactory.eINSTANCE.createProperty(); + ownedEnd.setOwner(newAssociation); + ownedEnd.setType(classifierOfnewProperty); + Utils.createGeneralization(generalAssociation, newAssociation); + if (classifierOfnewProperty.getOwner() != null) { + newAssociation.setOwner(classifierOfnewProperty.getOwner()); + } + else { + throw new NullPointerException("owner of classifier null!"); + } + newAssociation.getMemberEnd().add(newProperty); + newAssociation.getOwnedEnd().add(ownedEnd); + } + + private static Set getRedefinedElementsRecursively(RedefinableElement redefinableElement, Set set) { + if (set.add(redefinableElement)) { + redefinableElement.getRedefinedElement().forEach(redefinedElement -> getRedefinedElementsRecursively(redefinedElement, set)); + } + return set; + } + + private static boolean isMatchingTypedElement(RedefinableElement p, RedefinableElement elementToBeRedefined) { + Set flattenedRedefinedElements = getRedefinedElementsRecursively(elementToBeRedefined, new HashSet<>()); + if (p.getRedefinedElement().stream().anyMatch(flattenedRedefinedElements::contains)) { + return true; + } + if (p.getName().equals(elementToBeRedefined.getName())) { + if (p instanceof TypedElement && elementToBeRedefined instanceof TypedElement) { + if (((TypedElement) p).getType() != null) { + if (((TypedElement) p).getType().equals(((TypedElement) elementToBeRedefined).getType())) { + return true; + } + } + else if (((TypedElement) elementToBeRedefined).getType() == null) { + return true; + } + } + } + return false; + } + + @Override + public void run() { + redefineRedefinableElement(target, redefinedAttribute, isIndividual, isRecursive, isMultiply); + } + + @Override + public String getSessionName() { + return "redefine attribute"; + } +} diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetOrCreateRedefinableElementAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetOrCreateRedefinableElementAction.java deleted file mode 100644 index 6654cd4..0000000 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetOrCreateRedefinableElementAction.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.openmbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.copypaste.CopyPasting; -import com.nomagic.magicdraw.core.Application; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; -import com.nomagic.uml2.ext.magicdraw.compositestructures.mdinternalstructures.Connector; -import com.nomagic.uml2.ext.magicdraw.metadata.UMLFactory; -import gov.nasa.jpl.mbee.mdk.util.Utils; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; -import org.openmbee.mdk.systems_reasoner.validation.SRValidationSuite; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.IntStream; - -public class SetOrCreateRedefinableElementAction extends GenericRuleViolationAction { - private static final String DEFAULT_NAME = "Redefine Attribute"; - - private Classifier subClassifier; - private RedefinableElement re; - private String name; - private boolean isIndividual; - private boolean isRecursive; - - public SetOrCreateRedefinableElementAction(final Classifier targetForRedefEl, final RedefinableElement elementToBeRedefined, boolean isIndividual) { - this(targetForRedefEl, elementToBeRedefined, false, DEFAULT_NAME, isIndividual); - } - - public SetOrCreateRedefinableElementAction(final Classifier targetForRedefEl, final RedefinableElement elementToBeRedefined, final boolean recursion, final String name, boolean isIndividual) { - super(name); - this.subClassifier = targetForRedefEl; - this.re = elementToBeRedefined; - this.isRecursive = recursion; - this.name = name; - this.isIndividual = isIndividual; - } - - public static RedefinableElement redefineRedefinableElement(final Classifier subClassifier, final RedefinableElement re, boolean isIndividual, boolean isRecursive) { - return redefineRedefinableElement(subClassifier, re, new ArrayList(), new ArrayList(), isIndividual, isRecursive); - } - - public static RedefinableElement redefineRedefinableElement(final Classifier subClassifier, final RedefinableElement elementToBeRedefined, final List traveled, List visited, boolean isIndividual, boolean isRecursive) { - if (isNotRedefinable(subClassifier, elementToBeRedefined)) { - return null; - } - - - RedefinableElement redefinedElement = findExistingRedefiningElement(subClassifier, elementToBeRedefined); - if (redefinedElement == null) { - redefinedElement = (RedefinableElement) CopyPasting.copyPasteElement(elementToBeRedefined, subClassifier, false); - if (redefinedElement == null) { - return null; - } - } - redefinedElement.getRedefinedElement().removeAll(getRedefinedElementsRecursively(elementToBeRedefined, new HashSet<>())); - redefinedElement.getRedefinedElement().add(elementToBeRedefined); - - if (elementToBeRedefined instanceof Property) { - if (((Property) elementToBeRedefined).getAssociation() != null) { - if (!existingAssociationInheritsFromGeneralAssociation(redefinedElement, (Property) elementToBeRedefined)) { - createInheritingAssociation((Property) elementToBeRedefined, subClassifier, (Property) redefinedElement); - } - } - } - if (isRecursive && redefinedElement instanceof Property && ((TypedElement) redefinedElement).getType() != null) { - CreateSpecializedTypeAction.createSpecializedType((Property) redefinedElement, subClassifier, traveled, visited, isIndividual, isRecursive); - } - return redefinedElement; - } - - private static boolean existingAssociationInheritsFromGeneralAssociation(RedefinableElement redefinedElement, Property elementToBeRedefined) { - if (redefinedElement instanceof Property) { - Association association = ((Property) redefinedElement).getAssociation(); - Association general = elementToBeRedefined.getAssociation(); - if (association != null) { - return eventuallyInherits(association, general); - } - else { - return false; - } - - } - return false; - } - - private static boolean eventuallyInherits(Classifier association, Classifier general) { - if (association.getGeneral().contains(general)) { - return true; - } - else { - for (Classifier specific : association.getGeneral()) { - if (eventuallyInherits(specific, general)) { - return true; - } - } - return false; - } - } - - private static RedefinableElement findExistingRedefiningElement(Classifier subClassifier, RedefinableElement elementToBeRedefined) { - RedefinableElement existingRedefiningElement = null; - for (NamedElement p : subClassifier.getOwnedMember()) { - if (p instanceof RedefinableElement && SRValidationSuite.doesEventuallyRedefine((RedefinableElement) p, elementToBeRedefined)) { - existingRedefiningElement = (RedefinableElement) p; - break; - } - else if (p instanceof RedefinableElement) { - if (isMatchingTypedElement((RedefinableElement) p, elementToBeRedefined)) { - existingRedefiningElement = (RedefinableElement) p; - break; - } - else if (p instanceof Connector && elementToBeRedefined instanceof Connector) { - Connector c1 = (Connector) p; - Connector c2 = (Connector) elementToBeRedefined; - if (c1.getEnd() == null || c2.getEnd() == null) { - continue; - } - if (c1.getEnd().size() != 2 || c2.getEnd().size() != 2) { - continue; - } - if (c1.getEnd().stream().anyMatch(e -> !(e.getRole() instanceof RedefinableElement)) || c2.getEnd().stream().anyMatch(e -> !(e.getRole() instanceof RedefinableElement))) { - continue; - } - if (IntStream.range(0, 2).anyMatch(i -> !isMatchingTypedElement((RedefinableElement) c1.getEnd().get(i).getRole(), (RedefinableElement) c2.getEnd().get(i).getRole()))) { - continue; - } - existingRedefiningElement = (RedefinableElement) p; - break; - } - } - } - return existingRedefiningElement; - } - - private static boolean isNotRedefinable(Classifier subClassifier, RedefinableElement elementToBeRedefined) { - if (elementToBeRedefined.isLeaf()) { - Application.getInstance().getGUILog().log(elementToBeRedefined.getQualifiedName() + " is a leaf. Cannot redefine further."); - return true; - } - if (!subClassifier.isEditable()) { - Application.getInstance().getGUILog().log(subClassifier.getQualifiedName() + " is not editable. Skipping redefinition."); - return true; - } - return false; - } - - static void createInheritingAssociation(Property generalProperty, Classifier classifierOfnewProperty, Property newProperty) { - Association generalAssociation = generalProperty.getAssociation(); - Association newAssociation = UMLFactory.eINSTANCE.createAssociation(); - newAssociation.setName(generalAssociation.getName()); - Property ownedEnd = UMLFactory.eINSTANCE.createProperty(); - ownedEnd.setOwner(newAssociation); - ownedEnd.setType(classifierOfnewProperty); - Utils.createGeneralization(generalAssociation, newAssociation); - if (classifierOfnewProperty.getOwner() != null) { - newAssociation.setOwner(classifierOfnewProperty.getOwner()); - } - else { - throw new NullPointerException("owner of classifier null!"); - } - newAssociation.getMemberEnd().add(newProperty); - newAssociation.getOwnedEnd().add(ownedEnd); - } - - private static Set getRedefinedElementsRecursively(RedefinableElement redefinableElement, Set set) { - if (set.add(redefinableElement)) { - redefinableElement.getRedefinedElement().forEach(redefinedElement -> getRedefinedElementsRecursively(redefinedElement, set)); - } - return set; - } - - private static boolean isMatchingTypedElement(RedefinableElement p, RedefinableElement elementToBeRedefined) { - Set flattenedRedefinedElements = getRedefinedElementsRecursively(elementToBeRedefined, new HashSet<>()); - if (p.getRedefinedElement().stream().anyMatch(flattenedRedefinedElements::contains)) { - return true; - } - if (p.getName().equals(elementToBeRedefined.getName())) { - if (p instanceof TypedElement && elementToBeRedefined instanceof TypedElement) { - if (((TypedElement) p).getType() != null) { - if (((TypedElement) p).getType().equals(((TypedElement) elementToBeRedefined).getType())) { - return true; - } - } - else if (((TypedElement) elementToBeRedefined).getType() == null) { - return true; - } - } - } - return false; - } - - @Override - public void run() { - redefineRedefinableElement(subClassifier, re, isIndividual, isRecursive); - } - - @Override - public String getName() { - return name; - } - - @Override - public String getSessionName() { - return "redefine attribute"; - } -} diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SpecializeClassifierAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SpecializeClassifierAction.java index ecac762..16d4f33 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SpecializeClassifierAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SpecializeClassifierAction.java @@ -16,7 +16,7 @@ public SpecializeClassifierAction(final Classifier specific, final Classifier ge this.general = general; } - public static final Generalization specialize(final Classifier specific, final Classifier general) { + public static Generalization specialize(final Classifier specific, final Classifier general) { final Generalization generalization = Application.getInstance().getProject().getElementsFactory().createGeneralizationInstance(); generalization.setSpecific(specific); generalization.setGeneral(general); diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SpecializeStructureAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SpecializeStructureAction.java index 342a733..bf0b611 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SpecializeStructureAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SpecializeStructureAction.java @@ -35,17 +35,19 @@ public class SpecializeStructureAction extends SRAction { Model.class ); + private final Classifier classifier; + private final boolean isValidationMode; private final boolean isRecursive; - private final boolean individualMode; - private Classifier classifier; - private boolean isValidationMode; + private final boolean isIndividual; + private final boolean isMultiply; - public SpecializeStructureAction(final Classifier classifier, boolean isValidationMode, String id, boolean isRecursive, boolean isIndividual) { + public SpecializeStructureAction(final Classifier classifier, boolean isValidationMode, String id, boolean isRecursive, boolean isIndividual, boolean isMultiply) { super(id, classifier); this.classifier = classifier; this.isValidationMode = isValidationMode; this.isRecursive = isRecursive; - this.individualMode = isIndividual; + this.isIndividual = isIndividual; + this.isMultiply = isMultiply; } @@ -73,10 +75,9 @@ public void actionPerformed(ActionEvent e) { container = (Namespace) dlg.getSelectedElement(); } - Classifier specific = createSpecialClassifier(container, new ArrayList(), new ArrayList()); - SessionManager.getInstance().closeSession(); - + Classifier specific = createSpecialClassifier(container, new ArrayList<>(), new ArrayList<>()); checkAssociationsForInheritance(specific, classifier); + SessionManager.getInstance().closeSession(); } } @@ -127,16 +128,34 @@ public Classifier createSpecialClassifier(Namespace container, List Should Aspect Blocks be Redefined? + List elementsToBeRedefined = new ArrayList<>(); + for (NamedElement ne : members) { // Exclude Classifiers for now -> Should Aspect Blocks be Redefined? if (ne instanceof RedefinableElement && !((RedefinableElement) ne).isLeaf() && !(ne instanceof Classifier)) { final RedefinableElement elementToBeRedefined = (RedefinableElement) ne; - RedefinableElement redefinedElement = SetOrCreateRedefinableElementAction.redefineRedefinableElement(specific, elementToBeRedefined, traveled, visited, individualMode, isRecursive); - redefinedElements.remove(redefinedElement); + RedefinableElement existingRedefiningElement = RedefineAttributeAction.findExistingRedefiningElement(specific, elementToBeRedefined); + if (existingRedefiningElement != null) { + redefinedElements.remove(existingRedefiningElement); + } + if (RedefineAttributeAction.isNotRedefinable(specific, elementToBeRedefined)) { + continue; + } + if (isMultiply && elementToBeRedefined instanceof Property && + ((Property) elementToBeRedefined).getSubsettedProperty().stream() + .anyMatch(subsetted -> RedefineAttributeAction.getExplicitMultiplicity(subsetted) > 1)) { + continue; + } + elementsToBeRedefined.add(elementToBeRedefined); } } + for (RedefinableElement redefinedElement : redefinedElements) { redefinedElement.dispose(); } + + for (RedefinableElement elementToBeRedefined : elementsToBeRedefined) { + RedefineAttributeAction.redefineRedefinableElement(specific, elementToBeRedefined, traveled, visited, isIndividual, isRecursive, isMultiply); + } + return specific; } diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SubsetRedefinedProperty.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SubsetRedefinedProperty.java index f53b331..0671a63 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SubsetRedefinedProperty.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SubsetRedefinedProperty.java @@ -7,28 +7,19 @@ import java.awt.event.ActionEvent; public class SubsetRedefinedProperty extends SRAction { - public static final String DEFAULT_ID = "Set subsetted property in redefining property."; - private final Property redefinedElement; - private final Property redefiningElement; + public static final String DEFAULT_ID = "Add Subsetted Property"; + private final Property subsetting; + private final Property subsetted; - public SubsetRedefinedProperty(Property redefEl, Property redefingEl) { + public SubsetRedefinedProperty(Property subsetting, Property subsetted) { super(DEFAULT_ID); - this.redefinedElement = redefEl; - this.redefiningElement = redefingEl; + this.subsetting = subsetting; + this.subsetted = subsetted; } @Override public void actionPerformed(@CheckForNull ActionEvent actionEvent) { - - for (Property p : redefinedElement.getSubsettedProperty()) { - for (RedefinableElement r : p.get_redefinableElementOfRedefinedElement()) { - if (r instanceof Property) { - if (!redefiningElement.getSubsettedProperty().contains(r)) { - redefiningElement.getSubsettedProperty().add((Property) r); - } - } - } - } + subsetting.getSubsettedProperty().add(subsetted); } } \ No newline at end of file diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/validation/SRValidationSuite.java b/src/main/java/org/openmbee/mdk/systems_reasoner/validation/SRValidationSuite.java index e7628ac..929659d 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/validation/SRValidationSuite.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/validation/SRValidationSuite.java @@ -10,10 +10,7 @@ import gov.nasa.jpl.mbee.mdk.validation.*; import org.openmbee.mdk.systems_reasoner.actions.*; -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import java.util.Objects; +import java.util.*; public class SRValidationSuite extends ValidationSuite implements Runnable { @@ -25,7 +22,7 @@ public class SRValidationSuite extends ValidationSuite implements Runnable { private static final ValidationRule attributeMissingRule = new ValidationRule("Missing Owned Redefinable Element", "Owned RedefinableElement is missing", ViolationSeverity.ERROR); private static final ValidationRule aspectMissingRule = new ValidationRule("Missing Defined Aspect", "An aspect is defined but not realized", ViolationSeverity.ERROR); private static final ValidationRule nameRule = new ValidationRule("Naming Inconsistency", "Names are inconsistent", ViolationSeverity.WARNING); - private static final ValidationRule subsetsRule = new ValidationRule("Redefined Property Subset Missing.", "Subset missing.", ViolationSeverity.WARNING); + private static final ValidationRule subsetsRule = new ValidationRule("Redefined Property Subset Missing.", "Subset missing", ViolationSeverity.WARNING); private static final ValidationRule attributeTypeRule = new ValidationRule("Attribute Type Inconsistency", "Attribute types are inconsistent", ViolationSeverity.WARNING); private static final ValidationRule generalSpecificNameRule = new ValidationRule("General Specific Name Inconsistency", "General and specific names are inconsistent", ViolationSeverity.INFO); private static final ValidationRule instanceClassifierExistenceRule = new ValidationRule("Instance Classifier Unspecified", "Instance classifier is not specified", ViolationSeverity.ERROR); @@ -99,50 +96,60 @@ public void run() { for (final NamedElement ne : classifier.getInheritedMember()) { // Exclude Classifiers for now -> Should Aspect Blocks be Redefined? if (ne instanceof RedefinableElement && !((RedefinableElement) ne).isLeaf() && !(ne instanceof Classifier)) { - final RedefinableElement redefEl = (RedefinableElement) ne; - RedefinableElement redefingEl = null; - - for (Element p : classifier.getOwnedElement()) { - if (p instanceof RedefinableElement) { - if (doesEventuallyRedefine((RedefinableElement) p, redefEl)) { - redefingEl = (RedefinableElement) p; - if (redefingEl instanceof Property && redefEl instanceof Property) { - if (!((Property) redefEl).getSubsettedProperty().isEmpty()) { - final ValidationRuleViolation v = new ValidationRuleViolation(classifier, subsetsRule.getDescription() + ": " + redefEl.getQualifiedName()); - v.addAction(new SubsetRedefinedProperty((Property) redefEl, (Property) redefingEl)); + final RedefinableElement inheritedRedefinableElement = (RedefinableElement) ne; + RedefinableElement redefiningElement = null; + + for (NamedElement ownedMember : classifier.getOwnedMember()) { + if (ownedMember instanceof RedefinableElement) { + if (doesEventuallyRedefine((RedefinableElement) ownedMember, inheritedRedefinableElement)) { + redefiningElement = (RedefinableElement) ownedMember; + if (redefiningElement instanceof Property && inheritedRedefinableElement instanceof Property) { + outer: + for (Property propertyToSubset : ((Property) inheritedRedefinableElement).getSubsettedProperty()) { + for (Property subsettedProperty : ((Property) redefiningElement).getSubsettedProperty()) { + if (subsettedProperty.equals(propertyToSubset) || doesEventuallyRedefine(subsettedProperty, propertyToSubset)) { + continue outer; + } + } + final ValidationRuleViolation v = new ValidationRuleViolation(redefiningElement, subsetsRule.getDescription() + ": " + propertyToSubset.getQualifiedName() + " inherited from " + inheritedRedefinableElement.getQualifiedName()); + v.addAction(new SubsetRedefinedProperty((Property) redefiningElement, propertyToSubset)); attributeTypeRule.addViolation(v); } - break; } } } } - if (redefingEl == null) { + if (redefiningElement == null) { boolean redefinedInContext = false; for (final NamedElement ne2 : classifier.getInheritedMember()) { - if (ne2 instanceof RedefinableElement && ne2 instanceof RedefinableElement && doesEventuallyRedefine((RedefinableElement) ne2, redefEl)) { + if (ne2 instanceof RedefinableElement && ne2 instanceof RedefinableElement && doesEventuallyRedefine((RedefinableElement) ne2, inheritedRedefinableElement)) { redefinedInContext = true; break; } } if (!redefinedInContext) { - final ValidationRuleViolation v = new ValidationRuleViolation(classifier, (ne instanceof Property && ((Property) ne).isComposite() ? "[COMPOSITE] " : "") + - (redefEl instanceof TypedElement && ((TypedElement) redefEl).getType() != null ? "[TYPED] " : "") + attributeMissingRule.getDescription() + ": " + redefEl.getQualifiedName()); + final ValidationRuleViolation v = new ValidationRuleViolation(classifier, + (ne instanceof Property && ((Property) ne).isComposite() ? "[COMPOSITE] " : "") + + (inheritedRedefinableElement instanceof TypedElement && ((TypedElement) inheritedRedefinableElement).getType() != null ? "[TYPED] " : "") + + (ne instanceof Property && RedefineAttributeAction.getExplicitMultiplicity((Property) ne) > 1 ? "[MULTIPLIABLE] " : "") + + attributeMissingRule.getDescription() + ": " + inheritedRedefinableElement.getQualifiedName() + ); for (final Property p : classifier.getAttribute()) { - if (p.getName().equals(redefEl.getName()) && !p.hasRedefinedElement()) { - v.addAction(new SetRedefinitionAction(p, redefEl, "Redefine by Name Collision")); + if (p.getName().equals(inheritedRedefinableElement.getName()) && !p.hasRedefinedElement()) { + v.addAction(new SetRedefinitionAction(p, inheritedRedefinableElement, "Redefine by Name Collision")); } } if (ne instanceof RedefinableElement) { - v.addAction(new SetOrCreateRedefinableElementAction(classifier, redefEl, false)); - if (redefEl instanceof TypedElement) { // && ((TypedElement) redefEl).getType() != null + v.addAction(new RedefineAttributeAction(classifier, inheritedRedefinableElement, false, false, false)); + if (inheritedRedefinableElement instanceof TypedElement) { // && ((TypedElement) redefEl).getType() != null // Composite tag added, so user can make an educated decision on whether to specialize or not. Non-composite properties are typically not specialized in the context of the Block Specific Type, // but there could be a number of valid reasons to do so. // Non-aggregation properties should only be redefined but the type not be specialized. // if (!((Property) ne).isComposite()) { // intentionally showing this option even if the type isn't specializable so the user doesn't have to go through // grouping them separately to validate. It will just ignore and log if a type isn't specializable. - v.addAction(new SetOrCreateRedefinableElementAction(classifier, redefEl, true, "Redefine Attribute & Specialize Types Recursively & Individually", true)); + v.addAction(new RedefineAttributeAction(classifier, inheritedRedefinableElement, true, true, false, "Redefine Attribute & Specialize Types Recursively & Individually")); + v.addAction(new RedefineAttributeAction(classifier, inheritedRedefinableElement, true, true, true, "Redefine Attribute & Specialize Types Recursively, Individually & Multiply")); // } } } @@ -150,15 +157,15 @@ public void run() { } } else { - if ((redefingEl.getName() == null && redefEl.getName() != null) || (redefingEl.getName() != null && !redefingEl.getName().equals(redefEl.getName()))) { - final ValidationRuleViolation v = new ValidationRuleViolation(redefingEl, nameRule.getDescription() + ": [GENERAL] " + redefEl.getName() + " - [SPECIFIC] " + redefingEl.getName()); - v.addAction(new RenameElementAction(redefEl, redefingEl, "Update Specific")); - v.addAction(new RenameElementAction(redefingEl, redefEl, "Update General")); + if ((redefiningElement.getName() == null && inheritedRedefinableElement.getName() != null) || (redefiningElement.getName() != null && !redefiningElement.getName().equals(inheritedRedefinableElement.getName()))) { + final ValidationRuleViolation v = new ValidationRuleViolation(redefiningElement, nameRule.getDescription() + ": [GENERAL] " + inheritedRedefinableElement.getName() + " - [SPECIFIC] " + redefiningElement.getName()); + v.addAction(new RenameElementAction(inheritedRedefinableElement, redefiningElement, "Update Specific")); + v.addAction(new RenameElementAction(redefiningElement, inheritedRedefinableElement, "Update General")); nameRule.addViolation(v); } - if (redefingEl instanceof TypedElement && redefEl instanceof TypedElement) { - final TypedElement redefingTypdEl = (TypedElement) redefingEl; - final TypedElement redefableTypdEl = (TypedElement) redefEl; + if (redefiningElement instanceof TypedElement && inheritedRedefinableElement instanceof TypedElement) { + final TypedElement redefingTypdEl = (TypedElement) redefiningElement; + final TypedElement redefableTypdEl = (TypedElement) inheritedRedefinableElement; if ((redefingTypdEl.getType() == null && redefableTypdEl.getType() != null) || (redefingTypdEl.getType() != null && redefingTypdEl.getType() instanceof Classifier && redefableTypdEl.getType() instanceof Classifier && !doesEventuallyGeneralizeTo((Classifier) redefingTypdEl.getType(), (Classifier) redefableTypdEl.getType()))) { From 255b907e71a06fa8575ea03a66fa4f554871d791 Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Tue, 2 Apr 2024 14:02:04 -0700 Subject: [PATCH 2/3] update libz csm version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index aad81ea..1b98735 100644 --- a/build.gradle +++ b/build.gradle @@ -94,7 +94,7 @@ dependencies { preCompile group: 'gov.nasa.jpl.cae.nomagic', name: 'cae-cameo-systems-modeler-core', version: '4.3.1', classifier: 'linux', ext: 'zip' } else { - preCompile group: 'com.nomagic', name: 'democsm', version: '2022xRefresh1', classifier: 'Cameo_Systems_Modeler_2022x_Refresh1_HF1_no_install', ext: 'zip' + preCompile group: 'com.nomagic', name: 'democsm', version: '2022xRefresh2', classifier: 'Cameo_Systems_Modeler_2022x_Refresh2_HF1_no_install', ext: 'zip' } preCompile group: 'org.openmbee.mdk.magic', name: 'mdk', version: '6.0.0', classifier: 'plugin', ext: 'zip' From 2b7f7bb4bcb2f96608842219ad988e377f508e74 Mon Sep 17 00:00:00 2001 From: Doris Lam Date: Tue, 2 Apr 2024 14:53:05 -0700 Subject: [PATCH 3/3] clean up gradle and up version --- build.gradle | 37 +++---------------------------------- gradle.properties | 2 +- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/build.gradle b/build.gradle index 1b98735..bab749d 100644 --- a/build.gradle +++ b/build.gradle @@ -34,33 +34,7 @@ apply plugin: 'distribution' // In this section you declare where to find the dependencies of your project repositories { - // mavenCentral() flatDir { dirs "libz" } - if (buildAccess == 'internal') { - maven { - url 'https://cae-artifactory.jpl.nasa.gov/artifactory/maven-libs-snapshot-virtual' - credentials { - username project.getProperties().get('artifactoryUsername') - password project.getProperties().get('artifactoryPassword') - } - } - maven { - url 'https://cae-artifactory.jpl.nasa.gov/artifactory/maven-libs-release-virtual' - credentials { - username project.getProperties().get('artifactoryUsername') - password project.getProperties().get('artifactoryPassword') - } - } - } - else { - ivy { - // http://download1.nomagic.com/magicdraw185sp2/MagicDraw_185_sp2_no_install.zip - url 'http://download1.nomagic.com/' - layout 'pattern', { - artifact '/[module][revision]/[classifier].[ext]' - } - } - } mavenCentral() maven { url 'https://repo.gradle.org/gradle/libs-releases-local/' @@ -89,14 +63,9 @@ dependencies { testPublish group: 'org.openmbee.testrail', name: 'testrail-cli', version: '1.0.1' // Other dependencies we're unable to resolve via standard repositories - - if (buildAccess == 'internal') { - preCompile group: 'gov.nasa.jpl.cae.nomagic', name: 'cae-cameo-systems-modeler-core', version: '4.3.1', classifier: 'linux', ext: 'zip' - } - else { - preCompile group: 'com.nomagic', name: 'democsm', version: '2022xRefresh2', classifier: 'Cameo_Systems_Modeler_2022x_Refresh2_HF1_no_install', ext: 'zip' - } - preCompile group: 'org.openmbee.mdk.magic', name: 'mdk', version: '6.0.0', classifier: 'plugin', ext: 'zip' + + preCompile group: 'com.nomagic', name: 'democsm', version: '2022xRefresh2', classifier: 'Cameo_Systems_Modeler_2022x_Refresh2_HF1_no_install', ext: 'zip' + preCompile group: 'org.openmbee.mdk.magic', name: 'mdk', version: '6.1.0', classifier: 'plugin', ext: 'zip' // This ensures classpath load order to match the MagicDraw provided order and then includes extras needed for non-OpenAPI stuff. // This was necessary because of the Application class stubbing that was done in the chromium libraries. diff --git a/gradle.properties b/gradle.properties index 4f16ff1..902eb83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=2.0.0 +version=2.1.0 group=org.openmbee.mdk.magic descriptorFile=MDR_Plugin_MDK_Systems_Reasoner_91120_descriptor.xml # Add credentials for publishing to ~/.gradle/gradle.properties