Search in sources :

Example 11 with Format

use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.

the class FormatService method findAll.

// All READ operations
/**
 * Retrieve a list of all Format objects
 *
 * @return list of Format objects wrapped as a
 * MetadataHateoas object
 */
@Override
public MetadataHateoas findAll() {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) formatRepository.findAll(), FORMAT);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return metadataHateoas;
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)

Example 12 with Format

use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.

the class FormatService method getFormatOrThrow.

/**
 * Internal helper method. Rather than having a find and try catch in
 * multiple methods, we have it here once. If you call this, be aware
 * that you will only ever get a valid Format object back. If there is no
 * Format object, a NoarkEntityNotFoundException exception is thrown
 *
 * @param systemId The systemId of the Format object to retrieve
 * @return the Format object
 */
private Format getFormatOrThrow(@NotNull String systemId) {
    Format format = formatRepository.findBySystemId(systemId);
    if (format == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " Format, using systemId " + systemId;
        logger.error(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return format;
}
Also used : Format(nikita.common.model.noark5.v4.metadata.Format) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 13 with Format

use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.

the class FormatService method generateDefaultFormat.

/**
 * Generate a default Format object
 *
 * @return the Format object wrapped as a FormatHateoas object
 */
@Override
public Format generateDefaultFormat() {
    Format format = new Format();
    format.setCode(TEMPLATE_FORMAT_CODE);
    format.setDescription(TEMPLATE_FORMAT_DESCRIPTION);
    return format;
}
Also used : Format(nikita.common.model.noark5.v4.metadata.Format)

Example 14 with Format

use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.

the class FormatService method findByDescription.

/**
 * Retrieve all Format that have a given
 * description.
 * <br>
 * Note, this will be replaced by OData search.
 *
 * @param description Description of object you wish to retrieve. The
 *                    whole text, this is an exact search.
 * @return A list of Format objects wrapped as a MetadataHateoas object
 */
@Override
public MetadataHateoas findByDescription(String description) {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) formatRepository.findByDescription(description), FORMAT);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return metadataHateoas;
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)

Example 15 with Format

use of nikita.common.model.noark5.v4.metadata.Format in project nikita-noark5-core by HiOA-ABI.

the class FormatService method findByCode.

/**
 * retrieve all Format that have a particular code.
 * <br>
 * Note, this will be replaced by OData search.
 *
 * @param code The code of the object you wish to retrieve
 * @return A list of Format objects wrapped as a MetadataHateoas object
 */
@Override
public MetadataHateoas findByCode(String code) {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) formatRepository.findByCode(code), FORMAT);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return metadataHateoas;
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)8 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)7 NikitaMalformedInputDataException (nikita.util.exceptions.NikitaMalformedInputDataException)7 Authorisation (nikita.webapp.security.Authorisation)7 ParseException (java.text.ParseException)6 Date (java.util.Date)6 List (java.util.List)3 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)3 Format (nikita.common.model.noark5.v4.metadata.Format)3 RegistryEntryType (nikita.common.model.noark5.v4.metadata.RegistryEntryType)3 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)2 Series (nikita.model.noark5.v4.Series)2 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)2 DocumentObject (nikita.common.model.noark5.v4.DocumentObject)1 NikitaMalformedInputDataException (nikita.common.util.exceptions.NikitaMalformedInputDataException)1 BasicRecord (nikita.model.noark5.v4.BasicRecord)1 DocumentDescription (nikita.model.noark5.v4.DocumentDescription)1 DocumentObject (nikita.model.noark5.v4.DocumentObject)1 Record (nikita.model.noark5.v4.Record)1