Skip to content

Commit

Permalink
Merge pull request #27 from ideas-into-software/issue25-multidimensio…
Browse files Browse the repository at this point in the history
…nal-arrays-support
  • Loading branch information
juergen-albert authored May 13, 2024
2 parents 7fbeda5 + 365377f commit 919a8b5
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 32 deletions.
6 changes: 3 additions & 3 deletions cnf/build.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
dimcBaselining: true
mavenCentral: true
github-project: org.gecko.emf.persistence
base-version: 6.1.0
base-version: 6.1.1
repository-base-version: 9.3.0.${tstamp}-SNAPSHOT

# Maven Central Group-Id
Expand All @@ -29,8 +29,8 @@ javac.target: 11

-plugin.3.Central: \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
snapshotUrl="https://oss.sonatype.org/content/repositories/snapshots/"; \
releaseUrl=https://repo.maven.apache.org/maven2/; \
snapshotUrl="https://oss.sonatype.org/content/repositories/snapshots/,https://devel.data-in-motion.biz/nexus/repository/dim-snapshot/"; \
releaseUrl="https://repo.maven.apache.org/maven2/,https://devel.data-in-motion.biz/nexus/repository/dim-release/"; \
index=${.}/central.mvn; \
readOnly=true; \
poll.time=-1; \
Expand Down
6 changes: 5 additions & 1 deletion cnf/central.mvn
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ org.eclipse.platform:org.eclipse.core.runtime:3.26.100
org.eclipse.emf:org.eclipse.emf.codegen:2.23.0
org.eclipse.emf:org.eclipse.emf.codegen.ecore:2.33.0
org.eclipse.emf:org.eclipse.emf.common:2.28.0
org.eclipse.emf:org.eclipse.emf.common:2.30.0
org.eclipse.emf:org.eclipse.emf.ecore:2.33.0
org.eclipse.emf:org.eclipse.emf.ecore:2.36.0
org.eclipse.emf:org.eclipse.emf.ecore.xcore.lib:1.7.0
org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.18.0
org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.37.0
org.eclipse.emfcloud:emfjson-jackson:2.2.0
org.eclipse.platform:org.eclipse.equinox.common:3.17.0
org.eclipse.platform:org.eclipse.equinox.registry:3.11.200
Expand Down Expand Up @@ -142,7 +145,8 @@ org.geckoprojects.bnd:org.gecko.bnd.dimc.library:1.5.0
org.geckoprojects.bnd:org.gecko.bnd.jacoco.library:1.5.0
org.geckoprojects.bnd:org.gecko.bnd.osgitest.library:1.5.0
org.geckoprojects.emf:org.gecko.emf.osgi.bnd.library.workspace:6.0.2
org.geckoprojects.emf:org.gecko.emf.osgi.example.model.basic:6.0.2
org.geckoprojects.emf:org.gecko.emf.osgi.example.model.basic:6.2.0-SNAPSHOT
org.geckoprojects.emf:org.gecko.emf.osgi.example.model.extended:6.2.0-SNAPSHOT
org.geckoprojects.emf.utils:org.gecko.emf.collections:2.2.2
org.mongodb:mongo-java-driver:3.12.14
org.geckoprojects.emf:org.gecko.emf.pushstreams:1.0.15
Expand Down
1 change: 1 addition & 0 deletions org.gecko.emf.mongo.test/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Fragment-Host: org.gecko.emf.mongo.pushstream
org.mongodb.mongo-java-driver;version=latest,\
org.gecko.emf.osgi.api;version=latest,\
org.gecko.emf.osgi.example.model.basic;version=latest,\
org.gecko.emf.osgi.example.model.extended;version=latest,\
org.gecko.emf.collections,\
org.gecko.mongo.osgi.api;version=latest,\
org.gecko.mongo.osgi.component;version=latest,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.gecko.emf.osgi.constants.EMFNamespaces;
import org.gecko.emf.osgi.example.model.basic.BasicFactory;
import org.gecko.emf.osgi.example.model.basic.Geometry;
import org.gecko.emf.osgi.example.model.extended.ExtendedFactory;
import org.gecko.emf.osgi.example.model.extended.ExtendedGeometry;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -197,4 +199,99 @@ public void testMultiDimensionalArray() throws IOException, InvalidSyntaxExcepti

}

@Test
public void testExtendedGeometryOneCoordinate() throws IOException, InvalidSyntaxException, InterruptedException {
ResourceSet resourceSet = rsAware.waitForService(2000l);

System.out.println("Dropping DB");
MongoCollection<Document> geoCollection = client.getDatabase("test").getCollection("ExtendedGeometry");
geoCollection.drop();

assertEquals(0, geoCollection.countDocuments());
Resource resource = resourceSet
.createResource(URI.createURI("mongodb://" + mongoHost + ":27017/test/ExtendedGeometry/"));

// Create the ExtendedGeometry object
ExtendedGeometry extendedGeometry = ExtendedFactory.eINSTANCE.createExtendedGeometry();
extendedGeometry.setOneCoordinate(new Double[] { 11.23, 58.98 });

String geoId = UUID.randomUUID().toString();
extendedGeometry.setId(geoId);

// save the ExtendedGeometry object
resource.getContents().add(extendedGeometry);
resource.save(null);

resource.getContents().clear();
resource.unload();

// load the ExtendedGeometry object from the db
Resource findResource = resourceSet.createResource(
URI.createURI("mongodb://" + mongoHost + ":27017/test/ExtendedGeometry/" + extendedGeometry.getId()));
findResource.load(null);
assertNotNull(findResource);
assertFalse(findResource.getContents().isEmpty());
assertEquals(1, findResource.getContents().size());

assertTrue(findResource.getContents().get(0) instanceof ExtendedGeometry);
ExtendedGeometry retrievedExtendedGeometry = (ExtendedGeometry) findResource.getContents().get(0);
assertEquals(geoId, retrievedExtendedGeometry.getId());

assertNotNull(retrievedExtendedGeometry.getOneCoordinate());
assertTrue(retrievedExtendedGeometry.getOneCoordinate().getClass().isArray());
assertEquals(2, retrievedExtendedGeometry.getOneCoordinate().length);
assertEquals(11.23, retrievedExtendedGeometry.getOneCoordinate()[0], 0.001);
assertEquals(58.98, retrievedExtendedGeometry.getOneCoordinate()[1], 0.001);

geoCollection.drop();
}

@Test
public void testExtendedGeometryOneMultiDimensionalCoordinate()
throws IOException, InvalidSyntaxException, InterruptedException {
ResourceSet resourceSet = rsAware.waitForService(2000l);

System.out.println("Dropping DB");
MongoCollection<Document> geoCollection = client.getDatabase("test").getCollection("ExtendedGeometry");
geoCollection.drop();

assertEquals(0, geoCollection.countDocuments());
Resource resource = resourceSet
.createResource(URI.createURI("mongodb://" + mongoHost + ":27017/test/ExtendedGeometry/"));

// Create the ExtendedGeometry object
ExtendedGeometry extendedGeometry = ExtendedFactory.eINSTANCE.createExtendedGeometry();
extendedGeometry.setOneMultiDimensionalCoordinate(new Double[][] { new Double[] { 11.23, 58.98 } });

String geoId = UUID.randomUUID().toString();
extendedGeometry.setId(geoId);

// save the ExtendedGeometry object
resource.getContents().add(extendedGeometry);
resource.save(null);

resource.getContents().clear();
resource.unload();

// load the ExtendedGeometry object from the db
Resource findResource = resourceSet.createResource(
URI.createURI("mongodb://" + mongoHost + ":27017/test/ExtendedGeometry/" + extendedGeometry.getId()));
findResource.load(null);
assertNotNull(findResource);
assertFalse(findResource.getContents().isEmpty());
assertEquals(1, findResource.getContents().size());

assertTrue(findResource.getContents().get(0) instanceof ExtendedGeometry);
ExtendedGeometry retrievedExtendedGeometry = (ExtendedGeometry) findResource.getContents().get(0);
assertEquals(geoId, retrievedExtendedGeometry.getId());

assertNotNull(retrievedExtendedGeometry.getOneMultiDimensionalCoordinate());
assertTrue(retrievedExtendedGeometry.getOneMultiDimensionalCoordinate().getClass().isArray());
assertEquals(1, retrievedExtendedGeometry.getOneMultiDimensionalCoordinate().length);
assertEquals(2, retrievedExtendedGeometry.getOneMultiDimensionalCoordinate()[0].length);
assertEquals(11.23, retrievedExtendedGeometry.getOneMultiDimensionalCoordinate()[0][0], 0.001);
assertEquals(58.98, retrievedExtendedGeometry.getOneMultiDimensionalCoordinate()[0][1], 0.001);

geoCollection.drop();
}
}
12 changes: 6 additions & 6 deletions org.gecko.emf.mongo.test/test.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
org.osgi.test.junit5;version='[1.2.1,1.2.2)',\
org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\
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.mongo.component;version=snapshot,\
org.gecko.mongo.osgi.component;version=snapshot,\
org.mongodb.mongo-java-driver;version='[3.12.14,3.12.15)',\
Expand All @@ -36,10 +33,13 @@
org.osgi.util.converter;version='[1.0.9,1.0.10)',\
org.osgi.test.junit5.cm;version='[1.2.1,1.2.2)',\
org.gecko.emf.collections;version='[2.2.2,2.2.3)',\
org.gecko.mongo.osgi.api;version=snapshot,\
org.gecko.emf.mongo.pushstream;version=snapshot,\
org.gecko.emf.pushstreams;version='[1.0.15,1.0.16)',\
org.osgi.util.pushstream;version='[1.1.0,1.1.1)',\
org.gecko.emf.osgi.api;version='[6.0.2,6.0.3)',\
org.gecko.emf.osgi.component;version='[6.0.2,6.0.3)',\
org.gecko.emf.osgi.example.model.basic;version='[6.0.2,6.0.3)'
org.eclipse.emf.common;version='[2.30.0,2.30.1)',\
org.eclipse.emf.ecore;version='[2.36.0,2.36.1)',\
org.eclipse.emf.ecore.xmi;version='[2.37.0,2.37.1)',\
org.gecko.emf.osgi.example.model.basic;version='[6.2.0,6.2.1)',\
org.osgi.service.metatype;version='[1.4.1,1.4.2)',\
org.gecko.emf.osgi.example.model.extended;version='[6.2.0,6.2.1)'
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public void writePrimitiveValue(String name, Object value, BsonWriter writer) {

if(!(value instanceof byte[]) && value.getClass().isArray()) {
Object[] array = (Object[]) value;
writer.writeStartArray();
writer.writeStartArray(name);
for (Object object : array) {
writePrimitiveValueNoName(object, writer);
}
Expand Down
5 changes: 0 additions & 5 deletions org.gecko.emf.repository.mongo.tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,5 @@
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
<classpathentry kind="src" output="bin" path="src"/>
<classpathentry kind="src" output="bin_test" path="test">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
11 changes: 5 additions & 6 deletions org.gecko.emf.repository.mongo.tests/test.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
org.osgi.util.promise;version='[1.3.0,1.3.1)',\
org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\
org.apache.felix.metatype;version='[1.2.4,1.2.5)',\
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.collections;version='[2.2.2,2.2.3)',\
org.gecko.emf.mongo.component;version=snapshot,\
org.gecko.emf.repository.api;version=snapshot,\
Expand All @@ -36,13 +33,15 @@
net.bytebuddy.byte-buddy;version='[1.14.9,1.14.10)',\
net.bytebuddy.byte-buddy-agent;version='[1.14.9,1.14.10)',\
org.gecko.emf.repository.mongo.tests;version=snapshot,\
org.gecko.mongo.osgi.api;version=snapshot,\
org.mockito.junit-jupiter;version='[4.11.0,4.11.1)',\
org.mockito.mockito-core;version='[4.11.0,4.11.1)',\
org.objenesis;version='[3.3.0,3.3.1)',\
org.opentest4j;version='[1.3.0,1.3.1)',\
org.osgi.test.common;version='[1.2.1,1.2.2)',\
org.osgi.test.junit5;version='[1.2.1,1.2.2)',\
org.gecko.emf.osgi.api;version='[6.0.2,6.0.3)',\
org.gecko.emf.osgi.component;version='[6.0.2,6.0.3)',\
org.gecko.emf.osgi.example.model.basic;version='[6.0.2,6.0.3)'
org.eclipse.emf.common;version='[2.30.0,2.30.1)',\
org.eclipse.emf.ecore;version='[2.36.0,2.36.1)',\
org.eclipse.emf.ecore.xmi;version='[2.37.0,2.37.1)',\
org.gecko.emf.osgi.example.model.basic;version='[6.2.0,6.2.1)',\
org.osgi.service.metatype;version='[1.4.1,1.4.2)'
5 changes: 0 additions & 5 deletions org.gecko.emf.repository.tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin" path="src"/>
<classpathentry kind="src" output="bin_test" path="test">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
9 changes: 4 additions & 5 deletions org.gecko.emf.repository.tests/test.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
org.osgi.util.function;version='[1.2.0,1.2.1)',\
org.osgi.util.promise;version='[1.3.0,1.3.1)',\
org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\
org.eclipse.emf.common;version='[2.28.0,2.28.1)',\
org.eclipse.emf.ecore;version='[2.33.0,2.33.1)',\
org.gecko.emf.repository.api;version=snapshot,\
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)',\
net.bytebuddy.byte-buddy;version='[1.14.9,1.14.10)',\
net.bytebuddy.byte-buddy-agent;version='[1.14.9,1.14.10)',\
org.eclipse.emf.ecore.xmi;version='[2.18.0,2.18.1)',\
org.gecko.emf.repository.tests;version=snapshot,\
org.mockito.junit-jupiter;version='[4.11.0,4.11.1)',\
org.mockito.mockito-core;version='[4.11.0,4.11.1)',\
Expand All @@ -37,6 +34,8 @@
org.osgi.service.log;version='[1.5.0,1.5.1)',\
org.osgi.util.converter;version='[1.0.9,1.0.10)',\
org.gecko.emf.repository.file;version=snapshot,\
org.gecko.emf.osgi.api;version='[6.0.2,6.0.3)',\
org.gecko.emf.osgi.component;version='[6.0.2,6.0.3)',\
org.gecko.emf.osgi.example.model.basic;version='[6.0.2,6.0.3)'
org.eclipse.emf.common;version='[2.30.0,2.30.1)',\
org.eclipse.emf.ecore;version='[2.36.0,2.36.1)',\
org.eclipse.emf.ecore.xmi;version='[2.37.0,2.37.1)',\
org.gecko.emf.osgi.example.model.basic;version='[6.2.0,6.2.1)'

0 comments on commit 919a8b5

Please sign in to comment.