Search in sources :

Example 6 with Link

use of nikita.common.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.common.model.noark5.v4.hateoas.Link)

Example 7 with Link

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

the class FondsService method deleteEntity.

// All DELETE operations
/**
 * Deletes a Fonds object 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. Note that as there is a @ManyToMany relationship between
 * Fonds and FondsCreator with a join table, we first have to
 * disassociate the link between Fonds and FondsCreator or we hit a
 * foreign key constraint issue. The same applies for Fonds and
 * StorageLocation.
 * <p>
 * In order to minimise problems that could be caused with table and
 * column names changing, constants are used to define relevant column
 * and table names.
 * <p>
 * The approach is is discussed in a nikita github issue
 * https://github.com/HiOA-ABI/nikita-noark5-core/issues/82
 *
 * @param fondsSystemId The systemId of the fonds object to retrieve
 */
@Override
public void deleteEntity(@NotNull String fondsSystemId) {
    Fonds fonds = getFondsOrThrow(fondsSystemId);
    // Disassociate any links between Fonds and FondsCreator
    Query q = entityManager.createNativeQuery("DELETE FROM " + TABLE_FONDS_FONDS_CREATOR + " WHERE " + FOREIGN_KEY_FONDS_PK + " = :id ;");
    q.setParameter("id", fonds.getId());
    q.executeUpdate();
    // Disassociate any links between Fonds and StorageLocation
    q = entityManager.createNativeQuery("DELETE FROM " + TABLE_STORAGE_LOCATION + " WHERE " + FOREIGN_KEY_FONDS_PK + " = :id ;");
    q.setParameter("id", fonds.getId());
    q.executeUpdate();
    // Next get hibernate to delete the Fonds object
    entityManager.remove(fonds);
    entityManager.flush();
    entityManager.clear();
}
Also used : TypedQuery(javax.persistence.TypedQuery) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) Fonds(nikita.common.model.noark5.v4.Fonds)

Example 8 with Link

use of nikita.common.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

Query (javax.persistence.Query)2 TypedQuery (javax.persistence.TypedQuery)2 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)2 Link (nikita.common.model.noark5.v4.hateoas.Link)2 Link (nikita.model.noark5.v4.hateoas.Link)2 Fonds (nikita.common.model.noark5.v4.Fonds)1 CorrespondencePartInternal (nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)1 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)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