Skip to content

Commit

Permalink
Merge pull request #11 from Open-MBEE/develop
Browse files Browse the repository at this point in the history
2.1.0
  • Loading branch information
dlamoris authored Apr 2, 2024
2 parents 3dd7481 + 2b7f7bb commit a1c26f6
Show file tree
Hide file tree
Showing 12 changed files with 361 additions and 373 deletions.
37 changes: 3 additions & 34 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
Expand Down Expand Up @@ -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: '2022xRefresh1', classifier: 'Cameo_Systems_Modeler_2022x_Refresh1_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.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -57,6 +58,7 @@ protected void configure(ActionsManager manager, List<Element> elements) {
specializeStructureRecursiveAction = null;
specializeStructureAction = null;
specializeStructureRecursivelyIndividuallyAction = null;
specializeStructureRecursivelyIndividuallyMultiplyAction = null;
createInstanceMenuAction = null;
importCSVAction = null;
selectAspectAction = null;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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 org.openmbee.mdk.validation.GenericRuleViolationAction;
Expand All @@ -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<RedefinableElement>(), new ArrayList<Classifier>(), 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<RedefinableElement> traveled, List<Classifier> visited, boolean isIndividual, boolean isRecursive) {
public static boolean createSpecializedType(final StructuralFeature redefinedAttribute, final Classifier parent, final List<RedefinableElement> traveled, List<Classifier> visited, boolean isIndividual, boolean isRecursive, boolean isMultiply) {
if (!parent.isEditable()) {
Application.getInstance().getGUILog().log(parent.getQualifiedName() + " is not editable. Skipping creating specialization.");
return true;
Expand Down Expand Up @@ -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) {
Expand All @@ -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<Type> types = new HashSet<Type>();
Set<Type> 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()) {
Expand All @@ -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();
}
}
Expand All @@ -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<? extends Classifier> 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<String>();
// special.getOwnedMember().retainAll(emptyCollection);
// special.getGeneralization().retainAll(emptyCollection);


Classifier specific = (Classifier) CopyPasting.copyPasteElement(general, parent, true);
if (specific == null) {
return null;
}

ArrayList<NamedElement> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void checkForRedefinedElements(HashSet<Classifier> createdElements) {
}
}
if (!redefined) {
SetOrCreateRedefinableElementAction action = new SetOrCreateRedefinableElementAction(ns, (RedefinableElement) mem, false);
RedefineAttributeAction action = new RedefineAttributeAction(ns, (RedefinableElement) mem, false, false, false);
action.run();
}
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
Loading

0 comments on commit a1c26f6

Please sign in to comment.