Example usage for org.hibernate.criterion Restrictions isNotNull

List of usage examples for org.hibernate.criterion Restrictions isNotNull

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions isNotNull.

Prototype

public static Criterion isNotNull(String propertyName) 

Source Link

Document

Apply an "is not null" constraint to the named property

Usage

From source file:com.bluexml.side.Framework.alfresco.jbpm.CustomJBPMEngine.java

License:Open Source License

/**
 * Create process-specific query criteria
 * //from ww  w .j  a  v a 2  s .  c o  m
 * @param root
 * @param query
 * @return
 */
private Criteria createProcessCriteria(Criteria root, WorkflowTaskQuery query) {
    Criteria process = null;

    // process active?
    if (query.isActive() != null) {
        process = root.createCriteria("processInstance");
        if (query.isActive()) {
            process.add(Restrictions.isNull("end"));
        } else {
            process.add(Restrictions.isNotNull("end"));
        }
    }

    // process id
    if (query.getProcessId() != null) {
        process = (process == null) ? root.createCriteria("processInstance") : process;
        process.add(Restrictions.eq("id", getJbpmId(query.getProcessId())));
    }

    // process definition name
    String definitionName = query.getWorkflowDefinitionName();
    if (definitionName != null) {
        definitionName = createLocalId(definitionName);
    }
    if (definitionName == null) {
        QName qName = query.getProcessName();
        definitionName = qName == null ? null : qName.toPrefixString(namespaceService);
    }
    if (definitionName != null) {
        process = (process == null) ? root.createCriteria("processInstance") : process;
        Criteria processDef = process.createCriteria("processDefinition");
        String processName = tenantService.getName(definitionName);
        processDef.add(Restrictions.eq("name", processName));
    }

    return process;
}

From source file:com.cai310.lottery.web.controller.lottery.keno.KenoController.java

/**
 * ?//from ww w  . ja  v  a2 s  . com
 * 
 * @return
 */
public String note() {
    Class<I> cls = kenoService.getIssueDataClass();
    XDetachedCriteria criteria = new XDetachedCriteria(cls);
    if (period != null && !StringUtils.isBlank(period.getPeriodNumber())) {
        criteria.add(Restrictions.like("periodNumber", period.getPeriodNumber(), MatchMode.START));
    }
    criteria.add(Restrictions.gt("state", IssueState.ISSUE_SATE_RESULT));
    criteria.add(Restrictions.isNotNull("results"));
    // criteria.setMaxResults(count);
    criteria.addOrder(Order.desc("id"));
    // zhuhui motify by 2011-05-03 20 30 50  pagesize 20 30 50
    // ??
    if (count > 0) {
        pagination.setPageSize(count);
    }
    pagination = kenoService.findByCriteriaAndPagination(criteria, pagination);

    loadNewsList();

    return "note";
}

From source file:com.cai310.lottery.web.controller.lottery.keno.KenoController.java

/**
 * ?/* www.  j av  a2  s  .c  o m*/
 * 
 * @return
 */
public String result() {
    try {
        Class<I> cls = kenoService.getIssueDataClass();
        DetachedCriteria criteria = DetachedCriteria.forClass(cls);
        criteria.add(Restrictions.isNotNull("results"));
        if (StringUtils.isBlank(resultDate)) {
            resultDate = DateUtil.getTodaySixStr();
        }
        criteria.add(Restrictions.gt("prizeTime", DateUtil.getTodaySixDate(resultDate)));
        criteria.add(
                Restrictions.lt("prizeTime", DateUtil.getNextdaySixDate(DateUtil.getTodaySixDate(resultDate))));
        criteria.addOrder(Order.desc("id"));
        periods = kenoService.findKenoPeriodByCriteria(criteria, null);
        resultDates = DateUtil.getSixList();
        return "result-info";
    } catch (ServiceException e) {
        addActionMessage(e.getMessage());
    } catch (Exception e) {
        addActionMessage(e.getMessage());
        logger.warn(e.getMessage(), e);
    }

    return error();
}

From source file:com.cai310.lottery.web.controller.ticket.then.KenoController.java

public String resultList() {
    Map map = Maps.newHashMap();//from  www.j  a  va 2  s . com
    JsonConfig jsonConfig = new JsonConfig();
    StringBuffer sb = new StringBuffer();
    try {
        // check();
        checkTicket();
        Lottery lotteryType = null;
        if (StringUtils.isNotBlank(wLotteryId)) {
            try {
                lotteryType = Lottery.values()[Integer.valueOf(wLotteryId.trim())];
            } catch (Exception e) {
                throw new WebDataException("12-?");
            }
            if (null == lotteryType) {
                throw new WebDataException("12-?");
            }
        }
        // if (StringUtils.isBlank(start)){
        // throw new WebDataException("9-");
        // }
        // try{
        // Integer.valueOf(start);
        // } catch (Exception e) {
        // throw new WebDataException("9-");
        // }
        // if (StringUtils.isBlank(count)){
        // throw new WebDataException("10-?");
        // }
        // try{
        // Integer.valueOf(count);
        // } catch (Exception e) {
        // throw new WebDataException("10-?");
        // }
        Class<I> cls = this.kenoService.getIssueDataClass();
        DetachedCriteria criteria = DetachedCriteria.forClass(cls);
        criteria.add(Restrictions.gt("state", IssueState.ISSUE_SATE_RESULT));
        if (!"".equals(periodNumber)) {
            criteria.add(Restrictions.eq("periodNumber", periodNumber));
        }
        criteria.add(Restrictions.isNotNull("results"));
        criteria.addOrder(Order.desc("id"));
        List<I> list = null;
        if ("".equals(periodNumber)) {
            list = queryService.findByDetachedCriteria(criteria, 0, 1);
        } else {
            list = queryService.findByDetachedCriteria(criteria);
        }
        List<PeriodDataDTO> resultList = Lists.newArrayList();
        if (null != list && !list.isEmpty()) {
            for (I kenoPeriod : list) {
                if (null != kenoPeriod) {
                    PeriodDataDTO periodDataDTO = new PeriodDataDTO();
                    periodDataDTO.setLotteryType(kenoPeriod.getLotteryType());
                    periodDataDTO.setPeriodId(kenoPeriod.getId());
                    periodDataDTO.setPeriodNumber(kenoPeriod.getPeriodNumber());
                    periodDataDTO.setPeriodTitle(kenoPeriod.getLotteryType().getTitle());
                    periodDataDTO
                            .setPrizeTime(DateUtil.dateToStr(kenoPeriod.getPrizeTime(), "yyyy-MM-dd HH:mm:ss"));
                    periodDataDTO.setResult(kenoPeriod.getResults());
                    resultList.add(periodDataDTO);
                }
            }
        }
        map.put("processId", "0");

        map.put("resultList", resultList);
    } catch (WebDataException e) {
        String processId = "7";
        if (null != e.getMessage() && e.getMessage().indexOf("-") != -1) {
            String temp = e.getMessage().split("-")[0];
            try {
                processId = "" + Integer.valueOf(temp);
            } catch (Exception ex) {
            } // /
            Struts2Utils.setAttribute("errorMsg", e.getMessage());
        } else {
            Struts2Utils.setAttribute("errorMsg", "");
        }
        map.put("processId", processId);

        map.put("errorMsg", e.getMessage());
    } catch (ServiceException e) {
        logger.warn(e.getMessage(), e);
        String processId = "7";
        if (null != e.getMessage() && e.getMessage().indexOf("-") != -1) {
            String temp = e.getMessage().split("-")[0];
            try {
                processId = "" + Integer.valueOf(temp);
            } catch (Exception ex) {
            } // /
            Struts2Utils.setAttribute("errorMsg", e.getMessage());
        } else {
            Struts2Utils.setAttribute("errorMsg", "");
        }
        map.put("processId", processId);

        map.put("errorMsg", e.getMessage());
    } catch (Exception e) {
        logger.warn(e.getMessage(), e);
        String processId = "7";
        if (null != e.getMessage() && e.getMessage().indexOf("-") != -1) {
            String temp = e.getMessage().split("-")[0];
            try {
                processId = "" + Integer.valueOf(temp);
            } catch (Exception ex) {
            } // /
            Struts2Utils.setAttribute("errorMsg", e.getMessage());
        } else {
            Struts2Utils.setAttribute("errorMsg", "");
        }
        map.put("processId", processId);

        map.put("errorMsg", e.getMessage());
    }
    renderJson(map, jsonConfig);
    return null;
}

From source file:com.codefupanda.persistor.util.HibernateUtil.java

License:Open Source License

private static Criterion convert(NullCriteria criteria) {
    if (criteria.isNull()) {
        return Restrictions.isNull(criteria.getProperty());
    }//from  ww w  . j  av  a  2s. c  om
    return Restrictions.isNotNull(criteria.getProperty());
}

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateFindingDao.java

License:Mozilla Public License

@SuppressWarnings("unchecked")
@Override// ww w  . j ava2s .c o  m
public List<Finding> retrieveFindingsByScanIdAndPage(Integer scanId, int page) {
    return getScanIdAndPageCriteria(scanId, page).add(Restrictions.isNotNull("vulnerability")).list();
}

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateGenericVulnerabilityDao.java

License:Mozilla Public License

@Override
public List<GenericVulnerability> retrieveAllWithCustomText() {
    return sessionFactory.getCurrentSession().createCriteria(GenericVulnerability.class)
            .add(Restrictions.isNotNull("customText")).addOrder(Order.asc("id")).list();
}

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateRemoteProviderApplicationDao.java

License:Mozilla Public License

@SuppressWarnings("unchecked")
@Override/*from  w  w  w .  j a  va  2  s.  c om*/
public List<RemoteProviderApplication> retrieveAllWithMappings() {
    return (List<RemoteProviderApplication>) getActiveRPACriteria().add(Restrictions.isNotNull("application"))
            .list();
}

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateScanDao.java

License:Mozilla Public License

@Override
public long getFindingCount(Integer scanId) {
    Long actualFindings = (Long) sessionFactory.getCurrentSession().createCriteria(Finding.class)
            .add(Restrictions.isNotNull("vulnerability")).add(eq("scan.id", scanId)).setProjection(rowCount())
            .uniqueResult();//w  w w  .  ja va 2  s  .  co  m

    Long mappings = (Long) sessionFactory.getCurrentSession().createCriteria(ScanRepeatFindingMap.class)
            .createAlias("finding", "finding").add(Restrictions.isNotNull("finding.vulnerability"))
            .add(eq("scan.id", scanId)).setProjection(rowCount()).uniqueResult();

    return actualFindings + mappings;
}

From source file:com.denimgroup.threadfix.data.dao.hibernate.HibernateScanDao.java

License:Mozilla Public License

@Override
public long getTotalNumberFindingsMergedInScan(Integer scanId) {
    long numUniqueVulnerabilities = (Long) sessionFactory.getCurrentSession().createCriteria(Finding.class)
            .createAlias("vulnerability", "vuln").add(eq("scan.id", scanId))
            .setProjection(Projections.countDistinct("vuln.id")).uniqueResult();

    long numFindingsWithVulnerabilities = (Long) sessionFactory.getCurrentSession()
            .createCriteria(Finding.class).add(Restrictions.isNotNull("vulnerability"))
            .add(eq("scan.id", scanId)).setProjection(rowCount()).uniqueResult();

    return numFindingsWithVulnerabilities - numUniqueVulnerabilities;
}