use of nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasController method findOneCaseFilebySystemId.
// Retrieve a single casefile identified by systemId
// GET [contextPath][api]/casehandling/saksmappe/{systemID}
@ApiOperation(value = "Retrieves a single CaseFile entity given a systemId", response = CaseFile.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile returned", response = CaseFile.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(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> findOneCaseFilebySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the caseFile to retrieve", required = true) @PathVariable("systemID") final String caseFileSystemId) {
CaseFile caseFile = caseFileService.findBySystemIdOrderBySystemId(caseFileSystemId);
if (caseFile == null) {
throw new NoarkEntityNotFoundException(caseFileSystemId);
}
CaseFileHateoas caseFileHateoas = new CaseFileHateoas(caseFile);
caseFileHateoasHandler.addLinks(caseFileHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(caseFile.getVersion().toString()).body(caseFileHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasController method findAllCaseFile.
@ApiOperation(value = "Retrieves multiple CaseFile entities limited by ownership rights", notes = "The field skip" + "tells how many CaseFile rows of the result set to ignore (starting at 0), while top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = CaseFileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile list found", response = CaseFileHateoas.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)
public ResponseEntity<CaseFileHateoas> findAllCaseFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
CaseFileHateoas caseFileHateoas = new CaseFileHateoas((ArrayList<INikitaEntity>) (ArrayList) caseFileService.findCaseFileByOwnerPaginated(top, skip));
caseFileHateoasHandler.addLinks(caseFileHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(caseFileHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasController method updateCaseFile.
// Update a CaseFile with given values
// PUT [contextPath][api]/casehandling/saksmappe/{systemId}
@ApiOperation(value = "Updates a CaseFile identified by a given systemId", notes = "Returns the newly updated caseFile", response = CaseFileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CaseFileHateoas.class), @ApiResponse(code = 201, message = "CaseFile " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CaseFileHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type CaseFile"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<CaseFileHateoas> updateCaseFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of caseFile to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "CaseFile", value = "Incoming caseFile object", required = true) @RequestBody CaseFile caseFile) throws NikitaException {
validateForUpdate(caseFile);
CaseFile updatedCaseFile = caseFileService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), caseFile);
CaseFileHateoas caseFileHateoas = new CaseFileHateoas(updatedCaseFile);
caseFileHateoasHandler.addLinks(caseFileHateoas, request, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedCaseFile));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedCaseFile.getVersion().toString()).body(caseFileHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject caseFileHateoas, JsonGenerator jgen) throws IOException {
CaseFile caseFile = (CaseFile) noarkSystemIdEntity;
jgen.writeStartObject();
if (caseFile.getSystemId() != null) {
jgen.writeStringField(SYSTEM_ID, caseFile.getSystemId());
}
if (caseFile.getFileId() != null) {
jgen.writeStringField(FILE_ID, caseFile.getFileId());
}
if (caseFile.getTitle() != null) {
jgen.writeStringField(TITLE, caseFile.getTitle());
}
if (caseFile.getOfficialTitle() != null) {
jgen.writeStringField(FILE_PUBLIC_TITLE, caseFile.getOfficialTitle());
}
if (caseFile.getDescription() != null) {
jgen.writeStringField(DESCRIPTION, caseFile.getDescription());
}
CommonUtils.Hateoas.Serialize.printKeyword(jgen, caseFile);
if (caseFile.getDocumentMedium() != null) {
jgen.writeStringField(DOCUMENT_MEDIUM, caseFile.getDocumentMedium());
}
CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, caseFile);
if (caseFile.getCreatedDate() != null) {
jgen.writeStringField(CREATED_DATE, Serialize.formatDateTime(caseFile.getCreatedDate()));
}
if (caseFile.getCreatedBy() != null) {
jgen.writeStringField(CREATED_BY, caseFile.getCreatedBy());
}
if (caseFile.getFinalisedDate() != null) {
jgen.writeStringField(FINALISED_DATE, Serialize.formatDateTime(caseFile.getFinalisedDate()));
}
if (caseFile.getFinalisedBy() != null) {
jgen.writeStringField(FINALISED_BY, caseFile.getFinalisedBy());
}
if (caseFile.getReferenceSeries() != null && caseFile.getReferenceSeries().getSystemId() != null) {
jgen.writeStringField(REFERENCE_SERIES, caseFile.getReferenceSeries().getSystemId());
}
if (caseFile.getCaseYear() != null) {
jgen.writeNumberField(CASE_YEAR, caseFile.getCaseYear().intValue());
}
if (caseFile.getCaseSequenceNumber() != null) {
jgen.writeNumberField(CASE_SEQUENCE_NUMBER, caseFile.getCaseSequenceNumber().intValue());
}
if (caseFile.getCaseDate() != null) {
jgen.writeStringField(CASE_DATE, Serialize.formatDate(caseFile.getCaseDate()));
}
if (caseFile.getAdministrativeUnit() != null) {
jgen.writeStringField(ADMINISTRATIVE_UNIT, caseFile.getAdministrativeUnit());
}
if (caseFile.getCaseResponsible() != null) {
jgen.writeStringField(CASE_RESPONSIBLE, caseFile.getCaseResponsible());
}
if (caseFile.getRecordsManagementUnit() != null) {
jgen.writeStringField(CASE_RECORDS_MANAGEMENT_UNIT, caseFile.getRecordsManagementUnit());
}
if (caseFile.getCaseStatus() != null) {
jgen.writeStringField(CASE_STATUS, caseFile.getCaseStatus());
}
if (caseFile.getLoanedDate() != null) {
jgen.writeStringField(CASE_LOANED_DATE, Serialize.formatDate(caseFile.getLoanedDate()));
}
if (caseFile.getLoanedTo() != null) {
jgen.writeStringField(CASE_LOANED_TO, caseFile.getLoanedTo());
}
// TODO: Implement M209 referanseSekundaerKlassifikasjon
//CommonCommonUtils.Hateoas.Serialize.printSecondaryClassification(jgen, caseFile);
CommonUtils.Hateoas.Serialize.printCaseParty(jgen, caseFile);
//CommonUtils.Hateoas.Serialize.printPrecedence(jgen, caseFile);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, caseFileHateoas.getLinks(caseFile));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject caseFileHateoas, JsonGenerator jgen) throws IOException {
CaseFile caseFile = (CaseFile) noarkSystemIdEntity;
jgen.writeStartObject();
if (caseFile.getSystemId() != null) {
jgen.writeStringField(SYSTEM_ID, caseFile.getSystemId());
}
if (caseFile.getFileId() != null) {
jgen.writeStringField(FILE_ID, caseFile.getFileId());
}
if (caseFile.getTitle() != null) {
jgen.writeStringField(TITLE, caseFile.getTitle());
}
if (caseFile.getOfficialTitle() != null) {
jgen.writeStringField(FILE_PUBLIC_TITLE, caseFile.getOfficialTitle());
}
if (caseFile.getDescription() != null) {
jgen.writeStringField(DESCRIPTION, caseFile.getDescription());
}
CommonUtils.Hateoas.Serialize.printKeyword(jgen, caseFile);
if (caseFile.getDocumentMedium() != null) {
jgen.writeStringField(DOCUMENT_MEDIUM, caseFile.getDocumentMedium());
}
CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, caseFile);
if (caseFile.getCreatedDate() != null) {
jgen.writeStringField(CREATED_DATE, Serialize.formatDateTime(caseFile.getCreatedDate()));
}
if (caseFile.getCreatedBy() != null) {
jgen.writeStringField(CREATED_BY, caseFile.getCreatedBy());
}
if (caseFile.getFinalisedDate() != null) {
jgen.writeStringField(FINALISED_DATE, Serialize.formatDateTime(caseFile.getFinalisedDate()));
}
if (caseFile.getFinalisedBy() != null) {
jgen.writeStringField(FINALISED_BY, caseFile.getFinalisedBy());
}
if (caseFile.getReferenceSeries() != null && caseFile.getReferenceSeries().getSystemId() != null) {
jgen.writeStringField(REFERENCE_SERIES, caseFile.getReferenceSeries().getSystemId());
}
if (caseFile.getCaseYear() != null) {
jgen.writeNumberField(CASE_YEAR, caseFile.getCaseYear().intValue());
}
if (caseFile.getCaseSequenceNumber() != null) {
jgen.writeNumberField(CASE_SEQUENCE_NUMBER, caseFile.getCaseSequenceNumber().intValue());
}
if (caseFile.getCaseDate() != null) {
jgen.writeStringField(CASE_DATE, Serialize.formatDate(caseFile.getCaseDate()));
}
if (caseFile.getAdministrativeUnit() != null) {
jgen.writeStringField(ADMINISTRATIVE_UNIT, caseFile.getAdministrativeUnit());
}
if (caseFile.getCaseResponsible() != null) {
jgen.writeStringField(CASE_RESPONSIBLE, caseFile.getCaseResponsible());
}
if (caseFile.getRecordsManagementUnit() != null) {
jgen.writeStringField(CASE_RECORDS_MANAGEMENT_UNIT, caseFile.getRecordsManagementUnit());
}
if (caseFile.getCaseStatus() != null) {
jgen.writeStringField(CASE_STATUS, caseFile.getCaseStatus());
}
if (caseFile.getLoanedDate() != null) {
jgen.writeStringField(CASE_LOANED_DATE, Serialize.formatDate(caseFile.getLoanedDate()));
}
if (caseFile.getLoanedTo() != null) {
jgen.writeStringField(CASE_LOANED_TO, caseFile.getLoanedTo());
}
// TODO: Implement M209 referanseSekundaerKlassifikasjon
// CommonCommonUtils.Hateoas.Serialize.printSecondaryClassification(jgen, caseFile);
CommonUtils.Hateoas.Serialize.printCaseParty(jgen, caseFile);
// CommonUtils.Hateoas.Serialize.printPrecedence(jgen, caseFile);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, caseFileHateoas.getLinks(caseFile));
jgen.writeEndObject();
}
Aggregations