use of nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject registryEntryHateoas, JsonGenerator jgen) throws IOException {
RegistryEntry registryEntry = (RegistryEntry) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, registryEntry);
if (registryEntry.getArchivedDate() != null) {
jgen.writeStringField(RECORD_ARCHIVED_DATE, Serialize.formatDateTime(registryEntry.getArchivedDate()));
}
if (registryEntry.getArchivedBy() != null) {
jgen.writeStringField(RECORD_ARCHIVED_BY, registryEntry.getArchivedBy());
}
CommonUtils.Hateoas.Serialize.printDisposal(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printScreening(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printClassified(jgen, registryEntry);
// handle general registryEntry properties
if (registryEntry.getTitle() != null) {
jgen.writeStringField(TITLE, registryEntry.getTitle());
}
if (registryEntry.getOfficialTitle() != null) {
jgen.writeStringField(FILE_PUBLIC_TITLE, registryEntry.getOfficialTitle());
}
if (registryEntry.getDescription() != null) {
jgen.writeStringField(DESCRIPTION, registryEntry.getDescription());
}
CommonUtils.Hateoas.Serialize.printKeyword(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printComment(jgen, registryEntry);
// TODO: FIX THIS CommonCommonUtils.Hateoas.Serialize.printCrossReference(jgen, registryEntry);
if (registryEntry.getRecordYear() != null) {
jgen.writeNumberField(REGISTRY_ENTRY_YEAR, registryEntry.getRecordYear().intValue());
}
if (registryEntry.getRecordSequenceNumber() != null) {
jgen.writeNumberField(REGISTRY_ENTRY_SEQUENCE_NUMBER, registryEntry.getRecordSequenceNumber().intValue());
}
if (registryEntry.getRegistryEntryNumber() != null) {
jgen.writeNumberField(REGISTRY_ENTRY_NUMBER, registryEntry.getRegistryEntryNumber().intValue());
}
if (registryEntry.getRegistryEntryType() != null) {
jgen.writeStringField(REGISTRY_ENTRY_TYPE, registryEntry.getRegistryEntryType());
}
if (registryEntry.getRecordStatus() != null) {
jgen.writeStringField(REGISTRY_ENTRY_STATUS, registryEntry.getRecordStatus());
}
if (registryEntry.getRecordDate() != null) {
jgen.writeStringField(REGISTRY_ENTRY_DATE, Serialize.formatDate(registryEntry.getRecordDate()));
}
if (registryEntry.getDocumentDate() != null) {
jgen.writeStringField(REGISTRY_ENTRY_DOCUMENT_DATE, Serialize.formatDate(registryEntry.getDocumentDate()));
}
if (registryEntry.getReceivedDate() != null) {
jgen.writeStringField(REGISTRY_ENTRY_RECEIVED_DATE, Serialize.formatDate(registryEntry.getReceivedDate()));
}
if (registryEntry.getSentDate() != null) {
jgen.writeStringField(REGISTRY_ENTRY_SENT_DATE, Serialize.formatDate(registryEntry.getSentDate()));
}
if (registryEntry.getDueDate() != null) {
jgen.writeStringField(REGISTRY_ENTRY_DUE_DATE, Serialize.formatDate(registryEntry.getDueDate()));
}
if (registryEntry.getFreedomAssessmentDate() != null) {
jgen.writeStringField(REGISTRY_ENTRY_RECORD_FREEDOM_ASSESSMENT_DATE, Serialize.formatDate(registryEntry.getFreedomAssessmentDate()));
}
if (registryEntry.getNumberOfAttachments() != null) {
jgen.writeNumberField(REGISTRY_ENTRY_NUMBER_OF_ATTACHMENTS, registryEntry.getNumberOfAttachments().intValue());
}
if (registryEntry.getLoanedDate() != null) {
jgen.writeStringField(CASE_LOANED_DATE, Serialize.formatDate(registryEntry.getLoanedDate()));
}
if (registryEntry.getLoanedTo() != null) {
jgen.writeStringField(CASE_LOANED_TO, registryEntry.getLoanedTo());
}
CommonUtils.Hateoas.Serialize.printCorrespondenceParts(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printSignOff(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printDocumentFlow(jgen, registryEntry);
//CommonUtils.Hateoas.Serialize.printPrecedence(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printElectronicSignature(jgen, registryEntry);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, registryEntryHateoas.getLinks(registryEntry));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasController method createRegistryEntryAssociatedWithFile.
// API - All POST Requests (CRUD - CREATE)
// Create a RegistryEntry entity
// POST [contextPath][api]/casehandling/{systemId}/ny-journalpost
@ApiOperation(value = "Persists a RegistryEntry object associated with the given Series systemId", notes = "Returns the newly created record object after it was associated with a File object and " + "persisted to the database", response = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RegistryEntryHateoas.class), @ApiResponse(code = 201, message = "RegistryEntry " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RegistryEntryHateoas.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 RegistryEntry"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_REGISTRY_ENTRY, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<RegistryEntryHateoas> createRegistryEntryAssociatedWithFile(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of file to associate the record with", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "RegistryEntry", value = "Incoming registryEntry object", required = true) @RequestBody RegistryEntry registryEntry) throws NikitaException {
RegistryEntry createdRegistryEntry = caseFileService.createRegistryEntryAssociatedWithCaseFile(systemID, registryEntry);
RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(createdRegistryEntry);
registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdRegistryEntry));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdRegistryEntry.getVersion().toString()).body(registryEntryHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method updateRegistryEntry.
// Update a RegistryEntry with given values
// PUT [contextPath][api]/casehandling/journalpost/{systemId}
@ApiOperation(value = "Updates a RegistryEntry identified by a given systemId", notes = "Returns the newly updated registryEntry", response = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RegistryEntryHateoas.class), @ApiResponse(code = 201, message = "RegistryEntry " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RegistryEntryHateoas.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 RegistryEntry"), @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<RegistryEntryHateoas> updateRegistryEntry(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of registryEntry to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "RegistryEntry", value = "Incoming registryEntry object", required = true) @RequestBody RegistryEntry registryEntry) throws NikitaException {
validateForUpdate(registryEntry);
RegistryEntry updatedRegistryEntry = registryEntryService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), registryEntry);
RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(updatedRegistryEntry);
registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedRegistryEntry));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedRegistryEntry.getVersion().toString()).body(registryEntryHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method findOneRegistryEntrybySystemId.
// Retrieve a single registryEntry identified by systemId
// GET [contextPath][api]/casehandling/journalpost/{systemID}
@ApiOperation(value = "Retrieves a single RegistryEntry entity given a systemId", response = RegistryEntry.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry returned", response = RegistryEntry.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<RegistryEntryHateoas> findOneRegistryEntrybySystemId(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the registryEntry to retrieve", required = true) @PathVariable("systemID") final String registryEntrySystemId) {
RegistryEntry registryEntry = registryEntryService.findBySystemIdOrderBySystemId(registryEntrySystemId);
RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(registryEntry);
registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(registryEntry.getVersion().toString()).body(registryEntryHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasController method findRegistryEntryAssociatedWithCaseFileBySystemId.
// Retrieve all RegistryEntry associated with a casefile identified by systemId
// GET [contextPath][api]/casehandling/saksmappe/{systemID}/journalpost
@ApiOperation(value = "Retrieves all RegistryEntry associated with a CaseFile identified by systemId", response = RegistryEntry.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry list returned", response = RegistryEntryHateoas.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 + SLASH + REGISTRY_ENTRY, method = RequestMethod.GET)
public ResponseEntity<RegistryEntryHateoas> findRegistryEntryAssociatedWithCaseFileBySystemId(HttpServletRequest request, @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);
}
RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(new ArrayList<>(caseFile.getReferenceRecord()));
registryEntryHateoasHandler.addLinks(registryEntryHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(registryEntryHateoas);
}
Aggregations