📄 personattributesgroupstore.java
字号:
} } private java.util.Set primGetAllContainingGroups(IEntityGroup group, Set s) throws GroupsException { Iterator i = findContainingGroups(group); while ( i.hasNext() ) { IEntityGroup parentGroup = (IEntityGroup) i.next(); s.add(parentGroup); primGetAllContainingGroups(parentGroup, s); } return s; } public Iterator findContainingGroups(IGroupMember member) throws GroupsException { return (member.isEntity()) ? findContainingGroupsForEntity((IEntity)member) : findContainingGroupsForGroup((IEntityGroup)member); } private Iterator findContainingGroupsForGroup(IEntityGroup group) { List parents = (List)containingGroups.get(group.getLocalKey()); return (parents !=null) ? parents.iterator() : Collections.EMPTY_LIST.iterator(); } private Iterator findContainingGroupsForEntity(IEntity member) throws GroupsException { List results = new ArrayList(); for (Iterator i = groups.values().iterator(); i.hasNext(); ) { IEntityGroup group = (IEntityGroup)i.next(); if ( contains(group, member)) { results.add(group); } } return results.iterator(); } public Iterator findEntitiesForGroup(IEntityGroup group) throws GroupsException { return Collections.EMPTY_LIST.iterator(); } public ILockableEntityGroup findLockable(String key) throws GroupsException { throw new UnsupportedOperationException("PersonAttributesGroupStore: Method findLockable() not supported"); } public String[] findMemberGroupKeys(IEntityGroup group) throws GroupsException { List keys = new ArrayList(); GroupDefinition groupDef = (GroupDefinition) groupDefinitions.get(group.getLocalKey()); if (groupDef != null) { for (Iterator i = groupDef.members.iterator(); i.hasNext(); ) { keys.add((String) i.next()); } } return (String [])keys.toArray(new String[]{}); } public Iterator findMemberGroups(IEntityGroup group) throws GroupsException { String[] keys = findMemberGroupKeys(group); List results = new ArrayList(); for (int i = 0; i < keys.length; i++) { results.add(cacheGet(keys[i])); } return results.iterator(); } public IEntityGroup newInstance(Class entityType) throws GroupsException { throw new UnsupportedOperationException("PersonAttributesGroupStore: Method newInstance() not supported"); } public EntityIdentifier[] searchForGroups(String query, int method, Class leaftype) throws GroupsException { List results = new ArrayList(); switch (method) { case IS: for (Iterator i = groups.values().iterator(); i.hasNext(); ) { IEntityGroup g = (IEntityGroup)i.next(); if (g.getName().equalsIgnoreCase(query)) { results.add(g.getEntityIdentifier()); } } break; case STARTS_WITH: for (Iterator i = groups.values().iterator(); i.hasNext(); ) { IEntityGroup g = (IEntityGroup)i.next(); if (g.getName().toUpperCase().startsWith(query.toUpperCase())) { results.add(g.getEntityIdentifier()); } } break; case ENDS_WITH: for (Iterator i = groups.values().iterator(); i.hasNext(); ) { IEntityGroup g = (IEntityGroup)i.next(); if (g.getName().toUpperCase().endsWith(query.toUpperCase())) { results.add(g.getEntityIdentifier()); } } break; case CONTAINS: for (Iterator i = groups.values().iterator(); i.hasNext(); ) { IEntityGroup g = (IEntityGroup)i.next(); if (g.getName().toUpperCase().indexOf(query.toUpperCase()) != -1) { results.add(g.getEntityIdentifier()); } } break; } return (EntityIdentifier [])results.toArray(new EntityIdentifier[]{}); } public void update(IEntityGroup group) throws GroupsException { throw new UnsupportedOperationException("PersonAttributesGroupStore: Method update() not supported."); } public void updateMembers(IEntityGroup group) throws GroupsException { throw new UnsupportedOperationException("PersonAttributesGroupStore: Method updateMembers() not supported."); } public static class GroupDefinition { private String key; private String name; private String description; private List members; private List testGroups; public GroupDefinition() { members = new Vector(); testGroups = new Vector(); } public void setKey(String key) { this.key = key; } public String getKey() { return key; } public void setName(String name) { this.name = name; } public String getName() { return name; } public void setDescription(String description) { this.description = description; } public String getDescription() { return description; } public void addMember(String key) { members.add(key); } public boolean hasMember(String key) { return members.contains(key); } public void addTestGroup(TestGroup testGroup) { testGroups.add(testGroup); } public boolean contains(IPerson person) { return ( testGroups.isEmpty() ) ? false : test(person); } public boolean test(IPerson person) { if (testGroups.isEmpty()) return true; for (Iterator i = testGroups.iterator(); i.hasNext(); ) { TestGroup testGroup = (TestGroup)i.next(); if (testGroup.test(person)) { return true; } } return false; } public String toString() { return "GroupDefinition " + key + " (" + name + ")"; } } public static class TestGroup { private List tests; public TestGroup() { tests = new Vector(); } public void addTest(IPersonTester test) { tests.add(test); } public boolean test(IPerson person) { for (Iterator i = tests.iterator(); i.hasNext(); ) { IPersonTester tester = (IPersonTester)i.next(); if (!tester.test(person)) { return false; } } return true; } } public IEntity newInstance(String key, Class type) throws GroupsException { if (EntityTypes.getEntityTypeID(type) == null) { throw new GroupsException("Invalid entity type: "+type.getName()); } return new EntityImpl(key, type); } public IEntity newInstance(String key) throws GroupsException { return new EntityImpl(key, null); } public EntityIdentifier[] searchForEntities(String query, int method, Class type) throws GroupsException { List results = new ArrayList(); return (EntityIdentifier [])results.toArray(new EntityIdentifier[]{}); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -