diff --git a/cnf/build.bnd b/cnf/build.bnd index ea32f0ca..b3d691cb 100644 --- a/cnf/build.bnd +++ b/cnf/build.bnd @@ -7,7 +7,8 @@ geckoEMF,\ geckoOSGi-Test,\ geckoDIMC,\ - geckoJacoco + geckoJacoco,\ + geckoUtil # Needed because we enabled library 'gecko-dimc' github-project: org.gecko.emf.util @@ -49,8 +50,28 @@ javac.target: 11 readOnly=true;\ name=Baseline +-plugin.dimrelease: \ + aQute.bnd.repository.maven.provider.MavenBndRepository;\ + snapshotUrl=https://devel.data-in-motion.biz/nexus/repository/dim-snapshot/;\ + releaseUrl=https://devel.data-in-motion.biz/nexus/repository/dim-release/;\ + index=${.}/dim_release.maven;\ + name='DIM_Release' + +-plugin.dimruntime: \ + aQute.bnd.repository.osgi.OSGiRepository; \ + locations = https://devel.data-in-motion.biz/repository/p2/obr/dim-core-runtime/index.xml;\ + max.stale=-1;\ + readonly = true;\ + name = "DIM Eclipse Runtime Shade";\ + cache=${build}/cache/DimEclipseRuntime + +-plugin.z.target: \ + aQute.bnd.repository.p2.provider.P2Repository; \ + url = ${fileuri;${.}}qvt.target; \ + name = Targetdefinition;\ + poll.time = -1 + + -baselinerepo: Baseline -baseline: \ - * - --diffignore.module: + * \ No newline at end of file diff --git a/cnf/central.mvn b/cnf/central.mvn index 784dc1d8..257314a1 100644 --- a/cnf/central.mvn +++ b/cnf/central.mvn @@ -1,6 +1,9 @@ biz.aQute.bnd:biz.aQute.bnd.annotation:7.0.0 +biz.aQute.bnd:biz.aQute.bnd.annotation:7.0.0 biz.aQute:biz.aQute.gogo.commands.provider:1.8.0 biz.aQute:biz.aQute.wrapper.hamcrest:1.9.0 +biz.aQute.bnd:biz.aQute.bnd.javagen:7.0.0 +org.bndtools:org.bndtools.templates.osgi:7.0.0 jakarta.ws.rs:jakarta.ws.rs-api:3.1.0 jakarta.ws.rs:jakarta.ws.rs-api:2.1.6 @@ -18,8 +21,6 @@ org.objenesis:objenesis:3.2 org.apache.aries.spifly:org.apache.aries.spifly.dynamic.bundle:1.3.4 org.apache.felix:org.apache.felix.framework:jar:7.0.1 -org.apache.felix:org.apache.felix.configadmin:1.9.22 -org.apache.felix:org.apache.felix.configurator:1.0.14 org.apache.felix:org.apache.felix.converter:1.0.18 org.apache.felix:org.apache.felix.coordinator:1.0.2 org.apache.felix:org.apache.felix.eventadmin:1.6.2 @@ -80,7 +81,7 @@ org.osgi:org.osgi.service.blueprint:1.0.2 org.osgi:org.osgi.service.cdi:1.0.0 org.osgi:org.osgi.service.clusterinfo:1.0.0 org.osgi:org.osgi.service.cm:1.6.0 -org.osgi:org.osgi.service.component.annotations:1.4.0 +org.osgi:org.osgi.service.component.annotations:1.5.1 org.osgi:org.osgi.service.component:1.4.0 org.osgi:org.osgi.service.condition:1.0.0 org.osgi:org.osgi.service.condpermadmin:1.1.2 @@ -125,17 +126,9 @@ org.slf4j:slf4j-jcl:1.7.36 commons-logging:commons-logging:1.2 -org.eclipse.emf:org.eclipse.emf.common:2.23.0 -org.eclipse.emf:org.eclipse.emf.ecore:2.25.0 -org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.16.0 -org.eclipse.emf:org.eclipse.emf.codegen.ecore:2.28.0 -org.eclipse.emf:org.eclipse.emf.codegen:2.22.0 -org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:1.6.0 -org.eclipse.platform:org.eclipse.osgi:3.16.300 org.eclipse.platform:org.eclipse.equinox.common:3.14.0 org.eclipse.platform:org.eclipse.equinox.registry:3.10.200 org.eclipse.platform:org.eclipse.core.expressions:3.7.100 -org.eclipse.platform:org.eclipse.core.runtime:3.22.0 org.eclipse.platform:org.eclipse.core.resources:3.14.0 org.eclipse.platform:org.eclipse.core.jobs:3.11.0 org.eclipse.platform:org.eclipse.core.contenttype:3.7.1000 @@ -149,8 +142,9 @@ org.apiguardian:apiguardian-api:1.1.2 org.geckoprojects.bnd:org.gecko.bnd.dimc.library:1.4.4 org.geckoprojects.bnd:org.gecko.bnd.osgitest.library:1.4.4 org.geckoprojects.bnd:org.gecko.bnd.jacoco.library:1.4.4 +org.geckoprojects.utils:org.gecko.util.bnd.library.workspace:1.0.0 -org.geckoprojects.emf:org.gecko.emf.osgi.bnd.library.workspace:6.0.1 +org.geckoprojects.emf:org.gecko.emf.osgi.bnd.library.workspace:6.1.1 com.fasterxml.jackson.core:jackson-core:2.14.1 com.fasterxml.jackson.core:jackson-databind:2.14.1 @@ -180,3 +174,12 @@ org.apache.logging.log4j:log4j-to-slf4j:2.18.0 javax.xml.bind:jaxb-api:2.4.0-b180830.0359 javax.activation:javax.activation-api:1.2.0 + +#qvt +org.eclipse.platform:org.eclipse.equinox.supplement:1.10.700 +org.geckoprojects.emf:org.gecko.emf.osgi.example.model.basic:6.1.0 +org.eclipse.emf:org.eclipse.emf.ecore.change:2.15.0 +lpg.runtime:java:2.0.17-v201004271640 +org.eclipse.equinox:org.eclipse.equinox.registry:3.5.101 +org.apache.felix:org.apache.felix.configadmin:1.9.26 +org.apache.felix:org.apache.felix.configurator:1.0.18 diff --git a/cnf/dim_release.maven b/cnf/dim_release.maven new file mode 100644 index 00000000..52fd3fed --- /dev/null +++ b/cnf/dim_release.maven @@ -0,0 +1,32 @@ +#com.ibm:com.ibm.icu:64.2.0.v20190507-1337 +#lpg.runtime:lpg.runtime.java:2.0.17.v201004271640 + +#org.eclipse.emf:org.eclipse.emf.ecore.change:2.14.0.v20190528-0725 +#org.eclipse.emf:org.eclipse.emf.compare:3.5.3.201909101346 + +#org.eclipse.ocl:org.eclipse.ocl:3.10.400.201911041049 +#org.eclipse.ocl:org.eclipse.ocl.common:1.8.400.v20190910-0937 +#org.eclipse.ocl:org.eclipse.ocl.ecore:3.14.0.v20190910-0937 + +#org.eclipse.m2m:org.eclipse.m2m.qvt.oml.common:3.9.0.v20190909-1952 +#org.eclipse.m2m:org.eclipse.m2m.qvt.oml.cst.parser:3.9.0.v20190909-1952 +#org.eclipse.m2m:org.eclipse.m2m.qvt.oml.ecore.imperativeocl:3.9.0.v20190909-1952 +#org.eclipse.m2m:org.eclipse.m2m.qvt.oml.ocl:3.9.0.v20190909-1952 +#org.eclipse.m2m:org.eclipse.m2m.qvt.oml:3.10.0.201911041036 +#org.eclipse.m2m:org.eclipse.m2m.qvt.oml.emf.util:3.9.0.201911041041 + +#org.eclipse.equinox:org.eclipse.equinox.preferences:3.7.500.v20190815-1535 +#org.eclipse.equinox:org.eclipse.equinox.app:1.4.300.v20190815-1535 +#org.eclipse.equinox:org.eclipse.equinox.common:3.10.500.v20190815-1535 +#org.eclipse.equinox:org.eclipse.equinox.registry:3.8.500.v20190714-1850 +#org.eclipse.equinox:org.eclipse.equinox.supplement:1.9.100.201911011403 + +#org.eclipse.core:org.eclipse.core.runtime:3.16.100.201911011611 +#org.eclipse.core:org.eclipse.core.resources:3.13.600.201910311300 +#org.eclipse.core:org.eclipse.core.jobs:3.10.500.v20190620-1426 +#org.eclipse.core:org.eclipse.core.filesystem:1.7.600.201910311251 +#org.eclipse.core:org.eclipse.core.contenttype:3.7.400.v20190624-1144 +#org.eclipse.core:org.eclipse.core.expressions:3.6.600.201910311244 + +#org.gecko.eclipse:org.gecko.eclipse.core.supplement:1.0.0 + diff --git a/cnf/local/index.xml b/cnf/local/index.xml index 2cb89c19..c7fb1453 100644 --- a/cnf/local/index.xml +++ b/cnf/local/index.xml @@ -1,5 +1,43 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -42,42 +80,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cnf/local/index.xml.sha b/cnf/local/index.xml.sha deleted file mode 100644 index 52fed598..00000000 --- a/cnf/local/index.xml.sha +++ /dev/null @@ -1 +0,0 @@ -36fef63ad5a2969af2b0c99016ae1526c76cffd1aecb9d03c9b3d1ef367c60d7 \ No newline at end of file diff --git a/cnf/qvt.target b/cnf/qvt.target new file mode 100644 index 00000000..a91810fe --- /dev/null +++ b/cnf/qvt.target @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.eclipse.emf.ecore.fragment/.classpath b/org.eclipse.emf.ecore.fragment/.classpath new file mode 100644 index 00000000..a52eb822 --- /dev/null +++ b/org.eclipse.emf.ecore.fragment/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/org.eclipse.emf.ecore.fragment/.gitignore b/org.eclipse.emf.ecore.fragment/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/org.eclipse.emf.ecore.fragment/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/org.eclipse.emf.ecore.fragment/.project b/org.eclipse.emf.ecore.fragment/.project new file mode 100644 index 00000000..0fef2e91 --- /dev/null +++ b/org.eclipse.emf.ecore.fragment/.project @@ -0,0 +1,23 @@ + + + org.eclipse.emf.ecore.fragment + + + + + + org.eclipse.jdt.core.javabuilder + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + bndtools.core.bndnature + + diff --git a/org.eclipse.emf.ecore.fragment/.settings/org.eclipse.core.resources.prefs b/org.eclipse.emf.ecore.fragment/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..9c756685 --- /dev/null +++ b/org.eclipse.emf.ecore.fragment/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 +encoding/bnd.bnd=UTF-8 diff --git a/org.eclipse.emf.ecore.fragment/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.emf.ecore.fragment/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..8c9943d5 --- /dev/null +++ b/org.eclipse.emf.ecore.fragment/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/org.eclipse.emf.ecore.fragment/bnd.bnd b/org.eclipse.emf.ecore.fragment/bnd.bnd new file mode 100644 index 00000000..007a51b8 --- /dev/null +++ b/org.eclipse.emf.ecore.fragment/bnd.bnd @@ -0,0 +1,11 @@ +Fragment-Host: org.eclipse.emf.ecore + +Import-Package: org.eclipse.core.runtime.spi + +Provide-Capability: emf.m2m.companion;emf.m2m.companion=ecore.fragment + +Require-Bundle: org.eclipse.core.runtime + +-workingset: qvt + +Bundle-Version: 2.0.0.SNAPSHOT \ No newline at end of file diff --git a/org.eclipse.ocl.fragment/.classpath b/org.eclipse.ocl.fragment/.classpath new file mode 100644 index 00000000..a52eb822 --- /dev/null +++ b/org.eclipse.ocl.fragment/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/org.eclipse.ocl.fragment/.gitignore b/org.eclipse.ocl.fragment/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/org.eclipse.ocl.fragment/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/org.eclipse.ocl.fragment/.project b/org.eclipse.ocl.fragment/.project new file mode 100644 index 00000000..c81cd608 --- /dev/null +++ b/org.eclipse.ocl.fragment/.project @@ -0,0 +1,23 @@ + + + org.eclipse.ocl.fragment + + + + + + org.eclipse.jdt.core.javabuilder + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + bndtools.core.bndnature + + diff --git a/org.eclipse.ocl.fragment/.settings/org.eclipse.core.resources.prefs b/org.eclipse.ocl.fragment/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..9c756685 --- /dev/null +++ b/org.eclipse.ocl.fragment/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 +encoding/bnd.bnd=UTF-8 diff --git a/org.eclipse.ocl.fragment/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ocl.fragment/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..8c9943d5 --- /dev/null +++ b/org.eclipse.ocl.fragment/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/org.eclipse.ocl.fragment/bnd.bnd b/org.eclipse.ocl.fragment/bnd.bnd new file mode 100644 index 00000000..bc3ff428 --- /dev/null +++ b/org.eclipse.ocl.fragment/bnd.bnd @@ -0,0 +1,7 @@ +Fragment-Host: org.eclipse.ocl + +Import-Package: org.osgi.framework +Bundle-Version: 2.0.0.SNAPSHOT +Provide-Capability: emf.m2m.companion;emf.m2m.companion=ocl.fragment + +-workingset: qvt \ No newline at end of file diff --git a/org.gecko.emf.util.jakartars.bnd.library.workspace/bla.json b/org.gecko.emf.util.jakartars.bnd.library.workspace/bla.json new file mode 100644 index 00000000..daff2686 --- /dev/null +++ b/org.gecko.emf.util.jakartars.bnd.library.workspace/bla.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/org.gecko.emf.util.jakartars.bnd.library.workspace/required.bndrun b/org.gecko.emf.util.jakartars.bnd.library.workspace/required.bndrun index 02f48446..11558e36 100644 --- a/org.gecko.emf.util.jakartars.bnd.library.workspace/required.bndrun +++ b/org.gecko.emf.util.jakartars.bnd.library.workspace/required.bndrun @@ -49,22 +49,22 @@ org.gecko.emf.exporter.xlsx;version=snapshot,\ org.gecko.emf.xlsx;version=snapshot,\ org.apache.felix.scr;version='[2.2.6,2.2.7)',\ - org.eclipse.emf.common;version='[2.28.0,2.28.1)',\ - org.eclipse.emf.ecore;version='[2.33.0,2.33.1)',\ - org.eclipse.emf.ecore.xmi;version='[2.18.0,2.18.1)',\ org.gecko.emf.exporter.r_lang;version=snapshot,\ org.gecko.emf.r_lang;version=snapshot,\ org.apache.commons.logging;version='[1.2.0,1.2.1)',\ - org.osgi.service.cm;version='[1.6.0,1.6.1)',\ org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\ - org.apache.felix.metatype;version='[1.2.4,1.2.5)',\ org.osgi.service.component;version='[1.5.1,1.5.2)',\ - org.osgi.service.log;version='[1.5.0,1.5.1)',\ org.osgi.util.converter;version='[1.0.9,1.0.10)',\ org.osgi.util.function;version='[1.2.0,1.2.1)',\ org.osgi.util.promise;version='[1.3.0,1.3.1)',\ slf4j.jcl;version='[1.7.36,1.7.37)',\ org.gecko.com.github.miachm.sods;version=snapshot,\ org.gecko.emf.exporter;version=snapshot,\ - org.gecko.emf.osgi.component;version='[6.0.1,6.0.2)',\ - org.gecko.emf.util.common;version=snapshot + org.gecko.emf.util.common;version=snapshot,\ + org.eclipse.emf.common;version='[2.29.0,2.29.1)',\ + org.eclipse.emf.ecore;version='[2.35.0,2.35.1)',\ + org.eclipse.emf.ecore.xmi;version='[2.36.0,2.36.1)',\ + org.gecko.emf.osgi.api;version='[6.1.1,6.1.2)',\ + org.gecko.emf.osgi.component.config;version='[6.1.1,6.1.2)',\ + org.gecko.emf.osgi.component.minimal;version='[6.1.1,6.1.2)',\ + org.osgi.service.cm;version='[1.6.1,1.6.2)' diff --git a/org.gecko.emf.util.jakartars.bnd.library.workspace/resources/template/workspace.bnd b/org.gecko.emf.util.jakartars.bnd.library.workspace/resources/template/workspace.bnd index 7d5a638c..67573b2f 100644 --- a/org.gecko.emf.util.jakartars.bnd.library.workspace/resources/template/workspace.bnd +++ b/org.gecko.emf.util.jakartars.bnd.library.workspace/resources/template/workspace.bnd @@ -4,4 +4,5 @@ snapshotUrl = "https://devel.data-in-motion.biz/nexus/repository/dim-snapshot/,https://oss.sonatype.org/content/repositories/snapshots/";\ index = "${.}/geckoEMFUtil.maven" ;\ readOnly = true;\ + poll.time = -1;\ name="GeckoEMF Util Dependencies" diff --git a/org.gecko.emf.util.jaxrs.bnd.library.workspace/required.bndrun b/org.gecko.emf.util.jaxrs.bnd.library.workspace/required.bndrun index 2f4b8b24..a65820f4 100644 --- a/org.gecko.emf.util.jaxrs.bnd.library.workspace/required.bndrun +++ b/org.gecko.emf.util.jaxrs.bnd.library.workspace/required.bndrun @@ -49,25 +49,25 @@ org.gecko.emf.exporter.xlsx;version=snapshot,\ org.gecko.emf.xlsx;version=snapshot,\ org.apache.felix.scr;version='[2.2.6,2.2.7)',\ - org.eclipse.emf.common;version='[2.28.0,2.28.1)',\ - org.eclipse.emf.ecore;version='[2.33.0,2.33.1)',\ - org.eclipse.emf.ecore.xmi;version='[2.18.0,2.18.1)',\ org.gecko.emf.exporter.r_lang;version=snapshot,\ org.gecko.emf.r_lang;version=snapshot,\ org.apache.commons.logging;version='[1.2.0,1.2.1)',\ - org.osgi.service.cm;version='[1.6.0,1.6.1)',\ org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\ - org.apache.felix.metatype;version='[1.2.4,1.2.5)',\ org.osgi.service.component;version='[1.5.1,1.5.2)',\ - org.osgi.service.log;version='[1.5.0,1.5.1)',\ org.osgi.util.converter;version='[1.0.9,1.0.10)',\ org.osgi.util.function;version='[1.2.0,1.2.1)',\ org.osgi.util.promise;version='[1.3.0,1.3.1)',\ slf4j.jcl;version='[1.7.36,1.7.37)',\ org.gecko.com.github.miachm.sods;version=snapshot,\ org.gecko.emf.exporter;version=snapshot,\ - org.gecko.emf.osgi.component;version='[6.0.1,6.0.2)',\ - org.gecko.emf.util.common;version=snapshot + org.gecko.emf.util.common;version=snapshot,\ + org.eclipse.emf.common;version='[2.29.0,2.29.1)',\ + org.eclipse.emf.ecore;version='[2.35.0,2.35.1)',\ + org.eclipse.emf.ecore.xmi;version='[2.36.0,2.36.1)',\ + org.gecko.emf.osgi.api;version='[6.1.1,6.1.2)',\ + org.gecko.emf.osgi.component.config;version='[6.1.1,6.1.2)',\ + org.gecko.emf.osgi.component.minimal;version='[6.1.1,6.1.2)',\ + org.osgi.service.cm;version='[1.6.1,1.6.2)' -runrepos: \ Workspace,\ Central,\ diff --git a/org.gecko.emf.util.jaxrs.bnd.library.workspace/resources/template/workspace.bnd b/org.gecko.emf.util.jaxrs.bnd.library.workspace/resources/template/workspace.bnd index 7d5a638c..67573b2f 100644 --- a/org.gecko.emf.util.jaxrs.bnd.library.workspace/resources/template/workspace.bnd +++ b/org.gecko.emf.util.jaxrs.bnd.library.workspace/resources/template/workspace.bnd @@ -4,4 +4,5 @@ snapshotUrl = "https://devel.data-in-motion.biz/nexus/repository/dim-snapshot/,https://oss.sonatype.org/content/repositories/snapshots/";\ index = "${.}/geckoEMFUtil.maven" ;\ readOnly = true;\ + poll.time = -1;\ name="GeckoEMF Util Dependencies" diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/.classpath b/org.gecko.emf.util.qvt.bnd.library.workspace/.classpath new file mode 100644 index 00000000..a52eb822 --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/.gitignore b/org.gecko.emf.util.qvt.bnd.library.workspace/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/.project b/org.gecko.emf.util.qvt.bnd.library.workspace/.project new file mode 100644 index 00000000..cd0f561d --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/.project @@ -0,0 +1,23 @@ + + + org.gecko.emf.util.qvt.bnd.library + + + + + + org.eclipse.jdt.core.javabuilder + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + bndtools.core.bndnature + + diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/.settings/org.eclipse.core.resources.prefs b/org.gecko.emf.util.qvt.bnd.library.workspace/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..04225f97 --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +encoding//resources/template/geckoUtilQVT.maven=UTF-8 +encoding//resources/template/workspace.bnd=UTF-8 +encoding/=UTF-8 +encoding/bnd.bnd=UTF-8 +encoding/buildpath.bnd=UTF-8 +encoding/required.bndrun=UTF-8 diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/.settings/org.eclipse.jdt.core.prefs b/org.gecko.emf.util.qvt.bnd.library.workspace/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..8c9943d5 --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/bnd.bnd b/org.gecko.emf.util.qvt.bnd.library.workspace/bnd.bnd new file mode 100644 index 00000000..9a1acd74 --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/bnd.bnd @@ -0,0 +1,19 @@ +-resourceonly: true +-include: ${.}/buildpath.bnd +mavendeps: ${sjoin;\n; ${template;-maven-dependencies;${@}}} + +-includeresource: resources,\ + {template/geckoUtilQVT.maven=resources/template/geckoUtilQVT.maven},\ + template/qvt.target=${.}/../cnf/qvt.target + +Provide-Capability: \ + ${gecko-base} + +gecko-base:\ + bnd.library;\ + bnd.library = geckoUtilQVT; \ + path = template +Bundle-Description: Gecko QVT Workspace Libarary +Bundle-Version: 2.0.0.SNAPSHOT + +-workingset: qvt \ No newline at end of file diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/buildpath.bnd b/org.gecko.emf.util.qvt.bnd.library.workspace/buildpath.bnd new file mode 100644 index 00000000..ba58909f --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/buildpath.bnd @@ -0,0 +1,9 @@ +-include: ${.}/required.bndrun + +-buildpath: ${-runbundles} +-buildpath.extra: \ + org.osgi.service.condition;version=latest,\ + org.osgi.service.component.annotations;version=latest,\ + org.osgi.framework;version=latest,\ + org.osgi.annotation.versioning;version=latest,\ + org.osgi.annotation.bundle;version=latest \ No newline at end of file diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/required.bndrun b/org.gecko.emf.util.qvt.bnd.library.workspace/required.bndrun new file mode 100644 index 00000000..b842a720 --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/required.bndrun @@ -0,0 +1,11 @@ +-runfw: org.apache.felix.framework +-runee: JavaSE-17 + +#example +-runrequires: \ + bnd.identity;id='org.gecko.qvt.osgi.api',\ + bnd.identity;id='org.gecko.qvt.osgi.component' +-runbundles: \ + org.gecko.qvt.osgi.api;version=snapshot,\ + org.gecko.qvt.osgi.component;version=snapshot + \ No newline at end of file diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/resources/template/geckoUtilQVT.maven b/org.gecko.emf.util.qvt.bnd.library.workspace/resources/template/geckoUtilQVT.maven new file mode 100644 index 00000000..4700c956 --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/resources/template/geckoUtilQVT.maven @@ -0,0 +1 @@ +${mavendeps} \ No newline at end of file diff --git a/org.gecko.emf.util.qvt.bnd.library.workspace/resources/template/workspace.bnd b/org.gecko.emf.util.qvt.bnd.library.workspace/resources/template/workspace.bnd new file mode 100644 index 00000000..59c39d04 --- /dev/null +++ b/org.gecko.emf.util.qvt.bnd.library.workspace/resources/template/workspace.bnd @@ -0,0 +1,24 @@ +-plugin.geckoUtilQVT: \ + aQute.bnd.repository.maven.provider.MavenBndRepository;\ + releaseUrl = "https://repo.maven.apache.org/maven2/,https://devel.data-in-motion.biz/nexus/repository/dim-release/"; \ + snapshotUrl = "https://devel.data-in-motion.biz/nexus/repository/dim-snapshot/";\ + index = "${.}/geckoUtilQVT.maven" ;\ + readOnly = true;\ + poll.time = -1;\ + name ="GeckoUtil QVT M2M" + +-plugin.geckoUtilQVT.dimruntime: \ + aQute.bnd.repository.osgi.OSGiRepository; \ + locations = https://devel.data-in-motion.biz/repository/p2/obr/dim-core-runtime/index.xml;\ + max.stale=-1;\ + readonly = true;\ + name = "DIM Eclipse Runtime Shade";\ + cache=${build}/cache/DimEclipseRuntime + +-plugin.geckoUtilQVT.QVT: \ + aQute.bnd.repository.p2.provider.P2Repository; \ + url = ${fileuri;${.}}qvt.target; \ + name = "QVT P2 Dependencies";\ + poll.time = -1 + +-require-bnd: "(version>=7.0.0)" \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/.classpath b/org.gecko.qvt.osgi.tests/.classpath new file mode 100644 index 00000000..a52eb822 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/org.gecko.qvt.osgi.tests/.gitignore b/org.gecko.qvt.osgi.tests/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/org.gecko.qvt.osgi.tests/.project b/org.gecko.qvt.osgi.tests/.project new file mode 100644 index 00000000..293674b2 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/.project @@ -0,0 +1,33 @@ + + + org.gecko.qvt.osgi.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2m.qvt.oml.project.QVTOBuilder + + + src_container + transforms + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2m.qvt.oml.project.QVTONature + bndtools.core.bndnature + + diff --git a/org.gecko.qvt.osgi.tests/.settings/org.eclipse.core.resources.prefs b/org.gecko.qvt.osgi.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..3563c3a8 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//.settings/org.eclipse.core.resources.prefs=UTF-8 +encoding/=UTF-8 +encoding/bnd.bnd=UTF-8 +encoding/build.gradle=UTF-8 +encoding/test.bndrun=UTF-8 diff --git a/org.gecko.qvt.osgi.tests/.settings/org.eclipse.jdt.core.prefs b/org.gecko.qvt.osgi.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..8c9943d5 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/org.gecko.qvt.osgi.tests/.settings/org.eclipse.m2m.qvt.oml.mmodel.urimap b/org.gecko.qvt.osgi.tests/.settings/org.eclipse.m2m.qvt.oml.mmodel.urimap new file mode 100644 index 00000000..49c52d94 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/.settings/org.eclipse.m2m.qvt.oml.mmodel.urimap @@ -0,0 +1,4 @@ + + + + diff --git a/org.gecko.qvt.osgi.tests/bnd.bnd b/org.gecko.qvt.osgi.tests/bnd.bnd new file mode 100644 index 00000000..5c5a9a01 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/bnd.bnd @@ -0,0 +1,20 @@ +-library: enableOSGi-Test,\ + enable-emf + +# sets the usually required buildpath using the bnd library, you can extend it with the normal -buildpath to your liking +-buildpath: \ + org.osgi.framework;version=latest,\ + org.osgi.service.cm;version=latest,\ + org.osgi.util.tracker;version=latest,\ + org.gecko.util.pool;version=latest,\ + org.gecko.qvt.osgi.api;version=latest,\ + org.osgi.test.junit5.cm;version=latest,\ + org.gecko.emf.osgi.example.model.basic,\ + org.eclipse.m2m.qvt.oml;version=latest,\ + org.osgi.service.component;version=latest + +Bundle-Version: 2.0.0.SNAPSHOT + +-includeresource: transforms/ + +-workingset: qvt \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/build.gradle b/org.gecko.qvt.osgi.tests/build.gradle new file mode 100644 index 00000000..d3adac90 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/build.gradle @@ -0,0 +1,8 @@ + +def resolveTask = tasks.named("resolve.test") { + outputBndrun = layout.buildDirectory.file("test.bndrun") +} + +tasks.named("testOSGi") { + bndrun = resolveTask.flatMap { it.outputBndrun } +} diff --git a/org.gecko.qvt.osgi.tests/src/org/gecko/qvt/osgi/tests/QVTTransformatorIntegrationTest.java b/org.gecko.qvt.osgi.tests/src/org/gecko/qvt/osgi/tests/QVTTransformatorIntegrationTest.java new file mode 100644 index 00000000..6aa55f79 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/src/org/gecko/qvt/osgi/tests/QVTTransformatorIntegrationTest.java @@ -0,0 +1,424 @@ +/** + * Copyright (c) 2012 - 2017 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.tests; + + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.io.IOException; +import java.net.URL; +import java.util.Collections; +import java.util.Dictionary; +import java.util.Hashtable; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.m2m.qvt.oml.TransformationExecutor; +import org.eclipse.m2m.qvt.oml.TransformationExecutor.BlackboxRegistry; +import org.gecko.emf.osgi.example.model.basic.Address; +import org.gecko.emf.osgi.example.model.basic.BasicFactory; +import org.gecko.emf.osgi.example.model.basic.GenderType; +import org.gecko.emf.osgi.example.model.basic.Person; +import org.gecko.qvt.osgi.api.ModelTransformationConstants; +import org.gecko.qvt.osgi.api.ModelTransformator; +import org.gecko.qvt.osgi.tests.bbox.BlackboxTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.condition.Condition; +import org.osgi.test.common.annotation.InjectBundleContext; +import org.osgi.test.common.annotation.InjectService; +import org.osgi.test.common.annotation.Property; +import org.osgi.test.common.annotation.config.WithConfiguration; +import org.osgi.test.common.annotation.config.WithFactoryConfiguration; +import org.osgi.test.common.service.ServiceAware; +import org.osgi.test.junit5.cm.ConfigurationExtension; +import org.osgi.test.junit5.context.BundleContextExtension; +import org.osgi.test.junit5.service.ServiceExtension; + +/** + * Test QVT Mapping + * @author mark + * @since 20.10.2017 + */ +@ExtendWith(BundleContextExtension.class) +@ExtendWith(ServiceExtension.class) +@ExtendWith(ConfigurationExtension.class) +public class QVTTransformatorIntegrationTest { + + @InjectBundleContext + BundleContext context; + + @Test + @WithFactoryConfiguration(name = "testExample", factoryPid = ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, location = "?", properties = @Property(key = ModelTransformationConstants.TEMPLATE_PATH, value = "org.gecko.qvt.osgi.tests/PersonTransformation.qvto")) + public void testExample( + @InjectService ResourceSet rs, + @InjectService BasicFactory factory, + @InjectService(cardinality = 0) ServiceAware transformatorAware + ) throws InterruptedException{ + Resource r1 = rs.createResource(URI.createURI("tmp.test")); + Person p1 = BasicFactory.eINSTANCE.createPerson(); + p1.setFirstName("Mark"); + p1.setLastName("Hoffmann"); + p1.setGender(GenderType.MALE); + r1.getContents().add(p1); + + ModelTransformator transformator = transformatorAware.waitForService(500); + assertNotNull(transformator); + + EObject result = transformator.startTransformation(p1); + assertNotNull(result); + assertTrue(result instanceof Person); + Person resultPerson = (Person) result; + assertEquals(GenderType.FEMALE, resultPerson.getGender()); + assertEquals("Markin", resultPerson.getFirstName()); + assertEquals("Hoffmannin", resultPerson.getLastName()); + } + + @Test + @WithFactoryConfiguration(name = "testExampleWithDeps", factoryPid = ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, location = "?", properties = @Property(key = ModelTransformationConstants.TEMPLATE_PATH, value = "org.gecko.qvt.osgi.tests/PersonTransformationWithDeps.qvto")) + public void testExampleWithDeps( + @InjectService ResourceSet rs, + @InjectService BasicFactory factory, + @InjectService(cardinality = 0) ServiceAware transformatorAware + ) throws InterruptedException{ + Resource r1 = rs.createResource(URI.createURI("tmp.test")); + Person p1 = BasicFactory.eINSTANCE.createPerson(); + p1.setFirstName("Mark"); + p1.setLastName("Hoffmann"); + p1.setGender(GenderType.MALE); + Address address = BasicFactory.eINSTANCE.createAddress(); + address.setCity("Gera"); + address.setStreet("Kurt-Keicher"); + p1.setAddress(address); + + r1.getContents().add(p1); + + ModelTransformator transformator = transformatorAware.waitForService(500); + assertNotNull(transformator); + + EObject result = transformator.startTransformation(p1); + assertNotNull(result); + assertTrue(result instanceof Person); + Person resultPerson = (Person) result; + assertEquals(GenderType.FEMALE, resultPerson.getGender()); + assertEquals("Markin", resultPerson.getFirstName()); + assertEquals("Hoffmannin", resultPerson.getLastName()); + assertNotNull(resultPerson.getAddress()); + Address resultAddress = resultPerson.getAddress(); + assertEquals("SesamKurt-Keicher", resultAddress.getStreet()); + assertEquals("MyBeautifulGera", resultAddress.getCity()); + } + + @Test + @WithFactoryConfiguration(name = "testExampleWithDepsLibrary", factoryPid = ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, location = "?", properties = @Property(key = ModelTransformationConstants.TEMPLATE_PATH, value = "org.gecko.qvt.osgi.tests/PersonTransformationWithDepsLib.qvto")) + public void testExampleWithDepsLibrary( + @InjectService ResourceSet rs, + @InjectService BasicFactory factory, + @InjectService(cardinality = 0) ServiceAware transformatorAware + ) throws InterruptedException{ + Resource r1 = rs.createResource(URI.createURI("tmp.test")); + Person p1 = BasicFactory.eINSTANCE.createPerson(); + p1.setFirstName("Mark"); + p1.setLastName("Hoffmann"); + p1.setGender(GenderType.MALE); + Address address = BasicFactory.eINSTANCE.createAddress(); + address.setCity("Gera"); + address.setStreet("Kurt-Keicher"); + p1.setAddress(address); + + r1.getContents().add(p1); + + ModelTransformator transformator = transformatorAware.waitForService(500); + assertNotNull(transformator); + + EObject result = transformator.startTransformation(p1); + assertNotNull(result); + assertTrue(result instanceof Person); + Person resultPerson = (Person) result; + assertEquals(GenderType.FEMALE, resultPerson.getGender()); + assertEquals("Markin", resultPerson.getFirstName()); + assertEquals("Hoffmannin", resultPerson.getLastName()); + assertNotNull(resultPerson.getAddress()); + Address resultAddress = resultPerson.getAddress(); + assertEquals("SesamKurt-Keicher", resultAddress.getStreet()); + assertEquals("MyBeautifulGera", resultAddress.getCity()); + } + + @Test + public void testExampleWithBlackbox01( + @InjectService ResourceSet rs, + @InjectService BasicFactory factory, + @InjectService ConfigurationAdmin admin, + @InjectService(cardinality = 0) ServiceAware transformatorAware + ) throws InterruptedException, IOException{ + Resource r1 = rs.createResource(URI.createURI("tmp.test")); + Person p1 = BasicFactory.eINSTANCE.createPerson(); + p1.setFirstName("Mark"); + p1.setLastName("Hoffmann"); + p1.setGender(GenderType.MALE); + Address address = BasicFactory.eINSTANCE.createAddress(); + address.setCity("Gera"); + address.setStreet("Kurt-Keicher"); + p1.setAddress(address); + + r1.getContents().add(p1); + + BlackboxRegistry.INSTANCE.registerModule(BlackboxTest.class); + + Configuration configuration = admin.createFactoryConfiguration(ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, "?"); + + Dictionary props = new Hashtable(); + props.put(ModelTransformationConstants.TEMPLATE_PATH, "org.gecko.qvt.osgi.tests/PersonTransformationWithBlackbox.qvto"); + + configuration.update(props); + + ModelTransformator transformator = transformatorAware.waitForService(500); + assertNotNull(transformator); + + EObject result = transformator.startTransformation(p1); + assertNotNull(result); + assertTrue(result instanceof Person); + Person resultPerson = (Person) result; + assertEquals(GenderType.FEMALE, resultPerson.getGender()); + assertEquals("Markin", resultPerson.getFirstName()); + assertEquals("Hoffmannin", resultPerson.getLastName()); + assertNotNull(resultPerson.getAddress()); + Address resultAddress = resultPerson.getAddress(); + assertEquals("Kurt-KeicherCopy", resultAddress.getStreet()); + assertEquals("GeraCopy", resultAddress.getCity()); + } + + @Test + public void testExampleWithBlackbox02( + @InjectService ResourceSet rs, + @InjectService BasicFactory factory, + @InjectService ConfigurationAdmin admin, + @InjectService(cardinality = 0) ServiceAware transformatorAware + ) throws InterruptedException, IOException{ + Resource r1 = rs.createResource(URI.createURI("tmp.test")); + Person p1 = BasicFactory.eINSTANCE.createPerson(); + p1.setFirstName("Mark"); + p1.setLastName("Hoffmann"); + p1.setGender(GenderType.MALE); + Address address = BasicFactory.eINSTANCE.createAddress(); + address.setCity("Gera"); + address.setStreet("Kurt-Keicher"); + p1.setAddress(address); + + r1.getContents().add(p1); + + TransformationExecutor.BlackboxRegistry.INSTANCE.registerModule(BlackboxTest.class); + + Configuration configuration = admin.createFactoryConfiguration(ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, "?"); + + Dictionary props = new Hashtable(); + props.put(ModelTransformationConstants.TEMPLATE_PATH, "org.gecko.qvt.osgi.tests/PersonTransformationWithBlackbox.qvto"); + + configuration.update(props); + + ModelTransformator transformator = transformatorAware.waitForService(500); + assertNotNull(transformator); + + EObject result = transformator.startTransformation(p1); + assertNotNull(result); + assertTrue(result instanceof Person); + Person resultPerson = (Person) result; + assertEquals(GenderType.FEMALE, resultPerson.getGender()); + assertEquals("Markin", resultPerson.getFirstName()); + assertEquals("Hoffmannin", resultPerson.getLastName()); + assertNotNull(resultPerson.getAddress()); + Address resultAddress = resultPerson.getAddress(); + assertEquals("Kurt-KeicherCopy", resultAddress.getStreet()); + assertEquals("GeraCopy", resultAddress.getCity()); + } + + @Test + public void testExampleWithBlackboxAlternativeName01( + @InjectService ResourceSet rs, + @InjectService BasicFactory factory, + @InjectService ConfigurationAdmin admin, + @InjectService(cardinality = 0) ServiceAware transformatorAware + ) throws InterruptedException, IOException{ + Resource r1 = rs.createResource(URI.createURI("tmp.test")); + Person p1 = BasicFactory.eINSTANCE.createPerson(); + p1.setFirstName("Mark"); + p1.setLastName("Hoffmann"); + p1.setGender(GenderType.MALE); + Address address = BasicFactory.eINSTANCE.createAddress(); + address.setCity("Gera"); + address.setStreet("Kurt-Keicher"); + p1.setAddress(address); + + r1.getContents().add(p1); + + TransformationExecutor.BlackboxRegistry.INSTANCE.registerModule(BlackboxTest.class, "org.gecko.MyBB", "MyBBTest"); + + Configuration configuration = admin.createFactoryConfiguration(ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, "?"); + + Dictionary props = new Hashtable(); + props.put(ModelTransformationConstants.TEMPLATE_PATH, "org.gecko.qvt.osgi.tests/PersonTransformationWithBlackboxAltName.qvto"); + + configuration.update(props); + + ModelTransformator transformator = transformatorAware.waitForService(500); + assertNotNull(transformator); + EObject result = transformator.startTransformation(p1); + assertNotNull(result); + assertTrue(result instanceof Person); + Person resultPerson = (Person) result; + assertEquals(GenderType.FEMALE, resultPerson.getGender()); + assertEquals("Markin", resultPerson.getFirstName()); + assertEquals("Hoffmannin", resultPerson.getLastName()); + assertNotNull(resultPerson.getAddress()); + Address resultAddress = resultPerson.getAddress(); + assertEquals("Kurt-KeicherCopy", resultAddress.getStreet()); + assertEquals("GeraCopy", resultAddress.getCity()); + } + + @Test + public void testExampleWithBlackboxAlternativeName02( + @InjectService ResourceSet rs, + @InjectService BasicFactory factory, + @InjectService ConfigurationAdmin admin, + @InjectService(cardinality = 0) ServiceAware transformatorAware + ) throws InterruptedException, IOException{ + Resource r1 = rs.createResource(URI.createURI("tmp.test")); + Person p1 = BasicFactory.eINSTANCE.createPerson(); + p1.setFirstName("Mark"); + p1.setLastName("Hoffmann"); + p1.setGender(GenderType.MALE); + Address address = BasicFactory.eINSTANCE.createAddress(); + address.setCity("Gera"); + address.setStreet("Kurt-Keicher"); + p1.setAddress(address); + + r1.getContents().add(p1); + + TransformationExecutor.BlackboxRegistry.INSTANCE.registerModule(BlackboxTest.class); + + Configuration configuration = admin.createFactoryConfiguration(ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, "?"); + + Dictionary props = new Hashtable(); + props.put(ModelTransformationConstants.TEMPLATE_PATH, "org.gecko.qvt.osgi.tests/PersonTransformationWithBlackbox.qvto"); + + configuration.update(props); + + ModelTransformator transformator = transformatorAware.waitForService(500); + assertNotNull(transformator); + EObject result = transformator.startTransformation(p1); + assertNotNull(result); + assertTrue(result instanceof Person); + Person resultPerson = (Person) result; + assertEquals(GenderType.FEMALE, resultPerson.getGender()); + assertEquals("Markin", resultPerson.getFirstName()); + assertEquals("Hoffmannin", resultPerson.getLastName()); + assertNotNull(resultPerson.getAddress()); + Address resultAddress = resultPerson.getAddress(); + assertEquals("Kurt-KeicherCopy", resultAddress.getStreet()); + assertEquals("GeraCopy", resultAddress.getCity()); + } + + @Test + public void testExampleWithBlackboxService01( + @InjectService ResourceSet rs, + @InjectService BasicFactory factory, + @InjectService ConfigurationAdmin admin, + @InjectService(cardinality = 0) ServiceAware transformatorAware + ) throws InterruptedException, IOException{ + Resource r1 = rs.createResource(URI.createURI("tmp.test")); + Person p1 = BasicFactory.eINSTANCE.createPerson(); + p1.setFirstName("Mark"); + p1.setLastName("Hoffmann"); + p1.setGender(GenderType.MALE); + Address address = BasicFactory.eINSTANCE.createAddress(); + address.setCity("Gera"); + address.setStreet("Kurt-Keicher"); + p1.setAddress(address); + + r1.getContents().add(p1); + + Configuration configuration = admin.createFactoryConfiguration(ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, "?"); + + Dictionary props = new Hashtable(); + props.put(ModelTransformationConstants.TEMPLATE_PATH, "org.gecko.qvt.osgi.tests/PersonTransformationWithBlackboxService.qvto"); +// + BlackboxTest bbt = new BlackboxTest(); + + Dictionary properties = new Hashtable<>(); + properties.put(ModelTransformationConstants.QVT_BLACKBOX, "true"); + properties.put(ModelTransformationConstants.BLACKBOX_MODULENAME, "MyserviceBB"); + properties.put(ModelTransformationConstants.BLACKBOX_QUALIFIED_UNIT_NAME, "org.gecko.service.MyBB"); + + ServiceRegistration bbRegistration = context.registerService(BlackboxTest.class, bbt, properties); + + configuration.update(props); + + ModelTransformator transformator= transformatorAware.waitForService(500); + assertNotNull(transformator); + + EObject result = transformator.startTransformation(p1); + assertNotNull(result); + assertTrue(result instanceof Person); + Person resultPerson = (Person) result; + assertEquals(GenderType.FEMALE, resultPerson.getGender()); + assertEquals("Markin", resultPerson.getFirstName()); + assertEquals("Hoffmannin", resultPerson.getLastName()); + assertNotNull(resultPerson.getAddress()); + Address resultAddress = resultPerson.getAddress(); + assertEquals("Kurt-KeicherCopy", resultAddress.getStreet()); + assertEquals("GeraCopy", resultAddress.getCity()); + } + + @Test + public void testBlackboxWithTrafoRegistration( + @InjectService ResourceSet rs, + @InjectService BasicFactory factory, + @InjectService(cardinality = 0, filter = "(" + ModelTransformationConstants.TRANSFORMATOR_ID + "=org.gecko.qvt.osgi.tests/PersonTransformationWithBlackboxComponentRegistration.qvto)") ServiceAware transformatorAware + ) throws InterruptedException, IOException{ + Resource r1 = rs.createResource(URI.createURI("tmp.test")); + Person p1 = BasicFactory.eINSTANCE.createPerson(); + p1.setFirstName("Mark"); + p1.setLastName("Hoffmann"); + p1.setGender(GenderType.MALE); + Address address = BasicFactory.eINSTANCE.createAddress(); + address.setCity("Gera"); + address.setStreet("Kurt-Keicher"); + p1.setAddress(address); + + r1.getContents().add(p1); + + context.registerService(Condition.class, Condition.INSTANCE, new Hashtable<>(Collections.singletonMap(Condition.CONDITION_ID, "test"))); + + ModelTransformator transformator= transformatorAware.waitForService(1000); + assertNotNull(transformator); + + EObject result = transformator.startTransformation(p1); + assertNotNull(result); + assertTrue(result instanceof Person); + Person resultPerson = (Person) result; + assertEquals(GenderType.FEMALE, resultPerson.getGender()); + assertEquals("Markin", resultPerson.getFirstName()); + assertEquals("HoffmannBlackBox", resultPerson.getLastName()); + } + +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/src/org/gecko/qvt/osgi/tests/bbox/BlackboxComponentTest.java b/org.gecko.qvt.osgi.tests/src/org/gecko/qvt/osgi/tests/bbox/BlackboxComponentTest.java new file mode 100644 index 00000000..e45d6444 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/src/org/gecko/qvt/osgi/tests/bbox/BlackboxComponentTest.java @@ -0,0 +1,35 @@ +package org.gecko.qvt.osgi.tests.bbox; + +import org.eclipse.m2m.qvt.oml.blackbox.java.Module; +import org.eclipse.m2m.qvt.oml.blackbox.java.Operation; +import org.gecko.emf.osgi.example.model.basic.BasicPackage; +import org.gecko.emf.osgi.example.model.basic.Person; +import org.gecko.qvt.osgi.annotations.QvtBlackbox; +import org.gecko.qvt.osgi.annotations.TemplatePath; +import org.gecko.qvt.osgi.annotations.TransformatorId; +import org.gecko.qvt.osgi.annotations.UnitQualifiedName; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.propertytypes.SatisfyingConditionTarget; + +/** + *

QVT Blackbox for the sdg tlc communication state.

+ *

Copyright (c) SWARCO TRAFFIC SYSTEMS GMBH 2017

+ * + * @author Mark Hoffmann + * @version 10.11.2017 + */ +@Component(service = BlackboxComponentTest.class) +@SatisfyingConditionTarget("(osgi.condition.id=test)") +@QvtBlackbox +@TemplatePath("org.gecko.qvt.osgi.tests/PersonTransformationWithBlackboxComponentRegistration.qvto") +@TransformatorId("testTrafo") +@UnitQualifiedName("bla.blub.BlackboxTest") +@Module(packageURIs={BasicPackage.eNS_URI}) +public class BlackboxComponentTest { + + @Operation(contextual=true) + public static String getModifiedLastName(Person self) { + return self.getLastName() + "BlackBox"; + } + +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/src/org/gecko/qvt/osgi/tests/bbox/BlackboxTest.java b/org.gecko.qvt.osgi.tests/src/org/gecko/qvt/osgi/tests/bbox/BlackboxTest.java new file mode 100644 index 00000000..b1f7404a --- /dev/null +++ b/org.gecko.qvt.osgi.tests/src/org/gecko/qvt/osgi/tests/bbox/BlackboxTest.java @@ -0,0 +1,36 @@ +package org.gecko.qvt.osgi.tests.bbox; + +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.m2m.qvt.oml.blackbox.java.Module; +import org.eclipse.m2m.qvt.oml.blackbox.java.Operation; +import org.gecko.emf.osgi.example.model.basic.Address; +import org.gecko.emf.osgi.example.model.basic.BasicPackage; +import org.gecko.qvt.osgi.annotations.QvtBlackbox; +import org.gecko.qvt.osgi.annotations.TemplatePath; +import org.gecko.qvt.osgi.annotations.UnitQualifiedName; +import org.osgi.service.component.annotations.Component; + +/** + *

QVT Blackbox for the sdg tlc communication state.

+ *

Copyright (c) SWARCO TRAFFIC SYSTEMS GMBH 2017

+ * + * @author Mark Hoffmann + * @version 10.11.2017 + */ +@Module(packageURIs={BasicPackage.eNS_URI}) +public class BlackboxTest { + + /** + * Contextual method that can be called on each {@link com.swarco.sdg.sdgtlc.CommunicationStateType} + * @param self the instance the method is called from + * @return the int value of the {@link com.swarco.sdg.sdgtlc.CommunicationStateType} + */ + @Operation(contextual=true) + public static Address getCopyAddress(Address self) { + Address copy = EcoreUtil.copy(self); + copy.setCity(self.getCity() + "Copy"); + copy.setStreet(self.getStreet() + "Copy"); + return copy; + } + +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/test.bndrun b/org.gecko.qvt.osgi.tests/test.bndrun new file mode 100644 index 00000000..ad162781 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/test.bndrun @@ -0,0 +1,62 @@ +-library: enableOSGi-Test + +-resolve.effective: active + +-runrequires: bnd.identity;id='org.gecko.qvt.osgi.tests' + +-runbundles.test: \ + org.gecko.qvt.osgi.tests;version=snapshot + +-runfw: org.apache.felix.framework + +-runee: JavaSE-17 + +-runbundles: \ + junit-jupiter-api;version='[5.10.1,5.10.2)',\ + junit-jupiter-params;version='[5.10.1,5.10.2)',\ + junit-platform-commons;version='[1.10.1,1.10.2)',\ + lpg.runtime.java;version='[2.0.17,2.0.18)',\ + org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\ + org.apache.felix.scr;version='[2.2.6,2.2.7)',\ + org.eclipse.m2m.qvt.oml.cst.parser;version='[3.9.0,3.9.1)',\ + org.gecko.qvt.osgi.api;version=snapshot,\ + org.gecko.qvt.osgi.component;version=snapshot,\ + org.gecko.qvt.osgi.tests;version=snapshot,\ + org.opentest4j;version='[1.3.0,1.3.1)',\ + org.osgi.service.component;version='[1.5.1,1.5.2)',\ + org.osgi.service.log;version='[1.5.0,1.5.1)',\ + org.osgi.test.common;version='[1.2.1,1.2.2)',\ + org.osgi.test.junit5;version='[1.2.1,1.2.2)',\ + org.osgi.test.junit5.cm;version='[1.2.1,1.2.2)',\ + org.osgi.util.converter;version='[1.0.9,1.0.10)',\ + org.osgi.util.function;version='[1.2.0,1.2.1)',\ + org.osgi.util.promise;version='[1.3.0,1.3.1)',\ + org.eclipse.emf.ecore.change;version='[2.15.0,2.15.1)',\ + org.eclipse.m2m.qvt.oml;version='[3.10.8,3.10.9)',\ + org.eclipse.m2m.qvt.oml.common;version='[3.10.2,3.10.3)',\ + org.eclipse.m2m.qvt.oml.ecore.imperativeocl;version='[3.10.2,3.10.3)',\ + org.eclipse.m2m.qvt.oml.emf.util;version='[3.10.6,3.10.7)',\ + org.eclipse.m2m.qvt.oml.ocl;version='[3.10.2,3.10.3)',\ + org.eclipse.ocl;version='[3.19.0,3.19.1)',\ + org.eclipse.ocl.common;version='[1.19.0,1.19.1)',\ + org.eclipse.ocl.ecore;version='[3.19.0,3.19.1)',\ + org.eclipse.equinox.supplement;version='[1.10.700,1.10.701)',\ + de.dim.eclipse.osgi;version='[3.12.50,3.12.51)',\ + org.eclipse.equinox.common;version='[3.14.0,3.14.1)',\ + org.eclipse.equinox.registry;version='[3.10.200,3.10.201)',\ + org.eclipse.emf.ecore.fragment;version=snapshot,\ + org.eclipse.ocl.fragment;version=snapshot,\ + junit-jupiter-engine;version='[5.10.1,5.10.2)',\ + junit-platform-engine;version='[1.10.1,1.10.2)',\ + junit-platform-launcher;version='[1.10.1,1.10.2)',\ + org.eclipse.emf.common;version='[2.29.0,2.29.1)',\ + org.eclipse.emf.ecore;version='[2.35.0,2.35.1)',\ + org.eclipse.emf.ecore.xmi;version='[2.36.0,2.36.1)',\ + org.gecko.emf.osgi.api;version='[6.1.1,6.1.2)',\ + org.gecko.emf.osgi.component.minimal;version='[6.1.1,6.1.2)',\ + org.gecko.emf.osgi.example.model.basic;version='[6.1.0,6.1.1)',\ + org.osgi.service.cm;version='[1.6.1,1.6.2)',\ + org.gecko.emf.osgi.component.config;version='[6.1.1,6.1.2)',\ + de.dim.eclipse.core.runtime;version='[3.14.0,3.14.1)',\ + de.dim.equinox.common;version='[3.9.0,3.9.1)',\ + org.eclipse.core.runtime;version='[3.14.0,3.14.1)' diff --git a/org.gecko.qvt.osgi.tests/transforms/PersonTransformation.qvto b/org.gecko.qvt.osgi.tests/transforms/PersonTransformation.qvto new file mode 100644 index 00000000..a2b84216 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/transforms/PersonTransformation.qvto @@ -0,0 +1,14 @@ +modeltype ECORE "strict" uses ecore('http://www.eclipse.org/emf/2002/Ecore'); +modeltype TEST uses "http://gecko.org/example/model/basic"; + +transformation PersonTransformation(in rawIn : TEST, out rawOut : TEST); + +main() { + rawIn.rootObjects()[Person]->map mapToFemalePerson(); +} + +mapping Person::mapToFemalePerson() : Person { + firstName := self.firstName + "in"; + lastName := self.lastName + "in"; + gender := GenderType::FEMALE; +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackbox.qvto b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackbox.qvto new file mode 100644 index 00000000..3c5e983e --- /dev/null +++ b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackbox.qvto @@ -0,0 +1,17 @@ +import org.gecko.qvt.osgi.tests.bbox.BlackboxTest; + +modeltype ECORE "strict" uses ecore('http://www.eclipse.org/emf/2002/Ecore'); +modeltype TEST uses "http://gecko.org/example/model/basic"; + +transformation PersonTransformationWithBlackbox(in rawIn : TEST, out rawOut : TEST); + +main() { + rawIn.rootObjects()[Person]->map mapToFemalePerson(); +} + +mapping Person::mapToFemalePerson() : Person { + firstName := self.firstName + "in"; + lastName := self.lastName + "in"; + gender := GenderType::FEMALE; + address := self.address.getCopyAddress(); +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackboxAltName.qvto b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackboxAltName.qvto new file mode 100644 index 00000000..c0d31e7a --- /dev/null +++ b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackboxAltName.qvto @@ -0,0 +1,17 @@ +import org.gecko.MyBB; + +modeltype ECORE "strict" uses ecore('http://www.eclipse.org/emf/2002/Ecore'); +modeltype TEST uses "http://gecko.org/example/model/basic"; + +transformation PersonTransformationWithBlackboxAltName(in rawIn : TEST, out rawOut : TEST); + +main() { + rawIn.rootObjects()[Person]->map mapToFemalePerson(); +} + +mapping Person::mapToFemalePerson() : Person { + firstName := self.firstName + "in"; + lastName := self.lastName + "in"; + gender := GenderType::FEMALE; + address := self.address.getCopyAddress(); +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackboxComponentRegistration.qvto b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackboxComponentRegistration.qvto new file mode 100644 index 00000000..ef55f1ee --- /dev/null +++ b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackboxComponentRegistration.qvto @@ -0,0 +1,15 @@ +import bla.blub.BlackboxTest; + +modeltype ECORE "strict" uses ecore('http://www.eclipse.org/emf/2002/Ecore'); +modeltype TEST uses "http://gecko.org/example/model/basic"; + +transformation PersonTransformationWithBlackboxComponentRegistration(in rawIn : TEST, out rawOut : TEST); + +main() { + rawIn.rootObjects()[Person]->map mapToFemalePerson(); +} + +mapping Person::mapToFemalePerson() : Person { + firstName := self.firstName + "in"; + lastName := self.getModifiedLastName() +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackboxService.qvto b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackboxService.qvto new file mode 100644 index 00000000..28f95ea7 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithBlackboxService.qvto @@ -0,0 +1,18 @@ +import org.gecko.service.MyBB; +//import org.eclipselabs.qvt.osgi.tests.bbox.BlackboxTest; + +modeltype ECORE "strict" uses ecore('http://www.eclipse.org/emf/2002/Ecore'); +modeltype TEST uses "http://gecko.org/example/model/basic"; + +transformation PersonTransformationWithBlackboxService(in rawIn : TEST, out rawOut : TEST); + +main() { + rawIn.rootObjects()[Person]->map mapToFemalePerson(); +} + +mapping Person::mapToFemalePerson() : Person { + firstName := self.firstName + "in"; + lastName := self.lastName + "in"; + gender := GenderType::FEMALE; + address := self.address.getCopyAddress(); +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithDeps.qvto b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithDeps.qvto new file mode 100644 index 00000000..8d71463c --- /dev/null +++ b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithDeps.qvto @@ -0,0 +1,17 @@ +import lib.AddressTransformation; + +modeltype ECORE "strict" uses ecore('http://www.eclipse.org/emf/2002/Ecore'); +modeltype TEST uses "http://gecko.org/example/model/basic"; + +transformation PersonTransformationWithDeps(in rawIn : TEST, out rawOut : TEST); + +main() { + rawIn.rootObjects()[Person]->map mapToFemalePerson(); +} + +mapping Person::mapToFemalePerson() : Person { + firstName := self.firstName + "in"; + lastName := self.lastName + "in"; + gender := GenderType::FEMALE; + address := self.address.map mapToAddressNew(); +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithDepsLib.qvto b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithDepsLib.qvto new file mode 100644 index 00000000..edd1e7ae --- /dev/null +++ b/org.gecko.qvt.osgi.tests/transforms/PersonTransformationWithDepsLib.qvto @@ -0,0 +1,18 @@ +//import lib.AddressMapper; +import lib.AddressTransformationLib; + +modeltype ECORE "strict" uses ecore('http://www.eclipse.org/emf/2002/Ecore'); +modeltype TEST uses "http://gecko.org/example/model/basic"; + +transformation PersonTransformationWithDepsLib(in rawIn : TEST, out rawOut : TEST); + +main() { + rawIn.rootObjects()[Person]->map mapToFemalePerson(); +} + +mapping Person::mapToFemalePerson() : Person { + firstName := self.firstName + "in"; + lastName := self.lastName + "in"; + gender := GenderType::FEMALE; + address := self.address.map mapToAddressNew(); +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/transforms/lib/AddressTransformation.qvto b/org.gecko.qvt.osgi.tests/transforms/lib/AddressTransformation.qvto new file mode 100644 index 00000000..71e13434 --- /dev/null +++ b/org.gecko.qvt.osgi.tests/transforms/lib/AddressTransformation.qvto @@ -0,0 +1,9 @@ +modeltype ECORE "strict" uses ecore('http://www.eclipse.org/emf/2002/Ecore'); +modeltype TEST uses "http://gecko.org/example/model/basic"; + +transformation AddressTransformation(in rawIn : TEST, out rawOut : TEST); + +mapping Address::mapToAddressNew() : Address { + street := "Sesam" + self.street; + city := "MyBeautiful" + self.city; +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi.tests/transforms/lib/AddressTransformationLib.qvto b/org.gecko.qvt.osgi.tests/transforms/lib/AddressTransformationLib.qvto new file mode 100644 index 00000000..fd0d777b --- /dev/null +++ b/org.gecko.qvt.osgi.tests/transforms/lib/AddressTransformationLib.qvto @@ -0,0 +1,9 @@ +modeltype ECORE "strict" uses ecore('http://www.eclipse.org/emf/2002/Ecore'); +modeltype TEST uses "http://gecko.org/example/model/basic"; + +library AddressMapper; + +mapping Address::mapToAddressNew() : Address { + street := "Sesam" + self.street; + city := "MyBeautiful" + self.city; +} \ No newline at end of file diff --git a/org.gecko.qvt.osgi/.classpath b/org.gecko.qvt.osgi/.classpath new file mode 100644 index 00000000..0749e2fe --- /dev/null +++ b/org.gecko.qvt.osgi/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/org.gecko.qvt.osgi/.gitignore b/org.gecko.qvt.osgi/.gitignore new file mode 100644 index 00000000..90dde36e --- /dev/null +++ b/org.gecko.qvt.osgi/.gitignore @@ -0,0 +1,3 @@ +/bin/ +/bin_test/ +/generated/ diff --git a/org.gecko.qvt.osgi/.project b/org.gecko.qvt.osgi/.project new file mode 100644 index 00000000..cc87cbf6 --- /dev/null +++ b/org.gecko.qvt.osgi/.project @@ -0,0 +1,23 @@ + + + org.gecko.qvt.osgi + + + + + + org.eclipse.jdt.core.javabuilder + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + bndtools.core.bndnature + + diff --git a/org.gecko.qvt.osgi/.settings/org.eclipse.core.resources.prefs b/org.gecko.qvt.osgi/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..1554c6f8 --- /dev/null +++ b/org.gecko.qvt.osgi/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/bnd.bnd=UTF-8 diff --git a/org.gecko.qvt.osgi/.settings/org.eclipse.jdt.core.prefs b/org.gecko.qvt.osgi/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..3a215370 --- /dev/null +++ b/org.gecko.qvt.osgi/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/org.gecko.qvt.osgi/.settings/org.eclipse.jdt.ui.prefs b/org.gecko.qvt.osgi/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000..25b8c0de --- /dev/null +++ b/org.gecko.qvt.osgi/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,10 @@ +content_assist_proposals_background=255,255,255 +content_assist_proposals_foreground=0,0,0 +eclipse.preferences.version=1 +org.eclipse.jdt.ui.formatterprofiles.version=13 +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.text.code_templates_migrated=true +org.eclipse.jdt.ui.text.custom_code_templates= +spelling_locale_initialized=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true diff --git a/org.gecko.qvt.osgi/api.bnd b/org.gecko.qvt.osgi/api.bnd new file mode 100644 index 00000000..49f1e6c3 --- /dev/null +++ b/org.gecko.qvt.osgi/api.bnd @@ -0,0 +1,10 @@ +Bundle-Version: 4.1.1.SNAPSHOT +Bundle-Copyright: Data In Motion Consulting +Bundle-License: Eclipse Public License v1.0 +Bundle-Name: M2M QVT API +Bundle-Description: Model to Model QVT Transformation API +Bundle-Vendor: Data In Motion Consulting GmbH +Export-Package: \ + org.gecko.qvt.osgi.api,\ + org.gecko.qvt.osgi.annotations +Require-Capability: emf.m2m;filter:='(emf.m2m=qvto)' diff --git a/org.gecko.qvt.osgi/bnd.bnd b/org.gecko.qvt.osgi/bnd.bnd new file mode 100644 index 00000000..c67fe30a --- /dev/null +++ b/org.gecko.qvt.osgi/bnd.bnd @@ -0,0 +1,31 @@ +-library: enable-emf + +-buildpath: \ + org.eclipse.m2m.qvt.oml,\ + org.eclipse.m2m.qvt.oml.ecore.imperativeocl,\ + org.gecko.util.pool,\ + org.osgi.resource;version=latest,\ + org.osgi.framework;version=latest,\ + org.osgi.service.component;version=latest,\ + org.osgi.service.cm;version=latest,\ + org.osgi.util.tracker;version=latest,\ + org.osgi.namespace.extender;version=latest,\ + org.osgi.service.coordinator;version=latest,\ + org.eclipse.emf.compare,\ + org.eclipse.m2m.qvt.oml.common,\ + org.eclipse.m2m.qvt.oml.cst.parser,\ + org.eclipse.m2m.qvt.oml.emf.util,\ + org.eclipse.m2m.qvt.oml.ocl,\ + org.eclipse.ocl,\ + org.eclipse.ocl.common,\ + org.eclipse.ocl.ecore + +-dsannotations-options: inherit + +javac.source: 1.8 +javac.target: 1.8 + +Bundle-Version: 2.0.0.SNAPSHOT +-sub: *.bnd + +-workingset: qvt \ No newline at end of file diff --git a/org.gecko.qvt.osgi/component.bnd b/org.gecko.qvt.osgi/component.bnd new file mode 100644 index 00000000..eed628b2 --- /dev/null +++ b/org.gecko.qvt.osgi/component.bnd @@ -0,0 +1,21 @@ +Bundle-Version: 1.0.6.SNAPSHOT +Bundle-Copyright: Data In Motion Consulting +Bundle-License: Eclipse Public License v1.0 +Bundle-Name: M2M QVT Component +Bundle-Description: Model to Model QVT transformation service component +Bundle-Vendor: Data In Motion Consulting GmbH +Private-Package: \ + org.gecko.qvt.osgi.component,\ + org.gecko.qvt.osgi.util +Require-Capability: \ + osgi.identity;filter:='(osgi.identity=org.eclipse.emf.ecore.change)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.m2m.qvt.oml)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.m2m.qvt.oml.common)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.m2m.qvt.oml.emf.util)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.m2m.qvt.oml.ocl)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.m2m.qvt.oml.ecore.imperativeocl)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.m2m.qvt.oml.cst.parser)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.ocl)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.ocl.common)',\ + osgi.identity;filter:='(osgi.identity=org.eclipse.ocl.ecore)',\ + osgi.identity;filter:='(osgi.identity=lpg.runtime.java)' diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/ModuleName.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/ModuleName.java new file mode 100644 index 00000000..ca59bced --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/ModuleName.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2012 - 2024 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.osgi.service.component.annotations.ComponentPropertyType; + +@Documented +@Retention(CLASS) +@Target(TYPE) + +/** + * Sets the module name for this blackbox. + * + * @author Juergen Albert + * @since 4 Feb 2024 + */ +@ComponentPropertyType +@RequireQVT +@QvtBlackbox +public @interface ModuleName { + + /** + * Prefix for the property name. This value is prepended to each property + * name. + */ + String PREFIX_ = "qvt.blackbox."; + + String value(); + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/QvtBlackbox.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/QvtBlackbox.java new file mode 100644 index 00000000..3c8fbf8e --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/QvtBlackbox.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2012 - 2024 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.osgi.service.component.annotations.ComponentPropertyType; + +@Documented +@Retention(CLASS) +@Target(TYPE) +/** + * Marks a Component as a Blackbox + * + * @author Juergen Albert + * @since 4 Feb 2024 + */ +@ComponentPropertyType +@RequireQVT +public @interface QvtBlackbox { + + boolean value() default true; + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/RequireQVT.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/RequireQVT.java new file mode 100644 index 00000000..b198cb19 --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/RequireQVT.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2012 - 2024 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.annotations; + + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.gecko.qvt.osgi.api.ModelTransformationNamespace; +import org.osgi.annotation.bundle.Requirement; + +/** + * + * @author Juergen Albert + * @since 9 Feb 2018 + */ +@Documented +@Retention(RetentionPolicy.CLASS) +@Target({ + ElementType.TYPE, ElementType.PACKAGE +}) +@Requirement(namespace = ModelTransformationNamespace.NAMESPACE, name = "qvto") +public @interface RequireQVT { + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/TemplatePath.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/TemplatePath.java new file mode 100644 index 00000000..6071a128 --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/TemplatePath.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2012 - 2024 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.osgi.service.component.annotations.ComponentPropertyType; + +@Documented +@Retention(CLASS) +@Target(TYPE) + +/** + * Sets a list of templates to registered with this blackbox. + * This will make sure, that the Blackbox is available to the templates on creation. + * + * @author Juergen Albert + * @since 4 Feb 2024 + */ +@ComponentPropertyType +@RequireQVT +@QvtBlackbox +public @interface TemplatePath { + + /** + * Prefix for the property name. This value is prepended to each property + * name. + */ + String PREFIX_ = "qvt."; + + String value(); + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/TemplateUri.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/TemplateUri.java new file mode 100644 index 00000000..20f586d8 --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/TemplateUri.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2012 - 2024 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.osgi.service.component.annotations.ComponentPropertyType; + +@Documented +@Retention(CLASS) +@Target(TYPE) + +/** + * Sets a list of templates to registered with this blackbox. + * This will make sure, that the Blackbox is available to the templates on creation. + * + * If this is set, the {@link TemplatePath} properties will be ignored. + * + * @author Juergen Albert + * @since 4 Feb 2024 + */ +@ComponentPropertyType +@RequireQVT +@QvtBlackbox +public @interface TemplateUri { + + /** + * Prefix for the property name. This value is prepended to each property + * name. + */ + String PREFIX_ = "qvt."; + + String value(); + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/TransformatorId.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/TransformatorId.java new file mode 100644 index 00000000..98085a04 --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/TransformatorId.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2012 - 2024 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.osgi.service.component.annotations.ComponentPropertyType; + +@Documented +@Retention(CLASS) +@Target(TYPE) + +/** + * Sets a list of templates to registered with this blackbox. + * This will make sure, that the Blackbox is available to the templates on creation. + * + * @author Juergen Albert + * @since 4 Feb 2024 + */ +@ComponentPropertyType +@RequireQVT +@QvtBlackbox +public @interface TransformatorId { + + /** + * Prefix for the property name. This value is prepended to each property + * name. + */ + String PREFIX_ = "qvt.blackbox."; + + String[] value(); + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/UnitQualifiedName.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/UnitQualifiedName.java new file mode 100644 index 00000000..5bb89acf --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/UnitQualifiedName.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2012 - 2024 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.annotations; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import org.osgi.service.component.annotations.ComponentPropertyType; + +@Documented +@Retention(CLASS) +@Target(TYPE) + +/** + * Sets the unit qualified name. If nothing is given the qualified classname is used. + * + * @author Juergen Albert + * @since 4 Feb 2024 + */ +@ComponentPropertyType +@RequireQVT +@QvtBlackbox +public @interface UnitQualifiedName { + + /** + * Prefix for the property name. This value is prepended to each property + * name. + */ + String PREFIX_ = "qvt.blackbox."; + + String value(); + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/package-info.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/package-info.java new file mode 100644 index 00000000..1c8c6b0d --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/annotations/package-info.java @@ -0,0 +1,2 @@ +@org.osgi.annotation.versioning.Version("1.0.0") +package org.gecko.qvt.osgi.annotations; diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/ModelTransformationConstants.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/ModelTransformationConstants.java new file mode 100644 index 00000000..8e2f9e46 --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/ModelTransformationConstants.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2012 - 2024 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.api; + +/** + * Constants for registering blackboxes + * @author Mark Hoffmann + * @author Juergen Albert + * @since 12.11.2017 + */ +public interface ModelTransformationConstants { + + /* + * The property name of the blackbox registered service + */ + public static final String QVT_BLACKBOX_CONDITION = "qvt.blackbox.condition"; + + /* + * The property name of the blackbox registered service + */ + public static final String QVT_BLACKBOX = "qvt.blackbox"; + + /* + * The class of the Blackbox for easy targeting + */ + public static final String BLACKBOX_CLASS_NAME = "qvt.blackbox.class.name"; + + /* + * The name of the Blackbox + */ + public static final String BLACKBOX_MODULENAME = "qvt.blackbox.module.name"; + + /* + * The name to use as import in qvto templates: + * Usually this is the full qualified class name of the Blackbox class + */ + public static final String BLACKBOX_QUALIFIED_UNIT_NAME = "qvt.blackbox.unit.qualified.name"; + + /* + * The path to a template qvto file in style like this :/.qvto + */ + public static final String TEMPLATE_PATH = "qvt.template.path"; + + /* + * A URI for a template. Takes presedent over the {@lin ModelTransformationConstants#TEMPLATE_PATH} if set. + */ + public static final String TEMPLATE_URI = "qvt.template.uri"; + /* + * The target for the needed models in ldap style e.g. (&(emf.model.name=modelA)(emf.model.name=modelB)) + */ + public static final String MODEL_TARGET = "qvt.model.target"; + + public static final String TRANSFORMATOR_COMPONENT_NAME = "QVTModelTransformator"; + + /** If a trafo is registered with a blackbox, it can be identified via this property. If non was given, that uri or path is used as the id */ + public static final String TRANSFORMATOR_ID = "transformator.id"; + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/ModelTransformationNamespace.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/ModelTransformationNamespace.java new file mode 100644 index 00000000..90435483 --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/ModelTransformationNamespace.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2012 - 2024 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.api; + +/** + * Namespaces around the Model Requirement + * @author Juergen Albert + * @since 12.11.2017 + */ +public interface ModelTransformationNamespace { + + public static final String NAMESPACE = "emf.m2m"; + + public static final String COMPANION = NAMESPACE + ".companion"; + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/ModelTransformator.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/ModelTransformator.java new file mode 100644 index 00000000..76043de7 --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/ModelTransformator.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2012 - 2017 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.api; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; + +/** + * Model transformator that can be used for model-2-model-transformation + * @author Mark Hoffmann + * @since 20.10.2017 + */ +public interface ModelTransformator { + + /** + * Starts the batch transformation programmatic + * http://wiki.eclipse.org/QVTOML/Examples/InvokeInJava + * https://www.eclipse.org/forums/index.php/t/853024/ + * The objects are detached after the transformation. + * @param inObjects list of objects to transform as batch + */ + public List startTransformations(List inObjects); + + /** + * Starts the transformation programmatic + * http://wiki.eclipse.org/QVTOML/Examples/InvokeInJava + * https://www.eclipse.org/forums/index.php/t/853024/ + * The object is detached after the transformation. + * @param inObject the object to be transformed + */ + public EObject startTransformation(EObject inObject); + + /** + * Starts the transformation programmatic + * http://wiki.eclipse.org/QVTOML/Examples/InvokeInJava + * https://www.eclipse.org/forums/index.php/t/853024/ + * The object is detached after the transformation. + * @param inObject the object to be transformed + */ + public EObject startTransformation(List inObjects); +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/TransformationException.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/TransformationException.java new file mode 100644 index 00000000..1782351f --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/TransformationException.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2012 - 2018 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.api; + +/** + * Exception when an error during the transformation occurs + * @author Mark Hoffmann + * @since 22.11.2018 + */ +public class TransformationException extends Exception { + + /** serialVersionUID */ + private static final long serialVersionUID = 2631794786091593104L; + + /** + * Creates a new instance. + */ + public TransformationException(String message) { + super(message); + } + + /** + * Creates a new instance. + */ + public TransformationException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/package-info.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/package-info.java new file mode 100644 index 00000000..709e264f --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/api/package-info.java @@ -0,0 +1,2 @@ +@org.osgi.annotation.versioning.Version("3.1.0") +package org.gecko.qvt.osgi.api; diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/component/BlackBoxWhiteboard.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/component/BlackBoxWhiteboard.java new file mode 100644 index 00000000..1bc886f9 --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/component/BlackBoxWhiteboard.java @@ -0,0 +1,225 @@ +/** + * Copyright (c) 2012 - 2017 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.component; + +import java.io.IOException; +import java.util.Collections; +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.m2m.internal.qvt.oml.blackbox.java.JavaBlackboxProvider; +import org.eclipse.m2m.qvt.oml.TransformationExecutor.BlackboxRegistry; +import org.eclipse.m2m.qvt.oml.blackbox.java.Module; +import org.gecko.emf.osgi.constants.EMFNamespaces; +import org.gecko.qvt.osgi.api.ModelTransformationConstants; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.condition.Condition; +import org.osgi.util.tracker.ServiceTracker; + +/** + * A Whiteboard for BlackBox Services + * @author Juergen Albert + * @since 02.02.2024 + */ +@Component +public class BlackBoxWhiteboard { + + private final Logger logger = Logger.getLogger(BlackBoxWhiteboard.class.getName()); + private volatile ServiceTracker blackboxTracker; + + ServiceRegistration conditionRegistration = null; + + List blackBoxClassNames = new CopyOnWriteArrayList<>(); + List moduleNames = new CopyOnWriteArrayList<>(); + List unitQualifiedNames = new CopyOnWriteArrayList<>(); + + Map, Configuration> configs = new ConcurrentHashMap<>(); + + @Activate + public void activate(BundleContext context) { + try { + + conditionRegistration = context.registerService(Condition.class, Condition.INSTANCE, new Hashtable<>(Collections.singletonMap(Condition.CONDITION_ID, ModelTransformationConstants.QVT_BLACKBOX_CONDITION))); + + Filter bbFilter = FrameworkUtil.createFilter("(" + ModelTransformationConstants.QVT_BLACKBOX + "=true)"); + BlackboxRegistry blackboxRegistry = BlackboxRegistry.INSTANCE; + blackboxTracker = new ServiceTracker(context, bbFilter, null) { + + /* + * (non-Javadoc) + * @see org.osgi.util.tracker.ServiceTracker#addingService(org.osgi.framework.ServiceReference) + */ + @Override + public Object addingService(ServiceReference reference) { + String moduleName = (String) reference.getProperty(ModelTransformationConstants.BLACKBOX_MODULENAME); + String unitQualifiedName = (String) reference.getProperty(ModelTransformationConstants.BLACKBOX_QUALIFIED_UNIT_NAME); + Object blackbox = context.getService(reference); + if (moduleName == null ) { + moduleName = blackbox.getClass().getSimpleName(); + } + + if (unitQualifiedName == null) { + unitQualifiedName = blackbox.getClass().getPackage().getName() + JavaBlackboxProvider.CLASS_NAME_SEPARATOR + moduleName; + } + + if (unitQualifiedName != null) { + blackboxRegistry.registerModule(blackbox.getClass(), unitQualifiedName, moduleName); + } + moduleNames.add(moduleName); + unitQualifiedNames.add(unitQualifiedName); + blackBoxClassNames.add(blackbox.getClass().getName()); + updateCondition(); + if(reference.getProperty(ModelTransformationConstants.TEMPLATE_PATH) != null || reference.getProperty(ModelTransformationConstants.TEMPLATE_URI) != null) { + registerTransformator(reference, blackbox); + } + return blackbox; + } + + /* + * (non-Javadoc) + * @see org.osgi.util.tracker.ServiceTracker#modifiedService(org.osgi.framework.ServiceReference, java.lang.Object) + */ + @Override + public void modifiedService(ServiceReference reference, Object service) { + try { + updateConfiguration(reference, service, configs.get(reference)); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + super.modifiedService(reference, service); + } + + /* + * (non-Javadoc) + * @see org.osgi.util.tracker.ServiceTracker#removedService(org.osgi.framework.ServiceReference, java.lang.Object) + */ + @Override + public void removedService(ServiceReference reference, Object service) { + Configuration removed = configs.remove(reference); + if(removed != null) { + try { + removed.delete(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + context.ungetService(reference); + super.removedService(reference, service); + } + }; + blackboxTracker.open(); + } catch (InvalidSyntaxException e) { + logger.log(Level.SEVERE, "Cannot open tracker to track blackboxes, because of wrong filter", e); + } catch (Exception e) { + logger.log(Level.SEVERE, "An error occured trying to track blackbox services", e); + } + } + + private void registerTransformator(ServiceReference reference, Object blackbox) { + ServiceReference configAdminRef = reference.getBundle().getBundleContext().getServiceReference(ConfigurationAdmin.class); + ConfigurationAdmin configAdmin = reference.getBundle().getBundleContext().getService(configAdminRef); + + try { + Configuration configuration = configAdmin.createFactoryConfiguration(ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, "?"); + configs.put(reference, configuration); + updateConfiguration(reference, blackbox, configuration); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + reference.getBundle().getBundleContext().ungetService(configAdminRef); + } + } + + private void updateConfiguration(ServiceReference reference, Object blackbox, + Configuration configuration) throws IOException { + if(configuration != null) { + Module annotation = blackbox.getClass().getAnnotation(Module.class); + String[] packageURIs = (annotation == null) ? new String[] {} : annotation.packageURIs(); + + Dictionary props = new Hashtable(); + String id = (String) reference.getProperty(ModelTransformationConstants.TRANSFORMATOR_ID); + String uri = (String) reference.getProperty(ModelTransformationConstants.TEMPLATE_URI); + String path = (String) reference.getProperty(ModelTransformationConstants.TEMPLATE_PATH); + + if(id == null) { + id = uri == null ? path : uri; + } + props.put(ModelTransformationConstants.TRANSFORMATOR_ID, id); + if(uri != null) { + props.put(ModelTransformationConstants.TEMPLATE_URI, uri); + } else { + props.put(ModelTransformationConstants.TEMPLATE_PATH, path); + } + String modelFilter = createModelFilter(packageURIs); + props.put(ModelTransformationConstants.MODEL_TARGET, modelFilter); + props.put("osgi.ds.satisfying.condition", "(" + ModelTransformationConstants.BLACKBOX_CLASS_NAME + "=" + blackbox.getClass().getName() + ")"); + + configuration.update(props); + } + } + + /** + * @param packageURIs + * @return + */ + private String createModelFilter(String[] packageURIs) { + if(packageURIs.length == 1) { + return createModelFilter(packageURIs[0]); + } + StringBuilder builder = new StringBuilder("(&"); + for (int i = 0; i < packageURIs.length; i++) { + builder.append(createModelFilter(packageURIs[i])); + } + builder.append(")"); + return builder.toString(); + } + + private String createModelFilter(String packageURI) { + return "(" + EMFNamespaces.EMF_MODEL_NSURI + "=" + packageURI + ")"; + + } + + @Deactivate + public void deactivate() { + if (blackboxTracker != null) { + blackboxTracker.close(); + } + } + + private void updateCondition() { + Dictionary props = new Hashtable<>(); + props.put(Condition.CONDITION_ID, ModelTransformationConstants.QVT_BLACKBOX_CONDITION); + props.put(ModelTransformationConstants.BLACKBOX_CLASS_NAME, blackBoxClassNames.toArray(new String[blackBoxClassNames.size()])); + props.put(ModelTransformationConstants.BLACKBOX_MODULENAME, moduleNames.toArray(new String[moduleNames.size()])); + props.put(ModelTransformationConstants.BLACKBOX_QUALIFIED_UNIT_NAME, unitQualifiedNames.toArray(new String[unitQualifiedNames.size()])); + conditionRegistration.setProperties(props); + } +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/component/QVTModelTransformator.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/component/QVTModelTransformator.java new file mode 100644 index 00000000..d96a2d6d --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/component/QVTModelTransformator.java @@ -0,0 +1,260 @@ +/** + * Copyright (c) 2012 - 2014 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.component; + +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.emf.common.util.Diagnostic; +import org.eclipse.emf.common.util.ECollections; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.m2m.qvt.oml.BasicModelExtent; +import org.eclipse.m2m.qvt.oml.ExecutionContextImpl; +import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic; +import org.eclipse.m2m.qvt.oml.ModelExtent; +import org.eclipse.m2m.qvt.oml.TransformationExecutor; +import org.gecko.emf.osgi.annotation.require.RequireEMF; +import org.gecko.qvt.osgi.api.ModelTransformationConstants; +import org.gecko.qvt.osgi.api.ModelTransformationNamespace; +import org.gecko.qvt.osgi.api.ModelTransformator; +import org.gecko.qvt.osgi.util.JULLogWriter; +import org.osgi.annotation.bundle.Capability; +import org.osgi.annotation.bundle.Requirement; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Version; +import org.osgi.framework.namespace.BundleNamespace; +import org.osgi.service.cm.annotations.RequireConfigurationAdmin; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; + +/** + * QVT Implementation of a model transformator + * @author Mark Hoffmann + * @author Juergen Albert + * @since 20.10.2017 + */ +@RequireConfigurationAdmin +@RequireEMF +@Capability( namespace = ModelTransformationNamespace.NAMESPACE, name = "qvto") +@Requirement(namespace = ModelTransformationNamespace.COMPANION, name = "ecore.fragment") +@Requirement(namespace = ModelTransformationNamespace.COMPANION, name = "ocl.fragment") +@Component(name = ModelTransformationConstants.TRANSFORMATOR_COMPONENT_NAME, service = ModelTransformator.class, configurationPolicy = ConfigurationPolicy.REQUIRE, immediate = true) +public class QVTModelTransformator implements ModelTransformator, ModelTransformationConstants { + + private static final String VALIDATION_MESSAGE = "%sSource: [%s] Message [%s]"; + private static final Logger logger = Logger.getLogger(QVTModelTransformator.class.getName()); + private URI templateUri = null; + private TransformationExecutor executor = null; + private ExecutionContextImpl context = null; + + @Reference(name = "qvt.model") + private ResourceSet resourceSet; + + private BundleContext bundleContext; + + /** + * Initializes the transformation engine and does a warm-up for the executor to reduce execution time + * @throws URISyntaxException + */ + @Activate + void init(ComponentContext componentContext, Map properties) throws URISyntaxException { + this.bundleContext = componentContext.getBundleContext(); + if(properties.containsKey(TEMPLATE_URI)) { + String uriString = (String) properties.get(TEMPLATE_URI); + if(uriString != null && !uriString.trim().isEmpty()) { + templateUri = URI.createURI(TEMPLATE_URI); + } + } + if(templateUri == null) { + String templatePath = (String) properties.get(TEMPLATE_PATH); + templateUri = getTemplateUri(templatePath); + } + if ( templateUri == null) { + throw new IllegalArgumentException("Error initializing QVT helper without template or/and resource set"); + } + executor = new TransformationExecutor(templateUri, resourceSet.getPackageRegistry()); + Diagnostic result = executor.loadTransformation(); + if (result.getSeverity() == Diagnostic.OK) { + context = new ExecutionContextImpl(); + context.setConfigProperty("keepModeling", true); + // to log from QVTO during development uncomment the line below + context.setLog(new JULLogWriter("o.e.q.o.qvtTransformatorExecutor")); + } else { + String msg = getDiagnosticMessage(result); + logger.log(Level.SEVERE, String.format("Error loading transformation template: %s", msg)); + throw new IllegalStateException(msg); + } + } + + + @Deactivate + public void dispose() { + if (executor != null) { + executor.cleanup(); + executor = null; + } + if (context != null) { + context = null; + } + } + + /* + * (non-Javadoc) + * @see org.gecko.qvt.osgi.api.ModelTransformator#startTransformations(java.util.List) + */ + @Override + public List startTransformations(List inObjects) { + if (inObjects == null) { + throw new IllegalStateException("Error transforming object with null instance or no resource set"); + } + try { + // create the input extent with its initial contents + ModelExtent input = new BasicModelExtent(inObjects); + // create an empty extent to catch the output + ModelExtent output = new BasicModelExtent(); + ExecutionDiagnostic result = executor.execute(context, input, output); + if(result.getSeverity() == Diagnostic.OK) { + // the output objects got captured in the output extent + List outObjects = output.getContents(); + logger.fine("QVT transformation succeeded with: " + outObjects.size() + " elements"); + return outObjects; + } else { + String message = getDiagnosticMessage(result); + throw new IllegalStateException(String.format("Error executing transformation because of diagnostic errors: %s", message)); + } + } catch (Exception e) { + throw new IllegalStateException("Error transforming model from " + inObjects.toString(), e); + } + } + + /* + * (non-Javadoc) + * @see org.gecko.qvt.osgi.api.ModelTransformator#startTransformation(java.util.List) + */ + @Override + public EObject startTransformation(List inObjects) { + List outObjects = startTransformations(inObjects); + + if (outObjects.size() > 0) { + return outObjects.get(0); + } + throw new IllegalStateException("Transformation failed with no result object"); + } + + /* + * (non-Javadoc) + * @see org.gecko.qvt.osgi.api.ModelTransformator#startTransformation(org.eclipse.emf.ecore.EObject) + */ + @Override + public EObject startTransformation(EObject inObject) { + return startTransformation(ECollections.singletonEList(inObject)); + } + + /** + * Returns a message for a diagnostic + * @param diagnostic the {@link Diagnostic} + */ + private String getDiagnosticMessage(Diagnostic diagnostic) { + StringBuilder message = new StringBuilder(); + createValidationMessage("", diagnostic, message); + return message.toString(); + } + + private void createValidationMessage(String indent, Diagnostic diagnostic, StringBuilder message) { + String separator = System.getProperty("line.separator"); + message.append(String.format(VALIDATION_MESSAGE, indent, diagnostic.getSource(), diagnostic.getMessage())); + message.append(separator); + diagnostic.getChildren().forEach(d -> createValidationMessage(" " + indent , d, message)); + } + + /** + * Returns the bundle from the given bsn version string. + * This parameter is expected in the format: + * :, where the version part is optional. + * @param bsnVersionString the {@link String} in the format from above + */ + private Bundle getBundle(String bsnVersionString) { + String[] bsnVersion = bsnVersionString.split(":"); + String bsn = bsnVersion[0]; + Version version = null; + if (bsnVersion.length == 2) { + version = Version.parseVersion(bsnVersion[1]); + } + Set candidates = new TreeSet<>(new Comparator() { + + /* + * (non-Javadoc) + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) + */ + @Override + public int compare(Bundle o1, Bundle o2) { + return o1.getVersion().compareTo(o2.getVersion()); + } + }); + for (Bundle b : bundleContext.getBundles()) { + if (bsn.equalsIgnoreCase(b.getSymbolicName())) { + if (version == null) { + candidates.add(b); + } else { + if (b.getVersion().compareTo(version) == 0) { + return b; + } else { + continue; + } + } + } + } + if (candidates.isEmpty()) { + throw new IllegalStateException("There is no bundle with this bsn and version '" + bsn + ":" + version + "'"); + } else { + return candidates.stream().findFirst().get(); + } + } + + /** + * Loads the template from the given path + * @throws URISyntaxException + */ + private URI getTemplateUri(String templatePath) throws URISyntaxException { + String[] segments = templatePath.split("/"); + URL url = bundleContext.getBundle().getResource(templatePath); + if(url == null) { + if (segments.length < 2) { + + throw new IllegalStateException("There are at least two segments expected in the ecore path"); + } + Bundle bundle = getBundle(segments[0]); + String path = templatePath.replace(segments[0], ""); + url = bundle.getResource(path); + if (url == null) { + throw new IllegalStateException("There was no template found at '" + segments[0] + path + "'"); + } + } + java.net.URI uri = url.toURI(); + return URI.createHierarchicalURI(uri.getScheme(), uri.getAuthority(), null, uri.getPath().split("/"), null, null); + } + +} diff --git a/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/util/JULLogWriter.java b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/util/JULLogWriter.java new file mode 100644 index 00000000..e87bc3e4 --- /dev/null +++ b/org.gecko.qvt.osgi/src/org/gecko/qvt/osgi/util/JULLogWriter.java @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2012 - 2017 Data In Motion and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Data In Motion - initial API and implementation + */ +package org.gecko.qvt.osgi.util; + +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.eclipse.m2m.qvt.oml.util.Log; + +/** + * Logwriter for java.util.Logger + * @author Mark Hoffmann + * @since 12.11.2017 + */ +public class JULLogWriter implements Log { + + private final Logger logger; + + public JULLogWriter(String loggerName) { + logger = Logger.getLogger(loggerName); + } + + /* + * (non-Javadoc) + * @see org.eclipse.m2m.qvt.oml.util.Log#log(int, java.lang.String, java.lang.Object) + */ + @Override + public void log(int level, String message, Object param) { + Level julLevel = getJulLevel(level); + log(julLevel, message, param); + } + + /* + * (non-Javadoc) + * @see org.eclipse.m2m.qvt.oml.util.Log#log(int, java.lang.String) + */ + @Override + public void log(int level, String message) { + log(level, message, null); + } + + /* + * (non-Javadoc) + * @see org.eclipse.m2m.qvt.oml.util.Log#log(java.lang.String, java.lang.Object) + */ + @Override + public void log(String message, Object param) { + log(Level.INFO, message, null); + } + + /* + * (non-Javadoc) + * @see org.eclipse.m2m.qvt.oml.util.Log#log(java.lang.String) + */ + @Override + public void log(String message) { + log(message, null); + } + + /** + * Logs into JUL logger + * @param level the log level + * @param message the log message + * @param param the log parameter + */ + private void log(Level level, String message, Object param) { + if (param == null) { + logger.log(level, message); + } else { + if (param instanceof Throwable) { + logger.log(level, message, (Throwable)param); + } else { + logger.log(level, message, param); + } + } + } + + /** + * Returns the JUL log level + * @param level the org.eclipse.core.runtime.IStatus values + * @return the JUL log level + */ + private Level getJulLevel(int level) { + switch (level) { + case 0: + return Level.FINE; + case 1: + return Level.INFO; + case 2: + return Level.WARNING; + case 4: + case 8: + return Level.SEVERE; + default: + return Level.INFO; + } + } + +} diff --git a/org.gecko.qvt.osgi/test/.keep b/org.gecko.qvt.osgi/test/.keep new file mode 100644 index 00000000..e69de29b