diff --git a/.gitignore b/.gitignore index 5d5cde8bc6..a98508e0fa 100644 --- a/.gitignore +++ b/.gitignore @@ -133,5 +133,3 @@ **/java-gen **/src-gen/ - - diff --git a/neoemf-core/pom.xml b/neoemf-core/pom.xml index 508461ea67..5bbfc48470 100644 --- a/neoemf-core/pom.xml +++ b/neoemf-core/pom.xml @@ -19,8 +19,8 @@ - 3.21ea41 - 2.21ea43 + 3.22ea5 + 2.22ea17 2.14.1 3.3.0 @@ -143,6 +143,18 @@ true pom + + com.google.code.findbugs + jsr305 + 3.0.2 + compile + + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/neoemf-data/berkeleydb/pom.xml b/neoemf-data/berkeleydb/pom.xml index b748ae7a20..52f14f76ce 100644 --- a/neoemf-data/berkeleydb/pom.xml +++ b/neoemf-data/berkeleydb/pom.xml @@ -27,6 +27,12 @@ com.sleepycat je + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/neoemf-data/blueprints/core/pom.xml b/neoemf-data/blueprints/core/pom.xml index 0aaecb6bf8..7029fcd377 100644 --- a/neoemf-data/blueprints/core/pom.xml +++ b/neoemf-data/blueprints/core/pom.xml @@ -39,6 +39,12 @@ org.eclipse.emf.ecore test + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/neoemf-data/blueprints/neo4j/pom.xml b/neoemf-data/blueprints/neo4j/pom.xml index ba214588c7..6403c03acb 100644 --- a/neoemf-data/blueprints/neo4j/pom.xml +++ b/neoemf-data/blueprints/neo4j/pom.xml @@ -72,6 +72,12 @@ test-jar test + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/neoemf-data/blueprints/pom.xml b/neoemf-data/blueprints/pom.xml index 02507fae72..c5d7b7a585 100644 --- a/neoemf-data/blueprints/pom.xml +++ b/neoemf-data/blueprints/pom.xml @@ -24,5 +24,13 @@ 2.6.0 1.10 + + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + + diff --git a/neoemf-data/hbase/pom.xml b/neoemf-data/hbase/pom.xml index c1f7e9ee97..ee21fda8a0 100644 --- a/neoemf-data/hbase/pom.xml +++ b/neoemf-data/hbase/pom.xml @@ -97,6 +97,12 @@ junit-vintage-engine ${junit.version} + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/neoemf-data/mapdb/pom.xml b/neoemf-data/mapdb/pom.xml index 3d15e0e12f..3835e016d0 100644 --- a/neoemf-data/mapdb/pom.xml +++ b/neoemf-data/mapdb/pom.xml @@ -36,6 +36,12 @@ --> + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/neoemf-data/mongodb/pom.xml b/neoemf-data/mongodb/pom.xml index e77efc173d..d2eaa92990 100644 --- a/neoemf-data/mongodb/pom.xml +++ b/neoemf-data/mongodb/pom.xml @@ -36,6 +36,12 @@ de.flapdoodle.embed.mongo compile + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/neoemf-data/pom.xml b/neoemf-data/pom.xml index d6b01fec7d..08db16082e 100644 --- a/neoemf-data/pom.xml +++ b/neoemf-data/pom.xml @@ -104,6 +104,12 @@ ${project.version} runtime + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/neoemf-io/pom.xml b/neoemf-io/pom.xml index a2a7dd41ad..bb8be17377 100644 --- a/neoemf-io/pom.xml +++ b/neoemf-io/pom.xml @@ -22,9 +22,19 @@ 1.0-2 4.2.1 4.4.1 + 2.13.1 + + + oss.sonatype.org-snapshot + http://oss.sonatype.org/content/repositories/snapshots + false + true + + + @@ -82,6 +92,24 @@ org.eclipse.emf.ecore.xcore.lib + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + compile + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + compile + + + + @@ -111,14 +139,24 @@ assertj-core + + org.emfjson + emfjson-jackson + 1.3.0 + bundle + + + + @@ -129,7 +167,7 @@ org.eclipse.platform org.eclipse.core.runtime - [3.20.0,) + 3.23.0 test @@ -156,6 +194,10 @@ pom test + + org.eclipse.emf + org.eclipse.emf.ecore.xmi + diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/AbstractNotifier.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/AbstractNotifier.java index 238622e274..a8fde81881 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/AbstractNotifier.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/AbstractNotifier.java @@ -79,7 +79,7 @@ public void notifyInitialize() throws IOException { @Override public void notifyStartElement(ProxyElement element) throws IOException { - checkNotNull(element, "element"); + checkNotNull(element, "element"); for (H h : handlers) { h.onStartElement(element); diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/Migrator.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/Migrator.java index fe10c443f4..6801ce9439 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/Migrator.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/Migrator.java @@ -19,14 +19,17 @@ import fr.inria.atlanmod.neoemf.io.reader.AbstractReader; import fr.inria.atlanmod.neoemf.io.reader.DefaultMapperReader; import fr.inria.atlanmod.neoemf.io.reader.Reader; -import fr.inria.atlanmod.neoemf.io.reader.XmiStreamReader; +import fr.inria.atlanmod.neoemf.io.reader.xmi.XmiStreamReader; import fr.inria.atlanmod.neoemf.io.writer.DefaultMapperWriter; import fr.inria.atlanmod.neoemf.io.writer.Writer; -import fr.inria.atlanmod.neoemf.io.writer.XmiStreamWriter; +import fr.inria.atlanmod.neoemf.io.writer.json.JsonStreamWriter; +import fr.inria.atlanmod.neoemf.io.writer.xmi.XmiStreamWriter; import org.atlanmod.commons.annotation.VisibleForTesting; import org.atlanmod.commons.log.Level; import org.atlanmod.commons.log.Log; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.Closeable; import java.io.File; @@ -285,6 +288,36 @@ public Migrator toXmi(@WillNotClose OutputStream stream) throws IOException { return to(new XmiStreamWriter(stream)); } + /** + * Specifies the JSON {@code file} where to write the data. + * + * @param file the file where to write + * + * @return this migrator (for chaining) + * + * @throws IOException if an I/O error occurs during the creation + * @see #toXmi(File, boolean) + */ + @Nonnull + public Migrator toJson(File file) throws IOException { + OutputStream outputStream = new FileOutputStream(file); + return toJson(outputStream); + } + + /** + * Specifies the {@code stream} where to write the data. + * + * @param stream the file where to write + * + * @return this migrator (for chaining) + * + * @throws IOException if an I/O error occurs when writing + */ + @Nonnull + public Migrator toJson(@WillNotClose OutputStream stream) throws IOException { + return to(new JsonStreamWriter(stream)); + } + //endregion //region Listeners @@ -370,6 +403,8 @@ public void migrate() throws IOException { try { // Bind handlers and notifiers Collection handlers = new ArrayList<>(listeners.size() + writers.size()); + final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + logger.info("writers :: {}", writers.toArray()); handlers.addAll(listeners); handlers.addAll(writers); reader.addNext(new NoopProcessor(handlers)); diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/processor/EcoreMapper.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/processor/EcoreMapper.java index 93cee521ac..1356772e8d 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/processor/EcoreMapper.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/processor/EcoreMapper.java @@ -24,6 +24,8 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.util.ExtendedMetaData; import org.eclipse.emf.ecore.util.FeatureMapUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayDeque; @@ -45,6 +47,8 @@ public class EcoreMapper extends AbstractProcessor { /** * A LIFO that holds the current {@link Id} chain. */ + + final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); @Nonnull private final Deque identifiers = new ArrayDeque<>(); @@ -112,7 +116,13 @@ private void processElementAsRoot(ProxyElement element) throws IOException { checkNotNull(element.getMetaClass(), "The root element must have a namespace"); // Retrieve the current EClass & define the meta-class of the current element if not present + // element is not null + // logger.info("ProxyElement is null:: {}", element == null); final ProxyClass metaClass = element.getMetaClass(); + // metaClass is not null + //logger.info("metaClass is null:: {}", metaClass == null); + // the following condition is true + //logger.info("metaClass name space getOrgin is null:: {}", metaClass.getNamespace().getOrigin() == null); final EClass eClass = getClass(element.getName(), metaClass.getNamespace().getOrigin()); metaClass.setOrigin(eClass); @@ -281,8 +291,10 @@ private EStructuralFeature getFeature(String name) { */ @Nonnull private EClass getClass(String name, EPackage ePackage) { + + logger.info("ePackage is null :: {}", ePackage == null); EClass eClass = (EClass) ePackage.getEClassifier(name); - checkNotNull(eClass, "Unable to find EClass '%s' from EPackage '%s'", name, ePackage.getNsURI()); + checkNotNull(eClass, "Unable to find EClass '%s' from EPackage '%s'", name, ePackage.getNsURI()); return eClass; } diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/proxy/ProxyPackage.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/proxy/ProxyPackage.java index 3ec7cae592..8874a77cad 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/proxy/ProxyPackage.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/proxy/ProxyPackage.java @@ -14,31 +14,30 @@ import org.atlanmod.commons.annotation.VisibleForTesting; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EcorePackage; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import org.eclipse.emf.ecore.impl.EPackageImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import java.util.*; + import static org.atlanmod.commons.Preconditions.checkNotNull; + /** * A simple representation of a {@link org.eclipse.emf.ecore.EPackage}. */ @ParametersAreNonnullByDefault -public class ProxyPackage implements Proxy { +public class ProxyPackage extends EPackageImpl implements Proxy { /** * The instance of the default namespace: {@code ecore @ http://www.eclipse.org/emf/2002/Ecore}. */ @Nonnull public static final ProxyPackage DEFAULT = Registry.getInstance().register(EcorePackage.eINSTANCE); - /** * The prefix of this namespace. */ @@ -51,12 +50,27 @@ public class ProxyPackage implements Proxy { @Nonnull private final String uri; + final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + /** * The {@link EPackage} represented by this object. */ @Nonnull private final LazyReference ePackage = LazyReference.soft(() -> { + + // Until here we don't have a null object EPackage p = EPackage.Registry.INSTANCE.getEPackage(getUri()); + + logger.info("URI :: {}", getUri()); + logger.info("the ePackage :: {}", p); + if(p == null && getUri().equals("http://www.neoemf.com/tests/sample")){ + // create an EPackage object + p = EPackage.Registry.INSTANCE.getEPackage("http://www.neoemf.com/tests/sample"); + logger.info("The ePackage is null"); + + //p = new ProxyPackage("sample", "http://www.neoemf.com/tests/sample"); + } + checkNotNull(p, "EPackage %s is not registered.", getUri()); return p; }); @@ -70,11 +84,14 @@ public class ProxyPackage implements Proxy { private ProxyPackage(String prefix, String uri) { this.prefix = prefix; this.uri = uri; + + // logger.info("prefix :: {}, namespace :: {}", prefix, uri); } @Override public EPackage getOrigin() { return ePackage.get(); + //return (ePackage != null) ? ePackage.get(): new EPackageImpl("", ) } @Nonnull diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/AbstractStreamReader.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/AbstractStreamReader.java index db643202fc..6fa7f1496c 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/AbstractStreamReader.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/AbstractStreamReader.java @@ -77,7 +77,7 @@ public abstract class AbstractStreamReader extends AbstractReader { @Override public final void read(InputStream source) throws IOException { - checkNotNull(source, "source"); + checkNotNull(source, "source"); try (InputStream in = new BufferedInputStream(source)) { parse(in); diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/Test.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/Test.java new file mode 100644 index 0000000000..b356b2692a --- /dev/null +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/Test.java @@ -0,0 +1,13 @@ +package fr.inria.atlanmod.neoemf.io.reader; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +public class Test { + public static void main(String[] args) throws IOException { + Path fileName = Path.of("demo.txt"); + String store_xml = Files.readString(fileName); + System.out.println(store_xml); + } +} diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/AbstractJsonStreamReader.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/AbstractJsonStreamReader.java new file mode 100644 index 0000000000..87b5553a8d --- /dev/null +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/AbstractJsonStreamReader.java @@ -0,0 +1,54 @@ +package fr.inria.atlanmod.neoemf.io.reader.json; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import fr.inria.atlanmod.neoemf.io.reader.AbstractStreamReader; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import org.eclipse.emf.ecore.resource.Resource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Map; + + +public class AbstractJsonStreamReader extends AbstractStreamReader { + + private final Logger logger = LoggerFactory.getLogger(AbstractJsonStreamReader.class); + + /*public AbstractJsonStreamReader(){ + JsonReaderHelper.resourceSet.getResourceFactoryRegistry() + .getExtensionToFactoryMap() + .put("json", new JsonResourceFactory()); + + }*/ + + @Override + public void parse(@NotNull InputStream stream) throws IOException { + /* + resource = JsonReaderHelper.mapper.reader() + .withAttribute(EMFContext.Attributes.RESOURCE_SET, JsonReaderHelper.resourceSet) + .withAttribute(EMFContext.Attributes.RESOURCE_URI, JsonReaderHelper.resourceData) + .forType(Resource.class) + .readValue(stream); + + + String theString = IOUtils.toString(stream, StandardCharsets.UTF_8); + ObjectMapper mapper = new ObjectMapper(); + Reader reader = new StringReader(theString); + + */ + } + + + @Override + protected boolean isSpecialAttribute(@Nullable String prefix, String name, String value) throws IOException { + return false; + } +} diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/JsonReaderHelper.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/JsonReaderHelper.java new file mode 100644 index 0000000000..33b67893ee --- /dev/null +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/JsonReaderHelper.java @@ -0,0 +1,17 @@ +package fr.inria.atlanmod.neoemf.io.reader.json; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; + +import java.io.InputStream; + + +public class JsonReaderHelper { + + public static final ObjectMapper mapper = new ObjectMapper(); + public static final ResourceSet resourceSet = new ResourceSetImpl(); + public static final String resourceData = "/Users/macbook/eclipse-workspace/NeoEMF/neoemf-io/src/main/resources/data.json"; + + +} diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/JsonStreamReader.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/JsonStreamReader.java new file mode 100644 index 0000000000..3d5da5bb4a --- /dev/null +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/JsonStreamReader.java @@ -0,0 +1,5 @@ +package fr.inria.atlanmod.neoemf.io.reader.json; + +public class JsonStreamReader extends AbstractJsonStreamReader { + +} diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/User.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/User.java new file mode 100644 index 0000000000..abea086daf --- /dev/null +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/json/User.java @@ -0,0 +1,39 @@ +package fr.inria.atlanmod.neoemf.io.reader.json; + +public class User { + + private int id; + private String name; + + public User(int id, String name) { + this.id = id; + this.name = name; + } + + public User() { + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "User{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/store.xml b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/store.xml new file mode 100644 index 0000000000..2b42d41917 --- /dev/null +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/store.xml @@ -0,0 +1,91 @@ + + + +]> + + +
+
+ + + + +
+ + + + + + +
+ + + + + +
+ + + +
+ + + + +
+ + + + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/AbstractXmiStreamReader.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/xmi/AbstractXmiStreamReader.java similarity index 96% rename from neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/AbstractXmiStreamReader.java rename to neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/xmi/AbstractXmiStreamReader.java index b2cd73a387..61eaf5293e 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/AbstractXmiStreamReader.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/xmi/AbstractXmiStreamReader.java @@ -6,13 +6,14 @@ * this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ */ -package fr.inria.atlanmod.neoemf.io.reader; +package fr.inria.atlanmod.neoemf.io.reader.xmi; import fr.inria.atlanmod.neoemf.io.processor.AbstractProcessor; import fr.inria.atlanmod.neoemf.io.processor.EcoreMapper; import fr.inria.atlanmod.neoemf.io.processor.XPathResolver; import fr.inria.atlanmod.neoemf.io.proxy.ProxyReference; import fr.inria.atlanmod.neoemf.io.proxy.ProxyValue; +import fr.inria.atlanmod.neoemf.io.reader.AbstractStreamReader; import fr.inria.atlanmod.neoemf.io.util.XmiConstants; import org.atlanmod.commons.log.Log; diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/XmiStreamReader.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/xmi/XmiStreamReader.java similarity index 99% rename from neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/XmiStreamReader.java rename to neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/xmi/XmiStreamReader.java index 49b21654f6..612b524189 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/XmiStreamReader.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/reader/xmi/XmiStreamReader.java @@ -6,7 +6,7 @@ * this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ */ -package fr.inria.atlanmod.neoemf.io.reader; +package fr.inria.atlanmod.neoemf.io.reader.xmi; import com.ctc.wstx.api.WstxInputProperties; diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/util/JsonConstants.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/util/JsonConstants.java new file mode 100644 index 0000000000..e9213936a9 --- /dev/null +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/util/JsonConstants.java @@ -0,0 +1,11 @@ +package fr.inria.atlanmod.neoemf.io.util; + +import org.atlanmod.commons.annotation.Static; + +import javax.annotation.ParametersAreNonnullByDefault; + +@Static +@ParametersAreNonnullByDefault +public final class JsonConstants { + +} diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/AbstractWriter.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/AbstractWriter.java index f7e1eda687..3fb593ee2c 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/AbstractWriter.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/AbstractWriter.java @@ -139,7 +139,6 @@ public void onEndElement() throws IOException { /** * Handles an attribute in the current element. - * * @param attribute the new attribute, without its value * @param values the ordered values of the attribute; when the {@code attribute} is single-valued, this parameter * is a {@link Collections#singletonList(Object)} diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/DefaultMapperWriter.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/DefaultMapperWriter.java index 9ad8e82451..9a480872da 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/DefaultMapperWriter.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/DefaultMapperWriter.java @@ -60,7 +60,6 @@ public void onComplete() { @Override public void onStartElement(ProxyElement element) throws IOException { super.onStartElement(element); - createElement(element, false); } @@ -72,10 +71,19 @@ public void onAttribute(ProxyAttribute attribute, List values) { target.valueFor(bean, values.get(0)); } else { + // Old code target.appendAllValues(bean, values); + // new code + /* + values.stream().map(v -> { + target.valueFor(bean, v); + return null; + });*/ + } } + @Override public void onReference(ProxyReference reference, List values) { SingleFeatureBean bean = SingleFeatureBean.of(reference.getOwner(), reference.getId()); diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/json/AbstractJsonStreamWriter.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/json/AbstractJsonStreamWriter.java new file mode 100644 index 0000000000..3a4b9611ad --- /dev/null +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/json/AbstractJsonStreamWriter.java @@ -0,0 +1,142 @@ +package fr.inria.atlanmod.neoemf.io.writer.json; + +import fr.inria.atlanmod.neoemf.core.Id; +import fr.inria.atlanmod.neoemf.io.proxy.ProxyAttribute; +import fr.inria.atlanmod.neoemf.io.proxy.ProxyElement; +import fr.inria.atlanmod.neoemf.io.proxy.ProxyReference; +import fr.inria.atlanmod.neoemf.io.writer.AbstractStreamWriter; +import org.atlanmod.commons.primitive.Strings; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; +import java.util.stream.Collectors; + +public abstract class AbstractJsonStreamWriter extends AbstractStreamWriter { + /** + * Constructs a new {@code AbstractStreamWriter} with the given {@code stream}. + * + * @param stream the stream where to write data + */ + public AbstractJsonStreamWriter(OutputStream stream) { + super(stream); + } + + @Override + public void onInitialize() throws IOException { + writeStartDocument(); + } + + @Override + public final void onStartElement(ProxyElement element) throws IOException { + super.onStartElement(element); + writeStartElement(element.getMetaClass().getNamespace().getUri(), element.getMetaClass().getName()); + } + + @Override + public void onAttribute(ProxyAttribute attribute, List values) throws IOException { + if (!attribute.isMany()) { + writeAttribute(attribute.getName(), values.get(0)); + } else { + writeMultipleAttributes(attribute.getName(), values); + } + } + + @Override + public void onReference(ProxyReference reference, List values) throws IOException { + if (reference.isContainment()) { + if (reference.isMany()) { + writeStartMultiValuedContainmentReference(reference.getName()); + } else { + writeStartContainmentReference(reference.getName()); + } + return; + } + if (reference.isMany()) { + writeAttribute(reference.getName(), values.stream().map(Id::toHexString).collect(Collectors.joining(Strings.SPACE))); + } else { + writeAttribute(reference.getName(), values.get(0).toHexString()); + } + } + + @Override + public void onEndElement() throws IOException { + super.onEndElement(); + writeEndElement(); + } + + @Override + public void onComplete() throws IOException { + writeEndDocument(); + } + + /** + * Writes the start of a document, including the general header. + * + * @throws IOException if an I/O error occurs when writing + */ + protected abstract void writeStartDocument() throws IOException; + + /** + * Writes the start of an element {@code name} + * + * @param name the name of the element + * @throws IOException if an I/O error occurs when writing + */ + protected abstract void writeStartElement(String namespace, String name) throws IOException; + + /** + * Writes an attribute of the current element. + * + * @param name the name of the attribute + * @param value the value of the attribute + * @throws IOException if an I/O error occurs when writing + */ + protected abstract void writeAttribute(String name, Object value) throws IOException; + + /** + * Writes a multi valued attribute. + * + * @param name the name of the attribute + * @param values multiple values of the attribute + * @throws IOException if an I/O error occurs when writing + */ + protected abstract void writeMultipleAttributes(String name, List values) throws IOException; + + /** + * Writes characters. + * + * @param characters the characters + * @throws IOException if an I/O error occurs when writing + */ + protected abstract void writeCharacters(String characters) throws IOException; + + /** + * Writes the start of a containment reference + * + * @param name the name fo the reference + * @throws IOException + */ + protected abstract void writeStartContainmentReference(String name) throws IOException; + + /** + * Write the start of a multi-valued containment reference + * + * @param name the name of the reference + */ + protected abstract void writeStartMultiValuedContainmentReference(String name) throws IOException; + + /** + * Writes the end of the current element. + * + * @throws IOException if an I/O error occurs when writing + */ + protected abstract void writeEndElement() throws IOException; + + /** + * Writes the end of the document and finalizes the migration. + * + * @throws IOException if an I/O error occurs when writing + */ + protected abstract void writeEndDocument() throws IOException; +} diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/json/JsonStreamWriter.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/json/JsonStreamWriter.java new file mode 100644 index 0000000000..adc76a686b --- /dev/null +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/json/JsonStreamWriter.java @@ -0,0 +1,87 @@ +package fr.inria.atlanmod.neoemf.io.writer.json; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.ObjectMapper; + +import javax.annotation.Nonnull; +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +public class JsonStreamWriter extends AbstractJsonStreamWriter { + @Nonnull + protected final ObjectMapper mapper; + @Nonnull + protected final JsonGenerator jGenerator; + protected int id; + + /** + * Constructs a new {@code AbstractStreamWriter} with the given {@code stream}. + * + * @param stream the stream where to write data + */ + public JsonStreamWriter(OutputStream stream) throws IOException { + super(stream); + mapper = new ObjectMapper(); + jGenerator = mapper.getFactory().createGenerator(target); + jGenerator.useDefaultPrettyPrinter(); + id = 0; + } + + @Override + protected void writeStartDocument() throws IOException { + } + + @Override + protected void writeStartElement(String namespace, String name) throws IOException { + jGenerator.writeStartObject(); + jGenerator.writeStringField("eClass", namespace + "#//" + name); + } + + @Override + protected void writeAttribute(String name, Object value) throws IOException { + jGenerator.writeObjectField(name, value); + } + + @Override + protected void writeMultipleAttributes(String name, List values) throws IOException { + jGenerator.writeArrayFieldStart(name); + for (Object v : values) { + jGenerator.writeObject(v); + } + jGenerator.writeEndArray(); + } + + @Override + protected void writeStartContainmentReference(String name) throws IOException { + jGenerator.writeFieldName(name); + jGenerator.writeStartObject(); + } + + @Override + protected void writeStartMultiValuedContainmentReference(String name) throws IOException { + jGenerator.writeFieldName(name); + jGenerator.writeStartArray(); + } + + @Override + protected void writeCharacters(String characters) throws IOException { + jGenerator.writeString(characters); + } + + @Override + protected void writeEndElement() throws IOException { + try { + jGenerator.writeEndObject(); + } catch (JsonGenerationException e) { + jGenerator.writeEndArray(); + jGenerator.writeEndObject(); + } + } + + @Override + protected void writeEndDocument() throws IOException { + jGenerator.close(); + } +} diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/AbstractXmiStreamWriter.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/xmi/AbstractXmiStreamWriter.java similarity index 98% rename from neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/AbstractXmiStreamWriter.java rename to neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/xmi/AbstractXmiStreamWriter.java index 057a91cff3..15410017d9 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/AbstractXmiStreamWriter.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/xmi/AbstractXmiStreamWriter.java @@ -6,7 +6,7 @@ * this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ */ -package fr.inria.atlanmod.neoemf.io.writer; +package fr.inria.atlanmod.neoemf.io.writer.xmi; import fr.inria.atlanmod.neoemf.core.Id; import fr.inria.atlanmod.neoemf.io.processor.ValueConverter; @@ -17,6 +17,7 @@ import fr.inria.atlanmod.neoemf.io.proxy.ProxyReference; import fr.inria.atlanmod.neoemf.io.util.XmiConstants; +import fr.inria.atlanmod.neoemf.io.writer.AbstractStreamWriter; import org.atlanmod.commons.annotation.Beta; import org.atlanmod.commons.primitive.Strings; import org.eclipse.emf.ecore.EAttribute; diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/IndentingXmiStreamWriter.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/xmi/IndentingXmiStreamWriter.java similarity index 98% rename from neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/IndentingXmiStreamWriter.java rename to neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/xmi/IndentingXmiStreamWriter.java index ff2b6bd46d..9e8a7414cc 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/IndentingXmiStreamWriter.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/xmi/IndentingXmiStreamWriter.java @@ -6,7 +6,7 @@ * this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ */ -package fr.inria.atlanmod.neoemf.io.writer; +package fr.inria.atlanmod.neoemf.io.writer.xmi; import org.atlanmod.commons.primitive.Strings; diff --git a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/XmiStreamWriter.java b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/xmi/XmiStreamWriter.java similarity index 98% rename from neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/XmiStreamWriter.java rename to neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/xmi/XmiStreamWriter.java index ba7d1078ab..9fa638f391 100644 --- a/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/XmiStreamWriter.java +++ b/neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/writer/xmi/XmiStreamWriter.java @@ -6,7 +6,7 @@ * this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ */ -package fr.inria.atlanmod.neoemf.io.writer; +package fr.inria.atlanmod.neoemf.io.writer.xmi; import fr.inria.atlanmod.neoemf.io.util.XmiConstants; diff --git a/neoemf-io/src/main/resources/data.json b/neoemf-io/src/main/resources/data.json new file mode 100644 index 0000000000..994b398f49 --- /dev/null +++ b/neoemf-io/src/main/resources/data.json @@ -0,0 +1,5 @@ +{ + "eClass" : "http://emfjson.org/domain#//User", + "id": 1, + "name" : "Bob" +} diff --git a/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/XmiReaderTest.java b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/XmiReaderTest.java index 1a23bbd79e..d4da0767a1 100644 --- a/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/XmiReaderTest.java +++ b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/XmiReaderTest.java @@ -13,7 +13,7 @@ import fr.inria.atlanmod.neoemf.io.proxy.ProxyClass; import fr.inria.atlanmod.neoemf.io.proxy.ProxyReference; import fr.inria.atlanmod.neoemf.io.provider.UriProvider; -import fr.inria.atlanmod.neoemf.io.reader.XmiStreamReader; +import fr.inria.atlanmod.neoemf.io.reader.xmi.XmiStreamReader; import fr.inria.atlanmod.neoemf.io.util.InMemoryElement; import fr.inria.atlanmod.neoemf.io.util.InMemoryWriter; import fr.inria.atlanmod.neoemf.io.util.ResourceManager; diff --git a/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/reader/XmiReaderTest.java b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/reader/XmiReaderTest.java new file mode 100644 index 0000000000..2dbf9648e7 --- /dev/null +++ b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/reader/XmiReaderTest.java @@ -0,0 +1,435 @@ +/* + * Copyright (c) 2013 Atlanmod. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License v2.0 which accompanies + * this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ + */ + +package fr.inria.atlanmod.neoemf.io.reader; + +import fr.inria.atlanmod.neoemf.core.Id; +import fr.inria.atlanmod.neoemf.io.Migrator; +import fr.inria.atlanmod.neoemf.io.proxy.ProxyAttribute; +import fr.inria.atlanmod.neoemf.io.proxy.ProxyClass; +import fr.inria.atlanmod.neoemf.io.proxy.ProxyReference; +import fr.inria.atlanmod.neoemf.io.provider.UriProvider; +import fr.inria.atlanmod.neoemf.io.reader.xmi.XmiStreamReader; +import fr.inria.atlanmod.neoemf.io.util.InMemoryElement; +import fr.inria.atlanmod.neoemf.io.util.InMemoryWriter; +import fr.inria.atlanmod.neoemf.io.util.ResourceManager; + +import org.atlanmod.commons.AbstractTest; +import org.eclipse.emf.common.util.URI; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ArgumentsSource; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.catchThrowable; +import static org.atlanmod.commons.Preconditions.checkGreaterThan; +import static org.atlanmod.commons.Preconditions.checkNotNull; + +/** + * A test-case about the reading of a model. + */ +@ParametersAreNonnullByDefault +@SuppressWarnings("ConstantConditions") // Test with `@Nonnull` +class XmiReaderTest extends AbstractTest { + + /** + * A map that holds the mapping between an XPath and its {@code xmi:id} value. + */ + private static final Map MAPPING = new HashMap<>(); + + static { + MAPPING.put("/@Model.0", "_PYE3oE0VEeeM143ZRH6p9g"); + + MAPPING.put("/@Model.0/@orphanTypes.5", "_PZgbAk0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@orphanTypes.9", "_PZgbBk0VEeeM143ZRH6p9g"); + + MAPPING.put("/@Model.0/@ownedElements.0", "_PYNagE0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0", "_PYOooU0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0", "_PYOook0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@modifier.0", "_PYUIME0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@returnType.0", "_PYWkdU0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2", "_PYXLgE0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@modifier.0", "_PYXLg00VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.3", "_PYXLh00VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.1/@bodyDeclarations.5/@returnType.0", "_PZAExk0VEeeM143ZRH6p9g"); + + MAPPING.put("/@Model.0/@ownedElements.1", "_PZKcwE0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@ownedElements.1/@ownedPackages.1", "_PZOuME0VEeeM143ZRH6p9g"); + + MAPPING.put("/@Model.0/@ownedElements.2/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0", "_PZbijE0VEeeM143ZRH6p9g"); + + MAPPING.put("/@Model.0/@compilationUnits.0", "_PZhpIE0VEeeM143ZRH6p9g"); + + MAPPING.put("/@Model.0/@compilationUnits.1", "_PZhpOE0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@compilationUnits.1/@imports.1", "_PZhpOk0VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@compilationUnits.1/@imports.2", "_PZhpO00VEeeM143ZRH6p9g"); + MAPPING.put("/@Model.0/@compilationUnits.1/@imports.10", "_PZiQNE0VEeeM143ZRH6p9g"); + } + + /** + * Retrieves an element from the {@code root} element with the successive {@code indices}. + * + * @param root the element from which to start the search + * @param indices the index of the element, recursively in the children from the {@code root} + * + * @return the element + */ + @Nonnull + private static InMemoryElement childFrom(InMemoryElement root, int... indices) { + checkGreaterThan(indices.length, 0, "You must define at least one index"); + + InMemoryElement child = root; + + for (int index : indices) { + child = child.children().get(index); + } + + return checkNotNull(child, "child"); + } + + @BeforeAll + static void registerPackages() { + ResourceManager.registerAllPackages(); + } + + /** + * Check that the elements and their children are properly processed. + */ + @ParameterizedTest(name = "[{index}] source = {0}") + @ArgumentsSource(UriProvider.AllWithTypes.class) + void testElementsAndChildren(URI uri, Boolean withId) throws IOException { + InMemoryElement root = readResource(uri); + + InMemoryElement o; + InMemoryElement child; + + assertValidElement(root, resolve("/@Model.0", withId), "Model", 19); + { + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0 + o = childFrom(root, 0, 0, 0, 0, 0, 0); + assertValidElement(o, resolve("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0", withId), "ownedElements", 7); + { + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0/@modifier + child = childFrom(o, 0); + assertValidElement(child, resolve("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@modifier.0", withId), "modifier", 0); + + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0/@bodyDeclarations.2 + child = childFrom(o, 3); + assertValidElement(child, resolve("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2", withId), "bodyDeclarations", 5); + } + + //@Model/@ownedElements.1 + o = childFrom(root, 1); + assertValidElement(o, resolve("/@Model.0/@ownedElements.1", withId), "ownedElements", 5); + + //@Model/@orphanTypes.5 + o = childFrom(root, 8); + assertValidElement(o, resolve("/@Model.0/@orphanTypes.5", withId), "orphanTypes", 0); + + //@Model/@compilationUnits.1 + o = childFrom(root, 17); + assertValidElement(o, resolve("/@Model.0/@compilationUnits.1", withId), "compilationUnits", 16); + { + //@Model/@compilationUnits.1/@imports.2 + child = childFrom(o, 2); + assertValidElement(child, resolve("/@Model.0/@compilationUnits.1/@imports.2", withId), "imports", 0); + } + } + } + + /** + * Check that the XPath references are properly processed. + */ + @ParameterizedTest(name = "[{index}] source = {0}") + @ArgumentsSource(UriProvider.AllWithTypes.class) + void testReferences(URI uri, Boolean withId) throws IOException { + InMemoryElement root = readResource(uri); + + InMemoryElement o; + InMemoryElement child; + + List references; + + references = root.references(); + assertThat(references).hasSize(19); + assertValidReference(references.get(0), "ownedElements", resolve("/@Model.0/@ownedElements.0", withId), true, true); + assertValidReference(references.get(12), "orphanTypes", resolve("/@Model.0/@orphanTypes.9", withId), true, true); + { + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0 + o = childFrom(root, 0, 0, 0, 0, 0, 0); + references = o.references(); + assertThat(references).hasSize(8); + assertValidReference(references.get(0), "originalCompilationUnit", resolve("/@Model.0/@compilationUnits.0", withId), false, false); + assertValidReference(references.get(5), "bodyDeclarations", resolve("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.3", withId), true, true); + { + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0/@modifier + child = childFrom(o, 0); + assertThat(child.references()).isEmpty(); + + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0/@bodyDeclarations.2 + child = childFrom(o, 3); + references = child.references(); + assertThat(references).hasSize(6); + assertValidReference(references.get(0), "originalCompilationUnit", resolve("/@Model.0/@compilationUnits.0", withId), false, false); + assertValidReference(references.get(2), "modifier", resolve("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.2/@modifier.0", withId), false, true); + } + + //@Model/@ownedElements.1 + o = childFrom(root, 1); + references = o.references(); + assertThat(references).hasSize(5); + assertValidReference(references.get(1), "ownedPackages", resolve("/@Model.0/@ownedElements.1/@ownedPackages.1", withId), true, true); + + //@Model/@orphanTypes.5 + o = childFrom(root, 8); + references = o.references(); + + assertThat(references).hasSize(12); + assertValidReference(references.get(0), "usagesInTypeAccess", resolve("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0/@bodyDeclarations.1/@returnType.0", withId), true, false); + assertValidReference(references.get(9), "usagesInTypeAccess", resolve("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.1/@bodyDeclarations.5/@returnType.0", withId), true, false); + + //@Model/@compilationUnits.1 + o = childFrom(root, 17); + references = o.references(); + assertThat(references).hasSize(18); + assertValidReference(references.get(0), "package", resolve("/@Model.0/@ownedElements.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0", withId), false, false); + assertValidReference(references.get(3), "imports", resolve("/@Model.0/@compilationUnits.1/@imports.1", withId), true, true); + assertValidReference(references.get(12), "imports", resolve("/@Model.0/@compilationUnits.1/@imports.10", withId), true, true); + { + //@Model/@compilationUnits.1/@imports.2 + child = childFrom(o, 2); + references = child.references(); + assertThat(references).hasSize(2); + assertValidReference(references.get(0), "originalCompilationUnit", resolve("/@Model.0/@compilationUnits.1", withId), false, false); + assertValidReference(references.get(1), "importedElement", resolve("/@Model.0/@ownedElements.2/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedPackages.0/@ownedElements.0", withId), false, false); + } + } + } + + /** + * Check that the attributes are properly processed. + */ + @ParameterizedTest(name = "[{index}] source = {0}") + @ArgumentsSource(UriProvider.AllWithTypes.class) + void testAttributes(URI uri) throws IOException { + InMemoryElement root = readResource(uri); + + InMemoryElement o; + InMemoryElement child; + + List attributes; + + attributes = root.attributes(); + assertThat(attributes).hasSize(1); // Assert that 'xmi:version' and 'xmlns' don't exist + assertValidAttribute(attributes.get(0), "name", "fr.inria.atlanmod.kyanos.tests"); + { + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0 + o = childFrom(root, 0, 0, 0, 0, 0, 0); + attributes = o.attributes(); + assertThat(attributes).hasSize(1); + assertValidAttribute(attributes.get(0), "name", "TestCreateResource"); + { + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0/@modifier + child = childFrom(o, 0); + attributes = child.attributes(); + assertThat(attributes).hasSize(1); + assertValidAttribute(attributes.get(0), "visibility", "public"); + + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0/@bodyDeclarations.2 + child = childFrom(o, 3); + attributes = child.attributes(); + assertThat(attributes).hasSize(1); + assertValidAttribute(attributes.get(0), "name", "tearDownAfterClass"); + } + + //@Model/@ownedElements.1 + o = childFrom(root, 1); + attributes = o.attributes(); + assertThat(attributes).hasSize(2); + assertValidAttribute(attributes.get(0), "name", "java"); + assertValidAttribute(attributes.get(1), "proxy", true); + + //@Model/@orphanTypes.5 + o = childFrom(root, 8); + attributes = o.attributes(); + assertThat(attributes).hasSize(1); + assertValidAttribute(attributes.get(0), "name", "void"); + + //@Model/@compilationUnits.1 + o = childFrom(root, 17); + attributes = o.attributes(); + assertThat(attributes).hasSize(2); + assertValidAttribute(attributes.get(0), "name", "TestXmi.java"); + assertValidAttribute(attributes.get(1), "originalFilePath", "C:\\Eclipse\\eclipse-SDK-4.3.1-win32-x86_64-Blue\\eclipse\\workspace\\fr.inria.atlanmod.kyanos.tests\\src\\fr\\inria\\atlanmod\\kyanos\\tests\\TestXmi.java"); + { + //@Model/@compilationUnits.1/@imports.2 + child = childFrom(o, 2); + assertThat(child.attributes()).isEmpty(); + } + } + } + + /** + * Check that the meta-classes ('xsi:type' or 'xmi:type') are properly processed. + */ + @ParameterizedTest(name = "[{index}] source = {0}") + @ArgumentsSource(UriProvider.AllWithTypes.class) + void testMetaClasses(URI uri) throws IOException { + InMemoryElement root = readResource(uri); + + InMemoryElement o; + InMemoryElement child; + + assertValidMetaClass(root.metaClass(), "java", "Model"); + { + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0 + o = childFrom(root, 0, 0, 0, 0, 0, 0); + assertValidMetaClass(o.metaClass(), "java", "ClassDeclaration"); + { + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0/@modifier + child = childFrom(o, 0); + assertValidMetaClass(child.metaClass(), "java", "Modifier"); + + //@Model/@ownedElements.0/@ownedPackages[4]/@ownedElements.0/@bodyDeclarations.2 + child = childFrom(o, 3); + assertValidMetaClass(child.metaClass(), "java", "MethodDeclaration"); + } + + //@Model/@ownedElements.1 + o = childFrom(root, 1); + assertValidMetaClass(o.metaClass(), "java", "Package"); + + //@Model/@orphanTypes.5 + o = childFrom(root, 8); + assertValidMetaClass(o.metaClass(), "java", "PrimitiveTypeVoid"); + + //@Model/@compilationUnits.1 + o = childFrom(root, 17); + assertValidMetaClass(o.metaClass(), "java", "CompilationUnit"); + { + //@Model/@compilationUnits.1/@imports.2 + child = childFrom(o, 2); + assertValidMetaClass(child.metaClass(), "java", "ImportDeclaration"); + } + } + } + + /** + * Check if the reader stop its execution if it hasn't any handler. + */ + @Test + void testReaderWithoutHandler() { + assertThat( + catchThrowable(() -> new XmiStreamReader().read(null)) + ).isInstanceOf(NullPointerException.class); + } + + /** + * Reads a resource file from the given {@code uri}. + * + * @param uri the URI of the resource + * + * @return the root of the read resource + */ + @Nonnull + private InMemoryElement readResource(URI uri) throws IOException { + InMemoryWriter writer = new InMemoryWriter(); + + try (InputStream in = new URL(uri.toString()).openStream()) { + Migrator.fromXmi(in) + // .to(writer) // TODO + .withCounter() + .withTimer() +// .withLogger() + .migrate(); + } + + return checkNotNull(writer.getRoot(), "writer.root"); + } + + /** + * Retrieves the identifier of the given {@code path} if {@code useIds() == true}. + * + * @param path the path to retrieve + * + * @return the identifier + */ + @Nonnull + private Id resolve(String path, boolean withId) { + Id id = withId + ? Id.getProvider().generate(MAPPING.get(path)) + : Id.getProvider().generate(path); + + return checkNotNull(id, "Undefined path: %s", path); + } + + /** + * Checks that the {@code element} has the given arguments. + * + * @param element the element to test + * @param id the expected identifier + * @param name the expected name + * @param size the expected size + */ + private void assertValidElement(InMemoryElement element, Id id, String name, int size) { + assertThat(element.id()).isEqualTo(id); + assertThat(element.name()).isEqualTo(name); + assertThat(element.children()).hasSize(size); + } + + /** + * Checks that the {@code metaClass} has the given arguments. + * + * @param metaClass the meta-class to test + * @param nsPrefix the expected namespace prefix + * @param name the expected name + */ + private void assertValidMetaClass(ProxyClass metaClass, String nsPrefix, String name) { + assertThat(metaClass.getNamespace().getPrefix()).isEqualTo(nsPrefix); + assertThat(metaClass.getName()).isEqualTo(name); + } + + /** + * Checks that the {@code reference} has the given arguments. + * + * @param reference the reference to test + * @param name the expected name + * @param idReference the expected reference + * @param isMany {@code true} if the {@code reference} is multi-valued + * @param isContainment {@code true} if the {@code reference} is a containment + */ + private void assertValidReference(ProxyReference reference, String name, Id idReference, boolean isMany, boolean isContainment) { + assertThat(reference.getName()).isEqualTo(name); + assertThat(reference.getValue().getResolved()).isEqualTo(idReference); + assertThat(reference.isContainment()).isEqualTo(isContainment); + assertThat(reference.isMany()).isEqualTo(isMany); + } + + /** + * Checks that the {@code attribute} has the given arguments. + * + * @param attribute the attribute to test + * @param name the expected name + * @param value the expected value + */ + private void assertValidAttribute(ProxyAttribute attribute, String name, Object value) { + assertThat(attribute.getName()).isEqualTo(name); + assertThat(attribute.getValue().getResolved()).isEqualTo(value); + } +} diff --git a/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/util/ResourceManager.java b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/util/ResourceManager.java index 84a45d63b1..d9a7218188 100644 --- a/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/util/ResourceManager.java +++ b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/util/ResourceManager.java @@ -8,8 +8,9 @@ package fr.inria.atlanmod.neoemf.io.util; -import fr.inria.atlanmod.neoemf.tests.sample.impl.SamplePackageImpl; +//import fr.inria.atlanmod.neoemf.tests.sample.impl.SamplePackageImpl; +import fr.inria.atlanmod.neoemf.tests.sample.impl.SamplePackageImpl; import org.atlanmod.commons.Throwables; import org.atlanmod.commons.annotation.Singleton; import org.atlanmod.commons.annotation.Static; @@ -21,6 +22,7 @@ import org.eclipse.emf.ecore.xmi.XMIResource; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; import org.eclipse.gmt.modisco.java.impl.JavaPackageImpl; +//import org.eclipse.gmt.modisco.java.impl.JavaPackageImpl; import java.io.IOException; import java.net.URL; diff --git a/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/writer/json/Helper.java b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/writer/json/Helper.java new file mode 100644 index 0000000000..880b368d7b --- /dev/null +++ b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/writer/json/Helper.java @@ -0,0 +1,72 @@ +package fr.inria.atlanmod.neoemf.io.writer.json; + +import fr.inria.atlanmod.neoemf.data.im.DefaultInMemoryBackend; +import fr.inria.atlanmod.neoemf.data.mapping.DataMapper; +import fr.inria.atlanmod.neoemf.io.Migrator; +import fr.inria.atlanmod.neoemf.tests.sample.SampleFactory; +import org.atlanmod.commons.log.Log; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.emfjson.jackson.resource.JsonResourceFactory; +import org.jetbrains.annotations.NotNull; + +import java.io.*; +import java.util.function.Consumer; + +public class Helper { + private static final String testOutputPath = "src/test/resources/test-output/"; + + private static Resource resourceEmfJsonJackson; + private static Resource resourceXmi; + private static String currentTargetPath; + + static boolean deleteDirectory(String path) { + File directoryToBeDeleted = new File(path); + File[] allContents = directoryToBeDeleted.listFiles(); + if (allContents != null) { + for (File file : allContents) { + deleteDirectory(file.getPath()); + } + } + return directoryToBeDeleted.delete(); + } + + static private DataMapper getMapperFromXmi() throws IOException { + DataMapper mapper = new DefaultInMemoryBackend(); + InputStream in = new FileInputStream(currentTargetPath + "test-write.xmi"); + // xmi to mapper + Migrator.fromXmi(in) + .toMapper(mapper) + .migrate(); + return mapper; + } + + static private void mapperToJson(DataMapper mapper) throws IOException { + // mapper to json (our implementation) + Log.info("Exporting to file... [{0}]", currentTargetPath + "test-write.json"); + File targetFileJSON = new File(currentTargetPath + "test-write.json"); + Migrator.fromMapper(mapper) + .toJson(targetFileJSON) + .migrate(); + } + + static void testMigration(@NotNull String targetPath) throws IOException { + currentTargetPath = testOutputPath + targetPath; + // deleteDirectory(currentTargetPath); + + // java to emfjson-jackson (for testing/comparison purpose) + // saveWithEmfJsonJackson(populator, targetPath); + + // java to xmi (used in the Migrator input) + // saveWithEmfXmi(populator, targetPath); + + // migrate xmi to mapper + DataMapper mapper = getMapperFromXmi(); + + // migrate mapper to json + mapperToJson(mapper); + } +} diff --git a/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/writer/json/WriterTest.java b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/writer/json/WriterTest.java new file mode 100644 index 0000000000..9e7c2550dc --- /dev/null +++ b/neoemf-io/src/test/java/fr/inria/atlanmod/neoemf/io/writer/json/WriterTest.java @@ -0,0 +1,42 @@ +package fr.inria.atlanmod.neoemf.io.writer.json; + +import fr.inria.atlanmod.neoemf.tests.sample.Node; +import fr.inria.atlanmod.neoemf.tests.sample.SampleFactory; +import fr.inria.atlanmod.neoemf.tests.sample.SamplePackage; +import fr.inria.atlanmod.neoemf.tests.sample.Value; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import store.StoreFactory; +import store.StorePackage; + +import java.io.IOException; +import java.util.Arrays; +import java.util.function.Consumer; + +public class WriterTest { + @BeforeAll + static void initialize() { + SamplePackage.eINSTANCE.eClass(); + StorePackage.eINSTANCE.eClass(); + } + + @Test + void testSingleAttribute() throws IOException { + Helper.testMigration("GeneratedInstances/singleAttribute/"); + } + + @Test + void testMultipleAttributes() throws IOException { + Helper.testMigration("GeneratedInstances/multipleAttributes/"); + } + + @Test + void testMultiContainmentReference() throws IOException { + Helper.testMigration("GeneratedInstances/multiContainmentReference/"); + } +} diff --git a/neoemf-io/src/test/resources/model/Java.aird b/neoemf-io/src/test/resources/model/Java.aird new file mode 100644 index 0000000000..78f2a6a9af --- /dev/null +++ b/neoemf-io/src/test/resources/model/Java.aird @@ -0,0 +1,17 @@ + + + Java.ecore + Java.genmodel + + + + + + + + + + + + + diff --git a/neoemf-io/src/test/resources/model/Sample.aird b/neoemf-io/src/test/resources/model/Sample.aird new file mode 100644 index 0000000000..21c478e4b8 --- /dev/null +++ b/neoemf-io/src/test/resources/model/Sample.aird @@ -0,0 +1,1566 @@ + + + + Sample.ecore + Sample.genmodel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + italic + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + italic + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + italic + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + italic + + + + + + + + + + + + italic + + + + + + + + + + + + italic + + + + + + + + + + + + italic + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/neoemf-io/src/test/resources/model/store.ecore b/neoemf-io/src/test/resources/model/store.ecore new file mode 100644 index 0000000000..87499d6348 --- /dev/null +++ b/neoemf-io/src/test/resources/model/store.ecore @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/neoemf-io/src/test/resources/model/subSampleModel/.gitkeep b/neoemf-io/src/test/resources/model/subSampleModel/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/Sample.aird b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/Sample.aird new file mode 100644 index 0000000000..e961760752 --- /dev/null +++ b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/Sample.aird @@ -0,0 +1,314 @@ + + + + Sample.ecore + Sample.genmodel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + italic + + + + + + + + + + + + + + + + italic + + + + + + + + + + italic + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + diff --git a/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/Sample.ecore b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/Sample.ecore new file mode 100644 index 0000000000..d88b74a8f0 --- /dev/null +++ b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/Sample.ecore @@ -0,0 +1,17 @@ + + + +
+
+
+
+
+
+
+
+ + + + + diff --git a/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/Sample.genmodel b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/Sample.genmodel new file mode 100644 index 0000000000..e33ac6c493 --- /dev/null +++ b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/Sample.genmodel @@ -0,0 +1,16 @@ + + + Sample.ecore + + + + + + diff --git a/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/build.properties b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/build.properties new file mode 100644 index 0000000000..d54d9dc3ad --- /dev/null +++ b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/build.properties @@ -0,0 +1,9 @@ +# + +bin.includes = .,\ + model/,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src-gen/ +output.. = bin/ diff --git a/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/plugin.properties b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/plugin.properties new file mode 100644 index 0000000000..e27e39b957 --- /dev/null +++ b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = Sample Model +providerName = www.example.org diff --git a/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/plugin.xml b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/plugin.xml new file mode 100644 index 0000000000..bab04ba4f5 --- /dev/null +++ b/neoemf-io/src/test/resources/model/subSampleModel/simplestClass/plugin.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/neoemf-tests/pom.xml b/neoemf-tests/pom.xml index 55f797a01d..13a06d65ee 100644 --- a/neoemf-tests/pom.xml +++ b/neoemf-tests/pom.xml @@ -220,6 +220,12 @@ test-jar test + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/neoemf-utils/p2/pom.xml b/neoemf-utils/p2/pom.xml index 23c20a674f..bc05b4d7a9 100644 --- a/neoemf-utils/p2/pom.xml +++ b/neoemf-utils/p2/pom.xml @@ -21,6 +21,14 @@ 2.3.0 + + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + + diff --git a/neoemf-utils/pom.xml b/neoemf-utils/pom.xml index 3e14249471..23f8f7c435 100644 --- a/neoemf-utils/pom.xml +++ b/neoemf-utils/pom.xml @@ -51,6 +51,12 @@ guava ${guava.version} + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile + diff --git a/pom.xml b/pom.xml index fbaa0fefa7..b00e4d090e 100644 --- a/pom.xml +++ b/pom.xml @@ -183,6 +183,12 @@ jaxb-runtime 3.0.0 + + com.devialab + jackson-jsonld-maven + 0.0.4 + compile +