Search in sources :

Example 76 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class DocumentObjectHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject documentObjectHateoas, JsonGenerator jgen) throws IOException {
    DocumentObject documentObject = (DocumentObject) noarkSystemIdEntity;
    jgen.writeStartObject();
    // handle DocumentObject properties
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, documentObject);
    if (documentObject.getVersionNumber() != null) {
        jgen.writeNumberField(DOCUMENT_OBJECT_VERSION_NUMBER, documentObject.getVersionNumber().intValue());
    }
    if (documentObject.getVariantFormat() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_VARIANT_FORMAT, documentObject.getVariantFormat());
    }
    if (documentObject.getFormat() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_FORMAT, documentObject.getFormat());
    }
    if (documentObject.getFormatDetails() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_FORMAT_DETAILS, documentObject.getFormatDetails());
    }
    CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, documentObject);
    if (documentObject.getReferenceDocumentFile() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_REFERENCE_DOCUMENT_FILE, documentObject.getReferenceDocumentFile());
    }
    if (documentObject.getChecksum() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_CHECKSUM, documentObject.getChecksum());
    }
    if (documentObject.getChecksumAlgorithm() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_CHECKSUM_ALGORITHM, documentObject.getChecksumAlgorithm());
    }
    if (documentObject.getFileSize() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_FILE_SIZE, Long.toString(documentObject.getFileSize()));
    }
    if (documentObject.getOriginalFilename() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_FILE_NAME, documentObject.getOriginalFilename());
    }
    if (documentObject.getMimeType() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_MIME_TYPE, documentObject.getMimeType());
    }
    CommonUtils.Hateoas.Serialize.printElectronicSignature(jgen, documentObject);
    CommonUtils.Hateoas.Serialize.printConversion(jgen, documentObject);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, documentObjectHateoas.getLinks(documentObject));
    jgen.writeEndObject();
}
Also used : DocumentObject(nikita.model.noark5.v4.DocumentObject)

Example 77 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class FondsCreatorHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject fondsCreatorHateoas, JsonGenerator jgen) throws IOException {
    FondsCreator fondsCreator = (FondsCreator) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printFondsCreator(jgen, fondsCreator);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, fondsCreatorHateoas.getLinks(fondsCreator));
    jgen.writeEndObject();
}
Also used : FondsCreator(nikita.model.noark5.v4.FondsCreator)

Example 78 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity 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();
}
Also used : Fonds(nikita.model.noark5.v4.Fonds)

Example 79 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity 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();
    }
}
Also used : INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity)

Example 80 with INikitaEntity

use of nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity 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();
}
Also used : AdministrativeUnit(nikita.model.noark5.v4.admin.AdministrativeUnit)

Aggregations

INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)80 Authorisation (nikita.webapp.security.Authorisation)78 List (java.util.List)77 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)54 Counted (com.codahale.metrics.annotation.Counted)40 ApiOperation (io.swagger.annotations.ApiOperation)34 ApiResponses (io.swagger.annotations.ApiResponses)34 ArrayList (java.util.ArrayList)20 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)19 Timed (com.codahale.metrics.annotation.Timed)16 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)16 Fonds (nikita.common.model.noark5.v4.Fonds)6 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)5 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)4 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)3 Record (nikita.common.model.noark5.v4.Record)3 Fonds (nikita.model.noark5.v4.Fonds)3 FondsCreator (nikita.common.model.noark5.v4.FondsCreator)2 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)2 DocumentObjectHateoas (nikita.common.model.noark5.v4.hateoas.DocumentObjectHateoas)2