Skip to content

Commit

Permalink
Merge pull request #8 from ideas-into-software/emf-ods-exporter-sods
Browse files Browse the repository at this point in the history
Replaced FastODS with SODS
  • Loading branch information
juergen-albert committed Jan 8, 2024
2 parents be7cdfb + 5e22c55 commit c7cadde
Show file tree
Hide file tree
Showing 55 changed files with 3,227 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ generated/
/.metadata/
/build/
cnf/release/
cnf/local/
src-gen
7 changes: 6 additions & 1 deletion cnf/central.mvn
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ org.geckoprojects.bnd:org.gecko.bnd.dimc.library:1.1.1
org.geckoprojects.bnd:org.gecko.bnd.osgitest.library:1.1.1
org.geckoprojects.bnd:org.gecko.bnd.jacoco.library:1.1.1

#org.geckoprojects.emf:org.gecko.emf.osgi.api:4.1.1.202202162308
org.geckoprojects.emf:org.gecko.emf.osgi.bnd.library.workspace:4.1.1-SNAPSHOT

com.fasterxml.jackson.core:jackson-core:2.14.1
Expand All @@ -163,3 +162,9 @@ org.eclipse.emfcloud:emfjson-jackson:2.2.0
de.undercouch:bson4jackson:2.13.1
org.yaml:snakeyaml:1.33
org.geckoprojects.emf:org.gecko.emf.osgi.example.model.basic:4.1.1-SNAPSHOT

org.apache.commons:commons-text:1.10.0
org.apache.commons:commons-lang3:3.12.0

com.google.guava:guava:31.1-jre
com.google.guava:failureaccess:1.0.1
Binary file not shown.
45 changes: 45 additions & 0 deletions cnf/local/index.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version='1.0' encoding='UTF-8'?>
<repository xmlns="http://www.osgi.org/xmlns/repository/v1.0.0" name="Local" increment="1679853698364">
<resource>
<capability namespace="osgi.identity">
<attribute name="license" value="&quot;The Unlicense&quot;;link=&quot;https://github.com/miachm/SODS/blob/master/LICENSE&quot;"/>
<attribute name="osgi.identity" value="com.github.miachm.sods"/>
<attribute name="documentation" value="https://github.com/miachm/SODS"/>
<attribute name="description" value="A library for load/save ODS files in java."/>
<attribute name="type" value="osgi.bundle"/>
<attribute name="version" value="1.5.3" type="Version"/>
</capability>
<capability namespace="osgi.wiring.package">
<attribute name="bundle-symbolic-name" value="com.github.miachm.sods"/>
<attribute name="bundle-version" value="1.5.3" type="Version"/>
<attribute name="osgi.wiring.package" value="com.github.miachm.sods"/>
<attribute name="version" value="1.5.3" type="Version"/>
<attribute name="bnd.hashes" value="1324511984,1731897767,2096514,65290051,2023997302,822061019,1624016101,-266320387,-1291886874,520469601,1895597947,351111864,-1115736232,82941713,-1440044159,-1284638927,228265771,-1821040144,-70786291,861476502,677306575,1812804717,2479866,78727453,1567574187,82362,97316887,79850815,1620534404,-482667636,1193265721,2039393584,80227729,465601004,477953699,1916493886,924543180,-1736520349,355567514,1511059808,-1059699121,-1060180405" type="List&lt;Long&gt;"/>
</capability>
<capability namespace="osgi.wiring.bundle">
<attribute name="bundle-version" value="1.5.3" type="Version"/>
<attribute name="osgi.wiring.bundle" value="com.github.miachm.sods"/>
</capability>
<capability namespace="osgi.wiring.host">
<attribute name="bundle-version" value="1.5.3" type="Version"/>
<attribute name="osgi.wiring.host" value="com.github.miachm.sods"/>
</capability>
<capability namespace="osgi.content">
<attribute name="size" value="146610" type="Long"/>
<attribute name="mime" value="application/vnd.osgi.bundle"/>
<attribute name="url" value="com.github.miachm.sods/com.github.miachm.sods-1.5.3.jar"/>
<attribute name="osgi.content" value="55A14104C48686365F5531CB8A95CF8FC2EF5D0A45775A65EA7AC08B424A9205"/>
</capability>
<requirement namespace="osgi.wiring.package">
<directive name="filter" value="(osgi.wiring.package=javax.xml.namespace)"/>
<attribute name="osgi.wiring.package" value="javax.xml.namespace"/>
</requirement>
<requirement namespace="osgi.wiring.package">
<directive name="filter" value="(osgi.wiring.package=javax.xml.stream)"/>
<attribute name="osgi.wiring.package" value="javax.xml.stream"/>
</requirement>
<requirement namespace="osgi.ee">
<directive name="filter" value="(&amp;(osgi.ee=JavaSE)(version=1.8))"/>
</requirement>
</resource>
</repository>
11 changes: 11 additions & 0 deletions org.gecko.emf.exporter.ods.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="src" output="bin" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 2 additions & 0 deletions org.gecko.emf.exporter.ods.tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin/
/bin_test/
23 changes: 23 additions & 0 deletions org.gecko.emf.exporter.ods.tests/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.gecko.emf.exporter.ods.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>bndtools.core.bndbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>bndtools.core.bndnature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
eclipse.preferences.version=1
encoding//.settings/org.eclipse.core.resources.prefs=UTF-8
encoding//.settings/org.eclipse.jdt.core.prefs=UTF-8
encoding//.settings/org.eclipse.jdt.ui.prefs=UTF-8
encoding/bnd.bnd=UTF-8
encoding/test.bndrun=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
17 changes: 17 additions & 0 deletions org.gecko.emf.exporter.ods.tests/bnd.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-enable-junit5: true
-library: enable-emf

javac.source: 11
javac.target: 11

Bundle-Version: 1.0.0.SNAPSHOT

-buildpath: \
org.gecko.emf.osgi.component,\
org.eclipse.emf.ecore.xmi,\
org.eclipse.emf.ecore,\
org.gecko.emf.osgi.example.model.basic,\
org.gecko.emf.exporter;version=latest,\
org.apache.commons.commons-text,\
org.gecko.emf.util.model,\
com.github.miachm.sods
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/**
* Copyright (c) 2012 - 2023 Data In Motion and others.
* All rights reserved.
*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Data In Motion - initial API and implementation
*/
package org.gecko.emf.ods.tests;

import static org.assertj.core.api.Assertions.assertThat;
import static org.gecko.emf.ods.tests.helper.EMFODSExporterTestHelper.createBasicPackageResourceSet;
import static org.gecko.emf.ods.tests.helper.EMFODSExporterTestHelper.createBusinessPerson;
import static org.gecko.emf.ods.tests.helper.EMFODSExporterTestHelper.createFlintstonesFamily;
import static org.gecko.emf.ods.tests.helper.EMFODSExporterTestHelper.createRequest;
import static org.gecko.emf.ods.tests.helper.EMFODSExporterTestHelper.createSimpsonFamily;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.gecko.emf.exporter.EMFExportOptions;
import org.gecko.emf.exporter.EMFExporter;
import org.gecko.emf.osgi.example.model.basic.BasicFactory;
import org.gecko.emf.osgi.example.model.basic.BasicPackage;
import org.gecko.emf.osgi.example.model.basic.BusinessPerson;
import org.gecko.emf.osgi.example.model.basic.Family;
import org.gecko.emf.utilities.Request;
import org.gecko.emf.utilities.UtilitiesFactory;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.commons.annotation.Testable;
import org.osgi.framework.ServiceReference;
import org.osgi.test.common.annotation.InjectService;
import org.osgi.test.common.service.ServiceAware;
import org.osgi.test.junit5.context.BundleContextExtension;
import org.osgi.test.junit5.service.ServiceExtension;

/**
* EMF ODS exporter integration test.
*
* @author Michal H. Siemaszko
*/
@Testable
@ExtendWith(BundleContextExtension.class)
@ExtendWith(ServiceExtension.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class EMFODSExporterTest {

@Order(value = -1)
@Test
public void testServices(
@InjectService(cardinality = 1, timeout = 4000, filter = "(component.name=EMFODSExporter)") ServiceAware<EMFExporter> emfOdsExporterAware) {

assertThat(emfOdsExporterAware.getServices()).hasSize(1);
ServiceReference<EMFExporter> emfOdsExporterReference = emfOdsExporterAware.getServiceReference();
assertThat(emfOdsExporterReference).isNotNull();
}

@Test
public void testExportBasicPackageResourceToOds(
@InjectService(cardinality = 1, timeout = 4000, filter = "(component.name=EMFODSExporter)") ServiceAware<EMFExporter> emfOdsExporterAware,
@InjectService BasicFactory basicFactory, @InjectService BasicPackage basicPackage) throws Exception {

assertThat(emfOdsExporterAware.getServices()).hasSize(1);
EMFExporter emfOdsExporterService = emfOdsExporterAware.getService();
assertThat(emfOdsExporterService).isNotNull();

ResourceSet resourceSet = createBasicPackageResourceSet(basicPackage);
Resource xmiResource = resourceSet.createResource(URI.createURI("basicPackageExporter.test"));
assertNotNull(xmiResource);

Family simpsonFamily = createSimpsonFamily(basicFactory);
xmiResource.getContents().add(simpsonFamily);

Family flintstonesFamily = createFlintstonesFamily(basicFactory);
xmiResource.getContents().add(flintstonesFamily);

BusinessPerson businessPerson = createBusinessPerson(basicFactory);
xmiResource.getContents().add(businessPerson);

Path filePath = Files.createTempFile("testBasicPackageExport", ".ods");

OutputStream fileOutputStream = Files.newOutputStream(filePath);

// @formatter:off
emfOdsExporterService.exportResourceTo(xmiResource, fileOutputStream,
Map.of(
EMFExportOptions.OPTION_LOCALE, Locale.GERMANY,
EMFExportOptions.OPTION_EXPORT_NONCONTAINMENT, true,
EMFExportOptions.OPTION_EXPORT_METADATA, true,
EMFExportOptions.OPTION_ADJUST_COLUMN_WIDTH, true,
EMFExportOptions.OPTION_GENERATE_LINKS, true,
EMFExportOptions.OPTION_ADD_MAPPING_TABLE, true
)
);
// @formatter:on
}

@Test
public void testExportUtilitiesPackageResourceToOds(
@InjectService(cardinality = 1, timeout = 4000, filter = "(component.name=EMFODSExporter)") ServiceAware<EMFExporter> emfOdsExporterAware)
throws Exception {

assertThat(emfOdsExporterAware.getServices()).hasSize(1);
EMFExporter emfOdsExporterService = emfOdsExporterAware.getService();
assertThat(emfOdsExporterService).isNotNull();

Request request = createRequest(UtilitiesFactory.eINSTANCE);

Path filePath = Files.createTempFile("testUtilitiesPackageExport", ".ods");

OutputStream fileOutputStream = Files.newOutputStream(filePath);

// @formatter:off
emfOdsExporterService.exportEObjectsTo(List.of(request), fileOutputStream,
Map.of(
EMFExportOptions.OPTION_LOCALE, Locale.GERMANY,
EMFExportOptions.OPTION_EXPORT_NONCONTAINMENT, true,
EMFExportOptions.OPTION_EXPORT_METADATA, true,
EMFExportOptions.OPTION_ADJUST_COLUMN_WIDTH, true,
EMFExportOptions.OPTION_GENERATE_LINKS, true,
EMFExportOptions.OPTION_ADD_MAPPING_TABLE, true
)
);
// @formatter:on
}
}
Loading

0 comments on commit c7cadde

Please sign in to comment.