本文整理汇总了Java中org.apache.commons.collections.functors.AndPredicate类的典型用法代码示例。如果您正苦于以下问题:Java AndPredicate类的具体用法?Java AndPredicate怎么用?Java AndPredicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AndPredicate类属于org.apache.commons.collections.functors包,在下文中一共展示了AndPredicate类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: filterMemberGroups
import org.apache.commons.collections.functors.AndPredicate; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Collection<? extends MemberGroup> filterMemberGroups(final Predicate predicate, Collection<? extends Group> groups) {
Predicate predicateToApply = predicate;
if (groups == null) { // search for not removed member and broker groups
final GroupQuery query = new GroupQuery();
query.setStatus(Group.Status.NORMAL);
query.setNatures(Group.Nature.MEMBER, Group.Nature.BROKER);
groups = groupService.search(query);
} else if (groups.isEmpty()) { // if the group list is empty then return the same (empty) list
return (Collection<? extends MemberGroup>) groups;
} else { // it creates a predicate to filter not removed member and broker groups
final Predicate memberGroupPredicate = new Predicate() {
@Override
public boolean evaluate(final Object object) {
final Group grp = (Group) object;
return Group.Status.NORMAL == grp.getStatus() && (Group.Nature.MEMBER == grp.getNature() || Group.Nature.BROKER == grp.getNature());
}
};
predicateToApply = predicate == null ? memberGroupPredicate : new AndPredicate(memberGroupPredicate, predicate);
}
CollectionUtils.filter(groups, predicateToApply);
return (Collection<? extends MemberGroup>) groups;
}
开发者ID:mateli,项目名称:OpenCyclos,代码行数:28,代码来源:GuaranteeServiceImpl.java
示例2: modifySearchBean
import org.apache.commons.collections.functors.AndPredicate; //导入依赖的package包/类
/**
* Checks that historic criteria are added to search
*/
@Test
public void modifySearchBean() {
Map<String, Object> params = new HashMap<String, Object>();
params.put(PersistableEntity.APPLICATION_TYPE, Foo.TYPE);
SearchBean bean = modifier.doModify(searchbean, params);
Collection<SearchCriterion> searchCriteria = bean.getCriteria();
assertEquals(3, searchCriteria.size());
// Expect three criterion added implicitly
assertNotNull(CollectionUtils.find(searchCriteria,
new AndPredicate(new InstanceofPredicate(InSearchCriterion.class),
new AndPredicate(new BeanPropertyValueEqualsPredicate("name",
"token.domainObjectType"),
new AndPredicate(new BeanPropertyValueEqualsPredicate("value",
Collections.singleton(Foo.TYPE)),
new BeanPropertyValueEqualsPredicate("rootAlias",
SearchCriterionMarshaller.HISTORY_ALIAS))))));
assertNotNull(CollectionUtils.find(searchCriteria,
new AndPredicate(new InstanceofPredicate(JoinCriterion.class),
new AndPredicate(new BeanPropertyValueEqualsPredicate("lhs", "id"),
new BeanPropertyValueEqualsPredicate("rhs", "token.domainObjectId")))));
assertNotNull(CollectionUtils.find(searchCriteria,
new AndPredicate(new BeanPropertyValueEqualsPredicate("rootAlias",
SearchCriterionMarshaller.HISTORY_ALIAS),
new AndPredicate(new BeanPropertyValueEqualsPredicate(NAME_ALIAS, ID_PROPERTY),
new BeanPropertyValueEqualsPredicate("subSelect",
"select max(hr.id) from HistoryRecord hr where hr.token.domainObjectId = foo.id and hr.token.domainObjectType = 'Foo'")))));
}
开发者ID:cucina,项目名称:opencucina,代码行数:35,代码来源:HistorisedTypeCriteriaModifierTest.java
示例3: modifySearchBean
import org.apache.commons.collections.functors.AndPredicate; //导入依赖的package包/类
/**
* Checks that historic criteria are added to search
*/
@Test
public void modifySearchBean() {
Map<String, Object> params = new HashMap<String, Object>();
params.put(PersistableEntity.APPLICATION_TYPE, EntityDescriptor.class.getSimpleName());
SearchBean bean = modifier.doModify(searchbean, params);
Collection<SearchCriterion> searchCriteria = bean.getCriteria();
assertEquals(3, searchCriteria.size());
// Expect three criterion added implicitly, subjectAlias
assertNotNull(CollectionUtils.find(searchCriteria,
new AndPredicate(new InstanceofPredicate(JoinCriterion.class),
new AndPredicate(new BeanPropertyValueEqualsPredicate("lhs",
EntityDescriptor.APPLICATION_TYPE_PROP),
new BeanPropertyValueEqualsPredicate("rhs", "token.domainObjectType")))));
assertNotNull(CollectionUtils.find(searchCriteria,
new AndPredicate(new InstanceofPredicate(JoinCriterion.class),
new AndPredicate(new BeanPropertyValueEqualsPredicate("lhs", "id"),
new BeanPropertyValueEqualsPredicate("rhs", "token.domainObjectId")))));
assertNotNull(CollectionUtils.find(searchCriteria,
new AndPredicate(new BeanPropertyValueEqualsPredicate("rootAlias",
SearchCriterionMarshaller.HISTORY_ALIAS),
new AndPredicate(new BeanPropertyValueEqualsPredicate(NAME_ALIAS, ID_PROPERTY),
new BeanPropertyValueEqualsPredicate("subSelect",
"select max(hr.id) from HistoryRecord hr where hr.token.domainObjectId = foo.id and hr.token.domainObjectType = " +
NameUtils.concat(ALIAS, EntityDescriptor.APPLICATION_TYPE_PROP))))));
}
开发者ID:cucina,项目名称:opencucina,代码行数:33,代码来源:HistorisedEntityDescriptorCriteriaModifierTest.java
示例4: testOwnerPermissions
import org.apache.commons.collections.functors.AndPredicate; //导入依赖的package包/类
@Test
public void testOwnerPermissions() throws Exception {
CaArrayUsernameHolder.setUser(STANDARD_USER);
Transaction tx = this.hibernateHelper.beginTransaction();
saveSupportingObjects();
daoObject.save(DUMMY_PROJECT_1);
tx.commit();
tx = this.hibernateHelper.beginTransaction();
Project p = searchDao.retrieve(Project.class, DUMMY_PROJECT_1.getId());
assertTrue(SecurityUtils.isOwner(p, CaArrayUsernameHolder.getCsmUser()));
assertTrue(SecurityUtils.canWrite(DUMMY_SOURCE, CaArrayUsernameHolder.getCsmUser()));
assertNotNull(p.getPublicProfile());
assertEquals(2, p.getFiles().size());
assertNotNull(searchDao.retrieve(CaArrayFile.class, DUMMY_FILE_1.getId()));
assertNotNull(searchDao.retrieve(CaArrayFile.class, DUMMY_FILE_2.getId()));
assertNotNull(searchDao.retrieve(CaArrayFile.class, DUMMY_DATA_FILE.getId()));
List<UserGroupRoleProtectionGroup> list = SecurityUtils.getUserGroupRoleProtectionGroups(p);
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.READ_ROLE))));
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.WRITE_ROLE))));
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.PERMISSIONS_ROLE))));
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.BROWSE_ROLE))));
assertTrue(SecurityUtils.canRead(p, CaArrayUsernameHolder.getCsmUser()));
assertTrue(SecurityUtils.canWrite(p, CaArrayUsernameHolder.getCsmUser()));
assertTrue(SecurityUtils.canFullRead(p, CaArrayUsernameHolder.getCsmUser()));
assertTrue(SecurityUtils.canFullWrite(p, CaArrayUsernameHolder.getCsmUser()));
assertTrue(SecurityUtils.canModifyPermissions(p, CaArrayUsernameHolder.getCsmUser()));
}
开发者ID:NCIP,项目名称:caarray,代码行数:35,代码来源:ProjectDaoTest.java
示例5: testInitialProjectPermissions
import org.apache.commons.collections.functors.AndPredicate; //导入依赖的package包/类
@Test
public void testInitialProjectPermissions() {
// create project
Transaction tx = this.hibernateHelper.beginTransaction();
saveSupportingObjects();
this.hibernateHelper.getCurrentSession().save(DUMMY_PROJECT_1);
this.hibernateHelper.getCurrentSession().save(DUMMY_ASSAYTYPE_1);
this.hibernateHelper.getCurrentSession().save(DUMMY_ASSAYTYPE_2);
tx.commit();
// check initial settings.. drafts should be not visible
tx = this.hibernateHelper.beginTransaction();
final Project p = searchDao.retrieve(Project.class, DUMMY_PROJECT_1.getId());
List<UserGroupRoleProtectionGroup> list = SecurityUtils.getUserGroupRoleProtectionGroups(p);
assertEquals(8, list.size()); // expect the user-only ones only
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.READ_ROLE))));
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.WRITE_ROLE))));
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.PERMISSIONS_ROLE))));
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.BROWSE_ROLE))));
p.getPublicProfile().setSecurityLevel(SecurityLevel.VISIBLE);
tx.commit();
// check that after changing to visible, the role is reflected.
tx = this.hibernateHelper.beginTransaction();
list = SecurityUtils.getUserGroupRoleProtectionGroups(p);
assertEquals(9, list.size()); // expect the user-only ones and the anonymous access one
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.READ_ROLE))));
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.WRITE_ROLE))));
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.PERMISSIONS_ROLE))));
assertTrue(CollectionUtils.exists(list, new AndPredicate(new IsGroupPredicate(), new HasRolePredicate(
SecurityUtils.BROWSE_ROLE))));
tx.commit();
}
开发者ID:NCIP,项目名称:caarray,代码行数:41,代码来源:ProjectDaoTest.java
示例6: visit
import org.apache.commons.collections.functors.AndPredicate; //导入依赖的package包/类
void visit(AndPredicate p) {
for (int i = 0; i < p.getPredicates().length; i++) {
doVisit(p.getPredicates()[i]);
}
}
开发者ID:shevek,项目名称:spring-rich-client,代码行数:6,代码来源:ValangRichValidator.java
注:本文中的org.apache.commons.collections.functors.AndPredicate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论