org.hibernate.criterion.Conjunction Java Examples
The following examples show how to use
org.hibernate.criterion.Conjunction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Staff.java From unitime with Apache License 2.0 | 6 votes |
/** * Search staff list for instructors with matching names * @param fname First Name * @param lname Last Name * @return */ public static List findMatchingName(String fname, String lname) { List list = null; if ( (fname==null || fname.trim().length()==0) && (lname==null || lname.trim().length()==0) ) return list; Conjunction and = Restrictions.conjunction(); if (fname!=null && fname.trim().length()>0) and.add(Restrictions.ilike("firstName", fname, MatchMode.START)); if (lname!=null && lname.trim().length()>0) and.add(Restrictions.ilike("lastName", lname, MatchMode.START)); StaffDAO sdao = new StaffDAO(); list = sdao.getSession() .createCriteria(Staff.class) .add(and) .list(); Collections.sort(list); return list; }
Example #2
Source File: MassMailRecipientDaoImpl.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
private static void applyPendingCriteria(org.hibernate.Criteria recipientCriteria, boolean not) { Conjunction criterions = Restrictions.conjunction(); criterions.add(Restrictions.eq("sent", false)); criterions.add(Restrictions.eq("cancelled", false)); Long processMassMailsMax = Settings.getLongNullable(SettingCodes.EMAIL_PROCESS_MASS_MAILS_MAX, Bundle.SETTINGS, DefaultSettings.EMAIL_PROCESS_MASS_MAILS_MAX); if (processMassMailsMax != null) { criterions.add(Restrictions.lt("timesProcessed", processMassMailsMax.longValue())); } if (not) { recipientCriteria.add(Restrictions.not(criterions)); } else { recipientCriteria.add(criterions); } }
Example #3
Source File: AccountResourceImpl.java From authlib-agent with MIT License | 5 votes |
/** * Builds a conjunction by the properties of accounts. * * @param banned null for not query * @param twitchToken null for not query, empty for no token * @return conjunction */ private Conjunction buildAccountsPropertiesConjunction(Boolean banned, String twitchToken) { Conjunction conjunction = conjunction(); if (banned != null) { conjunction.add(eq("banned", banned)); } if (twitchToken != null) { conjunction.add(eqOrIsNull("twitchToken", emptyToNull(twitchToken))); } return conjunction; }
Example #4
Source File: SbiDataSetDAOImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
@Override public List<SbiDataSet> loadPaginatedSearchSbiDataSet(String search, Integer page, Integer item_per_page, IEngUserProfile finalUserProfile, Boolean seeTechnical, Integer[] ids, boolean spatialOnly) { Session session = null; List<SbiDataSet> list = null; try { session = getSession(); Criteria c = session.createCriteria(SbiDataSet.class); c.addOrder(Order.asc("label")); if (page != null && item_per_page != null) { c.setFirstResult((page - 1) * item_per_page); c.setMaxResults(item_per_page); } c.add(Restrictions.like("label", search == null ? "" : search, MatchMode.ANYWHERE).ignoreCase()); c.add(Restrictions.eq("active", true)); if (ids != null && ids.length > 0) { c.add(Restrictions.in("id.dsId", ids)); } if (spatialOnly) { c.add(Restrictions.like("dsMetadata", IFieldMetaData.FieldType.SPATIAL_ATTRIBUTE.toString(), MatchMode.ANYWHERE)); } if (finalUserProfile != null) { logger.debug("For final user take only owned, enterprise and shared"); SbiDomains scopeUserDomain = DAOFactory.getDomainDAO().loadSbiDomainByCodeAndValue("DS_SCOPE", SpagoBIConstants.DS_SCOPE_USER); SbiDomains scopeEnterpriseDomain = DAOFactory.getDomainDAO().loadSbiDomainByCodeAndValue("DS_SCOPE", SpagoBIConstants.DS_SCOPE_ENTERPRISE); SbiDomains scopeTechnicalDomain = DAOFactory.getDomainDAO().loadSbiDomainByCodeAndValue("DS_SCOPE", SpagoBIConstants.DS_SCOPE_TECHNICAL); Disjunction or = Restrictions.disjunction(); // OWNER OR // take owned datasets or.add(Restrictions.eq("owner", ((UserProfile) finalUserProfile).getUserId().toString())); // get categories Set<Domain> categoryList = UserUtilities.getDataSetCategoriesByUser(finalUserProfile); if (categoryList != null) { if (categoryList.size() > 0) { SbiDomains[] categoryArray = new SbiDomains[categoryList.size()]; int i = 0; for (Iterator iterator = categoryList.iterator(); iterator.hasNext();) { Domain domain = (Domain) iterator.next(); String domainCd = domain.getDomainCode(); String valueCd = domain.getValueCd(); SbiDomains sbiDomain = DAOFactory.getDomainDAO().loadSbiDomainByCodeAndValue(domainCd, valueCd); categoryArray[i] = sbiDomain; i++; } // (IN CATEGORY AND (SCOPE=USER OR SCOPE=ENTERPRISE)) OR SCOPE=TECHNICAL Conjunction andCategories = Restrictions.conjunction(); andCategories.add(Restrictions.in("category", categoryArray)); Disjunction orScope = Restrictions.disjunction(); orScope.add(Restrictions.eq("scope", scopeUserDomain)); orScope.add(Restrictions.eq("scope", scopeEnterpriseDomain)); andCategories.add(orScope); if (seeTechnical != null && seeTechnical) { Disjunction orTechnical = Restrictions.disjunction(); orTechnical.add(andCategories); orTechnical.add(Restrictions.eq("scope", scopeTechnicalDomain)); or.add(orTechnical); } else { or.add(andCategories); } } } else { // if no categoryList take also all USER and ENTERPRISE dataset // SCOPE=USER OR SCOPE=ENTERPRISE) or.add(Restrictions.eq("scope", scopeUserDomain)); or.add(Restrictions.eq("scope", scopeEnterpriseDomain)); } c.add(or); } list = c.list(); initialize(list); } catch (Exception e) { throw new SpagoBIDAOException("An unexpected error occured while loading datasets", e); } finally { if (session != null && session.isOpen()) { session.close(); } logger.debug("OUT"); } return list; }
Example #5
Source File: ProfileResourceImpl.java From authlib-agent with MIT License | 4 votes |
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS) @Override public Collection<String> getProfiles(String name, String owner, Boolean banned, String skin, String cape, String elytra, TextureModel model, String serverId) { if (name != null && name.isEmpty()) { throw new BadRequestException("name is empty"); } if (owner != null && owner.isEmpty()) { throw new BadRequestException("owner is empty"); } Session session = sessionFactory.getCurrentSession(); if (serverId == null) { Conjunction conjunction = conjunction(); if (name != null) { conjunction.add(eq("name", name)); } if (owner != null) { conjunction.add(eq("owner.id", owner)); } if (banned != null) { conjunction.add(eq("banned", banned)); } if (skin != null) { conjunction.add(eqOrIsNull("skin", emptyToNull(skin))); } if (cape != null) { conjunction.add(eqOrIsNull("cape", emptyToNull(cape))); } if (elytra != null) { conjunction.add(eqOrIsNull("elytra", emptyToNull(elytra))); } if (model != null) { conjunction.add(eq("textureModel", model)); } @SuppressWarnings("unchecked") List<String> uuids = session.createCriteria(GameProfile.class).add(conjunction).setProjection(property("uuid")).list(); return uuids; } else if (serverId.isEmpty()) { throw new BadRequestException("serverId is empty"); } else { UUID profileUUID = serveridRepo.getOwner(serverId); if (profileUUID != null) { GameProfile profile = session.get(GameProfile.class, profileUUID.toString()); if ((name == null || name.equals(profile.getName())) && (owner == null || owner.equals(profile.getOwner().getId())) && (banned == null || banned.equals(profile.isBanned())) && (skin == null || Objects.equals(emptyToNull(skin), profile.getSkin())) && (cape == null || Objects.equals(emptyToNull(cape), profile.getCape())) && (elytra == null || Objects.equals(emptyToNull(elytra), profile.getElytra())) && (model == null || model.equals(profile.getTextureModel()))) { return Collections.singleton(profile.getUuid()); } } return Collections.emptyList(); } }
Example #6
Source File: AccountResourceImpl.java From authlib-agent with MIT License | 3 votes |
/** * Queries accounts by the properties of themselves in the given range. * * @param banned null for not query * @param twitchToken null for not query, empty for no token * @param range the account range * @return a set of id */ private Collection<String> queryAccountsByPropertiesInRange(Boolean banned, String twitchToken, Set<String> range) { Conjunction propertiesConjunction = buildAccountsPropertiesConjunction(banned, twitchToken); Disjunction accountsDisjunction = disjunction(); range.forEach(id -> accountsDisjunction.add(eq("id", id))); return queryAccountsByCriterion(conjunction(propertiesConjunction, accountsDisjunction)); }