Search in sources :

Example 1 with Link

use of nikita.model.noark5.v4.hateoas.Link in project nikita-noark5-core by HiOA-ABI.

the class HateoasHandler method addSelfLink.

@Override
public void addSelfLink(INikitaEntity entity, IHateoasNoarkObject hateoasNoarkObject) {
    String systemId = entity.getSystemId();
    hateoasNoarkObject.addLink(entity, new Link(contextPath + HATEOAS_API_PATH + SLASH + entity.getFunctionalTypeName() + SLASH + entity.getBaseTypeName() + SLASH + systemId + SLASH, getRelSelfLink(), false));
}
Also used : Link(nikita.model.noark5.v4.hateoas.Link)

Example 2 with Link

use of nikita.model.noark5.v4.hateoas.Link in project nikita-noark5-core by HiOA-ABI.

the class HateoasHandler method addLinks.

@Override
public void addLinks(IHateoasNoarkObject hateoasNoarkObject, HttpServletRequest request, IAuthorisation authorisation) {
    setParameters(request);
    this.authorisation = authorisation;
    Iterable<INikitaEntity> entities = hateoasNoarkObject.getList();
    for (INikitaEntity entity : entities) {
        addSelfLink(entity, hateoasNoarkObject);
        addEntityLinks(entity, hateoasNoarkObject);
    }
    // { "entity": [], "_links": [] }
    if (!hateoasNoarkObject.isSingleEntity()) {
        StringBuffer url = request.getRequestURL();
        Link selfLink = new Link(url.toString(), getRelSelfLink(), false);
        hateoasNoarkObject.addSelfLink(selfLink);
    }
}
Also used : INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity) Link(nikita.model.noark5.v4.hateoas.Link)

Example 3 with Link

use of nikita.model.noark5.v4.hateoas.Link in project nikita-noark5-core by HiOA-ABI.

the class FondsService method deleteEntity.

// All DELETE operations
@Override
public void deleteEntity(@NotNull String fondsSystemId) {
    Fonds fonds = getFondsOrThrow(fondsSystemId);
    // Disassociate the link between Fonds and FondsCreator
    // https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
    Query q = entityManager.createNativeQuery("DELETE FROM fonds_fonds_creator WHERE f_pk_fonds_id  = :id ;");
    q.setParameter("id", fonds.getId());
    q.executeUpdate();
    entityManager.remove(fonds);
    entityManager.flush();
    entityManager.clear();
//fondsRepository.delete(fonds);
}
Also used : TypedQuery(javax.persistence.TypedQuery) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) Fonds(nikita.model.noark5.v4.Fonds)

Example 4 with Link

use of nikita.model.noark5.v4.hateoas.Link in project nikita-noark5-core by HiOA-ABI.

the class CorrespondencePartService method deleteCorrespondencePartInternal.

@Override
public void deleteCorrespondencePartInternal(@NotNull String code) {
    CorrespondencePartInternal correspondencePartInternal = (CorrespondencePartInternal) getCorrespondencePartOrThrow(code);
    /*
        // Disassociate the link between Fonds and FondsCreator
        // https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
        Query q = entityManager.createNativeQuery("DELETE FROM fonds_fonds_creator WHERE f_pk_fonds_id  = :id ;");
        q.setParameter("id", fonds.getId());
        q.executeUpdate();
        entityManager.remove(fonds);
        entityManager.flush();
        entityManager.clear();*/
    correspondencePartRepository.delete(correspondencePartInternal);
}
Also used : CorrespondencePartInternal(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)

Aggregations

Link (nikita.model.noark5.v4.hateoas.Link)2 Query (javax.persistence.Query)1 TypedQuery (javax.persistence.TypedQuery)1 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)1 Fonds (nikita.model.noark5.v4.Fonds)1 CorrespondencePartInternal (nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)1 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)1