Skip to content

Commit b5b8cc9

Browse files
committed
Merge #229 from branch 'WIP-metafacture-core-415-addSkosLookup' of https://github.com/metafacture/metafacture-fix
2 parents e944e27 + 3c09175 commit b5b8cc9

File tree

34 files changed

+8007
-7
lines changed

34 files changed

+8007
-7
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ put_map("<mapName>",
212212
)
213213
```
214214

215+
##### `put_rdfmap`
216+
217+
Defines an external RDF map for lookup from a file or an HTTP(S) resource.
218+
As the RDF map is reducing RDF triples to a key/value map it is mandatory to set the target.
219+
The targeted RDF property can optionally be bound by an RDF language tag.
220+
221+
```perl
222+
put_rdfmap("<rdfResource>", "<rdfMapName>", target: "<rdfProperty>")
223+
put_rdfmap("<rdfResource>", "<rdfMapName>", target: "<rdfProperty>", select_language: "<rdfLanguageTag>")
224+
```
225+
215226
##### `put_var`
216227

217228
Defines a single global variable that can be referenced with `$[<variableName>]`.
@@ -553,7 +564,7 @@ join_field("<sourceField>", "<separator>")
553564

554565
##### `lookup`
555566

556-
Looks up matching values in a map and replaces the field value with this match. [External files](#put_filemap) as well as [internal maps](#put_map) can be used.
567+
Looks up matching values in a map and replaces the field value with this match. [External files](#put_filemap), [internal maps](#put_map) as well as [RDF resources](#put_rdfmap) can be used.
557568

558569
Parameters:
559570

@@ -599,6 +610,10 @@ lookup("path.to.field", "path/to/file", sep_char: ";")
599610
put_filemap("path/to/file", "file-map", sep_char: ";")
600611
lookup("path.to.field", "file-map")
601612

613+
# RDF map (explicit)
614+
put_rdfmap("path/to/file", "rdf-map", target: "<rdfProperty>")
615+
lookup("path.to.field", "rdf-map")
616+
602617
# with default value
603618
lookup("path.to.field", "map-name", __default: "NA")
604619

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ subprojects {
3636
'ace': '1.3.3',
3737
'antlr': '3.2',
3838
'equalsverifier': '3.8.2',
39+
'guava': '29.0-jre',
3940
'jackson': '2.13.3',
41+
'jena': '3.17.0',
4042
'jetty': '9.4.14.v20181114',
4143
'jquery': '3.3.1-1',
4244
'junit_jupiter': '5.8.2',
@@ -45,8 +47,8 @@ subprojects {
4547
'mockito': '2.27.0',
4648
'requirejs': '2.3.6',
4749
'slf4j': '1.7.21',
48-
'xtext': '2.26.0',
49-
'guava': '29.0-jre'
50+
'wiremock': '2.33.2',
51+
'xtext': '2.26.0'
5052
]
5153
}
5254

metafix/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ dependencies {
1313
implementation "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
1414
implementation "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
1515
implementation "com.google.guava:guava:${versions.guava}"
16+
implementation "org.apache.jena:jena-arq:${versions.jena}"
17+
implementation "org.apache.jena:jena-core:${versions.jena}"
1618
implementation "org.eclipse.emf:org.eclipse.emf.ecore:${versions.xtext}" // Workaround for hbz/lobid-resources#1462
1719
implementation "org.eclipse.xtext:org.eclipse.xtext.xbase:${versions.xtext}"
1820
implementation "org.eclipse.xtext:org.eclipse.xtext:${versions.xtext}"
1921
implementation "org.slf4j:slf4j-api:${versions.slf4j}"
2022

21-
testImplementation "org.junit.jupiter:junit-jupiter-api:${versions.junit_jupiter}"
22-
testImplementation "org.junit.platform:junit-platform-launcher:${versions.junit_platform}"
23+
testImplementation "com.github.tomakehurst:wiremock-jre8:${versions.wiremock}"
2324
testImplementation "org.eclipse.xtext:org.eclipse.xtext.testing:${versions.xtext}"
2425
testImplementation "org.eclipse.xtext:org.eclipse.xtext.xbase.testing:${versions.xtext}"
26+
testImplementation "org.junit.jupiter:junit-jupiter-api:${versions.junit_jupiter}"
27+
testImplementation "org.junit.platform:junit-platform-launcher:${versions.junit_platform}"
2528

2629
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${versions.junit_jupiter}"
2730

@@ -43,6 +46,10 @@ dependencies {
4346
configurations {
4447
mwe2 {
4548
extendsFrom implementation
49+
50+
dependencies {
51+
implementation "org.slf4j:slf4j-simple:${versions.slf4j}"
52+
}
4653
}
4754
}
4855

metafix/src/main/java/org/metafacture/metafix/FixMethod.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.metafacture.metafix;
1818

1919
import org.metafacture.metafix.api.FixFunction;
20+
import org.metafacture.metafix.maps.RdfMap;
2021
import org.metafacture.metamorph.api.Maps;
2122
import org.metafacture.metamorph.functions.ISBN;
2223
import org.metafacture.metamorph.functions.Timestamp;
@@ -92,6 +93,22 @@ public void apply(final Metafix metafix, final Record record, final List<String>
9293
metafix.putMap(params.get(0), options);
9394
}
9495
},
96+
put_rdfmap {
97+
@Override
98+
public void apply(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {
99+
final String fileName = params.get(0);
100+
final RdfMap rdfMap = new RdfMap();
101+
102+
rdfMap.setResource(fileName, metafix::resolvePath);
103+
104+
withOption(options, RdfMap.TARGET, rdfMap::setTarget);
105+
withOption(options, RdfMap.TARGET_LANGUAGE, rdfMap::setTargetLanguage);
106+
withOption(options, RdfMap.SELECT, rdfMap::setSelect);
107+
withOption(options, Maps.DEFAULT_MAP_KEY, rdfMap::setDefault);
108+
109+
metafix.putMap(params.size() > 1 ? params.get(1) : fileName, rdfMap);
110+
}
111+
},
95112
put_var {
96113
@Override
97114
public void apply(final Metafix metafix, final Record record, final List<String> params, final Map<String, String> options) {

0 commit comments

Comments
 (0)