@Test public void testGetParentCommunity() throws Exception { new NonStrictExpectations() { AuthorizeManager authManager; { AuthorizeManager.authorizeAction((Context) any, (Community) any, Constants.ADD); result = null; AuthorizeManager.authorizeActionBoolean((Context) any, (Community) any, Constants.ADD); result = true; } }; assertThat("testGetParentCommunity 0",c.getParentCommunity(), nullValue()); Community son = Community.create(c, context); assertThat("testGetParentCommunity 1",son.getParentCommunity(), notNullValue()); assertThat("testGetParentCommunity 2", son.getParentCommunity(), equalTo(c)); }
public Community getParentCommunity() throws SQLException { Community parentCommunity = null; TableRowIterator tri = DatabaseManager.queryTable( ourContext,"community", "SELECT community.* FROM community, community2community WHERE " + "community2community.parent_comm_id=community.community_id " + "AND community2community.child_comm_id= ? ", getID()); try { if (tri.hasNext()) { TableRow row = tri.next(); Community fromCache = (Community) ourContext.fromCache( Community.class, row.getIntColumn("community_id")); if (fromCache != null) { parentCommunity = fromCache; } else { parentCommunity = new Community(ourContext, row); } } } finally { if (tri != null) { tri.close(); } } return parentCommunity; }
Community extends DSpaceObject { public Community getParentCommunity() throws SQLException { Community parentCommunity = null; TableRowIterator tri = DatabaseManager.queryTable( ourContext,"community", "SELECT community.* FROM community, community2community WHERE " + "community2community.parent_comm_id=community.community_id " + "AND community2community.child_comm_id= ? ", getID()); try { if (tri.hasNext()) { TableRow row = tri.next(); Community fromCache = (Community) ourContext.fromCache( Community.class, row.getIntColumn("community_id")); if (fromCache != null) { parentCommunity = fromCache; } else { parentCommunity = new Community(ourContext, row); } } } finally { if (tri != null) { tri.close(); } } return parentCommunity; } }
Community extends DSpaceObject { public Community getParentCommunity() throws SQLException { Community parentCommunity = null; TableRowIterator tri = DatabaseManager.queryTable( ourContext,"community", "SELECT community.* FROM community, community2community WHERE " + "community2community.parent_comm_id=community.community_id " + "AND community2community.child_comm_id= ? ", getID()); try { if (tri.hasNext()) { TableRow row = tri.next(); Community fromCache = (Community) ourContext.fromCache( Community.class, row.getIntColumn("community_id")); if (fromCache != null) { parentCommunity = fromCache; } else { parentCommunity = new Community(ourContext, row); } } } finally { if (tri != null) { tri.close(); } } return parentCommunity; } Community(Context context, TableRow row); }
Community extends DSpaceObject { public Community getParentCommunity() throws SQLException { Community parentCommunity = null; TableRowIterator tri = DatabaseManager.queryTable( ourContext,"community", "SELECT community.* FROM community, community2community WHERE " + "community2community.parent_comm_id=community.community_id " + "AND community2community.child_comm_id= ? ", getID()); try { if (tri.hasNext()) { TableRow row = tri.next(); Community fromCache = (Community) ourContext.fromCache( Community.class, row.getIntColumn("community_id")); if (fromCache != null) { parentCommunity = fromCache; } else { parentCommunity = new Community(ourContext, row); } } } finally { if (tri != null) { tri.close(); } } return parentCommunity; } Community(Context context, TableRow row); static Community find(Context context, int id); static Community create(Community parent, Context context); static Community create(Community parent, Context context, String handle); static Community[] findAll(Context context); static Community[] findAllTop(Context context); int getID(); String getHandle(); String getMetadata(String field); void setMetadata(String field, String value); String getName(); Bitstream getLogo(); Bitstream setLogo(InputStream is); void update(); Group createAdministrators(); void removeAdministrators(); Group getAdministrators(); Collection[] getCollections(); Community[] getSubcommunities(); Community getParentCommunity(); Community[] getAllParents(); Collection createCollection(); Collection createCollection(String handle); void addCollection(Collection c); Community createSubcommunity(); Community createSubcommunity(String handle); void addSubcommunity(Community c); void removeCollection(Collection c); void removeSubcommunity(Community c); void delete(); boolean equals(Object other); int hashCode(); int getType(); boolean canEditBoolean(); void canEdit(); int countItems(); DSpaceObject getAdminObject(int action); DSpaceObject getParentObject(); }
Community extends DSpaceObject { public Community getParentCommunity() throws SQLException { Community parentCommunity = null; TableRowIterator tri = DatabaseManager.queryTable( ourContext,"community", "SELECT community.* FROM community, community2community WHERE " + "community2community.parent_comm_id=community.community_id " + "AND community2community.child_comm_id= ? ", getID()); try { if (tri.hasNext()) { TableRow row = tri.next(); Community fromCache = (Community) ourContext.fromCache( Community.class, row.getIntColumn("community_id")); if (fromCache != null) { parentCommunity = fromCache; } else { parentCommunity = new Community(ourContext, row); } } } finally { if (tri != null) { tri.close(); } } return parentCommunity; } Community(Context context, TableRow row); static Community find(Context context, int id); static Community create(Community parent, Context context); static Community create(Community parent, Context context, String handle); static Community[] findAll(Context context); static Community[] findAllTop(Context context); int getID(); String getHandle(); String getMetadata(String field); void setMetadata(String field, String value); String getName(); Bitstream getLogo(); Bitstream setLogo(InputStream is); void update(); Group createAdministrators(); void removeAdministrators(); Group getAdministrators(); Collection[] getCollections(); Community[] getSubcommunities(); Community getParentCommunity(); Community[] getAllParents(); Collection createCollection(); Collection createCollection(String handle); void addCollection(Collection c); Community createSubcommunity(); Community createSubcommunity(String handle); void addSubcommunity(Community c); void removeCollection(Collection c); void removeSubcommunity(Community c); void delete(); boolean equals(Object other); int hashCode(); int getType(); boolean canEditBoolean(); void canEdit(); int countItems(); DSpaceObject getAdminObject(int action); DSpaceObject getParentObject();  }