@Override public DSpaceObject getParentObject(Context context, Community community) throws SQLException { List<Community> parentCommunities = community.getParentCommunities(); if (CollectionUtils.isNotEmpty(parentCommunities)) { return parentCommunities.iterator().next(); } else { return null; } }
@Override public List<Community> flatParentCommunities(Community c) throws SQLException { Queue<Community> queue = new LinkedList<>(); List<Community> result = new ArrayList<>(); queue.add(c); while (!queue.isEmpty()) { Community p = queue.poll(); List<Community> par = p.getParentCommunities(); if (par != null) { queue.addAll(par); } if (!result.contains(p)) { result.add(p); } } return result; }
@Override public List<Community> flatParentCommunities(Collection c) throws SQLException { Queue<Community> queue = new LinkedList<>(); List<Community> result = new ArrayList<>(); for (Community com : c.getCommunities()) { queue.add(com); } while (!queue.isEmpty()) { Community p = queue.poll(); List<Community> par = p.getParentCommunities(); if (par != null) { queue.addAll(par); } if (!result.contains(p)) { result.add(p); } } return result; }
private void findComms(Community comm, List<Object> parentComms) throws SQLException { if (comm == null) { return; } if (!parentComms.contains(comm.getID())) { parentComms.add(comm.getID()); } List<Community> parentCommunities = comm.getParentCommunities(); Community parent = parentCommunities.size() == 0 ? null : parentCommunities.get(0); findComms(parent, parentComms); }
@Override public List<Community> flatParentCommunities(Context context, Item c) throws SQLException { Queue<Community> queue = new LinkedList<>(); List<Community> result = new ArrayList<>(); for (Collection collection : c.getCollections()) { queue.addAll(communityService.getAllParents(context, collection)); } while (!queue.isEmpty()) { Community p = queue.poll(); List<Community> par = p.getParentCommunities(); if (par != null) { queue.addAll(par); } if (!result.contains(p)) { result.add(p); } } return result; } }
Community childDad = CollectionUtils.isNotEmpty(child.getParentCommunities()) ? child.getParentCommunities() .iterator().next() : null; List<Community> parentDads = parent.getParentCommunities(); if (parentDads.contains(child)) { System.out.println("Error, circular parentage - child is parent of parent");
/** * Can the current user remove the admins group of the community? * please note that the create/edit actions need separate check * * @param context the DSpace Context Object * @param community the community * @throws AuthorizeException if authorization error * if the current user is not allowed to remove the * collection's admins group * @throws SQLException if database error * if a db error occur * @see #authorizeManageAdminGroup(Context, Community) */ public static void authorizeRemoveAdminGroup(Context context, Community community) throws SQLException, AuthorizeException { List<Community> parentCommunities = community.getParentCommunities(); Community parentCommunity = null; if (0 < parentCommunities.size()) { parentCommunity = parentCommunities.get(0); } if (AuthorizeConfiguration.canCommunityAdminManageAdminGroup() && parentCommunity != null) { authorizeService.authorizeAction(context, parentCommunity, Constants.ADMIN); } else if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only system admin can remove the admin group of the community"); } }
Community community = (Community) dso; dc.add(makeDC("identifier", "uri", "hdl:" + dso.getHandle())); List<Community> parentCommunities = community.getParentCommunities(); String ownerHdl = null; if (CollectionUtils.isEmpty(parentCommunities)) {
List<Community> parents = ((Community) dso).getParentCommunities(); if (CollectionUtils.isEmpty(parents)) { parentHandle = siteService.findSite(context).getHandle();
if (dso instanceof Community) { Community comm = (Community) dso; List<Community> parentCommunities = comm.getParentCommunities(); for (Community parent : parentCommunities) { doc1.addField("owningComm", parent.getID());