Search in sources :

Example 1 with FlowStatus

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

the class FlowStatusService method find.

// find by systemId
/**
 * Retrieve a single FlowStatus object identified by systemId
 *
 * @param systemId systemId of the FlowStatus you wish to retrieve
 * @return single FlowStatus object wrapped as a MetadataHateoas object
 */
@Override
public MetadataHateoas find(String systemId) {
    MetadataHateoas metadataHateoas = new MetadataHateoas(flowStatusRepository.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 FlowStatus

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

the class FlowStatusService method getFlowStatusOrThrow.

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

Example 3 with FlowStatus

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

the class FlowStatusService method generateDefaultFlowStatus.

/**
 * Generate a default FlowStatus object
 *
 * @return the FlowStatus object wrapped as a FlowStatusHateoas object
 */
@Override
public FlowStatus generateDefaultFlowStatus() {
    FlowStatus flowStatus = new FlowStatus();
    flowStatus.setCode(TEMPLATE_FLOW_STATUS_CODE);
    flowStatus.setDescription(TEMPLATE_FLOW_STATUS_DESCRIPTION);
    return flowStatus;
}
Also used : FlowStatus(nikita.common.model.noark5.v4.metadata.FlowStatus)

Example 4 with FlowStatus

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

the class FlowStatusService method createNewFlowStatus.

// All CREATE operations
/**
 * Persists a new FlowStatus object to the database.
 *
 * @param flowStatus FlowStatus object with values set
 * @return the newly persisted FlowStatus object wrapped as a MetadataHateoas
 * object
 */
@Override
public MetadataHateoas createNewFlowStatus(FlowStatus flowStatus) {
    flowStatus.setDeleted(false);
    flowStatus.setOwnedBy(SecurityContextHolder.getContext().getAuthentication().getName());
    MetadataHateoas metadataHateoas = new MetadataHateoas(flowStatusRepository.save(flowStatus));
    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 FlowStatus

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

the class FlowStatusService method findAll.

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

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 FlowStatus (nikita.common.model.noark5.v4.metadata.FlowStatus)3 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)1 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)1