Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0bfbbcf
Added emf-jackson dependency for json testing
DaikiKaminari Oct 6, 2021
02afb86
Prepare for json writer
DaikiKaminari Oct 28, 2021
e20c369
Add json jackson dependency to pom
DaikiKaminari Oct 29, 2021
5b482a1
Method skeleton for json writer
DaikiKaminari Oct 29, 2021
614d9eb
Add JsonWriterTest to test writing json and a tiny ecore model for te…
DaikiKaminari Oct 30, 2021
ad1d51f
Fix json-jackson save
DaikiKaminari Nov 13, 2021
2371804
Not a commit, just the current state in the middle of testing..
DaikiKaminari Nov 22, 2021
4110f1d
Latest tests
DaikiKaminari Nov 23, 2021
51face7
Fix bug with jackson
DaikiKaminari Nov 25, 2021
a9235e9
Implementation of attribute serialization in json
DaikiKaminari Nov 29, 2021
8f2d113
Added automated testing with JUnit for JsonWriter
DaikiKaminari Dec 28, 2021
3c4d4b2
Removed files generated during tests
DaikiKaminari Dec 28, 2021
2d5efb9
Added test for multi valued attributes
DaikiKaminari Dec 31, 2021
59912df
reader start
mdiallogn Dec 28, 2021
c87bf5c
merge
mdiallogn Jan 1, 2022
a3bc06d
Try to fix loading from xmi to the mapper
DaikiKaminari Jan 2, 2022
c6591d9
local changes
mdiallogn Jan 5, 2022
f15f18f
Merge remote-tracking branch 'origin/master'
mdiallogn Jan 5, 2022
324c47d
Fix error for xmi, need to fix error with emfjson-jackson
DaikiKaminari Jan 7, 2022
e3e41cc
merge
DaikiKaminari Jan 7, 2022
99b2429
[WIP] Fixing containment ref serialization
DaikiKaminari Jan 8, 2022
a0748a5
Added tests sample, need to fix error when running tests
DaikiKaminari Jan 12, 2022
89171ba
Refactor
DaikiKaminari Jan 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,3 @@
**/java-gen
**/src-gen/



16 changes: 14 additions & 2 deletions neoemf-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
</description>

<properties>
<chronicle-map.version>3.21ea41</chronicle-map.version>
<chronicle-bytes.version>2.21ea43</chronicle-bytes.version>
<chronicle-map.version>3.22ea5</chronicle-map.version>
<chronicle-bytes.version>2.22ea17</chronicle-bytes.version>
<log4j.version>2.14.1</log4j.version>
<cglib.version>3.3.0</cglib.version>
</properties>
Expand Down Expand Up @@ -143,6 +143,18 @@
<optional>true</optional>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.devialab</groupId>
<artifactId>jackson-jsonld-maven</artifactId>
<version>0.0.4</version>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
6 changes: 6 additions & 0 deletions neoemf-data/berkeleydb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<groupId>com.sleepycat</groupId>
<artifactId>je</artifactId>
</dependency>
<dependency>
<groupId>com.devialab</groupId>
<artifactId>jackson-jsonld-maven</artifactId>
<version>0.0.4</version>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
6 changes: 6 additions & 0 deletions neoemf-data/blueprints/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
<artifactId>org.eclipse.emf.ecore</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.devialab</groupId>
<artifactId>jackson-jsonld-maven</artifactId>
<version>0.0.4</version>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
6 changes: 6 additions & 0 deletions neoemf-data/blueprints/neo4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.devialab</groupId>
<artifactId>jackson-jsonld-maven</artifactId>
<version>0.0.4</version>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
8 changes: 8 additions & 0 deletions neoemf-data/blueprints/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,13 @@
<blueprints.version>2.6.0</blueprints.version>
<commons-configuration.version>1.10</commons-configuration.version>
</properties>
<dependencies>
<dependency>
<groupId>com.devialab</groupId>
<artifactId>jackson-jsonld-maven</artifactId>
<version>0.0.4</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
6 changes: 6 additions & 0 deletions neoemf-data/hbase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>com.devialab</groupId>
<artifactId>jackson-jsonld-maven</artifactId>
<version>0.0.4</version>
<scope>compile</scope>
</dependency>


</dependencies>
Expand Down
6 changes: 6 additions & 0 deletions neoemf-data/mapdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
-->
<!-- compatibility issue with Guava/HBase (15.0) -->
</dependency>
<dependency>
<groupId>com.devialab</groupId>
<artifactId>jackson-jsonld-maven</artifactId>
<version>0.0.4</version>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
6 changes: 6 additions & 0 deletions neoemf-data/mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<scope>compile</scope><!-- FIXME Use 'test' scope: 'compile' is used to avoid errors in 'neoemf-tests' -->
</dependency>
<dependency>
<groupId>com.devialab</groupId>
<artifactId>jackson-jsonld-maven</artifactId>
<version>0.0.4</version>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
6 changes: 6 additions & 0 deletions neoemf-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.devialab</groupId>
<artifactId>jackson-jsonld-maven</artifactId>
<version>0.0.4</version>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
44 changes: 43 additions & 1 deletion neoemf-io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@
<stax.verions>1.0-2</stax.verions>
<stax2.version>4.2.1</stax2.version>
<woodstox.version>4.4.1</woodstox.version>
<jackson.version>2.13.1</jackson.version>

</properties>

<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>

<dependencies>

<!-- Commons -->
Expand Down Expand Up @@ -82,6 +92,24 @@
<artifactId>org.eclipse.emf.ecore.xcore.lib</artifactId>
</dependency>

<!-- JSON -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<scope>compile</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<scope>compile</scope>
</dependency>



<!-- Test -->

<dependency>
Expand Down Expand Up @@ -111,14 +139,24 @@
<artifactId>assertj-core</artifactId>
</dependency>

<dependency>
<groupId>org.emfjson</groupId>
<artifactId>emfjson-jackson</artifactId>
<version>1.3.0</version>
<type>bundle</type>
</dependency>

<!-- Test: EMF -->

<!--
<dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.ecore.xmi</artifactId>
<scope>test</scope>
</dependency>

-->


<!-- Test: Eclipse Runtime -->

Expand All @@ -129,7 +167,7 @@
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.runtime</artifactId>
<version>[3.20.0,)</version>
<version>3.23.0</version>
<scope>test</scope>
</dependency>

Expand All @@ -156,6 +194,10 @@
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>org.eclipse.emf.ecore.xmi</artifactId>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
39 changes: 37 additions & 2 deletions neoemf-io/src/main/java/fr/inria/atlanmod/neoemf/io/Migrator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -285,6 +288,36 @@ public Migrator<T> 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<T> 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<T> toJson(@WillNotClose OutputStream stream) throws IOException {
return to(new JsonStreamWriter(stream));
}

//endregion

//region Listeners
Expand Down Expand Up @@ -370,6 +403,8 @@ public void migrate() throws IOException {
try {
// Bind handlers and notifiers
Collection<Handler> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Id> identifiers = new ArrayDeque<>();

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down
Loading