Search in sources :

Example 6 with CorrespondencePartInternal

use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartInternalDeserializer method deserialize.

@Override
public CorrespondencePartInternal deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    StringBuilder errors = new StringBuilder();
    CorrespondencePartInternal correspondencePartInternal = new CorrespondencePartInternal();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(correspondencePartInternal, objectNode, errors);
    CommonUtils.Hateoas.Deserialize.deserialiseCorrespondencePartInternalEntity(correspondencePartInternal, objectNode, errors);
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        errors.append("The korrespondansepartintern you tried to create is malformed. The " + "following fields are not recognised as korrespondansepartintern fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
    }
    if (0 < errors.length())
        throw new NikitaMalformedInputDataException(errors.toString());
    return correspondencePartInternal;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) CorrespondencePartInternal(nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal) NikitaMalformedInputDataException(nikita.common.util.exceptions.NikitaMalformedInputDataException)

Example 7 with CorrespondencePartInternal

use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartInternalHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject correspondencePartHateoas, JsonGenerator jgen) throws IOException {
    CorrespondencePartInternal correspondencePart = (CorrespondencePartInternal) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printCorrespondencePartInternal(jgen, correspondencePart);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, correspondencePartHateoas.getLinks(correspondencePart));
    jgen.writeEndObject();
}
Also used : CorrespondencePartInternal(nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)

Example 8 with CorrespondencePartInternal

use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartInternalDeserializer method deserialize.

@Override
public CorrespondencePartInternal deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    CorrespondencePartInternal correspondencePartInternal = new CorrespondencePartInternal();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(correspondencePartInternal, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseCorrespondencePartInternalEntity(correspondencePartInternal, objectNode);
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        throw new NikitaMalformedInputDataException("The korrespondansepartintern you tried to create is malformed. The " + "following fields are not recognised as korrespondansepartintern fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
    }
    return correspondencePartInternal;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) CorrespondencePartInternal(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

Example 9 with CorrespondencePartInternal

use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.

the class RegistryEntryService method createCorrespondencePartInternalAssociatedWithRegistryEntry.

@Override
public CorrespondencePartInternal createCorrespondencePartInternalAssociatedWithRegistryEntry(String systemID, CorrespondencePartInternal correspondencePart) {
    RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
    NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(correspondencePart);
    NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(correspondencePart);
    // bidirectional relationship @ManyToMany, set both sides of relationship
    registryEntry.getReferenceCorrespondencePart().add(correspondencePart);
    correspondencePart.getReferenceRegistryEntry().add(registryEntry);
    return correspondencePartService.createNewCorrespondencePartInternal(correspondencePart);
}
Also used : RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry)

Example 10 with CorrespondencePartInternal

use of nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartService method deleteCorrespondencePartInternal.

@Override
public void deleteCorrespondencePartInternal(@NotNull String code) {
    CorrespondencePartInternal correspondencePartInternal = (CorrespondencePartInternal) getCorrespondencePartOrThrow(code);
    /*
        // Disassociate the link between Fonds and FondsCreator
        // https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
        Query q = entityManager.createNativeQuery("DELETE FROM fonds_fonds_creator WHERE f_pk_fonds_id  = :id ;");
        q.setParameter("id", fonds.getId());
        q.executeUpdate();
        entityManager.remove(fonds);
        entityManager.flush();
        entityManager.clear();*/
    correspondencePartRepository.delete(correspondencePartInternal);
}
Also used : CorrespondencePartInternal(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)6 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 CorrespondencePartInternal (nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)6 CorrespondencePartInternal (nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)6 Timed (com.codahale.metrics.annotation.Timed)3 Authorisation (nikita.webapp.security.Authorisation)3 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 CorrespondencePartInternalHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CorrespondencePartInternalHateoas)2 CorrespondencePartInternalHateoas (nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartInternalHateoas)2 ArrayList (java.util.ArrayList)1 Record (nikita.common.model.noark5.v4.Record)1 RegistryEntry (nikita.common.model.noark5.v4.casehandling.RegistryEntry)1 CorrespondencePartType (nikita.common.model.noark5.v4.metadata.CorrespondencePartType)1 NikitaException (nikita.common.util.exceptions.NikitaException)1 NikitaMalformedInputDataException (nikita.common.util.exceptions.NikitaMalformedInputDataException)1 RegistryEntry (nikita.model.noark5.v4.casehandling.RegistryEntry)1 CorrespondencePartType (nikita.model.noark5.v4.metadata.CorrespondencePartType)1 NikitaException (nikita.util.exceptions.NikitaException)1