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));
}
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();
}
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);
}
Aggregations