use of nl.knaw.huygens.timbuctoo.core.dto.CreateEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntityMarksOneVertexAsLatest.
@Test
public void createEntityMarksOneVertexAsLatest() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
CreateEntity createEntity = withProperties(properties);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).has("isLatest", true).count().next(), is(1L));
}
use of nl.knaw.huygens.timbuctoo.core.dto.CreateEntity in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntityDuplicatesTheVertex.
@Test
public void createEntityDuplicatesTheVertex() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
Collection collection = vres.getCollection("testthings").get();
TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
CreateEntity createEntity = withProperties(properties);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).count().next(), is(2L));
}
use of nl.knaw.huygens.timbuctoo.core.dto.CreateEntity in project timbuctoo by HuygensING.
the class TimbuctooActions method createEntity.
public UUID createEntity(Collection collection, Optional<Collection> baseCollection, Iterable<TimProperty<?>> properties, User user) throws PermissionFetchingException, IOException {
checkIfAllowedToWrite(user, collection);
UUID id = UUID.randomUUID();
Change created = createChange(user);
CreateEntity createEntity = ImmutableCreateEntity.builder().properties(properties).id(id).created(created).build();
dataStoreOperations.createEntity(collection, baseCollection, createEntity);
afterSuccessTaskExecutor.addTask(new AddPersistentUrlTask(persistentUrlCreator, uriToRedirectToFromPersistentUrls.apply(collection.getCollectionName(), id, 1), ImmutableEntityLookup.builder().rev(1).timId(id).collection(collection.getCollectionName()).build()));
return id;
}
Aggregations