当前位置: 首页>>代码示例>>Java>>正文


Java Disjunction.add方法代码示例

本文整理汇总了Java中org.hibernate.criterion.Disjunction.add方法的典型用法代码示例。如果您正苦于以下问题:Java Disjunction.add方法的具体用法?Java Disjunction.add怎么用?Java Disjunction.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.criterion.Disjunction的用法示例。


在下文中一共展示了Disjunction.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addCriteriaForMaclike

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
private void addCriteriaForMaclike(OnmsCriteria criteria, String macLike) {
    String macLikeStripped = macLike.replaceAll("[:-]", "");
    
    criteria.createAlias("node.snmpInterfaces", "snmpInterface", CriteriaSpecification.LEFT_JOIN);
    criteria.createAlias("node.arpInterfaces", "arpInterface", CriteriaSpecification.LEFT_JOIN);
    Disjunction physAddrDisjunction = Restrictions.disjunction();
    physAddrDisjunction.add(Restrictions.ilike("snmpInterface.physAddr", macLikeStripped, MatchMode.ANYWHERE));
    physAddrDisjunction.add(Restrictions.ilike("arpInterface.physAddr", macLikeStripped, MatchMode.ANYWHERE));
    criteria.add(physAddrDisjunction);
  
    // This is an alternative to the above code if we need to use the out-of-the-box DetachedCriteria which doesn't let us specify the join type 
    /*
    String propertyName = "nodeId";
    String value = "%" + macLikeStripped + "%";
    
    Disjunction physAddrDisjuction = Restrictions.disjunction();
    physAddrDisjuction.add(Restrictions.sqlRestriction("{alias}." + propertyName + " IN (SELECT nodeid FROM snmpinterface WHERE snmpphysaddr LIKE ? )", value, new StringType()));
    physAddrDisjuction.add(Restrictions.sqlRestriction("{alias}." + propertyName + " IN (SELECT nodeid FROM atinterface WHERE atphysaddr LIKE ? )", value, new StringType()));
    criteria.add(physAddrDisjuction);
    */
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:DefaultNodeListService.java

示例2: getBatchInstanceIdentifierForUserRoles

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
 * API for getting the batch instance identifiers having the user roles.
 * @param userRoles Set<String>
 * @return Set<String>
 */
@Override
public Set<String> getBatchInstanceIdentifierForUserRoles(final Set<String> userRoles) {
	boolean isValid = true;
	if (userRoles == null || userRoles.size() == 0) {
		isValid = false;
	}
	Set<String> batchInstanceIdentifiers = null;

	if (isValid) {
		batchInstanceIdentifiers = new HashSet<String>();
		final DetachedCriteria criteria = criteria();
		final Disjunction disjunction = Restrictions.disjunction();
		disjunction.add(Restrictions.in(GROUP_NAME, userRoles));
		criteria.add(disjunction);
		final List<BatchInstanceGroups> batchInstanceGroups = find(criteria);
		for (final BatchInstanceGroups batchInstanceGroup : batchInstanceGroups) {
			batchInstanceIdentifiers.add(batchInstanceGroup.getBatchInstanceIdentifier());
		}
	}
	return batchInstanceIdentifiers;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:27,代码来源:BatchInstanceGroupsDaoImpl.java

示例3: listUsersBySearch

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
 * Buscar usuários de acordo com um nome.
 * 
 * @param terms Nome buscado.
 * @return PaginatedList Lista de usuários que contém o nome buscado
 *         em alguma parte do nome.
 */
public PaginatedList<User> listUsersBySearch(String terms) {
	PaginatedList<User> results = new PaginatedList<User>();
	Criteria criteria = this.dao.newCriteria(User.class);
	criteria.add(Restrictions.eq("deleted", false));
	
	Criteria count = this.dao.newCriteria(User.class).add(Restrictions.eq("deleted", false))
			.setProjection(Projections.countDistinct("id"));

	if (terms != null && !terms.isEmpty()) {
		Disjunction or = Restrictions.disjunction();
		or.add(Restrictions.like("name", "%" + terms + "%").ignoreCase());
		criteria.add(or);
		count.add(or);
	}

	results.setList(this.dao.findByCriteria(criteria, User.class));
	results.setTotal((Long) count.uniqueResult());
	return results;

}
 
开发者ID:progolden,项目名称:vraptor-boilerplate,代码行数:28,代码来源:UserBS.java

示例4: createEntityIdsInCriterion

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
 * Create a in list criterion potentially using disjunction to overcome the
 * size limitation of certain DBs in restriction (e.g. Oracle is 1000).
 *
 * @param entityIds
 *     the list of entity ids.
 * @param chunkSize
 *     the size of disjunctions parts.
 * @return the criterion.
 */
public static Criterion createEntityIdsInCriterion(Collection<Serializable> entityIds, int chunkSize) {
  if (entityIds.size() < chunkSize) {
    return Restrictions.in(IEntity.ID, entityIds);
  }
  int i = 0;
  Disjunction splittedInlist = Restrictions.disjunction();
  Set<Serializable> currentEntityIds = new LinkedHashSet<>();
  boolean complete = false;
  for (Iterator<Serializable> ite = entityIds.iterator(); ite.hasNext(); i++) {
    currentEntityIds.add(ite.next());
    if (i % chunkSize == (chunkSize - 1)) {
      splittedInlist.add(Restrictions.in(IEntity.ID, currentEntityIds));
      currentEntityIds = new LinkedHashSet<>();
      complete = true;
    } else {
      complete = false;
    }
  }
  if (!complete) {
    splittedInlist.add(Restrictions.in(IEntity.ID, currentEntityIds));
  }
  return splittedInlist;
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:34,代码来源:QueryEntitiesAction.java

示例5: getTweetByOwnerId

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<Tweet> getTweetByOwnerId(String ownerId){
	
	DetachedCriteria dcr = DetachedCriteria.forClass(User.class, "follower");
	dcr.createAlias("follower.following", "following");
	dcr.add(Restrictions.eq("follower.id", ownerId));
	dcr.setProjection(Projections.property("following.id"));
	
	Criteria cr = getSession().createCriteria(Tweet.class, "tweets");
	
	Disjunction res = Restrictions.disjunction();
	res.add(Restrictions.eq("ownerId", ownerId));
	res.add(Subqueries.propertyIn("tweets.ownerId", dcr));
	
	cr.add(res);		
	return cr.list();
}
 
开发者ID:boyusun,项目名称:MiniTwitter,代码行数:18,代码来源:TweetDAOImpl.java

示例6: getDatumJunction

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
private Junction getDatumJunction(AdvancedSampleSearchBean searchBean) {
	// if AND and more than one type of datum, don't use junction
	if (searchBean.getCharacterizationLogicalOperator().equals("and")
			&& searchBean.getDatumTypeCount() > 1) {
		return null;
	}
	Disjunction datumDisjunction = Restrictions.disjunction();
	Conjunction datumConjunction = Restrictions.conjunction();
	for (CharacterizationQueryBean charQuery : searchBean
			.getCharacterizationQueries()) {
		Criterion datumCrit = getDatumCriterion(charQuery);
		if (datumCrit != null) {
			datumDisjunction.add(datumCrit);
			if (searchBean.getDatumTypeCount() == 1) {
				datumConjunction.add(datumCrit);
			}
		}
	}
	// default to or if only one query
	Junction junction = (searchBean.getCharacterizationLogicalOperator()
			.equals("or") || searchBean.getCharacterizationQueries().size() == 1) ? datumDisjunction
			: datumConjunction;
	return junction;
}
 
开发者ID:NCIP,项目名称:cananolab,代码行数:25,代码来源:AdvancedSampleServiceHelper.java

示例7: getPointOfContactDisjunctionPerQuery

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
private Disjunction getPointOfContactDisjunctionPerQuery(
		SampleQueryBean query, String pocAlias, String otherPOCAlias) {
	String pocCritStrs[] = null;
	if (StringUtils.isEmpty(otherPOCAlias)) {
		pocCritStrs = new String[] { pocAlias + "lastName",
				pocAlias + "firstName", "organization.name" };
	} else {
		pocCritStrs = new String[] { pocAlias + "lastName",
				pocAlias + "firstName", "organization.name",
				otherPOCAlias + "lastName", otherPOCAlias + "firstName",
				"otherOrg.name" };
	}
	TextMatchMode nameMatchMode = null;
	if (query.getOperand().equals("equals")) {
		nameMatchMode = new TextMatchMode(query.getName());
	} else if (query.getOperand().equals(Constants.STRING_OPERAND_CONTAINS)) {
		nameMatchMode = new TextMatchMode("*" + query.getName() + "*");
	}
	Disjunction pocDisjunction = Restrictions.disjunction();
	for (String critStr : pocCritStrs) {
		Criterion pocCrit = Restrictions.ilike(critStr, nameMatchMode
				.getUpdatedText(), nameMatchMode.getMatchMode());
		pocDisjunction.add(pocCrit);
	}
	return pocDisjunction;
}
 
开发者ID:NCIP,项目名称:cananolab,代码行数:27,代码来源:AdvancedSampleServiceHelper.java

示例8: getSampleNameJunction

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
 * Get the sample name junction used in sample queries
 * 
 * @param searchBean
 * @param crit
 * @return
 * @throws Exception
 */
private Junction getSampleNameJunction(AdvancedSampleSearchBean searchBean)
		throws Exception {
	Disjunction sampleDisjunction = Restrictions.disjunction();
	Conjunction sampleConjunction = Restrictions.conjunction();
	for (SampleQueryBean query : searchBean.getSampleQueries()) {
		if (query.getNameType().equals("sample name")) {
			Criterion sampleNameCrit = getSampleNameCriterion(query);
			if (sampleNameCrit != null) {
				sampleDisjunction.add(sampleNameCrit);
				sampleConjunction.add(sampleNameCrit);
			}
		}
	}
	Junction junction = (searchBean.getSampleLogicalOperator().equals("or") || searchBean
			.getSampleQueries().size() == 1) ? sampleDisjunction
			: sampleConjunction;
	return junction;
}
 
开发者ID:NCIP,项目名称:cananolab,代码行数:27,代码来源:AdvancedSampleServiceHelper.java

示例9: getRolesByNamesAndOrg

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
 * Return the roles with the given names in the organisation if present
 * 
 * @author Adelina
 * 
 * @param organisationId
 * @param count
 * @param name 
 * @return List<Role> 
 */
public List<Role> getRolesByNamesAndOrg(Integer organisationId, int count, String... name) {
	
	logger.debug("getRoleByNameAndOrg DAO IMPL - START - ");	
	for(int i = 0; i < count; i++) {
		logger.debug("name = ".concat(name[i]));
	}
   	logger.debug("organisationId = ".concat(String.valueOf(organisationId)));
   	
   	DetachedCriteria dc = DetachedCriteria.forEntityName(IModelConstant.roleForListingEntity);

   	Disjunction disjunction = Restrictions.disjunction();
	for(int i = 0; i < count; i++) {		    
	    disjunction.add(Restrictions.eq("name", name[i]));
	}
	dc.add(disjunction);
   	dc.add(Restrictions.eq("organisation.organisationId", organisationId));
	List<Role> roles = getHibernateTemplate().findByCriteria(dc);
   				
	return roles;				
}
 
开发者ID:CodeSphere,项目名称:termitaria,代码行数:31,代码来源:DaoRoleImpl.java

示例10: setSeriesSecurityGroups

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
private static void setSeriesSecurityGroups(DetachedCriteria criteria, List<String> securityGroups)
{
	Conjunction con = new Conjunction();

	if (securityGroups != null && securityGroups.size() != 0)
	{
		Disjunction disjunction = Restrictions.disjunction();
		disjunction.add(Restrictions.isNull("securityGroup"));
		disjunction.add(Restrictions.in("securityGroup", securityGroups));
		con.add(disjunction);
		criteria.add(con);
	}
	else
	{
		criteria.add(Restrictions.isNull("securityGroup"));
	}
}
 
开发者ID:NCIP,项目名称:national-biomedical-image-archive,代码行数:18,代码来源:GeneralSeriesDAOImpl.java

示例11: getUsersById

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
@Override
public List<User> getUsersById(Collection<Integer> usersId) {
    if (usersId.isEmpty()) {
        return new ArrayList<>();
    }
    final Disjunction disjunction = Restrictions.disjunction();
    for (final Integer id : usersId) {
        disjunction.add(Property.forName(Constants.ID).eq(id));
    }
    final DetachedCriteria detachedCriteria = DetachedCriteria.forClass(User.class)
            .add(disjunction);
    return dao.getAllBy(detachedCriteria);
}
 
开发者ID:music-for-all,项目名称:music-for-all-application,代码行数:14,代码来源:UserServiceImpl.java

示例12: getRolesForBatchInstance

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
 * API for getting roles for the specified batch instance.
 * @param batchInstanceId String
 * @return Set<String>
 */
@Override
public Set<String> getRolesForBatchInstance(String batchInstanceId) {
	Set<String> grps = new HashSet<String>();
	final DetachedCriteria criteria = criteria();
	final Disjunction disjunction = Restrictions.disjunction();
	disjunction.add(Restrictions.eq(BATCH_INSTANCE_ID, batchInstanceId));
	criteria.add(disjunction);
	final List<BatchInstanceGroups> batchClassGroups = find(criteria);
	for (final BatchInstanceGroups batchInstanceGroup : batchClassGroups) {
		grps.add(batchInstanceGroup.getGroupName());
	}
	return grps;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:19,代码来源:BatchInstanceGroupsDaoImpl.java

示例13: getBatchInstanceIdentifiersExceptUserRoles

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
 * API for getting the batch instance identifiers except provided user roles.
 * 
 * @param userRoles Set<String>
 * @return Set<String>
 */
@Override
public Set<String> getBatchInstanceIdentifiersExceptUserRoles(final Set<String> userRoles) {
	Set<String> batchInstanceIdentifiers = new HashSet<String>();
	final DetachedCriteria criteria = criteria();
	final Disjunction disjunction = Restrictions.disjunction();
	disjunction.add(Restrictions.not(Restrictions.in(GROUP_NAME, userRoles)));
	criteria.add(disjunction);
	final List<BatchInstanceGroups> batchInstanceGroups = find(criteria);
	for (final BatchInstanceGroups batchInstanceGroup : batchInstanceGroups) {
		batchInstanceIdentifiers.add(batchInstanceGroup.getBatchInstanceIdentifier());
	}
	return batchInstanceIdentifiers;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:20,代码来源:BatchInstanceGroupsDaoImpl.java

示例14: getBatchClassIdentifierForUserRoles

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
 * API for getting the batch class identifiers having the user roles.
 * @param userRoles Set<String>
 * @param includeDeleted boolean
 * @return Set<String>
 */
@Override
public Set<String> getBatchClassIdentifierForUserRoles(Set<String> userRoles, boolean includeDeleted) {
	boolean isValid = true;
	if (userRoles == null || userRoles.size() == 0) {
		isValid = false;
	}
	Set<String> batchClassIdentifiers = null;

	// New version of fetching.
	if (isValid) {
		batchClassIdentifiers = new LinkedHashSet<String>();
		DetachedCriteria criteria = criteria();
		Disjunction disjunction = Restrictions.disjunction();
		for (String userRole : userRoles) {
			disjunction.add(Restrictions.eq(GROUP_NAME, userRole));
		}
		criteria.add(disjunction);
		criteria.addOrder(Order.asc(BATCH_CLASS));
		List<BatchClassGroups> batchClassGroups = find(criteria);
		for (BatchClassGroups batchClassGroup : batchClassGroups) {
			if(includeDeleted) {
				batchClassIdentifiers.add(batchClassGroup.getBatchClass().getIdentifier());	
			} else {
				if(!batchClassGroup.getBatchClass().isDeleted()) {
					batchClassIdentifiers.add(batchClassGroup.getBatchClass().getIdentifier());
				}
			}
		}
	}
	return batchClassIdentifiers;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:38,代码来源:BatchClassGroupsDaoImpl.java

示例15: getAttributeSearch

import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
protected DetachedCriteria getAttributeSearch(DetachedCriteria ciCrit) {
	if (getTextMatch() != null) {
		DetachedCriteria attribute = DetachedCriteria.forClass(BasicAttribute.class);
		//ciCrit.setProjection();
		Disjunction orAttribute = Restrictions.disjunction();
		boolean orAttributeAdded = false;
		
		if (isTextMatchAlias()) {
			orAttribute.add(Expression.ilike("alias", getTextMatch(), MatchMode.ANYWHERE));
			orAttributeAdded = true;
			
		}
		
		if (isTextMatchDescription()) {
			orAttribute.add(Expression.ilike("description", getTextMatch(), MatchMode.ANYWHERE));
			orAttributeAdded = true;
	
		}
		
		if (isTextMatchValue()) {
			orAttribute.add(Expression.ilike("valueAsString", getTextMatch(), MatchMode.ANYWHERE));
			orAttributeAdded = true;
		}
		if (orAttributeAdded) {
			DetachedCriteria ciIdCriteria = ciCrit.setProjection(Projections.property("longId"));
			DetachedCriteria attributeCriteira = DetachedCriteria.forClass(BasicAttribute.class);
			attributeCriteira.add(Property.forName("ownerId").in(ciIdCriteria));
			attributeCriteira.add(orAttribute);
			
			return(attributeCriteira);
		}
	}
	return(null);
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:35,代码来源:OneCMDBExpression.java


注:本文中的org.hibernate.criterion.Disjunction.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。