public void updateCategory(CategoryData categoryData) { Category category = categoryService.find(UUIDHelper.stringToUUID(categoryData.getUuid())); if (categoryData.getParentCategory() != null) { log.info("found parent category"); category.setParentCategory( categoryService.find( UUIDHelper.stringToUUID(categoryData.getParentCategory().getUuid()))); } categoryService.update(category); }
@Override public void saveCategory(CategoryData categoryData) { if (categoryData.getParentCategory() == null) categoryService.addCategory(categoryData.getCategoryEntity()); else { Category parent = categoryService.find(UUIDHelper.stringToUUID(categoryData.getParentCategory().getUuid())); Category child = new Category( UUIDHelper.stringToUUID(categoryData.getUuid()), categoryData.getCategoryName(), parent); categoryService.addCategory(child); categoryService.addParentCategory( child.getUuid(), UUIDHelper.stringToUUID(categoryData.getParentCategory().getUuid())); } }