1 package org.infoglue.cms.applications.managementtool.actions; 2 3 import org.infoglue.cms.applications.common.actions.ModelAction; 4 import org.infoglue.cms.controllers.kernel.impl.simple.CategoryController; 5 import org.infoglue.cms.entities.kernel.Persistent; 6 import org.infoglue.cms.entities.management.CategoryVO; 7 import org.infoglue.cms.exception.ConstraintException; 8 import org.infoglue.cms.exception.SystemException; 9 10 13 public class CategoryAction extends ModelAction 14 { 15 private static final long serialVersionUID = 1L; 16 17 public static final String MAIN = "main"; 18 19 private CategoryController controller = CategoryController.getController(); 20 21 protected Persistent createModel() { return new CategoryVO(); } 22 23 public CategoryVO getCategory() { return (CategoryVO)getModel(); } 24 25 public Integer getCategoryId() { return getCategory().getCategoryId(); } 26 public void setCategoryId(Integer i) { getCategory().setCategoryId(i); } 27 28 29 public String doList() throws SystemException 30 { 31 setModels(controller.findRootCategories()); 32 return SUCCESS; 33 } 34 35 public String doNew() throws SystemException 36 { 37 return SUCCESS; 38 } 39 40 public String doEdit() throws SystemException 41 { 42 setModel(controller.findWithChildren(getCategoryId())); 43 return SUCCESS; 44 } 45 46 public String doDisplayTreeForMove() throws SystemException 47 { 48 return SUCCESS; 49 } 50 51 public String doMove() throws SystemException 52 { 53 setModel(controller.moveCategory(getCategoryId(), getCategory().getParentId())); 54 return SUCCESS; 55 } 56 57 public String doSave() throws SystemException, ConstraintException 58 { 59 validateModel(); 60 setModel(controller.save(getCategory())); 61 return (getCategory().isRoot())? MAIN : SUCCESS; 62 } 63 64 public String doDelete() throws SystemException 65 { 66 setModel(controller.findById(getCategoryId())); 68 controller.delete(getCategoryId()); 69 70 return (getCategory().getParentId() == null) ? MAIN : SUCCESS; 71 } 72 73 public String doExecute() throws Exception 75 { return SUCCESS; } 76 } 77 | Popular Tags |