diff --git a/README.md b/README.md index 100b9b2..2e49d05 100644 --- a/README.md +++ b/README.md @@ -1 +1,47 @@ -# MDK Systems Reasoner +# Cameo MDK Systems Reasoner + +[![GitHub release (latest by date)](https://img.shields.io/github/v/release/Open-MBEE/mdk-systems-reasoner?label=download)](https://github.com/Open-MBEE/mdk-systems-reasoner/releases/latest) [![Jira](https://img.shields.io/badge/issues-jira-blue)](https://openmbee.atlassian.net/browse/MDK) [![CircleCI](https://circleci.com/gh/Open-MBEE/mdk-systems-reasoner.svg?style=shield)](https://circleci.com/gh/Open-MBEE/mdk-systems-reasoner) [![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/Open-MBEE/mdk-systems-reasoner.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Open-MBEE/mdk-systems-reasoner/context:java) + +Convenience tooling for UML/SysML inheritance using the Block Specific Type pattern. Cameo MDK Systems Reasoner is a plugin for [Cameo Systems Modeler](https://www.nomagic.com/products/cameo-systems-modeler) and other No Magic environment bundles. + +# Quickstart + +## Prerequisites + +* [Cameo Systems Modeler (CSM)](https://www.nomagic.com/products/cameo-systems-modeler) or another No Magic environment bundle that includes the [SysML plugin](https://www.nomagic.com/product-addons/magicdraw-addons/sysml-plugin) + * The latest Cameo MDK Systems Reasoner version is tested with and supports **2022 Refresh 1**. Compatibility for previous versions of Cameo MDK Systems Reasoner can be found in the [compatibility matrices](https://github.com/Open-MBEE/open-mbee.github.io/wiki/Compatibilities). + +## Installation + +1. [Download](https://github.com/Open-MBEE/mdk-systems-reasoner/releases/latest) the Cameo MDK Systems Reasoner plugin, e.g. `mdk-systems-reasoner-*-plugin.zip`. + +2. Run CSM. From the main menu, select "Help" > "Resource/Plugin Manager". + ![Resource/Plugin Manager](doc/images/resource-plugin-manager.png) + +3. Click "Import", navigate to the downloaded Cameo MDK Systems Reasoner plugin, and click "Open". + +4. CSM should confirm installation with the following prompt. + + ![MDK Installation Confirmation](doc/images/mdk-installation-confirmation.png) + +5. Restart CSM. To check installation, select from the main menu "Help" > "Resource/Plugin Manager" > "Plugins (no cost)" and ensure a row exists for "MDK Systems Reasoner" and its status is "Installed" with the correct version. + ![MDK Installed](doc/images/mdk-installed.png) + +> Cameo MDK Systems Reasoner can also be installed headlessly by simply unzipping the plugin archive into the directory that CSM is installed in. + +## Usage + +Documentation can be accessed [online](src/main/dist/manual) or offline in CSM from the main menu "Help" > "Other Documentation" > "MDK [...] UserGuide". + +# Local Development + +Cameo MDK Systems Reasoner is a Java project that uses the [Gradle](https://gradle.org/) build tool. It can be imported as a Gradle project in IDEs like [IntelliJ](https://www.jetbrains.com/idea/) and [Eclipse](https://www.eclipse.org/ide/). + +## Common Tasks +* `./gradlew dependencies` will download all necessary dependencies. +* `./gradlew assemble` will compile the plugin from source. +* `./gradlew distZip` will package the installable plugin. +* `./gradlew installDist` will install the plugin in a staging environment. +* `./gradlew runJava` will interactively run CSM with the plugin installed from the staging environment. + +Task dependencies are declared such that all necessary prerequisites are executed/cached, e.g. `runJava` will first `dependencies`, `assemble`, `distZip`, etc. diff --git a/build.gradle b/build.gradle index 98e580b..aad81ea 100644 --- a/build.gradle +++ b/build.gradle @@ -14,16 +14,16 @@ if (buildTag == null || buildTag.isEmpty() || project.getProperties().getOrDefau String buildNumber = project.hasProperty('buildNumber') ? project.getProperty('buildNumber') : System.currentTimeSeconds() String timestamp = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH:mm").format(LocalDateTime.now()) // classpathLibraries as defined in bin/[magicdraw|csm].properties#CLASSPATH -String[] classpathLibraries = ['lib/patch.jar', 'lib/brand.jar', 'lib/brand_api.jar', 'lib/md.jar', 'lib/md_api.jar', 'lib/md_common.jar', 'lib/md_common_api.jar', 'lib/md_common_test.jar', 'lib/tw_common.jar', 'lib/tw_common_api.jar', 'lib/launcher.jar', 'lib/activation.jar', 'lib/annotation.jar', 'lib/batik.jar', 'lib/bridj-0.7.0.jar', 'lib/bundles/ch.qos.logback.classic_1.2.3.jar', 'lib/bundles/ch.qos.logback.core_1.2.3.jar', 'lib/bundles/cmof_1.4.0.201911181409/cmof14.jar', 'lib/bundles/cmof_1.4.0.201911181409/tas.jar', 'lib/bundles/com.esotericsoftware.kryo_2.22.0.201401231130.jar', 'lib/bundles/com.google.guava_18.0.0.jar', 'lib/bundles/com.nomagic.annotations_1.0.0/com.nomagic.annotation-1.0.jar', 'lib/bundles/com.nomagic.ci.binary_17.0.5.v20191118-1402.jar', 'lib/bundles/com.nomagic.ci.metamodel.project_17.0.5.v20191118-1402.jar', 'lib/bundles/com.nomagic.ci.persistence.local_17.0.5.v20191118-1402.jar', 'lib/bundles/com.nomagic.ci.persistence_17.0.5.v20191118-1402.jar', 'lib/bundles/com.nomagic.ci.services_17.0.5.v20191118-1402.jar', 'lib/bundles/com.nomagic.ci_17.0.5.v20191118-1402.jar', 'lib/bundles/com.nomagic.magicdraw.ce_18.1.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.core.diagram_18.1.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.core.project.options_18.1.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.core_1.0.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.esi.binary.metamodel_18.1.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.esi.esiproject_18.1.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.esi.uuidmap_18.1.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.foundation_2.0.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.osgi.fragment_1.0.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.security_18.3.0.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw.uml2_2.5.1.201911181409.jar', 'lib/bundles/com.nomagic.magicdraw_17.0.5.201911181409.jar', 'lib/bundles/com.teamdev.jxbrowser.chromium.internal.linux64_6.24.1.jar', 'lib/bundles/com.teamdev.jxbrowser.chromium.internal.mac_6.24.1.jar', 'lib/bundles/com.teamdev.jxbrowser.chromium.internal.win32_6.24.1.jar', 'lib/bundles/com.teamdev.jxbrowser.chromium.internal.win64_6.24.1.jar', 'lib/bundles/com.teamdev.jxbrowser.chromium_6.24.1.jar', 'lib/bundles/com.typesafe.config_1.3.0.jar', 'lib/bundles/com.typesafe.sslconfig_0.2.2.jar', 'lib/bundles/de.schlichtherle.truezip_7.4.3.v20191118-1402/lib/truezip-driver-zip-7.4.3.jar', 'lib/bundles/de.schlichtherle.truezip_7.4.3.v20191118-1402/lib/truezip-kernel-7.4.3.jar', 'lib/bundles/gnu.trove_3.0.3/lib/trove-3.0.3.jar', 'lib/bundles/io.aeron.client_1.7.0.jar', 'lib/bundles/io.aeron.driver_1.7.0.jar', 'lib/bundles/io.dropwizard.metrics.core_3.1.2.jar', 'lib/bundles/io.dropwizard.metrics.graphite_3.1.2.jar', 'lib/bundles/io.netty.buffer_4.1.21.Final.jar', 'lib/bundles/io.netty.codec_4.1.21.Final.jar', 'lib/bundles/io.netty.common_4.1.21.Final.jar', 'lib/bundles/io.netty.handler_4.1.21.Final.jar', 'lib/bundles/io.netty.resolver_4.1.21.Final.jar', 'lib/bundles/io.netty.transport_4.1.21.Final.jar', 'lib/bundles/javax.jmi_1.0.0.201911181409/javax_jmi-1_0-fr.jar', 'lib/bundles/joda-time_2.9.1.jar', 'lib/bundles/lz4-java_1.3.0.jar', 'lib/bundles/org.agrona_0.9.12.jar', 'lib/bundles/org.apache.commons.codec_1.9.0.v20170208-1614.jar', 'lib/bundles/org.apache.commons.collections_3.2.1.jar', 'lib/bundles/org.apache.commons.compress_1.3.0.jar', 'lib/bundles/org.apache.commons.io_2.4.0.jar', 'lib/bundles/org.apache.commons.lang_2.6.0.v201404270220.jar', 'lib/bundles/org.apache.commons.logging_1.1.1.v201101211721.jar', 'lib/bundles/org.apache.felix.scr_2.0.10.v20170501-2007.jar', 'lib/bundles/org.apache.httpcomponents.httpclient_4.5.3.jar', 'lib/bundles/org.apache.httpcomponents.httpcore_4.4.6.v20170210-0925.jar', 'lib/bundles/org.apache.log4j_1.2.15.v201005080500.jar', 'lib/bundles/org.apache.servicemix.bundles.jsr305_2.0.1.1.jar', 'lib/bundles/org.apiguardian_1.1.0.v20190826-0900.jar', 'lib/bundles/org.eclipse.core.contenttype_3.6.0.v20170207-1037.jar', 'lib/bundles/org.eclipse.core.jobs_3.9.2.v20171030-1027.jar', 'lib/bundles/org.eclipse.core.runtime_3.13.0.v20170207-1030.jar', 'lib/bundles/org.eclipse.emf.common_2.13.0.v20170609-0707.jar', 'lib/bundles/org.eclipse.emf.ecore.xmi_2.13.0.v20170609-0707.jar', 'lib/bundles/org.eclipse.emf.ecore_2.13.0.v20170609-0707.jar', 'lib/bundles/org.eclipse.equinox.app_1.3.400.v20150715-1528.jar', 'lib/bundles/org.eclipse.equinox.common_3.9.0.v20170207-1454.jar', 'lib/bundles/org.eclipse.equinox.ds_1.5.0.v20170307-1429.jar', 'lib/bundles/org.eclipse.equinox.preferences_3.7.0.v20170126-2132.jar', 'lib/bundles/org.eclipse.equinox.registry_3.7.0.v20170222-1344.jar', 'lib/bundles/org.eclipse.osgi.services_3.6.0.v20170228-1906.jar', 'lib/bundles/org.eclipse.osgi.util_3.4.0.v20170111-1608.jar', 'lib/bundles/org.eclipse.osgi_3.12.50.v20170928-1321.jar', 'lib/bundles/org.eclipse.uml2.common_1.5.0.v200905041045.jar', 'lib/bundles/org.hamcrest.core_1.3.0.v201303031735.jar', 'lib/bundles/org.jboss.netty_3.10.6.Final.jar', 'lib/bundles/org.json_1.0.0.255610281323.jar', 'lib/bundles/org.junit.jupiter.api_5.5.1.v20190826-0900.jar', 'lib/bundles/org.junit.jupiter.params_5.5.1.v20190826-0900.jar', 'lib/bundles/org.junit.platform.commons_1.5.1.v20190826-0900.jar', 'lib/bundles/org.junit_4.12.0.v201504281640/junit.jar', 'lib/bundles/org.opentest4j_1.2.0.v20190826-0900.jar', 'lib/bundles/org.reactivestreams.reactive-streams_1.0.2.jar', 'lib/bundles/org.uncommons.maths_1.2.2.201301151508/lib/uncommons-maths-1.2.2a.jar', 'lib/bundles/slf4j.api_1.7.25.jar', 'lib/com.nomagic.osgi.launcher-17.0.5-SNAPSHOT.jar', 'lib/commons-compress-1.3.jar', 'lib/commons-httpclient-3.1.jar', 'lib/commons-logging-1.0.4.jar', 'lib/concurrent.jar', 'lib/EccpressoAll.jar', 'lib/ehcache-2.10.1.jar', 'lib/flexlm.jar', 'lib/graphics/clibwrapper_jiio.jar', 'lib/graphics/freehep-base.jar', 'lib/graphics/freehep-graphics2d.jar', 'lib/graphics/freehep-graphicsio-emf.jar', 'lib/graphics/freehep-graphicsio-ps.jar', 'lib/graphics/freehep-graphicsio.jar', 'lib/graphics/jai_imageio.jar', 'lib/gson-2.2.4.jar', 'lib/HTMLEditorLight.jar', 'lib/hunspell-bridj-1.0.5-SNAPSHOT.jar', 'lib/javassist.jar', 'lib/jhall.jar', 'lib/jide-action.jar', 'lib/jide-charts.jar', 'lib/jide-common.jar', 'lib/jide-components.jar', 'lib/jide-diff.jar', 'lib/jide-dock.jar', 'lib/jide-editor.jar', 'lib/jide-gantt.jar', 'lib/jide-grids.jar', 'lib/jide-shortcut.jar', 'lib/jimi.jar', 'lib/jna.jar', 'lib/jnp-client.jar', 'lib/jtidy-sources.zip', 'lib/jtidy.jar', 'lib/JUnitParams-1.0.1.jar', 'lib/lucene-analyzers-common-7.5.0.jar', 'lib/lucene-core-7.5.0.jar', 'lib/lucene-misc-7.5.0.jar', 'lib/poi-3.14-20160307.jar', 'lib/poi-ooxml-3.14-20160307.jar', 'lib/poi-ooxml-schemas-3.14-20160307.jar', 'lib/webservice/axis-config.jar', 'lib/webservice/axis.jar', 'lib/webservice/commons-discovery-0.2.jar', 'lib/webservice/jaxrpc.jar', 'lib/webservice/mdserviceclient.jar', 'lib/webservice/rsclient.jar', 'lib/webservice/wsdl4j-1.5.1.jar', 'lib/xalan.jar', 'lib/xmlbeans-2.6.0.jar', 'lib/y.jar'] - +String[] classpathLibraries = ['lib/classpath.jar'] buildscript { repositories { - jcenter() + mavenCentral() + maven { + url 'https://plugins.gradle.org/m2/' + } } dependencies { classpath group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '4.9.0' - classpath group: 'com.jfrog.bintray.gradle', name: 'gradle-bintray-plugin', version: '1.8.4' - classpath group: 'org.zeroturnaround', name: 'gradle-jrebel-plugin', version: '1.1.8' } } @@ -31,11 +31,11 @@ apply plugin: 'idea' apply plugin: 'eclipse' apply plugin: 'java' apply plugin: 'distribution' -apply plugin: 'rebel' // In this section you declare where to find the dependencies of your project repositories { - maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' } + // mavenCentral() + flatDir { dirs "libz" } if (buildAccess == 'internal') { maven { url 'https://cae-artifactory.jpl.nasa.gov/artifactory/maven-libs-snapshot-virtual' @@ -61,7 +61,10 @@ repositories { } } } - jcenter() + mavenCentral() + maven { + url 'https://repo.gradle.org/gradle/libs-releases-local/' + } } configurations { @@ -71,36 +74,35 @@ configurations { // In this section you declare the dependencies for your production and test code dependencies { - compile group: 'net.sf.opencsv', name: 'opencsv', version: '2.3' + implementation group: 'net.sf.opencsv', name: 'opencsv', version: '2.3' // Test Dependencies //testCompile 'junit:junit:4.11' - testCompile group: 'org.gradle', name: 'gradle-core', version: '3.5.1' - testCompile group: 'org.gradle', name: 'gradle-base-services', version: '3.5.1' - testCompile group: 'org.gradle', name: 'gradle-messaging', version: '3.5.1' - testCompile group: 'org.gradle', name: 'gradle-logging', version: '3.5.1' - testCompile group: 'org.gradle', name: 'gradle-process-services', version: '3.5.1' - testCompile group: 'org.gradle', name: 'gradle-tooling-api', version: '3.5.1' + testImplementation group: 'org.gradle', name: 'gradle-core', version: '6.1.1' + testImplementation group: 'org.gradle', name: 'gradle-base-services', version: '6.1.1' + testImplementation group: 'org.gradle', name: 'gradle-messaging', version: '6.1.1' + testImplementation group: 'org.gradle', name: 'gradle-logging', version: '6.1.1' + testImplementation group: 'org.gradle', name: 'gradle-process-services', version: '6.1.1' + testImplementation group: 'org.gradle', name: 'gradle-worker-processes', version: '6.1.1' + testImplementation group: 'org.gradle', name: 'gradle-tooling-api', version: '6.1.1' 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.2.1', classifier: 'linux', ext: 'zip' + 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: 'demomagicdraw', version: '190sp3', classifier: 'MagicDraw_Demo_190_sp3_no_install', ext: 'zip' - preCompile group: 'com.nomagic', name: 'sysml', version: '190sp3', classifier: 'SysML_Plugin_190_sp3_bundle', ext: 'zip' - preCompile group: 'com.nomagic', name: 'cst', version: '190sp3', classifier: 'Cameo_Simulation_Toolkit_Plugin_190_sp3', ext: 'zip' + preCompile group: 'com.nomagic', name: 'democsm', version: '2022xRefresh1', classifier: 'Cameo_Systems_Modeler_2022x_Refresh1_HF1_no_install', ext: 'zip' } - preCompile group: 'org.openmbee.magicdraw.mdk', name: 'mdk', version: '4.2.1', classifier: 'plugin', ext: 'zip' + preCompile group: 'org.openmbee.mdk.magic', name: 'mdk', version: '6.0.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. - compile files(classpathLibraries.collect { 'build/dependency-cache/extracted/' + it }) - compile fileTree(dir: 'build/dependency-cache/extracted', include: ['lib/**/*.jar', 'plugins/**/*.jar'], exclude: ([ classpathLibraries, ['plugins/com.nomagic.collaborator.publisher/**/*.jar', 'plugins/com.nomagic.magicdraw.emfuml2xmi*/**/*.jar', 'plugins/com.nomagic.magicdraw.automaton/lib/engines/**/*.jar', 'plugins/tomsawyer/**/*.jar'] ]).flatten()) - compile fileTree(dir: 'lib', include: ['**/*.jar']) + implementation files(classpathLibraries.collect { 'build/dependency-cache/extracted/' + it }) + implementation fileTree(dir: 'build/dependency-cache/extracted', include: ['lib/**/*.jar', 'plugins/**/*.jar'], exclude: ([classpathLibraries, ['plugins/com.nomagic.collaborator.publisher/**/*.jar', 'plugins/com.nomagic.magicdraw.emfuml2xmi*/**/*.jar', 'plugins/com.nomagic.magicdraw.automaton/lib/engines/**/*.jar', 'plugins/tomsawyer/**/*.jar'] ]).flatten()) + implementation fileTree(dir: 'lib', include: ['**/*.jar']) } task extractDependencies { @@ -171,7 +173,7 @@ task testsHackJar(type: Jar, dependsOn: testClasses) { manifest { attributes( - 'Main-Class': 'gov.nasa.jpl.mbee.mdk.test.framework.GradleMagicDrawLauncher' + 'Main-Class': 'org.openmbee.mdk.test.framework.GradleMagicDrawLauncher' ) } } @@ -278,7 +280,6 @@ distZip.dependsOn preDist apply plugin: 'maven-publish' apply plugin: 'com.jfrog.artifactory' -apply plugin: 'com.jfrog.bintray' publishing { // Reference to Gradle publications defined in the build script. @@ -328,17 +329,6 @@ artifactory { artifactoryPublish.dependsOn distZip -bintray { - user = project.getProperties().get('bintrayUser') - key = project.getProperties().get('bintrayKey') - publications = ['mavenJava'] - publish = true - pkg { - repo = project.getProperties().get('bintrayRepo') - name = rootProject.name - userOrg = project.getProperties().get('bintrayUserOrg') - } -} installDist { destinationDir = file('build/plugin') @@ -364,14 +354,13 @@ task runJava(type: JavaExec) { standardOutput = System.out errorOutput = System.err - main = 'com.nomagic.osgi.launcher.ProductionFrameworkLauncher' - jvmArgs = ['-Xmx8192M', '-Xss512M', '-DLOCALCONFIG=true', '-DWINCONFIG=true', '-Djsse.enableSNIExtension=false', '-Djava.net.preferIPv4Stack=true', '-Dcom.sun.media.imageio.disableCodecLib=true', '-noverify', '-Dlocal.config.dir.ext=-dev', '-splash:data/splash.png', '-Dmd.class.path=$java.class.path', '-Dcom.nomagic.osgi.config.dir=configuration', '-Desi.system.config=data/application.conf', '-Dlogback.configurationFile=data/logback.xml', '-Dsun.locale.formatasdefault=true', '-Dorg.osgi.framework.bundle.parent=ext'] + main = 'com.nomagic.magicdraw.Main' + jvmArgs = ['-Xmx8192M', '-Xss512M', '-DLOCALCONFIG=true', '-DWINCONFIG=true', '-Djsse.enableSNIExtension=false', '-Djava.net.preferIPv4Stack=true', '-Dcom.sun.media.imageio.disableCodecLib=true', '-noverify', '-Dlocal.config.dir.ext=-dev', '-splash:data/splash.png', '-Dmd.class.path=$java.class.path', '-Desi.system.config=data/application.conf', '-Dlogback.configurationFile=data/logback.xml', '-Dsun.locale.formatasdefault=true', '-Djdk.attach.allowAttachSelf=true'] // arguments to pass to the application args 'DEVELOPER' } runJava.dependsOn installDist -runJava.dependsOn generateRebel task runScript(type: Exec) { workingDir "build/install" diff --git a/doc/images/mdk-installation-confirmation.png b/doc/images/mdk-installation-confirmation.png new file mode 100644 index 0000000..38f9148 Binary files /dev/null and b/doc/images/mdk-installation-confirmation.png differ diff --git a/doc/images/mdk-installed.png b/doc/images/mdk-installed.png new file mode 100644 index 0000000..c646deb Binary files /dev/null and b/doc/images/mdk-installed.png differ diff --git a/doc/images/resource-plugin-manager.png b/doc/images/resource-plugin-manager.png new file mode 100644 index 0000000..b4c81bf Binary files /dev/null and b/doc/images/resource-plugin-manager.png differ diff --git a/gradle.properties b/gradle.properties index 26f8fb3..4f16ff1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -version=1.0.0 -group=org.openmbee.magicdraw.mdk.systems_reasoner +version=2.0.0 +group=org.openmbee.mdk.magic descriptorFile=MDR_Plugin_MDK_Systems_Reasoner_91120_descriptor.xml # Add credentials for publishing to ~/.gradle/gradle.properties artifactoryUrl= diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 6ffa237..94336fc 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f6a138c..ecdac3b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Feb 05 13:56:26 PST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip diff --git a/settings.gradle b/settings.gradle index e6ff8c5..b21684e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = 'mdk-systems-reasoner' +rootProject.name = 'systems-reasoner' diff --git a/src/main/dist/template/plugins/${group}/plugin.xml b/src/main/dist/template/plugins/${group}/plugin.xml index 76fa687..c84bd03 100644 --- a/src/main/dist/template/plugins/${group}/plugin.xml +++ b/src/main/dist/template/plugins/${group}/plugin.xml @@ -8,7 +8,7 @@ class="org.openmbee.mdk.systems_reasoner.SystemsReasonerPlugin"> - + diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AddAssociationGeneralizationAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AddAssociationGeneralizationAction.java new file mode 100644 index 0000000..28b3037 --- /dev/null +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AddAssociationGeneralizationAction.java @@ -0,0 +1,43 @@ +package org.openmbee.mdk.systems_reasoner.actions; + +import com.nomagic.magicdraw.core.Application; +import com.nomagic.magicdraw.openapi.uml.SessionManager; +import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Association; +import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; +import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Generalization; +import com.nomagic.uml2.ext.magicdraw.metadata.UMLFactory; + +import java.awt.event.ActionEvent; + +public class AddAssociationGeneralizationAction extends SRAction { + public static final String DEFAULT_ID = "Generalize Association"; + private final Association association; + private final Association superAssociation; + + public AddAssociationGeneralizationAction(Association association, Association superAssociation) { + super(DEFAULT_ID); + this.association = association; + this.superAssociation = superAssociation; + + } + + public void actionPerformed(ActionEvent e) { + if (association == null) { + Application.getInstance().getGUILog().log("[WARNING] Association on specific missing. Skipping association generalization."); + return; + } + if (superAssociation == null) { + Application.getInstance().getGUILog().log("[WARNING] Association on general missing. Skipping association generalization."); + return; + } + SessionManager.getInstance().createSession(DEFAULT_ID); + try { + Generalization gen = UMLFactory.eINSTANCE.createGeneralization(); + gen.setGeneral(superAssociation); + gen.setSpecific(association); + this.association.getGeneralization().add(gen); + } finally { + SessionManager.getInstance().closeSession(); + } + } +} diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AddInheritanceToAssociationAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AddInheritanceToAssociationAction.java deleted file mode 100644 index e697893..0000000 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AddInheritanceToAssociationAction.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.openmbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.core.Application; -import com.nomagic.magicdraw.openapi.uml.SessionManager; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Association; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Generalization; -import com.nomagic.uml2.ext.magicdraw.metadata.UMLFactory; - -import java.awt.event.ActionEvent; - -public class AddInheritanceToAssociationAction extends SRAction { - public static final String DEFAULT_ID = "Add inheritance to association."; - private Association association; - private Association superAssociation; - - public AddInheritanceToAssociationAction(Association association, Association superAssociation) { - super(DEFAULT_ID); - this.association = association; - this.superAssociation = superAssociation; - - } - - public void actionPerformed(ActionEvent e) { - SessionManager.getInstance().createSession(DEFAULT_ID); - if (association != null) { - if (superAssociation != null) { - Generalization gen = UMLFactory.eINSTANCE.createGeneralization(); - gen.setGeneral(superAssociation); - gen.setSpecific(association); - this.association.getGeneralization().add(gen); - Application.getInstance().getGUILog().log("Inheritance added to association" + association.getName()); - } - else { - Application.getInstance().getGUILog().log("Association on super element missing."); - } - } - else { - Application.getInstance().getGUILog().log("Association on inheriting element missing."); - } - SessionManager.getInstance().closeSession(); - } -} 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..5dfbb73 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 @@ -3,7 +3,7 @@ import com.nomagic.magicdraw.core.Project; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.validation.GenericRuleViolationAction; import java.util.ArrayList; diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AspectSelectionAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AspectSelectionAction.java index b012ad9..90e82a2 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AspectSelectionAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/AspectSelectionAction.java @@ -17,7 +17,7 @@ import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Package; import com.nomagic.uml2.ext.magicdraw.mdprofiles.Stereotype; -import gov.nasa.jpl.mbee.mdk.api.incubating.convert.Converters; +import org.openmbee.mdk.api.incubating.convert.Converters; import org.openmbee.mdk.systems_reasoner.api.SRConstants; import java.awt.*; diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateInstanceAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateInstanceAction.java index 9d21fd5..2fe7967 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateInstanceAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateInstanceAction.java @@ -3,7 +3,7 @@ import com.nomagic.magicdraw.annotation.Annotation; import com.nomagic.magicdraw.core.Application; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.validation.GenericRuleViolationAction; import java.util.Collection; import java.util.HashMap; diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateSlotsAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateSlotsAction.java index 454b2cc..e782e16 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateSlotsAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/CreateSlotsAction.java @@ -5,7 +5,7 @@ import com.nomagic.magicdraw.core.Application; import com.nomagic.task.ProgressStatus; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.validation.GenericRuleViolationAction; import java.util.*; 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..476ea0b 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 @@ -3,7 +3,7 @@ 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; +import org.openmbee.mdk.validation.GenericRuleViolationAction; import java.lang.Class; import java.util.ArrayList; 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 8831986..57fcf99 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 @@ -15,10 +15,10 @@ import com.nomagic.uml2.ext.magicdraw.auxiliaryconstructs.mdmodels.Model; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; import com.nomagic.uml2.ext.magicdraw.metadata.UMLFactory; -import gov.nasa.jpl.mbee.mdk.api.incubating.convert.Converters; -import gov.nasa.jpl.mbee.mdk.util.Utils; -import gov.nasa.jpl.mbee.mdk.validation.ValidationRule; -import gov.nasa.jpl.mbee.mdk.validation.ValidationRuleViolation; +import org.openmbee.mdk.api.incubating.convert.Converters; +import org.openmbee.mdk.util.Utils; +import org.openmbee.mdk.validation.ValidationRule; +import org.openmbee.mdk.validation.ValidationRuleViolation; import org.openmbee.mdk.systems_reasoner.validation.SRValidationSuite; import javax.swing.*; @@ -105,8 +105,8 @@ private void checkForAssociationInheritance(HashSet createdElements) for (Classifier element : createdElements) { for (Classifier general : element.getGeneral()) { - SRValidationSuite.checkAssociationsForInheritance(element, general); - ValidationRule ele = SRValidationSuite.getAssociationInheritanceRule(); + SRValidationSuite.checkAssociationGeneralizations(element, general); + ValidationRule ele = SRValidationSuite.getAssociationGeneralizationRule(); for (ValidationRuleViolation violation : ele.getViolations()) { NMAction action = violation.getActions().get(0); action.actionPerformed(null); @@ -391,4 +391,4 @@ private Element getPropertyFromColumnName(String propertyName, Classifier classi } return null; } -} \ No newline at end of file +} diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/OpenSpecificationAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/OpenSpecificationAction.java index 8383c81..973e3eb 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/OpenSpecificationAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/OpenSpecificationAction.java @@ -2,7 +2,7 @@ import com.nomagic.magicdraw.ui.dialogs.specifications.SpecificationDialogManager; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.validation.GenericRuleViolationAction; public class OpenSpecificationAction extends GenericRuleViolationAction { private static final String DEFAULT_NAME = "Specification"; diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RenameElementAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RenameElementAction.java index 316c774..3d99393 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RenameElementAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RenameElementAction.java @@ -2,7 +2,7 @@ import com.nomagic.magicdraw.core.Application; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.validation.GenericRuleViolationAction; public class RenameElementAction extends GenericRuleViolationAction { private NamedElement source, target; diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RetypeElementAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RetypeElementAction.java index 4fed0e2..77166d5 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RetypeElementAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/RetypeElementAction.java @@ -2,7 +2,7 @@ import com.nomagic.magicdraw.core.Application; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.TypedElement; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.validation.GenericRuleViolationAction; public class RetypeElementAction extends GenericRuleViolationAction { private TypedElement source, target; diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SelectInContainmentTreeAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SelectInContainmentTreeAction.java index 522f82f..909c4c6 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SelectInContainmentTreeAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SelectInContainmentTreeAction.java @@ -2,7 +2,7 @@ import com.nomagic.magicdraw.core.Application; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.validation.GenericRuleViolationAction; public class SelectInContainmentTreeAction extends GenericRuleViolationAction { private static final String DEFAULT_NAME = "Select in Containment Tree"; 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 index 6654cd4..6a70f2a 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetOrCreateRedefinableElementAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetOrCreateRedefinableElementAction.java @@ -5,8 +5,8 @@ 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.util.Utils; +import org.openmbee.mdk.validation.GenericRuleViolationAction; import org.openmbee.mdk.systems_reasoner.validation.SRValidationSuite; import java.util.ArrayList; diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetRedefinitionAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetRedefinitionAction.java index c1c39c7..29807f1 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetRedefinitionAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/SetRedefinitionAction.java @@ -2,7 +2,7 @@ import com.nomagic.magicdraw.core.Application; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.RedefinableElement; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.validation.GenericRuleViolationAction; public class SetRedefinitionAction extends GenericRuleViolationAction { private RedefinableElement redefiningElement, redefinedElement; 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..adce895 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 @@ -3,7 +3,7 @@ import com.nomagic.magicdraw.core.Application; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Generalization; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; +import org.openmbee.mdk.validation.GenericRuleViolationAction; public class SpecializeClassifierAction extends GenericRuleViolationAction { private static final String DEFAULT_NAME = "Specialize Classifier"; 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 80dfb03..31a71ff 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 @@ -15,8 +15,8 @@ import com.nomagic.uml2.ext.jmi.helpers.ModelHelper; import com.nomagic.uml2.ext.magicdraw.auxiliaryconstructs.mdmodels.Model; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; -import gov.nasa.jpl.mbee.mdk.api.incubating.convert.Converters; -import gov.nasa.jpl.mbee.mdk.util.Utils; +import org.openmbee.mdk.api.incubating.convert.Converters; +import org.openmbee.mdk.util.Utils; import java.awt.*; import java.awt.event.ActionEvent; @@ -148,7 +148,9 @@ private > R collectDiagrams(Namespace specific, R } else if (ne instanceof Namespace) { for (NamedElement nam : ((Namespace) ne).getOwnedMember()) { - collectDiagrams((Namespace) nam, diagrams); + if (nam instanceof Namespace) { + collectDiagrams((Namespace) nam, diagrams); + } } } } @@ -174,7 +176,7 @@ private void checkAssociationsForInheritance(Classifier classifier, Classifier g break assocRule; } else { - AddInheritanceToAssociationAction action = new AddInheritanceToAssociationAction(((Property) child).getAssociation(), ((Property) superChild).getAssociation()); + AddAssociationGeneralizationAction action = new AddAssociationGeneralizationAction(((Property) child).getAssociation(), ((Property) superChild).getAssociation()); action.actionPerformed(null); } } @@ -185,7 +187,7 @@ else if (partType instanceof Classifier) { break assocRule; } else { - AddInheritanceToAssociationAction action = new AddInheritanceToAssociationAction(((Property) child).getAssociation(), ((Property) superChild).getAssociation()); + AddAssociationGeneralizationAction action = new AddAssociationGeneralizationAction(((Property) child).getAssociation(), ((Property) superChild).getAssociation()); action.actionPerformed(null); } } @@ -204,7 +206,7 @@ private boolean hasAnAssociation(Element superChild) { private boolean hasInheritanceFromTo(Classifier classifier, Classifier general) { if (classifier != null) { - return ModelHelper.getGeneralClassifiersRecursivelly(classifier).contains(general); + return ModelHelper.collectGeneralClassifiersRecursively(classifier, new ArrayList<>()).contains(general); } else { return false; diff --git a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/ValidateAction.java b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/ValidateAction.java index dc854cc..ac8479c 100644 --- a/src/main/java/org/openmbee/mdk/systems_reasoner/actions/ValidateAction.java +++ b/src/main/java/org/openmbee/mdk/systems_reasoner/actions/ValidateAction.java @@ -3,7 +3,7 @@ import com.nomagic.magicdraw.core.Application; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.InstanceSpecification; -import gov.nasa.jpl.mbee.mdk.util.Utils; +import org.openmbee.mdk.util.Utils; import org.openmbee.mdk.systems_reasoner.validation.SRValidationSuite; import java.awt.event.ActionEvent; 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 a88e5bf..d1e323d 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 @@ -7,12 +7,13 @@ import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; import com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdbasicbehaviors.Behavior; import com.nomagic.uml2.ext.magicdraw.mdprofiles.Stereotype; -import gov.nasa.jpl.mbee.mdk.validation.*; +import org.openmbee.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; public class SRValidationSuite extends ValidationSuite implements Runnable { @@ -30,11 +31,11 @@ public class SRValidationSuite extends ValidationSuite implements Runnable { private static final ValidationRule instanceClassifierExistenceRule = new ValidationRule("Instance Classifier Unspecified", "Instance classifier is not specified", ViolationSeverity.ERROR); private static final ValidationRule missingSlotsRule = new ValidationRule("Missing Slot(s) Detected", "Missing slot(s) detected", ViolationSeverity.ERROR); - public static ValidationRule getAssociationInheritanceRule() { - return associationInheritanceRule; + public static ValidationRule getAssociationGeneralizationRule() { + return associationGeneralizationRule; } - private static final ValidationRule associationInheritanceRule = new ValidationRule("Association inheritance missing.", "The association of the specialized element does not inherit from its general classifier.", ViolationSeverity.ERROR); + private static final ValidationRule associationGeneralizationRule = new ValidationRule("Missing Association Generalization", "The association of the specific does not generalize to that of the general", ViolationSeverity.ERROR); { this.addValidationRule(generalMissingRule); @@ -46,7 +47,7 @@ public static ValidationRule getAssociationInheritanceRule() { this.addValidationRule(generalSpecificNameRule); this.addValidationRule(instanceClassifierExistenceRule); this.addValidationRule(missingSlotsRule); - this.addValidationRule(associationInheritanceRule); + this.addValidationRule(associationGeneralizationRule); this.addValidationRule(subsetsRule); } @@ -92,7 +93,7 @@ public void run() { for (final Classifier general : classifier.getGeneral()) { // Inheritance on Associations Rule - checkAssociationsForInheritance(classifier, general); + checkAssociationGeneralizations(classifier, general); checkForAspects(classifier, general); } @@ -245,41 +246,43 @@ else if (element instanceof InstanceSpecification) { } } - public static void checkAssociationsForInheritance(Classifier classifier, Classifier general) { - assocRule: - for (Element child : classifier.getOwnedElement()) { - if (child instanceof Property) { - Type partType = ((Property) child).getType(); - for (Element superChild : general.getOwnedElement()) { - if (superChild instanceof Property) { - Type superPartType = ((Property) superChild).getType(); - final ValidationRuleViolation v = new ValidationRuleViolation(classifier, associationInheritanceRule.getDescription() + ": [GENERAL] " + general.getName() + " - [SPECIFIC] " + classifier.getName()); - if (partType != null) { - if (partType.equals(superPartType)) { - if (hasAnAssociation(superChild)) { - if (hasInheritanceFromTo(((Property) child).getAssociation(), ((Property) superChild).getAssociation())) { - break assocRule; - } - else { - v.addAction(new AddInheritanceToAssociationAction(((Property) child).getAssociation(), ((Property) superChild).getAssociation())); - associationInheritanceRule.addViolation(v); - } - } - } - else if (partType instanceof Classifier) { - if (((Classifier) partType).getGeneral().contains(superPartType)) { - if (hasInheritanceFromTo(((Property) child).getAssociation(), ((Property) superChild).getAssociation())) { - break assocRule; - } - else { - v.addAction(new AddInheritanceToAssociationAction(((Property) child).getAssociation(), ((Property) superChild).getAssociation())); - associationInheritanceRule.addViolation(v); - } - } - } - } - } + public static void checkAssociationGeneralizations(Classifier special, Classifier general) { + + property: + for (Element specialOwnedMember : special.getOwnedMember()) { + if (!(specialOwnedMember instanceof Property)) { + continue; + } + Property specialProperty = (Property) specialOwnedMember; + + Type specialPropertyType = specialProperty.getType(); + if (specialPropertyType == null) { + continue; + } + + Association specialAssociation; + if ((specialAssociation = specialProperty.getAssociation()) == null) { + continue; + } + + for (Property generalProperty : specialProperty.getRedefinedProperty()) { + if (!Objects.equals(generalProperty.getClassifier(), general)) { + continue; + } + + Association generalAssociation; + if ((generalAssociation = generalProperty.getAssociation()) == null) { + continue; + } + + if (hasInheritanceFromTo(specialAssociation, generalAssociation)) { + continue property; } + + final ValidationRuleViolation v = new ValidationRuleViolation(specialAssociation, + associationGeneralizationRule.getDescription() + ": [GENERAL] " + general.getName() + " - [SPECIFIC] " + special.getName()); + v.addAction(new AddAssociationGeneralizationAction(specialAssociation, generalAssociation)); + associationGeneralizationRule.addViolation(v); } } } @@ -325,14 +328,9 @@ else if (ownedElement instanceof CallBehaviorAction) { } } - private static boolean hasAnAssociation(Element superChild) { - return ((Property) superChild).getAssociation() != null; - - } - - private static boolean hasInheritanceFromTo(Classifier classifier, Classifier general) { - if (classifier != null) { - return ModelHelper.getGeneralClassifiersRecursivelly(classifier).contains(general); + private static boolean hasInheritanceFromTo(Classifier special, Classifier general) { + if (special != null) { + return ModelHelper.collectGeneralClassifiersRecursively(special, new ArrayList<>()).contains(general); } else { return false; diff --git a/src/test/java/gov/nasa/jpl/mbee/mdk/test/framework/GradleMagicDrawLauncher.java b/src/test/java/gov/nasa/jpl/mbee/mdk/test/framework/GradleMagicDrawLauncher.java index ae73c49..31e9739 100644 --- a/src/test/java/gov/nasa/jpl/mbee/mdk/test/framework/GradleMagicDrawLauncher.java +++ b/src/test/java/gov/nasa/jpl/mbee/mdk/test/framework/GradleMagicDrawLauncher.java @@ -17,7 +17,7 @@ * Created by igomes on 10/22/16. */ public class GradleMagicDrawLauncher { - private static final String FRAMEWORK_LAUNCHER_CLASS = System.getProperty("com.nomagic.osgi.launcher", "com.nomagic.osgi.launcher.ProductionFrameworkLauncher"); + private static final String FRAMEWORK_LAUNCHER_CLASS = System.getProperty("com.nomagic.osgi.launcher", "com.nomagic.magicdraw.Main"); private URLClassLoader urlClassLoader; private String mainClass; @@ -145,4 +145,4 @@ private void parseArgs(String... args) throws IOException { private static boolean isAcceptablePath(String path) { return !path.contains("com.typesafe.akka") && !path.contains("org.scala") && !path.contains("com.nomagic.esi"); } -} \ No newline at end of file +} diff --git a/src/test/java/gov/nasa/jpl/mbee/mdk/test/framework/MagicDrawClassLoaderWorker.java b/src/test/java/gov/nasa/jpl/mbee/mdk/test/framework/MagicDrawClassLoaderWorker.java index 22a3415..2420571 100644 --- a/src/test/java/gov/nasa/jpl/mbee/mdk/test/framework/MagicDrawClassLoaderWorker.java +++ b/src/test/java/gov/nasa/jpl/mbee/mdk/test/framework/MagicDrawClassLoaderWorker.java @@ -69,6 +69,7 @@ public MagicDrawClassLoaderWorker(DataInputStream configInputStream) { } public Void call() throws Exception { + /* if (System.getProperty("org.gradle.worker.test.stuck") != null) { // Simulate a stuck worker. There's probably a way to inject this failure... Thread.sleep(30000); @@ -132,14 +133,14 @@ public ObjectConnection getServerConnection() { messagingServices.close(); loggingManager.stop(); } - +*/ return null; } private WorkerLogEventListener configureLogging(LoggingManagerInternal loggingManager, ObjectConnection connection) { connection.useParameterSerializers(WorkerLoggingSerializer.create()); WorkerLoggingProtocol workerLoggingProtocol = connection.addOutgoing(WorkerLoggingProtocol.class); - WorkerLogEventListener workerLogEventListener = new WorkerLogEventListener(workerLoggingProtocol); + WorkerLogEventListener workerLogEventListener = new WorkerLogEventListener(); loggingManager.addOutputEventListener(workerLogEventListener); return workerLogEventListener; }