Search in sources :

Example 41 with INikitaEntity

use of nikita.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class HateoasHandler method addLinksOnNew.

@Override
public void addLinksOnNew(IHateoasNoarkObject hateoasNoarkObject, IAuthorisation authorisation) {
    this.authorisation = authorisation;
    Iterable<INikitaEntity> entities = hateoasNoarkObject.getList();
    for (INikitaEntity entity : entities) {
        addEntityLinksOnNew(entity, hateoasNoarkObject);
    }
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)

Example 42 with INikitaEntity

use of nikita.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class HateoasHandler method addLinksOnTemplate.

@Override
public void addLinksOnTemplate(IHateoasNoarkObject hateoasNoarkObject, IAuthorisation authorisation) {
    this.authorisation = authorisation;
    Iterable<INikitaEntity> entities = hateoasNoarkObject.getList();
    for (INikitaEntity entity : entities) {
        addEntityLinksOnTemplate(entity, hateoasNoarkObject);
    }
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)

Example 43 with INikitaEntity

use of nikita.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class FondsService method findFondsCreatorAssociatedWithFonds.

// All READ operations
/**
 * Retrieve a list of FondsCreator objects associated with a given Fonds
 * from the database. First we try to locate the Fonds object. If the
 * Fonds object does not exist a NoarkEntityNotFoundException exception
 * is thrown that the caller has to deal with.
 * <p>
 * If any FondsCreator objects exist, they are wrapped in a
 * FondsCreatorHateoas object and returned to the caller.
 *
 * @param fondsSystemId The systemId of the Fonds object that you want to
 *                      retrieve associated FondsCreator objects
 * @return the fondsCreator objects wrapped as a FondsCreatorHateoas object
 */
@Override
public FondsCreatorHateoas findFondsCreatorAssociatedWithFonds(@NotNull String fondsSystemId) {
    Fonds fonds = getFondsOrThrow(fondsSystemId);
    FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas((List<INikitaEntity>) (List) fonds.getReferenceFondsCreator());
    fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, new Authorisation());
    return fondsCreatorHateoas;
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) Fonds(nikita.common.model.noark5.v4.Fonds) FondsCreatorHateoas(nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas) List(java.util.List)

Example 44 with INikitaEntity

use of nikita.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class FondsService method findSingleFonds.

/**
 * Retrieve a list of StorageLocation objects associated with a given Fonds
 * from the database. First we try to locate the Fonds object. If the
 * Fonds object does not exist a NoarkEntityNotFoundException exception
 * is thrown that the caller has to deal with.
 *
 * If any StorageLocation objects exist, they are wrapped in a
 * StorageLocationHateoas object and returned to the caller.
 *
 * @param fondsSystemId The systemId of the Fonds object that you want to
 *                      retrieve associated StorageLocation objects
 *
 * @return the newly persisted fondsCreator object wrapped as a
 * StorageLocationHateoas object
 */
/*@Override
    TODO: Finish implementing this.
    public StorageLocationHateoas findStorageLocationAssociatedWithFonds(
            @NotNull String fondsSystemId) {

        Fonds fonds = getFondsOrThrow(fondsSystemId);

        StorageLocationHateoas stroageLocationHateoas = new
                StorageLocationHateoas((List<INikitaEntity>)
                (List) fonds.getReferenceStorageLocation());
        fondsCreatorHateoasHandler.addLinks(stroageLocationHateoas,
                new Authorisation());
        return stroageLocationHateoas;
    } */
/**
 * Retrieve a single Fonds objects from the database.
 *
 * @param fondsSystemId The systemId of the Fonds object you wish to
 *                      retrieve
 * @return the Fonds object wrapped as a FondsHateoas object
 */
@Override
public FondsHateoas findSingleFonds(String fondsSystemId) {
    Fonds existingFonds = getFondsOrThrow(fondsSystemId);
    FondsHateoas fondsHateoas = new FondsHateoas(fondsRepository.save(existingFonds));
    fondsHateoasHandler.addLinks(fondsHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingFonds));
    return fondsHateoas;
}
Also used : FondsHateoas(nikita.common.model.noark5.v4.hateoas.FondsHateoas) Authorisation(nikita.webapp.security.Authorisation) Fonds(nikita.common.model.noark5.v4.Fonds) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)

Example 45 with INikitaEntity

use of nikita.model.noark5.v4.interfaces.entities.INikitaEntity in project nikita-noark5-core by HiOA-ABI.

the class CasePartyRoleService method findByCode.

/**
 * retrieve all CasePartyRole 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 CasePartyRole objects wrapped as a MetadataHateoas
 * object
 */
@Override
public MetadataHateoas findByCode(String code) {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) casePartyRoleRepository.findByCode(code), CASE_PARTY_ROLE);
    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

INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)80 Authorisation (nikita.webapp.security.Authorisation)78 List (java.util.List)77 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)54 Counted (com.codahale.metrics.annotation.Counted)40 ApiOperation (io.swagger.annotations.ApiOperation)34 ApiResponses (io.swagger.annotations.ApiResponses)34 ArrayList (java.util.ArrayList)20 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)19 Timed (com.codahale.metrics.annotation.Timed)16 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)16 Fonds (nikita.common.model.noark5.v4.Fonds)6 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)5 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)4 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)3 Record (nikita.common.model.noark5.v4.Record)3 Fonds (nikita.model.noark5.v4.Fonds)3 FondsCreator (nikita.common.model.noark5.v4.FondsCreator)2 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)2 DocumentObjectHateoas (nikita.common.model.noark5.v4.hateoas.DocumentObjectHateoas)2