1 64 65 package com.jcorporate.expresso.services.dbobj; 66 67 import com.jcorporate.expresso.core.db.DBException; 68 import com.jcorporate.expresso.core.dbobj.RequestContext; 69 import com.jcorporate.expresso.core.dbobj.SecuredDBObject; 70 71 import java.util.Iterator ; 72 73 74 80 public class GroupNest 81 extends SecurityDBObject { 82 83 86 public static final String FLD_GROUPNAME = "GroupName"; 87 public static final String FLD_MEMBEROF = "MemberOf"; 88 89 92 public GroupNest() 93 throws DBException { 94 super(); 95 } 96 97 98 102 public GroupNest(int uid) 103 throws DBException { 104 super(uid); 105 } 106 107 114 public GroupNest(RequestContext request) 115 throws DBException { 116 super(request); 117 } 118 119 123 public void add() 124 throws DBException { 125 GroupMembers ml = new GroupMembers(SecuredDBObject.SYSTEM_ACCOUNT); 126 ml.setDataContext(getDataContext()); 127 128 GroupMembers oneMember = null; 129 GroupMembers newMember = new GroupMembers(SecuredDBObject.SYSTEM_ACCOUNT); 130 newMember.setDataContext(getDataContext()); 131 ml.setField(GroupMembers.GROUP_NAME, getField(FLD_GROUPNAME)); 132 133 for (Iterator e = ml.searchAndRetrieveList().iterator(); e.hasNext();) { 134 oneMember = (GroupMembers) e.next(); 135 newMember.clear(); 136 newMember.setField(GroupMembers.EXPUID, oneMember.getField(GroupMembers.EXPUID)); 137 newMember.setField(GroupMembers.GROUP_NAME, getField(FLD_MEMBEROF)); 138 139 if (!newMember.find()) { 140 newMember.add(); 141 } 142 } 143 144 145 super.add(); 146 } 147 148 149 154 protected void checkAllRefs() 155 throws DBException { 156 checkRef(FLD_GROUPNAME, new UserGroup(), 157 "Invalid " + getString(getMetaData().getDescription(FLD_GROUPNAME))); 158 checkRef(FLD_MEMBEROF, new UserGroup(), 159 "Invalid " + getString(getMetaData().getDescription(FLD_MEMBEROF))); 160 } 161 162 163 167 public void delete() 168 throws DBException { 169 GroupMembers ml = new GroupMembers(SecuredDBObject.SYSTEM_ACCOUNT); 170 ml.setDataContext(getDataContext()); 171 172 GroupMembers oneMember = null; 173 GroupMembers newMember = new GroupMembers(SecuredDBObject.SYSTEM_ACCOUNT); 174 newMember.setDataContext(getDataContext()); 175 ml.setField(GroupMembers.GROUP_NAME, getField(FLD_GROUPNAME)); 176 177 for (Iterator e = ml.searchAndRetrieveList().iterator(); e.hasNext();) { 178 oneMember = (GroupMembers) e.next(); 179 newMember.clear(); 180 newMember.setField(GroupMembers.EXPUID, oneMember.getField(GroupMembers.EXPUID)); 181 newMember.setField(GroupMembers.GROUP_NAME, getField(FLD_MEMBEROF)); 182 183 if (newMember.find()) { 184 newMember.delete(); 185 } 186 } 187 188 189 super.delete(); 190 } 191 192 193 196 protected synchronized void setupFields() 197 throws DBException { 198 setTargetTable("GROUPNEST"); 199 setName("GROUPNEST"); 200 setDescription("DBgroupNest"); 201 setCharset("ISO-8859-1"); 202 addField(FLD_GROUPNAME, "char", 10, false, "groupName"); 203 addField(FLD_MEMBEROF, "char", 10, false, "memberOf"); 204 addKey(FLD_GROUPNAME); 205 addKey(FLD_MEMBEROF); 206 setStringFilter(FLD_GROUPNAME, "stripFilter"); 207 setStringFilter(FLD_MEMBEROF, "stripFilter"); 208 setMultiValued(FLD_GROUPNAME); 209 setMultiValued(FLD_MEMBEROF); 210 setLookupObject(FLD_MEMBEROF, 211 com.jcorporate.expresso.services.dbobj.UserGroup.class.getName()); 212 setLookupObject(FLD_GROUPNAME, 213 com.jcorporate.expresso.services.dbobj.UserGroup.class.getName()); 214 } 215 216 217 } 218 219 | Popular Tags |