Search in sources :

Example 6 with CaseStatus

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

the class CaseStatusService method findAll.

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

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

the class CaseStatusService method getCaseStatusOrThrow.

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

Example 8 with CaseStatus

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

the class CaseStatusService method findByCode.

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

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

the class CaseStatusService method findByDescription.

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

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

the class CaseStatusService method generateDefaultCaseStatus.

/**
 * Generate a default CaseStatus object
 *
 * @return the CaseStatus object wrapped as a CaseStatusHateoas object
 */
@Override
public CaseStatus generateDefaultCaseStatus() {
    CaseStatus caseStatus = new CaseStatus();
    caseStatus.setCode(TEMPLATE_CASE_STATUS_CODE);
    caseStatus.setDescription(TEMPLATE_CASE_STATUS_DESCRIPTION);
    return caseStatus;
}
Also used : CaseStatus(nikita.common.model.noark5.v4.metadata.CaseStatus)

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 CaseStatus (nikita.common.model.noark5.v4.metadata.CaseStatus)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ParseException (java.text.ParseException)1 Date (java.util.Date)1 Series (nikita.common.model.noark5.v4.Series)1 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)1 NikitaMalformedInputDataException (nikita.common.util.exceptions.NikitaMalformedInputDataException)1 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)1 Series (nikita.model.noark5.v4.Series)1 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)1 NikitaMalformedInputDataException (nikita.util.exceptions.NikitaMalformedInputDataException)1 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)1