public boolean deleteAllocation(int assetClassId) { ExceptionHandler handler = new ExceptionHandler(getContext(), this); AssetClassRepository repo = new AssetClassRepository(getContext()); // todo: use transaction? (see bulkUpdate) // Delete all child elements. List<Integer> childIds = getAllChildrenIds(assetClassId); repo.deleteAll(childIds); // delete any stock links AssetClassStockRepository stockRepo = new AssetClassStockRepository(getContext()); boolean linksDeleted = stockRepo.deleteAllForAssetClass(assetClassId); if (!linksDeleted) { handler.showMessage("Error deleting stock links."); return false; } // delete allocation record boolean assetClassDeleted = repo.delete(assetClassId); if (!assetClassDeleted) { handler.showMessage("Error deleting asset class."); return false; } return true; }