use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryTypeService method handleUpdate.
/**
* Update a RegistryEntryType identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the format object you wish to update
* @param format The updated format object. Note the values you are
* allowed to change are copied from this object. This
* object is not persisted.
* @return the updated format
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, RegistryEntryType format) {
RegistryEntryType existingRegistryEntryType = getRegistryEntryTypeOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingRegistryEntryType.getCode()) {
existingRegistryEntryType.setCode(existingRegistryEntryType.getCode());
}
if (null != existingRegistryEntryType.getDescription()) {
existingRegistryEntryType.setDescription(existingRegistryEntryType.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingRegistryEntryType.setVersion(version);
MetadataHateoas formatHateoas = new MetadataHateoas(formatRepository.save(existingRegistryEntryType));
metadataHateoasHandler.addLinks(formatHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingRegistryEntryType));
return formatHateoas;
}
use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.
the class RecordDeserializer method deserialize.
@Override
public Record deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
Record record = new Record();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(record, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(record, objectNode);
// Deserialize archivedBy
JsonNode currentNode = objectNode.get(RECORD_ARCHIVED_BY);
if (currentNode != null) {
record.setArchivedBy(currentNode.textValue());
objectNode.remove(RECORD_ARCHIVED_BY);
}
// Deserialize archivedDate
currentNode = objectNode.get(RECORD_ARCHIVED_DATE);
if (currentNode != null) {
try {
Date parsedDate = Deserialize.parseDateTimeFormat(currentNode.textValue());
record.setArchivedDate(parsedDate);
objectNode.remove(RECORD_ARCHIVED_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The registrering you tried to create " + "has a malformed arkivertDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The registrering you tried to create is malformed. The " + "following fields are not recognised as registrering fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return record;
}
use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.
the class SeriesDeserializer method deserialize.
@Override
public Series deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
Series series = new Series();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(series, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(series, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(series, objectNode);
// Deserialize seriesStatus
JsonNode currentNode = objectNode.get(SERIES_STATUS);
if (null != currentNode) {
series.setSeriesStatus(currentNode.textValue());
objectNode.remove(SERIES_STATUS);
}
// Deserialize seriesStartDate
currentNode = objectNode.get(SERIES_START_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
series.setSeriesStartDate(parsedDate);
objectNode.remove(SERIES_START_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The arkivdel you tried to create " + "has a malformed arkivperiodeStartDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize seriesEndDate
currentNode = objectNode.get(SERIES_END_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
series.setSeriesEndDate(parsedDate);
objectNode.remove(SERIES_END_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The arkivdel you tried to create " + "has a malformed arkivperiodeSluttDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize referencePrecursor
currentNode = objectNode.get(SERIES_PRECURSOR);
if (null != currentNode) {
Series seriesPrecursor = new Series();
seriesPrecursor.setSystemId(currentNode.textValue());
series.setReferencePrecursor(seriesPrecursor);
// TODO: Does this imply that the current arkivdel is the successor?
// I would not set it here, as the service class has to check that
// the seriesPrecursor object actually exists
objectNode.remove(SERIES_PRECURSOR);
}
// Deserialize referenceSuccessor
currentNode = objectNode.get(SERIES_SUCCESSOR);
if (null != currentNode) {
Series seriesSuccessor = new Series();
seriesSuccessor.setSystemId(currentNode.textValue());
series.setReferenceSuccessor(seriesSuccessor);
// TODO: Does this imply that the current arkivdel is the precursor?
// I would not set it here, as the service class should do this
objectNode.remove(SERIES_SUCCESSOR);
}
series.setReferenceDisposal(CommonUtils.Hateoas.Deserialize.deserialiseDisposal(objectNode));
series.setReferenceDisposalUndertaken(CommonUtils.Hateoas.Deserialize.deserialiseDisposalUndertaken(objectNode));
series.setReferenceDeletion(CommonUtils.Hateoas.Deserialize.deserialiseDeletion(objectNode));
series.setReferenceScreening(CommonUtils.Hateoas.Deserialize.deserialiseScreening(objectNode));
series.setReferenceClassified(CommonUtils.Hateoas.Deserialize.deserialiseClassified(objectNode));
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The arkivdel you tried to create is malformed. The " + "following fields are not recognised as arkivdel fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return series;
}
use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryDeserializer method deserialize.
@Override
public RegistryEntry deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
RegistryEntry registryEntry = new RegistryEntry();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general record properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(registryEntry, objectNode);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(registryEntry, objectNode);
// Deserialize archivedBy
JsonNode currentNode = objectNode.get(RECORD_ARCHIVED_BY);
if (null != currentNode) {
registryEntry.setArchivedBy(currentNode.textValue());
objectNode.remove(RECORD_ARCHIVED_BY);
}
// Deserialize archivedDate
currentNode = objectNode.get(RECORD_ARCHIVED_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateTimeFormat(currentNode.textValue());
registryEntry.setArchivedDate(parsedDate);
objectNode.remove(RECORD_ARCHIVED_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The journalpost object you tried to create " + "has a malformed arkivertDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize general basicRecord properties
// Deserialize recordId
currentNode = objectNode.get(BASIC_RECORD_ID);
if (null != currentNode) {
registryEntry.setRecordId(currentNode.textValue());
objectNode.remove(BASIC_RECORD_ID);
}
// Deserialize title (not using utils to preserve order)
currentNode = objectNode.get(TITLE);
if (null != currentNode) {
registryEntry.setTitle(currentNode.textValue());
objectNode.remove(TITLE);
}
// Deserialize officialTitle
currentNode = objectNode.get(FILE_PUBLIC_TITLE);
if (null != currentNode) {
registryEntry.setOfficialTitle(currentNode.textValue());
objectNode.remove(FILE_PUBLIC_TITLE);
}
// Deserialize description
currentNode = objectNode.get(DESCRIPTION);
if (null != currentNode) {
registryEntry.setDescription(currentNode.textValue());
objectNode.remove(DESCRIPTION);
}
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(registryEntry, objectNode);
// Deserialize general registryEntry properties
// Deserialize recordYear
currentNode = objectNode.get(REGISTRY_ENTRY_YEAR);
if (null != currentNode) {
registryEntry.setRecordYear(Integer.valueOf(currentNode.intValue()));
objectNode.remove(REGISTRY_ENTRY_YEAR);
}
// Deserialize recordSequenceNumber
currentNode = objectNode.get(REGISTRY_ENTRY_SEQUENCE_NUMBER);
if (null != currentNode) {
registryEntry.setRecordSequenceNumber(Integer.valueOf(currentNode.intValue()));
objectNode.remove(REGISTRY_ENTRY_SEQUENCE_NUMBER);
}
// Deserialize registryEntryNumber
currentNode = objectNode.get(REGISTRY_ENTRY_NUMBER);
if (null != currentNode) {
registryEntry.setRegistryEntryNumber(Integer.valueOf(currentNode.intValue()));
objectNode.remove(REGISTRY_ENTRY_NUMBER);
}
// Deserialize registryEntryType
currentNode = objectNode.get(REGISTRY_ENTRY_TYPE);
if (null != currentNode) {
registryEntry.setRegistryEntryType(currentNode.textValue());
objectNode.remove(REGISTRY_ENTRY_TYPE);
}
// Deserialize recordStatus
currentNode = objectNode.get(REGISTRY_ENTRY_STATUS);
if (null != currentNode) {
registryEntry.setRecordStatus(currentNode.textValue());
objectNode.remove(REGISTRY_ENTRY_STATUS);
}
// Deserialize recordDate
currentNode = objectNode.get(REGISTRY_ENTRY_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
registryEntry.setRecordDate(parsedDate);
objectNode.remove(REGISTRY_ENTRY_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The journalpost you tried to create " + "has a malformed journaldato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize documentDate
currentNode = objectNode.get(REGISTRY_ENTRY_DOCUMENT_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
registryEntry.setDocumentDate(parsedDate);
objectNode.remove(REGISTRY_ENTRY_DOCUMENT_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The journalpost you tried to create " + "has a malformed dokumentetsDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize receivedDate
currentNode = objectNode.get(REGISTRY_ENTRY_RECEIVED_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
registryEntry.setReceivedDate(parsedDate);
objectNode.remove(REGISTRY_ENTRY_RECEIVED_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The journalpost you tried to create " + "has a malformed mottattDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize sentDate
currentNode = objectNode.get(REGISTRY_ENTRY_SENT_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
registryEntry.setSentDate(parsedDate);
objectNode.remove(REGISTRY_ENTRY_SENT_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The journalpost you tried to create " + "has a malformed sendtDate. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize dueDate
currentNode = objectNode.get(REGISTRY_ENTRY_DUE_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
registryEntry.setDueDate(parsedDate);
objectNode.remove(REGISTRY_ENTRY_DUE_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The journalpost you tried to create " + "has a malformed forfallsdato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize freedomAssessmentDate
currentNode = objectNode.get(REGISTRY_ENTRY_RECORD_FREEDOM_ASSESSMENT_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
registryEntry.setFreedomAssessmentDate(parsedDate);
objectNode.remove(REGISTRY_ENTRY_RECORD_FREEDOM_ASSESSMENT_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The journalpost you tried to create " + "has a malformed offentlighetsvurdertDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize numberOfAttachments
currentNode = objectNode.get(REGISTRY_ENTRY_NUMBER_OF_ATTACHMENTS);
if (null != currentNode) {
registryEntry.setNumberOfAttachments(Integer.valueOf(currentNode.intValue()));
objectNode.remove(REGISTRY_ENTRY_NUMBER_OF_ATTACHMENTS);
}
// Deserialize loanedDate
currentNode = objectNode.get(CASE_LOANED_DATE);
if (null != currentNode) {
try {
Date parsedDate = Deserialize.parseDateFormat(currentNode.textValue());
registryEntry.setLoanedDate(parsedDate);
objectNode.remove(CASE_LOANED_DATE);
} catch (ParseException e) {
throw new NikitaMalformedInputDataException("The journalpost you tried to create " + "has a malformed utlaantDato. Make sure format is " + NOARK_DATE_FORMAT_PATTERN);
}
}
// Deserialize loanedTo
currentNode = objectNode.get(CASE_LOANED_TO);
if (null != currentNode) {
registryEntry.setLoanedTo(currentNode.textValue());
objectNode.remove(CASE_LOANED_TO);
}
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The journalpost you tried to create is malformed. The " + "following fields are not recognised as journalpost fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return registryEntry;
}
Aggregations