using helper method from ModelSupport to find the inverse relation descriptor

This commit is contained in:
Claudio Atzori 2022-01-20 09:19:07 +01:00
parent 9acc32faa6
commit f2fde5566b
2 changed files with 39 additions and 1 deletions

View File

@ -90,7 +90,7 @@ public class ReadBlacklistFromDB implements Closeable {
inverse.setSource(target_direct); inverse.setSource(target_direct);
String encoding = rs.getString("relationship"); String encoding = rs.getString("relationship");
RelationInverse ri = ModelSupport.relationInverseMap.get(encoding); RelationInverse ri = ModelSupport.findInverse(encoding);
direct.setRelClass(ri.getRelClass()); direct.setRelClass(ri.getRelClass());
inverse.setRelClass(ri.getInverseRelClass()); inverse.setRelClass(ri.getInverseRelClass());
direct.setRelType(ri.getRelType()); direct.setRelType(ri.getRelType());

View File

@ -0,0 +1,38 @@
package eu.dnetlib.dhp.blacklist;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import eu.dnetlib.dhp.schema.common.ModelSupport;
import eu.dnetlib.dhp.schema.common.RelationInverse;
public class BlacklistRelationTest {
@Test
public void testRelationInverseLookup() {
final List<String> rels = Arrays
.asList(
"resultResult_relationship_IsRelatedTo",
"resultOrganization_affiliation_isAuthorInstitutionOf",
"resultOrganization_affiliation_hasAuthorInstitution",
"datasourceOrganization_provision_isProvidedBy",
"projectOrganization_participation_hasParticipant",
"resultProject_outcome_produces",
"resultProject_outcome_isProducedBy");
rels.forEach(r -> {
RelationInverse inverse = ModelSupport.relationInverseMap.get(r);
Assertions.assertNotNull(inverse);
Assertions.assertNotNull(inverse.getRelType());
Assertions.assertNotNull(inverse.getSubReltype());
Assertions.assertNotNull(inverse.getRelClass());
});
}
}