use of nl.knaw.huygens.timbuctoo.rdf.Relation in project timbuctoo by HuygensING.
the class RelationTripleProcessorTest method setup.
@Before
public void setup() {
final Database database = mock(Database.class);
subjectEntity = mock(Entity.class);
objectEntity = mock(Entity.class);
relation = mock(Relation.class);
relationType = mock(RelationType.class);
given(database.findOrCreateEntity(VRE_NAME, SUBJECT_URI)).willReturn(subjectEntity);
given(database.findOrCreateEntity(VRE_NAME, OBJECT_URI)).willReturn(objectEntity);
given(database.findOrCreateRelationType(PREDICATE_URI, PREDICATE_NAME)).willReturn(relationType);
given(subjectEntity.addRelation(any(), any())).willReturn(relation);
instance = new RelationTripleProcessor(database);
}
use of nl.knaw.huygens.timbuctoo.rdf.Relation in project timbuctoo by HuygensING.
the class RelationTripleProcessor method processAssertion.
@Override
protected void processAssertion(String vreName, String subject, String predicate, String object) {
final Entity subjectEntity = database.findOrCreateEntity(vreName, subject);
final RelationType relationType = database.findOrCreateRelationType(predicate, getLocalName(predicate));
final Entity objectEntity = database.findOrCreateEntity(vreName, object);
if (relationType.isInverted()) {
final Relation relation = objectEntity.addRelation(relationType, subjectEntity);
relation.setCommonVreProperties(vreName);
} else {
final Relation relation = subjectEntity.addRelation(relationType, objectEntity);
relation.setCommonVreProperties(vreName);
}
}
Aggregations