1 40 41 package org.dspace.content; 42 43 import java.io.IOException ; 44 import java.sql.SQLException ; 45 import java.util.ArrayList ; 46 import java.util.List ; 47 48 import org.apache.log4j.Logger; 49 50 import org.dspace.authorize.AuthorizeException; 51 import org.dspace.content.Item; 52 import org.dspace.content.Collection; 53 import org.dspace.content.WorkspaceItem; 54 import org.dspace.core.Context; 55 import org.dspace.eperson.EPerson; 56 import org.dspace.eperson.Group; 57 import org.dspace.storage.rdbms.DatabaseManager; 58 import org.dspace.storage.rdbms.TableRowIterator; 59 import org.dspace.storage.rdbms.TableRow; 60 61 68 public class SupervisedItem extends WorkspaceItem 69 { 70 71 72 private static Logger log = Logger.getLogger(SupervisedItem.class); 73 74 75 private Item item; 76 77 78 private Context ourContext; 79 80 81 private TableRow siRow; 82 83 84 private Collection collection; 85 86 92 SupervisedItem(Context context, TableRow row) 93 throws SQLException 94 { 95 super(context, row); 97 } 98 99 106 public static SupervisedItem[] getAll(Context context) 107 throws SQLException 108 { 109 List sItems = new ArrayList (); 110 111 String query = "SELECT DISTINCT workspaceitem.* " + 116 "FROM workspaceitem, epersongroup2workspaceitem " + 117 "WHERE workspaceitem.workspace_item_id = " + 118 "epersongroup2workspaceitem.workspace_item_id " + 119 "ORDER BY workspaceitem.workspace_item_id"; 120 121 TableRowIterator tri = DatabaseManager.queryTable(context, 122 "workspaceitem", 123 query); 124 125 while (tri.hasNext()) 126 { 127 TableRow row = tri.next(); 128 SupervisedItem si = new SupervisedItem(context, row); 129 130 sItems.add(si); 131 } 132 133 tri.close(); 134 135 SupervisedItem[] siArray = new SupervisedItem[sItems.size()]; 136 siArray = (SupervisedItem[]) sItems.toArray(siArray); 137 138 return siArray; 139 } 140 141 149 public Group[] getSupervisorGroups(Context c, int wi) 150 throws SQLException 151 { 152 List groupList = new ArrayList (); 153 String query = "SELECT epersongroup.* " + 154 "FROM epersongroup, epersongroup2workspaceitem " + 155 "WHERE epersongroup2workspaceitem.workspace_item_id" + 156 " = ? " + 157 " AND epersongroup2workspaceitem.eperson_group_id =" + 158 " epersongroup.eperson_group_id " + 159 "ORDER BY epersongroup.name"; 160 161 TableRowIterator tri = DatabaseManager.queryTable(c,"epersongroup",query, wi); 162 163 while (tri.hasNext()) 164 { 165 TableRow row = tri.next(); 166 Group group = Group.find(c,row.getIntColumn("eperson_group_id")); 167 168 groupList.add(group); 169 } 170 171 tri.close(); 172 173 Group[] groupArray = new Group[groupList.size()]; 174 groupArray = (Group[]) groupList.toArray(groupArray); 175 176 return groupArray; 177 } 178 179 185 public Group[] getSupervisorGroups() 188 throws SQLException 189 { 190 Context ourContext = new Context(); 191 192 List groupList = new ArrayList (); 193 String query = "SELECT epersongroup.* " + 194 "FROM epersongroup, epersongroup2workspaceitem " + 195 "WHERE epersongroup2workspaceitem.workspace_item_id" + 196 " = ? " + 197 " AND epersongroup2workspaceitem.eperson_group_id =" + 198 " epersongroup.eperson_group_id " + 199 "ORDER BY epersongroup.name"; 200 201 TableRowIterator tri = DatabaseManager.queryTable(ourContext, 202 "epersongroup", 203 query, this.getID()); 204 205 while (tri.hasNext()) 206 { 207 TableRow row = tri.next(); 208 Group group = Group.find(ourContext, 209 row.getIntColumn("eperson_group_id")); 210 211 groupList.add(group); 212 } 213 214 tri.close(); 215 216 Group[] groupArray = new Group[groupList.size()]; 217 groupArray = (Group[]) groupList.toArray(groupArray); 218 219 return groupArray; 220 } 221 222 230 public static SupervisedItem[] findbyEPerson(Context context, EPerson ep) 231 throws SQLException 232 { 233 List sItems = new ArrayList (); 234 String query = "SELECT DISTINCT workspaceitem.* " + 235 "FROM workspaceitem, epersongroup2workspaceitem, " + 236 "epersongroup2eperson " + 237 "WHERE workspaceitem.workspace_item_id = " + 238 "epersongroup2workspaceitem.workspace_item_id " + 239 "AND epersongroup2workspaceitem.eperson_group_id =" + 240 " epersongroup2eperson.eperson_group_id " + 241 "AND epersongroup2eperson.eperson_id= ? " + 242 " ORDER BY workspaceitem.workspace_item_id"; 243 244 TableRowIterator tri = DatabaseManager.queryTable(context, 245 "workspaceitem", 246 query,ep.getID()); 247 248 while (tri.hasNext()) 249 { 250 TableRow row = tri.next(); 251 SupervisedItem si = new SupervisedItem(context, row); 252 sItems.add(si); 253 } 254 255 tri.close(); 256 257 SupervisedItem[] siArray = new SupervisedItem[sItems.size()]; 258 siArray = (SupervisedItem[]) sItems.toArray(siArray); 259 260 return siArray; 261 262 } 263 264 } 265 | Popular Tags |