From c02e32b76745d1919e32589740a30329ce590378 Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Tue, 20 Aug 2024 14:43:40 +0200 Subject: [PATCH 1/8] build!: use hale-core libraries as dependencies ING-4375 --- build.gradle | 113 +++++------------- .../groovy/to/wetransform/halecli/CLI.java | 2 +- .../CustomMetaClassCreationHandle.java | 101 ---------------- .../to/wetransform/halecli/internal/Init.java | 46 ------- .../match/postnas/PostNASPropertyInfo.groovy | 5 +- .../to/wetransform/halecli/RunnerTest.groovy | 19 +-- .../halecli/data/RewriteCommandTest.groovy | 2 +- 7 files changed, 44 insertions(+), 244 deletions(-) delete mode 100644 src/main/groovy/to/wetransform/halecli/internal/CustomMetaClassCreationHandle.java delete mode 100644 src/main/groovy/to/wetransform/halecli/internal/Init.java diff --git a/build.gradle b/build.gradle index 9e4576e..94f0107 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ java { group = 'to.wetransform' project.ext { - haleVersion = '5.3.0' + haleVersion = '5.4.0-SNAPSHOT' groovyVersion = '2.5.23' } @@ -66,60 +66,28 @@ configurations { dependencies { // HALE - // CLI API, utilities and default commands - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.util.cli:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.cli:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.app.cli.commands:$haleVersion" + // BOM + implementation(platform("eu.esdihumboldt.hale:bom:$haleVersion")) - implementation "org.codehaus.groovy:groovy-all:$groovyVersion" + /* + * Features + */ - // core - implementation 'eu.esdihumboldt.unpuzzled:org.eclipse.equinox.nonosgi.registry:1.0.0' - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.core:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.align.groovy:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.align.merge:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.referencing:$haleVersion" - - // transformation - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.app.transform:$haleVersion" - // needed to run successfully: - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.headless.orient:$haleVersion" // reiterable transformation sink (for WFS FeatureCollection) - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.propertyaccessor:$haleVersion" // for CQL filters to work - // transformation functions: - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.core:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.inspire:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.geometric:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.groovy:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.groovy.helpers:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.numeric:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.string:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.custom:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.collector:$haleVersion" - - // formats - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.xml:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.xsd:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.gml:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.shp:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.csv:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.wfs:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.json:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.xls:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.geopackage:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.html.svg:$haleVersion" - - // database support - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.postgresql:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.mssql:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.msaccess:$haleVersion" + // CLI and core hale libraries & resources + implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.app.feature.cli:$haleVersion" - // hale connect - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.haleconnect:$haleVersion" + // core I/O providers and core hale libraries & resources + implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.feature.core:$haleVersion" - // code list formats - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.codelist.xml:$haleVersion" + // HTML export + implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.feature.html:$haleVersion" + + /* + * Additional formats + */ + + implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.mssql:$haleVersion" + implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.msaccess:$haleVersion" // Schematron validation implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.schematron:$haleVersion" @@ -127,47 +95,24 @@ dependencies { // tested w/ schematron validation in https://github.com/wetransform/exp-schematron/tree/exp/saxon-he implementation 'net.sf.saxon:Saxon-HE:9.9.1-8' - // converters - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.convert.core:$haleVersion" - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.convert.wkt:$haleVersion" - - // Groovy meta extensions - implementation "eu.esdihumboldt.hale:eu.esdihumboldt.util.groovy.meta.extension:$haleVersion" - - // logging - implementation(group: 'eu.esdihumboldt.unpuzzled', name: 'de.fhg.igd.slf4jplus.logback.appender', version: '1.2.0.201503311443') - implementation 'org.slf4j:jul-to-slf4j:1.7.36' - - // resource cache - implementation(group: 'eu.esdihumboldt.hale', name: 'eu.esdihumboldt.util.resource', version: haleVersion) - def resourcesGroup = 'to.wetransform.offline-resources' - // OpenGIS schemas, INSPIRE schemas, W3C schemas, etc. - implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.schemas.opengis.net', version: '2024.7.31') - implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.schemas.inspire', version: '2024.7.31') - implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.schemas.portele.de', version: '2024.1.25') - implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.w3.org', version: '2024.1.25') - // INSPIRE code lists and feature concepts - implementation(group: resourcesGroup, - name: 'eu.esdihumboldt.util.resource.codelists.inspire', - version: '2024.7.31') - implementation(group: resourcesGroup, - name: 'eu.esdihumboldt.util.resource.codelists.inspire.accept-xml', - version: '2024.7.31') - implementation(group: resourcesGroup, - name: 'eu.esdihumboldt.util.resource.featureconcepts.inspire', - version: '2024.2.20') - // More resources - implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.schemas.repository.gdi-de.org', version: '2024.5.23') + /* + * Other + */ // user / customer specific implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.adv.merge:$haleVersion" + // Groovy + implementation "org.codehaus.groovy:groovy-all:$groovyVersion" + // CLI - implementation 'commons-cli:commons-cli:1.9.0' + // implementation 'commons-cli:commons-cli:1.9.0' // Groovy Shell implementation 'jline:jline:2.14.6' - // Testing + /* + * Testing + */ testImplementation 'junit:junit:4.13.2' testImplementation 'com.github.stefanbirkner:system-rules:1.19.0' } diff --git a/src/main/groovy/to/wetransform/halecli/CLI.java b/src/main/groovy/to/wetransform/halecli/CLI.java index 02180c6..3de795d 100644 --- a/src/main/groovy/to/wetransform/halecli/CLI.java +++ b/src/main/groovy/to/wetransform/halecli/CLI.java @@ -16,7 +16,7 @@ package to.wetransform.halecli; import eu.esdihumboldt.util.cli.Runner; -import to.wetransform.halecli.internal.Init; +import eu.esdihumboldt.util.nonosgi.Init; /** * hale CLI main class. diff --git a/src/main/groovy/to/wetransform/halecli/internal/CustomMetaClassCreationHandle.java b/src/main/groovy/to/wetransform/halecli/internal/CustomMetaClassCreationHandle.java deleted file mode 100644 index 1106ad3..0000000 --- a/src/main/groovy/to/wetransform/halecli/internal/CustomMetaClassCreationHandle.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2016 wetransform GmbH - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the License, - * or (at your option) any later version. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH - */ - -package to.wetransform.halecli.internal; - -import java.lang.reflect.Constructor; - -import org.eclipse.equinox.nonosgi.registry.RegistryFactoryHelper; - -import eu.esdihumboldt.util.groovy.meta.extension.MetaClassDescriptor; -import eu.esdihumboldt.util.groovy.meta.extension.MetaClassExtension; -import groovy.lang.MetaClass; -import groovy.lang.MetaClassRegistry; -import groovy.lang.MetaClassRegistry.MetaClassCreationHandle; - -/** - * Adapts created meta classes with delegating meta classes registered in the - * {@link MetaClassExtension}. - * - * @author Simon Templer - */ -public class CustomMetaClassCreationHandle extends MetaClassCreationHandle { - - private final MetaClassExtension ext; - - public CustomMetaClassCreationHandle() { - // initialize registry - RegistryFactoryHelper.getRegistry(); - - ext = new MetaClassExtension(); - } - - @Override - protected MetaClass createNormalMetaClass(@SuppressWarnings("rawtypes") Class theClass, - MetaClassRegistry registry) { - MetaClass metaClass = super.createNormalMetaClass(theClass, registry); - - for (MetaClassDescriptor descriptor : ext.getElements()) { - if (descriptorApplies(descriptor, theClass)) { - // create meta class - Class delegatingMetaClass = descriptor.getMetaClass(); - try { - Constructor constructor = delegatingMetaClass - .getConstructor(MetaClass.class); - metaClass = (MetaClass) constructor.newInstance(metaClass); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - return metaClass; - } - - /** - * Check if a meta class descriptor applies to a given class. - * - * @param descriptor the meta class descriptor - * @param theClass the class for which should be determined if the - * descriptor applies - * @return true if the descriptor applies to the class, - * false otherwise - */ - private boolean descriptorApplies(MetaClassDescriptor descriptor, - @SuppressWarnings("rawtypes") Class theClass) { - Class forClass = descriptor.getForClass(); - if (descriptor.isForArray()) { - if (theClass.isArray()) { - Class componentClass = theClass.getComponentType(); - if (componentClass != null) { - return forClass.equals(componentClass) - || forClass.isAssignableFrom(componentClass); - } - else { - // should actually not happen - return false; - } - } - else { - // no array - return false; - } - } - else { - return forClass.equals(theClass) || forClass.isAssignableFrom(theClass); - } - } - -} diff --git a/src/main/groovy/to/wetransform/halecli/internal/Init.java b/src/main/groovy/to/wetransform/halecli/internal/Init.java deleted file mode 100644 index cca0dac..0000000 --- a/src/main/groovy/to/wetransform/halecli/internal/Init.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016 wetransform GmbH - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the License, - * or (at your option) any later version. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH - */ - -package to.wetransform.halecli.internal; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.eclipse.equinox.nonosgi.registry.RegistryFactoryHelper; -import org.slf4j.bridge.SLF4JBridgeHandler; - -import groovy.lang.GroovySystem; - -/** - * Initializes hale functionality in a non-OSGi environment. - * - * @author Simon Templer - */ -public class Init { - - private static AtomicBoolean initialized = new AtomicBoolean(false); - - public static void init() { - if (initialized.compareAndSet(false, true)) { - SLF4JBridgeHandler.install(); - - // initialize registry - RegistryFactoryHelper.getRegistry(); - - // initialize meta extensions - GroovySystem.getMetaClassRegistry().setMetaClassCreationHandle(new CustomMetaClassCreationHandle()); - } - } - -} diff --git a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy index d343ccc..59e85c4 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy @@ -13,12 +13,13 @@ * wetransform GmbH */ -package to.wetransform.halecli.project.match.postnas; +package to.wetransform.halecli.project.match.postnas + +import eu.esdihumboldt.hale.common.align.groovy.accessor.path.PathElement; import java.util.List import eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor -import eu.esdihumboldt.hale.common.align.groovy.accessor.PathElement; import eu.esdihumboldt.hale.common.align.groovy.accessor.internal.EntityAccessorUtil; import eu.esdihumboldt.hale.common.align.model.EntityDefinition import eu.esdihumboldt.util.groovy.paths.Path; diff --git a/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy b/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy index b092cbf..c0c7233 100644 --- a/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy +++ b/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy @@ -15,6 +15,8 @@ package to.wetransform.halecli +import eu.esdihumboldt.util.nonosgi.Init + import static org.junit.Assert.* import org.junit.BeforeClass @@ -22,53 +24,52 @@ import org.junit.Rule import org.junit.Test import org.junit.contrib.java.lang.system.SystemOutRule -import to.wetransform.halecli.internal.Init import eu.esdihumboldt.hale.common.core.HalePlatform import eu.esdihumboldt.util.cli.Runner /** * Simple tests for CLI runner. - * + * * @author Simon Templer */ class RunnerTest { - + @BeforeClass static void init() { Init.init() } - + @Rule public final SystemOutRule out = new SystemOutRule().enableLog() - + @Test void testVersion() { int code = new Runner('hale').run('version') assertEquals(0, code) assertEquals(HalePlatform.coreVersion.toString(), out.log.trim()) } - + @Test void testNoArgs() { int code = new Runner('hale').run() assertEquals(1, code) assertTrue(out.log.startsWith('usage:')) } - + @Test void testWrongCommands() { int code = new Runner('hale').run('zombie-apocalypse') assertEquals(1, code) assertTrue(out.log.startsWith('usage:')) } - + @Test void testHelp() { int code = new Runner('hale').run('help') assertEquals(0, code) assertTrue(out.log.startsWith('usage:')) } - + @Test void testTransformUsage() { int code = new Runner('hale').run('transform') diff --git a/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy b/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy index 4494225..7112550 100644 --- a/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy +++ b/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy @@ -16,12 +16,12 @@ package to.wetransform.halecli.data import eu.esdihumboldt.util.cli.Runner +import eu.esdihumboldt.util.nonosgi.Init import org.junit.BeforeClass import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.contrib.java.lang.system.SystemOutRule -import to.wetransform.halecli.internal.Init import static org.junit.Assert.assertEquals import static org.junit.Assert.assertTrue From 624ef560bf0d9d4470c37015219c49f2efeebf53 Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Tue, 20 Aug 2024 16:33:53 +0200 Subject: [PATCH 2/8] ci: add Java and Groovy formatting rules --- build.gradle | 67 ++++ eclipse-format.xml | 309 ++++++++++++++++++ groovy-format.properties | 34 ++ .../halecli/groovy/GroovyShellCommand.groovy | 2 + .../alignment/FilterAlignmentCommand.groovy | 2 + 5 files changed, 414 insertions(+) create mode 100644 eclipse-format.xml create mode 100644 groovy-format.properties diff --git a/build.gradle b/build.gradle index 94f0107..1654446 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ plugins { id "nebula.ospackage-application" version "9.1.1" id 'org.ajoberstar.grgit' version '5.2.2' id 'to.wetransform.semantic-release-version' version '2.1.1' + id 'com.diffplug.spotless' version '6.25.0' } apply plugin: 'org.standardout.eclipseconfig' @@ -291,3 +292,69 @@ task uploadArchives { wrapper { gradleVersion = '7.6.4' } + +/* + * Formatting + */ + +def header = ''' +/* + * Copyright (c) $YEAR wetransform GmbH + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + */ +''' + +def headerRegex = /(?!.*@custom-license-header).*/ + +spotless { + java { + toggleOffOn() + + importOrder('java', 'javax', 'org', 'com', '') + + removeUnusedImports() + + // https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-jdt + eclipse().configFile('eclipse-format.xml') + + // licenseHeader(header).onlyIfContentMatches(headerRegex) + + trimTrailingWhitespace() + endWithNewline() + } + + groovy { + toggleOffOn() + + importOrder('java', 'javax', 'org', 'com', '') + + // https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-groovy + greclipse().configFile('groovy-format.properties') + + // excludes all Java sources within the Groovy source dirs from formatting + excludeJava() + + // licenseHeader(header).onlyIfContentMatches(headerRegex) + + trimTrailingWhitespace() + endWithNewline() + } + + groovyGradle { + toggleOffOn() + + target '*.gradle' + + greclipse().configFile('groovy-format.properties') + + trimTrailingWhitespace() + endWithNewline() + } +} diff --git a/eclipse-format.xml b/eclipse-format.xml new file mode 100644 index 0000000..da833cf --- /dev/null +++ b/eclipse-format.xml @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/groovy-format.properties b/groovy-format.properties new file mode 100644 index 0000000..f06ceef --- /dev/null +++ b/groovy-format.properties @@ -0,0 +1,34 @@ +#Whether to use 'space', 'tab' or 'mixed' (both) characters for indentation. +#The default value is 'tab'. +org.eclipse.jdt.core.formatter.tabulation.char=space + +#Number of spaces used for indentation in case 'space' characters +#have been selected. The default value is 4. +org.eclipse.jdt.core.formatter.tabulation.size=2 + +#Number of spaces used for indentation in case 'mixed' characters +#have been selected. The default value is 4. +org.eclipse.jdt.core.formatter.indentation.size=2 + +#Whether or not indentation characters are inserted into empty lines. +#The default value is 'true'. +org.eclipse.jdt.core.formatter.indent_empty_lines=false + +#Number of spaces used for multiline indentation. +#The default value is 2. +groovy.formatter.multiline.indentation=1 + +#Length after which list are considered too long. These will be wrapped. +#The default value is 30. +groovy.formatter.longListLength=30 + +#Whether opening braces position shall be the next line. +#The default value is 'same'. +groovy.formatter.braces.start=same + +#Whether closing braces position shall be the next line. +#The default value is 'next'. +groovy.formatter.braces.end=next + +#Remove unnecessary semicolons. The default value is 'false'. +groovy.formatter.remove.unnecessary.semicolons=true diff --git a/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy b/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy index 0faa513..be08bbd 100644 --- a/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy @@ -12,6 +12,8 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. + * + * @custom-license-header */ package to.wetransform.halecli.groovy diff --git a/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy index 2e4d079..a122ebc 100644 --- a/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy @@ -192,6 +192,7 @@ class FilterAlignmentCommand extends AbstractDeriveProjectCommand { messages << "Removed $removed cells" messages << "Retained $retained cells from original project" } + // spotless:off /* XXX case that retains base alignments contained in the original alignment not working properly currently @@ -252,6 +253,7 @@ class FilterAlignmentCommand extends AbstractDeriveProjectCommand { } } */ + // spotless:on ValueList msgList = new ValueList() messages.each { From e62380f32e6f7c0a6799c4e601f66f8c7caba93b Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Tue, 20 Aug 2024 16:49:37 +0200 Subject: [PATCH 3/8] style: apply formatting rules --- build.gradle | 27 +++++---- settings.gradle | 1 - .../wetransform/halecli/VersionCommand.groovy | 1 - .../halecli/data/RewriteCommand.groovy | 10 ++-- .../halecli/data/SplitCommand.groovy | 23 ++++--- .../halecli/groovy/GroovyShellCommand.groovy | 24 ++++---- .../AbstractDeriveProjectCommand.groovy | 5 +- .../project/ExportProjectCommand.groovy | 1 - .../halecli/project/ProjectHelper.groovy | 24 ++++---- .../project/advisor/SaveAlignmentAdvisor.java | 4 +- .../project/advisor/SaveProjectAdvisor.java | 15 +++-- .../alignment/FilterAlignmentCommand.groovy | 30 +++++----- .../project/match/MatchSchemasCommand.groovy | 5 +- .../match/postnas/PostNASPropertyInfo.groovy | 12 ++-- .../match/postnas/PostNASSchemaMatcher.groovy | 36 ++++++----- .../halecli/project/merge/MergeCommand.groovy | 5 +- .../halecli/project/merge/MergeMigrator.java | 30 ++++++---- .../project/merge/MergeStatistics.groovy | 7 +-- .../migrate/AbstractMigrationCommand.groovy | 1 - .../migrate/AbstractMigratorCommand.groovy | 3 +- .../migrate/MigrateMatchingCommand.groovy | 3 +- .../project/migrate/ProjectMigrator.java | 20 +++---- .../migrate/ReplaceSourceCommand.groovy | 9 +-- .../halecli/schema/RewriteCommand.groovy | 3 +- .../halecli/util/HaleConnectCLI.groovy | 5 +- .../halecli/util/HaleIOHelper.java | 49 ++++++++------- .../halecli/util/InstanceCLI.groovy | 60 +++++++++---------- .../halecli/util/ProjectCLI.groovy | 9 ++- .../wetransform/halecli/util/SchemaCLI.groovy | 22 +++---- .../to/wetransform/halecli/RunnerTest.groovy | 4 +- .../halecli/data/RewriteCommandTest.groovy | 35 +++++------ 31 files changed, 234 insertions(+), 249 deletions(-) diff --git a/build.gradle b/build.gradle index 1654446..1ff184c 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,8 @@ repositories { // but libs-release-local was placed before snapshots here in the hierarchy and also // vice-versa case when dependencies were encountered from release but snapshots // was placed before release - maven { // wetransform release repository (HALE releases and Eclipse dependencies) + maven { + // wetransform release repository (HALE releases and Eclipse dependencies) url 'https://artifactory.wetransform.to/artifactory/local' } @@ -122,12 +123,14 @@ configurations.all { // ensure SNAPSHOTs are updated every time if needed resolutionStrategy.cacheChangingModulesFor 0, 'seconds' } -def defaultJvmArgs = ['-Dcache.level1.enabled=false', - '-Dcache.level1.size=0', - '-Dcache.level2.enabled=false', - '-Dcache.level2.size=0', - '--add-exports=java.base/sun.nio.ch=ALL-UNNAMED', - '--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED'] +def defaultJvmArgs = [ + '-Dcache.level1.enabled=false', + '-Dcache.level1.size=0', + '-Dcache.level2.enabled=false', + '-Dcache.level2.size=0', + '--add-exports=java.base/sun.nio.ch=ALL-UNNAMED', + '--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED' +] mainClassName = 'to.wetransform.halecli.CLI' applicationName = 'hale' applicationDefaultJvmArgs = defaultJvmArgs @@ -143,7 +146,7 @@ applicationDefaultJvmArgs = defaultJvmArgs jar { manifest { attributes 'Bundle-SymbolicName': 'to.wetransform.halecli;singleton:=true', - 'Bundle-Vendor': 'wetransform GmbH' + 'Bundle-Vendor': 'wetransform GmbH' } } @@ -183,10 +186,12 @@ docker { // switching to jre-jammy as the use pf Alpine as the OS of the hale-cli image breaks derived images that expect Ubuntu baseImage = 'eclipse-temurin:17-jre-jammy' maintainer = 'Simon Templer "simon@wetransform.to"' - images = ["wetransform/${project.name}:${project.version}", "wetransform/${project.name}:latest"] + images = [ + "wetransform/${project.name}:${project.version}", + "wetransform/${project.name}:latest" + ] // apply JAVA_OPTS to docker plugin as the default args configured in build does not apply to docker plugin jvmArgs = defaultJvmArgs - } url = project.hasProperty('dockerHost') ? dockerHost : 'http://localdocker:2375' @@ -200,7 +205,7 @@ docker { } dockerCreateDockerfile { - def buildTime = java.time.ZonedDateTime.now().format(java.time.format.DateTimeFormatter.ISO_INSTANT); + def buildTime = java.time.ZonedDateTime.now().format(java.time.format.DateTimeFormatter.ISO_INSTANT) label('git.sha': grgit.head().id, 'git.branch': grgit.branch.current.name, 'build.version': version, 'build.time': buildTime) instruction 'COPY hale /hale/' } diff --git a/settings.gradle b/settings.gradle index 382a560..312a773 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1 @@ rootProject.name= 'hale-cli' - diff --git a/src/main/groovy/to/wetransform/halecli/VersionCommand.groovy b/src/main/groovy/to/wetransform/halecli/VersionCommand.groovy index dc7b806..ac9ba76 100644 --- a/src/main/groovy/to/wetransform/halecli/VersionCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/VersionCommand.groovy @@ -35,5 +35,4 @@ class VersionCommand implements Command { } final String shortDescription = 'Print the hale version' - } diff --git a/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy b/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy index 19b6ee2..e47f5a6 100644 --- a/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy @@ -15,6 +15,8 @@ package to.wetransform.halecli.data +import static to.wetransform.halecli.util.HaleIOHelper.guessSchema + import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.core.io.report.IOReport import eu.esdihumboldt.hale.common.instance.io.InstanceWriter @@ -28,11 +30,9 @@ import eu.esdihumboldt.util.cli.CLIUtil import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor import to.wetransform.halecli.util.InstanceCLI import to.wetransform.halecli.util.SchemaCLI -import groovy.cli.picocli.OptionAccessor - -import static to.wetransform.halecli.util.HaleIOHelper.guessSchema /** * Reads a source file and writes it. @@ -99,7 +99,7 @@ class RewriteCommand implements Command { try { // replace source with database if (db != null) { - source = new BrowseOrientInstanceCollection(db, schema, DataSet.SOURCE); + source = new BrowseOrientInstanceCollection(db, schema, DataSet.SOURCE) } // Note: It is important that OrientDB caches are disabled // via system properties to have a decent performance @@ -113,7 +113,6 @@ class RewriteCommand implements Command { if (!report.isSuccess()) { throw new IllegalStateException('Writing target file failed: ' + report.summary) } - } finally { if (db != null) { db.delete() @@ -126,5 +125,4 @@ class RewriteCommand implements Command { final String shortDescription = 'Read a data source and write it with specific settings' final boolean experimental = true - } diff --git a/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy b/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy index eca8cae..11b7152 100644 --- a/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy @@ -15,6 +15,8 @@ package to.wetransform.halecli.data +import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail + import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.core.io.HaleIO import eu.esdihumboldt.hale.common.core.io.Value @@ -33,12 +35,10 @@ import eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor import groovy.transform.CompileStatic import to.wetransform.halecli.util.InstanceCLI import to.wetransform.halecli.util.SchemaCLI -import groovy.cli.picocli.OptionAccessor - -import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail /** * Splits a GML source file and creates multiple target files. @@ -90,7 +90,7 @@ class SplitCommand implements Command { LocalOrientDB db = InstanceCLI.loadTempDatabase(source, schema, reports) try { // replace source with database - source = new BrowseOrientInstanceCollection(db, schema, DataSet.SOURCE); + source = new BrowseOrientInstanceCollection(db, schema, DataSet.SOURCE) // Note: It is important that OrientDB caches are disabled // via system properties to have a decent performance @@ -98,11 +98,11 @@ class SplitCommand implements Command { // create a reference graph ReferenceGraph rg = new ReferenceGraph(new XMLInspector(), - source) + source) // partition the graph int threshold = (options.threshold ?: 10000) as int - Iterator parts = rg.partition(threshold); + Iterator parts = rg.partition(threshold) // target def target = options.target as File @@ -147,7 +147,7 @@ class SplitCommand implements Command { @CompileStatic private void saveGml(InstanceCollection instances, File targetFile, Schema schema, - ReportHandler reports) { + ReportHandler reports) { def target = new FileIOSupplier(targetFile) // create I/O provider @@ -155,17 +155,17 @@ class SplitCommand implements Command { String customProvider = 'eu.esdihumboldt.hale.io.gml.writer' if (customProvider != null) { // use specified provider - instanceWriter = HaleIO.createIOProvider(InstanceWriter, null, customProvider); + instanceWriter = HaleIO.createIOProvider(InstanceWriter, null, customProvider) if (instanceWriter == null) { - fail("Could not find instance writer with ID " + customProvider); + fail("Could not find instance writer with ID " + customProvider) } } if (instanceWriter == null) { // find applicable reader - instanceWriter = HaleIO.findIOProvider(InstanceWriter, target, targetFile.name); + instanceWriter = HaleIO.findIOProvider(InstanceWriter, target, targetFile.name) } if (instanceWriter == null) { - throw fail("Could not determine instance reader to use for source data"); + throw fail("Could not determine instance reader to use for source data") } //FIXME apply custom settings @@ -189,5 +189,4 @@ class SplitCommand implements Command { final String shortDescription = 'Split a source file (GML) into portions' final boolean experimental = true - } diff --git a/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy b/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy index be08bbd..61a0ad6 100644 --- a/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy @@ -18,14 +18,6 @@ package to.wetransform.halecli.groovy -import eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctions -import eu.esdihumboldt.hale.common.core.HalePlatform -import eu.esdihumboldt.hale.common.core.io.HaleIO -import eu.esdihumboldt.hale.common.core.io.Value -import eu.esdihumboldt.util.cli.Command -import eu.esdihumboldt.util.cli.CommandContext -import groovy.transform.CompileStatic -import groovyjarjarcommonscli.HelpFormatter import org.codehaus.groovy.tools.shell.Groovysh import org.codehaus.groovy.tools.shell.IO import org.codehaus.groovy.tools.shell.Main @@ -34,8 +26,17 @@ import org.codehaus.groovy.tools.shell.util.MessageSource import org.codehaus.groovy.tools.shell.util.NoExitSecurityManager import org.eclipse.core.runtime.IConfigurationElement import org.eclipse.core.runtime.Platform + +import eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctions +import eu.esdihumboldt.hale.common.core.HalePlatform +import eu.esdihumboldt.hale.common.core.io.HaleIO +import eu.esdihumboldt.hale.common.core.io.Value +import eu.esdihumboldt.util.cli.Command +import eu.esdihumboldt.util.cli.CommandContext import groovy.cli.picocli.CliBuilder import groovy.cli.picocli.OptionAccessor +import groovy.transform.CompileStatic +import groovyjarjarcommonscli.HelpFormatter /** * Groovy shell command based on Groovy shell main class. * @@ -162,10 +163,10 @@ class GroovyShellCommand implements Command { // determine imports from extension (see DefaultGroovyService class) for (IConfigurationElement conf : Platform.getExtensionRegistry() - .getConfigurationElementsFor('eu.esdihumboldt.util.groovy.sandbox')) { + .getConfigurationElementsFor('eu.esdihumboldt.util.groovy.sandbox')) { if (conf.getName().equals("import")) { - String className = conf.getAttribute("class"); - String alias = conf.getAttribute("alias"); + String className = conf.getAttribute("class") + String alias = conf.getAttribute("alias") if (className != null && !className.isEmpty()) { if (alias == null || alias.isEmpty()) { @@ -193,5 +194,4 @@ class GroovyShellCommand implements Command { public String getShortDescription() { 'Launch a Groovy shell (for advanced users)' } - } diff --git a/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy index 5093cd5..bc48599 100644 --- a/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy @@ -41,13 +41,13 @@ abstract class AbstractDeriveProjectCommand extends AbstractProjectEnvironmentCo @Override void setupOptions(CliBuilder cli) { - super.setupOptions(cli); + super.setupOptions(cli) cli._(longOpt: 'name', args: 1, argName: 'variant-name', 'Set the name of project variant') } abstract DeriveProjectResult deriveProject(ProjectTransformationEnvironment projectEnv, - OptionAccessor options) + OptionAccessor options) @Override boolean runForProject(ProjectTransformationEnvironment projectEnv, URI projectLocation, @@ -93,5 +93,4 @@ abstract class AbstractDeriveProjectCommand extends AbstractProjectEnvironmentCo true } - } diff --git a/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy index 5942bd0..a0e4986 100644 --- a/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy @@ -75,5 +75,4 @@ class ExportProjectCommand implements Command { final String shortDescription = 'Exports a project with different settings' final boolean experimental = true - } diff --git a/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy b/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy index d2c18b8..99adb1e 100644 --- a/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy @@ -17,7 +17,6 @@ package to.wetransform.halecli.project import org.eclipse.core.runtime.content.IContentType -import to.wetransform.halecli.project.advisor.SaveProjectAdvisor import eu.esdihumboldt.hale.common.align.model.Alignment import eu.esdihumboldt.hale.common.core.io.HaleIO import eu.esdihumboldt.hale.common.core.io.Value @@ -34,6 +33,7 @@ import eu.esdihumboldt.hale.common.core.service.ServiceManager import eu.esdihumboldt.hale.common.core.service.ServiceProvider import eu.esdihumboldt.hale.common.schema.model.SchemaSpace import groovy.transform.CompileStatic +import to.wetransform.halecli.project.advisor.SaveProjectAdvisor /** * Helper for dealing with hale projects. @@ -52,7 +52,7 @@ class ProjectHelper { IContentType projectType = HaleIO.findContentType( ProjectWriter.class, null, "project.$extension") IOProviderDescriptor factory = HaleIO.findIOProviderFactory( - ProjectWriter.class, projectType, null); + ProjectWriter.class, projectType, null) saveProject(project, alignment, sourceSchema, targetSchema, output, reports, factory, projectLoadLocation, settings) @@ -85,23 +85,22 @@ class ProjectHelper { // service provider // XXX what services are needed for project export? - ServiceProvider projectScope = new ServiceManager(ServiceManager.SCOPE_PROJECT); + ServiceProvider projectScope = new ServiceManager(ServiceManager.SCOPE_PROJECT) ProjectInfoService projectInfo = new FixedProjectInfoService(project, projectLoadLocation) ServiceProvider serviceProvider = new ServiceProvider() { - @Override - public T getService(Class serviceInterface) { - if (ProjectInfoService.metaClass.equals(serviceInterface)) { - return projectInfo; + @Override + public T getService(Class serviceInterface) { + if (ProjectInfoService.metaClass.equals(serviceInterface)) { + return projectInfo + } + return projectScope.getService(serviceInterface) } - return projectScope.getService(serviceInterface); } - } - SaveProjectAdvisor advisor = new SaveProjectAdvisor(project, alignment, sourceSchema, - targetSchema, projectLoadLocation); - advisor.setServiceProvider(serviceProvider); + targetSchema, projectLoadLocation) + advisor.setServiceProvider(serviceProvider) advisor.prepareProvider(projectWriter) advisor.updateConfiguration(projectWriter) // HeadlessIO.executeProvider(projectWriter, advisor, null, reports); @@ -118,5 +117,4 @@ class ProjectHelper { } } } - } diff --git a/src/main/groovy/to/wetransform/halecli/project/advisor/SaveAlignmentAdvisor.java b/src/main/groovy/to/wetransform/halecli/project/advisor/SaveAlignmentAdvisor.java index f377a2e..3b8e709 100644 --- a/src/main/groovy/to/wetransform/halecli/project/advisor/SaveAlignmentAdvisor.java +++ b/src/main/groovy/to/wetransform/halecli/project/advisor/SaveAlignmentAdvisor.java @@ -37,8 +37,8 @@ public class SaveAlignmentAdvisor extends AbstractIOAdvisor { private final SchemaSpace targetSchema; private final URI projectLoadLocation; - public SaveAlignmentAdvisor(ProjectInfo projectInfo, Alignment alignment, SchemaSpace sourceSchema, - SchemaSpace targetSchema, URI projectLoadLocation) { + public SaveAlignmentAdvisor(ProjectInfo projectInfo, Alignment alignment, + SchemaSpace sourceSchema, SchemaSpace targetSchema, URI projectLoadLocation) { super(); this.projectInfo = projectInfo; this.alignment = alignment; diff --git a/src/main/groovy/to/wetransform/halecli/project/advisor/SaveProjectAdvisor.java b/src/main/groovy/to/wetransform/halecli/project/advisor/SaveProjectAdvisor.java index 533c648..af7c0f4 100644 --- a/src/main/groovy/to/wetransform/halecli/project/advisor/SaveProjectAdvisor.java +++ b/src/main/groovy/to/wetransform/halecli/project/advisor/SaveProjectAdvisor.java @@ -38,7 +38,8 @@ * * @author Simon Templer */ -public class SaveProjectAdvisor extends AbstractIOAdvisor implements IOAdvisorRegister { +public class SaveProjectAdvisor extends AbstractIOAdvisor + implements IOAdvisorRegister { private final Map> advisors = new HashMap<>(); @@ -46,15 +47,14 @@ public class SaveProjectAdvisor extends AbstractIOAdvisor impleme private final URI projectLoadLocation; - public SaveProjectAdvisor(Project project, Alignment alignment, - SchemaSpace sourceSchema, SchemaSpace targetSchema, URI projectLoadLocation) { + public SaveProjectAdvisor(Project project, Alignment alignment, SchemaSpace sourceSchema, + SchemaSpace targetSchema, URI projectLoadLocation) { super(); this.project = project; this.projectLoadLocation = projectLoadLocation; - advisors.put("eu.esdihumboldt.hale.io.align.write", - new SaveAlignmentAdvisor(project, alignment, sourceSchema, targetSchema, - projectLoadLocation)); + advisors.put("eu.esdihumboldt.hale.io.align.write", new SaveAlignmentAdvisor(project, alignment, + sourceSchema, targetSchema, projectLoadLocation)); } @Override @@ -66,8 +66,7 @@ public void prepareProvider(ProjectWriter provider) { public void updateConfiguration(ProjectWriter provider) { provider.getProject().setModified(new Date()); provider.getProject().setHaleVersion(HalePlatform.getCoreVersion()); - Map projectFiles = ProjectIO - .createDefaultProjectFiles(this); + Map projectFiles = ProjectIO.createDefaultProjectFiles(this); for (ProjectFile pf : projectFiles.values()) { if (pf instanceof AdvisorProjectFile) { diff --git a/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy index a122ebc..c9461bd 100644 --- a/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy @@ -15,6 +15,8 @@ package to.wetransform.halecli.project.alignment +import javax.xml.namespace.QName + import eu.esdihumboldt.cst.functions.groovy.GroovyJoin import eu.esdihumboldt.hale.common.align.migrate.util.MigrationUtil import eu.esdihumboldt.hale.common.align.model.* @@ -40,8 +42,6 @@ import groovy.json.JsonSlurper import groovy.transform.CompileStatic import to.wetransform.halecli.project.AbstractDeriveProjectCommand -import javax.xml.namespace.QName - /** * Command creating a project with a filtered alignment. * @@ -56,7 +56,7 @@ class FilterAlignmentCommand extends AbstractDeriveProjectCommand { super.setupOptions(cli) cli._(longOpt: 'json-filter', args: 1, argName: 'json-file', required: true, - 'Specify a JSON file with the filter definition') + 'Specify a JSON file with the filter definition') cli.b(longOpt: 'use-base-alignment', 'Use the original alignment as base alignment instead of copying the cells') cli._(longOpt: 'skip-empty', 'Specify to skip the project if the filtered alignment is empty') cli._(longOpt: 'skip-no-type-cells', 'Specify to skip the project if the filtered alignment contains no type cells') @@ -166,12 +166,12 @@ class FilterAlignmentCommand extends AbstractDeriveProjectCommand { messages << "Deactivated $rejected rejected alignment cells" } else { - result = new DefaultAlignment(alignment); + result = new DefaultAlignment(alignment) // remove base alignment cells keeping custom functions - MigrationUtil.removeBaseCells(result); + MigrationUtil.removeBaseCells(result) // remove other cells - result.clearCells(); + result.clearCells() int removed = 0 int retained = 0 @@ -179,13 +179,13 @@ class FilterAlignmentCommand extends AbstractDeriveProjectCommand { for (Cell cell : alignment.getCells()) { if (acceptCell(cell, filterDef, messages)) { // transfer cell unchanged - MutableCell cellNew = new DefaultCell(cell); - MigrationUtil.removeIdPrefix(cellNew, true, true); - result.addCell(cellNew); - retained++; + MutableCell cellNew = new DefaultCell(cell) + MigrationUtil.removeIdPrefix(cellNew, true, true) + result.addCell(cellNew) + retained++ } else { - removed++; + removed++ } } @@ -364,7 +364,7 @@ class FilterAlignmentCommand extends AbstractDeriveProjectCommand { switch (cell.transformationIdentifier) { case JoinFunction.ID: case GroovyJoin.ID: - // check if mismatch is on first type in Join order -> then don't keep cell + // check if mismatch is on first type in Join order -> then don't keep cell def joinParam = CellUtil.getFirstParameter(cell, JoinFunction.PARAMETER_JOIN).as(JoinParameter) if (joinParam && joinParam.getTypes()) { def firstType = joinParam.getTypes()[0] @@ -398,7 +398,8 @@ class FilterAlignmentCommand extends AbstractDeriveProjectCommand { } boolean matchesCell(Cell cell, Map excludeObj, List messages) { - if (excludeObj.typeCell) { // match type cells + if (excludeObj.typeCell) { + // match type cells //TODO support different kinds of matching? // for now lax matching, but source and target need at least one match if (AlignmentUtil.isTypeCell(cell)) { @@ -429,9 +430,7 @@ class FilterAlignmentCommand extends AbstractDeriveProjectCommand { if (sourceMatch && targetMatch) { return true } - } - } else { // unknown definition @@ -469,5 +468,4 @@ class FilterAlignmentCommand extends AbstractDeriveProjectCommand { } final boolean experimental = true - } diff --git a/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy index c1f4f2f..f2f345d 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy @@ -22,10 +22,10 @@ import eu.esdihumboldt.hale.common.schema.model.Schema import eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext +import groovy.cli.picocli.CliBuilder import groovy.cli.picocli.OptionAccessor import to.wetransform.halecli.util.ProjectCLI import to.wetransform.halecli.util.SchemaCLI -import groovy.cli.picocli.CliBuilder abstract class MatchSchemasCommand implements Command { @@ -57,7 +57,7 @@ abstract class MatchSchemasCommand implements Command { assert targetSchema // generate mapping between schemas - SchemaMatcher matcher = createMatcher(); + SchemaMatcher matcher = createMatcher() Alignment alignment = matcher.generateSchemaMatching(refSchema, targetSchema) // save project @@ -85,5 +85,4 @@ abstract class MatchSchemasCommand implements Command { } final boolean experimental = true - } diff --git a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy index 59e85c4..96e65a1 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy @@ -15,14 +15,13 @@ package to.wetransform.halecli.project.match.postnas -import eu.esdihumboldt.hale.common.align.groovy.accessor.path.PathElement; - import java.util.List import eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor -import eu.esdihumboldt.hale.common.align.groovy.accessor.internal.EntityAccessorUtil; +import eu.esdihumboldt.hale.common.align.groovy.accessor.internal.EntityAccessorUtil +import eu.esdihumboldt.hale.common.align.groovy.accessor.path.PathElement import eu.esdihumboldt.hale.common.align.model.EntityDefinition -import eu.esdihumboldt.util.groovy.paths.Path; +import eu.esdihumboldt.util.groovy.paths.Path import groovy.transform.CompileStatic import groovy.transform.Immutable import groovy.transform.ToString @@ -110,8 +109,8 @@ class PostNASPropertyInfo { } new PostNASPropertyInfo(baseProperty: baseProperty, path: path, - typeCategory: typeCategory, typeName: typeName, cardinality: cardinality, - assocRef: assocRef, assocType: assocType) + typeCategory: typeCategory, typeName: typeName, cardinality: cardinality, + assocRef: assocRef, assocType: assocType) } EntityDefinition findEntity(EntityDefinition typeEntity) { @@ -157,5 +156,4 @@ class PostNASPropertyInfo { } } } - } diff --git a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy index e760215..400f619 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy @@ -15,30 +15,29 @@ package to.wetransform.halecli.project.match.postnas -import com.google.common.collect.ListMultimap -import eu.esdihumboldt.hale.common.align.model.Entity - import javax.xml.namespace.QName import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap -import eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor; +import eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor import eu.esdihumboldt.hale.common.align.model.Alignment -import eu.esdihumboldt.hale.common.align.model.AlignmentUtil; -import eu.esdihumboldt.hale.common.align.model.EntityDefinition; +import eu.esdihumboldt.hale.common.align.model.AlignmentUtil +import eu.esdihumboldt.hale.common.align.model.Entity +import eu.esdihumboldt.hale.common.align.model.EntityDefinition import eu.esdihumboldt.hale.common.align.model.MutableAlignment import eu.esdihumboldt.hale.common.align.model.MutableCell -import eu.esdihumboldt.hale.common.align.model.functions.RenameFunction; -import eu.esdihumboldt.hale.common.align.model.functions.RetypeFunction; +import eu.esdihumboldt.hale.common.align.model.functions.RenameFunction +import eu.esdihumboldt.hale.common.align.model.functions.RetypeFunction import eu.esdihumboldt.hale.common.align.model.impl.DefaultAlignment import eu.esdihumboldt.hale.common.align.model.impl.DefaultCell import eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty import eu.esdihumboldt.hale.common.align.model.impl.DefaultType -import eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition; +import eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition import eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition import eu.esdihumboldt.hale.common.schema.SchemaSpaceID -import eu.esdihumboldt.hale.common.schema.model.ChildDefinition; -import eu.esdihumboldt.hale.common.schema.model.DefinitionUtil; +import eu.esdihumboldt.hale.common.schema.model.ChildDefinition +import eu.esdihumboldt.hale.common.schema.model.DefinitionUtil import eu.esdihumboldt.hale.common.schema.model.TypeDefinition import eu.esdihumboldt.hale.common.schema.model.TypeIndex import groovy.transform.CompileStatic @@ -74,8 +73,8 @@ class PostNASSchemaMatcher implements SchemaMatcher { def candidateName if (typeInfo) { //XXX DEBUG -// println "Type $it.name" -// println typeInfo + // println "Type $it.name" + // println typeInfo targetTypeInfo[it.name] = typeInfo @@ -234,11 +233,11 @@ class PostNASSchemaMatcher implements SchemaMatcher { // mapping for GML identifier //XXX identifier is not used for references /* - def refIdent = new EntityAccessor(refEntity).findChildren('identifier').toEntityDefinition() - if (refIdent) { - alignment.addCell(createCell(refIdent, targetProperty, RenameFunction.ID)) - } - */ + def refIdent = new EntityAccessor(refEntity).findChildren('identifier').toEntityDefinition() + if (refIdent) { + alignment.addCell(createCell(refIdent, targetProperty, RenameFunction.ID)) + } + */ } else if (property.name.localPart == 'ogc_fid') { // ignore generated sequential id in database @@ -299,5 +298,4 @@ class PostNASSchemaMatcher implements SchemaMatcher { cell } - } diff --git a/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy index 5f52d66..4beeb20 100644 --- a/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy @@ -21,10 +21,10 @@ import eu.esdihumboldt.hale.common.core.service.ServiceProvider import eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment import eu.esdihumboldt.hale.common.schema.io.SchemaIO import eu.esdihumboldt.hale.common.schema.model.SchemaSpace -import to.wetransform.halecli.project.migrate.AbstractMigratorCommand -import to.wetransform.halecli.util.ProjectCLI import groovy.cli.picocli.CliBuilder import groovy.cli.picocli.OptionAccessor +import to.wetransform.halecli.project.migrate.AbstractMigratorCommand +import to.wetransform.halecli.util.ProjectCLI /** * Command that migrates a project to a different schema. @@ -101,5 +101,4 @@ class MergeCommand extends AbstractMigratorCommand newCells = mergeCell(cell, migration, options, log); result.removeCell(cell); for (MutableCell newCell : newCells) { - MigrationUtil.removeIdPrefix(newCell, options.transferBase(), - options.transferBase()); + MigrationUtil.removeIdPrefix(newCell, options.transferBase(), options.transferBase()); if (newCell != null) { result.addCell(newCell); } @@ -158,12 +157,15 @@ protected Iterable mergeCell(Cell originalCell, AlignmentMigration MergeCellMigrator merger; try { - merger = MigratorExtension.getInstance().getMigrator(originalCell.getTransformationIdentifier()).orElse(null); + merger = MigratorExtension.getInstance() + .getMigrator(originalCell.getTransformationIdentifier()).orElse(null); } catch (Exception e) { - throw new IllegalStateException("Unable to initialize migrator for function " + originalCell.getTransformationIdentifier(), e); + throw new IllegalStateException("Unable to initialize migrator for function " + + originalCell.getTransformationIdentifier(), e); } if (merger == null) { - CellMigrator cellMigrator = super.getCellMigrator(originalCell.getTransformationIdentifier()); + CellMigrator cellMigrator = super.getCellMigrator( + originalCell.getTransformationIdentifier()); if (cellMigrator instanceof MergeCellMigrator) { // function explicitly supports merge merger = (MergeCellMigrator) cellMigrator; @@ -176,7 +178,8 @@ protected Iterable mergeCell(Cell originalCell, AlignmentMigration return merger.mergeCell(originalCell, targetIndex, migration, this::getCellMigrator, log); } - else throw new IllegalStateException(); + else + throw new IllegalStateException(); } /** @@ -211,7 +214,8 @@ private void collectStatistics(Cell originalCell, Collection s return; } - String targetFunction = FunctionUtil.getFunction(originalCell.getTransformationIdentifier(), serviceProvider).getDisplayName(); + String targetFunction = FunctionUtil + .getFunction(originalCell.getTransformationIdentifier(), serviceProvider).getDisplayName(); List> sourceFunctions = new ArrayList<>(); boolean incomplete = false; for (Entity source : sources) { @@ -237,13 +241,14 @@ else if (matches.isEmpty()) { List matchFunctions = new ArrayList<>(); for (Cell match : matches) { String sourceFunction = match.getTransformationIdentifier(); - sourceFunction = FunctionUtil.getFunction(sourceFunction, serviceProvider).getDisplayName(); + sourceFunction = FunctionUtil.getFunction(sourceFunction, serviceProvider) + .getDisplayName(); matchFunctions.add(sourceFunction); boolean hasNewSourceCondition = false; if (match.getSource() != null) { - //XXX also report multiple sources? + // XXX also report multiple sources? for (Entity matchSource : match.getSource().values()) { if (hasConditions(matchSource)) { @@ -268,11 +273,12 @@ else if (matches.isEmpty()) { } statistics.addCell(); - // System.out.println("| " + targetFunction + ": " + sourceFunctions.stream().collect(Collectors.joining(", ")) + " |"); + // System.out.println("| " + targetFunction + ": " + + // sourceFunctions.stream().collect(Collectors.joining(", ")) + " |"); } private boolean hasConditions(Entity source) { - //XXX what about index conditions? + // XXX what about index conditions? EntityDefinition def = source.getDefinition(); diff --git a/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy b/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy index 65644b1..a70a716 100644 --- a/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy @@ -18,10 +18,10 @@ package to.wetransform.halecli.project.merge import java.util.List import eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition -import eu.esdihumboldt.hale.common.align.extension.function.FunctionUtil; +import eu.esdihumboldt.hale.common.align.extension.function.FunctionUtil import eu.esdihumboldt.hale.common.align.helper.EntityDefinitionComparator -import eu.esdihumboldt.hale.common.align.model.EntityDefinition; -import groovy.json.JsonOutput; +import eu.esdihumboldt.hale.common.align.model.EntityDefinition +import groovy.json.JsonOutput /** * Collects statistics on the merge. @@ -178,5 +178,4 @@ class MergeStatistics { entry.noSource++ } } - } diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy index bb6d171..13b3476 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy @@ -40,5 +40,4 @@ abstract class AbstractMigrationCommand extends Ab protected abstract SchemaSpace getNewSource(T migration, OptionAccessor options) protected abstract List getNewSourceConfig(T migration, OptionAccessor options) - } diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy index 79aeeee..85df6e3 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy @@ -42,7 +42,7 @@ import to.wetransform.halecli.util.ProjectCLI * @author Simon Templer */ abstract class AbstractMigratorCommand - implements Command { +implements Command { protected abstract void addOptions(CliBuilder cli) @@ -149,5 +149,4 @@ abstract class AbstractMigratorCommand final String shortDescription = 'Migrate a source project based on a project providing a schema matching' final boolean experimental = true - } diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/ProjectMigrator.java b/src/main/groovy/to/wetransform/halecli/project/migrate/ProjectMigrator.java index 9a54f0c..d950430 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/ProjectMigrator.java +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/ProjectMigrator.java @@ -54,34 +54,32 @@ public static void updateProject(Project project, AlignmentMigration migration, updateMappingRelevantTypes(conf, SchemaSpaceID.TARGET, oldTargetSchema, migration, log); } - //TODO what else? + // TODO what else? } private static void updateMappingRelevantTypes(ComplexConfigurationService config, - SchemaSpaceID schemaSpace, TypeIndex oldSchema, AlignmentMigration migration, - SimpleLog log) { + SchemaSpaceID schemaSpace, TypeIndex oldSchema, AlignmentMigration migration, SimpleLog log) { String confName = SchemaIO.getMappingRelevantTypesParameterName(schemaSpace); List cfg = config.getList(confName); if (cfg != null) { - List typeNames = cfg.stream() - .map(name -> QName.valueOf(name)) - .map(name -> oldSchema.getType(name)) - .filter(type -> type != null) + List typeNames = cfg.stream().map(name -> QName.valueOf(name)) + .map(name -> oldSchema.getType(name)).filter(type -> type != null) .map(type -> new TypeEntityDefinition(type, schemaSpace, null)) .flatMap(entity -> { if (migration instanceof MatchingMigration) { - return ((MatchingMigration) migration).findMatches(entity).orElse(Collections.emptyList()).stream(); + return ((MatchingMigration) migration).findMatches(entity) + .orElse(Collections.emptyList()).stream(); } else { - return migration.entityReplacement(entity, log).map(e -> Collections.singletonList(e)).orElse(Collections.emptyList()).stream(); + return migration.entityReplacement(entity, log).map(e -> Collections.singletonList(e)) + .orElse(Collections.emptyList()).stream(); } }) - .map(option -> option.getType().getName().toString()) - .collect(Collectors.toList()); + .map(option -> option.getType().getName().toString()).collect(Collectors.toList()); config.setList(confName, typeNames); } diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy index ea46528..7e5d872 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy @@ -21,9 +21,9 @@ import eu.esdihumboldt.hale.common.schema.model.Schema import eu.esdihumboldt.hale.common.schema.model.SchemaSpace import eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor import groovy.transform.CompileStatic import to.wetransform.halecli.util.SchemaCLI -import groovy.cli.picocli.OptionAccessor /** * Command that migrates a project to a different schema. * @@ -34,7 +34,7 @@ class ReplaceSourceCommand extends AbstractMigrationCommand getNewSourceConfig(DefaultSchemaMigration migration, OptionAccessor options) { - [SchemaCLI.getSchemaIOConfig(options, 'schema', true)] + [ + SchemaCLI.getSchemaIOConfig(options, 'schema', true) + ] } final String shortDescription = 'Migrate a source project to a new source schema' final boolean experimental = true - } diff --git a/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy b/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy index eae6151..ac69042 100644 --- a/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy @@ -20,8 +20,8 @@ import eu.esdihumboldt.hale.common.schema.model.Schema import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext import groovy.cli.picocli.CliBuilder -import to.wetransform.halecli.util.SchemaCLI import groovy.cli.picocli.OptionAccessor +import to.wetransform.halecli.util.SchemaCLI /** * Reads a schema and writes it. * @@ -62,5 +62,4 @@ class RewriteCommand implements Command { final String shortDescription = 'Read a schema and write it with specific settings' final boolean experimental = true - } diff --git a/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy index bf322b2..e947159 100644 --- a/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy @@ -15,14 +15,14 @@ package to.wetransform.halecli.util +import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail + import eu.esdihumboldt.hale.common.core.HalePlatform import eu.esdihumboldt.hale.common.core.service.ServiceProvider import eu.esdihumboldt.hale.io.haleconnect.HaleConnectService import groovy.cli.picocli.CliBuilder import groovy.cli.picocli.OptionAccessor -import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail - /** * Common utility functions for configuring a hale connect connection. * @@ -66,5 +66,4 @@ class HaleConnectCLI { static void login(OptionAccessor options) { login(options, HalePlatform.getServiceProvider()) } - } diff --git a/src/main/groovy/to/wetransform/halecli/util/HaleIOHelper.java b/src/main/groovy/to/wetransform/halecli/util/HaleIOHelper.java index 4901a98..9eb6b29 100644 --- a/src/main/groovy/to/wetransform/halecli/util/HaleIOHelper.java +++ b/src/main/groovy/to/wetransform/halecli/util/HaleIOHelper.java @@ -112,7 +112,8 @@ public static Pair prepareReader(URI loc, } if (reader == null) { // find applicable reader - Pair providerInfo = HaleIO.findIOProviderAndId(providerClass, sourceIn, loc.getPath()); + Pair providerInfo = HaleIO.findIOProviderAndId(providerClass, sourceIn, + loc.getPath()); if (providerInfo != null) { reader = providerInfo.getFirst(); providerId = providerInfo.getSecond(); @@ -134,14 +135,14 @@ public static Pair prepareReader(URI loc, return new Pair<>(reader, providerId); } - /** * Guess the schema location for a given data location. * * XXX improve and move to hale codebase? * * @param dataLoc the location of the data - * @return the location of the schema if any could be determined, otherwise null + * @return the location of the schema if any could be determined, otherwise + * null */ @Nullable public static URI guessSchema(URI dataLoc) { @@ -156,8 +157,8 @@ public static URI guessSchema(URI dataLoc) { IContentType xml = ctm.getContentType("org.eclipse.core.runtime.xml"); IContentType xmlGz = ctm.getContentType("eu.esdihumboldt.hale.io.xml.gzip"); - - IContentType contentType = HaleIO.findContentType(InstanceReader.class, input, dataLoc.getPath()); + IContentType contentType = HaleIO.findContentType(InstanceReader.class, input, + dataLoc.getPath()); URI result = null; @@ -170,7 +171,8 @@ public static URI guessSchema(URI dataLoc) { } } - //TODO support for other types, especially those where the schema is extracted from the data + // TODO support for other types, especially those where the schema is extracted + // from the data return result; } @@ -179,33 +181,36 @@ public static URI guessSchema(URI dataLoc) { * Determine the XML Schema location for a given XML document. * * @param input the input supplier of the XML document - * @return the location of the schema if any could be determined, otherwise null + * @return the location of the schema if any could be determined, otherwise + * null * @throws IOException * @throws XMLStreamException */ - private static URI getXmlSchemaLocation(DefaultInputSupplier input) throws IOException, XMLStreamException { + private static URI getXmlSchemaLocation(DefaultInputSupplier input) + throws IOException, XMLStreamException { XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); try (InputStream in = input.getInput()) { XMLEventReader xmlEventReader = xmlInputFactory.createXMLEventReader(in); boolean done = false; - while(xmlEventReader.hasNext() && !done) { + while (xmlEventReader.hasNext() && !done) { XMLEvent xmlEvent = xmlEventReader.nextEvent(); if (xmlEvent.isStartElement()) { - StartElement startElement = xmlEvent.asStartElement(); - - Attribute att = startElement.getAttributeByName(new QName(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "schemaLocation")); - if (att != null) { - String value = att.getValue(); - - //XXX may hold multiple schema locations, right now we only can only handle one - //XXX using the first one for now - String[] parts = value.split("\\s+"); - if (parts != null && parts.length >= 2) { - return URI.create(parts[1]); - } + StartElement startElement = xmlEvent.asStartElement(); + + Attribute att = startElement.getAttributeByName( + new QName(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "schemaLocation")); + if (att != null) { + String value = att.getValue(); + + // XXX may hold multiple schema locations, right now we only can only handle one + // XXX using the first one for now + String[] parts = value.split("\\s+"); + if (parts != null && parts.length >= 2) { + return URI.create(parts[1]); } + } - done = true; + done = true; } } } diff --git a/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy index 984478d..86a98cb 100644 --- a/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy @@ -15,7 +15,13 @@ package to.wetransform.halecli.util +import static to.wetransform.halecli.util.HaleIOHelper.prepareReader +import static to.wetransform.halecli.util.HaleIOHelper.prepareWriter + +import org.eclipse.core.runtime.jobs.Job + import com.google.common.io.Files + import eu.esdihumboldt.hale.app.transform.ConsoleProgressMonitor import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator @@ -35,10 +41,6 @@ import eu.esdihumboldt.util.cli.CLIUtil import groovy.cli.picocli.CliBuilder import groovy.cli.picocli.OptionAccessor import groovy.transform.CompileStatic -import org.eclipse.core.runtime.jobs.Job - -import static to.wetransform.halecli.util.HaleIOHelper.prepareReader -import static to.wetransform.halecli.util.HaleIOHelper.prepareWriter /** * Common utility functions for setting up a CliBuilder for loading/saving instances. @@ -50,9 +52,9 @@ class InstanceCLI { static void loadOptions(CliBuilder cli, String argName = 'data', String descr = 'Data to load', boolean allowFilter = true) { cli._(longOpt: argName, args:1, argName:'file-or-URL', descr) cli._(longOpt: argName + '-setting', args:2, valueSeparator:'=', argName:'setting=value', - 'Setting for instance reader (optional, repeatable)') + 'Setting for instance reader (optional, repeatable)') cli._(longOpt: argName + '-reader', args:1, argName: 'provider-id', - 'Identifier of instance reader to use (otherwise auto-detect)') + 'Identifier of instance reader to use (otherwise auto-detect)') // filter options if (allowFilter) { @@ -63,13 +65,13 @@ class InstanceCLI { static void filterOptions(CliBuilder cli, String argName) { def prefix = argName ? argName + '-' : '' cli._(longOpt: prefix + 'filter', args: 1, argName: 'filter', - 'Filter expression that is checked against all objects read from the source. The filter language can be specified at the beginning of the filter expression, followed by a colon. If no language is provided explicitly, the expression is assumed to be CQL. If multiple filters are provided an object must only match one of them.') + 'Filter expression that is checked against all objects read from the source. The filter language can be specified at the beginning of the filter expression, followed by a colon. If no language is provided explicitly, the expression is assumed to be CQL. If multiple filters are provided an object must only match one of them.') cli._(longOpt: prefix + 'exclude', args: 1, argName: 'filter', - 'All objects matching the filter will be exlcuded.') + 'All objects matching the filter will be exlcuded.') cli._(longOpt: prefix + 'filter-on', args: 2, valueSeparator:'=', argName: 'type=filter', - 'Filter on a specific type only. You can specify the type\'s name with or without namespace. If you want to specify the namespace, wrap it in curly braces and prepend it to the type name.') + 'Filter on a specific type only. You can specify the type\'s name with or without namespace. If you want to specify the namespace, wrap it in curly braces and prepend it to the type name.') cli._(longOpt: prefix + 'exclude-type', args: 1, argName: 'type', - 'Exclude a specific type') + 'Exclude a specific type') } static InstanceFilterDefinition createFilter(OptionAccessor options, String argName) { @@ -78,7 +80,7 @@ class InstanceCLI { def filter = options."${prefix}filters" // magic "s" at the end yields a list if (filter) { - if (!res) res = new InstanceFilterDefinition(); + if (!res) res = new InstanceFilterDefinition() filter.each { res.addUnconditionalFilter(it) @@ -87,7 +89,7 @@ class InstanceCLI { filter = options."${prefix}excludes" if (filter) { - if (!res) res = new InstanceFilterDefinition(); + if (!res) res = new InstanceFilterDefinition() filter.each { res.addExcludeFilter(it) @@ -96,7 +98,7 @@ class InstanceCLI { filter = options."${prefix}filter-ons" if (filter) { - if (!res) res = new InstanceFilterDefinition(); + if (!res) res = new InstanceFilterDefinition() filter.toSpreadMap().each { key, value -> res.addTypeFilter(key, value) @@ -105,7 +107,7 @@ class InstanceCLI { filter = options."${prefix}exclude-types" if (filter) { - if (!res) res = new InstanceFilterDefinition(); + if (!res) res = new InstanceFilterDefinition() filter.each { res.addExcludedType(it) @@ -138,7 +140,7 @@ class InstanceCLI { @CompileStatic static InstanceCollection load(URI loc, Map settings, String customProvider, - TypeIndex schema, ReportHandler reports, InstanceFilterDefinition filter = null) { + TypeIndex schema, ReportHandler reports, InstanceFilterDefinition filter = null) { Pair readerInfo = prepareReader(loc, InstanceReader, settings, customProvider) InstanceReader instanceReader = readerInfo.first @@ -165,9 +167,9 @@ class InstanceCLI { //TODO support preset? cli._(longOpt: argName, args:1, argName: 'file-or-URI', descr) cli._(longOpt: argName + '-setting', args:2, valueSeparator:'=', argName:'setting=value', - 'Setting for target writer (optional, repeatable)') + 'Setting for target writer (optional, repeatable)') cli._(longOpt: argName + '-writer', args:1, argName: 'provider-id', - 'Identifier of instance writer to use') + 'Identifier of instance writer to use') } static InstanceWriter getWriter(OptionAccessor options, String argName = 'target') { @@ -192,12 +194,12 @@ class InstanceCLI { // writer is returned because of writing instance directly, because for some // use cases it is required to first check - return prepareWriter(providerId, InstanceWriter, settings, loc); + return prepareWriter(providerId, InstanceWriter, settings, loc) } @CompileStatic static IOReport save(InstanceWriter instanceWriter, InstanceCollection instances, SchemaSpace targetSchema, - ReportHandler reports) { + ReportHandler reports) { def loc = instanceWriter.getTarget()?.location println "Writing instances to ${loc}..." @@ -214,28 +216,26 @@ class InstanceCLI { @CompileStatic static LocalOrientDB loadTempDatabase(InstanceCollection instances, TypeIndex schema, - ReportHandler reports = null) { + ReportHandler reports = null) { // create db - File tmpDir = Files.createTempDir(); - LocalOrientDB db = new LocalOrientDB(tmpDir); - tmpDir.deleteOnExit(); + File tmpDir = Files.createTempDir() + LocalOrientDB db = new LocalOrientDB(tmpDir) + tmpDir.deleteOnExit() ServiceProvider serviceProvider = null // run store instance job first... Job storeJob = new StoreInstancesJob("Load source instances into temporary database", - db, instances, serviceProvider, reports, false) { + db, instances, serviceProvider, reports, false) { - @Override - protected void onComplete() { - // do nothing + @Override + protected void onComplete() { + // do nothing + } } - }; - storeJob.run(new ConsoleProgressMonitor()) db } - } diff --git a/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy index 978bc94..c66f263 100644 --- a/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy @@ -15,6 +15,8 @@ package to.wetransform.halecli.util +import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail + import eu.esdihumboldt.hale.common.align.model.Alignment import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.core.io.HaleIO @@ -35,8 +37,6 @@ import groovy.cli.picocli.OptionAccessor import groovy.transform.CompileStatic import to.wetransform.halecli.project.ProjectHelper -import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail - /** * Common utility functions for setting up a CliBuilder for loading and saving a project. * @@ -68,7 +68,7 @@ class ProjectCLI { static void saveProjectOptions(CliBuilder cli, String argName = 'target', String descr = 'Target project file') { cli._(longOpt: argName, args:1, argName:'file', descr) cli._(longOpt: argName + '-setting', args:2, valueSeparator:'=', argName:'setting=value', - 'Setting for target writer (optional, repeatable)') + 'Setting for target writer (optional, repeatable)') //TODO also support provider ID? } @@ -137,7 +137,7 @@ class ProjectCLI { def output = new NoStreamOutputSupplier(location) IOProviderDescriptor writerFactory = HaleIO.findIOProviderFactory( - ProjectWriter.class, null, HaleConnectProjectWriter.ID); + ProjectWriter.class, null, HaleConnectProjectWriter.ID) ProjectHelper.saveProject(project, alignment, sourceSchema, targetSchema, output, reports, writerFactory, projectLoadLocation, @@ -145,5 +145,4 @@ class ProjectCLI { //TODO feedback? } - } diff --git a/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy index 3542545..694fdcd 100644 --- a/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy @@ -15,6 +15,9 @@ package to.wetransform.halecli.util +import static to.wetransform.halecli.util.HaleIOHelper.prepareReader +import static to.wetransform.halecli.util.HaleIOHelper.prepareWriter + import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator import eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration @@ -29,10 +32,8 @@ import eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace import eu.esdihumboldt.util.Pair import eu.esdihumboldt.util.cli.CLIUtil import groovy.cli.picocli.CliBuilder -import groovy.transform.CompileStatic import groovy.cli.picocli.OptionAccessor -import static to.wetransform.halecli.util.HaleIOHelper.prepareReader -import static to.wetransform.halecli.util.HaleIOHelper.prepareWriter +import groovy.transform.CompileStatic /** * Common utility functions for setting up a CliBuilder for loading a schema. @@ -44,9 +45,9 @@ class SchemaCLI { static void loadSchemaOptions(CliBuilder cli, String argName = 'schema', String descr = 'Schema to load') { cli._(longOpt: argName, args:1, argName:'file-or-URL', descr) cli._(longOpt: argName + '-setting', args:2, valueSeparator:'=', argName:'setting=value', - 'Setting for schema reader (optional, repeatable)') + 'Setting for schema reader (optional, repeatable)') cli._(longOpt: argName + '-reader', args:1, argName: 'provider-id', - 'Identifier of schema reader to use') + 'Identifier of schema reader to use') } static Schema loadSchema(OptionAccessor options, String argName = 'schema') { @@ -73,7 +74,7 @@ class SchemaCLI { } static IOConfiguration getSchemaIOConfig(OptionAccessor options, String argName = 'schema', - boolean isSource = true) { + boolean isSource = true) { def location = options."$argName" if (location) { URI loc = CLIUtil.fileOrUri(location) @@ -92,7 +93,7 @@ class SchemaCLI { @CompileStatic static IOConfiguration getSchemaIOConfig(URI loc, Map settings, - String customProvider, boolean isSource) { + String customProvider, boolean isSource) { Pair readerInfo = prepareReader(loc, SchemaReader, settings, customProvider) SchemaReader schemaReader = readerInfo.first @@ -123,9 +124,9 @@ class SchemaCLI { static void saveSchemaOptions(CliBuilder cli, String argName = 'target', String descr = 'Target location') { cli._(longOpt: argName, args:1, argName: 'file-or-URI', descr) cli._(longOpt: argName + '-setting', args:2, valueSeparator:'=', argName:'setting=value', - 'Setting for target writer (optional, repeatable)') + 'Setting for target writer (optional, repeatable)') cli._(longOpt: argName + '-writer', args:1, argName: 'provider-id', - 'Identifier of schema writer to use') + 'Identifier of schema writer to use') } private static SchemaWriter getWriter(OptionAccessor options, String argName = 'target') { @@ -147,7 +148,7 @@ class SchemaCLI { @CompileStatic private static SchemaWriter getWriter(URI loc, Map settings, String providerId) { - return prepareWriter(providerId, SchemaWriter, settings, loc); + return prepareWriter(providerId, SchemaWriter, settings, loc) } @CompileStatic @@ -170,5 +171,4 @@ class SchemaCLI { return report } - } diff --git a/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy b/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy index c0c7233..1a1866e 100644 --- a/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy +++ b/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy @@ -15,8 +15,6 @@ package to.wetransform.halecli -import eu.esdihumboldt.util.nonosgi.Init - import static org.junit.Assert.* import org.junit.BeforeClass @@ -26,6 +24,7 @@ import org.junit.contrib.java.lang.system.SystemOutRule import eu.esdihumboldt.hale.common.core.HalePlatform import eu.esdihumboldt.util.cli.Runner +import eu.esdihumboldt.util.nonosgi.Init /** * Simple tests for CLI runner. @@ -77,5 +76,4 @@ class RunnerTest { assertTrue(out.log.trim().startsWith('Usage:')) assertTrue(out.log.contains('-project')) } - } diff --git a/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy b/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy index 7112550..ecb1b7e 100644 --- a/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy +++ b/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy @@ -15,16 +15,17 @@ package to.wetransform.halecli.data -import eu.esdihumboldt.util.cli.Runner -import eu.esdihumboldt.util.nonosgi.Init +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertTrue + import org.junit.BeforeClass import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.contrib.java.lang.system.SystemOutRule -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertTrue +import eu.esdihumboldt.util.cli.Runner +import eu.esdihumboldt.util.nonosgi.Init /** * Tests for rewrite command. @@ -44,15 +45,15 @@ class RewriteCommandTest { @Test void testSimpleRewrite() { - def args = ['data', 'rewrite']; + def args = ['data', 'rewrite'] args << '--data' args << 'https://wetransform.box.com/shared/static/9sjicl1nmrxzxiapq1o2jefu5byz63j4.gml' args << '--schema' args << 'https://wetransform.box.com/shared/static/2gb9ifjjn0h08rogllm1undbbrhmwllz.xsd' -// args << '--schema-reader' -// args << 'eu.esdihumboldt.hale.io.xsd.reader' + // args << '--schema-reader' + // args << 'eu.esdihumboldt.hale.io.xsd.reader' def targetFile = File.createTempFile('rewrite', '.gml') args << '--target' @@ -71,7 +72,6 @@ class RewriteCommandTest { assertTrue(targetFile.exists()) assertTrue(targetFile.size() > 0) //TODO check file content? - } finally { targetFile.delete() } @@ -80,7 +80,7 @@ class RewriteCommandTest { @Test void testRewriteGuessSchema() { - def args = ['data', 'rewrite']; + def args = ['data', 'rewrite'] args << '--data' args << getClass().getClassLoader().getResource("testdata/inspire.gml") @@ -102,7 +102,6 @@ class RewriteCommandTest { assertTrue(targetFile.exists()) assertTrue(targetFile.size() > 0) //TODO check file content? - } finally { targetFile.delete() } @@ -111,7 +110,7 @@ class RewriteCommandTest { @Test void testRewriteNoPassthrough() { - def args = ['data', 'rewrite']; + def args = ['data', 'rewrite'] args << '--data' args << getClass().getClassLoader().getResource("testdata/inspire.gml") @@ -133,7 +132,6 @@ class RewriteCommandTest { assertTrue(targetFile.exists()) assertTrue(targetFile.size() > 0) //TODO check file content? - } finally { targetFile.delete() } @@ -142,7 +140,7 @@ class RewriteCommandTest { @Test void testRewriteFilter() { - def args = ['data', 'rewrite']; + def args = ['data', 'rewrite'] args << '--data' args << getClass().getClassLoader().getResource("testdata/inspire2.gml") @@ -179,7 +177,7 @@ class RewriteCommandTest { @Test void testRewriteFilterList() { - def args = ['data', 'rewrite']; + def args = ['data', 'rewrite'] args << '--data' args << getClass().getClassLoader().getResource("testdata/inspire2.gml") @@ -223,7 +221,7 @@ class RewriteCommandTest { @Test void testRewriteExcludeType() { - def args = ['data', 'rewrite']; + def args = ['data', 'rewrite'] args << '--data' args << getClass().getClassLoader().getResource("testdata/inspire2.gml") @@ -265,7 +263,7 @@ class RewriteCommandTest { @Test void testRewriteExclude() { - def args = ['data', 'rewrite']; + def args = ['data', 'rewrite'] args << '--data' args << getClass().getClassLoader().getResource("testdata/inspire2.gml") @@ -306,7 +304,7 @@ class RewriteCommandTest { @Test void testRewriteExcludeWorkaround() { - def args = ['data', 'rewrite']; + def args = ['data', 'rewrite'] args << '--data' args << getClass().getClassLoader().getResource("testdata/inspire2.gml") @@ -350,7 +348,7 @@ class RewriteCommandTest { @Test void testRewriteFilterContext() { - def args = ['data', 'rewrite']; + def args = ['data', 'rewrite'] args << '--data' args << getClass().getClassLoader().getResource("testdata/inspire2.gml") @@ -405,5 +403,4 @@ class RewriteCommandTest { targetFile.delete() } } - } From 40d77ed28ce3da41d57f9280a84e2d885239014e Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Tue, 20 Aug 2024 17:17:10 +0200 Subject: [PATCH 4/8] ci: add common license header to formatting rules --- build.gradle | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 1ff184c..300943b 100644 --- a/build.gradle +++ b/build.gradle @@ -316,7 +316,8 @@ def header = ''' */ ''' -def headerRegex = /(?!.*@custom-license-header).*/ +// add header only if "@custom-license-header" is NOT present in file +def headerRegex = /^(?s)(?!.*@custom-license-header).*/ spotless { java { @@ -329,7 +330,7 @@ spotless { // https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-jdt eclipse().configFile('eclipse-format.xml') - // licenseHeader(header).onlyIfContentMatches(headerRegex) + licenseHeader(header).onlyIfContentMatches(headerRegex) trimTrailingWhitespace() endWithNewline() @@ -346,7 +347,7 @@ spotless { // excludes all Java sources within the Groovy source dirs from formatting excludeJava() - // licenseHeader(header).onlyIfContentMatches(headerRegex) + licenseHeader(header).onlyIfContentMatches(headerRegex) trimTrailingWhitespace() endWithNewline() From a9edb8b707704edfaaf6524f17dde6226750f1d8 Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Tue, 20 Aug 2024 17:19:36 +0200 Subject: [PATCH 5/8] chore: apply common license headers --- src/main/groovy/to/wetransform/halecli/CLI.java | 5 +---- src/main/groovy/to/wetransform/halecli/VersionCommand.groovy | 5 +---- .../groovy/to/wetransform/halecli/data/RewriteCommand.groovy | 5 +---- .../groovy/to/wetransform/halecli/data/SplitCommand.groovy | 5 +---- .../halecli/project/AbstractDeriveProjectCommand.groovy | 5 +---- .../wetransform/halecli/project/ExportProjectCommand.groovy | 5 +---- .../to/wetransform/halecli/project/ProjectHelper.groovy | 5 +---- .../halecli/project/advisor/SaveAlignmentAdvisor.java | 5 +---- .../halecli/project/advisor/SaveProjectAdvisor.java | 5 +---- .../halecli/project/alignment/FilterAlignmentCommand.groovy | 5 +---- .../halecli/project/match/MatchSchemasCommand.groovy | 5 +---- .../to/wetransform/halecli/project/match/SchemaMatcher.java | 5 +---- .../halecli/project/match/postnas/PostNASMatchSchemas.java | 5 +---- .../halecli/project/match/postnas/PostNASPropertyInfo.groovy | 5 +---- .../project/match/postnas/PostNASSchemaMatcher.groovy | 5 +---- .../to/wetransform/halecli/project/merge/MergeCommand.groovy | 5 +---- .../to/wetransform/halecli/project/merge/MergeMigrator.java | 5 +---- .../wetransform/halecli/project/merge/MergeStatistics.groovy | 5 +---- .../halecli/project/migrate/AbstractMigrationCommand.groovy | 5 +---- .../halecli/project/migrate/AbstractMigratorCommand.groovy | 5 +---- .../halecli/project/migrate/MigrateMatchingCommand.groovy | 5 +---- .../wetransform/halecli/project/migrate/ProjectMigrator.java | 5 +---- .../halecli/project/migrate/ReplaceSourceCommand.groovy | 5 +---- .../to/wetransform/halecli/schema/RewriteCommand.groovy | 5 +---- .../groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy | 5 +---- .../groovy/to/wetransform/halecli/util/HaleIOHelper.java | 5 +---- .../groovy/to/wetransform/halecli/util/InstanceCLI.groovy | 5 +---- .../groovy/to/wetransform/halecli/util/ProjectCLI.groovy | 5 +---- src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy | 5 +---- src/test/groovy/to/wetransform/halecli/RunnerTest.groovy | 5 +---- .../to/wetransform/halecli/data/RewriteCommandTest.groovy | 5 +---- 31 files changed, 31 insertions(+), 124 deletions(-) diff --git a/src/main/groovy/to/wetransform/halecli/CLI.java b/src/main/groovy/to/wetransform/halecli/CLI.java index 3de795d..a16f431 100644 --- a/src/main/groovy/to/wetransform/halecli/CLI.java +++ b/src/main/groovy/to/wetransform/halecli/CLI.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli; import eu.esdihumboldt.util.cli.Runner; diff --git a/src/main/groovy/to/wetransform/halecli/VersionCommand.groovy b/src/main/groovy/to/wetransform/halecli/VersionCommand.groovy index ac9ba76..5678549 100644 --- a/src/main/groovy/to/wetransform/halecli/VersionCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/VersionCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli import eu.esdihumboldt.hale.common.core.HalePlatform diff --git a/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy b/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy index e47f5a6..b161232 100644 --- a/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.data import static to.wetransform.halecli.util.HaleIOHelper.guessSchema diff --git a/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy b/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy index 11b7152..742a7c3 100644 --- a/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.data import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail diff --git a/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy index bc48599..babc843 100644 --- a/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project import eu.esdihumboldt.hale.common.align.model.Alignment diff --git a/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy index a0e4986..fc90314 100644 --- a/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project import eu.esdihumboldt.hale.common.cli.HaleCLIUtil diff --git a/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy b/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy index 99adb1e..591d85d 100644 --- a/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project import org.eclipse.core.runtime.content.IContentType diff --git a/src/main/groovy/to/wetransform/halecli/project/advisor/SaveAlignmentAdvisor.java b/src/main/groovy/to/wetransform/halecli/project/advisor/SaveAlignmentAdvisor.java index 3b8e709..d8eb839 100644 --- a/src/main/groovy/to/wetransform/halecli/project/advisor/SaveAlignmentAdvisor.java +++ b/src/main/groovy/to/wetransform/halecli/project/advisor/SaveAlignmentAdvisor.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.advisor; import java.net.URI; diff --git a/src/main/groovy/to/wetransform/halecli/project/advisor/SaveProjectAdvisor.java b/src/main/groovy/to/wetransform/halecli/project/advisor/SaveProjectAdvisor.java index af7c0f4..47c6c02 100644 --- a/src/main/groovy/to/wetransform/halecli/project/advisor/SaveProjectAdvisor.java +++ b/src/main/groovy/to/wetransform/halecli/project/advisor/SaveProjectAdvisor.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.advisor; import java.net.URI; diff --git a/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy index c9461bd..7214b7c 100644 --- a/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.alignment import javax.xml.namespace.QName diff --git a/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy index f2f345d..6057b14 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.match import eu.esdihumboldt.hale.common.align.model.Alignment diff --git a/src/main/groovy/to/wetransform/halecli/project/match/SchemaMatcher.java b/src/main/groovy/to/wetransform/halecli/project/match/SchemaMatcher.java index 7eaa301..112caa7 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/SchemaMatcher.java +++ b/src/main/groovy/to/wetransform/halecli/project/match/SchemaMatcher.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.match; import eu.esdihumboldt.hale.common.align.model.Alignment; diff --git a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASMatchSchemas.java b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASMatchSchemas.java index 3e648ce..9d75704 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASMatchSchemas.java +++ b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASMatchSchemas.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2018 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.match.postnas; import to.wetransform.halecli.project.match.MatchSchemasCommand; diff --git a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy index 96e65a1..31b3a5f 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.match.postnas import java.util.List diff --git a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy index 400f619..f0fc138 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.match.postnas import javax.xml.namespace.QName diff --git a/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy index 4beeb20..c5a3165 100644 --- a/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.merge import eu.esdihumboldt.hale.common.align.merge.impl.MatchingMigration diff --git a/src/main/groovy/to/wetransform/halecli/project/merge/MergeMigrator.java b/src/main/groovy/to/wetransform/halecli/project/merge/MergeMigrator.java index 5f26c71..5b868bc 100644 --- a/src/main/groovy/to/wetransform/halecli/project/merge/MergeMigrator.java +++ b/src/main/groovy/to/wetransform/halecli/project/merge/MergeMigrator.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.merge; import java.util.ArrayList; diff --git a/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy b/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy index a70a716..05064a7 100644 --- a/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.merge import java.util.List diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy index 13b3476..b3b68d5 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.migrate import eu.esdihumboldt.hale.common.align.migrate.AlignmentMigration diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy index 85df6e3..2e81d60 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.migrate import eu.esdihumboldt.hale.common.align.migrate.AlignmentMigration diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/MigrateMatchingCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/MigrateMatchingCommand.groovy index f0abf02..636988d 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/MigrateMatchingCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/MigrateMatchingCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.migrate import eu.esdihumboldt.hale.common.align.merge.impl.MatchingMigration diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/ProjectMigrator.java b/src/main/groovy/to/wetransform/halecli/project/migrate/ProjectMigrator.java index d950430..ca011ac 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/ProjectMigrator.java +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/ProjectMigrator.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.migrate; import java.util.Collections; diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy index 7e5d872..53866a3 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.project.migrate import eu.esdihumboldt.hale.common.align.merge.impl.DefaultSchemaMigration diff --git a/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy b/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy index ac69042..d7a1b6e 100644 --- a/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2018 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.schema import eu.esdihumboldt.hale.common.cli.HaleCLIUtil diff --git a/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy index e947159..425e129 100644 --- a/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2018 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.util import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail diff --git a/src/main/groovy/to/wetransform/halecli/util/HaleIOHelper.java b/src/main/groovy/to/wetransform/halecli/util/HaleIOHelper.java index 9eb6b29..65ef19a 100644 --- a/src/main/groovy/to/wetransform/halecli/util/HaleIOHelper.java +++ b/src/main/groovy/to/wetransform/halecli/util/HaleIOHelper.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.util; import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail; diff --git a/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy index 86a98cb..d715f66 100644 --- a/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.util import static to.wetransform.halecli.util.HaleIOHelper.prepareReader diff --git a/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy index c66f263..374eb99 100644 --- a/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.util import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail diff --git a/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy index 694fdcd..fcf0ac1 100644 --- a/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.util import static to.wetransform.halecli.util.HaleIOHelper.prepareReader diff --git a/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy b/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy index 1a1866e..face7f1 100644 --- a/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy +++ b/src/test/groovy/to/wetransform/halecli/RunnerTest.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2016 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli import static org.junit.Assert.* diff --git a/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy b/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy index ecb1b7e..533655d 100644 --- a/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy +++ b/src/test/groovy/to/wetransform/halecli/data/RewriteCommandTest.groovy @@ -1,3 +1,4 @@ + /* * Copyright (c) 2017 wetransform GmbH * @@ -8,11 +9,7 @@ * * You should have received a copy of the GNU Lesser General Public License * along with this distribution. If not, see . - * - * Contributors: - * wetransform GmbH */ - package to.wetransform.halecli.data import static org.junit.Assert.assertEquals From 750ab18d2e52b3c5ee674bfa3dc2aea20ec30fad Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Fri, 30 Aug 2024 01:31:29 +0200 Subject: [PATCH 6/8] test: add integration test running a transformation --- build.gradle | 5 + .../wetransform/halecli/TransformTest.groovy | 101 ++++++++++++++++++ .../resources/testdata/hydroex/expected.gml | 1 + .../resources/testdata/hydroex/hydroEx.halez | Bin 0 -> 9831 bytes .../hydroex/hydroEx_River_1Feature.gml | 21 ++++ 5 files changed, 128 insertions(+) create mode 100644 src/test/groovy/to/wetransform/halecli/TransformTest.groovy create mode 100644 src/test/resources/testdata/hydroex/expected.gml create mode 100644 src/test/resources/testdata/hydroex/hydroEx.halez create mode 100644 src/test/resources/testdata/hydroex/hydroEx_River_1Feature.gml diff --git a/build.gradle b/build.gradle index 300943b..25a6ddd 100644 --- a/build.gradle +++ b/build.gradle @@ -135,6 +135,11 @@ mainClassName = 'to.wetransform.halecli.CLI' applicationName = 'hale' applicationDefaultJvmArgs = defaultJvmArgs +test { + // debug classloading + // jvmArgs '-verbose:class' +} + /* * plugin.xml and OSGi manifest * diff --git a/src/test/groovy/to/wetransform/halecli/TransformTest.groovy b/src/test/groovy/to/wetransform/halecli/TransformTest.groovy new file mode 100644 index 0000000..ad70192 --- /dev/null +++ b/src/test/groovy/to/wetransform/halecli/TransformTest.groovy @@ -0,0 +1,101 @@ + +/* + * Copyright (c) 2024 wetransform GmbH + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + */ +package to.wetransform.halecli + +import static org.junit.Assert.* + +import java.nio.file.Files +import java.nio.file.StandardCopyOption + +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.contrib.java.lang.system.SystemOutRule +import org.junit.rules.TemporaryFolder + +import eu.esdihumboldt.hale.common.core.HalePlatform +import eu.esdihumboldt.util.cli.Runner +import eu.esdihumboldt.util.io.IOUtils +import eu.esdihumboldt.util.nonosgi.Init +import groovy.xml.XmlUtil + +/** + * Simple tests for CLI runner. + * + * @author Simon Templer + */ +class TransformTest { + + @BeforeClass + static void init() { + Init.init() + } + + @Rule + public final SystemOutRule out = new SystemOutRule().enableLog() + + @Rule + public final TemporaryFolder folder = new TemporaryFolder() + + @Test + void testTransformExample() { + File tempFolder = folder.newFolder() + + def projectFileName = 'hydroEx.halez' + def sourceDataName = 'hydroEx_River_1Feature.gml' + def expectedResultName = 'expected.gml' + + // copy files to folder + [ + projectFileName, + sourceDataName, + expectedResultName + ].each {fileName -> + def resPath = "testdata/hydroex/$fileName" + def targetFile = new File(tempFolder, fileName) + + getClass().getClassLoader().getResourceAsStream(resPath).withStream { + Files.copy(it, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING) + } + } + + def projectFile = new File(tempFolder, projectFileName) + def sourceFile = new File(tempFolder, sourceDataName) + def targetFile = new File(tempFolder, 'target.gml') + + int code = new Runner('hale').run( + 'transform', + '-project', + projectFile.absolutePath, + '-source', + sourceFile.absolutePath, + '-target', + targetFile.absolutePath, + '-providerId', + 'eu.esdihumboldt.hale.io.gml.writer' + ) + assertEquals(0, code) + + assertTrue(out.log.contains('Transformation completed')) + + assertTrue(targetFile.exists()) + assertTrue(targetFile.length() > 0) + + def expectedResult = new File(tempFolder, expectedResultName) + + def expectedXml = new XmlSlurper().parse(expectedResult) + def resultXml = new XmlSlurper().parse(targetFile) + + assertEquals(XmlUtil.serialize(expectedXml.featureMember), XmlUtil.serialize(resultXml.featureMember)) + } +} diff --git a/src/test/resources/testdata/hydroex/expected.gml b/src/test/resources/testdata/hydroex/expected.gml new file mode 100644 index 0000000..6d88667 --- /dev/null +++ b/src/test/resources/testdata/hydroex/expected.gml @@ -0,0 +1 @@ +Contains Ordnance Survey data © Crown copyright and database right 2011engLatn389065.2778650138 603671.3321135609 389321.82097369706 603680.8337101787 389331.3778515117 603682.1336809961 389340.49748487346 603685.2731276092 389348.8294113867 603690.1314028451 389356.053439788 603696.5218059111 389361.8919547173 603704.1987572012 389366.1205853201 603712.8672357824 389368.57682769373 603722.1941168845 389369.1662898213 603731.8209736971 389367.86631900386 603741.3778515117 389364.7268723908 603750.4974848735 389359.86859715485 603758.8294113866 389353.47819408885 603766.053439788 389345.8012427988 603771.8919547173 389337.1327642175 603776.12058532 389327.80588311545 603778.5768276937 389318.17902630294 603779.1662898213 389048.17902630294 603769.1662898213 389039.49725475995 603768.0659166398 389031.1477680726 603765.4448385558 389023.39472650737 603761.3859809885 388888.5864051159 603674.7234886654 388693.28110761906 603609.6217228331 388512.58589458966 603619.1319972031 388502.9510301945 603618.6924226618 388493.58705375594 603616.3816256247 388484.853817637 603612.2884087259 388477.08693520416 603606.5700719954 388470.58488339355 603599.4463679068 388465.5975324099 603591.1910564132 388462.31654335454 603582.1213845059 388460.86800279684 603572.5858945897 388461.3075773381 603562.9510301945 388463.6183743753 603553.587053756 388467.7115912741 603544.8538176371 388473.4299280046 603537.0869352042 388480.55363209324 603530.5848833936 388488.8089435867 603525.5975324099 388497.8786154941 603522.3165433545 388507.41410541034 603520.8680027969 388697.41410541034 603510.8680027969 388706.6015493888 603511.2449023622 388715.55840608804 603513.3247817359 388925.55840608804 603583.3247817359 388936.60527349263 603588.6140190115 389065.2778650138 603671.3321135609_d1a6215e-3185-429f-b9b1-f160437e4f99_example4.5731707317073174.573170731707317 diff --git a/src/test/resources/testdata/hydroex/hydroEx.halez b/src/test/resources/testdata/hydroex/hydroEx.halez new file mode 100644 index 0000000000000000000000000000000000000000..bc00023f5f5ee2996a0c9313492f1680b4437812 GIT binary patch literal 9831 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 + + + + Contains Ordnance Survey data © Crown copyright and database right 2011 + + + + + + 389065.2778650138 603671.3321135609 389321.82097369706 603680.8337101787 389331.3778515117 603682.1336809961 389340.49748487346 603685.2731276092 389348.8294113867 603690.1314028451 389356.053439788 603696.5218059111 389361.8919547173 603704.1987572012 389366.1205853201 603712.8672357824 389368.57682769373 603722.1941168845 389369.1662898213 603731.8209736971 389367.86631900386 603741.3778515117 389364.7268723908 603750.4974848735 389359.86859715485 603758.8294113866 389353.47819408885 603766.053439788 389345.8012427988 603771.8919547173 389337.1327642175 603776.12058532 389327.80588311545 603778.5768276937 389318.17902630294 603779.1662898213 389048.17902630294 603769.1662898213 389039.49725475995 603768.0659166398 389031.1477680726 603765.4448385558 389023.39472650737 603761.3859809885 388888.5864051159 603674.7234886654 388693.28110761906 603609.6217228331 388512.58589458966 603619.1319972031 388502.9510301945 603618.6924226618 388493.58705375594 603616.3816256247 388484.853817637 603612.2884087259 388477.08693520416 603606.5700719954 388470.58488339355 603599.4463679068 388465.5975324099 603591.1910564132 388462.31654335454 603582.1213845059 388460.86800279684 603572.5858945897 388461.3075773381 603562.9510301945 388463.6183743753 603553.587053756 388467.7115912741 603544.8538176371 388473.4299280046 603537.0869352042 388480.55363209324 603530.5848833936 388488.8089435867 603525.5975324099 388497.8786154941 603522.3165433545 388507.41410541034 603520.8680027969 388697.41410541034 603510.8680027969 388706.6015493888 603511.2449023622 388715.55840608804 603513.3247817359 388925.55840608804 603583.3247817359 388936.60527349263 603588.6140190115 389065.2778650138 603671.3321135609 + + + + + 6223 + 3889100603630 + 15.0 + + + From 1f23edb49bb54291b5067dae42fb6ab58f4c6499 Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Fri, 30 Aug 2024 01:31:49 +0200 Subject: [PATCH 7/8] test: add integration test using SKOS codelist reader ...to test shadowed dependencies used in that library. --- .../wetransform/halecli/SKOSCodeListTest.java | 64 +++++++++++++++++++ src/test/resources/testdata/skos/test1.rdf | 12 ++++ 2 files changed, 76 insertions(+) create mode 100644 src/test/groovy/to/wetransform/halecli/SKOSCodeListTest.java create mode 100644 src/test/resources/testdata/skos/test1.rdf diff --git a/src/test/groovy/to/wetransform/halecli/SKOSCodeListTest.java b/src/test/groovy/to/wetransform/halecli/SKOSCodeListTest.java new file mode 100644 index 0000000..c6d3432 --- /dev/null +++ b/src/test/groovy/to/wetransform/halecli/SKOSCodeListTest.java @@ -0,0 +1,64 @@ + +/* + * Copyright (c) 2024 wetransform GmbH + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution. If not, see . + */ +package to.wetransform.halecli; + +import static org.junit.Assert.*; + +import java.net.URI; +import java.util.Collection; + +import org.junit.Test; + +import eu.esdihumboldt.hale.common.codelist.CodeList; +import eu.esdihumboldt.hale.common.codelist.io.CodeListReader; +import eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator; +import eu.esdihumboldt.hale.common.core.io.report.IOReport; +import eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier; +import eu.esdihumboldt.hale.io.codelist.skos.reader.SkosCodeListReader; + +/** + * Tests reading SKOS code lists to test shadowed dependencies in SKOS I/O + * bundle. + */ +public class SKOSCodeListTest { + + @Test + public void testSKOSFromRDF1() throws Exception { + CodeList codeList = readCodeList( + getClass().getClassLoader().getResource("testdata/skos/test1.rdf").toURI()); + + Collection entries = codeList.getEntries(); + assertFalse(entries.isEmpty()); + + assertEquals(entries.size(), 1); + + assertNotNull(codeList.getLocation()); + assertNotNull(codeList.getIdentifier()); + + for (CodeList.CodeEntry entry : entries) { + assertEquals("Data scientist", entry.getName()); + } + } + + private CodeList readCodeList(URI source) throws Exception { + CodeListReader reader = new SkosCodeListReader(); + + reader.setSource(new DefaultInputSupplier(source)); + + IOReport report = reader.execute(new LogProgressIndicator()); + assertTrue(report.isSuccess()); + + return reader.getCodeList(); + } + +} diff --git a/src/test/resources/testdata/skos/test1.rdf b/src/test/resources/testdata/skos/test1.rdf new file mode 100644 index 0000000..0bce0db --- /dev/null +++ b/src/test/resources/testdata/skos/test1.rdf @@ -0,0 +1,12 @@ + + + + SDN:W080:1:CONT0006 + Data scientist + + + Relevant contact information about the person or organisation that is responsible for the archiving, quality control and quality assurance of data. + + 2016-12-09T08:56:35.660+0000 + + \ No newline at end of file From e2475cb2f6f0833b3a23f7500bf4cb022f53c905 Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Fri, 30 Aug 2024 01:34:43 +0200 Subject: [PATCH 8/8] style: modify import order Import groovy packages first for Groovy sources. --- build.gradle | 2 +- .../to/wetransform/halecli/data/RewriteCommand.groovy | 5 +++-- .../to/wetransform/halecli/data/SplitCommand.groovy | 7 ++++--- .../wetransform/halecli/groovy/GroovyShellCommand.groovy | 9 +++++---- .../halecli/project/AbstractDeriveProjectCommand.groovy | 5 +++-- .../halecli/project/ExportProjectCommand.groovy | 5 +++-- .../to/wetransform/halecli/project/ProjectHelper.groovy | 3 ++- .../project/alignment/FilterAlignmentCommand.groovy | 9 +++++---- .../halecli/project/match/MatchSchemasCommand.groovy | 5 +++-- .../project/match/postnas/PostNASPropertyInfo.groovy | 7 ++++--- .../project/match/postnas/PostNASSchemaMatcher.groovy | 3 ++- .../halecli/project/merge/MergeCommand.groovy | 5 +++-- .../halecli/project/merge/MergeStatistics.groovy | 3 ++- .../project/migrate/AbstractMigrationCommand.groovy | 5 +++-- .../project/migrate/AbstractMigratorCommand.groovy | 5 +++-- .../project/migrate/MigrateMatchingCommand.groovy | 5 +++-- .../halecli/project/migrate/ReplaceSourceCommand.groovy | 7 ++++--- .../to/wetransform/halecli/schema/RewriteCommand.groovy | 5 +++-- .../to/wetransform/halecli/util/HaleConnectCLI.groovy | 5 +++-- .../to/wetransform/halecli/util/InstanceCLI.groovy | 7 ++++--- .../groovy/to/wetransform/halecli/util/ProjectCLI.groovy | 7 ++++--- .../groovy/to/wetransform/halecli/util/SchemaCLI.groovy | 7 ++++--- .../groovy/to/wetransform/halecli/TransformTest.groovy | 3 ++- 23 files changed, 73 insertions(+), 51 deletions(-) diff --git a/build.gradle b/build.gradle index 25a6ddd..5a1d02b 100644 --- a/build.gradle +++ b/build.gradle @@ -344,7 +344,7 @@ spotless { groovy { toggleOffOn() - importOrder('java', 'javax', 'org', 'com', '') + importOrder('groovy', 'java', 'javax', 'org', 'com', '') // https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-groovy greclipse().configFile('groovy-format.properties') diff --git a/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy b/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy index b161232..d3616ad 100644 --- a/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/data/RewriteCommand.groovy @@ -14,6 +14,9 @@ package to.wetransform.halecli.data import static to.wetransform.halecli.util.HaleIOHelper.guessSchema +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.core.io.report.IOReport import eu.esdihumboldt.hale.common.instance.io.InstanceWriter @@ -26,8 +29,6 @@ import eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace import eu.esdihumboldt.util.cli.CLIUtil import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor import to.wetransform.halecli.util.InstanceCLI import to.wetransform.halecli.util.SchemaCLI diff --git a/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy b/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy index 742a7c3..b38d2c6 100644 --- a/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/data/SplitCommand.groovy @@ -14,6 +14,10 @@ package to.wetransform.halecli.data import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor +import groovy.transform.CompileStatic + import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.core.io.HaleIO import eu.esdihumboldt.hale.common.core.io.Value @@ -31,9 +35,6 @@ import eu.esdihumboldt.hale.common.schema.model.Schema import eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor -import groovy.transform.CompileStatic import to.wetransform.halecli.util.InstanceCLI import to.wetransform.halecli.util.SchemaCLI diff --git a/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy b/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy index 61a0ad6..bbd7e7c 100644 --- a/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/groovy/GroovyShellCommand.groovy @@ -18,6 +18,11 @@ package to.wetransform.halecli.groovy +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor +import groovy.transform.CompileStatic +import groovyjarjarcommonscli.HelpFormatter + import org.codehaus.groovy.tools.shell.Groovysh import org.codehaus.groovy.tools.shell.IO import org.codehaus.groovy.tools.shell.Main @@ -33,10 +38,6 @@ import eu.esdihumboldt.hale.common.core.io.HaleIO import eu.esdihumboldt.hale.common.core.io.Value import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor -import groovy.transform.CompileStatic -import groovyjarjarcommonscli.HelpFormatter /** * Groovy shell command based on Groovy shell main class. * diff --git a/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy index babc843..8f721ed 100644 --- a/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/AbstractDeriveProjectCommand.groovy @@ -12,6 +12,9 @@ */ package to.wetransform.halecli.project +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.align.model.Alignment import eu.esdihumboldt.hale.common.cli.project.AbstractProjectEnvironmentCommand import eu.esdihumboldt.hale.common.core.io.project.ComplexConfigurationService @@ -21,8 +24,6 @@ import eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier import eu.esdihumboldt.hale.common.core.report.ReportHandler import eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment import eu.esdihumboldt.util.cli.CommandContext -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor /** * Base class for command creating derived projects. diff --git a/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy index fc90314..cdaa88c 100644 --- a/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/ExportProjectCommand.groovy @@ -12,12 +12,13 @@ */ package to.wetransform.halecli.project +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor import to.wetransform.halecli.util.HaleConnectCLI import to.wetransform.halecli.util.ProjectCLI diff --git a/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy b/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy index 591d85d..34736f4 100644 --- a/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/ProjectHelper.groovy @@ -12,6 +12,8 @@ */ package to.wetransform.halecli.project +import groovy.transform.CompileStatic + import org.eclipse.core.runtime.content.IContentType import eu.esdihumboldt.hale.common.align.model.Alignment @@ -29,7 +31,6 @@ import eu.esdihumboldt.hale.common.core.report.ReportHandler import eu.esdihumboldt.hale.common.core.service.ServiceManager import eu.esdihumboldt.hale.common.core.service.ServiceProvider import eu.esdihumboldt.hale.common.schema.model.SchemaSpace -import groovy.transform.CompileStatic import to.wetransform.halecli.project.advisor.SaveProjectAdvisor /** diff --git a/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy index 7214b7c..f6bd7d4 100644 --- a/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/alignment/FilterAlignmentCommand.groovy @@ -12,6 +12,11 @@ */ package to.wetransform.halecli.project.alignment +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor +import groovy.json.JsonSlurper +import groovy.transform.CompileStatic + import javax.xml.namespace.QName import eu.esdihumboldt.cst.functions.groovy.GroovyJoin @@ -33,10 +38,6 @@ import eu.esdihumboldt.hale.common.schema.io.SchemaIO import eu.esdihumboldt.hale.common.schema.model.TypeDefinition import eu.esdihumboldt.hale.io.xsd.constraint.XmlElements import eu.esdihumboldt.hale.io.xsd.model.XmlElement -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor -import groovy.json.JsonSlurper -import groovy.transform.CompileStatic import to.wetransform.halecli.project.AbstractDeriveProjectCommand /** diff --git a/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy index 6057b14..632ee11 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/MatchSchemasCommand.groovy @@ -12,6 +12,9 @@ */ package to.wetransform.halecli.project.match +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.align.model.Alignment import eu.esdihumboldt.hale.common.core.io.project.model.Project import eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier @@ -19,8 +22,6 @@ import eu.esdihumboldt.hale.common.schema.model.Schema import eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor import to.wetransform.halecli.util.ProjectCLI import to.wetransform.halecli.util.SchemaCLI diff --git a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy index 31b3a5f..10c17ac 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASPropertyInfo.groovy @@ -12,6 +12,10 @@ */ package to.wetransform.halecli.project.match.postnas +import groovy.transform.CompileStatic +import groovy.transform.Immutable +import groovy.transform.ToString + import java.util.List import eu.esdihumboldt.hale.common.align.groovy.accessor.EntityAccessor @@ -19,9 +23,6 @@ import eu.esdihumboldt.hale.common.align.groovy.accessor.internal.EntityAccessor import eu.esdihumboldt.hale.common.align.groovy.accessor.path.PathElement import eu.esdihumboldt.hale.common.align.model.EntityDefinition import eu.esdihumboldt.util.groovy.paths.Path -import groovy.transform.CompileStatic -import groovy.transform.Immutable -import groovy.transform.ToString @CompileStatic @Immutable diff --git a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy index f0fc138..f0acc9e 100644 --- a/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/match/postnas/PostNASSchemaMatcher.groovy @@ -12,6 +12,8 @@ */ package to.wetransform.halecli.project.match.postnas +import groovy.transform.CompileStatic + import javax.xml.namespace.QName import com.google.common.collect.ArrayListMultimap @@ -37,7 +39,6 @@ import eu.esdihumboldt.hale.common.schema.model.ChildDefinition import eu.esdihumboldt.hale.common.schema.model.DefinitionUtil import eu.esdihumboldt.hale.common.schema.model.TypeDefinition import eu.esdihumboldt.hale.common.schema.model.TypeIndex -import groovy.transform.CompileStatic import to.wetransform.halecli.project.match.SchemaMatcher /** diff --git a/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy index c5a3165..fd297ce 100644 --- a/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/merge/MergeCommand.groovy @@ -12,14 +12,15 @@ */ package to.wetransform.halecli.project.merge +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.align.merge.impl.MatchingMigration import eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration import eu.esdihumboldt.hale.common.core.service.ServiceProvider import eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment import eu.esdihumboldt.hale.common.schema.io.SchemaIO import eu.esdihumboldt.hale.common.schema.model.SchemaSpace -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor import to.wetransform.halecli.project.migrate.AbstractMigratorCommand import to.wetransform.halecli.util.ProjectCLI diff --git a/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy b/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy index 05064a7..e09b748 100644 --- a/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/merge/MergeStatistics.groovy @@ -12,13 +12,14 @@ */ package to.wetransform.halecli.project.merge +import groovy.json.JsonOutput + import java.util.List import eu.esdihumboldt.hale.common.align.extension.function.FunctionDefinition import eu.esdihumboldt.hale.common.align.extension.function.FunctionUtil import eu.esdihumboldt.hale.common.align.helper.EntityDefinitionComparator import eu.esdihumboldt.hale.common.align.model.EntityDefinition -import groovy.json.JsonOutput /** * Collects statistics on the merge. diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy index b3b68d5..9f6a4da 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigrationCommand.groovy @@ -12,13 +12,14 @@ */ package to.wetransform.halecli.project.migrate +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.align.migrate.AlignmentMigration import eu.esdihumboldt.hale.common.align.migrate.impl.DefaultAlignmentMigrator import eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration import eu.esdihumboldt.hale.common.core.service.ServiceProvider import eu.esdihumboldt.hale.common.schema.model.SchemaSpace -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor /** * Base class for commands migrating a project to a different schema. * diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy index 2e81d60..df39af7 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/AbstractMigratorCommand.groovy @@ -12,6 +12,9 @@ */ package to.wetransform.halecli.project.migrate +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.align.migrate.AlignmentMigration import eu.esdihumboldt.hale.common.align.migrate.AlignmentMigrator import eu.esdihumboldt.hale.common.align.migrate.MigrationOptions @@ -29,8 +32,6 @@ import eu.esdihumboldt.hale.common.schema.io.SchemaIO import eu.esdihumboldt.hale.common.schema.model.SchemaSpace import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor import to.wetransform.halecli.util.ProjectCLI /** diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/MigrateMatchingCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/MigrateMatchingCommand.groovy index 636988d..5e16b3e 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/MigrateMatchingCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/MigrateMatchingCommand.groovy @@ -12,13 +12,14 @@ */ package to.wetransform.halecli.project.migrate +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.align.merge.impl.MatchingMigration import eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration import eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment import eu.esdihumboldt.hale.common.schema.io.SchemaIO import eu.esdihumboldt.hale.common.schema.model.SchemaSpace -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor import to.wetransform.halecli.util.ProjectCLI /** * Command that migrates a project to a different schema. diff --git a/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy b/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy index 53866a3..272930c 100644 --- a/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/project/migrate/ReplaceSourceCommand.groovy @@ -12,14 +12,15 @@ */ package to.wetransform.halecli.project.migrate +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor +import groovy.transform.CompileStatic + import eu.esdihumboldt.hale.common.align.merge.impl.DefaultSchemaMigration import eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration import eu.esdihumboldt.hale.common.schema.model.Schema import eu.esdihumboldt.hale.common.schema.model.SchemaSpace import eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor -import groovy.transform.CompileStatic import to.wetransform.halecli.util.SchemaCLI /** * Command that migrates a project to a different schema. diff --git a/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy b/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy index d7a1b6e..f8d714e 100644 --- a/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy +++ b/src/main/groovy/to/wetransform/halecli/schema/RewriteCommand.groovy @@ -12,12 +12,13 @@ */ package to.wetransform.halecli.schema +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.schema.model.Schema import eu.esdihumboldt.util.cli.Command import eu.esdihumboldt.util.cli.CommandContext -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor import to.wetransform.halecli.util.SchemaCLI /** * Reads a schema and writes it. diff --git a/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy index 425e129..8dad83e 100644 --- a/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/HaleConnectCLI.groovy @@ -14,11 +14,12 @@ package to.wetransform.halecli.util import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor + import eu.esdihumboldt.hale.common.core.HalePlatform import eu.esdihumboldt.hale.common.core.service.ServiceProvider import eu.esdihumboldt.hale.io.haleconnect.HaleConnectService -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor /** * Common utility functions for configuring a hale connect connection. diff --git a/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy index d715f66..5b8a694 100644 --- a/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/InstanceCLI.groovy @@ -15,6 +15,10 @@ package to.wetransform.halecli.util import static to.wetransform.halecli.util.HaleIOHelper.prepareReader import static to.wetransform.halecli.util.HaleIOHelper.prepareWriter +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor +import groovy.transform.CompileStatic + import org.eclipse.core.runtime.jobs.Job import com.google.common.io.Files @@ -35,9 +39,6 @@ import eu.esdihumboldt.hale.common.schema.model.SchemaSpace import eu.esdihumboldt.hale.common.schema.model.TypeIndex import eu.esdihumboldt.util.Pair import eu.esdihumboldt.util.cli.CLIUtil -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor -import groovy.transform.CompileStatic /** * Common utility functions for setting up a CliBuilder for loading/saving instances. diff --git a/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy index 374eb99..7eefdce 100644 --- a/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/ProjectCLI.groovy @@ -14,6 +14,10 @@ package to.wetransform.halecli.util import static eu.esdihumboldt.hale.app.transform.ExecUtil.fail +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor +import groovy.transform.CompileStatic + import eu.esdihumboldt.hale.common.align.model.Alignment import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.core.io.HaleIO @@ -29,9 +33,6 @@ import eu.esdihumboldt.hale.common.schema.model.SchemaSpace import eu.esdihumboldt.hale.io.haleconnect.HaleConnectUrnBuilder import eu.esdihumboldt.hale.io.haleconnect.project.HaleConnectProjectWriter import eu.esdihumboldt.util.cli.CLIUtil -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor -import groovy.transform.CompileStatic import to.wetransform.halecli.project.ProjectHelper /** diff --git a/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy b/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy index fcf0ac1..9fbfe29 100644 --- a/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy +++ b/src/main/groovy/to/wetransform/halecli/util/SchemaCLI.groovy @@ -15,6 +15,10 @@ package to.wetransform.halecli.util import static to.wetransform.halecli.util.HaleIOHelper.prepareReader import static to.wetransform.halecli.util.HaleIOHelper.prepareWriter +import groovy.cli.picocli.CliBuilder +import groovy.cli.picocli.OptionAccessor +import groovy.transform.CompileStatic + import eu.esdihumboldt.hale.common.cli.HaleCLIUtil import eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator import eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration @@ -28,9 +32,6 @@ import eu.esdihumboldt.hale.common.schema.model.SchemaSpace import eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace import eu.esdihumboldt.util.Pair import eu.esdihumboldt.util.cli.CLIUtil -import groovy.cli.picocli.CliBuilder -import groovy.cli.picocli.OptionAccessor -import groovy.transform.CompileStatic /** * Common utility functions for setting up a CliBuilder for loading a schema. diff --git a/src/test/groovy/to/wetransform/halecli/TransformTest.groovy b/src/test/groovy/to/wetransform/halecli/TransformTest.groovy index ad70192..b0f9502 100644 --- a/src/test/groovy/to/wetransform/halecli/TransformTest.groovy +++ b/src/test/groovy/to/wetransform/halecli/TransformTest.groovy @@ -14,6 +14,8 @@ package to.wetransform.halecli import static org.junit.Assert.* +import groovy.xml.XmlUtil + import java.nio.file.Files import java.nio.file.StandardCopyOption @@ -27,7 +29,6 @@ import eu.esdihumboldt.hale.common.core.HalePlatform import eu.esdihumboldt.util.cli.Runner import eu.esdihumboldt.util.io.IOUtils import eu.esdihumboldt.util.nonosgi.Init -import groovy.xml.XmlUtil /** * Simple tests for CLI runner.