use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveVreTest method loadLoadsRelationCollections.
@Test
public void loadLoadsRelationCollections() {
final String entityTypeName = "relation";
final String collectionName = "relations";
final Vre instance = load(initGraph(g -> g.withVertex("vre", v -> v.withLabel(Vre.DATABASE_LABEL).withProperty(VRE_NAME_PROPERTY_NAME, "VreName")).withVertex("collection", v -> v.withLabel(entityTypeName).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, collectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName).withProperty(Collection.IS_RELATION_COLLECTION_PROPERTY_NAME, true).withIncomingRelation(HAS_COLLECTION_RELATION_NAME, "vre"))));
final Collection collectionByName = instance.getCollectionForCollectionName(collectionName).get();
assertThat(instance.getRelationCollection().get(), equalTo(collectionByName));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class LoadSaveVreTest method loadLoadsInheritingCollections.
@Test
public void loadLoadsInheritingCollections() {
final String entityTypeName = "wwperson";
final String collectionName = "wwpersons";
final String archetypeName = "person";
final String archetypeCollectionName = "persons";
final Vre instance = load(initGraph(g -> g.withVertex("vre", v -> v.withLabel(Vre.DATABASE_LABEL).withProperty(VRE_NAME_PROPERTY_NAME, "VreName")).withVertex("collection", v -> v.withLabel(Collection.DATABASE_LABEL).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, collectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, entityTypeName).withProperty(Collection.IS_RELATION_COLLECTION_PROPERTY_NAME, false).withIncomingRelation(HAS_COLLECTION_RELATION_NAME, "vre")).withVertex("archetype", v -> v.withLabel(Collection.DATABASE_LABEL).withProperty(Collection.COLLECTION_NAME_PROPERTY_NAME, archetypeCollectionName).withProperty(Collection.ENTITY_TYPE_NAME_PROPERTY_NAME, archetypeName).withIncomingRelation(HAS_ARCHETYPE_RELATION_NAME, "collection"))));
assertThat(instance.getImplementerOf("person").get().getEntityTypeName(), equalTo(entityTypeName));
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class RdfImportSession method close.
public void close() {
Vre reloadedVre = dataStoreOperations.loadVres().getVre(this.vre.getVreName());
if (sessionState == SessionState.SUCCESS) {
dataStoreOperations.getEntitiesWithUnknownType(reloadedVre).forEach(entityUri -> errorReporter.entityTypeUnknown(entityUri));
dataStoreOperations.finishEntities(reloadedVre, entityFinisherHelper);
reloadedVre.getCollections().values().forEach(col -> {
List<PredicateInUse> predicatesFor = dataStoreOperations.getPredicatesFor(col);
dataStoreOperations.addPropertiesToCollection(col, propertyFactory.fromPredicates(predicatesFor));
});
}
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class RdfImportSession method cleanImportSession.
static RdfImportSession cleanImportSession(String vreName, DataStoreOperations dataStoreOperations, RdfImportErrorReporter errorReporter, PropertyFactory propertyFactory, EntityFinisherHelper entityFinisherHelper) {
Vre vre = dataStoreOperations.ensureVreExists(vreName);
dataStoreOperations.clearMappingErrors(vre);
dataStoreOperations.removeCollectionsAndEntities(vre);
dataStoreOperations.addCollectionToVre(vre, CreateCollection.defaultCollection(vre.getVreName()));
dataStoreOperations.addPredicateValueTypeVertexToVre(vre);
Vre reloadedVre = dataStoreOperations.loadVres().getVre(vre.getVreName());
return new RdfImportSession(dataStoreOperations, reloadedVre, errorReporter, propertyFactory, entityFinisherHelper);
}
use of nl.knaw.huygens.timbuctoo.model.vre.Vre in project timbuctoo by HuygensING.
the class RdfImportSession method updateImportSession.
public static RdfImportSession updateImportSession(String vreName, DataStoreOperations dataStoreOperations, EntityFinisherHelper entityFinisherHelper) {
LogRdfImportErrorReporter errorReporter = new LogRdfImportErrorReporter();
Vre vre = dataStoreOperations.ensureVreExists(vreName);
if (vre.getCollectionForTypeName(CreateCollection.defaultCollection(vreName).getEntityTypeName(vre)) == null) {
dataStoreOperations.addCollectionToVre(vre, CreateCollection.defaultCollection(vre.getVreName()));
dataStoreOperations.addPredicateValueTypeVertexToVre(vre);
}
Vre reloadedVre = dataStoreOperations.loadVres().getVre(vre.getVreName());
return new RdfImportSession(dataStoreOperations, reloadedVre, errorReporter, new PropertyFactory(errorReporter), entityFinisherHelper);
}
Aggregations