use of nl.knaw.huygens.timbuctoo.rdf.Entity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method getEntityOmitsDeletedRelations.
@Test
public void getEntityOmitsDeletedRelations() throws Exception {
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
UUID id = UUID.randomUUID();
UUID relatedId = UUID.randomUUID();
TinkerPopGraphManager graphManager = newGraph().withVertex("source", v -> v.withOutgoingRelation("isRelatedTo", "relatedThing", rel -> rel.withDeleted(true)).withOutgoingRelation("hasOtherRelationWith", "relatedThing").withVre("test").withVre("").withType("thing").isLatest(true).withTimId(id.toString())).withVertex("relatedThing", v -> v.withVre("test").withVre("").withType("thing").withTimId(relatedId.toString()).withProperty("testthing_displayName", "displayName")).wrap();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
ReadEntity entity = instance.getEntity(id, null, collection, (readEntity, vertex) -> {
}, (graphTraversalSource, vre, vertex, relationRef) -> {
});
assertThat(entity.getRelations(), hasSize(1));
assertThat(entity.getRelations(), contains(hasProperty("relationType", equalTo("hasOtherRelationWith"))));
}
use of nl.knaw.huygens.timbuctoo.rdf.Entity in project timbuctoo by HuygensING.
the class AltLabelTripleProcessorTest method setup.
@Before
public void setup() {
final Database database = mock(Database.class);
entity = mock(Entity.class);
instance = new AltLabelTripleProcessor(database);
given(database.findOrCreateEntity(VRE_NAME, SUBJECT_URI)).willReturn(entity);
}
use of nl.knaw.huygens.timbuctoo.rdf.Entity in project timbuctoo by HuygensING.
the class CollectionMembershipTripleProcessorTest method processMovesTheEntityToTheKnownCollectionIfItIsAnAssertion.
@Test
public void processMovesTheEntityToTheKnownCollectionIfItIsAnAssertion() {
Database database = mock(Database.class);
Collection collectionFromTriple = mock(Collection.class);
Collection archetypeCollection = mock(Collection.class);
when(collectionFromTriple.getArchetype()).thenReturn(Optional.of(archetypeCollection));
when(database.findOrCreateCollection(anyString(), anyString(), anyString())).thenReturn(collectionFromTriple);
Collection defaultCollection = mock(Collection.class);
when(database.getDefaultCollection("vreName")).thenReturn(defaultCollection);
Entity entity = mock(Entity.class);
when(database.findOrCreateEntity("vreName", SUBJECT_URI)).thenReturn(entity);
CollectionMembershipTripleProcessor instance = new CollectionMembershipTripleProcessor(database, mock(RdfImportSession.class));
instance.process("vreName", SUBJECT_URI, PREDICATE_URI, OBJECT_URI, true);
verify(entity).moveToNewCollection(defaultCollection, collectionFromTriple);
}
use of nl.knaw.huygens.timbuctoo.rdf.Entity in project timbuctoo by HuygensING.
the class AltLabelTripleProcessor method processAssertion.
@Override
protected void processAssertion(String vreName, String subject, String predicate, String lexicalValue, String typeUri) {
final Entity entity = database.findOrCreateEntity(vreName, subject);
final String propertyName = getLocalName(predicate);
addToListProperty(entity, propertyName, lexicalValue);
}
use of nl.knaw.huygens.timbuctoo.rdf.Entity in project timbuctoo by HuygensING.
the class ArchetypeTripleProcessor method processAssertion.
@Override
protected void processAssertion(String vreName, String subject, String predicate, String object) {
Collection collection = database.findOrCreateCollection(vreName, subject, getLocalName(subject));
// collection must have an archetype
Collection previousArchetype = collection.getArchetype().get();
Optional<Collection> archetypeCollectionOptional = database.findArchetypeCollection(getLocalName(object));
if (!archetypeCollectionOptional.isPresent()) {
return;
}
Collection archetypeCollection = archetypeCollectionOptional.get();
collection.setArchetype(archetypeCollection, object);
Set<Entity> entities = database.findEntitiesByCollection(collection);
entities.forEach(entity -> entity.moveToOtherArchetype(previousArchetype, archetypeCollection));
}
Aggregations