List of usage examples for org.hibernate.criterion Restrictions eqProperty
public static PropertyExpression eqProperty(String propertyName, String otherPropertyName)
From source file:com.ibm.asset.trails.dao.jpa.VSoftwareLparDAOJpa.java
public void paginatedList(DisplayTagList data, Account account, ReconSetting reconSetting, int startIndex, int objectsPerPage, String sort, String dir) { Criteria criteria = getHibernateSessionCriteria(); criteria.createAlias("hardwareLpar", "hl") .createAlias("hl.hardwareLparEff", "hle", CriteriaSpecification.LEFT_JOIN) .createAlias("hl.hardware", "h").createAlias("h.machineType", "mt") .createAlias("installedSoftwares", "is") .createAlias("is.scheduleF", "sf", CriteriaSpecification.LEFT_JOIN) .createAlias("sf.scope", "scope", CriteriaSpecification.LEFT_JOIN) .createAlias("is.softwareLpar", "sl").createAlias("is.alert", "aus") .createAlias("aus.reconcile", "r", CriteriaSpecification.LEFT_JOIN) .createAlias("r.usedLicenses", "ul", CriteriaSpecification.LEFT_JOIN) .createAlias("ul.license", "license", CriteriaSpecification.LEFT_JOIN) .createAlias("r.reconcileType", "rt", CriteriaSpecification.LEFT_JOIN) .createAlias("is.software", "sw") .createAlias("sw.manufacturer", "mf", CriteriaSpecification.LEFT_JOIN) .add(Restrictions.eq("account", account)); if (reconSetting.getReconcileType() != null) { criteria.add(Restrictions.eq("rt.id", reconSetting.getReconcileType())); }/*from w w w . j a v a2 s .c o m*/ if (StringUtils.isNotBlank(reconSetting.getAlertStatus())) { boolean open = false; if (reconSetting.getAlertStatus().equals("OPEN")) { open = true; criteria.add(Restrictions.eq("aus.open", open)); } else { criteria.add(Restrictions.and(Restrictions.eq("aus.open", false), Restrictions.eqProperty("is.id", "r.installedSoftware.id"))); } } else { criteria.add(Restrictions.or(Restrictions.eq("aus.open", true), Restrictions.and(Restrictions.eq("aus.open", false), Restrictions.eqProperty("is.id", "r.installedSoftware.id")))); } if (null != reconSetting.getAlertFrom() && reconSetting.getAlertFrom().intValue() >= 0) { criteria.add(Restrictions.ge("aus.alertAge", reconSetting.getAlertFrom())); } if (null != reconSetting.getAlertTo() && reconSetting.getAlertTo().intValue() >= 0) { criteria.add(Restrictions.le("aus.alertAge", reconSetting.getAlertTo())); } if (StringUtils.isNotBlank(reconSetting.getAssigned())) { if (reconSetting.getAssigned().equals("Assigned")) { criteria.add(Restrictions.ne("aus.remoteUser", "STAGING")); } if (reconSetting.getAssigned().equals("Unassigned")) { criteria.add(Restrictions.eq("aus.remoteUser", "STAGING")); } } if (StringUtils.isNotBlank(reconSetting.getAssignee())) { criteria.add(Restrictions.eq("aus.remoteUser", reconSetting.getAssignee()).ignoreCase()); } if (StringUtils.isNotBlank(reconSetting.getOwner())) { if (reconSetting.getOwner().equalsIgnoreCase("IBM")) { criteria.add(Restrictions.eq("h.owner", reconSetting.getOwner()).ignoreCase()); } else if (reconSetting.getOwner().equalsIgnoreCase("Customer")) { ArrayList<String> lalOwner = new ArrayList<String>(); lalOwner.add("CUST"); lalOwner.add("CUSTO"); criteria.add(Restrictions.in("h.owner", lalOwner)); } } // I'm not sure why the heck we aren't just getting a list of strings? if (reconSetting.getCountries().length > 0) { List<String> list = new ArrayList<String>(); for (int i = 0; i < reconSetting.getCountries().length; i++) { if (StringUtils.isNotBlank(reconSetting.getCountries()[i])) { list.add(reconSetting.getCountries()[i].toUpperCase()); } } if (list.size() > 0) { criteria.add(Restrictions.in("h.country", list)); } } if (reconSetting.getNames().length > 0) { List<String> list = new ArrayList<String>(); for (int i = 0; i < reconSetting.getNames().length; i++) { if (StringUtils.isNotBlank(reconSetting.getNames()[i])) { list.add(reconSetting.getNames()[i].toUpperCase()); } } if (list.size() > 0) { criteria.add(Restrictions.in("hl.name", list)); } } if (reconSetting.getSwcmIDs().length > 0) { List<String> list = new ArrayList<String>(); for (int i = 0; i < reconSetting.getSwcmIDs().length; i++) { if (StringUtils.isNotBlank(reconSetting.getSwcmIDs()[i])) { list.add(reconSetting.getSwcmIDs()[i].toUpperCase()); } } if (list.size() > 0) { criteria.add(Restrictions.in("license.extSrcId", list)); } } if (reconSetting.getSerialNumbers().length > 0) { List<String> list = new ArrayList<String>(); for (int i = 0; i < reconSetting.getSerialNumbers().length; i++) { if (StringUtils.isNotBlank(reconSetting.getSerialNumbers()[i])) { list.add(reconSetting.getSerialNumbers()[i].toUpperCase()); } } if (list.size() > 0) { criteria.add(Restrictions.in("h.serial", list)); } } if (reconSetting.getProductInfoNames().length > 0) { List<String> list = new ArrayList<String>(); for (int i = 0; i < reconSetting.getProductInfoNames().length; i++) { if (StringUtils.isNotBlank(reconSetting.getProductInfoNames()[i])) { list.add(reconSetting.getProductInfoNames()[i]); } } if (list.size() > 0) { criteria.add(Restrictions.in("sw.softwareName", list)); } } if (StringUtils.isNotBlank(reconSetting.getScope())) { if ("Not specified".equalsIgnoreCase(reconSetting.getScope())) { criteria.add(Restrictions.isNull("scope.description")); } else { criteria.add(Restrictions.eq("scope.description", reconSetting.getScope())); } } if (StringUtils.isNotBlank(reconSetting.getFinanResp())) { if ("Not Specified".trim().equalsIgnoreCase(reconSetting.getFinanResp())) { criteria.add(Restrictions.isNull("sf.SWFinanceResp")); } else { criteria.add(Restrictions.eq("sf.SWFinanceResp", reconSetting.getFinanResp())); } } criteria.setProjection(Projections.projectionList().add(Projections.property("aus.id").as("alertId")) .add(Projections.property("r.id").as("reconcileId")) .add(Projections.property("aus.alertAge").as("alertAgeI")) .add(Projections.property("is.id").as("installedSoftwareId")) .add(Projections.property("hl.name").as("hostname")) .add(Projections.property("sl.name").as("sl_hostname")) .add(Projections.property("hl.spla").as("spla")) .add(Projections.property("hl.sysplex").as("sysplex")) .add(Projections.property("hl.internetIccFlag").as("internetIccFlag")) .add(Projections.property("h.serial").as("serial")) .add(Projections.property("h.country").as("country")) .add(Projections.property("h.owner").as("owner")) .add(Projections.property("h.mastProcessorType").as("mastProcessorType")) .add(Projections.property("h.processorManufacturer").as("processorManufacturer")) .add(Projections.property("h.mastProcessorModel").as("mastProcessorModel")) .add(Projections.property("h.nbrCoresPerChip").as("nbrCoresPerChip")) .add(Projections.property("h.nbrOfChipsMax").as("nbrOfChipsMax")) .add(Projections.property("h.cpuLsprMips").as("cpuLsprMips")) .add(Projections.property("h.cpuIfl").as("cpuIFL")) .add(Projections.property("hl.partLsprMips").as("partLsprMips")) .add(Projections.property("h.cpuGartnerMips").as("cpuGartnerMips")) .add(Projections.property("hl.partGartnerMips").as("partGartnerMips")) .add(Projections.property("hl.effectiveThreads").as("effectiveThreads")) .add(Projections.property("hl.vcpu").as("vcpu")).add(Projections.property("h.cpuMsu").as("cpuMsu")) .add(Projections.property("hl.partMsu").as("partMsu")) .add(Projections.property("hl.serverType").as("lparServerType")) .add(Projections.property("h.shared").as("shared")) .add(Projections.property("h.multi_tenant").as("multi_tenant")) .add(Projections.property("mt.type").as("assetType")) .add(Projections.property("mt.name").as("assetName")) .add(Projections.property("h.hardwareStatus").as("hardwareStatus")) .add(Projections.property("hl.lparStatus").as("lparStatus")) .add(Projections.property("processorCount").as("processorCount")) .add(Projections.property("sw.softwareName").as("productInfoName")) .add(Projections.property("sw.softwareId").as("productInfoId")) .add(Projections.property("sw.pid").as("pid")) .add(Projections.property("mf.manufacturerName").as("manufacturerName")) .add(Projections.property("rt.name").as("reconcileTypeName")) .add(Projections.property("rt.id").as("reconcileTypeId")) .add(Projections.property("aus.remoteUser").as("assignee")) .add(Projections.property("h.processorCount").as("hardwareProcessorCount")) .add(Projections.property("hle.processorCount").as("hwLparEffProcessorCount")) .add(Projections.property("hl.osType").as("osType")) .add(Projections.property("hle.status").as("hwLparEffProcessorStatus")) .add(Projections.property("h.chips").as("chips"))); criteria.setResultTransformer(new AliasToBeanResultTransformer(ReconWorkspace.class)); criteria.addOrder(Order.desc("aus.open")); if (dir.equalsIgnoreCase("ASC")) { criteria.addOrder(Order.asc(sort)); } else { criteria.addOrder(Order.desc(sort)); } ArrayList<ReconWorkspace> list = new ArrayList<ReconWorkspace>(); ScrollableResults itemCursor = criteria.scroll(); itemCursor.beforeFirst(); if (itemCursor.next()) { itemCursor.scroll(startIndex); int i = 0; while (objectsPerPage > i++) { ReconWorkspace rw = (ReconWorkspace) itemCursor.get(0); if (null != rw.getHwLparEffProcessorStatus() && rw.getHwLparEffProcessorStatus().equalsIgnoreCase("INACTIVE")) { rw.setHwLparEffProcessorCount(0); } list.add(rw); if (!itemCursor.next()) break; } data.setList(list); itemCursor.last(); data.setFullListSize(itemCursor.getRowNumber() + 1); itemCursor.close(); addSchedulef2List(account, data.getList()); } else { data.setList(null); data.setFullListSize(0); itemCursor.close(); } }
From source file:com.qcadoo.model.api.search.SearchRestrictions.java
License:Open Source License
/** * Creates criterion which checks if field is equal to other field. * /* w ww. ja va 2 s. c om*/ * @param field * field * @param otherField * other field * @return criterion */ public static SearchCriterion eqField(final String field, final String otherField) { return new SearchCriterionImpl(Restrictions.eqProperty(field, otherField)); }
From source file:com.square.core.dao.implementations.ActionDaoImplementation.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//w w w . jav a 2s.c o m public List<Action> rechercherActionsSources(CritereActionSyntheseDto critereActionSyntheseDto) { final Criteria criteria = createCriteria(Action.class); // Critere de la personne criteria.createAlias("actionAffectation", "actionAffectationAlias"); criteria.add( Restrictions.eq("actionAffectationAlias.personne.id", critereActionSyntheseDto.getIdPersonne())); // Critere action source : l'action source doit etre null ou rattache une autre personne // (pb des actions sur personnes morales dont la source est une action sur personne physique) criteria.createAlias("actionSource", "actionSourceAlias", CriteriaSpecification.LEFT_JOIN); criteria.createAlias("actionSourceAlias.actionAffectation", "actionSourceAffectationAlias", CriteriaSpecification.LEFT_JOIN); final Junction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.isNull("actionSource")); disjunction.add(Restrictions.not(Restrictions.eqProperty("actionSourceAffectationAlias.personne.id", "actionAffectationAlias.personne.id"))); criteria.add(disjunction); // Critere sur les opportunits if (critereActionSyntheseDto.getIdOpportunite() != null) { criteria.add(Restrictions.eq("actionAffectationAlias.opportunite.id", critereActionSyntheseDto.getIdOpportunite())); } // Critre sur la date d'effet if (critereActionSyntheseDto.getFiltrerDateCreation() != null && critereActionSyntheseDto.getFiltrerDateCreation()) { criteria.add(Restrictions.le("dateCreation", Calendar.getInstance())); } criteria.add(Restrictions.eq("supprime", false)); // Ordre criteria.addOrder(Order.desc(CHAMP_DATE)); return criteria.list(); }
From source file:com.ut.tekir.finance.ChequeChangeLastStatusBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(Cheque.class); crit.createAlias("this.history", "history"); if (isNotEmpty(filterModel.getReferenceNo())) { crit.add(Restrictions.eq("referenceNo", filterModel.getReferenceNo())); }/*from ww w . ja va 2s .c om*/ if (isNotEmpty(filterModel.getBankName())) { crit.add(Restrictions.like("bankName", filterModel.getBankName() + "%")); } if (isNotEmpty(filterModel.getBankBranch())) { crit.add(Restrictions.like("bankBranch", filterModel.getBankBranch() + "%")); } if (filterModel.getContact() != null) { crit.add(Restrictions.eq("contact", filterModel.getContact())); } if (isNotEmpty(filterModel.getChequeOwner())) { crit.add(Restrictions.like("chequeOwner", filterModel.getChequeOwner() + "%")); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("history.date", filterModel.getBeginDate())); } if (filterModel.getLastStatus() != null) { crit.add(Restrictions.eq("lastStatus", filterModel.getLastStatus())); crit.add(Restrictions.ne("previousStatus", filterModel.getLastStatus())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("history.date", filterModel.getEndDate())); } if (getIsClientCheque() != null) { crit.add(Restrictions.eq("clientCheque", getIsClientCheque())); } crit.add(Restrictions.eqProperty("history.status", "this.lastStatus")); return crit; }
From source file:com.ut.tekir.finance.ChequeSuggestionBean.java
License:LGPL
@SuppressWarnings("unchecked") public List<Cheque> selectChequeList() { HibernateSessionProxy session = (HibernateSessionProxy) entityManager.getDelegate(); DetachedCriteria crit = DetachedCriteria.forClass(Cheque.class); //TODO: projection saglanmali, embedded money nesnesi sorun cikariyor // crit.forClass(Money.class, "money"); // crit.setProjection(Projections.projectionList() // .add(Projections.property("id"), "id") // .add(Projections.property("maturityDate"), "maturityDate") // .add(Projections.property("referenceNo"), "referenceNo") // .add(Projections.property("bankName"), "bankName") // .add(Projections.property("bankBranch"), "bankBranch") // .add(Projections.property("accountNo"), "accountNo") // .add(Projections.property("chequeOwner"), "chequeOwner") // .add(Projections.property("contact"), "contact") // .add(Projections.property("lastStatus"), "lastStatus") // .add(Projections.property("previousStatus"), "previousStatus") // .add(Projections.property("serialNo"), "serialNo")); // //from ww w.jav a 2 s .co m // crit.setResultTransformer(Transformers.aliasToBean(Cheque.class)); if (getHistoryBeginDate() != null || getHistoryEndDate() != null) { crit.createAlias("history", "history"); if (getHistoryBeginDate() != null) { crit.add(Restrictions.ge("history.date", getHistoryBeginDate())); } if (getHistoryEndDate() != null) { crit.add(Restrictions.le("history.date", getHistoryEndDate())); } crit.add(Restrictions.eqProperty("history.status", "this.lastStatus")); } if (getReferenceNo() != null && getReferenceNo().length() > 0) { crit.add(Restrictions.ilike("referenceNo", getReferenceNo(), MatchMode.ANYWHERE)); } if (getSerialNo() != null && getSerialNo().length() > 0) { crit.add(Restrictions.ilike("serialNo", getSerialNo(), MatchMode.START)); } if (getBeginDate() != null) { crit.add(Restrictions.ge("maturityDate", getBeginDate())); } if (getEndDate() != null) { crit.add(Restrictions.le("maturityDate", getEndDate())); } if (getBankName() != null && getBankName().length() > 0) { crit.add(Restrictions.ilike("bankName", getBankName(), MatchMode.START)); } if (getBankBranch() != null && getBankBranch().length() > 0) { crit.add(Restrictions.ilike("bankBranch", getBankBranch(), MatchMode.START)); } if (getChequeOwner() != null && getChequeOwner().length() > 0) { crit.add(Restrictions.ilike("chequeOwner", getChequeOwner(), MatchMode.START)); } if (getBankBranch() != null && getBankBranch().length() > 0) { crit.add(Restrictions.ilike("bankBranch", getBankBranch(), MatchMode.START)); } if (getBankAccount() != null && getBankAccount().length() > 0) { crit.add(Restrictions.ilike("bankAccount", getBankAccount(), MatchMode.START)); } if (getBankAccountId() != null) { crit.add(Restrictions.eq("bankAccountId", getBankAccountId().getId())); } if (getContact() != null) { crit.add(Restrictions.eq("contact", getContact())); } if (lastStatus != null) { crit.add(Restrictions.eq("lastStatus", lastStatus)); } else { List<ChequeStatus> possibleStatus = null; if (clientCheque != null && clientCheque.equals(Boolean.TRUE)) { possibleStatus = possibleStatusForCustomer(targetStatus); } else { possibleStatus = possibleStatusForFirm(targetStatus); } if (possibleStatus != null) { crit.add(Restrictions.in("lastStatus", possibleStatus)); } } crit.add(Restrictions.eq("clientCheque", getClientCheque())); Criteria ecrit = crit.getExecutableCriteria(session); chequeList = ecrit.list(); return chequeList; }
From source file:com.ut.tekir.finance.PromissoryChangeLastStatusBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(PromissoryNote.class); crit.createAlias("this.history", "history"); if (isNotEmpty(filterModel.getReferenceNo())) { crit.add(Restrictions.eq("referenceNo", filterModel.getReferenceNo())); }/* w w w.j a va 2s. c om*/ if (filterModel.getContact() != null) { crit.add(Restrictions.eq("contact", filterModel.getContact())); } if (isNotEmpty(filterModel.getPromissorynoteOwner())) { crit.add(Restrictions.like("promissorynoteOwner", filterModel.getPromissorynoteOwner() + "%")); } if (filterModel.getBeginDate() != null) { crit.add(Restrictions.ge("history.date", filterModel.getBeginDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("history.date", filterModel.getEndDate())); } if (filterModel.getLastStatus() != null) { crit.add(Restrictions.eq("lastStatus", filterModel.getLastStatus())); crit.add(Restrictions.ne("previousStatus", filterModel.getLastStatus())); } if (getIsClientPromissory() != null) { crit.add(Restrictions.eq("clientPromissoryNote", getIsClientPromissory())); } crit.add(Restrictions.eqProperty("history.status", "this.lastStatus")); return crit; }
From source file:com.ut.tekir.finance.PromissorySuggestionBean.java
License:LGPL
@SuppressWarnings("unchecked") public List<PromissoryNote> selectPromissoryList() { HibernateSessionProxy session = (HibernateSessionProxy) entityManager.getDelegate(); DetachedCriteria crit = DetachedCriteria.forClass(PromissoryNote.class); //TODO: projection saglanmali, embedded money nesnesi sorun cikariyor // crit.setProjection(Projections.projectionList() // .add(Projections.property("id"), "id") // .add(Projections.property("maturityDate"), "maturityDate") // .add(Projections.property("referenceNo"), "referenceNo") // .add(Projections.property("paymentPlace"), "paymentPlace") // .add(Projections.property("promissorynoteOwner"), "promissorynoteOwner") // .add(Projections.property("clientPromissoryNote"), "clientPromissoryNote") // .add(Projections.property("contact"), "contact") // .add(Projections.property("lastStatus"), "lastStatus") // .add(Projections.property("previousStatus"), "previousStatus") // .add(Projections.property("serialNo"), "serialNo")); // /*from w w w . j a v a 2 s . c o m*/ // crit.setResultTransformer(Transformers.aliasToBean(PromissoryNote.class)); if (getHistoryBeginDate() != null || getHistoryEndDate() != null) { crit.createAlias("history", "history"); if (getHistoryBeginDate() != null) { crit.add(Restrictions.ge("history.date", getHistoryBeginDate())); } if (getHistoryEndDate() != null) { crit.add(Restrictions.le("history.date", getHistoryEndDate())); } crit.add(Restrictions.eqProperty("history.status", "this.lastStatus")); } if (getReferenceNo() != null && getReferenceNo().length() > 0) { crit.add(Restrictions.ilike("referenceNo", getReferenceNo(), MatchMode.ANYWHERE)); } if (getSerialNo() != null && getSerialNo().length() > 0) { crit.add(Restrictions.ilike("serialNo", getSerialNo(), MatchMode.START)); } if (getBeginDate() != null) { crit.add(Restrictions.ge("maturityDate", getBeginDate())); } if (getEndDate() != null) { crit.add(Restrictions.le("maturityDate", getEndDate())); } if (getPaymentPlace() != null && getPaymentPlace().length() > 0) { crit.add(Restrictions.ilike("paymentPlace", getPaymentPlace(), MatchMode.START)); } if (getPromissorynoteOwner() != null && getPromissorynoteOwner().length() > 0) { crit.add(Restrictions.ilike("promissorynoteOwner", getPromissorynoteOwner(), MatchMode.START)); } if (getContact() != null) { crit.add(Restrictions.eq("contact", getContact())); } if (lastStatus != null) { crit.add(Restrictions.eq("lastStatus", lastStatus)); } else { List<ChequeStatus> possibleStatus = null; if (clientPromissory != null && clientPromissory.equals(Boolean.TRUE)) { possibleStatus = possibleStatusForCustomer(targetStatus); } else { possibleStatus = possibleStatusForFirm(targetStatus); } if (possibleStatus != null) { crit.add(Restrictions.in("lastStatus", possibleStatus)); } } crit.add(Restrictions.eq("clientPromissoryNote", getClientPromissory())); Criteria ecrit = crit.getExecutableCriteria(session); promissoryList = ecrit.list(); return promissoryList; }
From source file:de.decidr.model.commands.user.GetAdministratedWorkflowModelsCommand.java
License:Apache License
@SuppressWarnings("unchecked") @Override//from ww w .j a va 2 s .co m public void transactionAllowed(TransactionStartedEvent evt) throws TransactionException { result = null; // does the user exist? returning an empty list might be ambigous. String hql = "select u.id from User u where u.id = :userId"; Object id = evt.getSession().createQuery(hql).setLong("userId", getUserId()).setMaxResults(1) .uniqueResult(); if (id == null) { throw new EntityNotFoundException(User.class, getUserId()); } /* * Criteria that represent the following query: * * "from WorkflowModel w where w.tenant.id = DEFAULT_TENANT_ID or * (exists(from UserAdministratesWorkflowModel rel where * rel.workflowModel = w and rel.user.id = :userId) or w.tenant.admin.id * = :userId) or exists (from SystemSettings s where s.admin.id = * :userId))" */ PaginatingCriteria criteria = new PaginatingCriteria(WorkflowModel.class, "m", evt.getSession()); /* * A user administers a workflow model if there's an explicit * relationship. */ DetachedCriteria explicitWorkflowAdminCriteria = DetachedCriteria .forClass(UserAdministratesWorkflowModel.class, "rel"); explicitWorkflowAdminCriteria .add(Restrictions.conjunction().add(Restrictions.eqProperty("rel.workflowModel.id", "m.id")) .add(Restrictions.eq("rel.user.id", getUserId()))); /* * A user administers *any* workflow model if he is the super admin. */ DetachedCriteria superAdminCriteria = DetachedCriteria.forClass(SystemSettings.class, "s"); superAdminCriteria.add(Restrictions.eq("s.superAdmin.id", getUserId())); /* * Workaround for Hibernate issue HHH-993: Criteria subquery without * projection fails throwing NullPointerException. * * Additionally, Mysql doesn't seem to like aliases in EXISTS * subqueries, so we have to explicitly specify "*" */ explicitWorkflowAdminCriteria.setProjection(Projections.sqlProjection("*", new String[0], new Type[0])); superAdminCriteria.setProjection(Projections.sqlProjection("*", new String[0], new Type[0])); /* * Finally, a user administers a workflow model if he is the tenant * admin of the tenant that owns the model. We now add each criterion to * a disjuncion. */ criteria.createAlias("tenant", "t"); Disjunction allAdministrationCriteria = Restrictions.disjunction(); allAdministrationCriteria.add(Subqueries.exists(superAdminCriteria)); allAdministrationCriteria.add(Subqueries.exists(explicitWorkflowAdminCriteria)); allAdministrationCriteria.add(Restrictions.eq("t.admin.id", getUserId())); /* * Everyone is a workflow admin for models within the default tenant. */ criteria.add(Restrictions.disjunction().add(allAdministrationCriteria) .add(Restrictions.eq("m.tenant.id", DecidrGlobals.DEFAULT_TENANT_ID))); Filters.apply(criteria, filters, paginator); criteria.setResultTransformer(CriteriaSpecification.ROOT_ENTITY); result = criteria.list(); }
From source file:de.decidr.model.commands.workflowmodel.WorkflowModelCommand.java
License:Apache License
/** * Fetches the current deployed version of the workflow model. * /* www . j ava2 s . c o m*/ * @param session * current Hibernate Session * @return the current deployed version of the workflow model or null if * there is no current deplyoed version. */ public DeployedWorkflowModel fetchCurrentDeployedWorkflowModel(Session session) { Criteria crit = session.createCriteria(DeployedWorkflowModel.class, "dwm"); crit.createCriteria("originalWorkflowModel", "owm") .add(Restrictions.eqProperty("owm.version", "dwm.version")); crit.add(Restrictions.eq("originalWorkflowModel.id", getWorkflowModelId())); return (DeployedWorkflowModel) crit.setResultTransformer(CriteriaSpecification.ROOT_ENTITY).uniqueResult(); }
From source file:de.decidr.model.filters.StartableWorkflowModelFilter.java
License:Apache License
/** * {@inheritDoc}/* w ww . j a v a 2 s . com*/ */ public void apply(Criteria criteria) { DetachedCriteria exists = DetachedCriteria.forClass(StartableWorkflowModelView.class, "startableFilter"); exists.add(Restrictions.eqProperty(exists.getAlias() + ".id", criteria.getAlias() + ".id")); /* * Workaround for Hibernate issue HHH-993: Criteria subquery without * projection fails throwing NullPointerException. * * Additionally, Mysql doesn't seem to like aliases in EXISTS * subqueries, so we have to explicitly specify "*" */ exists.setProjection(Projections.sqlProjection("*", new String[0], new Type[0])); criteria.add(Subqueries.exists(exists)); }