Search in sources :

Example 1 with CorrespondencePart

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

the class RegistryEntryService method createCorrespondencePartPersonAssociatedWithRegistryEntry.

@Override
public CorrespondencePartPerson createCorrespondencePartPersonAssociatedWithRegistryEntry(String systemID, CorrespondencePartPerson correspondencePart) {
    RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
    associateCorrespondencePartTypeWithCorrespondencePart(correspondencePart);
    ContactInformation contactInformation = correspondencePart.getContactInformation();
    if (null != contactInformation) {
        NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(contactInformation);
        NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(contactInformation);
    }
    SimpleAddress postalAddress = correspondencePart.getPostalAddress();
    if (null != postalAddress) {
        NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(postalAddress);
        NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(postalAddress);
    }
    SimpleAddress residingAddress = correspondencePart.getResidingAddress();
    if (null != residingAddress) {
        NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(residingAddress);
        NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(residingAddress);
    }
    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.createNewCorrespondencePartPerson(correspondencePart);
}
Also used : RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry)

Example 2 with CorrespondencePart

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

the class RegistryEntryService method createCorrespondencePartUnitAssociatedWithRegistryEntry.

@Override
public CorrespondencePartUnit createCorrespondencePartUnitAssociatedWithRegistryEntry(String systemID, CorrespondencePartUnit correspondencePart) {
    RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
    associateCorrespondencePartTypeWithCorrespondencePart(correspondencePart);
    ContactInformation contactInformation = correspondencePart.getContactInformation();
    if (null != contactInformation) {
        NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(contactInformation);
        NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(contactInformation);
    }
    SimpleAddress postalAddress = correspondencePart.getPostalAddress();
    if (null != postalAddress) {
        NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(postalAddress);
        NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(postalAddress);
    }
    SimpleAddress businessAddress = correspondencePart.getBusinessAddress();
    if (null != businessAddress) {
        NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(businessAddress);
        NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(businessAddress);
    }
    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.createNewCorrespondencePartUnit(correspondencePart);
}
Also used : RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry)

Example 3 with CorrespondencePart

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

the class CorrespondencePartService method getCorrespondencePartOrThrow.

/**
     * Internal helper method. Rather than having a find and try catch in multiple methods, we have it here once.
     * If you call this, be aware that you will only ever get a valid CorrespondencePart back. If there is no valid
     * CorrespondencePart, an exception is thrown
     *
     * @param correspondencePartSystemId
     * @return
     */
protected CorrespondencePart getCorrespondencePartOrThrow(@NotNull String correspondencePartSystemId) {
    CorrespondencePart correspondencePart = correspondencePartRepository.findBySystemIdOrderBySystemId(correspondencePartSystemId);
    if (correspondencePart == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " CorrespondencePart, using systemId " + correspondencePartSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return correspondencePart;
}
Also used : NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException) CorrespondencePart(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePart)

Example 4 with CorrespondencePart

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

the class RegistryEntryHateoasController method getCorrespondencePartInternalTemplate.

// Create a suggested CorrespondencePartInternal (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartintern
@ApiOperation(value = "Suggests the contents of a new CorrespondencePartInternal object", notes = "Returns a pre-filled CorrespondencePartInternal object" + " with values relevant for the logged-in user", response = CorrespondencePartInternalHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartInternalHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.GET, value = { SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CORRESPONDENCE_PART_INTERNAL })
public ResponseEntity<String> getCorrespondencePartInternalTemplate(HttpServletRequest request) throws NikitaException {
    CorrespondencePartInternal suggestedCorrespondencePart = new CorrespondencePartInternal();
    CorrespondencePartType correspondencePartType = correspondencePartTypeService.findByCode(CORRESPONDENCE_PART_CODE_EA);
    if (correspondencePartType == null) {
        throw new NikitaException("Internal error, metadata missing. [" + CORRESPONDENCE_PART_CODE_EA + "] returns no value");
    }
    suggestedCorrespondencePart.setCorrespondencePartType(correspondencePartType);
    // The reason this is not implemented is that we are missing AdministrativeUnit and multiple users
    CorrespondencePartInternalHateoas correspondencePartHateoas = new CorrespondencePartInternalHateoas(suggestedCorrespondencePart);
    correspondencePartHateoasHandler.addLinksOnTemplate(correspondencePartHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body("");
}
Also used : NikitaException(nikita.util.exceptions.NikitaException) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.model.noark5.v4.metadata.CorrespondencePartType) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 5 with CorrespondencePart

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

the class CorrespondencePartPersonDeserializer method deserialize.

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

Aggregations

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