Search in sources :

Example 11 with CorrespondencePartType

use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.

the class RegistryEntryHateoasController method getCorrespondencePartUnitTemplate.

// Create a suggested CorrespondencePartUnit (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartenhet
@ApiOperation(value = "Suggests the contents of a new CorrespondencePart object", notes = "Returns a pre-filled CorrespondencePart object" + " with values relevant for the logged-in user", response = CorrespondencePartUnitHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartUnitHateoas.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_UNIT })
public ResponseEntity<CorrespondencePartUnitHateoas> getCorrespondencePartUnitTemplate(HttpServletRequest request) throws NikitaException {
    CorrespondencePartUnit suggestedCorrespondencePart = new CorrespondencePartUnit();
    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);
    PostalAddress postalAddress = new PostalAddress();
    postalAddress.setAddressType(POSTAL_ADDRESS);
    postalAddress.setAddressLine1("ADRL1: 744 Evergreen Terrace");
    postalAddress.setAddressLine2("ADRL2: 744 Evergreen Terrace");
    postalAddress.setAddressLine3("ADRL3: 744 Evergreen Terrace");
    postalAddress.setCountryCode("US");
    postalAddress.setPostalNumber(new PostalNumber("12345"));
    postalAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setPostalAddress(postalAddress);
    BusinessAddress businessAddress = new BusinessAddress();
    businessAddress.setAddressType(BUSINESS_ADDRESS);
    businessAddress.setAddressLine1("ADRL1: 745 Evergreen Terrace");
    businessAddress.setAddressLine2("ADRL2: 745 Evergreen Terrace");
    businessAddress.setAddressLine3("ADRL3: 745 Evergreen Terrace");
    businessAddress.setCountryCode("US");
    businessAddress.setPostalNumber(new PostalNumber("12345"));
    businessAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setBusinessAddress(businessAddress);
    suggestedCorrespondencePart.setContactPerson("Frank Contact Person Grimes");
    ContactInformation contactInformation = new ContactInformation();
    contactInformation.setEmailAddress("nikita@example.com");
    contactInformation.setMobileTelephoneNumber("123456789");
    contactInformation.setTelephoneNumber("987654321");
    suggestedCorrespondencePart.setContactInformation(contactInformation);
    suggestedCorrespondencePart.setName("Frank Grimes");
    CorrespondencePartUnitHateoas correspondencePartHateoas = new CorrespondencePartUnitHateoas(suggestedCorrespondencePart);
    correspondencePartHateoasHandler.addLinksOnTemplate(correspondencePartHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(correspondencePartHateoas);
}
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 12 with CorrespondencePartType

use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartTypeController method getCorrespondencePartTypeTemplate.

// Create a suggested correspondencePartType(like a template) with default values (nothing persisted)
// GET [contextPath][api]/metadata/ny-korrespondanseparttype
@ApiOperation(value = "Creates a suggested CorrespondencePartType", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType codes found", response = CorrespondencePartType.class), @ApiResponse(code = 404, message = "No CorrespondencePartType found"), @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 = NEW_CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> getCorrespondencePartTypeTemplate(HttpServletRequest request) {
    CorrespondencePartType correspondencePartType = new CorrespondencePartType();
    correspondencePartType.setCode(TEMPLATE_FONDS_STATUS_CODE);
    correspondencePartType.setDescription(TEMPLATE_FONDS_STATUS_DESCRIPTION);
    MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
Also used : CorrespondencePartType(nikita.model.noark5.v4.metadata.CorrespondencePartType) MetadataHateoas(nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 13 with CorrespondencePartType

use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartTypeController method updateCorrespondencePartType.

// API - All PUT Requests (CRUD - UPDATE)
// Update a korrespondanseparttype
// PUT [contextPath][api]/metatdata/korrespondanseparttype/
@ApiOperation(value = "Updates a CorrespondencePartType object", notes = "Returns the newly" + " updated CorrespondencePartType object after it is persisted to the database", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartType.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.PUT, value = CORRESPONDENCE_PART_TYPE + SLASH + FONDS_STATUS)
public ResponseEntity<MetadataHateoas> updateCorrespondencePartType(@RequestBody CorrespondencePartType correspondencePartType, HttpServletRequest request) throws NikitaException {
    CorrespondencePartType newCorrespondencePartType = correspondencePartTypeService.update(correspondencePartType);
    MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartType.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.model.noark5.v4.metadata.CorrespondencePartType) MetadataHateoas(nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 14 with CorrespondencePartType

use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartTypeService method deleteEntity.

// All DELETE operations
@Override
public void deleteEntity(@NotNull String correspondencePartTypeCode) {
    CorrespondencePartType correspondencePartType = getCorrespondencePartTypeOrThrow(correspondencePartTypeCode);
    correspondencePartTypeRepository.delete(correspondencePartType);
}
Also used : CorrespondencePartType(nikita.common.model.noark5.v4.metadata.CorrespondencePartType)

Example 15 with CorrespondencePartType

use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.

the class RegistryEntryService method createDocumentDescriptionAssociatedWithRegistryEntry.

/*
TODO: Temp disabled!
    private void associateCorrespondencePartTypeWithCorrespondencePart(@NotNull CorrespondencePart correspondencePart) {
        CorrespondencePartType incomingCorrespondencePartType = correspondencePart.getCorrespondencePartType();
        // It should never get this far with a null value
        // It should be rejected at controller level
        // The incoming CorrespondencePartType will not have @id field set. Therefore, we have to look it up
        // in the database and make sure the proper CorrespondencePartType is associated with the CorrespondencePart
        if (incomingCorrespondencePartType != null && incomingCorrespondencePartType.getCode() != null) {
            CorrespondencePartType actualCorrespondencePartType =
                    correspondencePartTypeRepository.findByCode(incomingCorrespondencePartType.getCode());
            if (actualCorrespondencePartType != null) {
                correspondencePart.setCorrespondencePartType(actualCorrespondencePartType);
            }
        }
    }


    TODO: Temp disabled!
    @Override
    public List<CorrespondencePartPerson> getCorrespondencePartPersonAssociatedWithRegistryEntry(String systemID) {
        RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
        return registryEntry.getReferenceCorrespondencePartPerson();
    }

    @Override
    public List<CorrespondencePartInternal> getCorrespondencePartInternalAssociatedWithRegistryEntry(String systemID) {
        RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
        return registryEntry.getReferenceCorrespondencePartInternal();
    }

    @Override
    public List<CorrespondencePartUnit> getCorrespondencePartUnitAssociatedWithRegistryEntry(String systemID) {
        RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
        return registryEntry.getReferenceCorrespondencePartUnit();
    }
    */
/* @Override
     public CorrespondencePartPerson createCorrespondencePartPersonAssociatedWithRegistryEntry(
             String systemID, CorrespondencePartPerson correspondencePart) {
         RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);

 TODO: Temp disabled!
         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.getReferenceCorrespondencePartPerson().add(correspondencePart);
         correspondencePart.getReferenceRegistryEntry().add(registryEntry);
         return correspondencePartService.createNewCorrespondencePartPerson(correspondencePart);

         return null;
     }
 */
/*
  TODO: Temp disabled!
    @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.getReferenceCorrespondencePartInternal().add(correspondencePart);
        correspondencePart.getReferenceRegistryEntry().add(registryEntry);
        return correspondencePartService.createNewCorrespondencePartInternal(correspondencePart);
    }

    @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.getReferenceCorrespondencePartUnit().add(correspondencePart);
        correspondencePart.getReferenceRegistryEntry().add(registryEntry);
        return correspondencePartService.createNewCorrespondencePartUnit(correspondencePart);
    }

*/
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRegistryEntry(String systemID, DocumentDescription documentDescription) {
    RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
    ArrayList<Record> records = (ArrayList<Record>) documentDescription.getReferenceRecord();
    // It should always be instaniated ... check this ...
    if (records == null) {
        records = new ArrayList<>();
        documentDescription.setReferenceRecord(records);
    }
    records.add(registryEntry);
    return documentDescriptionService.save(documentDescription);
}
Also used : ArrayList(java.util.ArrayList) Record(nikita.common.model.noark5.v4.Record) RegistryEntry(nikita.common.model.noark5.v4.casehandling.RegistryEntry)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)16 ApiOperation (io.swagger.annotations.ApiOperation)16 ApiResponses (io.swagger.annotations.ApiResponses)16 Timed (com.codahale.metrics.annotation.Timed)8 CorrespondencePartType (nikita.common.model.noark5.v4.metadata.CorrespondencePartType)8 Authorisation (nikita.webapp.security.Authorisation)7 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)7 CorrespondencePartType (nikita.model.noark5.v4.metadata.CorrespondencePartType)6 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)5 MetadataHateoas (nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas)5 NikitaException (nikita.common.util.exceptions.NikitaException)3 NikitaException (nikita.util.exceptions.NikitaException)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Record (nikita.common.model.noark5.v4.Record)1 RegistryEntry (nikita.common.model.noark5.v4.casehandling.RegistryEntry)1 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)1 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)1