use of nikita.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryService method createDocumentDescriptionAssociatedWithRegistryEntry.
/*
TODO: Temp disabled!
private void associateCorrespondencePartTypeWithCorrespondencePart(@NotNull CorrespondencePart correspondencePart) {
CorrespondencePartType incomingCorrespondencePartType = correspondencePart.getCorrespondencePartType();
// It should never get this far with a null value
// It should be rejected at controller level
// The incoming CorrespondencePartType will not have @id field set. Therefore, we have to look it up
// in the database and make sure the proper CorrespondencePartType is associated with the CorrespondencePart
if (incomingCorrespondencePartType != null && incomingCorrespondencePartType.getCode() != null) {
CorrespondencePartType actualCorrespondencePartType =
correspondencePartTypeRepository.findByCode(incomingCorrespondencePartType.getCode());
if (actualCorrespondencePartType != null) {
correspondencePart.setCorrespondencePartType(actualCorrespondencePartType);
}
}
}
TODO: Temp disabled!
@Override
public List<CorrespondencePartPerson> getCorrespondencePartPersonAssociatedWithRegistryEntry(String systemID) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
return registryEntry.getReferenceCorrespondencePartPerson();
}
@Override
public List<CorrespondencePartInternal> getCorrespondencePartInternalAssociatedWithRegistryEntry(String systemID) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
return registryEntry.getReferenceCorrespondencePartInternal();
}
@Override
public List<CorrespondencePartUnit> getCorrespondencePartUnitAssociatedWithRegistryEntry(String systemID) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
return registryEntry.getReferenceCorrespondencePartUnit();
}
*/
/* @Override
public CorrespondencePartPerson createCorrespondencePartPersonAssociatedWithRegistryEntry(
String systemID, CorrespondencePartPerson correspondencePart) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
TODO: Temp disabled!
associateCorrespondencePartTypeWithCorrespondencePart(correspondencePart);
ContactInformation contactInformation = correspondencePart.getContactInformation();
if (null != contactInformation) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(contactInformation);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(contactInformation);
}
SimpleAddress postalAddress = correspondencePart.getPostalAddress();
if (null != postalAddress) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(postalAddress);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(postalAddress);
}
SimpleAddress residingAddress = correspondencePart.getResidingAddress();
if (null != residingAddress) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(residingAddress);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(residingAddress);
}
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(correspondencePart);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(correspondencePart);
// bidirectional relationship @ManyToMany, set both sides of relationship
registryEntry.getReferenceCorrespondencePartPerson().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartPerson(correspondencePart);
return null;
}
*/
/*
TODO: Temp disabled!
@Override
public CorrespondencePartInternal createCorrespondencePartInternalAssociatedWithRegistryEntry(
String systemID, CorrespondencePartInternal correspondencePart) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(correspondencePart);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(correspondencePart);
// bidirectional relationship @ManyToMany, set both sides of relationship
registryEntry.getReferenceCorrespondencePartInternal().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartInternal(correspondencePart);
}
@Override
public CorrespondencePartUnit createCorrespondencePartUnitAssociatedWithRegistryEntry(
String systemID, CorrespondencePartUnit correspondencePart) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
associateCorrespondencePartTypeWithCorrespondencePart(correspondencePart);
ContactInformation contactInformation = correspondencePart.getContactInformation();
if (null != contactInformation) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(contactInformation);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(contactInformation);
}
SimpleAddress postalAddress = correspondencePart.getPostalAddress();
if (null != postalAddress) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(postalAddress);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(postalAddress);
}
SimpleAddress businessAddress = correspondencePart.getBusinessAddress();
if (null != businessAddress) {
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(businessAddress);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(businessAddress);
}
NoarkUtils.NoarkEntity.Create.setNikitaEntityValues(correspondencePart);
NoarkUtils.NoarkEntity.Create.setSystemIdEntityValues(correspondencePart);
// bidirectional relationship @ManyToMany, set both sides of relationship
registryEntry.getReferenceCorrespondencePartUnit().add(correspondencePart);
correspondencePart.getReferenceRegistryEntry().add(registryEntry);
return correspondencePartService.createNewCorrespondencePartUnit(correspondencePart);
}
*/
@Override
public DocumentDescription createDocumentDescriptionAssociatedWithRegistryEntry(String systemID, DocumentDescription documentDescription) {
RegistryEntry registryEntry = getRegistryEntryOrThrow(systemID);
ArrayList<Record> records = (ArrayList<Record>) documentDescription.getReferenceRecord();
// It should always be instaniated ... check this ...
if (records == null) {
records = new ArrayList<>();
documentDescription.setReferenceRecord(records);
}
records.add(registryEntry);
return documentDescriptionService.save(documentDescription);
}
use of nikita.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.
the class BasicRecordDeserializer method deserialize.
@Override
public BasicRecord deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
BasicRecord basicRecord = new BasicRecord();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general record properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(basicRecord, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(basicRecord, objectNode, errors);
// Deserialize archivedBy
JsonNode currentNode = objectNode.get(N5ResourceMappings.RECORD_ARCHIVED_BY);
if (null != currentNode) {
basicRecord.setArchivedBy(currentNode.textValue());
objectNode.remove(N5ResourceMappings.RECORD_ARCHIVED_BY);
}
// Deserialize archivedDate
basicRecord.setArchivedDate(CommonUtils.Hateoas.Deserialize.deserializeDateTime(N5ResourceMappings.RECORD_ARCHIVED_DATE, objectNode, errors));
// Deserialize general basicRecord properties
// Deserialize recordId
currentNode = objectNode.get(N5ResourceMappings.BASIC_RECORD_ID);
if (null != currentNode) {
basicRecord.setRecordId(currentNode.textValue());
objectNode.remove(N5ResourceMappings.BASIC_RECORD_ID);
}
// Deserialize title (not using utils to preserve order)
currentNode = objectNode.get(N5ResourceMappings.TITLE);
if (null != currentNode) {
basicRecord.setTitle(currentNode.textValue());
objectNode.remove(N5ResourceMappings.TITLE);
}
// Deserialize officialTitle
currentNode = objectNode.get(N5ResourceMappings.FILE_PUBLIC_TITLE);
if (null != currentNode) {
basicRecord.setOfficialTitle(currentNode.textValue());
objectNode.remove(N5ResourceMappings.FILE_PUBLIC_TITLE);
}
// Deserialize description
currentNode = objectNode.get(N5ResourceMappings.DESCRIPTION);
if (null != currentNode) {
basicRecord.setDescription(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DESCRIPTION);
}
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(basicRecord, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseAuthor(basicRecord, objectNode, errors);
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The basisregistrering you tried to create is malformed. The " + "following fields are not recognised as basisregistrering fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return basicRecord;
}
use of nikita.model.noark5.v4.Record 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;
}
use of nikita.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordDeserializer method deserialize.
@Override
public Record deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
Record record = new Record();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(record, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(record, objectNode, errors);
// Deserialize archivedBy
JsonNode currentNode = objectNode.get(N5ResourceMappings.RECORD_ARCHIVED_BY);
if (currentNode != null) {
record.setArchivedBy(currentNode.textValue());
objectNode.remove(N5ResourceMappings.RECORD_ARCHIVED_BY);
}
// Deserialize archivedDate
record.setArchivedDate(CommonUtils.Hateoas.Deserialize.deserializeDateTime(N5ResourceMappings.RECORD_ARCHIVED_DATE, objectNode, errors));
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The registrering you tried to create is malformed. The " + "following fields are not recognised as registrering fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return record;
}
use of nikita.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryDeserializer method deserialize.
@Override
public RegistryEntry deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
StringBuilder errors = new StringBuilder();
RegistryEntry registryEntry = new RegistryEntry();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general record properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkSystemIdEntity(registryEntry, objectNode, errors);
CommonUtils.Hateoas.Deserialize.deserialiseNoarkCreateEntity(registryEntry, objectNode, errors);
// Deserialize archivedBy
JsonNode currentNode = objectNode.get(N5ResourceMappings.RECORD_ARCHIVED_BY);
if (null != currentNode) {
registryEntry.setArchivedBy(currentNode.textValue());
objectNode.remove(N5ResourceMappings.RECORD_ARCHIVED_BY);
}
// Deserialize archivedDate
registryEntry.setArchivedDate(CommonUtils.Hateoas.Deserialize.deserializeDateTime(N5ResourceMappings.RECORD_ARCHIVED_DATE, objectNode, errors));
// Deserialize general basicRecord properties
// Deserialize recordId
currentNode = objectNode.get(N5ResourceMappings.BASIC_RECORD_ID);
if (null != currentNode) {
registryEntry.setRecordId(currentNode.textValue());
objectNode.remove(N5ResourceMappings.BASIC_RECORD_ID);
}
// Deserialize title (not using utils to preserve order)
currentNode = objectNode.get(N5ResourceMappings.TITLE);
if (null != currentNode) {
registryEntry.setTitle(currentNode.textValue());
objectNode.remove(N5ResourceMappings.TITLE);
}
// Deserialize officialTitle
currentNode = objectNode.get(N5ResourceMappings.FILE_PUBLIC_TITLE);
if (null != currentNode) {
registryEntry.setOfficialTitle(currentNode.textValue());
objectNode.remove(N5ResourceMappings.FILE_PUBLIC_TITLE);
}
// Deserialize description
currentNode = objectNode.get(N5ResourceMappings.DESCRIPTION);
if (null != currentNode) {
registryEntry.setDescription(currentNode.textValue());
objectNode.remove(N5ResourceMappings.DESCRIPTION);
}
CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(registryEntry, objectNode, errors);
// Deserialize general registryEntry properties
// Deserialize recordYear
currentNode = objectNode.get(N5ResourceMappings.REGISTRY_ENTRY_YEAR);
if (null != currentNode) {
registryEntry.setRecordYear(Integer.valueOf(currentNode.intValue()));
objectNode.remove(N5ResourceMappings.REGISTRY_ENTRY_YEAR);
}
// Deserialize recordSequenceNumber
currentNode = objectNode.get(N5ResourceMappings.REGISTRY_ENTRY_SEQUENCE_NUMBER);
if (null != currentNode) {
registryEntry.setRecordSequenceNumber(Integer.valueOf(currentNode.intValue()));
objectNode.remove(N5ResourceMappings.REGISTRY_ENTRY_SEQUENCE_NUMBER);
}
// Deserialize registryEntryNumber
currentNode = objectNode.get(N5ResourceMappings.REGISTRY_ENTRY_NUMBER);
if (null != currentNode) {
registryEntry.setRegistryEntryNumber(Integer.valueOf(currentNode.intValue()));
objectNode.remove(N5ResourceMappings.REGISTRY_ENTRY_NUMBER);
}
// Deserialize registryEntryType
currentNode = objectNode.get(N5ResourceMappings.REGISTRY_ENTRY_TYPE);
if (null != currentNode) {
registryEntry.setRegistryEntryType(currentNode.textValue());
objectNode.remove(N5ResourceMappings.REGISTRY_ENTRY_TYPE);
} else {
errors.append("The journalpost you tried to create is missing journalposttype. ");
}
// Deserialize recordStatus
currentNode = objectNode.get(N5ResourceMappings.REGISTRY_ENTRY_STATUS);
if (null != currentNode) {
registryEntry.setRecordStatus(currentNode.textValue());
objectNode.remove(N5ResourceMappings.REGISTRY_ENTRY_STATUS);
} else {
errors.append("The journalpost you tried to create is missing journalstatus. ");
}
// Deserialize recordDate
registryEntry.setRecordDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.REGISTRY_ENTRY_DATE, objectNode, errors, true));
// Deserialize documentDate
registryEntry.setDocumentDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.REGISTRY_ENTRY_DOCUMENT_DATE, objectNode, errors));
// Deserialize receivedDate
registryEntry.setReceivedDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.REGISTRY_ENTRY_RECEIVED_DATE, objectNode, errors));
// Deserialize sentDate
registryEntry.setSentDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.REGISTRY_ENTRY_SENT_DATE, objectNode, errors));
// Deserialize dueDate
registryEntry.setDueDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.REGISTRY_ENTRY_DUE_DATE, objectNode, errors));
// Deserialize freedomAssessmentDate
registryEntry.setFreedomAssessmentDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.REGISTRY_ENTRY_RECORD_FREEDOM_ASSESSMENT_DATE, objectNode, errors));
// Deserialize numberOfAttachments
currentNode = objectNode.get(N5ResourceMappings.REGISTRY_ENTRY_NUMBER_OF_ATTACHMENTS);
if (null != currentNode) {
registryEntry.setNumberOfAttachments(Integer.valueOf(currentNode.intValue()));
objectNode.remove(N5ResourceMappings.REGISTRY_ENTRY_NUMBER_OF_ATTACHMENTS);
}
// Deserialize loanedDate
registryEntry.setLoanedDate(CommonUtils.Hateoas.Deserialize.deserializeDate(N5ResourceMappings.CASE_LOANED_DATE, objectNode, errors));
// Deserialize loanedTo
currentNode = objectNode.get(N5ResourceMappings.CASE_LOANED_TO);
if (null != currentNode) {
registryEntry.setLoanedTo(currentNode.textValue());
objectNode.remove(N5ResourceMappings.CASE_LOANED_TO);
}
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
errors.append("The journalpost you tried to create is malformed. The " + "following fields are not recognised as journalpost fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
}
if (0 < errors.length())
throw new NikitaMalformedInputDataException(errors.toString());
return registryEntry;
}
Aggregations