@Test public void testFindbyEPerson() throws Exception { context.turnOffAuthorisationSystem(); SupervisedItem[] found = SupervisedItem.findbyEPerson(context, EPerson.create(context)); assertThat("testFindbyEPerson 0", found, notNullValue()); assertTrue("testFindbyEPerson 1", found.length == 0); found = SupervisedItem.findbyEPerson(context, context.getCurrentUser()); assertThat("testFindbyEPerson 2", found, notNullValue()); assertTrue("testFindbyEPerson 3", found.length >= 1); boolean added = false; for(SupervisedItem sia: found) { if(sia.equals(si)) { added = true; } } assertTrue("testFindbyEPerson 4",added); context.restoreAuthSystemState(); }
public static SupervisedItem[] findbyEPerson(Context context, EPerson ep) throws SQLException { List<SupervisedItem> sItems = new ArrayList<SupervisedItem>(); String query = "SELECT DISTINCT workspaceitem.* " + "FROM workspaceitem, epersongroup2workspaceitem, " + "epersongroup2eperson " + "WHERE workspaceitem.workspace_item_id = " + "epersongroup2workspaceitem.workspace_item_id " + "AND epersongroup2workspaceitem.eperson_group_id =" + " epersongroup2eperson.eperson_group_id " + "AND epersongroup2eperson.eperson_id= ? " + " ORDER BY workspaceitem.workspace_item_id"; TableRowIterator tri = DatabaseManager.queryTable(context, "workspaceitem", query,ep.getID()); try { while (tri.hasNext()) { TableRow row = tri.next(); SupervisedItem si = new SupervisedItem(context, row); sItems.add(si); } } finally { if (tri != null) { tri.close(); } } return sItems.toArray(new SupervisedItem[sItems.size()]); }
SupervisedItem extends WorkspaceItem { public static SupervisedItem[] findbyEPerson(Context context, EPerson ep) throws SQLException { List<SupervisedItem> sItems = new ArrayList<SupervisedItem>(); String query = "SELECT DISTINCT workspaceitem.* " + "FROM workspaceitem, epersongroup2workspaceitem, " + "epersongroup2eperson " + "WHERE workspaceitem.workspace_item_id = " + "epersongroup2workspaceitem.workspace_item_id " + "AND epersongroup2workspaceitem.eperson_group_id =" + " epersongroup2eperson.eperson_group_id " + "AND epersongroup2eperson.eperson_id= ? " + " ORDER BY workspaceitem.workspace_item_id"; TableRowIterator tri = DatabaseManager.queryTable(context, "workspaceitem", query,ep.getID()); try { while (tri.hasNext()) { TableRow row = tri.next(); SupervisedItem si = new SupervisedItem(context, row); sItems.add(si); } } finally { if (tri != null) { tri.close(); } } return sItems.toArray(new SupervisedItem[sItems.size()]); } }
SupervisedItem extends WorkspaceItem { public static SupervisedItem[] findbyEPerson(Context context, EPerson ep) throws SQLException { List<SupervisedItem> sItems = new ArrayList<SupervisedItem>(); String query = "SELECT DISTINCT workspaceitem.* " + "FROM workspaceitem, epersongroup2workspaceitem, " + "epersongroup2eperson " + "WHERE workspaceitem.workspace_item_id = " + "epersongroup2workspaceitem.workspace_item_id " + "AND epersongroup2workspaceitem.eperson_group_id =" + " epersongroup2eperson.eperson_group_id " + "AND epersongroup2eperson.eperson_id= ? " + " ORDER BY workspaceitem.workspace_item_id"; TableRowIterator tri = DatabaseManager.queryTable(context, "workspaceitem", query,ep.getID()); try { while (tri.hasNext()) { TableRow row = tri.next(); SupervisedItem si = new SupervisedItem(context, row); sItems.add(si); } } finally { if (tri != null) { tri.close(); } } return sItems.toArray(new SupervisedItem[sItems.size()]); } SupervisedItem(Context context, TableRow row); }
SupervisedItem extends WorkspaceItem { public static SupervisedItem[] findbyEPerson(Context context, EPerson ep) throws SQLException { List<SupervisedItem> sItems = new ArrayList<SupervisedItem>(); String query = "SELECT DISTINCT workspaceitem.* " + "FROM workspaceitem, epersongroup2workspaceitem, " + "epersongroup2eperson " + "WHERE workspaceitem.workspace_item_id = " + "epersongroup2workspaceitem.workspace_item_id " + "AND epersongroup2workspaceitem.eperson_group_id =" + " epersongroup2eperson.eperson_group_id " + "AND epersongroup2eperson.eperson_id= ? " + " ORDER BY workspaceitem.workspace_item_id"; TableRowIterator tri = DatabaseManager.queryTable(context, "workspaceitem", query,ep.getID()); try { while (tri.hasNext()) { TableRow row = tri.next(); SupervisedItem si = new SupervisedItem(context, row); sItems.add(si); } } finally { if (tri != null) { tri.close(); } } return sItems.toArray(new SupervisedItem[sItems.size()]); } SupervisedItem(Context context, TableRow row); static SupervisedItem[] getAll(Context context); Group[] getSupervisorGroups(Context c, int wi); Group[] getSupervisorGroups(); static SupervisedItem[] findbyEPerson(Context context, EPerson ep); }
SupervisedItem extends WorkspaceItem { public static SupervisedItem[] findbyEPerson(Context context, EPerson ep) throws SQLException { List<SupervisedItem> sItems = new ArrayList<SupervisedItem>(); String query = "SELECT DISTINCT workspaceitem.* " + "FROM workspaceitem, epersongroup2workspaceitem, " + "epersongroup2eperson " + "WHERE workspaceitem.workspace_item_id = " + "epersongroup2workspaceitem.workspace_item_id " + "AND epersongroup2workspaceitem.eperson_group_id =" + " epersongroup2eperson.eperson_group_id " + "AND epersongroup2eperson.eperson_id= ? " + " ORDER BY workspaceitem.workspace_item_id"; TableRowIterator tri = DatabaseManager.queryTable(context, "workspaceitem", query,ep.getID()); try { while (tri.hasNext()) { TableRow row = tri.next(); SupervisedItem si = new SupervisedItem(context, row); sItems.add(si); } } finally { if (tri != null) { tri.close(); } } return sItems.toArray(new SupervisedItem[sItems.size()]); } SupervisedItem(Context context, TableRow row); static SupervisedItem[] getAll(Context context); Group[] getSupervisorGroups(Context c, int wi); Group[] getSupervisorGroups(); static SupervisedItem[] findbyEPerson(Context context, EPerson ep);  }