Skip to content

Commit

Permalink
Merge branch 'rpb-157-lifeDates' of https://github.com/hbz/lobid-gnd
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Apr 26, 2024
2 parents 4b896b0 + 50aed91 commit 52b0d3a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/models/AuthorityResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ private String process(String field, String value, String label, int i, int size
} else if (Arrays.asList("dateOfBirth", "dateOfDeath").contains(field)) {
result = germanDate(value);
}
else if (value.startsWith("http")) {
else if (value.startsWith("http") && !value.contains(" ")) {
List<String> facets = Arrays.asList(HomeController.AGGREGATIONS);
boolean labelBasedFacet = facets.contains(field + ".label");
boolean qBasedSearch = facets.stream().noneMatch(s -> s.startsWith(field));
Expand Down Expand Up @@ -511,6 +511,7 @@ private String labelFor(String uri) {
: response;
return entity.get("title").asText();
} catch (InterruptedException | ExecutionException e) {
Logger.error("Could not get label for {}", uri);
e.printStackTrace();
}
return uri;
Expand All @@ -522,7 +523,7 @@ public static String germanDate(String value) {
.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(cleanDate(value)))
.format(DateTimeFormatter.ofPattern("dd.MM.uuuu", Locale.GERMAN));
} catch (DateTimeParseException e) {
e.printStackTrace();
Logger.warn("Non-ISO date: {}", value);
return value;
}

Expand Down Expand Up @@ -561,6 +562,7 @@ private static String year(JsonNode node) {
return "";
}
String text = node.elements().next().asText();
return text.matches("\\d{4}-\\d{2}-\\d{2}") ? text.split("-")[0] : text;
return text.matches(".*\\d{4}.*") ? text.replaceAll(".*(\\d{4}).*", "$1")
: text.replaceAll(".*(\\d{3}).*", "$1");
}
}

0 comments on commit 52b0d3a

Please sign in to comment.