From a69e57eeccc20b1adfef0cd88199e753dd1965b9 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Mon, 6 Dec 2021 09:53:15 +0100 Subject: [PATCH] Added helper method to lookup for inverse relations regardless of the upper/lower case in the relation encoding --- .../eu/dnetlib/dhp/schema/common/ModelSupport.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/eu/dnetlib/dhp/schema/common/ModelSupport.java b/src/main/java/eu/dnetlib/dhp/schema/common/ModelSupport.java index 8639d55..c93a45c 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/common/ModelSupport.java +++ b/src/main/java/eu/dnetlib/dhp/schema/common/ModelSupport.java @@ -158,6 +158,16 @@ public class ModelSupport { } } + private RelationInverse findInverse(String encoding) { + return ModelSupport.relationInverseMap + .entrySet() + .stream() + .filter(r -> encoding.equalsIgnoreCase(r.getKey())) + .findFirst() + .map(r -> r.getValue()) + .orElseThrow(() -> new IllegalArgumentException("invalid relationship: " + encoding)); + } + /** * Helper method: fina a relation filtering by a relation name * @param relationName