1 25 package org.infoglue.cms.entities.management; 26 27 import java.util.ArrayList ; 28 import java.util.List ; 29 30 import org.infoglue.cms.entities.kernel.Persistent; 31 import org.infoglue.cms.util.ConstraintExceptionBuffer; 32 import org.infoglue.cms.util.DomainUtils; 33 import org.infoglue.cms.util.validators.ValidatorFactory; 34 35 40 public class CategoryVO extends Persistent 41 { 42 private Integer categoryId; 43 private String name; 44 private String description; 45 private boolean active = true; 46 private Integer parentId; 47 private List children = new ArrayList (); 48 49 public CategoryVO() {} 50 51 public CategoryVO(String name) 52 { 53 setName(name); 54 } 55 56 public CategoryVO(Integer id, String name) 57 { 58 this(name); 59 setCategoryId(id); 60 } 61 62 public Integer getId() 63 { 64 return getCategoryId(); 65 } 66 67 public Integer getCategoryId() 68 { 69 return categoryId; 70 } 71 72 public void setCategoryId(Integer i) 73 { 74 categoryId = i; 75 } 76 77 public String getName() 78 { 79 return name; 80 } 81 82 public void setName(String s) 83 { 84 name = s; 85 } 86 87 public String getDescription() 88 { 89 return description; 90 } 91 92 public void setDescription(String s) 93 { 94 description = s; 95 } 96 97 public boolean isActive() 98 { 99 return active; 100 } 101 102 public void setActive(boolean b) 103 { 104 active = b; 105 } 106 107 public Integer getParentId() 108 { 109 return parentId; 110 } 111 112 public void setParentId(Integer i) 113 { 114 parentId = i; 115 } 116 117 public List getChildren() 118 { 119 return children; 120 } 121 122 public void setChildren(List l) 123 { 124 children = l; 125 } 126 127 public boolean isRoot() 128 { 129 return getParentId() == null; 130 } 131 132 public ConstraintExceptionBuffer validate() 133 { 134 ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer(); 135 ValidatorFactory.createStringValidator("Category.name", true, 1, 100).validate(name, ceb); 136 ValidatorFactory.createStringValidator("Category.description", false, 255).validate(description, ceb); 137 return ceb; 138 } 139 140 public boolean equals(Object o) 141 { 142 if (super.equals(o)) 143 { 144 CategoryVO category = (CategoryVO)o; 145 return DomainUtils.equals(categoryId, category.categoryId) 146 && DomainUtils.equals(name, category.name) 147 && DomainUtils.equals(description, category.description) 148 && DomainUtils.equals(parentId, category.parentId) 149 && children.size() == category.children.size() 150 && (active == category.active); 151 } 152 153 return false; 154 } 155 156 public StringBuffer toStringBuffer() 157 { 158 StringBuffer sb = super.toStringBuffer(); 159 sb.append(" name=").append(name) 160 .append(" description=").append(description) 161 .append(" active=").append(active) 162 .append(" parentId=").append(parentId) 163 .append(" children.size=").append(children.size()); 164 return sb; 165 } 166 } 167 | Popular Tags |