use of nikita.common.model.noark5.v4.metadata.DocumentStatus in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionDeserializer method deserialize.
@Override
public DocumentDescription deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
DocumentDescription documentDescription = new DocumentDescription();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general record properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(documentDescription, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(documentDescription, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkTitleDescriptionEntity(documentDescription, objectNode);
// Deserialize documentType
JsonNode currentNode = objectNode.get(DOCUMENT_DESCRIPTION_DOCUMENT_TYPE);
if (null != currentNode) {
documentDescription.setDocumentType(currentNode.textValue());
objectNode.remove(DOCUMENT_DESCRIPTION_DOCUMENT_TYPE);
}
// Deserialize documentStatus
currentNode = objectNode.get(DOCUMENT_DESCRIPTION_STATUS);
if (null != currentNode) {
documentDescription.setDocumentStatus(currentNode.textValue());
objectNode.remove(DOCUMENT_DESCRIPTION_STATUS);
}
// Deserialize associatedWithRecordAs
currentNode = objectNode.get(DOCUMENT_DESCRIPTION_ASSOCIATED_WITH_RECORD_AS);
if (null != currentNode) {
documentDescription.setAssociatedWithRecordAs(currentNode.textValue());
objectNode.remove(DOCUMENT_DESCRIPTION_ASSOCIATED_WITH_RECORD_AS);
}
// Deserialize documentNumber
currentNode = objectNode.get(DOCUMENT_DESCRIPTION_DOCUMENT_NUMBER);
if (null != currentNode) {
documentDescription.setDocumentNumber(Integer.valueOf(currentNode.intValue()));
objectNode.remove(DOCUMENT_DESCRIPTION_DOCUMENT_NUMBER);
}
// Deserialize associationDate
currentNode = objectNode.get(DOCUMENT_DESCRIPTION_ASSOCIATION_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateTimeFormat(currentNode.textValue());
documentDescription.setAssociationDate(parsedDate);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The dokumentbeskrivelse you tried to create " + "has a malformed tilknyttetDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
objectNode.remove(DOCUMENT_DESCRIPTION_ASSOCIATION_DATE);
}
// Deserialize associatedBy
currentNode = objectNode.get(DOCUMENT_DESCRIPTION_ASSOCIATED_BY);
if (null != currentNode) {
documentDescription.setAssociatedBy(currentNode.textValue());
objectNode.remove(DOCUMENT_DESCRIPTION_ASSOCIATED_BY);
}
// Deserialize storageLocation
currentNode = objectNode.get(STORAGE_LOCATION);
if (null != currentNode) {
documentDescription.setStorageLocation(currentNode.textValue());
objectNode.remove(STORAGE_LOCATION);
}
// Deserialize general documentDescription properties
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(documentDescription, objectNode);
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The dokumentbeskrivelse you tried to create is malformed. The " + "following fields are not recognised as dokumentbeskrivelse fields[" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return documentDescription;
}
use of nikita.common.model.noark5.v4.metadata.DocumentStatus in project nikita-noark5-core by HiOA-ABI.
the class DocumentStatusController method updateDocumentStatus.
// API - All PUT Requests (CRUD - UPDATE)
// Update a dokumentstatus
// PUT [contextPath][api]/metatdata/dokumentstatus/
@ApiOperation(value = "Updates a DocumentStatus object", notes = "Returns the newly" + " updated DocumentStatus object after it is persisted to the database", response = DocumentStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentStatus.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
@RequestMapping(method = RequestMethod.PUT, value = DOCUMENT_STATUS + SLASH + DOCUMENT_STATUS)
public ResponseEntity<MetadataHateoas> updateDocumentStatus(@RequestBody DocumentStatus documentStatus, HttpServletRequest request) throws NikitaException {
documentStatusService.update(documentStatus);
MetadataHateoas metadataHateoas = new MetadataHateoas(documentStatus);
metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
use of nikita.common.model.noark5.v4.metadata.DocumentStatus in project nikita-noark5-core by HiOA-ABI.
the class DocumentStatusController method getDocumentStatusTemplate.
// Create a suggested documentStatus(like a template) with default values (nothing persisted)
// GET [contextPath][api]/metadata/ny-dokumentstatus
@ApiOperation(value = "Creates a suggested DocumentStatus", response = DocumentStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentStatus codes found", response = DocumentStatus.class), @ApiResponse(code = 404, message = "No DocumentStatus 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 = NEW_DOCUMENT_STATUS)
public ResponseEntity<MetadataHateoas> getDocumentStatusTemplate(HttpServletRequest request) {
DocumentStatus documentStatus = new DocumentStatus();
documentStatus.setCode(TEMPLATE_DOCUMENT_STATUS_CODE);
documentStatus.setDescription(TEMPLATE_DOCUMENT_STATUS_DESCRIPTION);
MetadataHateoas metadataHateoas = new MetadataHateoas(documentStatus);
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
use of nikita.common.model.noark5.v4.metadata.DocumentStatus in project nikita-noark5-core by HiOA-ABI.
the class DocumentStatusController method findAll.
// API - All GET Requests (CRUD - READ)
// Retrieves all documentStatus
// GET [contextPath][api]/metadata/dokumentstatus/
@ApiOperation(value = "Retrieves all DocumentStatus ", response = DocumentStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentStatus codes found", response = DocumentStatus.class), @ApiResponse(code = 404, message = "No DocumentStatus 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 = DOCUMENT_STATUS)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) documentStatusService.findAll(), DOCUMENT_STATUS);
metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
use of nikita.common.model.noark5.v4.metadata.DocumentStatus in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionDeserializer method deserialize.
@Override
public DocumentDescription deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
DocumentDescription documentDescription = new DocumentDescription();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general record properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(documentDescription, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(documentDescription, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkTitleDescriptionEntity(documentDescription, objectNode, errors);
// Deserialize documentType
JsonNode currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_DESCRIPTION_DOCUMENT_TYPE);
if (null != currentNode) {
documentDescription.setDocumentType(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_DESCRIPTION_DOCUMENT_TYPE);
}
// Deserialize documentStatus
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_DESCRIPTION_STATUS);
if (null != currentNode) {
documentDescription.setDocumentStatus(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_DESCRIPTION_STATUS);
}
// Deserialize associatedWithRecordAs
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_DESCRIPTION_ASSOCIATED_WITH_RECORD_AS);
if (null != currentNode) {
documentDescription.setAssociatedWithRecordAs(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_DESCRIPTION_ASSOCIATED_WITH_RECORD_AS);
}
// Deserialize documentNumber
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_DESCRIPTION_DOCUMENT_NUMBER);
if (null != currentNode) {
documentDescription.setDocumentNumber(Integer.valueOf(currentNode.intValue()));
objectNode.remove(N5ResourceMappings.DOCUMENT_DESCRIPTION_DOCUMENT_NUMBER);
}
// Deserialize associationDate
documentDescription.setAssociationDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.DOCUMENT_DESCRIPTION_ASSOCIATION_DATE, objectNode, errors));
// Deserialize associatedBy
currentNode = objectNode.get(N5ResourceMappings.DOCUMENT_DESCRIPTION_ASSOCIATED_BY);
if (null != currentNode) {
documentDescription.setAssociatedBy(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DOCUMENT_DESCRIPTION_ASSOCIATED_BY);
}
// Deserialize storageLocation
currentNode = objectNode.get(N5ResourceMappings.STORAGE_LOCATION);
if (null != currentNode) {
documentDescription.setStorageLocation(currentNode.textValue());
objectNode.remove(N5ResourceMappings.STORAGE_LOCATION);
}
// Deserialize general documentDescription properties
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(documentDescription, objectNode, errors);
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The dokumentbeskrivelse you tried to create is malformed. The " + "following fields are not recognised as dokumentbeskrivelse fields[" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return documentDescription;
}
Aggregations