Search in sources :

Example 1 with Relation

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);
}
Also used : Entity(nl.knaw.huygens.timbuctoo.rdf.Entity) Relation(nl.knaw.huygens.timbuctoo.rdf.Relation) RelationType(nl.knaw.huygens.timbuctoo.rdf.RelationType) Database(nl.knaw.huygens.timbuctoo.rdf.Database) Before(org.junit.Before)

Example 2 with Relation

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);
    }
}
Also used : Entity(nl.knaw.huygens.timbuctoo.rdf.Entity) Relation(nl.knaw.huygens.timbuctoo.rdf.Relation) RelationType(nl.knaw.huygens.timbuctoo.rdf.RelationType)

Aggregations

Entity (nl.knaw.huygens.timbuctoo.rdf.Entity)2 Relation (nl.knaw.huygens.timbuctoo.rdf.Relation)2 RelationType (nl.knaw.huygens.timbuctoo.rdf.RelationType)2 Database (nl.knaw.huygens.timbuctoo.rdf.Database)1 Before (org.junit.Before)1