ItEr54S09AdaptacionServiciosRESTItEr53S10: Moved the creation of the MaterialCategory entities from XXController to XXModel.

This change will be necessary when we add the attribute generateCode to that entity.
This commit is contained in:
Jacobo Aragunde Pérez 2010-04-15 21:51:45 +02:00 committed by Javier Moran Rua
parent eecea3e7e2
commit 17f2005e2d
3 changed files with 6 additions and 5 deletions

View file

@ -36,7 +36,7 @@ import org.zkoss.ganttz.util.MutableTreeModel;
*/
public interface IMaterialsModel {
void addMaterialCategory(MaterialCategory parent, MaterialCategory child) throws ValidationException;
void addMaterialCategory(MaterialCategory parent, String categoryName) throws ValidationException;
void addMaterialToMaterialCategory(MaterialCategory materialCategory);

View file

@ -248,14 +248,13 @@ public class MaterialsController extends
throw new WrongValueException(txtCategory, _("cannot be null or empty"));
}
final MaterialCategory category = MaterialCategory.create(_(categoryName));
MaterialCategory parent = null;
final Treeitem treeitem = categoriesTree.getSelectedItem();
if (treeitem != null) {
parent = (MaterialCategory) treeitem.getValue();
}
try {
materialsModel.addMaterialCategory(parent, category);
materialsModel.addMaterialCategory(parent, categoryName);
txtCategory.setValue("");
reloadCategoriesTree(treeitem);
} catch (ValidationException e) {

View file

@ -121,8 +121,10 @@ public class MaterialsModel implements IMaterialsModel {
}
@Override
public void addMaterialCategory(MaterialCategory parent, MaterialCategory child) throws ValidationException {
Validate.notNull(child);
public void addMaterialCategory(MaterialCategory parent, String categoryName) throws ValidationException {
Validate.notNull(categoryName);
MaterialCategory child = MaterialCategory.create(_(categoryName));
final MaterialCategory materialCategory = findMaterialCategory(child);
if (materialCategory != null) {