Search in sources :

Example 1 with IMetadataEntity

use of nikita.model.noark5.v4.interfaces.entities.IMetadataEntity 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 nikita.model.noark5.v4.interfaces.entities.IMetadataEntity)) {
        throw new NikitaException("Internal error when serialising " + noarkSystemIdEntity + " Not castable to nikita.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.util.exceptions.NikitaException) IMetadataEntity(nikita.model.noark5.v4.interfaces.entities.IMetadataEntity)

Aggregations

IMetadataEntity (nikita.model.noark5.v4.interfaces.entities.IMetadataEntity)1 NikitaException (nikita.util.exceptions.NikitaException)1