Search in sources :

Example 16 with INikitaEntity

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

the class RegistryEntryHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject registryEntryHateoas, JsonGenerator jgen) throws IOException {
    RegistryEntry registryEntry = (RegistryEntry) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, registryEntry);
    if (registryEntry.getArchivedDate() != null) {
        jgen.writeStringField(RECORD_ARCHIVED_DATE, Serialize.formatDateTime(registryEntry.getArchivedDate()));
    }
    if (registryEntry.getArchivedBy() != null) {
        jgen.writeStringField(RECORD_ARCHIVED_BY, registryEntry.getArchivedBy());
    }
    CommonUtils.Hateoas.Serialize.printDisposal(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printScreening(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printClassified(jgen, registryEntry);
    // handle general registryEntry properties
    if (registryEntry.getTitle() != null) {
        jgen.writeStringField(TITLE, registryEntry.getTitle());
    }
    if (registryEntry.getOfficialTitle() != null) {
        jgen.writeStringField(FILE_PUBLIC_TITLE, registryEntry.getOfficialTitle());
    }
    if (registryEntry.getDescription() != null) {
        jgen.writeStringField(DESCRIPTION, registryEntry.getDescription());
    }
    CommonUtils.Hateoas.Serialize.printKeyword(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printComment(jgen, registryEntry);
    // TODO: FIX THIS CommonCommonUtils.Hateoas.Serialize.printCrossReference(jgen, registryEntry);
    if (registryEntry.getRecordYear() != null) {
        jgen.writeNumberField(REGISTRY_ENTRY_YEAR, registryEntry.getRecordYear().intValue());
    }
    if (registryEntry.getRecordSequenceNumber() != null) {
        jgen.writeNumberField(REGISTRY_ENTRY_SEQUENCE_NUMBER, registryEntry.getRecordSequenceNumber().intValue());
    }
    if (registryEntry.getRegistryEntryNumber() != null) {
        jgen.writeNumberField(REGISTRY_ENTRY_NUMBER, registryEntry.getRegistryEntryNumber().intValue());
    }
    if (registryEntry.getRegistryEntryType() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_TYPE, registryEntry.getRegistryEntryType());
    }
    if (registryEntry.getRecordStatus() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_STATUS, registryEntry.getRecordStatus());
    }
    if (registryEntry.getRecordDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_DATE, Serialize.formatDate(registryEntry.getRecordDate()));
    }
    if (registryEntry.getDocumentDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_DOCUMENT_DATE, Serialize.formatDate(registryEntry.getDocumentDate()));
    }
    if (registryEntry.getReceivedDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_RECEIVED_DATE, Serialize.formatDate(registryEntry.getReceivedDate()));
    }
    if (registryEntry.getSentDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_SENT_DATE, Serialize.formatDate(registryEntry.getSentDate()));
    }
    if (registryEntry.getDueDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_DUE_DATE, Serialize.formatDate(registryEntry.getDueDate()));
    }
    if (registryEntry.getFreedomAssessmentDate() != null) {
        jgen.writeStringField(REGISTRY_ENTRY_RECORD_FREEDOM_ASSESSMENT_DATE, Serialize.formatDate(registryEntry.getFreedomAssessmentDate()));
    }
    if (registryEntry.getNumberOfAttachments() != null) {
        jgen.writeNumberField(REGISTRY_ENTRY_NUMBER_OF_ATTACHMENTS, registryEntry.getNumberOfAttachments().intValue());
    }
    if (registryEntry.getLoanedDate() != null) {
        jgen.writeStringField(CASE_LOANED_DATE, Serialize.formatDate(registryEntry.getLoanedDate()));
    }
    if (registryEntry.getLoanedTo() != null) {
        jgen.writeStringField(CASE_LOANED_TO, registryEntry.getLoanedTo());
    }
    CommonUtils.Hateoas.Serialize.printCorrespondenceParts(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printSignOff(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printDocumentFlow(jgen, registryEntry);
    //CommonUtils.Hateoas.Serialize.printPrecedence(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printElectronicSignature(jgen, registryEntry);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, registryEntryHateoas.getLinks(registryEntry));
    jgen.writeEndObject();
}
Also used : RegistryEntry(nikita.model.noark5.v4.casehandling.RegistryEntry)

Example 17 with INikitaEntity

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

the class PrecedenceHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject precedenceHateoas, JsonGenerator jgen) throws IOException {
    Precedence precedence = (Precedence) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printPrecedence(jgen, precedence);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, precedenceHateoas.getLinks(precedence));
    jgen.writeEndObject();
}
Also used : Precedence(nikita.model.noark5.v4.casehandling.Precedence)

Example 18 with INikitaEntity

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

the class HateoasHandler method addSelfLink.

@Override
public void addSelfLink(INikitaEntity entity, IHateoasNoarkObject hateoasNoarkObject) {
    String systemId = entity.getSystemId();
    hateoasNoarkObject.addLink(entity, new Link(contextPath + HATEOAS_API_PATH + SLASH + entity.getFunctionalTypeName() + SLASH + entity.getBaseTypeName() + SLASH + systemId + SLASH, getRelSelfLink(), false));
}
Also used : Link(nikita.model.noark5.v4.hateoas.Link)

Example 19 with INikitaEntity

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

the class HateoasHandler method addLinksOnTemplate.

@Override
public void addLinksOnTemplate(IHateoasNoarkObject hateoasNoarkObject, HttpServletRequest request, IAuthorisation authorisation) {
    setParameters(request);
    this.authorisation = authorisation;
    Iterable<INikitaEntity> entities = hateoasNoarkObject.getList();
    for (INikitaEntity entity : entities) {
        addEntityLinksOnTemplate(entity, hateoasNoarkObject);
    }
}
Also used : INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity)

Example 20 with INikitaEntity

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

the class HateoasHandler method addLinks.

@Override
public void addLinks(IHateoasNoarkObject hateoasNoarkObject, HttpServletRequest request, IAuthorisation authorisation) {
    setParameters(request);
    this.authorisation = authorisation;
    Iterable<INikitaEntity> entities = hateoasNoarkObject.getList();
    for (INikitaEntity entity : entities) {
        addSelfLink(entity, hateoasNoarkObject);
        addEntityLinks(entity, hateoasNoarkObject);
    }
    // { "entity": [], "_links": [] }
    if (!hateoasNoarkObject.isSingleEntity()) {
        StringBuffer url = request.getRequestURL();
        Link selfLink = new Link(url.toString(), getRelSelfLink(), false);
        hateoasNoarkObject.addSelfLink(selfLink);
    }
}
Also used : INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Link(nikita.model.noark5.v4.hateoas.Link)

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