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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations