use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.
the class FondsHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject fondsHateoas, JsonGenerator jgen) throws IOException {
Fonds fonds = (Fonds) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, fonds);
CommonUtils.Hateoas.Serialize.printTitleAndDescription(jgen, fonds);
if (fonds.getFondsStatus() != null) {
jgen.writeStringField(FONDS_STATUS, fonds.getFondsStatus());
}
CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, fonds);
CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, fonds);
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, fonds);
CommonUtils.Hateoas.Serialize.printFinaliseEntity(jgen, fonds);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, fondsHateoas.getLinks(fonds));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.
the class HateoasSerializer method serialize.
@Override
public void serialize(HateoasNoarkObject hateoasObject, JsonGenerator jgen, SerializerProvider provider) throws IOException {
// For lists the output should be
// { "entity": [], "_links": [] }
// An empty list should produce
// { "entity": [], "_links": [] }
// An entity should produce
// { "field" : "value", "_links": [] }
// No such thing as an empty entity
List<INikitaEntity> list = hateoasObject.getList();
if (list.size() > 0) {
if (!hateoasObject.isSingleEntity()) {
jgen.writeStartObject();
jgen.writeFieldName(ENTITY_ROOT_NAME_LIST);
jgen.writeStartArray();
}
for (INikitaEntity entity : list) {
serializeNoarkEntity(entity, hateoasObject, jgen);
}
if (!hateoasObject.isSingleEntity()) {
jgen.writeEndArray();
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, hateoasObject.getSelfLinks());
jgen.writeEndObject();
}
} else // It's an empty object, so just returning Hateoas self links
{
jgen.writeStartObject();
jgen.writeFieldName(ENTITY_ROOT_NAME_LIST);
jgen.writeStartArray();
jgen.writeEndArray();
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, hateoasObject.getSelfLinks());
jgen.writeEndObject();
}
}
use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.
the class AdministrativeUnitHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject administrativeUnitHateoas, JsonGenerator jgen) throws IOException {
AdministrativeUnit administrativeUnit = (AdministrativeUnit) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, administrativeUnit);
if (administrativeUnit.getAdministrativeUnitName() != null) {
jgen.writeStringField(ADMINISTRATIVE_UNIT_NAME, administrativeUnit.getAdministrativeUnitName());
}
if (administrativeUnit.getShortName() != null) {
jgen.writeStringField(SHORT_NAME, administrativeUnit.getShortName());
}
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, administrativeUnit);
CommonUtils.Hateoas.Serialize.printFinaliseEntity(jgen, administrativeUnit);
if (administrativeUnit.getAdministrativeUnitStatus() != null) {
jgen.writeStringField(ADMINISTRATIVE_UNIT_STATUS, administrativeUnit.getAdministrativeUnitStatus());
}
if (administrativeUnit.getParentAdministrativeUnit() != null) {
jgen.writeStringField(ADMINISTRATIVE_UNIT_PARENT_REFERENCE, administrativeUnit.getParentAdministrativeUnit().getSystemId());
}
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, administrativeUnitHateoas.getLinks(administrativeUnit));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.
the class UserHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject userHateoas, JsonGenerator jgen) throws IOException {
User user = (User) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, user);
if (user.getUsername() != null) {
jgen.writeStringField(USER_NAME, user.getUsername());
}
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, user);
CommonUtils.Hateoas.Serialize.printFinaliseEntity(jgen, user);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, userHateoas.getLinks(user));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject 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