Search in sources :

Example 1 with ClassificationType

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

the class ClassificationTypeService method generateDefaultClassificationType.

/**
 * Generate a default ClassificationType object
 *
 * @return the ClassificationType object wrapped as a
 * ClassificationTypeHateoas object
 */
@Override
public ClassificationType generateDefaultClassificationType() {
    ClassificationType classificationType = new ClassificationType();
    classificationType.setCode(TEMPLATE_CLASSIFICATION_TYPE_CODE);
    classificationType.setDescription(TEMPLATE_CLASSIFICATION_TYPE_DESCRIPTION);
    return classificationType;
}
Also used : ClassificationType(nikita.common.model.noark5.v4.metadata.ClassificationType)

Example 2 with ClassificationType

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

the class ClassificationTypeService method findByDescription.

/**
 * Retrieve all ClassificationType 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 ClassificationType objects wrapped as a MetadataHateoas
 * object
 */
@Override
public MetadataHateoas findByDescription(String description) {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) classificationTypeRepository.findByDescription(description), 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 3 with ClassificationType

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

the class ClassificationTypeService method createNewClassificationType.

// All CREATE operations
/**
 * Persists a new ClassificationType object to the database.
 *
 * @param classificationType ClassificationType object with values set
 * @return the newly persisted ClassificationType object wrapped as a
 * MetadataHateoas object
 */
@Override
public MetadataHateoas createNewClassificationType(ClassificationType classificationType) {
    classificationType.setDeleted(false);
    classificationType.setOwnedBy(SecurityContextHolder.getContext().getAuthentication().getName());
    MetadataHateoas metadataHateoas = new MetadataHateoas(classificationTypeRepository.save(classificationType));
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return metadataHateoas;
}
Also used : Authorisation(nikita.webapp.security.Authorisation) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)

Example 4 with ClassificationType

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

the class ClassificationTypeService method find.

// find by systemId
/**
 * Retrieve a single ClassificationType object identified by systemId
 *
 * @param systemId systemId of the ClassificationType you wish to retrieve
 * @return single ClassificationType object wrapped as a MetadataHateoas
 * object
 */
@Override
public MetadataHateoas find(String systemId) {
    MetadataHateoas metadataHateoas = new MetadataHateoas(classificationTypeRepository.findBySystemId(systemId));
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return metadataHateoas;
}
Also used : Authorisation(nikita.webapp.security.Authorisation) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)

Example 5 with ClassificationType

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

the class ClassificationTypeService method handleUpdate.

/**
 * Update a ClassificationType identified by its systemId
 * <p>
 * Copy the values you are allowed to change, code and description
 *
 * @param systemId           The systemId of the classificationType object you wish to
 *                           update
 * @param classificationType The updated classificationType object. Note
 *                           the values you are allowed to change are
 *                           copied from this object. This object is not
 *                           persisted.
 * @return the updated classificationType
 */
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, ClassificationType classificationType) {
    ClassificationType existingClassificationType = getClassificationTypeOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    if (null != existingClassificationType.getCode()) {
        existingClassificationType.setCode(existingClassificationType.getCode());
    }
    if (null != existingClassificationType.getDescription()) {
        existingClassificationType.setDescription(existingClassificationType.getDescription());
    }
    // Note this can potentially result in a NoarkConcurrencyException
    // exception
    existingClassificationType.setVersion(version);
    MetadataHateoas classificationTypeHateoas = new MetadataHateoas(classificationTypeRepository.save(existingClassificationType));
    metadataHateoasHandler.addLinks(classificationTypeHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingClassificationType));
    return classificationTypeHateoas;
}
Also used : Authorisation(nikita.webapp.security.Authorisation) ClassificationType(nikita.common.model.noark5.v4.metadata.ClassificationType) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)

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