Search in sources :

Example 51 with Change

use of nl.knaw.huygens.timbuctoo.model.Change in project timbuctoo by HuygensING.

the class ChangeRangeFacetGetterTest method serializedChangeWithDate.

/**
 * Serializes a Change with a json object mapper.
 *
 * @param dateString a date in the format yyyyMMdd
 * @return the serialized Change
 */
private String serializedChangeWithDate(String dateString) {
    try {
        LocalDate localDate = LocalDate.parse(dateString, DateTimeFormatter.BASIC_ISO_DATE);
        Instant instant = localDate.atStartOfDay(ZoneId.systemDefault()).toInstant();
        Change change = new Change(instant.toEpochMilli(), "notImportant", "notImportant");
        return new ObjectMapper().writeValueAsString(change);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Instant(java.time.Instant) Change(nl.knaw.huygens.timbuctoo.model.Change) LocalDate(java.time.LocalDate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 52 with Change

use of nl.knaw.huygens.timbuctoo.model.Change 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;
}
Also used : ImmutableCreateEntity(nl.knaw.huygens.timbuctoo.core.dto.ImmutableCreateEntity) CreateEntity(nl.knaw.huygens.timbuctoo.core.dto.CreateEntity) Change(nl.knaw.huygens.timbuctoo.model.Change) UUID(java.util.UUID)

Aggregations

Change (nl.knaw.huygens.timbuctoo.model.Change)52 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)40 Test (org.junit.Test)40 UUID (java.util.UUID)39 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)34 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 IOException (java.io.IOException)33 TimProperty (nl.knaw.huygens.timbuctoo.core.dto.property.TimProperty)31 UpdateEntity (nl.knaw.huygens.timbuctoo.core.dto.UpdateEntity)30 Instant (java.time.Instant)29 List (java.util.List)29 ReadEntity (nl.knaw.huygens.timbuctoo.core.dto.ReadEntity)29 Vres (nl.knaw.huygens.timbuctoo.model.vre.Vres)29 Lists (com.google.common.collect.Lists)28 URI (java.net.URI)28 Optional (java.util.Optional)28 Collectors.toList (java.util.stream.Collectors.toList)28 CreateCollection (nl.knaw.huygens.timbuctoo.core.dto.CreateCollection)28 CreateEntity (nl.knaw.huygens.timbuctoo.core.dto.CreateEntity)28 ArrayList (java.util.ArrayList)27