Skip to content

Commit

Permalink
Add path to rpb-spatial entries as SKOS.definition (RPB-146)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Jul 17, 2024
1 parent 5bcb4d6 commit daa60f2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/SpatialToSkos.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import java.io.IOException;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import org.apache.commons.lang3.tuple.Pair;
import org.apache.jena.rdf.model.Model;
Expand All @@ -24,6 +26,7 @@
import com.fasterxml.jackson.databind.JsonNode;

import controllers.nwbib.Classification;
import controllers.nwbib.Lobid;

/**
* Generate a SKOS representation from the internal spatial classification data
Expand Down Expand Up @@ -97,8 +100,13 @@ private static void addHierarchy(Model model, Map<String, List<JsonNode>> hierar
sub.getValue().forEach(entry -> {
try {
String superSubject = sub.getKey();
addInSchemeAndPrefLabel(model, entry).addProperty(SKOS.broader,
model.createResource(superSubject));
Resource resource = addInSchemeAndPrefLabel(model, entry);
resource.addProperty(SKOS.broader, model.createResource(superSubject));
resource.addProperty(SKOS.definition,
Classification
.pathTo(entry.get("value").asText()).stream().map(uri -> String.format("%s (n%s)",
Lobid.facetLabel(Arrays.asList(uri), "", ""), Classification.shortId(uri)))
.collect(Collectors.joining(" > ")), "de");
} catch (Exception e) {
System.err.println("Error processing: " + entry);
e.printStackTrace();
Expand Down

0 comments on commit daa60f2

Please sign in to comment.