Skip to content

Commit

Permalink
v4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdmeest committed Nov 14, 2018
1 parent c990ad2 commit 8fbc27d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 23 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

## [4.2.0] - 2018-11-14

### Added

- output format: hdt
Expand Down Expand Up @@ -106,6 +108,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- support for accessing remote files (via HTTP GET)
- basic support for functions

[4.2.0]: https://github.com/RMLio/rmlmapper-java/compare/v4.1.0...v4.2.0
[4.1.0]: https://github.com/RMLio/rmlmapper-java/compare/v4.0.0...v4.1.0
[4.0.0]: https://github.com/RMLio/rmlmapper-java/compare/v0.2.1...v4.0.0
[0.2.1]: https://github.com/RMLio/rmlmapper-java/compare/v0.2.0...v0.2.1
Expand Down
78 changes: 56 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,27 @@ import be.ugent.rml.records.RecordsFactory;
import be.ugent.rml.store.RDF4JStore;
import be.ugent.rml.store.QuadStore;

public class Main {
import java.io.FileInputStream;
import java.io.InputStream;


class Main {

public static void main(String[] args) {

boolean removeDuplicates = false; //set to true if you want to remove duplicates triples/quads from the output
String cwd = "/home/rml"; //path to default directory for local files
String mappingFile = "/home/rml/mapping.rml.ttl"; //path to the mapping file that needs to be executed
List<String> triplesMaps = new ArrayList<>(); //list of triplesmaps to execute. When this list is empty all triplesmaps in the mapping file are executed

InputStream mappingStream = new FileInputStream(mappingFile);
Model model = Rio.parse(mappingStream, "", RDFFormat.TURTLE);
RDF4JStore rmlStore = new RDF4JStore(model);

Executor executor = new Executor(rmlStore, new RecordsFactory(new DataFetcher(cwd, rmlStore)));
QuadStore result = executor.execute(triplesMaps, removeDuplicates);
try {
InputStream mappingStream = new FileInputStream(mappingFile);
Model model = Rio.parse(mappingStream, "", RDFFormat.TURTLE);
RDF4JStore rmlStore = new RDF4JStore(model);

Executor executor = new Executor(rmlStore, new RecordsFactory(new DataFetcher(cwd, rmlStore)));
QuadStore result = executor.execute(null);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
```
Expand Down Expand Up @@ -137,24 +143,51 @@ You can change the functions.ttl path using a commandline-option (`-f`).
This overrides the dynamic loading.
See the snippet below for an example of how to do it.

```
```java
package be.ugent.rml;

import be.ugent.rml.functions.FunctionLoader;
import be.ugent.rml.functions.lib.GrelProcessor;
import be.ugent.rml.records.RecordsFactory;
import be.ugent.rml.store.QuadStore;
import com.google.common.io.Resources;

String mapPath = "path/to/mapping/file";
String outPath = "path/to/where/the/output/triples/should/be/written";
Map<String, Class> libraryMap = new HashMap<>();
libraryMap.put("GrelFunctions.jar", GrelProcessor.class);
FunctionLoader functionLoader = new FunctionLoader(libraryMap);
try {
Executor executor = this.createExecutor(mapPath, functionLoader);
doMapping(executor, outPath);
} catch (IOException e) {
logger.error(e.getMessage(), e);
import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;


class Main {

public static void main(String[] args) {
String mapPath = "path/to/mapping/file";
String functionPath = "path/to/functions.ttl/file";

URL url = Resources.getResource(functionPath);

Map<String, Class> libraryMap = new HashMap<>();
libraryMap.put("GrelFunctions.jar", GrelProcessor.class);
try {
File functionsFile = new File(url.toURI());
FunctionLoader functionLoader = new FunctionLoader(functionsFile, null, libraryMap);
ClassLoader classLoader = Main.class.getClassLoader();
// execute mapping file
File mappingFile = new File(classLoader.getResource(mapPath).getFile());
QuadStore rmlStore = Utils.readTurtle(mappingFile);

Executor executor = new Executor(rmlStore, new RecordsFactory(new DataFetcher(mappingFile.getParent(), rmlStore)),
functionLoader);
QuadStore result = executor.execute(null);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
```

### Testing

#### RDBs
Make sure you have [Docker](https://www.docker.com) running.

Expand All @@ -181,6 +214,7 @@ Make sure you have [Docker](https://www.docker.com) running.
| com.opencsv opencsv | Apache License 2.0 |
| commons-lang | Apache License 2.0 |
| ch.qos.logback | Eclipse Public License 1.0 & GNU Lesser General Public License 2.1 |
| org.rdfhdt.hdt-jena | GNU Lesser General Public License v3.0 |

# UML Diagrams
## How to generate with IntelliJ IDEA
Expand All @@ -189,4 +223,4 @@ Make sure you have [Docker](https://www.docker.com) running.
* Right click on package: "be.ugent.rml"
* Diagrams > Show Diagram > Java Class Diagrams
* Choose what properties of the classes you want to show in the upper left corner
* Export to file > .png | Save diagram > .uml
* Export to file > .png | Save diagram > .uml
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>be.ugent.rml</groupId>
<artifactId>rmlmapper</artifactId>
<version>4.1.0</version>
<version>4.2.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.12</junit.version>
Expand Down

0 comments on commit 8fbc27d

Please sign in to comment.