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()));
   }
 }
Exemplo n.º 3
0
 public DualListModel<StoreData> getSelectedUserStores() {
   if (getUserForm().getSelectedUserStoresModel() == null) {
     List<StoreData> source = new ArrayList<StoreData>();
     List<StoreData> target = new ArrayList<StoreData>();
     for (StoreData store : storeProcessor.getStores()) {
       boolean setToSource = true;
       if (getUserForm().getSelectedUser() != null) {
         for (String storeId : getUserForm().getSelectedUser().getStoreIds()) {
           if (store.getStoreEntity().getUuid().equals(UUIDHelper.stringToUUID(storeId))) {
             target.add(store);
             setToSource = false;
           }
         }
       }
       if (setToSource) source.add(store);
     }
     getUserForm().setSelectedUserStoresModel(new DualListModel<StoreData>(source, target));
   }
   return getUserForm().getSelectedUserStoresModel();
 }
 public void removeCategory(CategoryData categoryData) {
   Category category = categoryService.find(UUIDHelper.stringToUUID(categoryData.getUuid()));
   categoryService.removeCategory(category);
 }