use of org.hisp.dhis.common.ObjectDeletionRequestedEvent in project dhis2-core by dhis2.
the class SoftDeleteHibernateObjectStore method delete.
@Override
public void delete(SoftDeletableObject object) {
publisher.publishEvent(new ObjectDeletionRequestedEvent(object));
object.setDeleted(true);
getSession().update(object);
}
use of org.hisp.dhis.common.ObjectDeletionRequestedEvent in project dhis2-core by dhis2.
the class RelationshipDeletionHandlerTest method allowDeleteRelationshipTypeWithoutData.
@Test
void allowDeleteRelationshipTypeWithoutData() {
when(relationshipService.getRelationshipsByRelationshipType(any())).thenReturn(emptyList());
ObjectDeletionRequestedEvent event = new ObjectDeletionRequestedEvent(new RelationshipType());
deletionManager.onDeletion(event);
verify(relationshipService, atLeastOnce()).getRelationshipsByRelationshipType(any());
}
use of org.hisp.dhis.common.ObjectDeletionRequestedEvent in project dhis2-core by dhis2.
the class RelationshipDeletionHandlerTest method allowDeleteRelationshipTypeWithData.
@Test
void allowDeleteRelationshipTypeWithData() {
when(relationshipService.getRelationshipsByRelationshipType(any())).thenReturn(singletonList(new Relationship()));
ObjectDeletionRequestedEvent event = new ObjectDeletionRequestedEvent(new RelationshipType());
Exception ex = assertThrows(DeleteNotAllowedException.class, () -> deletionManager.onDeletion(event));
assertEquals("Object could not be deleted because it is associated with another object: Relationship", ex.getMessage());
}
use of org.hisp.dhis.common.ObjectDeletionRequestedEvent in project dhis2-core by dhis2.
the class RelationshipDeletionHandlerTest method deleteTrackedEntityInstance.
@Test
void deleteTrackedEntityInstance() {
when(relationshipService.getRelationshipsByTrackedEntityInstance(any(), anyBoolean())).thenReturn(singletonList(new Relationship()));
ObjectDeletionRequestedEvent event = new ObjectDeletionRequestedEvent(new TrackedEntityInstance());
deletionManager.onDeletion(event);
verify(relationshipService, atLeastOnce()).getRelationshipsByTrackedEntityInstance(any(), anyBoolean());
verify(relationshipService, atLeastOnce()).deleteRelationship(any());
}
use of org.hisp.dhis.common.ObjectDeletionRequestedEvent in project dhis2-core by dhis2.
the class HibernateCategoryOptionComboStore method deleteNoRollBack.
@Override
public void deleteNoRollBack(CategoryOptionCombo categoryOptionCombo) {
ObjectDeletionRequestedEvent event = new ObjectDeletionRequestedEvent(categoryOptionCombo);
event.setShouldRollBack(false);
publisher.publishEvent(event);
getSession().delete(categoryOptionCombo);
}
Aggregations