diff --git a/Jenkinsfile b/Jenkinsfile index f3164464d..abcf99e1b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -65,7 +65,7 @@ pipeline { } } stage('Publish Snapshot') { - when { branch 'develop' } + when { anyOf { branch 'develop' ; branch 'release/**' } } steps { sh './gradlew \ -PbuildNumber=$BUILD_NUMBER \ diff --git a/build.gradle b/build.gradle index 8d335c8fd..6f085626e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ import java.util.zip.ZipFile String buildAccess = project.getProperties().getOrDefault('buildAccess', 'opensource') String buildTag = project.getProperties().get('buildTag') if (buildTag != null && !buildTag.isEmpty() && buildTag != version) { - throw new GradleException('Version mismatch.') + throw new GradleException('Version mismatch: '+buildTag+' vs '+version) } if (buildTag == null || buildTag.isEmpty() || project.getProperties().getOrDefault('artifactoryRepository', '').toLowerCase().contains('snapshot')) { version += '-SNAPSHOT' @@ -16,8 +16,9 @@ if (buildAccess == 'internal') { } String buildNumber = project.hasProperty('buildNumber') ? project.getProperty('buildNumber') : System.currentTimeSeconds() String timestamp = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH:mm").format(LocalDateTime.now()) -//String[] classpathLibraries = ['lib/patch.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.201811041524/cmof14.jar','lib/bundles/cmof_1.4.0.201811041524/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.v20181104-1514.jar','lib/bundles/com.nomagic.ci.metamodel.project_17.0.5.v20181104-1514.jar','lib/bundles/com.nomagic.ci.persistence.local_17.0.5.v20181104-1514.jar','lib/bundles/com.nomagic.ci.persistence_17.0.5.v20181104-1514.jar','lib/bundles/com.nomagic.ci.services_17.0.5.v20181104-1514.jar','lib/bundles/com.nomagic.ci_17.0.5.v20181104-1514.jar','lib/bundles/com.nomagic.esi.api.messages_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.api_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.client.core_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.common_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.config_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.core.msg_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.emf_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.helper_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.net_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.serializer.akka_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.serializer_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.service.actorsystem_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.services_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.stream_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.esi.supervisor_1.0.0.v20181030-1552.jar','lib/bundles/com.nomagic.magicdraw.ce_18.1.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.core.diagram_18.1.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.core.project.options_18.1.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.core_1.0.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.esi.binary.metamodel_18.1.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.esi.esiproject_18.1.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.esi.uuidmap_18.1.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.foundation_2.0.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.osgi.fragment_1.0.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.security_18.3.0.201811041524.jar','lib/bundles/com.nomagic.magicdraw.uml2_2.5.1.201811041524.jar','lib/bundles/com.nomagic.magicdraw_17.0.5.201811041524.jar','lib/bundles/com.teamdev.jxbrowser.chromium.internal.linux32_6.13.0.jar','lib/bundles/com.teamdev.jxbrowser.chromium.internal.linux64_6.13.0.jar','lib/bundles/com.teamdev.jxbrowser.chromium.internal.mac_6.13.0.jar','lib/bundles/com.teamdev.jxbrowser.chromium.internal.win32_6.13.0.jar','lib/bundles/com.teamdev.jxbrowser.chromium_6.13.0.jar','lib/bundles/com.typesafe.akka.actor_2.5.10.jar','lib/bundles/com.typesafe.akka.cluster.tools_2.5.10.jar','lib/bundles/com.typesafe.akka.cluster_2.5.10.jar','lib/bundles/com.typesafe.akka.osgi_2.5.10.jar','lib/bundles/com.typesafe.akka.protobuf_2.5.10.jar','lib/bundles/com.typesafe.akka.remote_2.5.10.jar','lib/bundles/com.typesafe.akka.slf4j_2.5.10.jar','lib/bundles/com.typesafe.akka.stream_2.5.10.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.v20181104-1514/lib/truezip-driver-zip-7.4.3.jar','lib/bundles/de.schlichtherle.truezip_7.4.3.v20181104-1514/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.201811041524/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.0.0.v20170910-2246.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.0.0.v20170910-2246.jar','lib/bundles/org.junit.jupiter.params_5.0.0.v20170910-2246.jar','lib/bundles/org.junit.platform.commons_1.0.0.v20170910-2246.jar','lib/bundles/org.junit_4.12.0.v201504281640/junit.jar','lib/bundles/org.opentest4j_1.0.0.v20170910-2246.jar','lib/bundles/org.reactivestreams.reactive-streams_1.0.2.jar','lib/bundles/org.scala-lang.modules.scala-java8-compat_0.8.0.jar','lib/bundles/org.scala-lang.modules.scala-parser-combinators_1.0.4.jar','lib/bundles/org.scala-lang.scala-library_2.12.4.v20171010-220511-VFINAL-c2a5883.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/jsr250-api-1.0.jar','lib/jsr305.jar','lib/jtidy.jar','lib/JUnitParams-1.0.1.jar','lib/lucene-analyzers-common-4.10.3.jar','lib/lucene-core-4.10.3.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/patch.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/brand.jar','lib/brand_api.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.201903082028/cmof14.jar','lib/bundles/cmof_1.4.0.201903082028/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.v20190308-2012.jar','lib/bundles/com.nomagic.ci.metamodel.project_17.0.5.v20190308-2012.jar','lib/bundles/com.nomagic.ci.persistence.local_17.0.5.v20190308-2012.jar','lib/bundles/com.nomagic.ci.persistence_17.0.5.v20190308-2012.jar','lib/bundles/com.nomagic.ci.services_17.0.5.v20190308-2012.jar','lib/bundles/com.nomagic.ci_17.0.5.v20190308-2012.jar','lib/bundles/com.nomagic.esi.api.messages_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.api_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.client.core_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.common_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.config_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.core.msg_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.emf_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.helper_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.net_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.serializer.akka_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.serializer_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.service.actorsystem_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.services_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.stream_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.esi.supervisor_1.0.0.v20190306-1144.jar','lib/bundles/com.nomagic.magicdraw.ce_18.1.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.core.diagram_18.1.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.core.project.options_18.1.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.core_1.0.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.esi.binary.metamodel_18.1.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.esi.esiproject_18.1.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.esi.uuidmap_18.1.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.foundation_2.0.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.osgi.fragment_1.0.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.security_18.3.0.201903082028.jar','lib/bundles/com.nomagic.magicdraw.uml2_2.5.1.201903082028.jar','lib/bundles/com.nomagic.magicdraw_17.0.5.201903082028.jar','lib/bundles/com.teamdev.jxbrowser.chromium.internal.linux64_6.22.0.jar','lib/bundles/com.teamdev.jxbrowser.chromium.internal.mac_6.22.0.jar','lib/bundles/com.teamdev.jxbrowser.chromium.internal.win32_6.22.0.jar','lib/bundles/com.teamdev.jxbrowser.chromium.internal.win64_6.22.0.jar','lib/bundles/com.teamdev.jxbrowser.chromium_6.22.0.jar','lib/bundles/com.typesafe.akka.actor_2.5.10.jar','lib/bundles/com.typesafe.akka.cluster.tools_2.5.10.jar','lib/bundles/com.typesafe.akka.cluster_2.5.10.jar','lib/bundles/com.typesafe.akka.osgi_2.5.10.jar','lib/bundles/com.typesafe.akka.protobuf_2.5.10.jar','lib/bundles/com.typesafe.akka.remote_2.5.10.jar','lib/bundles/com.typesafe.akka.slf4j_2.5.10.jar','lib/bundles/com.typesafe.akka.stream_2.5.10.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.v20190308-2012/lib/truezip-driver-zip-7.4.3.jar','lib/bundles/de.schlichtherle.truezip_7.4.3.v20190308-2012/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.201903082028/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.0.0.v20170910-2246.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.0.0.v20170910-2246.jar','lib/bundles/org.junit.jupiter.params_5.0.0.v20170910-2246.jar','lib/bundles/org.junit.platform.commons_1.0.0.v20170910-2246.jar','lib/bundles/org.junit_4.12.0.v201504281640/junit.jar','lib/bundles/org.opentest4j_1.0.0.v20170910-2246.jar','lib/bundles/org.reactivestreams.reactive-streams_1.0.2.jar','lib/bundles/org.scala-lang.modules.scala-java8-compat_0.8.0.jar','lib/bundles/org.scala-lang.modules.scala-parser-combinators_1.0.4.jar','lib/bundles/org.scala-lang.scala-library_2.12.4.v20171010-220511-VFINAL-c2a5883.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/jsr250-api-1.0.jar','lib/jsr305.jar','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/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'] +// 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'] + buildscript { repositories { @@ -142,7 +143,7 @@ dependencies { // 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.0', classifier: 'linux', ext: 'zip' + preCompile group: 'gov.nasa.jpl.cae.nomagic', name: 'cae-cameo-systems-modeler-core', version: '4.2.1', classifier: 'linux', ext: 'zip' } else { preCompile group: 'com.nomagic', name: 'demomagicdraw', version: '190sp3', classifier: 'MagicDraw_Demo_190_sp3_no_install', ext: 'zip' diff --git a/gradle.properties b/gradle.properties index ab87a02c3..bc7c1c18a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=4.2.0 +version=4.2.1 group=org.openmbee.magicdraw.mdk descriptorFile=MDR_Plugin_Model_Development_Kit_91110_descriptor.xml magicdDrawGroupName=gov.nasa.jpl.cae.magicdraw.mdk diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/MDKPlugin.java b/src/main/java/gov/nasa/jpl/mbee/mdk/MDKPlugin.java index 45ef2ca04..6262d3e52 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/MDKPlugin.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/MDKPlugin.java @@ -17,7 +17,6 @@ import gov.nasa.jpl.mbee.mdk.cli.AutomatedViewGenerator; import gov.nasa.jpl.mbee.mdk.mms.sync.status.SyncStatusConfigurator; import gov.nasa.jpl.mbee.mdk.options.MDKOptionsGroup; -import gov.nasa.jpl.mbee.mdk.systems_reasoner.SRConfigurator; import gov.nasa.jpl.mbee.mdk.util.MDUtils; import java.io.File; @@ -94,11 +93,6 @@ public void init() { acm.addMainMenuConfigurator(new MMSConfigurator()); EvaluationConfigurator.getInstance().registerBinaryImplementers(MDKPlugin.class.getClassLoader()); - SRConfigurator srConfigurator = new SRConfigurator(); - acm.addSearchBrowserContextConfigurator(srConfigurator); - acm.addContainmentBrowserContextConfigurator(srConfigurator); - acm.addBaseDiagramContextConfigurator(DiagramTypeConstants.UML_ANY_DIAGRAM, srConfigurator); - acm.addMainToolbarConfigurator(new SyncStatusConfigurator()); DiagramDescriptor viewDiagramDescriptor = Application.getInstance().getDiagramDescriptor(ViewDiagramConfigurator.DIAGRAM_NAME); diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/actions/LockAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/actions/LockAction.java index 47f2f56af..d9c283aa7 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/actions/LockAction.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/actions/LockAction.java @@ -1,5 +1,6 @@ package gov.nasa.jpl.mbee.mdk.actions; +import com.nomagic.magicdraw.actions.MDAction; import com.nomagic.magicdraw.annotation.Annotation; import com.nomagic.magicdraw.annotation.AnnotationAction; import com.nomagic.magicdraw.core.Project; @@ -8,7 +9,6 @@ import com.nomagic.task.RunnableWithProgress; import com.nomagic.ui.ProgressStatusRunner; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; -import gov.nasa.jpl.mbee.mdk.systems_reasoner.actions.SRAction; import javax.annotation.CheckForNull; import java.awt.event.ActionEvent; @@ -20,12 +20,12 @@ /** * Created by igomes on 12/5/16. */ -public class LockAction extends SRAction implements AnnotationAction { +public class LockAction extends MDAction implements AnnotationAction { private final Element element; private final boolean recursive; public LockAction(Element element, boolean recursive) { - super("Lock" + (recursive ? " Recursively" : "")); + super("Lock" + (recursive ? " Recursively" : ""), "Lock" + (recursive ? " Recursively" : ""), null, null); this.element = element; this.recursive = recursive; } diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFExporter.java b/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFExporter.java index 573ae3a13..17ab179af 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFExporter.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/emf/EMFExporter.java @@ -209,15 +209,16 @@ private enum Processor { objectNode.put(MDKConstants.TYPE_KEY, "Mount"); objectNode.put(MDKConstants.MOUNTED_ELEMENT_ID_KEY, Converters.getIProjectToIdConverter().apply(attachedProject) + MDKConstants.PRIMARY_MODEL_ID_SUFFIX); objectNode.put(MDKConstants.MOUNTED_ELEMENT_PROJECT_ID_KEY, Converters.getIProjectToIdConverter().apply(attachedProject)); - String branchName; - EsiUtils.EsiBranchInfo esiBranchInfo = null; - if (isRemote && (esiBranchInfo = EsiUtils.getCurrentBranch(attachedProject)) == null) { + EsiUtils.EsiBranchInfo branchInfo = EsiUtils.getCurrentBranch(attachedProject); + if (isRemote && branchInfo == null) { return null; } - if (!isRemote || (branchName = esiBranchInfo.getName()) == null || branchName.equals("trunk")) { + String branchName; + if (!isRemote || (branchName = branchInfo.getName()) == null || "trunk".equals(branchName)) { branchName = "master"; } - objectNode.put(MDKConstants.MOUNTED_REF_ID_KEY, branchName); + String branchId = "master".equals(branchName) ? "master" : branchInfo.getID().toString(); + objectNode.put(MDKConstants.MOUNTED_REF_ID_KEY, branchId); objectNode.put(MDKConstants.TWC_VERSION_KEY, isRemote ? ProjectUtilities.versionToInt(ProjectUtilities.getVersion(attachedProject).getName()) : -1); return objectNode; }, diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/mms/actions/DetailedSyncStatusAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/mms/actions/DetailedSyncStatusAction.java index 1093c5399..28d5aca2f 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/mms/actions/DetailedSyncStatusAction.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/mms/actions/DetailedSyncStatusAction.java @@ -1,5 +1,6 @@ package gov.nasa.jpl.mbee.mdk.mms.actions; +import com.nomagic.magicdraw.actions.MDAction; import com.nomagic.magicdraw.core.Application; import com.nomagic.magicdraw.core.Project; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; @@ -10,7 +11,6 @@ import gov.nasa.jpl.mbee.mdk.mms.sync.local.LocalDeltaProjectEventListenerAdapter; import gov.nasa.jpl.mbee.mdk.mms.sync.local.LocalDeltaTransactionCommitListener; import gov.nasa.jpl.mbee.mdk.mms.sync.mms.MMSDeltaProjectEventListenerAdapter; -import gov.nasa.jpl.mbee.mdk.systems_reasoner.actions.SRAction; import gov.nasa.jpl.mbee.mdk.util.Changelog; import gov.nasa.jpl.mbee.mdk.util.Utils; import gov.nasa.jpl.mbee.mdk.validation.ValidationRule; @@ -27,9 +27,9 @@ /** * Created by igomes on 12/5/16. */ -public class DetailedSyncStatusAction extends SRAction { +public class DetailedSyncStatusAction extends MDAction { public DetailedSyncStatusAction() { - super(DetailedSyncStatusAction.class.getSimpleName()); + super(DetailedSyncStatusAction.class.getSimpleName(), DetailedSyncStatusAction.class.getSimpleName(), null, null); } private static final ValidationSuite validationSuite = new ValidationSuite("Sync Status"); diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/mms/sync/status/actions/SyncStatusAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/mms/sync/status/actions/SyncStatusAction.java index 376e65d75..315f4a429 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/mms/sync/status/actions/SyncStatusAction.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/mms/sync/status/actions/SyncStatusAction.java @@ -1,5 +1,6 @@ package gov.nasa.jpl.mbee.mdk.mms.sync.status.actions; +import com.nomagic.magicdraw.actions.MDAction; import com.nomagic.magicdraw.core.Application; import com.nomagic.magicdraw.core.Project; import com.nomagic.ui.ProgressStatusRunner; @@ -11,7 +12,6 @@ import gov.nasa.jpl.mbee.mdk.mms.sync.local.LocalDeltaTransactionCommitListener; import gov.nasa.jpl.mbee.mdk.mms.sync.mms.MMSDeltaProjectEventListenerAdapter; import gov.nasa.jpl.mbee.mdk.mms.sync.status.ui.SyncStatusFrame; -import gov.nasa.jpl.mbee.mdk.systems_reasoner.actions.SRAction; import gov.nasa.jpl.mbee.mdk.util.Changelog; import javax.annotation.CheckForNull; @@ -24,14 +24,14 @@ /** * Created by igomes on 8/16/16. */ -public class SyncStatusAction extends SRAction { +public class SyncStatusAction extends MDAction { public static final String NAME = "Unsynced"; private SyncStatusFrame syncStatusFrame; public SyncStatusAction() { - super(NAME); + super(NAME, NAME, null, null); update(); } diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/model/GenericTable.java b/src/main/java/gov/nasa/jpl/mbee/mdk/model/GenericTable.java index a8b3434dc..a1da006ea 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/model/GenericTable.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/model/GenericTable.java @@ -2,22 +2,17 @@ import com.nomagic.generictable.GenericTableManager; import com.nomagic.magicdraw.core.Application; - import com.nomagic.magicdraw.dependencymatrix.configuration.MatrixDataHelper; import com.nomagic.magicdraw.dependencymatrix.datamodel.MatrixData; import com.nomagic.magicdraw.dependencymatrix.datamodel.cell.AbstractMatrixCell; import com.nomagic.magicdraw.properties.*; +import com.nomagic.magicdraw.properties.ui.ObjectListProperty; import com.nomagic.magicdraw.uml.DiagramType; - import com.nomagic.uml2.ext.jmi.helpers.ModelHelper; -import com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; - import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.InstanceSpecification; import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement; - import gov.nasa.jpl.mbee.mdk.docgen.DocGenProfile; import gov.nasa.jpl.mbee.mdk.docgen.docbook.*; import gov.nasa.jpl.mbee.mdk.mms.sync.local.LocalDeltaProjectEventListenerAdapter; @@ -26,9 +21,12 @@ import gov.nasa.jpl.mbee.mdk.util.GeneratorUtils; import gov.nasa.jpl.mbee.mdk.util.MatrixUtil; import gov.nasa.jpl.mbee.mdk.util.Utils; + import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; public class GenericTable extends Table { @@ -206,78 +204,22 @@ public List> getHeaders(Diagram genericTable, List public List> getBody(Diagram d, Collection rowElements, List columnIds, boolean forViewEditor) { List> res = new ArrayList<>(); - for (Element e : rowElements) { - if (skipIfNoDoc && ModelHelper.getComment(e).trim().isEmpty()) { + for (Element rowElement : rowElements) { + if (skipIfNoDoc && ModelHelper.getComment(rowElement).trim().isEmpty()) { continue; } List row = new ArrayList<>(); int count = 0; - for (String cid : columnIds) { + for (String columnId : columnIds) { if (count == 0) { count++; continue; } - if (skipColumnIds.contains(cid)) { + if (skipColumnIds.contains(columnId)) { continue; } - DBTableEntry entry = new DBTableEntry(); - - Property cellValue = GenericTableManager.getCellValue(d, e, cid); - if (cellValue instanceof ElementProperty) { - Element cellelement = ((ElementProperty) cellValue).getElement(); - if (cellelement instanceof NamedElement) { - entry.addElement(new DBParagraph(((NamedElement) cellelement).getName(), cellelement, From.NAME)); - } - } - else if (cellValue instanceof StringProperty) { - if (cid.contains("documentation")) { - entry.addElement(new DBParagraph(cellValue.getValue(), e, From.DOCUMENTATION)); - - } - else { - entry.addElement(new DBParagraph(cellValue.getValue())); - } - } - else if (cellValue instanceof NumberProperty) { - entry.addElement(new DBParagraph(cellValue.getValue())); - } - else if (cellValue instanceof ElementListProperty) { - for (Element listEl : ((ElementListProperty) cellValue).getValue()) { - if (listEl instanceof NamedElement) { - entry.addElement(new DBParagraph(((NamedElement) listEl).getName(), listEl, From.NAME)); - } - } - } - else if (cellValue instanceof ElementInstanceProperty) { - Object value = cellValue.getValue(); - - if (value instanceof List) { - for (Object o : (List) value) { - if (o instanceof InstanceSpecification) { - entry.addElement(new DBParagraph(((InstanceSpecification) o).getName(), (Element) o, From.NAME)); - } - } - } - } - else if (cellValue instanceof AbstractChoiceProperty) { - if (cellValue instanceof ChoiceProperty) { - int index = ((ChoiceProperty) cellValue).getIndex(); - if (index > -1) { - Object choice = ((ChoiceProperty) cellValue).getChoice().get(index); - entry.addElement(new DBParagraph(choice.toString())); - } - } - else { - for (Object choice : ((AbstractChoiceProperty) cellValue).getChoice()) { - if (choice instanceof String) { - entry.addElement(new DBParagraph(choice.toString())); - } - } - } - } - else { - Application.getInstance().getGUILog().log("[WARNING] Cell value omitted: " + cellValue.toString() + "."); - } + Property property = GenericTableManager.getCellValue(d, rowElement, columnId); + DBTableEntry entry = buildTableEntry(property, columnId, rowElement); row.add(entry); } res.add(row); @@ -285,23 +227,66 @@ else if (cellValue instanceof AbstractChoiceProperty) { return res; } - public List getTableValues(Object o) { - List res = new ArrayList<>(); - if (o instanceof Object[]) { - Object[] a = (Object[]) o; - for (int i = 0; i < a.length; i++) { - res.addAll(getTableValues(a[i])); + private DBTableEntry buildTableEntry(Property property, String columnId, Element rowElement) { + DBTableEntry entry = new DBTableEntry(); + if (property instanceof ElementProperty) { + Element element = ((ElementProperty) property).getElement(); + if (element instanceof NamedElement) { + entry.addElement(new DBParagraph(((NamedElement) element).getName(), element, From.NAME)); } } - else if (o instanceof Collection) { - for (Object oo : (Collection) o) { - res.addAll(getTableValues(oo)); + else if (property instanceof StringProperty) { + if (columnId.contains("documentation")) { + entry.addElement(new DBParagraph(property.getValue(), rowElement, From.DOCUMENTATION)); + } + else { + entry.addElement(new DBParagraph(property.getValue())); } } - else if (o != null) { - res.add(o); + else if (property instanceof NumberProperty) { + entry.addElement(new DBParagraph(property.getValue())); } - return res; + else if (property instanceof ElementListProperty) { + for (Element listEl : ((ElementListProperty) property).getValue()) { + if (listEl instanceof NamedElement) { + entry.addElement(new DBParagraph(((NamedElement) listEl).getName(), listEl, From.NAME)); + } + } + } + else if (property instanceof ElementInstanceProperty) { + Object value = property.getValue(); + + if (value instanceof List) { + for (Object o : (List) value) { + if (o instanceof InstanceSpecification) { + entry.addElement(new DBParagraph(((InstanceSpecification) o).getName(), (Element) o, From.NAME)); + } + } + } + } + else if (property instanceof AbstractChoiceProperty) { + if (property instanceof ChoiceProperty) { + int index = ((ChoiceProperty) property).getIndex(); + if (index > -1) { + Object choice = ((ChoiceProperty) property).getChoice().get(index); + entry.addElement(new DBParagraph(choice.toString())); + } + } + else { + for (Object choice : ((AbstractChoiceProperty) property).getChoice()) { + if (choice instanceof String) { + entry.addElement(new DBParagraph(choice.toString())); + } + } + } + } + else if (property instanceof ObjectListProperty) { + entry.addElements(Arrays.stream(((ObjectListProperty) property).getValue()).map(DBParagraph::new).collect(Collectors.toList())); + } + else { + Application.getInstance().getGUILog().log("[WARNING] Unknown cell value omitted: " + property.toString() + "."); + } + return entry; } public void setSkipIfNoDoc(boolean b) { diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/SRConfigurator.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/SRConfigurator.java deleted file mode 100644 index 9a5a27d32..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/SRConfigurator.java +++ /dev/null @@ -1,161 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner; - -import com.nomagic.actions.ActionsCategory; -import com.nomagic.actions.ActionsManager; -import com.nomagic.magicdraw.actions.*; -import com.nomagic.magicdraw.core.ProjectUtilities; -import com.nomagic.magicdraw.ui.browser.Node; -import com.nomagic.magicdraw.ui.browser.Tree; -import com.nomagic.magicdraw.uml.symbols.DiagramPresentationElement; -import com.nomagic.magicdraw.uml.symbols.PresentationElement; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.InstanceSpecification; -import gov.nasa.jpl.mbee.mdk.systems_reasoner.actions.*; - -import java.util.ArrayList; -import java.util.List; - -public class SRConfigurator implements BrowserContextAMConfigurator, DiagramContextAMConfigurator { - - public static final String NAME = "Systems Reasoner"; - 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; - - @Override - public int getPriority() { - return 0; // medium - } - - @Override - public void configure(ActionsManager manager, Tree tree) { - final List elements = new ArrayList(); - for (final Node n : tree.getSelectedNodes()) { - if (n.getUserObject() instanceof Element) { - elements.add((Element) n.getUserObject()); - } - } - configure(manager, elements); - } - - @Override - public void configure(ActionsManager manager, DiagramPresentationElement diagram, PresentationElement[] selected, PresentationElement requestor) { - final List elements = new ArrayList(); - for (final PresentationElement pe : selected) { - if (pe.getElement() != null) { - elements.add(pe.getElement()); - } - } - configure(manager, elements); - } - - protected void configure(ActionsManager manager, List elements) { - // refresh the actions for every new click (or selection) - validateAction = null; - specializeStructureRecursiveAction = null; - specializeStructureAction = null; - specializeStructureRecursivelyIndividuallyAction = null; - createInstanceMenuAction = null; - importCSVAction = null; - selectAspectAction = null; - - ActionsCategory category = (ActionsCategory) manager.getActionFor("SRMain"); - if (category == null) { - category = new MDActionsCategory("SRMain", "Systems Reasoner", null, ActionsGroups.APPLICATION_RELATED); - category.setNested(true); - // manager.addCategory(0, category); - } - manager.removeCategory(category); - - if (elements.size() > 1) { - category = handleMultipleNodes(category, manager, elements); - } - else if (elements.size() == 1) { - category = handleSingleNode(category, manager, elements.get(0)); - } - else { - return; - } - - if (category == null) { - return; - } - manager.addCategory(0, category); - - category.addAction(validateAction); - category.addAction(importCSVAction); - category.addAction(specializeStructureAction); - category.addAction(specializeStructureRecursiveAction); - category.addAction(specializeStructureRecursivelyIndividuallyAction); - category.addAction(selectAspectAction); - category.addAction(createInstanceMenuAction); - - category.getActions().clear(); - category.setUseActionForDisable(true); - if (category.isEmpty()) { - final MDAction mda = new MDAction(null, null, null, "null"); - mda.updateState(); - mda.setEnabled(false); - category.addAction(mda); - } - } - - public ActionsCategory handleMultipleNodes(ActionsCategory category, ActionsManager manager, List elements) { - final List validatableElements = new ArrayList(); - boolean hasUneditable = false; - - for (Element element : elements) { - if (element != null) { - if (element instanceof Classifier) { - validatableElements.add(element); - } - else if (element instanceof InstanceSpecification) { - validatableElements.add(element); - } - if (!hasUneditable && !element.isEditable()) { - hasUneditable = true; - } - } - } - - // if nothing in classes, disable category and return it - if (validatableElements.isEmpty()) { - // category = disableCategory(category); - return null; - } - // otherwise, add the classes to the ValidateAction action - validateAction = new ValidateAction(validatableElements); - category.addAction(validateAction); - - return category; - } - - public ActionsCategory handleSingleNode(ActionsCategory category, ActionsManager manager, Element element) { - if (element == null) { - return null; - } - if (element instanceof Classifier) { - 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); - createInstanceMenuAction = new CreateInstanceMenuAction(classifier); - - if (!ProjectUtilities.isElementInAttachedProject(classifier)) { - selectAspectAction = new AspectSelectionAction(classifier); - } - } - else if (element instanceof InstanceSpecification) { - final InstanceSpecification instance = (InstanceSpecification) element; - validateAction = new ValidateAction(instance); - } - else { - return null; - } - return category; - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/SpecificationNodeAspectsConfigurator.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/SpecificationNodeAspectsConfigurator.java deleted file mode 100644 index e1d786329..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/SpecificationNodeAspectsConfigurator.java +++ /dev/null @@ -1,147 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner; - -import com.nomagic.magicdraw.ui.dialogs.specifications.ISpecificationComponent; -import com.nomagic.magicdraw.ui.dialogs.specifications.configurator.ISpecificationNodeConfigurator; -import com.nomagic.magicdraw.ui.dialogs.specifications.tree.node.ConfigurableNodeFactory; -import com.nomagic.magicdraw.ui.dialogs.specifications.tree.node.IConfigurableNode; -import com.nomagic.magicdraw.ui.dialogs.specifications.tree.node.ISpecificationNode; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; -import gov.nasa.jpl.mbee.mdk.systems_reasoner.actions.AspectSelectionAction; - -import javax.swing.*; -import java.beans.PropertyChangeEvent; -import java.util.ArrayList; - -/** - * @author Johannes Gross - */ -public class SpecificationNodeAspectsConfigurator implements ISpecificationNodeConfigurator { - @Override - public void configure(IConfigurableNode node, Element element) { - final IConfigurableNode myNode = ConfigurableNodeFactory.createConfigurableNode(new MyNode()); - node.insertNode(IConfigurableNode.DOCUMENTATION_HYPERLINKS, IConfigurableNode.Position.BEFORE, myNode); - } - - private static class MyNode implements ISpecificationNode { - @Override - public String getID() { - return "ASPECTS"; - } - - @Override - public Icon getIcon() { - return null; - } - - @Override - public String getText() { - return "Aspects"; - } - - @Override - public void dispose() { - } - - @Override - public ISpecificationComponent createSpecificationComponent(Element element) { - return new AspectsSpecificationComponent(element); - } - - @Override - public void propertyChanged(Element element, PropertyChangeEvent event) { - } - - @Override - public boolean updateNode() { - return false; - } - } - - private static class AspectsSpecificationComponent implements ISpecificationComponent { - - private final Element specifiedElement; - - public AspectsSpecificationComponent(Element element) { - this.specifiedElement = element; - } - - @Override - public JComponent getComponent() { - StringBuffer sb = new StringBuffer(); - if (specifiedElement instanceof Classifier) { - AspectSelectionAction asa = new AspectSelectionAction((Classifier) specifiedElement); - ArrayList aspects = new ArrayList(); - //asa.findAspectsOfClassifier(aspects); - } - return new JLabel(sb.toString()); - } - - @Override - public void propertyChanged(Element element, PropertyChangeEvent event) { - } - - @Override - public void updateComponent() { - } - - @Override - public void dispose() { - } - } - - private static class MyInnerSpecificationNode implements ISpecificationNode { - @Override - public String getID() { - return "MY_INNER_NODE"; - } - - @Override - public Icon getIcon() { - return null; - } - - @Override - public String getText() { - return "My Inner Node"; - } - - @Override - public void dispose() { - } - - @Override - public ISpecificationComponent createSpecificationComponent(Element element) { - return new MyInnerSpecificationComponent(); - } - - @Override - public void propertyChanged(Element element, PropertyChangeEvent event) { - } - - @Override - public boolean updateNode() { - return false; - } - } - - private static class MyInnerSpecificationComponent implements ISpecificationComponent { - @Override - public JComponent getComponent() { - return new JLabel("My Inner Specification Component"); - } - - @Override - public void propertyChanged(Element element, PropertyChangeEvent event) { - } - - @Override - public void updateComponent() { - } - - @Override - public void dispose() { - } - } - -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/AddInheritanceToAssociationAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/AddInheritanceToAssociationAction.java deleted file mode 100644 index 20ec4e8d1..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/AddInheritanceToAssociationAction.java +++ /dev/null @@ -1,57 +0,0 @@ -package gov.nasa.jpl.mbee.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 { - /** - * - */ - private static final long serialVersionUID = 1L; - public static final String DEFAULT_ID = "Add inheritance to assocation."; - private Association association; - private Association superAssociation; - - public AddInheritanceToAssociationAction(String id) { - super(id); - - } - - public AddInheritanceToAssociationAction(String id, Element element) { - super(id, element); - - } - - 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/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/AspectRemedyAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/AspectRemedyAction.java deleted file mode 100644 index ec974f1c4..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/AspectRemedyAction.java +++ /dev/null @@ -1,28 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -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 java.util.ArrayList; - -public class AspectRemedyAction extends GenericRuleViolationAction { - public static final String DEFAULT_ID = "Realize Aspect"; - private final Classifier classifier, aspect; - - public AspectRemedyAction(Classifier classifier, Classifier aspect) { - super(DEFAULT_ID); - this.classifier = classifier; - this.aspect = aspect; - } - - public void run() { - Classifier realization = new SpecializeStructureAction(aspect, false, null, true, true).createSpecialClassifier(classifier, new ArrayList<>(), new ArrayList<>()); - if (realization != null) { - Property property = Project.getProject(classifier).getElementsFactory().createPropertyInstance(); - property.setClassifier(classifier); - property.setType(realization); - } - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/AspectSelectionAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/AspectSelectionAction.java deleted file mode 100644 index b8c751f7f..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/AspectSelectionAction.java +++ /dev/null @@ -1,93 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.google.common.collect.Lists; -import com.nomagic.magicdraw.core.Application; -import com.nomagic.magicdraw.core.Project; -import com.nomagic.magicdraw.openapi.uml.SessionManager; -import com.nomagic.magicdraw.ui.dialogs.MDDialogParentProvider; -import com.nomagic.magicdraw.ui.dialogs.SelectElementInfo; -import com.nomagic.magicdraw.ui.dialogs.SelectElementTypes; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlg; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlgFactory; -import com.nomagic.uml2.ext.jmi.helpers.ModelHelper; -import com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper; -import com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.DirectedRelationship; -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 gov.nasa.jpl.mbee.mdk.systems_reasoner.api.SRConstants; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -public class AspectSelectionAction extends SRAction { - public static final String DEFAULT_ID = "Add & Realize Aspect(s)"; - - private final Classifier classifier; - - public AspectSelectionAction(Classifier classifier) { - super(DEFAULT_ID); - this.classifier = classifier; - } - - @Override - public void actionPerformed(ActionEvent e) { - Project project = Application.getInstance().getProject(); - if (project == null) { - return; - } - Stereotype aspectStereotype = (Stereotype) Converters.getIdToElementConverter().apply(SRConstants.ASPECT_STEREOTYPE_ID, project); - if (aspectStereotype == null) { - Application.getInstance().getGUILog().log("[ERROR] Aspect stereotype not found. Please add SysML Extensions as a used project. Aborting aspect creation."); - return; - } - List> types = Lists.newArrayList(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class); - - Frame dialogParent = MDDialogParentProvider.getProvider().getDialogParent(); - ElementSelectionDlg dlg = ElementSelectionDlgFactory.create(dialogParent); - SelectElementTypes set = new SelectElementTypes(types, types, null, null); - SelectElementInfo sei = new SelectElementInfo(true, false, project.getPrimaryModel(), true); - - ElementSelectionDlgFactory.initMultiple(dlg, set, sei, Collections.emptyList()); - dlg.show(); - if (!dlg.isOkClicked()) { - return; - } - - SessionManager.getInstance().createSession(project, "Creating aspect"); - Set initialAspects = classifier.getClientDependency().stream().filter(dependency -> StereotypesHelper.hasStereotypeOrDerived(dependency, aspectStereotype)) - .map(DirectedRelationship::getTarget).filter(targets -> targets.size() == 1).map(targets -> targets.iterator().next()).filter(target -> target instanceof Classifier).map(target -> (Classifier) target).collect(Collectors.toSet()); - Set finalAspects = dlg.getSelectedElements().stream().filter(element -> element instanceof Classifier).map(element -> (Classifier) element).collect(Collectors.toSet()); - Set addedAspects = new HashSet<>(finalAspects); - addedAspects.removeAll(initialAspects); - - addedAspects.forEach(aspect -> { - createDependencyWithStereotype(classifier, aspect, aspectStereotype); - new AspectRemedyAction(classifier, aspect).run(); - }); - SessionManager.getInstance().closeSession(project); - } - - private static void setOwnerPackage(Element child, Element parent) { - while (!(parent instanceof Package)) { - parent = parent.getOwner(); - } - child.setOwner(parent); - } - - private static void createDependencyWithStereotype(Element from, Element to, Stereotype s) { - Dependency d = Project.getProject(from).getElementsFactory().createDependencyInstance(); - ModelHelper.setClientElement(d, from); - ModelHelper.setSupplierElement(d, to); - StereotypesHelper.addStereotype(d, s); - setOwnerPackage(d, from); - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateInstanceAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateInstanceAction.java deleted file mode 100644 index 7ce2eb784..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateInstanceAction.java +++ /dev/null @@ -1,126 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -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 java.util.*; - -public class CreateInstanceAction extends GenericRuleViolationAction { - - private static final long serialVersionUID = 1L; - private static final String DEFAULT_NAME = "Create Instance"; - - private Classifier classifier; - private Element context; - private String name; - private boolean createSlots; - private InstanceSpecification instance; - - private static int safetyNet; - - private static Map createdInstances = new HashMap(); - - public CreateInstanceAction(final Classifier classifier, final Element context, final boolean createSlots) { - this(classifier, context, createSlots, DEFAULT_NAME); - } - - public CreateInstanceAction(final Classifier classifier, final Element context, final boolean createSlots, String name) { - super(name); - this.classifier = classifier; - this.context = context; - this.createSlots = createSlots; - } - - public static InstanceSpecification createInstance(final Element instanceable, final Element context, final boolean createSlots) { - safetyNet = 0; - return createInstance(instanceable, context, createSlots, new HashMap()); - } - - public static InstanceSpecification createInstance(final Element instanceable, final Element context, final boolean createSlots, final Map traveled) { - final Classifier classifier; - if (instanceable instanceof Classifier) { - createdInstances.clear(); - classifier = (Classifier) instanceable; - } - else if (instanceable instanceof Property && ((Property) instanceable).getType() instanceof Classifier) { - classifier = (Classifier) ((Property) instanceable).getType(); - } - else { - return null; - } - - if (classifier.isAbstract()) { - Application.getInstance().getGUILog().log(classifier.getQualifiedName() + " is marked as abstract. Skipping instantiation."); - return null; - } - - //System.out.println("Instancing " + ((Property) instanceable).getQualifiedName() + " | Traveled: " + traveled.size()); - if (traveled.containsKey(classifier)) { - Application.getInstance().getGUILog().log("Caught circular reference for " + ((Property) instanceable).getQualifiedName() + ". Skipping instantiation and applying circular reference."); - return traveled.get(classifier); - //return null; - } - System.out.println("Classifier: " + classifier.getQualifiedName()); - - String prefix = ""; - Element owner = context; - if (context instanceof InstanceSpecification) { - prefix = ((InstanceSpecification) context).getName() + "."; - owner = context.getOwner(); - } - - final InstanceSpecification instance = Application.getInstance().getProject().getElementsFactory().createInstanceSpecificationInstance(); - traveled.put(classifier, instance); - /*if (instanceable instanceof Property) { - traveled.put((Property) instanceable, instance); - System.out.println("Adding to traveled: " + ((Property) instanceable).getQualifiedName() + " [" + traveled.size() + "]"); - }*/ - - instance.setName(prefix + (instanceable instanceof Property ? ((Property) instanceable).getName() : classifier.getName())); - instance.getClassifier().add(classifier); - - if (!owner.canAdd(instance)) { - Application.getInstance().getGUILog().log("Cannot add instance specification to " + (owner instanceof NamedElement ? ((NamedElement) owner).getQualifiedName() : owner) + "."); - return null; - } - instance.setOwner(owner); - - - /*if (safetyNet++ > 1000) { - Application.getInstance().getGUILog().log("Exceeded safety net max instantiations. Aborting..."); - throw new RuntimeException("Show me stack"); - //return instance; - }*/ - if (createSlots) { - //final Map clonedMap = new HashMap(traveled); - //System.out.println("Clone size: " + clonedMap.size()); - - CreateSlotsAction.createSlots(instance, createSlots, new HashMap(traveled)); - } - return instance; - } - - @Override - public void run() { - instance = createInstance(classifier, context, createSlots); - } - - @Override - public void execute(Collection annotations) { - - super.execute(annotations); - ValidateAction.validate(instance); - } - - @Override - public String getName() { - return name; - } - - @Override - public String getSessionName() { - return name; - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateInstanceMenuAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateInstanceMenuAction.java deleted file mode 100644 index 9a3a39180..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateInstanceMenuAction.java +++ /dev/null @@ -1,60 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.core.Application; -import com.nomagic.magicdraw.openapi.uml.SessionManager; -import com.nomagic.magicdraw.ui.dialogs.MDDialogParentProvider; -import com.nomagic.magicdraw.ui.dialogs.SelectElementInfo; -import com.nomagic.magicdraw.ui.dialogs.SelectElementTypes; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlg; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlgFactory; -import com.nomagic.magicdraw.ui.dialogs.selection.SelectionMode; -import com.nomagic.uml2.ext.magicdraw.auxiliaryconstructs.mdmodels.Model; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.InstanceSpecification; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Namespace; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.util.ArrayList; -import java.util.List; - -public class CreateInstanceMenuAction extends SRAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - public static final String DEFAULT_ID = "Create Instance"; - private Classifier classifier; - - public CreateInstanceMenuAction(final Classifier classifier) { - super(DEFAULT_ID, classifier); - this.classifier = classifier; - } - - @Override - public void actionPerformed(ActionEvent e) { - final List> types = new ArrayList>(); - types.add(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Package.class); - types.add(Model.class); - - final Frame dialogParent = MDDialogParentProvider.getProvider().getDialogParent(); - final ElementSelectionDlg dlg = ElementSelectionDlgFactory.create(dialogParent); - - final SelectElementTypes set = new SelectElementTypes(null, types, null, null); - final SelectElementInfo sei = new SelectElementInfo(true, false, Application.getInstance().getProject().getModel().getOwner(), true); - ElementSelectionDlgFactory.initSingle(dlg, set, sei, classifier.getOwner()); - dlg.setSelectionMode(SelectionMode.SINGLE_MODE); - if (dlg != null) { - dlg.setVisible(true); - if (dlg.isOkClicked() && dlg.getSelectedElement() != null && dlg.getSelectedElement() instanceof Namespace) { - SessionManager.getInstance().createSession(DEFAULT_ID); - final InstanceSpecification instance = CreateInstanceAction.createInstance(classifier, (Namespace) dlg.getSelectedElement(), false); - SessionManager.getInstance().closeSession(); - - ValidateAction.validate(instance); - } - } - } - -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateOntoBehaviorBlocks.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateOntoBehaviorBlocks.java deleted file mode 100644 index 457c9eb7f..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateOntoBehaviorBlocks.java +++ /dev/null @@ -1,179 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.core.Application; -import com.nomagic.magicdraw.core.Project; -import com.nomagic.magicdraw.openapi.uml.SessionManager; -import com.nomagic.magicdraw.ui.dialogs.MDDialogParentProvider; -import com.nomagic.magicdraw.ui.dialogs.SelectElementInfo; -import com.nomagic.magicdraw.ui.dialogs.SelectElementTypes; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlg; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlgFactory; -import com.nomagic.magicdraw.ui.dialogs.selection.SelectionMode; -import com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper; -import com.nomagic.uml2.ext.magicdraw.actions.mdbasicactions.Action; -import com.nomagic.uml2.ext.magicdraw.auxiliaryconstructs.mdmodels.Model; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; -import com.nomagic.uml2.ext.magicdraw.compositestructures.mdinternalstructures.Connector; -import com.nomagic.uml2.ext.magicdraw.compositestructures.mdinternalstructures.ConnectorEnd; -import com.nomagic.uml2.ext.magicdraw.mdprofiles.Profile; -import com.nomagic.uml2.ext.magicdraw.mdprofiles.Stereotype; -import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.*; -import gov.nasa.jpl.mbee.mdk.api.ElementFinder; -import gov.nasa.jpl.mbee.mdk.util.Utils; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class CreateOntoBehaviorBlocks extends SRAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - public static final String DEFAULT_ID = "Create OntoBehavior Blocks"; - private Classifier classifier; - private Classifier behaviorOccurence = null; - private int stateCounter; - private int regionCounter; - private HashMap stateProps; - private boolean isValidationMode; - - public CreateOntoBehaviorBlocks(final Classifier classifier, boolean isValidationMode) { - super(DEFAULT_ID, classifier); - this.classifier = classifier; - this.isValidationMode = isValidationMode; - } - - @Override - public void actionPerformed(ActionEvent e) { - final List> types = new ArrayList>(); - types.add(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class); - types.add(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Package.class); - types.add(Model.class); - - final Frame dialogParent = MDDialogParentProvider.getProvider().getDialogParent(); - final ElementSelectionDlg dlg = ElementSelectionDlgFactory.create(dialogParent); - dlg.setTitle("Select container for generated elements:"); - final SelectElementTypes set = new SelectElementTypes(null, types, null, null); - final SelectElementInfo sei = new SelectElementInfo(true, false, Application.getInstance().getProject().getModel().getOwner(), true); - ElementSelectionDlgFactory.initSingle(dlg, set, sei, classifier.getOwner()); - - dlg.setSelectionMode(SelectionMode.SINGLE_MODE); - if (dlg != null) { - if (!isValidationMode) { - dlg.setVisible(true); - } - if (isValidationMode || dlg.isOkClicked() && dlg.getSelectedElement() != null && dlg.getSelectedElement() instanceof Namespace) { - Namespace container = null; - if (isValidationMode) { - container = (Namespace) classifier.getOwner(); - } - else { - container = (Namespace) dlg.getSelectedElement(); - } - SessionManager.getInstance().createSession("create ontobehavior"); - //TODO @donbot this qualified name path doesn't exist. fix when fixing systems reasoner. - behaviorOccurence = (Classifier) ElementFinder.getElementByQualifiedName("SysML Extensions::SystemsReasoner::BehaviorOccurence", Application.getInstance().getProject()); - Profile sysml = StereotypesHelper.getProfile(Project.getProject(classifier), "SysML"); - Stereotype block = StereotypesHelper.getStereotype(Project.getProject(classifier), "Block", sysml); - - - com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class smc = createBlock(classifier, block, container); - regionCounter = 0; - for (Element oe : classifier.getOwnedElement()) { - - if (oe instanceof Region) { - Class reg = createBlock((Region) oe, block, smc); - stateCounter = 0; - stateProps = new HashMap(); - - for (Transition t : ((Region) oe).getTransition()) { - // createStepFromTo(stateProps.get(t.getSource()), stateProps.get(t.getTarget()), statemap.get(t.getSource())); - } - } - else if (oe instanceof StateMachine) { - Class reg = createBlock((StateMachine) oe, block, smc); - } - else if (oe instanceof Action) { - Class reg = createBlock((Action) oe, block, smc); - - // createProperty((Action) oe, smc); - } - } - // final Classifier specific = (Classifier) CopyPasting.copyPasteElement(classifier, (Namespace) dlg.getSelectedElement(), true); - // for (final Generalization generalization : Lists.newArrayList(specific.getGeneralization())) { - // generalization.dispose(); - // } - // for (final NamedElement ne : Lists.newArrayList(specific.getOwnedMember())) { - // ne.dispose(); - // } - - SessionManager.getInstance().closeSession(); - - // ValidateAction.validate(specific); - } - } - } - - private Object createProperty(Action oe, Class smc) { - Property prop = Project.getProject(classifier).getElementsFactory().createPropertyInstance(); - - return null; - } - - private void createStepFromTo(Property from, Property to, Class fromClass) { - if (from != null && to != null && fromClass != null) { - if (fromClass.getOwner() instanceof Class) { - Class containerClass = (Class) fromClass.getOwner(); - Connector c = Project.getProject(classifier).getElementsFactory().createConnectorInstance(); - ConnectorEnd cf = Project.getProject(classifier).getElementsFactory().createConnectorEndInstance(); - ConnectorEnd ct = Project.getProject(classifier).getElementsFactory().createConnectorEndInstance(); - cf.setRole(from); - ct.setRole(to); - cf.setOwner(c); - ct.setOwner(c); - - c.getEnd().add(cf); - c.getEnd().add(ct); - c.setOwner(containerClass); - } - - } - } - - private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class createBlock(NamedElement bo, Stereotype block, Namespace container) { - com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class smc = Project.getProject(classifier).getElementsFactory().createClassInstance(); - StereotypesHelper.addStereotype(smc, block); - - container.getOwnedElement().add(smc); - String[] end = bo.getClassType().toString().split("\\."); - String name = end[end.length - 1]; - smc.setName(bo.getName() + "_" + name); - - - Utils.createGeneralization(behaviorOccurence, smc); - - if (container instanceof Classifier) { - Property p = Project.getProject(classifier).getElementsFactory().createPropertyInstance(); - p.setOwner(container); - p.setType(smc); - if (bo instanceof State) { - p.setName("state" + stateCounter++); - stateProps.put((State) bo, p); - } - else if (bo instanceof Region) { - p.setName("region" + regionCounter++); - } - else if (bo instanceof Action) { - p.setName("action" + regionCounter++); - } - ((Classifier) container).getFeature().add(p); - } - return smc; - } - -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateSlotsAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateSlotsAction.java deleted file mode 100644 index 220652955..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateSlotsAction.java +++ /dev/null @@ -1,250 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.annotation.Annotation; -import com.nomagic.magicdraw.copypaste.CopyPasting; -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 java.util.*; - -public class CreateSlotsAction extends GenericRuleViolationAction { - - /** - * ADD CIRCULAR REFERENCE DETECTION - */ - private static final long serialVersionUID = 1L; - private static final String DEFAULT_NAME = "Create Slots"; - - private InstanceSpecification instance; - private boolean recurse, deleteSlots, deleteChildInstances; - private String name; - - private ProgressStatus progressStatus; - - public CreateSlotsAction(final InstanceSpecification instance) { - this(instance, false, false, false); - } - - public CreateSlotsAction(final InstanceSpecification instance, final boolean recurse, final boolean deleteSlots, final boolean deleteChildInstances) { - this(instance, recurse, deleteSlots, deleteChildInstances, DEFAULT_NAME); - } - - public CreateSlotsAction(final InstanceSpecification instance, final boolean recurse, final boolean deleteSlots, final boolean deleteChildInstances, final String name) { - super(name); - this.instance = instance; - this.recurse = recurse; - this.deleteSlots = deleteSlots; - this.deleteChildInstances = deleteChildInstances; - this.name = name; - } - - public static List getChildInstancesRecursively(final Slot slot) { - final List instances = new ArrayList(); - for (final ValueSpecification vs : slot.getValue()) { - InstanceSpecification instance; - if (vs instanceof InstanceValue && (instance = ((InstanceValue) vs).getInstance()) != null) { - instances.add(instance); - for (final Slot childSlot : instance.getSlot()) { - instances.addAll(getChildInstancesRecursively(childSlot)); - } - } - } - return instances; - } - - public static List collectSlottableProperties(final Classifier classifier) { - final List properties = new ArrayList(); - properties.addAll(classifier.getAttribute()); - - for (final NamedElement inheritedMember : classifier.getInheritedMember()) { - boolean toAdd = true; - for (final Property property : properties) { - if (property.hasRedefinedElement() && property.getRedefinedElement().contains(inheritedMember)) { - toAdd = false; - break; - } - } - if (toAdd && inheritedMember instanceof Property) { - properties.add((Property) inheritedMember); - } - } - return properties; - } - - public static Map createSlots(final InstanceSpecification instance, final boolean recurse, final boolean deleteSlots, final boolean deleteChildInstances, final ProgressStatus progressStatus) { - if (progressStatus != null) { - progressStatus.setIndeterminate(true); - } - if (deleteSlots && instance.hasSlot()) { - for (final Slot slot : instance.getSlot()) { - if (deleteChildInstances) { - for (final InstanceSpecification is : getChildInstancesRecursively(slot)) { - is.dispose(); - } - } - } - for (final Slot slot : instance.getSlot()) { - slot.dispose(); - } - } - return createSlots(instance, recurse, new HashMap()); - } - - public static Map createSlots(final InstanceSpecification instance, final boolean recurse, final Map traveled) { - final Map propertySlotMapping = new HashMap(); - final Map implicitCache = new HashMap(); - - for (final Classifier classifier : instance.getClassifier()) { - int loop = 0; - final List properties = collectSlottableProperties(classifier); - for (final Slot slot : instance.getSlot()) { - if (slot.getDefiningFeature() != null) { - properties.remove(slot.getDefiningFeature()); - } - } - while (!properties.isEmpty() && loop++ < 100) { - //System.out.print("Loop: " + ++loop + " : " + properties.size() + " - "); - /*for (final Property property : properties) { - System.out.print(property.getQualifiedName() + ", "); - } - System.out.println();*/ - final ListIterator propertyIterator = properties.listIterator(); - while (propertyIterator.hasNext()) { - final Property property = propertyIterator.next(); - final List subsettingProperties = new ArrayList(); - if (property.has_propertyOfSubsettedProperty()) { - for (final Property subsettingProperty : property.get_propertyOfSubsettedProperty()) { - if (subsettingProperty.getClassifier() != null && subsettingProperty.getClassifier().equals(classifier)) { - subsettingProperties.add(subsettingProperty); - } - } - } - if (!subsettingProperties.isEmpty()) { - /*System.out.println("I AM SUBSETTED: " + property.getQualifiedName()); - for (final Property subsettingProperty : property.get_propertyOfSubsettedProperty()) { - System.out.println(subsettingProperty.getQualifiedName()); - }*/ - boolean missingDependency = false; - for (final Property subsettingProperty : subsettingProperties) { - if (!implicitCache.containsKey(subsettingProperty)) { - //System.out.println("Missing property! " + subsettingProperty.getQualifiedName() + " : " + property.getQualifiedName()); - missingDependency = true; - break; - } - } - if (missingDependency) { - /*System.out.println("Cache [" + implicitCache.size() + "]: "); - for (final Map.Entry entrySet : implicitCache.entrySet()) { - System.out.println("[" + entrySet.getKey().getQualifiedName() + "]=" + entrySet.getValue().getID()); - } - if (traveled.contains(property)) { - System.out.println("REMOVING " + property.getQualifiedName()); - propertyIterator.remove(); - } - System.out.println("CONTINUING " + property.getQualifiedName());*/ - continue; - } - final Slot slot = Application.getInstance().getProject().getElementsFactory().createSlotInstance(); - slot.setDefiningFeature(property); - for (final Property subsettingProperty : subsettingProperties) { - for (final ValueSpecification vs : implicitCache.get(subsettingProperty).getValue()) { - final ValueSpecification clonedValueSpec = (ValueSpecification) CopyPasting.copyPasteElement(vs, slot, false); - if (clonedValueSpec != null) { - slot.getValue().add(clonedValueSpec); - } - } - } - slot.setOwningInstance(instance); - } - //else if (classifier.getAttribute().contains(property)) { - else { - final Slot slot = createSlot(property, instance, recurse, traveled); - //System.out.println("Created " + slot.getDefiningFeature().getQualifiedName() + " [" + implicitCache.size() + "]"); - propertySlotMapping.put(property, slot); - implicitCache.put(property, slot); - for (final Property redefinedProperty : flattenRedefinedProperties(property)) { - implicitCache.put(redefinedProperty, slot); - } - //System.out.println("New Cache Size: " + implicitCache.size()); - } - propertyIterator.remove(); - - } - } - } - return propertySlotMapping; - } - - public static List flattenRedefinedProperties(final Property property) { - final List redefinedProperties = new ArrayList(); - for (final Property redefinedProperty : property.getRedefinedProperty()) { - redefinedProperties.addAll(flattenRedefinedProperties(redefinedProperty)); - } - return redefinedProperties; - } - - public static Slot createSlot(final Property property, final InstanceSpecification instance, final boolean recurse, final Map traveled) { - final Slot slot = Application.getInstance().getProject().getElementsFactory().createSlotInstance(); - slot.setDefiningFeature(property); - createValueSpecification(property, instance, slot, recurse, traveled); - slot.setOwningInstance(instance); - return slot; - } - - public static ValueSpecification createValueSpecification(final Property property, final InstanceSpecification instance, final Slot slot, final boolean recurse, final Map traveled) { - if (property.getDefaultValue() != null) { - final ValueSpecification clonedValue = (ValueSpecification) CopyPasting.copyPasteElement(property.getDefaultValue(), slot, false); - if (clonedValue == null) { - return null; - } - slot.getValue().add(clonedValue); - return clonedValue; - } - else if (property.getType() != null && property.getType() instanceof Classifier) { - //System.out.println("Nested Instance: " + property.getQualifiedName()); - final InstanceSpecification nestedInstance = CreateInstanceAction.createInstance(property, instance, recurse, traveled); - if (nestedInstance == null) { - //System.out.println("Nested instance is null."); - return null; - } - final InstanceValue instanceValue = Application.getInstance().getProject().getElementsFactory().createInstanceValueInstance(); - instanceValue.setInstance(nestedInstance); - instanceValue.setOwner(slot); - slot.getValue().add(instanceValue); - return instanceValue; - } - return null; - } - - @Override - public void run() { - if (!instance.isEditable()) { - Application.getInstance().getGUILog().log(instance.getQualifiedName() + " is not editable. Skipping slots creation."); - return; - } - createSlots(instance, recurse, deleteSlots, deleteChildInstances, progressStatus); - } - - public void actionPerformed(java.awt.event.ActionEvent e) { - super.actionPerformed(e); - ValidateAction.validate(instance); - } - - @Override - public void execute(Collection annotations) { - super.execute(annotations); - ValidateAction.validate(instance); - } - - @Override - public String getName() { - return name; - } - - @Override - public String getSessionName() { - return name; - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateSpecializedTypeAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateSpecializedTypeAction.java deleted file mode 100644 index 252095ea8..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/CreateSpecializedTypeAction.java +++ /dev/null @@ -1,182 +0,0 @@ -package gov.nasa.jpl.mbee.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; - -import java.lang.Class; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class CreateSpecializedTypeAction extends GenericRuleViolationAction { - - public static final List> UNSPECIALIZABLE_CLASSIFIERS = new ArrayList>(); - - static { - UNSPECIALIZABLE_CLASSIFIERS.add(DataType.class); - UNSPECIALIZABLE_CLASSIFIERS.add(PrimitiveType.class); - } - - private static final long serialVersionUID = 1L; - 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; - - - public CreateSpecializedTypeAction(final Property property, final Classifier parent, final String name, boolean isIndividual, boolean isRecursive) { - super(name); - this.property = property; - this.parent = parent; - this.name = name; - this.isIndividual = isIndividual; - this.isRecursive = isRecursive; - } - - 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 final boolean createSpecializedType(final StructuralFeature redefinedAttribute, final Classifier parent, final List traveled, List visited, boolean isIndividual, boolean isRecursive) { - if (!parent.isEditable()) { - Application.getInstance().getGUILog().log(parent.getQualifiedName() + " is not editable. Skipping creating specialization."); - return true; - } - if (redefinedAttribute.getType() instanceof Classifier && !(redefinedAttribute.getType() instanceof Property)) { - boolean hasTraveled = false; - if (traveled.contains(redefinedAttribute)) { - hasTraveled = true; - } - else { - for (final RedefinableElement redefinedProperty : redefinedAttribute.getRedefinedElement()) { - if (traveled.contains(redefinedProperty)) { - hasTraveled = true; - break; - } - } - } - if (hasTraveled) { - Application.getInstance().getGUILog().log("[WARNING] Detected circular reference at " + redefinedAttribute.getQualifiedName() + ". Stopping recursion."); - return false; - } - - traveled.add(redefinedAttribute); - traveled.addAll(redefinedAttribute.getRedefinedElement()); - - final Classifier general = (Classifier) redefinedAttribute.getType(); - Type special = null; - if (isIndividual || (isRecursive && getExistingSpecial(redefinedAttribute) == null)) { - SpecializeStructureAction speca = new SpecializeStructureAction(general, false, "", isRecursive, isIndividual); - special = speca.createSpecialClassifier(parent, new ArrayList<>(traveled), visited); - } - else if (getExistingSpecial(redefinedAttribute) != null) { - special = getExistingSpecial(redefinedAttribute); - } - else if (visited.contains(general)) { - Application.getInstance().getGUILog().log("[WARNING] Detected circular reference. Type " + general.getQualifiedName() + " referenced by " + redefinedAttribute.getQualifiedName() + " was already visited. Stopping recursion."); - return false; - } - - if (special == null) { - 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(); - 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()) { - if (oe instanceof Property) { - if (!oe.equals(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(); - } - } - } - } - } - } - - 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); - } - - @Override - public String getName() { - return name; - } - - @Override - public String getSessionName() { - return "create specialized classifier"; - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/ImportCSVAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/ImportCSVAction.java deleted file mode 100644 index 0104d3c5e..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/ImportCSVAction.java +++ /dev/null @@ -1,395 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import au.com.bytecode.opencsv.CSVReader; -import com.nomagic.actions.NMAction; -import com.nomagic.magicdraw.copypaste.CopyPasting; -import com.nomagic.magicdraw.core.Application; -import com.nomagic.magicdraw.core.GUILog; -import com.nomagic.magicdraw.core.Project; -import com.nomagic.magicdraw.openapi.uml.SessionManager; -import com.nomagic.magicdraw.ui.dialogs.MDDialogParentProvider; -import com.nomagic.magicdraw.ui.dialogs.SelectElementInfo; -import com.nomagic.magicdraw.ui.dialogs.SelectElementTypes; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlg; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlgFactory; -import com.nomagic.magicdraw.ui.dialogs.selection.SelectionMode; -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.systems_reasoner.validation.SRValidationSuite; -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 javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.*; -import java.util.List; - -public class ImportCSVAction extends SRAction { - public static final String DEFAULT_ID = "Import from CSV"; - - private static final String LITERAL_BOOLEAN_ID = "_16_5_1_12c903cb_1245415335546_39033_4086"; - private static final String LITERAL_INTEGER_ID = "_16_5_1_12c903cb_1245415335546_8641_4088"; - private static final String LITERAL_REAL_ID = "_11_5EAPbeta_be00301_1147431819399_50461_1671"; - private static final String LITERAL_STRING_ID = "_16_5_1_12c903cb_1245415335546_479030_4092"; - private static final char CSV_SEPARATOR = ','; - - private Classifier classifier; - private int row; - private Namespace container; - - public ImportCSVAction(Classifier classifier) { - super(DEFAULT_ID); - this.classifier = classifier; - } - - @Override - public void actionPerformed(ActionEvent arg0) { - final List> types = new ArrayList<>(); - types.add(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class); - types.add(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Package.class); - types.add(Model.class); - - - GUILog gl = Application.getInstance().getGUILog(); - row = 0; - JFileChooser choose = new JFileChooser(); - choose.setDialogTitle("Open CSV file"); - choose.setFileSelectionMode(JFileChooser.FILES_ONLY); - HashSet createdElements = new HashSet<>(); - int retval = choose.showOpenDialog(null); - if (retval == JFileChooser.APPROVE_OPTION) { - if (choose.getSelectedFile() != null) { - File savefile = choose.getSelectedFile(); - try { - - final Frame dialogParent = MDDialogParentProvider.getProvider().getDialogParent(); - final ElementSelectionDlg dlg = ElementSelectionDlgFactory.create(dialogParent); - dlg.setTitle("Select container for generated elements:"); - final SelectElementTypes set = new SelectElementTypes(null, types, null, null); - final SelectElementInfo sei = new SelectElementInfo(true, false, Application.getInstance().getProject().getModel().getOwner(), true); - ElementSelectionDlgFactory.initSingle(dlg, set, sei, classifier.getOwner()); - dlg.setSelectionMode(SelectionMode.SINGLE_MODE); - dlg.setVisible(true); - if (dlg.isOkClicked() && dlg.getSelectedElement() != null && dlg.getSelectedElement() instanceof Namespace) { - container = (Namespace) dlg.getSelectedElement(); - SessionManager.getInstance().createSession("change"); - gl.log("[INFO] Starting CSV import."); - CSVReader reader = new CSVReader(new FileReader(savefile), CSV_SEPARATOR); - importFromCsv(reader, createdElements); - checkForRedefinedElements(createdElements); - reader.close(); - SessionManager.getInstance().closeSession(); - checkForAssociationInheritance(createdElements); - gl.log("[INFO] CSV import finished."); - } - } catch (IOException ex) { - gl.log("[ERROR] CSV import failed. Reason: " + ex.getMessage()); - SessionManager.getInstance().cancelSession(); - ex.printStackTrace(); - for (StackTraceElement s : ex.getStackTrace()) { - gl.log("\t" + s.toString()); - } - } - } - } - } - - - private void checkForAssociationInheritance(HashSet createdElements) { - - for (Classifier element : createdElements) { - for (Classifier general : element.getGeneral()) { - SRValidationSuite.checkAssociationsForInheritance(element, general); - ValidationRule ele = SRValidationSuite.getAssociationInheritanceRule(); - for (ValidationRuleViolation violation : ele.getViolations()) { - NMAction action = violation.getActions().get(0); - action.actionPerformed(null); - } - } - } - - } - - private void checkForRedefinedElements(HashSet createdElements) { - for (Classifier ns : createdElements) { - for (NamedElement mem : ns.getInheritedMember()) { - if (mem instanceof RedefinableElement) { - boolean redefined = false; - for (NamedElement om : ns.getOwnedMember()) { - if (om instanceof RedefinableElement) { - if (SRValidationSuite.doesEventuallyRedefine(((RedefinableElement) om), (RedefinableElement) mem)) { - redefined = true; - } - } - } - if (!redefined) { - SetOrCreateRedefinableElementAction action = new SetOrCreateRedefinableElementAction(ns, (RedefinableElement) mem, false); - action.run(); - } - } - } - } - } - - private void importFromCsv(CSVReader reader, HashSet createdElements) throws IOException { - String[] line = reader.readNext(); // ignore header - - String selectedClassifierName = classifier.getName(); - List sortedColumns = new ArrayList<>(); - boolean isFirstLine = true; - boolean lineWasEmpty = true; - int elementName = -1; - HashMap thisLinesClasses = new HashMap<>(); - while (line != null) { - if (!emptyLine(line)) { - HashMap previousLinesClasses = thisLinesClasses; - thisLinesClasses = new HashMap<>(); - if (!isFirstLine) { - for (int jj = 0; jj < sortedColumns.size(); jj++) { - String valueFromCSV = line[jj].trim(); - Element el = sortedColumns.get(jj); - if (el != null) { - if (el instanceof Property) { - Classifier child; - Type type = ((Property) el).getType(); - if (!(type instanceof DataType)) { - if (!valueFromCSV.isEmpty()) { - if (type instanceof Classifier) { - child = createNewSubElement(line, jj, (Classifier) type); - thisLinesClasses.put((Property) el, child); - } - } - else { - thisLinesClasses.put((Property) el, previousLinesClasses.get(el)); - } - } - if (!valueFromCSV.isEmpty()) { - setPropertyValue(valueFromCSV, (RedefinableElement) el, thisLinesClasses); - } - } - } - else { - if (sortedColumns.get(jj) == null) { - if (!line[jj].isEmpty()) { - Classifier topClass = (Classifier) CopyPasting.copyPasteElement(classifier, container, true); - if (topClass == null) { - continue; - } - topClass.getOwnedMember().clear(); - topClass.getGeneralization().clear(); - Utils.createGeneralization(classifier, topClass); - topClass.setName(line[jj]); - thisLinesClasses.put(null, topClass); - Application.getInstance().getGUILog().log("[INFO] Creating new " + classifier.getName() + " named " + topClass.getName() + " for line " + row + "."); - } - else { - if (jj == elementName) { - thisLinesClasses.put(null, previousLinesClasses.get(null)); - } - } - } - } - } - - } - else { - for (int c = 0; c < line.length; c++) { - String propertyName = line[c]; - if (!propertyName.isEmpty()) { - if (propertyName.contains(".")) { - propertyName = handleSubProperty(sortedColumns, propertyName, classifier); - } - else { - lineWasEmpty = false; - sortedColumns.add(getPropertyFromColumnName(propertyName, classifier)); - if (propertyName.equals(selectedClassifierName)) { - elementName = c; - } - } - } - else { - if (elementName == -1) {// only set it the first time. - elementName = c; - } - sortedColumns.add(null); - } - } - } - if (!lineWasEmpty) { - isFirstLine = false; - } - createdElements.addAll(thisLinesClasses.values()); - - } - line = reader.readNext(); - row++; - } - } - - private boolean emptyLine(String[] line) { - for (String s : line) { - if (!s.trim().isEmpty()) { - return false; - } - } - return true; - } - - private String handleSubProperty(List sortedColumns, String propertyName, Classifier parent) { - String[] subprops = propertyName.split("\\."); - propertyName = propertyName.replace(subprops[0] + ".", ""); - String newTypeName = subprops[0]; - Element property = getPropertyFromColumnName(newTypeName, parent); - if (property instanceof TypedElement) { - Type type = ((TypedElement) property).getType(); - if (type instanceof Classifier) { - if (propertyName.contains(".")) { - handleSubProperty(sortedColumns, propertyName, (Classifier) type); - } - else { - sortedColumns.add(getPropertyFromColumnName(propertyName, (Classifier) type)); - } - } - } - return propertyName; - } - - private Classifier createNewSubElement(String[] line, int index, Classifier generalClassifier) { - Classifier createdClassifier = (Classifier) CopyPasting.copyPasteElement(generalClassifier, container, true); - if (createdClassifier == null) { - return null; - } - createdClassifier.getOwnedMember().clear(); - createdClassifier.getGeneralization().clear(); - Utils.createGeneralization(generalClassifier, createdClassifier); - createdClassifier.setName(line[index]); - Application.getInstance().getGUILog().log("[INFO] Creating new " + generalClassifier.getName() + " named " + createdClassifier.getName() + " for line " + row + "."); - return createdClassifier; - } - - private void setPropertyValue(String valueFromCSV, RedefinableElement el, HashMap thisLinesClasses) { - if (el instanceof TypedElement) { - if (el.getOwner() instanceof Classifier) { - Classifier owner = findMatchingSubclass((Classifier) el.getOwner(), thisLinesClasses.values()); - if (owner != null) { - Property prop = UMLFactory.eINSTANCE.createProperty(); - prop.setType(((TypedElement) el).getType()); - prop.getRedefinedElement().add(el); - prop.setOwner(owner); - prop.setName(el.getName()); - ValueSpecification vs = null; - Classifier linkedElement = null; - if (((TypedElement) el).getType() instanceof Classifier) { - linkedElement = findMatchingSubclass((Classifier) ((TypedElement) el).getType(), thisLinesClasses.values()); - } - if (linkedElement == null) { - if (((Property) el).getType() instanceof DataType) { - if (!valueFromCSV.isEmpty()) { - try { - switch (Converters.getElementToIdConverter().apply(((Property) el).getType())) { - case LITERAL_STRING_ID: - LiteralString literalString = UMLFactory.eINSTANCE.createLiteralString(); - literalString.setValue(valueFromCSV); - vs = literalString; - break; - case LITERAL_REAL_ID: - LiteralReal literalReal = UMLFactory.eINSTANCE.createLiteralReal(); - literalReal.setValue(Double.parseDouble(valueFromCSV)); - vs = literalReal; - break; - case LITERAL_INTEGER_ID: - LiteralInteger literalInteger = UMLFactory.eINSTANCE.createLiteralInteger(); - literalInteger.setValue(Integer.parseInt(valueFromCSV)); - vs = literalInteger; - break; - case LITERAL_BOOLEAN_ID: - LiteralBoolean literalBoolean = UMLFactory.eINSTANCE.createLiteralBoolean(); - literalBoolean.setValue(Boolean.parseBoolean(valueFromCSV)); - vs = literalBoolean; - break; - } - } catch (NumberFormatException nf) { - Application.getInstance().getGUILog().log("[WARNING] Value in line " + row + " for property " + el.getName() + " not correct. Reason: " + nf.getMessage()); - nf.printStackTrace(); - } - } - } - if (vs != null) { - prop.setDefaultValue(vs); - } - } - else { - prop.setType(linkedElement); - if (el instanceof Property) { - if (((Property) el).getAssociation() != null) { - SetOrCreateRedefinableElementAction.createInheritingAssociation((Property) el, owner, prop); - } - } - } - } - else { - Application.getInstance().getGUILog().log("[WARNING] Property for " + el.getName() + " not created."); - - } - } - } - - } - - private Classifier findMatchingSubclass(Classifier general, Collection thisLinesClasses) { - for (Classifier cl : thisLinesClasses) { - if (cl != null) { - if (cl.getGeneral().contains(general)) { - return cl; - } - } - } - return null; - } - - /** - * Selects in order owned elements, inherited elements and then ignores case. - * - * @param propertyName - */ - private Element getPropertyFromColumnName(String propertyName, Classifier classifier) { - for (Element p : classifier.getOwnedMember()) { - if (p instanceof NamedElement) { - if (propertyName.trim().equals(((NamedElement) p).getName())) { - return p; - } - } - } - for (Element p : classifier.getInheritedMember()) { - if (p instanceof NamedElement) { - if (propertyName.trim().equals(((NamedElement) p).getName())) { - return p; - - } - } - } - for (Element p : classifier.getOwnedMember()) { - if (p instanceof NamedElement) { - if (propertyName.trim().equalsIgnoreCase(((NamedElement) p).getName())) { - return p; - - } - } - } - for (Element p : classifier.getInheritedMember()) { - if (p instanceof NamedElement) { - if (propertyName.trim().equalsIgnoreCase(((NamedElement) p).getName())) { - return p; - } - } - } - return null; - } -} \ No newline at end of file diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/Instance2BSTAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/Instance2BSTAction.java deleted file mode 100644 index 25c69f655..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/Instance2BSTAction.java +++ /dev/null @@ -1,124 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.copypaste.CopyPasting; -import com.nomagic.magicdraw.core.Application; -import com.nomagic.magicdraw.openapi.uml.SessionManager; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.*; - -import java.awt.event.ActionEvent; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class Instance2BSTAction extends SRAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public static final String DEFAULT_ID = "Convert Instance to BST"; - public List instances; - - - public Instance2BSTAction(List instances) { - super(DEFAULT_ID); - this.instances = instances; - } - - @Override - public void actionPerformed(ActionEvent e) { - SessionManager.getInstance().createSession(DEFAULT_ID); - for (final InstanceSpecification instance : instances) { - if (!instance.hasClassifier()) { - Application.getInstance().getGUILog().log("Instance " + instance.getQualifiedName() + " has no classifiers. Skipping BST conversion."); - continue; - } - instance2BST(instance); - } - SessionManager.getInstance().closeSession(); - } - - public static Classifier instance2BST(final InstanceSpecification instance) { - return instance2BST(instance, null, null, new HashMap()); - } - - public static Classifier instance2BST(final InstanceSpecification instance, final InstanceSpecification lastInstance, final Element owner, final Map traveled) { - if (traveled.containsKey(instance)) { - //Application.getInstance().getGUILog().log("Detected circular reference: " + instance.getQualifiedName() + ". Skipping conversion."); - return traveled.get(instance); - } - //System.out.println("Traveled to " + instance.getQualifiedName()); - //traveled.put(instance); - - final Classifier classifier = instance.getClassifier().get(0); - final Classifier specific = (Classifier) CopyPasting.copyPasteElement(classifier, instance.getOwner(), true); - if (specific == null) { - return null; - } - for (final Generalization generalization : specific.getGeneralization()) { - generalization.dispose(); - } - for (final NamedElement ne : specific.getOwnedMember()) { - ne.dispose(); - } - - for (final Classifier c : instance.getClassifier()) { - SpecializeClassifierAction.specialize(specific, c); - } - if (owner != null && owner.canAdd(specific)) { - specific.setOwner(owner); - } - traveled.put(instance, specific); - - specific.setName(lastInstance != null && instance.getName().startsWith(lastInstance.getName() + ".") ? instance.getName().replaceFirst(lastInstance.getName() + ".", "") : instance.getName()); - specific.setName(specific.getName().substring(0, 1).toUpperCase() + specific.getName().substring(1, specific.getName().length())); - for (final Slot slot : instance.getSlot()) { - if (slot.getDefiningFeature() instanceof Property) { - final Property property = (Property) slot.getDefiningFeature(); - final Property redefinedAttribute = (Property) SetOrCreateRedefinableElementAction.redefineRedefinableElement(specific, property, true, false); - - if (!slot.hasValue()) { - continue; - } - if (slot.getValue().size() == 1) { - final ValueSpecification value = slot.getValue().get(0); - processAttribute(redefinedAttribute, value, instance, specific, traveled); - //Application.getInstance().getGUILog().log("Slot " + slot.getOwningInstance().getQualifiedName() + "::" + slot.getDefiningFeature().getName() + " has more than one value. Only applying the first to converted BST default value."); - } - else { - for (final ValueSpecification value : slot.getValue()) { - final Property subsettingProperty = Application.getInstance().getProject().getElementsFactory().createPropertyInstance(); - subsettingProperty.setOwner(specific); - processAttribute(subsettingProperty, value, instance, specific, traveled); - if (subsettingProperty.getType() != null && subsettingProperty.getType() instanceof Classifier) { - final String name = subsettingProperty.getType().getName(); - subsettingProperty.setName((name.substring(0, 1).toLowerCase() + name.substring(1, name.length())).replaceAll(" ", "")); - } - subsettingProperty.getSubsettedProperty().add(redefinedAttribute); - } - } - } - } - return specific; - } - - public static void processAttribute(final Property property, final ValueSpecification value, final InstanceSpecification lastInstance, final Element owner, final Map traveled) { - //final ValueSpecification value = slot.getValue().get(0); - if (value instanceof InstanceValue && ((InstanceValue) value).getInstance() != null) { - final Classifier nestedClassifier = instance2BST(((InstanceValue) value).getInstance(), lastInstance, owner, traveled); - property.setType(nestedClassifier); - } - else if (value instanceof ElementValue && ((ElementValue) value).getElement() instanceof Classifier) { - property.setType((Classifier) ((ElementValue) value).getElement()); - } - else { - final ValueSpecification defaultValue = (ValueSpecification) CopyPasting.copyPasteElement(value, null, false); - if (defaultValue == null) { - return; - } - property.setDefaultValue(defaultValue); - } - } - -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/OpenSpecificationAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/OpenSpecificationAction.java deleted file mode 100644 index 09e16971f..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/OpenSpecificationAction.java +++ /dev/null @@ -1,36 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -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; - -public class OpenSpecificationAction extends GenericRuleViolationAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - private static final String DEFAULT_NAME = "Specification"; - - private Element element; - - public OpenSpecificationAction(final Element element) { - super(DEFAULT_NAME); - this.element = element; - } - - @Override - public void run() { - SpecificationDialogManager.getManager().editSpecification(element); - } - - @Override - public String getName() { - return DEFAULT_NAME; - } - - @Override - public String getSessionName() { - return DEFAULT_NAME; - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/RenameElementAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/RenameElementAction.java deleted file mode 100644 index 888883066..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/RenameElementAction.java +++ /dev/null @@ -1,42 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.core.Application; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; - -public class RenameElementAction extends GenericRuleViolationAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - - private NamedElement source, target; - private String name; - - public RenameElementAction(final NamedElement source, final NamedElement target, final String name) { - super(name); - this.source = source; - this.target = target; - this.name = name; - } - - @Override - public void run() { - if (!target.isEditable()) { - Application.getInstance().getGUILog().log(target.getQualifiedName() + " is not editable. Skipping rename."); - return; - } - target.setName(source.getName()); - } - - @Override - public String getName() { - return name; - } - - @Override - public String getSessionName() { - return "rename element"; - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/RetypeElementAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/RetypeElementAction.java deleted file mode 100644 index 572164e78..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/RetypeElementAction.java +++ /dev/null @@ -1,42 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.core.Application; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.TypedElement; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; - -public class RetypeElementAction extends GenericRuleViolationAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - - private TypedElement source, target; - private String name; - - public RetypeElementAction(final TypedElement source, final TypedElement target, final String name) { - super(name); - this.source = source; - this.target = target; - this.name = name; - } - - @Override - public void run() { - if (!target.isEditable()) { - Application.getInstance().getGUILog().log(target.getQualifiedName() + " is not editable. Skipping retype."); - return; - } - target.setType(source.getType()); - } - - @Override - public String getName() { - return name; - } - - @Override - public String getSessionName() { - return "retype element"; - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SRAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SRAction.java deleted file mode 100644 index 5691c28d9..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SRAction.java +++ /dev/null @@ -1,43 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.actions.ActionsGroups; -import com.nomagic.magicdraw.actions.MDAction; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; - -public class SRAction extends MDAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - private String DEFAULT_ID; - public Element element; - - public SRAction(String DEFAULT_ID) { - super(DEFAULT_ID, DEFAULT_ID, null, ActionsGroups.APPLICATION_RELATED); - this.DEFAULT_ID = DEFAULT_ID; - } - - public SRAction(String DEFAULT_ID, Element element) { - this(DEFAULT_ID); - this.element = element; - } - - public void disable() { - setEnabled(false); - } - - public void disable(String error) { - this.setName(DEFAULT_ID + " [" + error + "]"); - disable(); - } - - public void enable() { - setEnabled(true); - } - - @Override - public void updateState() { - } - -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SelectInContainmentTreeAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SelectInContainmentTreeAction.java deleted file mode 100644 index bdc4cd6df..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SelectInContainmentTreeAction.java +++ /dev/null @@ -1,36 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.core.Application; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; - -public class SelectInContainmentTreeAction extends GenericRuleViolationAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - private static final String DEFAULT_NAME = "Select in Containment Tree"; - - private Element element; - - public SelectInContainmentTreeAction(final Element element) { - super(DEFAULT_NAME); - this.element = element; - } - - @Override - public void run() { - Application.getInstance().getMainFrame().getBrowser().getContainmentTree().openNode(element); - } - - @Override - public String getName() { - return DEFAULT_NAME; - } - - @Override - public String getSessionName() { - return DEFAULT_NAME; - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SetOrCreateRedefinableElementAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SetOrCreateRedefinableElementAction.java deleted file mode 100644 index ad93adf89..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SetOrCreateRedefinableElementAction.java +++ /dev/null @@ -1,208 +0,0 @@ -package gov.nasa.jpl.mbee.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.systems_reasoner.validation.SRValidationSuite; -import gov.nasa.jpl.mbee.mdk.util.Utils; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; - -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/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SetRedefinitionAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SetRedefinitionAction.java deleted file mode 100644 index e39df0c76..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SetRedefinitionAction.java +++ /dev/null @@ -1,43 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.core.Application; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.RedefinableElement; -import gov.nasa.jpl.mbee.mdk.validation.GenericRuleViolationAction; - -public class SetRedefinitionAction extends GenericRuleViolationAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - - private RedefinableElement redefiningElement, redefinedElement; - private String name; - - public SetRedefinitionAction(final RedefinableElement redefiningElement, final RedefinableElement redefinedElement, String name) { - super(name); - this.redefiningElement = redefiningElement; - this.redefinedElement = redefinedElement; - this.name = name; - } - - @Override - public void run() { - if (!redefiningElement.isEditable()) { - Application.getInstance().getGUILog().log(redefiningElement.getQualifiedName() + " is not editable. Skipping set redefinition."); - return; - } - redefiningElement.getRedefinedElement().add(redefinedElement); - } - - @Override - public String getName() { - return name; - } - - @Override - public String getSessionName() { - return "set redefinition"; - } - -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SpecializeClassifierAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SpecializeClassifierAction.java deleted file mode 100644 index 26c733fc3..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SpecializeClassifierAction.java +++ /dev/null @@ -1,51 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -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; - -public class SpecializeClassifierAction extends GenericRuleViolationAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - private static final String DEFAULT_NAME = "Specialize Classifier"; - - private Classifier specific, general; - - public SpecializeClassifierAction(final Classifier specific, final Classifier general) { - super(DEFAULT_NAME); - this.specific = specific; - this.general = general; - } - - public static final Generalization specialize(final Classifier specific, final Classifier general) { - final Generalization generalization = Application.getInstance().getProject().getElementsFactory().createGeneralizationInstance(); - generalization.setSpecific(specific); - generalization.setGeneral(general); - generalization.setOwner(specific); - // special.getGeneral().add(general); - return generalization; - } - - @Override - public void run() { - if (!specific.isEditable()) { - Application.getInstance().getGUILog().log(specific.getQualifiedName() + " is not editable. Skipping specialization."); - return; - } - SpecializeClassifierAction.specialize(specific, general); - } - - @Override - public String getName() { - return DEFAULT_NAME; - } - - @Override - public String getSessionName() { - return "specialize classifier"; - } -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SpecializeStructureAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SpecializeStructureAction.java deleted file mode 100644 index 7e8dce70d..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SpecializeStructureAction.java +++ /dev/null @@ -1,213 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.copypaste.CopyPasting; -import com.nomagic.magicdraw.core.Application; -import com.nomagic.magicdraw.openapi.uml.SessionManager; -import com.nomagic.magicdraw.ui.dialogs.MDDialogParentProvider; -import com.nomagic.magicdraw.ui.dialogs.SelectElementInfo; -import com.nomagic.magicdraw.ui.dialogs.SelectElementTypes; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlg; -import com.nomagic.magicdraw.ui.dialogs.selection.ElementSelectionDlgFactory; -import com.nomagic.magicdraw.ui.dialogs.selection.SelectionMode; -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 java.awt.*; -import java.awt.event.ActionEvent; -import java.lang.Class; -import java.util.*; -import java.util.List; - -public class SpecializeStructureAction extends SRAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - public static final List> UNSPECIALIZABLE_CLASSIFIERS = new ArrayList>(); - - static { - UNSPECIALIZABLE_CLASSIFIERS.add(DataType.class); - UNSPECIALIZABLE_CLASSIFIERS.add(PrimitiveType.class); - } - - private final boolean isRecursive; - private final boolean individualMode; - private Classifier classifier; - private ArrayList recursionList; - private boolean isValidationMode = false; - - public SpecializeStructureAction(final Classifier classifier, boolean isValidationMode, String id, boolean isRecursive, boolean isIndividual) { - super(id, classifier); - this.classifier = classifier; - recursionList = new ArrayList<>(); - this.isValidationMode = isValidationMode; - this.isRecursive = isRecursive; - this.individualMode = isIndividual; - } - - - @Override - public void actionPerformed(ActionEvent e) { - final List> types = new ArrayList<>(); - types.add(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class); - types.add(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Package.class); - types.add(Model.class); - - final Frame dialogParent = MDDialogParentProvider.getProvider().getDialogParent(); - final ElementSelectionDlg dlg = ElementSelectionDlgFactory.create(dialogParent); - dlg.setTitle("Select container for generated elements:"); - final SelectElementTypes set = new SelectElementTypes(null, types, null, null); - final SelectElementInfo sei = new SelectElementInfo(true, false, Application.getInstance().getProject().getModel().getOwner(), true); - ElementSelectionDlgFactory.initSingle(dlg, set, sei, classifier.getOwner()); - - - dlg.setSelectionMode(SelectionMode.SINGLE_MODE); - if (!isValidationMode) { - dlg.setVisible(true); - } - if (isValidationMode || dlg.isOkClicked() && dlg.getSelectedElement() != null && dlg.getSelectedElement() instanceof Namespace) { - SessionManager.getInstance().createSession("Create BST"); - Namespace container; - if (isValidationMode) { - container = (Namespace) classifier.getOwner(); - } - else { - container = (Namespace) dlg.getSelectedElement(); - } - - Classifier specific = createSpecialClassifier(container, new ArrayList(), new ArrayList()); - SessionManager.getInstance().closeSession(); - - checkAssociationsForInheritance(specific, classifier); - } - } - - public Classifier createSpecialClassifier(Namespace container, List traveled, List visited) { - - for (final Class c : UNSPECIALIZABLE_CLASSIFIERS) { - if (c.isAssignableFrom(classifier.getClass())) { -// Application.getInstance().getGUILog() -// .log("[WARNING] " + (structuralFeature != null ? structuralFeature.getQualifiedName() : "< >") + " is a " + c.getSimpleName() + ", which is not specializable."); - return null; - } - } - - Classifier specific = (Classifier) CopyPasting.copyPasteElement(classifier, container, true); - if (specific == null) { - Application.getInstance().getGUILog().log("[ERROR] Failed to create specialized classifier for " + Converters.getElementToHumanNameConverter().apply(classifier) + " in " + Converters.getElementToHumanNameConverter().apply(container) + ". Aborting specialization."); - return null; - } - visited.add(specific); - visited.add(classifier); - specific.getGeneralization().clear(); - ArrayList redefinedElements = new ArrayList<>(); - for (NamedElement namedElement : specific.getOwnedMember()) { - if (namedElement instanceof RedefinableElement && !((RedefinableElement) namedElement).isLeaf()) { - redefinedElements.add((RedefinableElement) namedElement); - ((RedefinableElement) namedElement).getRedefinedElement().clear(); - } - } - Utils.createGeneralization(classifier, specific); - - Set members = new HashSet<>(specific.getInheritedMember());// - //ClassifierHelper.collectInheritedAttributes(specific ,listOfAllMembers, false, true); - List removeElements = new ArrayList<>(); - for (NamedElement member : members) { - if (member instanceof RedefinableElement) { - Collection redefinedBy = ((RedefinableElement) member).getRedefinedElement(); - removeElements.addAll(redefinedBy); - } - else { - removeElements.add(member); - } - } - members.removeAll(removeElements); - - for (final 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); - } - } - for (RedefinableElement redefinedElement : redefinedElements) { - redefinedElement.dispose(); - } - return specific; - } - - - private void deleteDiagrams(Namespace specific, ArrayList diagrams) { - for (NamedElement ne : specific.getOwnedMember()) { - if (ne instanceof Diagram) { - diagrams.add((Diagram) ne); - } - else if (ne instanceof Namespace) { - for (NamedElement nam : ((Namespace) ne).getOwnedMember()) { - deleteDiagrams((Namespace) nam, diagrams); - } - } - } - } - - - private void checkAssociationsForInheritance(Classifier classifier, Classifier general) { - if (classifier == null) { - return; - } - 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(); - if (partType != null) { - if (partType.equals(superPartType)) { - if (hasAnAssociation(superChild)) { - if (hasInheritanceFromTo(((Property) child).getAssociation(), ((Property) superChild).getAssociation())) { - break assocRule; - } - else { - AddInheritanceToAssociationAction action = new AddInheritanceToAssociationAction(((Property) child).getAssociation(), ((Property) superChild).getAssociation()); - action.actionPerformed(null); - } - } - } - else if (partType instanceof Classifier) { - if (((Classifier) partType).getGeneral().contains(superPartType)) { - if (hasInheritanceFromTo(((Property) child).getAssociation(), ((Property) superChild).getAssociation())) { - break assocRule; - } - else { - AddInheritanceToAssociationAction action = new AddInheritanceToAssociationAction(((Property) child).getAssociation(), ((Property) superChild).getAssociation()); - action.actionPerformed(null); - } - } - } - } - } - } - } - } - } - - private boolean hasAnAssociation(Element superChild) { - return ((Property) superChild).getAssociation() != null; - - } - - private boolean hasInheritanceFromTo(Classifier classifier, Classifier general) { - if (classifier != null) { - return ModelHelper.getGeneralClassifiersRecursivelly(classifier).contains(general); - } - else { - return false; - } - } - -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SubsetRedefinedProperty.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SubsetRedefinedProperty.java deleted file mode 100644 index 0cd396f0f..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/SubsetRedefinedProperty.java +++ /dev/null @@ -1,47 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.InstanceSpecification; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.RedefinableElement; - -import javax.annotation.CheckForNull; -import java.awt.event.ActionEvent; -import java.util.List; - -/** - * Created by johannes on 3/15/17. - */ -public class SubsetRedefinedProperty extends SRAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public static final String DEFAULT_ID = "Set subsetted property in redefining property."; - private final Property redefinedElement; - private final Property redefiningElement; - public List instances; - - - public SubsetRedefinedProperty(Property redefEl, Property redefingEl) { - super(DEFAULT_ID); - this.redefinedElement = redefEl; - this.redefiningElement = redefingEl; - - } - - @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); - } - } - } - } - } -} \ No newline at end of file diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/ValidateAction.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/ValidateAction.java deleted file mode 100644 index 336487785..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/actions/ValidateAction.java +++ /dev/null @@ -1,68 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.actions; - -import com.nomagic.magicdraw.core.Application; -import com.nomagic.magicdraw.core.Project; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element; -import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.InstanceSpecification; -import gov.nasa.jpl.mbee.mdk.systems_reasoner.validation.SRValidationSuite; -import gov.nasa.jpl.mbee.mdk.util.Utils; -import gov.nasa.jpl.mbee.mdk.util.Utils2; - -import java.awt.event.ActionEvent; -import java.util.ArrayList; -import java.util.List; - -public class ValidateAction extends SRAction { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public static final String DEFAULT_ID = "Validate"; - public List elements; - - public ValidateAction(Element element) { - this(Utils2.newList(element)); - } - - public ValidateAction(List elements) { - super(DEFAULT_ID); - this.elements = elements; - } - - - public static void validate(final List elements) { - final List elems = new ArrayList<>(); - elems.addAll(elements); - final SRValidationSuite svs = new SRValidationSuite(elems); - svs.run(); - Utils.displayValidationWindow(Application.getInstance().getProject(), svs, "Systems Reasoner Validation"); - /*for (final Generalization g : clazz.getGeneralization()) { - if (g.getGeneral() != null) - System.out.println(g.getGeneral()); - if (g.getGeneral() instanceof Class) { - System.out.println(((Class) g.getGeneral()).getName()); - } - }*/ - - //ProgressStatusRunner.runWithProgressStatus(new ValidateModelRunner(start), "Validating Model", true, 0); - - /*if (!ExportUtility.checkBaseline()) { - return; - } - ProgressStatusRunner.runWithProgressStatus(new ValidateModelRunner(start), "Validating Model", true, 0);*/ - } - - @Override - public void actionPerformed(ActionEvent e) { - validate(elements); - } - - public static void validate(InstanceSpecification instance) { - ArrayList insts = new ArrayList(); - insts.add(instance); - validate(insts); - } - -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/api/SRConstants.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/api/SRConstants.java deleted file mode 100644 index 3e79bdbb4..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/api/SRConstants.java +++ /dev/null @@ -1,5 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.api; - -public class SRConstants { - public static final String ASPECT_STEREOTYPE_ID = "_18_0_2_407019f_1449688347122_736579_14412"; -} diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/validation/SRValidationSuite.java b/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/validation/SRValidationSuite.java deleted file mode 100644 index fa1cf3bd6..000000000 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/systems_reasoner/validation/SRValidationSuite.java +++ /dev/null @@ -1,371 +0,0 @@ -package gov.nasa.jpl.mbee.mdk.systems_reasoner.validation; - -import com.nomagic.uml2.ext.jmi.helpers.ModelHelper; -import com.nomagic.uml2.ext.jmi.helpers.StereotypesHelper; -import com.nomagic.uml2.ext.magicdraw.actions.mdbasicactions.CallBehaviorAction; -import com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency; -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.systems_reasoner.actions.*; -import gov.nasa.jpl.mbee.mdk.validation.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; - -public class SRValidationSuite extends ValidationSuite implements Runnable { - - private static final String NAME = "SR Validate"; - private List elements; - - private static final ValidationRule generalMissingRule = new ValidationRule("Missing General", "General is missing in generalization", ViolationSeverity.ERROR); - private static final ValidationRule generalNotClassRule = new ValidationRule("General Not Class", "General is not of type class", ViolationSeverity.ERROR); - 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 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// orphanAttributeRule = new ValidationRule("Potential Orphan", "First degree attribute is never redefined", ViolationSeverity.WARNING); - 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; - } - - 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); - - { - this.addValidationRule(generalMissingRule); - this.addValidationRule(generalNotClassRule); - this.addValidationRule(attributeMissingRule); - this.addValidationRule(aspectMissingRule); - this.addValidationRule(nameRule); - this.addValidationRule(attributeTypeRule); - // this.addValidationRule(orphanAttributeRule); - this.addValidationRule(generalSpecificNameRule); - this.addValidationRule(instanceClassifierExistenceRule); - this.addValidationRule(missingSlotsRule); - this.addValidationRule(associationInheritanceRule); - this.addValidationRule(subsetsRule); - } - - public SRValidationSuite(final List elements) { - super(NAME); - this.elements = elements; - } - - @Override - public void run() { - for (final ValidationRule vr : this.getValidationRules()) { - vr.getViolations().clear(); - } - - final ListIterator iterator = elements.listIterator(); - while (iterator.hasNext()) { - final Element element = iterator.next(); - - if (element instanceof Classifier) { - final Classifier classifier = (Classifier) element; - // traverse the hierarchy down - for (final Generalization generalization : classifier.get_generalizationOfGeneral()) { - if (!elements.contains(generalization.getSpecific())) { - iterator.add(generalization.getSpecific()); - iterator.previous(); - } - } - for (final InstanceSpecification instance : classifier.get_instanceSpecificationOfClassifier()) { - if (!elements.contains(instance)) { - iterator.add(instance); - iterator.previous(); - } - } - for (Property property : classifier.getAttribute()) { - if (!elements.contains(property.getType())) { - iterator.add(property.getType()); - iterator.previous(); - } - } - - checkForAspects(classifier, classifier); - - for (final Classifier general : classifier.getGeneral()) { - - // Inheritance on Associations Rule - checkAssociationsForInheritance(classifier, general); - checkForAspects(classifier, general); - } - - 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)); - attributeTypeRule.addViolation(v); - } - break; - } - } - } - } - if (redefingEl == null) { - boolean redefinedInContext = false; - for (final NamedElement ne2 : classifier.getInheritedMember()) { - if (ne2 instanceof RedefinableElement && ne2 instanceof RedefinableElement && doesEventuallyRedefine((RedefinableElement) ne2, redefEl)) { - 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()); - 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 (ne instanceof RedefinableElement) { - v.addAction(new SetOrCreateRedefinableElementAction(classifier, redefEl, false)); - if (redefEl 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)); - // } - } - } - attributeMissingRule.addViolation(v); - } - } - 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")); - nameRule.addViolation(v); - } - if (redefingEl instanceof TypedElement && redefEl instanceof TypedElement) { - final TypedElement redefingTypdEl = (TypedElement) redefingEl; - final TypedElement redefableTypdEl = (TypedElement) redefEl; - - 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()))) { - if (redefingTypdEl.getType() instanceof Classifier && redefableTypdEl.getType() instanceof Classifier && ((Classifier) redefingTypdEl.getType()).getGeneral().contains(redefableTypdEl.getType())) { - if (!elements.contains(redefableTypdEl.getType())) { - iterator.add(redefingTypdEl.getType()); - iterator.previous(); - } - } - else { - final ValidationRuleViolation v = new ValidationRuleViolation(redefingTypdEl, - attributeTypeRule.getDescription() + ": [GENERAL] " + (redefableTypdEl.getType() != null ? redefableTypdEl.getType().getQualifiedName() : "null") + " - [SPECIFIC] " - + (redefingTypdEl.getType() != null ? redefingTypdEl.getType().getQualifiedName() : "null")); - v.addAction(new RetypeElementAction(redefableTypdEl, redefingTypdEl, "Update Specific")); - v.addAction(new RetypeElementAction(redefingTypdEl, redefableTypdEl, "Update General")); - attributeTypeRule.addViolation(v); - } - } - } - } - } - } - - } - else if (element instanceof InstanceSpecification) { - final InstanceSpecification instance = (InstanceSpecification) element; - - for (final Slot slot : instance.getSlot()) { - for (final ValueSpecification vs : slot.getValue()) { - final InstanceSpecification i; - if (vs instanceof InstanceValue && (i = ((InstanceValue) vs).getInstance()) != null && !elements.contains(i)) { - iterator.add(i); - iterator.previous(); - } - } - } - - if (!instance.hasClassifier()) { - final ValidationRuleViolation v = new ValidationRuleViolation(instance, instanceClassifierExistenceRule.getDescription() + ": " + instance.getQualifiedName()); - v.addAction(new OpenSpecificationAction(instance)); - v.addAction(new SelectInContainmentTreeAction(instance)); - instanceClassifierExistenceRule.addViolation(v); - continue; - } - - // boolean needsReslotting = false; - final List missingProperties = new ArrayList<>(); - for (final Classifier classifier : instance.getClassifier()) { - for (final Property property : CreateSlotsAction.collectSlottableProperties(classifier)) { - boolean isDefined = false; - for (final Slot slot : instance.getSlot()) { - if (slot.getDefiningFeature().equals(property)) { - isDefined = true; - break; - } - } - if (!isDefined) { - missingProperties.add(property); - } - } - } - if (!missingProperties.isEmpty()) { - String suffix = ""; - if (instance.hasSlot()) { - suffix += ": "; - for (int i = 0; i < missingProperties.size(); i++) { - final Property property = missingProperties.get(i); - suffix += property.getName() != null && !property.getName().isEmpty() ? property.getName() : "<>"; - if (i != missingProperties.size() - 1) { - suffix += ", "; - } - } - } - final ValidationRuleViolation v = new ValidationRuleViolation(instance, (!instance.hasSlot() ? missingSlotsRule.getDescription().replaceFirst("Missing", "No") : missingSlotsRule.getDescription()) + suffix); - v.addAction(IndeterminateProgressMonitorProxy.doubleWrap(new CreateSlotsAction(instance, false, false, false, "Create Missing Slots"), "Systems Reasoner")); - v.addAction(IndeterminateProgressMonitorProxy.doubleWrap(new CreateSlotsAction(instance, false, false, true, "Recreate Slots"), "Systems Reasoner")); - v.addAction(IndeterminateProgressMonitorProxy.doubleWrap(new CreateSlotsAction(instance, false, true, true, "Delete Child Instances & Recreate Slots"), "Systems Reasoner")); - - v.addAction(IndeterminateProgressMonitorProxy.doubleWrap(new CreateSlotsAction(instance, true, false, false, "[R] Create Missing Slots"), "Systems Reasoner")); - v.addAction(IndeterminateProgressMonitorProxy.doubleWrap(new CreateSlotsAction(instance, true, false, true, "[R] Recreate Slots"), "Systems Reasoner")); - v.addAction(IndeterminateProgressMonitorProxy.doubleWrap(new CreateSlotsAction(instance, true, true, true, "[R] Delete Child Instances & Recreate Slots"), "Systems Reasoner")); - missingSlotsRule.addViolation(v); - } - } - } - } - - 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); - } - } - } - } - } - } - } - } - } - - private void checkForAspects(final Classifier classifier, final Classifier general) { - /** - * Check for aspect structures: - */ - for (Dependency d : general.getClientDependency()) { - boolean aspectFound = false; - Classifier aspect = null; - Stereotype s = StereotypesHelper.getAppliedStereotypeByString(d, "aspect"); - if (s != null) { - for (Element el : d.getTarget()) { - if (el instanceof Classifier) { - aspect = (Classifier) el; - for (Element ownedElement : classifier.getOwnedElement()) { - if (ownedElement instanceof Property) { - Type type = ((TypedElement) ownedElement).getType(); - if (type instanceof Classifier) { - if ((hasInheritanceFromTo((Classifier) type, aspect))) { - aspectFound = true; - } - } - } - else if (ownedElement instanceof CallBehaviorAction) { - Behavior b = ((CallBehaviorAction) ownedElement).getBehavior(); - if (b.getGeneral().contains(el)) { - aspectFound = true; - } - } - } - } - } - if (!aspectFound) { - if (aspect != null) { - final ValidationRuleViolation v = new ValidationRuleViolation(classifier, aspectMissingRule.getDescription() + ": [CLASS WITH ASPECT] " + classifier.getName() + " - [ASPECT] " + aspect.getName()); - v.addAction(new AspectRemedyAction(classifier, aspect)); - aspectMissingRule.addViolation(v); - } - } - } - } - } - - 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); - } - else { - return false; - } - } - - public static boolean doesEventuallyRedefine(final RedefinableElement source, final RedefinableElement target) { - if (source.getRedefinedElement().contains(target)) { - return true; - } - for (final RedefinableElement p : source.getRedefinedElement()) { - if (doesEventuallyRedefine(p, target)) { - return true; - } - } - return false; - } - - public static boolean doesEventuallyGeneralizeTo(final Classifier source, final Classifier target) { - if (source.getGeneral().contains(target)) { - return true; - } - if (source.equals(target)) { - return true; - } - for (final Classifier classifier : source.getGeneral()) { - if (doesEventuallyGeneralizeTo(classifier, target)) { - return true; - } - } - return false; - } - -}