This is a minimal Java 8 Maven project with solutions to the exercises from the workshop Analysis of library metadata with Metafacture conducted by Christoph Böhme at SWIB13. It can be used as a template for Java projects using Metafacture.
The processing pipelines or workflows are built using the typesafe Metafacture Java API directly, not the Flux DSL.
Prerequisites: Java 8, Maven 3; verify with mvn -version
Create and change into a folder where you want to store the project:
mkdir ~/git ; cd ~/git
Clone metafacture-java-examples:
git clone https://github.com/hbz/metafacture-java-examples.git
Build metafacture-java-examples:
mvn clean verify
Run the included metamorph tests:
mvn clean test
Run a sample with Maven:
mvn exec:java -Dexec.classpathScope=test -Dexec.mainClass="samples.Sample1_PrintData"
Output is written to the individual folders for each sample in src/test/resources
.
The processing pipelines are written in Java, the actual transformation logic and tests are written in XML. Both can be comfortably edited using Eclipse, which provides content assist (auto-suggest), Maven support, and direct execution of the tests and the transformation.
- Download and run the Eclipse Java IDE (at least version 4.4, Luna), close the welcome screen and import metafacture-core and metafacture-java-examples:
File
→Import...
→Maven
→Existing Maven Projects...
→Next
→Browse...
→ select~/git
→Finish
- Follow the instructions for installing additional plugins and restart Eclipse when it asks you to
- Set up the XML schemas for content assist and documentation while editing metamorph and metamorph-test files:
Window
(on Mac:Eclipse
) →Preferences
→XML
→XML Catalog
- select
User Specified Entries
→Add...
→Workspace...
→metafacture-core/src/main/resources/schemata/metamorph.xsd
- repeat previous step for
metamorph-test.xsd
in the same location
To run a sample in Eclipse, open metafacture-java-examples/src/test/java/samples
, right click a sample → ‘Run As…’ → ‘Java Application’. Output is written to the corresponding folder in src/test/resources
.