1 package org.apache.fulcrum.security.impl.db.entity; 2 3 56 57 import java.util.List ; 59 60 import org.apache.fulcrum.security.entity.Group; 61 import org.apache.fulcrum.security.entity.SecurityEntity; 62 import org.apache.fulcrum.security.util.DataBackendException; 63 import org.apache.fulcrum.security.util.GroupSet; 64 import org.apache.torque.util.BasePeer; 65 import org.apache.torque.util.Criteria; 66 67 78 public class TurbineGroupPeer 79 extends org.apache.fulcrum.security.impl.db.entity.BaseTurbineGroupPeer 80 { 81 82 public static final String NAME = GROUP_NAME; 83 84 89 public static String getColumnName(String name) 90 { 91 StringBuffer sb = new StringBuffer (); 92 sb.append(TurbineGroupPeer.TABLE_NAME); 93 sb.append("."); 94 sb.append(name); 95 return sb.toString(); 96 } 97 98 108 public static boolean checkExists(Group group) 109 throws DataBackendException, Exception 110 { 111 Criteria criteria = new Criteria(); 112 criteria.addSelectColumn(GROUP_ID); 113 criteria.add(NAME, ((SecurityEntity)group).getName()); 114 List results = BasePeer.doSelect(criteria); 115 if (results.size() > 1) 116 { 117 throw new DataBackendException("Multiple groups named '" + 118 ((TurbineGroup)group).getName() + "' exist!"); 119 } 120 return (results.size()==1); 121 } 122 123 128 public static String getTableName() 129 { 130 return TABLE_NAME; 131 } 132 133 140 public static GroupSet retrieveSet() throws Exception 141 { 142 return retrieveSet(new Criteria()); 143 } 144 145 148 public static GroupSet retrieveSet(Criteria criteria) throws Exception 149 { 150 List results = doSelect(criteria); 151 GroupSet rs = new GroupSet(); 152 for (int i = 0; i < results.size(); i++) 153 { 154 rs.add((Group)results.get(i)); 155 } 156 return rs; 157 } 158 159 } 160 | Popular Tags |