Search in sources :

Example 6 with ClassificationType

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

the class ClassificationTypeService method findByCode.

/**
 * retrieve all ClassificationType 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 ClassificationType objects wrapped as a MetadataHateoas
 * object
 */
@Override
public MetadataHateoas findByCode(String code) {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) classificationTypeRepository.findByCode(code), CLASSIFICATION_TYPE);
    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 7 with ClassificationType

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

the class ClassificationTypeService method getClassificationTypeOrThrow.

/**
 * 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 ClassificationType object back. If
 * there is no ClassificationType object, a NoarkEntityNotFoundException
 * exception is thrown
 *
 * @param systemId The systemId of the ClassificationType object to retrieve
 * @return the ClassificationType object
 */
private ClassificationType getClassificationTypeOrThrow(@NotNull String systemId) {
    ClassificationType classificationType = classificationTypeRepository.findBySystemId(systemId);
    if (classificationType == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " ClassificationType, using " + "systemId " + systemId;
        logger.error(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return classificationType;
}
Also used : NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) ClassificationType(nikita.common.model.noark5.v4.metadata.ClassificationType)

Example 8 with ClassificationType

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

the class ClassificationTypeService method findAll.

// All READ operations
/**
 * Retrieve a list of all ClassificationType objects
 *
 * @return list of ClassificationType objects wrapped as a
 * MetadataHateoas object
 */
@Override
public MetadataHateoas findAll() {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) classificationTypeRepository.findAll(), CLASSIFICATION_TYPE);
    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

MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)6 Authorisation (nikita.webapp.security.Authorisation)6 List (java.util.List)3 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)3 ClassificationType (nikita.common.model.noark5.v4.metadata.ClassificationType)3 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)1 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)1