Search in sources :

Example 1 with RegistryEntryStatus

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

the class RegistryEntryStatusService method find.

// find by systemId
/**
 * Retrieve a single RegistryEntryStatus object identified by systemId
 *
 * @param systemId
 * @return single RegistryEntryStatus object wrapped as a MetadataHateoas object
 */
@Override
public MetadataHateoas find(String systemId) {
    MetadataHateoas metadataHateoas = new MetadataHateoas(RegistryEntryStatusRepository.save(RegistryEntryStatusRepository.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 2 with RegistryEntryStatus

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

the class RegistryEntryStatusService method findByDescription.

/**
 * Retrieve all RegistryEntryStatus that have a given description.
 * <br>
 * Note, this will be replaced by OData search.
 *
 * @param description
 * @return A list of RegistryEntryStatus objects wrapped as a MetadataHateoas
 * object
 */
@Override
public MetadataHateoas findByDescription(String description) {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) RegistryEntryStatusRepository.findByDescription(description), REGISTRY_ENTRY_STATUS);
    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 RegistryEntryStatus

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

the class RegistryEntryStatusService method findAll.

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

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

the class RegistryEntryStatusService method getRegistryEntryStatusOrThrow.

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

Example 5 with RegistryEntryStatus

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

the class RegistryEntryStatusService method handleUpdate.

/**
 * Update a RegistryEntryStatus identified by its systemId
 * <p>
 * Copy the values you are allowed to change, code and description
 *
 * @param RegistryEntryStatus
 * @return the updated RegistryEntryStatus
 */
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, RegistryEntryStatus RegistryEntryStatus) {
    RegistryEntryStatus existingRegistryEntryStatus = getRegistryEntryStatusOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    if (null != existingRegistryEntryStatus.getCode()) {
        existingRegistryEntryStatus.setCode(existingRegistryEntryStatus.getCode());
    }
    if (null != existingRegistryEntryStatus.getDescription()) {
        existingRegistryEntryStatus.setDescription(existingRegistryEntryStatus.getDescription());
    }
    // Note this can potentially result in a NoarkConcurrencyException
    // exception
    existingRegistryEntryStatus.setVersion(version);
    MetadataHateoas RegistryEntryStatusHateoas = new MetadataHateoas(RegistryEntryStatusRepository.save(existingRegistryEntryStatus));
    metadataHateoasHandler.addLinks(RegistryEntryStatusHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingRegistryEntryStatus));
    return RegistryEntryStatusHateoas;
}
Also used : Authorisation(nikita.webapp.security.Authorisation) RegistryEntryStatus(nikita.common.model.noark5.v4.metadata.RegistryEntryStatus) 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 RegistryEntryStatus (nikita.common.model.noark5.v4.metadata.RegistryEntryStatus)3 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)1 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)1