Search in sources :

Example 26 with HateoasNoarkObject

use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartInternalHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject correspondencePartHateoas, JsonGenerator jgen) throws IOException {
    CorrespondencePartInternal correspondencePart = (CorrespondencePartInternal) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printCorrespondencePartInternal(jgen, correspondencePart);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, correspondencePartHateoas.getLinks(correspondencePart));
    jgen.writeEndObject();
}
Also used : CorrespondencePartInternal(nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)

Example 27 with HateoasNoarkObject

use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartUnitHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject correspondencePartHateoas, JsonGenerator jgen) throws IOException {
    CorrespondencePartUnit correspondencePart = (CorrespondencePartUnit) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printCorrespondencePartUnit(jgen, correspondencePart);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, correspondencePartHateoas.getLinks(correspondencePart));
    jgen.writeEndObject();
}
Also used : CorrespondencePartUnit(nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit)

Example 28 with HateoasNoarkObject

use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject 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());
    }
    /*
        TODO: Temp disabled!
        CommonUtils.Hateoas.Serialize.printCorrespondencePartPersons(jgen, registryEntry);
        CommonUtils.Hateoas.Serialize.printCorrespondencePartUnits(jgen, registryEntry);
        CommonUtils.Hateoas.Serialize.printCorrespondencePartInternals(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.common.model.noark5.v4.casehandling.RegistryEntry)

Example 29 with HateoasNoarkObject

use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.

the class MetadataHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject metadataHateoas, JsonGenerator jgen) throws IOException {
    if (!(noarkSystemIdEntity instanceof IMetadataEntity)) {
        throw new NikitaException("Internal error when serialising " + noarkSystemIdEntity + " Not castable to nikita.common.model.noark5.v4.interfaces.entities.IMetadataEntity");
    }
    IMetadataEntity metadataEntity = (IMetadataEntity) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, metadataEntity);
    if (metadataEntity.getCode() != null) {
        jgen.writeStringField(CODE, metadataEntity.getCode());
    }
    if (metadataEntity.getDescription() != null) {
        jgen.writeStringField(DESCRIPTION, metadataEntity.getDescription());
    }
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, metadataHateoas.getLinks(metadataEntity));
    jgen.writeEndObject();
}
Also used : NikitaException(nikita.common.util.exceptions.NikitaException) IMetadataEntity(nikita.common.model.noark5.v4.interfaces.entities.IMetadataEntity)

Example 30 with HateoasNoarkObject

use of nikita.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.

the class FondsIT method test_2_createFonds.

@Test
public void test_2_createFonds() throws JsonProcessingException {
    assertTrue(checkLoggedIn());
    assertNotNull(headers);
    assertNotNull(headers.get("Authorization"));
    Fonds fonds = new Fonds();
    fonds.setDescription("description");
    fonds.setTitle("title");
    String serializedFonds = mapper.writeValueAsString(fonds);
    HttpEntity<String> request = new HttpEntity<>(serializedFonds, headers);
    ResponseEntity<HateoasNoarkObject> responseEntity = restTemplate.exchange("/hateoas-api/arkivstruktur/ny-arkiv", HttpMethod.POST, request, HateoasNoarkObject.class);
    assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode());
    HateoasNoarkObject result = responseEntity.getBody();
    ArrayList<INikitaEntity> entities = (ArrayList<INikitaEntity>) result.getList();
    assertNotNull(entities);
    assertEquals(entities.size(), 1);
    INoarkGeneralEntity returnedFonds = (INoarkGeneralEntity) entities.get(0);
    assertEquals("description", returnedFonds.getDescription());
    assertEquals("title", returnedFonds.getTitle());
}
Also used : INoarkGeneralEntity(nikita.common.model.noark5.v4.interfaces.entities.INoarkGeneralEntity) HateoasNoarkObject(nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject) INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) ArrayList(java.util.ArrayList) Fonds(nikita.common.model.noark5.v4.Fonds) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)12 ApiOperation (io.swagger.annotations.ApiOperation)12 ApiResponses (io.swagger.annotations.ApiResponses)12 Timed (com.codahale.metrics.annotation.Timed)6 NikitaException (nikita.common.util.exceptions.NikitaException)6 NikitaException (nikita.util.exceptions.NikitaException)6 AfterNoarkEntityDeletedEvent (nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)6 AfterNoarkEntityDeletedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)6 Class (nikita.common.model.noark5.v4.Class)5 HateoasNoarkObject (nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject)5 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)5 Class (nikita.model.noark5.v4.Class)5 Authorisation (nikita.webapp.security.Authorisation)5 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)5 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)4 NoarkEntity (nikita.common.model.noark5.v4.NoarkEntity)3 Record (nikita.common.model.noark5.v4.Record)3 NoarkEntity (nikita.model.noark5.v4.NoarkEntity)3 Record (nikita.model.noark5.v4.Record)3 HateoasNoarkObject (nikita.model.noark5.v4.hateoas.HateoasNoarkObject)3