use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class EntityGroupImpl method getChildren.
/**
* Returns an <code>Iterator</code> over the <code>GroupMembers</code> in our member <code>
* Collection</code>. Reflects pending changes.
*
* @return Iterator
*/
@Override
public Set<IGroupMember> getChildren() throws GroupsException {
final EntityIdentifier cacheKey = getUnderlyingEntityIdentifier();
Element element = childrenCache.get(cacheKey);
if (element == null) {
final Set<IGroupMember> children = buildChildrenSet();
element = new Element(cacheKey, children);
childrenCache.put(element);
}
@SuppressWarnings("unchecked") final Set<IGroupMember> rslt = (Set<IGroupMember>) element.getObjectValue();
return rslt;
}
use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class GroupMemberImpl method getParentGroups.
/**
* Returns an <code>Iterator</code> over this <code>IGroupMember's</code> parent groups.
* Synchronize the collection of keys with adds and removes.
*
* @return Iterator
*/
@Override
public Set<IEntityGroup> getParentGroups() throws GroupsException {
final EntityIdentifier cacheKey = getUnderlyingEntityIdentifier();
Element element = parentGroupsCache.get(cacheKey);
if (element == null) {
final Set<IEntityGroup> groups = buildParentGroupsSet();
element = new Element(cacheKey, groups);
parentGroupsCache.put(element);
}
@SuppressWarnings("unchecked") final Set<IEntityGroup> rslt = (Set<IEntityGroup>) element.getObjectValue();
return rslt;
}
use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class RDBMEntityGroupStore method searchForGroups.
@Override
public EntityIdentifier[] searchForGroups(String query, SearchMethod method, Class leaftype) throws GroupsException {
EntityIdentifier[] r = new EntityIdentifier[0];
ArrayList ar = new ArrayList();
Connection conn = null;
PreparedStatement ps = null;
int type = EntityTypesLocator.getEntityTypes().getEntityIDFromType(leaftype).intValue();
try {
conn = RDBMServices.getConnection();
switch(method) {
case DISCRETE:
ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS);
break;
case DISCRETE_CI:
ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_CASE_INSENSITIVE);
break;
case STARTS_WITH:
query = query + "%";
ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL);
break;
case STARTS_WITH_CI:
query = query + "%";
ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL_CASE_INSENSITIVE);
break;
case ENDS_WITH:
query = "%" + query;
ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL);
break;
case ENDS_WITH_CI:
query = "%" + query;
ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL_CASE_INSENSITIVE);
break;
case CONTAINS:
query = "%" + query + "%";
ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL);
break;
case CONTAINS_CI:
query = "%" + query + "%";
ps = conn.prepareStatement(RDBMEntityGroupStore.SEARCH_GROUPS_PARTIAL_CASE_INSENSITIVE);
break;
default:
throw new GroupsException("Unknown search type");
}
try {
ps.clearParameters();
ps.setInt(1, type);
ps.setString(2, query);
ResultSet rs = ps.executeQuery();
try {
// System.out.println(ps.toString());
while (rs.next()) {
// System.out.println("result");
ar.add(new EntityIdentifier(rs.getString(1), ICompositeGroupService.GROUP_ENTITY_TYPE));
}
} finally {
close(rs);
}
} finally {
close(ps);
}
} catch (Exception e) {
LOG.error("RDBMChannelDefSearcher.searchForEntities(): " + ps, e);
} finally {
RDBMServices.releaseConnection(conn);
}
return (EntityIdentifier[]) ar.toArray(r);
}
use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class ReferenceCompositeGroupService method searchForEntities.
/**
* Find EntityIdentifiers for entities whose name matches the query string according to the
* specified method and is of the specified type
*/
@Override
public EntityIdentifier[] searchForEntities(String query, IGroupConstants.SearchMethod method, Class type) throws GroupsException {
Set allIds = new HashSet();
for (Iterator services = getComponentServices().values().iterator(); services.hasNext(); ) {
IIndividualGroupService service = (IIndividualGroupService) services.next();
EntityIdentifier[] ids = service.searchForEntities(query, method, type);
for (int i = 0; i < ids.length; i++) {
allIds.add(ids[i]);
}
}
return (EntityIdentifier[]) allIds.toArray(new EntityIdentifier[allIds.size()]);
}
use of org.apereo.portal.EntityIdentifier in project uPortal by Jasig.
the class ReferenceCompositeGroupService method searchForGroups.
/**
* Find EntityIdentifiers for groups whose name matches the query string according to the
* specified method and matches the provided leaf type
*/
@Override
public EntityIdentifier[] searchForGroups(String query, IGroupConstants.SearchMethod method, Class leaftype) throws GroupsException {
Set allIds = new HashSet();
for (Iterator services = getComponentServices().values().iterator(); services.hasNext(); ) {
IIndividualGroupService service = (IIndividualGroupService) services.next();
EntityIdentifier[] ids = service.searchForGroups(query, method, leaftype);
for (int i = 0; i < ids.length; i++) {
try {
CompositeEntityIdentifier cei = new CompositeEntityIdentifier(ids[i].getKey(), ids[i].getType());
cei.setServiceName(service.getServiceName());
allIds.add(cei);
} catch (javax.naming.InvalidNameException ine) {
}
}
}
return (EntityIdentifier[]) allIds.toArray(new EntityIdentifier[allIds.size()]);
}
Aggregations