1 41 package com.mvnforum.db; 42 43 import java.sql.Timestamp ; 44 import java.util.Collection ; 45 import java.util.Iterator ; 46 47 import net.myvietnam.mvncore.exception.ObjectNotFoundException; 48 import net.myvietnam.mvncore.util.StringUtil; 49 50 55 public class GroupsBean { 56 57 private int groupID; 58 private int groupOwnerID; 59 private String groupOwnerName; 60 private String groupName; 61 private String groupDesc; 62 private int groupOption; 63 private Timestamp groupCreationDate; 64 private Timestamp groupModifiedDate; 65 66 public int getGroupID() { 67 return groupID; 68 } 69 public void setGroupID(int groupID) { 70 this.groupID = groupID; 71 } 72 73 public int getGroupOwnerID() { 74 return groupOwnerID; 75 } 76 public void setGroupOwnerID(int groupOwnerID) { 77 this.groupOwnerID = groupOwnerID; 78 } 79 80 public String getGroupOwnerName() { 81 return groupOwnerName; 82 } 83 public void setGroupOwnerName(String groupOwnerName) { 84 this.groupOwnerName = StringUtil.getEmptyStringIfNull(groupOwnerName); 85 } 86 87 public String getGroupName() { 88 return groupName; 89 } 90 public void setGroupName(String groupName) { 91 this.groupName = groupName; 92 } 93 94 public String getGroupDesc() { 95 return groupDesc; 96 } 97 public void setGroupDesc(String groupDesc) { 98 this.groupDesc = StringUtil.getEmptyStringIfNull(groupDesc); 99 } 100 101 public int getGroupOption() { 102 return groupOption; 103 } 104 public void setGroupOption(int groupOption) { 105 this.groupOption = groupOption; 106 } 107 108 public Timestamp getGroupCreationDate() { 109 return groupCreationDate; 110 } 111 public void setGroupCreationDate(Timestamp groupCreationDate) { 112 this.groupCreationDate = groupCreationDate; 113 } 114 115 public Timestamp getGroupModifiedDate() { 116 return groupModifiedDate; 117 } 118 public void setGroupModifiedDate(Timestamp groupModifiedDate) { 119 this.groupModifiedDate = groupModifiedDate; 120 } 121 122 public String getXML() { 123 StringBuffer xml = new StringBuffer (1024); 124 xml.append("<GroupsSection>\n"); 125 xml.append(" <Rows>\n"); 126 xml.append(" <Row>\n"); 127 xml.append(" <Column>\n"); 128 xml.append(" <Name>GroupID</Name>\n"); 129 xml.append(" <Value>").append(String.valueOf(groupID)).append("</Value>\n"); 130 xml.append(" </Column>\n"); 131 xml.append(" <Column>\n"); 132 xml.append(" <Name>GroupOwnerID</Name>\n"); 133 xml.append(" <Value>").append(String.valueOf(groupOwnerID)).append("</Value>\n"); 134 xml.append(" </Column>\n"); 135 xml.append(" <Column>\n"); 136 xml.append(" <Name>GroupOwnerName</Name>\n"); 137 xml.append(" <Value>").append(String.valueOf(groupOwnerName)).append("</Value>\n"); 138 xml.append(" </Column>\n"); 139 xml.append(" <Column>\n"); 140 xml.append(" <Name>GroupName</Name>\n"); 141 xml.append(" <Value>").append(String.valueOf(groupName)).append("</Value>\n"); 142 xml.append(" </Column>\n"); 143 xml.append(" <Column>\n"); 144 xml.append(" <Name>GroupDesc</Name>\n"); 145 xml.append(" <Value>").append(String.valueOf(groupDesc)).append("</Value>\n"); 146 xml.append(" </Column>\n"); 147 xml.append(" <Column>\n"); 148 xml.append(" <Name>GroupOption</Name>\n"); 149 xml.append(" <Value>").append(String.valueOf(groupOption)).append("</Value>\n"); 150 xml.append(" </Column>\n"); 151 xml.append(" <Column>\n"); 152 xml.append(" <Name>GroupCreationDate</Name>\n"); 153 xml.append(" <Value>").append(String.valueOf(groupCreationDate)).append("</Value>\n"); 154 xml.append(" </Column>\n"); 155 xml.append(" <Column>\n"); 156 xml.append(" <Name>GroupModifiedDate</Name>\n"); 157 xml.append(" <Value>").append(String.valueOf(groupModifiedDate)).append("</Value>\n"); 158 xml.append(" </Column>\n"); 159 xml.append(" </Row>\n"); 160 xml.append(" </Rows>\n"); 161 xml.append("</GroupsSection>\n"); 162 return xml.toString(); 163 } 164 165 public static String getXML(Collection objGroupsBeans) { 166 StringBuffer xml = new StringBuffer (1024); 167 Iterator iterator = objGroupsBeans.iterator(); 168 xml.append("<GroupsSection>\n"); 169 xml.append(" <Rows>\n"); 170 while (iterator.hasNext()) { 171 GroupsBean objGroupsBean = (GroupsBean)iterator.next(); 172 xml.append(" <Row>\n"); 173 xml.append(" <Column>\n"); 174 xml.append(" <Name>GroupID</Name>\n"); 175 xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupID)).append("</Value>\n"); 176 xml.append(" </Column>\n"); 177 xml.append(" <Column>\n"); 178 xml.append(" <Name>GroupOwnerID</Name>\n"); 179 xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupOwnerID)).append("</Value>\n"); 180 xml.append(" </Column>\n"); 181 xml.append(" <Column>\n"); 182 xml.append(" <Name>GroupOwnerName</Name>\n"); 183 xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupOwnerName)).append("</Value>\n"); 184 xml.append(" </Column>\n"); 185 xml.append(" <Column>\n"); 186 xml.append(" <Name>GroupName</Name>\n"); 187 xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupName)).append("</Value>\n"); 188 xml.append(" </Column>\n"); 189 xml.append(" <Column>\n"); 190 xml.append(" <Name>GroupDesc</Name>\n"); 191 xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupDesc)).append("</Value>\n"); 192 xml.append(" </Column>\n"); 193 xml.append(" <Column>\n"); 194 xml.append(" <Name>GroupOption</Name>\n"); 195 xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupOption)).append("</Value>\n"); 196 xml.append(" </Column>\n"); 197 xml.append(" <Column>\n"); 198 xml.append(" <Name>GroupCreationDate</Name>\n"); 199 xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupCreationDate)).append("</Value>\n"); 200 xml.append(" </Column>\n"); 201 xml.append(" <Column>\n"); 202 xml.append(" <Name>GroupModifiedDate</Name>\n"); 203 xml.append(" <Value>").append(String.valueOf(objGroupsBean.groupModifiedDate)).append("</Value>\n"); 204 xml.append(" </Column>\n"); 205 xml.append(" </Row>\n"); 206 } xml.append(" </Rows>\n"); 208 xml.append("</GroupsSection>\n"); 209 return xml.toString(); 210 } 211 212 215 private int groupMemberCount; 216 217 public int getGroupMemberCount() { 218 return groupMemberCount; 219 } 220 public void setGroupMemberCount(int groupMemberCount) { 221 this.groupMemberCount = groupMemberCount; 222 } 223 224 public static GroupsBean getGroupsBean(Collection objGroupsBeans, int groupID) 225 throws ObjectNotFoundException { 226 Iterator iterator = objGroupsBeans.iterator(); 227 while (iterator.hasNext()) { 228 GroupsBean objGroupsBean = (GroupsBean)iterator.next(); 229 if (objGroupsBean.getGroupID() == groupID) { 230 return objGroupsBean; 231 } 232 } throw new ObjectNotFoundException("Cannot find GroupsBean with GroupID = " + groupID); 235 } 236 237 } | Popular Tags |