Search in sources :

Example 6 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
@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, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(correspondencePartHateoas);
}
Also used : NikitaException(nikita.common.util.exceptions.NikitaException) Authorisation(nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.common.model.noark5.v4.metadata.CorrespondencePartType) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 7 with CorrespondencePartType

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

the class RegistryEntryHateoasController method getCorrespondencePartPersonTemplate.

// Create a suggested CorrespondencePartPerson (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartperson
@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 = CorrespondencePartPersonHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartPersonHateoas.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
@RequestMapping(method = RequestMethod.GET, value = { SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CORRESPONDENCE_PART_PERSON })
public ResponseEntity<CorrespondencePartPersonHateoas> getCorrespondencePartPersonTemplate(HttpServletRequest request) throws NikitaException {
    CorrespondencePartPerson suggestedCorrespondencePart = new CorrespondencePartPerson();
    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: 742 Evergreen Terrace");
    postalAddress.setAddressLine2("ADRL2: 742 Evergreen Terrace");
    postalAddress.setAddressLine3("ADRL3: 742 Evergreen Terrace");
    postalAddress.setCountryCode("US");
    postalAddress.setPostalNumber(new PostalNumber("12345"));
    postalAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setPostalAddress(postalAddress);
    ResidingAddress residingAddress = new ResidingAddress();
    residingAddress.setAddressType(RESIDING_ADDRESS);
    residingAddress.setAddressLine1("ADRL1: 743 Evergreen Terrace");
    residingAddress.setAddressLine2("ADRL2: 743 Evergreen Terrace");
    residingAddress.setAddressLine3("ADRL3: 743 Evergreen Terrace");
    residingAddress.setCountryCode("US");
    residingAddress.setPostalNumber(new PostalNumber("12345"));
    residingAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setResidingAddress(residingAddress);
    suggestedCorrespondencePart.setSocialSecurityNumber("09088512345");
    suggestedCorrespondencePart.setdNumber("dddddd1234");
    ContactInformation contactInformation = new ContactInformation();
    contactInformation.setEmailAddress("nikita@example.com");
    contactInformation.setMobileTelephoneNumber("123456789");
    contactInformation.setTelephoneNumber("987654321");
    suggestedCorrespondencePart.setContactInformation(contactInformation);
    suggestedCorrespondencePart.setName("Frank Grimes");
    CorrespondencePartPersonHateoas correspondencePartHateoas = new CorrespondencePartPersonHateoas(suggestedCorrespondencePart);
    correspondencePartHateoasHandler.addLinksOnTemplate(correspondencePartHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(correspondencePartHateoas);
}
Also used : NikitaException(nikita.common.util.exceptions.NikitaException) Authorisation(nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.common.model.noark5.v4.metadata.CorrespondencePartType) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 8 with CorrespondencePartType

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

the class CorrespondencePartTypeController method findBySystemId.

// Retrieves a given correspondencePartType identified by a systemId
// GET [contextPath][api]/metadata/korrespondanseparttype/{systemId}
@ApiOperation(value = "Gets correspondencePartType identified by its systemId", notes = "Returns the requested " + " correspondencePartType object", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartType.class), @ApiResponse(code = 201, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, 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), @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED) })
@Counted
@RequestMapping(value = CORRESPONDENCE_PART_TYPE + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<MetadataHateoas> findBySystemId(@PathVariable("systemID") final String systemId, HttpServletRequest request) {
    CorrespondencePartType correspondencePartType = correspondencePartTypeService.findBySystemId(systemId);
    MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartType.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.common.model.noark5.v4.metadata.CorrespondencePartType) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 9 with CorrespondencePartType

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

the class CorrespondencePartTypeController method findAll.

// API - All GET Requests (CRUD - READ)
// Retrieves all correspondencePartType
// GET [contextPath][api]/metadata/korrespondanseparttype/
@ApiOperation(value = "Retrieves all 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
@RequestMapping(method = RequestMethod.GET, value = CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) correspondencePartTypeService.findAll(), CORRESPONDENCE_PART_TYPE);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 10 with CorrespondencePartType

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

the class RegistryEntryHateoasController method getCorrespondencePartPersonTemplate.

// Create a suggested CorrespondencePartPerson (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartperson
@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 = CorrespondencePartPersonHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartPersonHateoas.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_PERSON })
public ResponseEntity<CorrespondencePartPersonHateoas> getCorrespondencePartPersonTemplate(HttpServletRequest request) throws NikitaException {
    CorrespondencePartPerson suggestedCorrespondencePart = new CorrespondencePartPerson();
    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: 742 Evergreen Terrace");
    postalAddress.setAddressLine2("ADRL2: 742 Evergreen Terrace");
    postalAddress.setAddressLine3("ADRL3: 742 Evergreen Terrace");
    postalAddress.setCountryCode("US");
    postalAddress.setPostalNumber(new PostalNumber("12345"));
    postalAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setPostalAddress(postalAddress);
    ResidingAddress residingAddress = new ResidingAddress();
    residingAddress.setAddressType(RESIDING_ADDRESS);
    residingAddress.setAddressLine1("ADRL1: 743 Evergreen Terrace");
    residingAddress.setAddressLine2("ADRL2: 743 Evergreen Terrace");
    residingAddress.setAddressLine3("ADRL3: 743 Evergreen Terrace");
    residingAddress.setCountryCode("US");
    residingAddress.setPostalNumber(new PostalNumber("12345"));
    residingAddress.setPostalTown("Springfield");
    suggestedCorrespondencePart.setResidingAddress(residingAddress);
    suggestedCorrespondencePart.setSocialSecurityNumber("09088512345");
    suggestedCorrespondencePart.setdNumber("dddddd1234");
    ContactInformation contactInformation = new ContactInformation();
    contactInformation.setEmailAddress("nikita@example.com");
    contactInformation.setMobileTelephoneNumber("123456789");
    contactInformation.setTelephoneNumber("987654321");
    suggestedCorrespondencePart.setContactInformation(contactInformation);
    suggestedCorrespondencePart.setName("Frank Grimes");
    CorrespondencePartPersonHateoas correspondencePartHateoas = new CorrespondencePartPersonHateoas(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)

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