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:mx.edu.um.mateo.inventario.dao.impl.TipoProductoDaoHibernate.java

@Override
@Transactional(readOnly = true)/*www . ja  va 2s. c o  m*/
public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de tipos de producto 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(TipoProducto.class);
    Criteria countCriteria = currentSession().createCriteria(TipoProducto.class);

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

    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("descripcion", 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("tiposDeProducto", criteria.list());

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

    return params;
}

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

@Override
@Transactional(readOnly = true)/*from w  ww.  ja  v a  2  s. c  om*/
public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de TipoClientes 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(TipoCliente.class);
    Criteria countCriteria = currentSession().createCriteria(TipoCliente.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("filtro")) {
        String filtro = (String) params.get("filtro");
        Disjunction propiedades = Restrictions.disjunction();
        propiedades.add(Restrictions.ilike("nombre", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("descripcion", 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("tiposDeCliente", criteria.list());

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

    return params;
}

From source file:org.kuali.mobility.push.service.DeviceServiceImplTest.java

@Test
public void testCountDevices() {
    Long count = getService().countDevices();
    assertEquals("Failed to find proper count of devices.", 6, count.intValue());
}

From source file:net.jradius.handler.PacketHandlerChain.java

public boolean handle(JRadiusRequest request) throws Exception {
    Catalog catalog = getCatalog();//from  w  ww .j  av a  2 s .  c om
    if (catalog != null) {
        JRCommand command;

        if (request.getType() == JRadiusServer.JRADIUS_accounting) {
            RadiusPacket req = request.getRequestPacket();
            Long i = (Long) req.getAttributeValue(AttributeDictionary.ACCT_STATUS_TYPE);
            if (i != null) {
                String com = "other_accounting";
                switch (i.intValue()) {
                case AccountingRequest.ACCT_STATUS_START:
                    com = "start_accounting";
                    break;
                case AccountingRequest.ACCT_STATUS_STOP:
                    com = "stop_accounting";
                    break;
                case AccountingRequest.ACCT_STATUS_INTERIM:
                    com = "interim_accounting";
                    break;
                case AccountingRequest.ACCT_STATUS_ACCOUNTING_ON:
                    com = "accounting_on";
                    break;
                case AccountingRequest.ACCT_STATUS_ACCOUNTING_OFF:
                    com = "accounting_off";
                    break;
                }
                command = (JRCommand) catalog.getCommand(com);
                if (command != null)
                    return execute(command, request);
            }
        }

        command = (JRCommand) catalog.getCommand(request.getTypeString());
        return execute(command, request);
    }
    return true;
}

From source file:com.sshdemo.common.report.manage.service.ChartReportService.java

@Override
public Long updChartReportParameter(Long chartReportId, Parameter parameter) throws BaseException {
    if (chartReportId == null || chartReportId.intValue() == 0)
        throw new BaseException("", "????");
    ChartReport chart = chartReportDAO.get(chartReportId);
    if (chart == null)
        throw new BaseException("", "???");

    parameter = ParameterSetValueUtil.setParametersValue(parameter);

    Set<Parameter> parameters = chart.getParameters();
    parameters.remove(parameter);/*from www  .  j a  v a  2  s. c  o m*/
    parameters.add(parameter);
    chart.setParameters(parameters);

    chartReportDAO.merge(chart);

    return parameter.getId();
}

From source file:com.insoul.ti.controller.FinanceController.java

@RequestMapping("/list")
public ModelAndView list(@Valid ProjectListRequest request, BindingResult result) {
    ModelAndView mv = createModelView(FINANCE_LIST, request);
    PageQuery query = request.init().getQuery();
    FinancingCriteria criteria = new FinancingCriteria();
    criteria.setLimit(query.getPage_size());
    criteria.setOffset(Long.valueOf(query.getIndex()).intValue());
    criteria.setStatus(new String[] { request.getStatus() });
    criteria.setProjectName(request.getName());
    criteria.setUserId(request.getId());
    criteria.setBeused((byte) 2);
    List<Financing> list = financingDAO.queryFinancing(criteria);
    Long count = financingDAO.countFinancing(criteria);
    query.setCount((count == null || count <= 0L) ? 0 : count.intValue());
    mv.addObject("query", query);
    mv.addObject("financingList", list);
    mv.addObject("success", CollectionUtils.isNotEmpty(list));
    mv.addObject("req", request);
    return mv;//from   w  w w.  ja va2  s  . co  m
}

From source file:at.tuwien.minimee.migration.engines.MonitorEngineWinPslist.java

@Override
protected String prepareCommand(ToolConfig config, String params, String inputFile, String outputFile,
        long time) throws Exception {

    prepareWorkingDirectory(time);//w w w.j  a  va  2  s. c  om

    // we calculate the timeout for the migration process
    File file = new File(inputFile);
    // we calculate the cycle (winTop has a counter that needs 6 units: we set 150000 as max)
    //            Long timeout = Math.max((file.length() / (1000000))*6, 150000);

    //so small time only for testing
    Long timeout = Math.max((file.length() / (1000000)) * 6, 100000);
    String cycles = timeout.intValue() + "";

    String monitoringCmd = prepareMonitoringCommand(time, cycles);

    String command = monitoringCmd + " " + config.getTool().getExecutablePath() + " \"" + config.getParams()
            + " " + inputFile;

    // SPECIAL STUFF, UNLIKELY TO REMAIN HERE:
    if (!config.isNoOutFile()) {
        command = command + " " + outputFile;
    }

    command += "\"";

    log.debug("TOP WINDOWS MONITORING COMMAND: " + command);
    return command;
}

From source file:com.ar.dev.tierra.api.dao.impl.ChartDAOImpl.java

@SuppressWarnings("unchecked")
@Override/*  www  .  jav a2 s  .co  m*/
public List<Chart> getVentaVendedores(int idVendedor) {
    Calendar calendarInitial = Calendar.getInstance();
    Calendar calendarClosing = Calendar.getInstance();
    calendarInitial.set(Calendar.HOUR_OF_DAY, 0);
    calendarInitial.set(Calendar.MINUTE, 0);
    calendarInitial.set(Calendar.SECOND, 0);
    calendarInitial.set(Calendar.MILLISECOND, 0);
    Date fromDate = calendarInitial.getTime();
    calendarClosing.set(Calendar.HOUR_OF_DAY, 23);
    calendarClosing.set(Calendar.MINUTE, 59);
    calendarClosing.set(Calendar.SECOND, 59);
    calendarClosing.set(Calendar.MILLISECOND, 59);
    Date toDate = calendarClosing.getTime();
    int days = 0;
    List<Chart> chartVenta = new ArrayList<>();
    while (days <= 6) {
        Chart chart = new Chart();
        Criteria facturas = getSession().createCriteria(Factura.class);
        facturas.add(Restrictions.like("estado", "CONFIRMADO"));
        facturas.add(Restrictions.between("fechaCreacion", fromDate, toDate));
        Criteria vendedorFactura = facturas.createCriteria("idVendedor");
        vendedorFactura.add(Restrictions.eq("idUsuario", idVendedor));
        vendedorFactura.setProjection(Projections.rowCount());
        Long counter = (Long) facturas.uniqueResult();
        chart.setValue(counter.intValue());
        chart.setDate(fromDate);
        chartVenta.add(chart);
        calendarInitial.add(Calendar.DAY_OF_MONTH, -1);
        fromDate = calendarInitial.getTime();
        calendarClosing.add(Calendar.DAY_OF_MONTH, -1);
        toDate = calendarClosing.getTime();
        days++;
    }
    return chartVenta;
}

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

@Override
@Transactional(readOnly = true)/*  w ww. j a  v a  2  s. c o  m*/
public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de proveedores 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(Proveedor.class);
    Criteria countCriteria = currentSession().createCriteria(Proveedor.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("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("proveedores", criteria.list());

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

    return params;
}

From source file:mx.edu.um.mateo.rh.dao.impl.CategoriaDaoHibernate.java

/**
 * @see mx.edu.um.mateo.rh.dao.CategoriaDao#lista(java.util.Map) 
 *
 *//*from w  w  w . ja v a  2 s  . c om*/
@Override
public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de categorias 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(Categoria.class)
            .add(Restrictions.eq("status", Constantes.STATUS_ACTIVO));
    Criteria countCriteria = currentSession().createCriteria(Categoria.class)
            .add(Restrictions.eq("status", Constantes.STATUS_ACTIVO));

    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("filtro")) {
        String filtro = (String) params.get("filtro");
        Disjunction propiedades = Restrictions.disjunction();
        propiedades.add(Restrictions.ilike("nombre", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("status", 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(Constantes.CONTAINSKEY_CATEGORIAS, criteria.list());

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

    return params;
}