@Test public final void testDeleteWithPropertiesButParentPreserved() { final IExternalDataDAO externalDataDAO = daoFactory.getExternalDataDAO(); final ExternalDataPE deletedData = findExternalData(CHILD_CODE); // Deleted data set should have all collections which prevent it from deletion empty. assertTrue(deletedData.getChildren().isEmpty()); // delete externalDataDAO.delete(deletedData); // test successful deletion of data set assertNull(externalDataDAO.tryGetByTechId(TechId.create(deletedData))); // test successful deletion of data set properties assertFalse(deletedData.getProperties().isEmpty()); List<EntityTypePropertyTypePE> retrievedPropertyTypes = daoFactory .getEntityPropertyTypeDAO(EntityKind.DATA_SET) .listEntityPropertyTypes(deletedData.getEntityType()); for (DataSetPropertyPE property : deletedData.getProperties()) { int index = retrievedPropertyTypes.indexOf(property.getEntityTypePropertyType()); EntityTypePropertyTypePE retrievedPropertyType = retrievedPropertyTypes.get(index); assertFalse(retrievedPropertyType.getPropertyValues().contains(property)); } // deleted sample had parent connected that should not have been deleted // NOTE: somehow cannot get parents even though connection is the same as with children // DataPE parent = deletedData.tryGetParent(); // assertNotNull(parent); // assertNotNull(externalDataDAO.tryGetByTechId(new TechId(HibernateUtils.getId(parent)))); findExternalData(PARENT_CODE); }
@Override protected void executeConfirmedAction() { viewContext .getCommonService() .deletePropertyTypes(TechId.createList(data), reason.getValue(), callback); }