Skip to content

Commit

Permalink
ODS (OpenDocument Spreadsheet) Exporter for EMF (c.d.)
Browse files Browse the repository at this point in the history
 - Potential fix for performance issue - over 7 times (700+%) speed-up

 - Refactoring

 - (temporarily) large-data set (trees) for performance measurement

Signed-off-by: Michael H. Siemaszko <m.siemaszko@datainmotion.com>
  • Loading branch information
Michael H. Siemaszko committed Sep 2, 2023
1 parent 75ffb50 commit f912ee3
Show file tree
Hide file tree
Showing 32 changed files with 214,281 additions and 81 deletions.
5 changes: 5 additions & 0 deletions cnf/central.mvn
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,8 @@ com.google.guava:failureaccess:1.0.1
# maintainer of https://github.com/miachm/SODS did not merge https://github.com/miachm/SODS/pull/63 yet, so e.g. 'com.github.miachm.sods.LinkedValue' is missing
#com.github.miachm.sods:SODS:1.6.2

org.apache.servicemix.bundles:org.apache.servicemix.bundles.poi:5.2.2_3
org.apache.commons:commons-compress:1.21
org.apache.logging.log4j:log4j-api:2.18.0
org.apache.logging.log4j:log4j-core:2.18.0
org.apache.logging.log4j:log4j-to-slf4j:2.18.0
11 changes: 11 additions & 0 deletions org.gecko.emf.exporter.ods.api/.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.api/.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.api/.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.api</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,5 @@
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
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
13 changes: 13 additions & 0 deletions org.gecko.emf.exporter.ods.api/bnd.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Bundle-Version: 1.0.0.SNAPSHOT
Bundle-Name: Gecko EMF ODS Exporter API
Bundle-Description: ODS (OpenDocument Spreadsheet) Exporter API for EMF

-library: enable-emf

-buildpath: \
org.gecko.emf.exporter,\
com.github.miachm.sods,\
org.apache.commons.commons-text;version='1.10',\
slf4j.api

Export-Package: org.gecko.emf.exporter.ods.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 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.exporter.ods.api;

import org.gecko.emf.exporter.EMFExportOptions;

/**
* ODS export options.
*
* @author Michal H. Siemaszko
*/
public interface EMFODSExportOptions extends EMFExportOptions {

// automatically adjust column width based on contents
String OPTION_ADJUST_COLUMN_WIDTH = "ADJUST_COLUMN_WIDTH"; // TODO: extract to org.gecko.emf.exporter.ods.EMFODSExportOptions

// generate links for references
String OPTION_GENERATE_LINKS = "GENERATE_LINKS"; // TODO: extract to org.gecko.emf.exporter.ods.EMFODSExportOptions

// TODO: freezing rows is currently not supported in SODS
// freeze header row
// String OPTION_FREEZE_HEADER_ROW = "FREEZE_HEADER_ROW";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@org.osgi.annotation.versioning.Version("1.0.0")
@org.osgi.annotation.bundle.Export
package org.gecko.emf.exporter.ods.api;
4 changes: 3 additions & 1 deletion org.gecko.emf.exporter.ods.tests/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ Bundle-Version: 1.0.0.SNAPSHOT
org.eclipse.emf.ecore,\
org.gecko.emf.osgi.example.model.basic,\
org.gecko.emf.exporter;version=latest,\
org.gecko.emf.exporter.ods.api;version=latest,\
org.apache.commons.commons-text,\
org.gecko.emf.util.model
org.gecko.emf.util.model,\
org.gecko.emf.trees.model;version=latest
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.gecko.emf.ods.tests.helper.EMFODSExporterTestHelper.createSimpsonFamily;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.io.File;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -27,16 +28,20 @@
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.gecko.emf.exporter.EMFExportOptions;
import org.gecko.emf.exporter.EMFExporter;
import org.gecko.emf.exporter.ods.api.EMFODSExportOptions;
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.Disabled;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand All @@ -49,6 +54,8 @@
import org.osgi.test.junit5.context.BundleContextExtension;
import org.osgi.test.junit5.service.ServiceExtension;

import trees.TreesPackage;

/**
* EMF ODS exporter integration test.
*
Expand All @@ -59,7 +66,10 @@
@ExtendWith(ServiceExtension.class)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class EMFODSExporterTest {

private static final String TREES_DATASET_XMI = System.getProperty("TREES_DATASET_XMI");

@Disabled
@Order(value = -1)
@Test
public void testServices(
Expand All @@ -70,6 +80,7 @@ public void testServices(
assertThat(emfOdsExporterReference).isNotNull();
}

@Disabled
@Test
public void testExportBasicPackageResourceToOds(
@InjectService(cardinality = 1, timeout = 4000, filter = "(component.name=EMFODSExporter)") ServiceAware<EMFExporter> emfOdsExporterAware,
Expand Down Expand Up @@ -102,14 +113,15 @@ public void testExportBasicPackageResourceToOds(
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,
EMFODSExportOptions.OPTION_ADJUST_COLUMN_WIDTH, true,
EMFODSExportOptions.OPTION_GENERATE_LINKS, true,
EMFExportOptions.OPTION_ADD_MAPPING_TABLE, true
)
);
// @formatter:on
}

@Disabled
@Test
public void testExportUtilitiesPackageResourceToOds(
@InjectService(cardinality = 1, timeout = 4000, filter = "(component.name=EMFODSExporter)") ServiceAware<EMFExporter> emfOdsExporterAware)
Expand All @@ -131,11 +143,95 @@ public void testExportUtilitiesPackageResourceToOds(
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,
EMFODSExportOptions.OPTION_ADJUST_COLUMN_WIDTH, true,
EMFODSExportOptions.OPTION_GENERATE_LINKS, true,
EMFExportOptions.OPTION_ADD_MAPPING_TABLE, true
)
);
// @formatter:on
}

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

assertNotNull(rsAware);
assertThat(rsAware.getServices()).hasSize(1);
ResourceSet resourceSet = rsAware.getService();
assertNotNull(resourceSet);

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

// register model
EPackage.Registry packageRegistry = resourceSet.getPackageRegistry();
packageRegistry.put(TreesPackage.eNS_URI, TreesPackage.eINSTANCE);

// register xmi
Map<String, Object> extensionFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
extensionFactoryMap.put("xmi", new XMIResourceFactoryImpl());

Resource resource = resourceSet.getResource(URI.createFileURI(new File(TREES_DATASET_XMI).getAbsolutePath()), true);

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

OutputStream fileOutputStream = Files.newOutputStream(filePath);

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

// @Disabled
@Test
public void testExportLotsOfEObjectsToXLSX(@InjectService(timeout = 2000) ServiceAware<ResourceSet> rsAware,
@InjectService(cardinality = 1, timeout = 4000, filter = "(component.name=EMFXLSXExporter_POC)") ServiceAware<EMFExporter> emfxlsxExporterAware) throws Exception {

assertNotNull(rsAware);
assertThat(rsAware.getServices()).hasSize(1);
ResourceSet resourceSet = rsAware.getService();
assertNotNull(resourceSet);

assertThat(emfxlsxExporterAware.getServices()).hasSize(1);
EMFExporter emfXlsxExporterService = emfxlsxExporterAware.getService();
assertThat(emfXlsxExporterService).isNotNull();

// register model
EPackage.Registry packageRegistry = resourceSet.getPackageRegistry();
packageRegistry.put(TreesPackage.eNS_URI, TreesPackage.eINSTANCE);

// register xmi
Map<String, Object> extensionFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
extensionFactoryMap.put("xmi", new XMIResourceFactoryImpl());

Resource resource = resourceSet.getResource(URI.createFileURI(new File(TREES_DATASET_XMI).getAbsolutePath()), true);

Path filePath = Files.createTempFile("treesPackageExportEObjectsToTest", ".xlsx");

OutputStream fileOutputStream = Files.newOutputStream(filePath);

// @formatter:off
emfXlsxExporterService.exportEObjectsTo(resource.getContents(), fileOutputStream,
Map.of(
EMFExportOptions.OPTION_LOCALE, Locale.GERMANY,
EMFExportOptions.OPTION_EXPORT_NONCONTAINMENT, true,
EMFExportOptions.OPTION_EXPORT_METADATA, true,
EMFODSExportOptions.OPTION_ADJUST_COLUMN_WIDTH, true,
EMFODSExportOptions.OPTION_GENERATE_LINKS, true,
EMFExportOptions.OPTION_ADD_MAPPING_TABLE, true
)
);
// @formatter:on
}
}
41 changes: 27 additions & 14 deletions org.gecko.emf.exporter.ods.tests/test.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,25 @@
-resolve.effective: active

-runbundles.junit5: ${test.runbundles}


-runrequires: \
bnd.identity;id='org.gecko.emf.exporter.ods',\
bnd.identity;id='org.gecko.emf.exporter.ods.tests'

-runee: JavaSE-11

-runtrace: true

-runproperties.debug: \
felix.log.level=4,\
org.osgi.service.log.admin.loglevel=DEBUG,\

-runproperties.poi: \
org.osgi.framework.bootdelegation=org.w3c.dom

-runproperties.trees: \
TREES_DATASET_XMI="${.}/testdata/Trees/CityTree.xmi"

-runbundles: \
junit-jupiter-api;version='[5.8.2,5.8.3)',\
junit-platform-commons;version='[1.8.2,1.8.3)',\
Expand Down Expand Up @@ -47,16 +65,11 @@
org.apache.commons.logging;version='[1.2.0,1.2.1)',\
slf4j.api;version='[1.7.36,1.7.37)',\
slf4j.simple;version='[1.7.25,1.7.26)',\
org.gecko.emf.bson;version=snapshot,\
org.gecko.emf.collections;version=snapshot

-runrequires: bnd.identity;id='org.gecko.emf.exporter.ods.tests'

-runee: JavaSE-11

-runtrace: true

-runproperties.debug: \
felix.log.level=4,\
org.osgi.service.log.admin.loglevel=DEBUG

com.google.guava;version='[32.1.2,32.1.3)',\
com.google.guava.failureaccess;version='[1.0.1,1.0.2)',\
org.gecko.emf.trees.model;version=snapshot,\
org.osgi.service.component;version='[1.4.0,1.4.1)',\
org.apache.commons.commons-compress;version='[1.21.0,1.21.1)',\
org.apache.servicemix.bundles.poi;version='[5.2.2,5.2.3)',\
org.gecko.emf.collections;version=snapshot,\
org.gecko.emf.ods;version=snapshot
Loading

0 comments on commit f912ee3

Please sign in to comment.