Example usage for java.lang Long intValue

List of usage examples for java.lang Long intValue

Introduction

In this page you can find the example usage for java.lang Long intValue.

Prototype

public int intValue() 

Source Link

Document

Returns the value of this Long as an int after a narrowing primitive conversion.

Usage

From source file:ru.codemine.ccms.dao.TaskDAOImpl.java

@Override
public Integer getOpenTaskCount() {
    Query query = getSession().createQuery("SELECT COUNT(*) FROM Task t WHERE t.status = :statusNew");
    query.setParameter("statusNew", Task.Status.NEW);
    Long count = (Long) query.uniqueResult();

    return count == null ? 0 : count.intValue();
}

From source file:com.safasoft.treeweb.dao.FfSubmitJobDAO.java

/**
 * Get amount of job records based on given user
 * @param userName//  ww  w .j  ava 2s .com
 * @return amount of job
 */
public int countByUser(String userName) {
    Long longVal = (Long) sessionFactory.getCurrentSession()
            .createQuery("select count(*) from " + domainClass.getName() + " x " + "where userName = :userName")
            .setString("userName", userName).list().get(0);
    return longVal.intValue();
}

From source file:ru.codemine.ccms.dao.TaskDAOImpl.java

@Override
public Integer getPerfTaskCount(Employee performer) {
    Query query = getSession().createQuery(
            "SELECT COUNT(*) FROM Task t WHERE :performer IN ELEMENTS(t.performers) AND t.status != :statusClosed");
    query.setParameter("performer", performer);
    query.setParameter("statusClosed", Task.Status.CLOSED);
    Long count = (Long) query.uniqueResult();

    return count == null ? 0 : count.intValue();
}

From source file:com.beyond.common.base.AbstractBaseDao.java

@SuppressWarnings("unchecked")
protected PageInfo<T> getObjectPage(PageInfo<T> pageInfo, String countListStatementName,
        String getListStatementName, int pageNum, int pageSize, Map<String, Object> paramObject) {
    Long total = (Long) getSqlMapClientTemplate().queryForObject(countListStatementName, paramObject);
    pageNum = PageInfoUtil.getInstance().dealOutofMaxPageNum(total.intValue(), pageSize, pageNum);
    List<T> result = null;//from w w w.  j a  va2s . c om
    if (total != null && total.longValue() > 0) {
        paramObject.put(PAGE_FROM, (pageNum - 1) * pageSize);
        paramObject.put(PAGE_TO, pageNum * pageSize);
        result = getSqlMapClientTemplate().queryForList(getListStatementName, paramObject);
    }
    pageInfo.setResult(result);
    pageInfo.setTotalRowSize(total);
    pageInfo.setCurrentPage(pageNum);
    pageInfo.setPerPageSize(pageSize);
    return pageInfo;
}

From source file:ru.codemine.ccms.dao.TaskDAOImpl.java

@Override
public Integer getClosedTasksByPerformerCount(Employee performer, LocalDate startDate, LocalDate endDate) {
    Query query = getSession().createQuery(
            "SELECT COUNT(*) FROM Task t WHERE :performer IN ELEMENTS(t.performers) AND t.closeTime >= :startDate AND t.closeTime <= :endDate");
    query.setParameter("performer", performer);
    query.setDate("startDate", startDate.toDate());
    query.setDate("endDate", endDate.toDate());

    Long count = (Long) query.uniqueResult();

    return count == null ? 0 : count.intValue();
}

From source file:ru.codemine.ccms.dao.TaskDAOImpl.java

@Override
public Integer getOverdueTasksByPerformerCount(Employee performer, LocalDate startDate, LocalDate endDate) {
    Query query = getSession().createQuery(
            "SELECT COUNT(*) FROM Task t WHERE :performer IN ELEMENTS(t.performers) AND t.closeTime >= :startDate AND t.closeTime <= :endDate AND t.deadline < t.closeTime");
    query.setParameter("performer", performer);
    query.setDate("startDate", startDate.toDate());
    query.setDate("endDate", endDate.toDate());

    Long count = (Long) query.uniqueResult();

    return count == null ? 0 : count.intValue();
}

From source file:com.bizintelapps.bugtracker.dao.impl.GenericDaoImpl.java

private Integer executeQueryReturnInt(final String jpql, final Object... params) throws DataAccessException {
    Query query = entityManager.createQuery(jpql);
    int i = 1;/*from w  w  w  . jav  a 2  s .c  o m*/
    for (Object param : params) {
        query.setParameter(i++, param);
    }
    Long result = (Long) query.getSingleResult();
    try {
        return result.intValue();
    } catch (RuntimeException re) {
        log.debug(re);
        return null;
    }
}

From source file:mx.edu.um.mateo.general.dao.impl.ClienteDaoHibernate.java

@Override
@Transactional(readOnly = true)/*www  .  ja va2 s.c  o  m*/
public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de clientes con params {}", params);
    if (params == null) {
        params = new HashMap<>();
    }

    if (!params.containsKey("max")) {
        params.put("max", 10);
    } else {
        params.put("max", Math.min((Integer) params.get("max"), 100));
    }

    if (params.containsKey("pagina")) {
        Long pagina = (Long) params.get("pagina");
        Long offset = (pagina - 1) * (Integer) params.get("max");
        params.put("offset", offset.intValue());
    }

    if (!params.containsKey("offset")) {
        params.put("offset", 0);
    }
    Criteria criteria = currentSession().createCriteria(Cliente.class);
    Criteria countCriteria = currentSession().createCriteria(Cliente.class);

    if (params.containsKey("empresa")) {
        criteria.createCriteria("empresa").add(Restrictions.idEq(params.get("empresa")));
        countCriteria.createCriteria("empresa").add(Restrictions.idEq(params.get("empresa")));
    }

    if (params.containsKey("tipoCliente")) {
        criteria.createCriteria("tipoCliente").add(Restrictions.idEq(params.get("tipoCliente")));
        countCriteria.createCriteria("tipoCliente").add(Restrictions.idEq(params.get("tipoCliente")));
    }

    if (params.containsKey("filtro")) {
        String filtro = (String) params.get("filtro");
        Disjunction propiedades = Restrictions.disjunction();
        propiedades.add(Restrictions.ilike("nombre", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("nombreCompleto", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("rfc", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("correo", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("contacto", filtro, MatchMode.ANYWHERE));
        criteria.add(propiedades);
        countCriteria.add(propiedades);
    }

    if (params.containsKey("order")) {
        String campo = (String) params.get("order");
        if (params.get("sort").equals("desc")) {
            criteria.addOrder(Order.desc(campo));
        } else {
            criteria.addOrder(Order.asc(campo));
        }
    }

    if (!params.containsKey("reporte")) {
        criteria.setFirstResult((Integer) params.get("offset"));
        criteria.setMaxResults((Integer) params.get("max"));
    }
    params.put("clientes", criteria.list());

    countCriteria.setProjection(Projections.rowCount());
    params.put("cantidad", (Long) countCriteria.list().get(0));

    return params;
}

From source file:ru.codemine.ccms.dao.SalesDAOImpl.java

@Override
public Integer getPassabilityValueByPeriod(Shop shop, LocalDate startDate, LocalDate endDate) {
    Query query = getSession().createQuery("SELECT SUM(Sm.passabilityTotal) " + "FROM SalesMeta Sm "
            + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate");
    query.setInteger("shopid", shop.getId());
    query.setDate("startdate", startDate.toDate());
    query.setDate("enddate", endDate.toDate());

    Long result = (Long) query.uniqueResult();

    return result == null ? 0 : result.intValue();
}

From source file:ru.codemine.ccms.dao.SalesDAOImpl.java

@Override
public Integer getCqcountValueByPeriod(Shop shop, LocalDate startDate, LocalDate endDate) {
    Query query = getSession().createQuery("SELECT SUM(Sm.chequeCountTotal) " + "FROM SalesMeta Sm "
            + "WHERE Sm.shop.id = :shopid " + "AND Sm.startDate >= :startdate " + "AND Sm.endDate <= :enddate");
    query.setInteger("shopid", shop.getId());
    query.setDate("startdate", startDate.toDate());
    query.setDate("enddate", endDate.toDate());

    Long result = (Long) query.uniqueResult();

    return result == null ? 0 : result.intValue();
}