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:com.sshdemo.common.report.manage.service.TextReportService.java

@Override
public Long updTextReportParameter(Long textReportId, Parameter parameter) throws BaseException {
    if (textReportId == null || textReportId.intValue() == 0)
        throw new BaseException("", "????");
    TextReport text = textReportDAO.get(textReportId);
    if (text == null)
        throw new BaseException("", "???");

    parameter = ParameterSetValueUtil.setParametersValue(parameter);

    Set<Parameter> parameters = text.getParameters();
    parameters.remove(parameter);//from  w ww  .j a v  a2 s .co  m
    parameters.add(parameter);
    text.setParameters(parameters);

    textReportDAO.merge(text);

    return parameter.getId();
}

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

public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de asociaciones con params {}", params);
    if (params == null) {
        params = new HashMap<>();
    }/*from ww  w.  j a v  a2s . com*/

    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(Asociacion.class);
    Criteria countCriteria = currentSession().createCriteria(Asociacion.class);

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

    if (params.containsKey("filtro")) {
        String filtro = (String) params.get("filtro");
        filtro = "%" + filtro + "%";
        Disjunction propiedades = Restrictions.disjunction();
        propiedades.add(Restrictions.ilike("nombre", filtro));
        propiedades.add(Restrictions.ilike("nombreCompleto", filtro));
        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("asociaciones", 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.ColportorDao.java

public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de colportor con params {}", params);
    if (params == null) {
        params = new HashMap<>();
    }//from  w  w w .  ja v a 2s  .  c  o m

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

    if (params.containsKey(Constantes.CONTAINSKEY_PAGINA)) {
        Long pagina = (Long) params.get(Constantes.CONTAINSKEY_PAGINA);
        Long offset = (pagina - 1) * (Integer) params.get(Constantes.CONTAINSKEY_MAX);
        params.put(Constantes.CONTAINSKEY_OFFSET, offset.intValue());
    }

    if (!params.containsKey(Constantes.CONTAINSKEY_OFFSET)) {
        params.put(Constantes.CONTAINSKEY_OFFSET, 0);
    }
    Criteria criteria = currentSession().createCriteria(Colportor.class);
    Criteria countCriteria = currentSession().createCriteria(Colportor.class);

    if (params.containsKey(Constantes.CONTAINSKEY_FILTRO)) {
        String filtro = (String) params.get(Constantes.CONTAINSKEY_FILTRO);
        filtro = "%" + filtro + "%";
        Disjunction propiedades = Restrictions.disjunction();
        propiedades.add(Restrictions.ilike("status", filtro));
        propiedades.add(Restrictions.ilike("clave", filtro));
        criteria.add(propiedades);
        countCriteria.add(propiedades);
    }

    if (params.containsKey(Constantes.CONTAINSKEY_ORDER)) {
        String campo = (String) params.get(Constantes.CONTAINSKEY_ORDER);
        if (params.get(Constantes.CONTAINSKEY_SORT).equals(Constantes.CONTAINSKEY_DESC)) {
            criteria.addOrder(Order.desc(campo));
        } else {
            criteria.addOrder(Order.asc(campo));
        }
    }

    if (!params.containsKey(Constantes.CONTAINSKEY_REPORTE)) {
        criteria.setFirstResult((Integer) params.get(Constantes.CONTAINSKEY_OFFSET));
        criteria.setMaxResults((Integer) params.get(Constantes.CONTAINSKEY_MAX));
    }
    params.put(Constantes.CONTAINSKEY_COLPORTORES, criteria.list());

    countCriteria.setProjection(Projections.rowCount());
    params.put(Constantes.CONTAINSKEY_CANTIDAD, (Long) countCriteria.list().get(0));

    return params;
}

From source file:mx.edu.um.mateo.contabilidad.dao.impl.EjercicioDaoHibernate.java

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

    if (params.containsKey("organizacion")) {
        criteria.add(Restrictions.eq("id.organizacion.id", params.get("organizacion")));
        countCriteria.add(Restrictions.eq("id.organizacion.id", params.get("organizacion")));
    }

    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("id.idEjercicio", 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));
        }
    } else {
        criteria.addOrder(Order.desc("id.idEjercicio"));
    }

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

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

    return params;
}

From source file:com.abssh.util.Page.java

/**
 * ??,??1,11.// w  ww  . j a  v a2  s  .  c o m
 */
public void setPageNo(final Long pageNo) {
    if (pageNo == null || pageNo.intValue() < 1) {
        this.pageNo = 1;
    } else {
        this.pageNo = pageNo.intValue();
    }
}

From source file:com.farmafene.aurius.impl.DatoRegistroTypeBlob.java

/**
 * {@inheritDoc}/*from  ww w  .j a v  a 2s  .  c o m*/
 * 
 * @see com.farmafene.aurius.impl.DatoRegistroAbstract#validaValor(java.lang.
 *      Object)
 */
@Override
protected void validaValor(byte[] bytes) throws AuriusValidationException {
    if (null != bytes) {
        Long longMax = this.getLongitudMaxima();
        Long longMin = this.getLongitudMinima();

        if (null != longMax && bytes.length > longMax.intValue()) {
            throw new AuriusValidationException();
        } else if (null != longMin && bytes.length < longMin.intValue()) {
            throw new AuriusValidationException();
        }
    }
}

From source file:edu.scripps.fl.pubchem.app.assayxml.ReadDocumentStage.java

@Override
public void process(Object obj) throws StageException {
    Long id = (Long) obj;
    try {/*from  w  ww .  j  av  a2  s .  com*/
        int count = ac.incrementAndGet();
        if (!onHoldAidSet.contains(id)) { // no file when on hold
            InputStream is = PubChemFactory.getInstance().getXmlDescr(getDataUrl(), id.intValue());
            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            DOMReader reader = new DOMReader();
            Document doc = reader.read(builder.parse(is));
            is.close();
            emit(doc);
        }
        if (count % 1000 == 0)
            log.debug(String.format("Read %s Bioassay XML documents", count));
    } catch (Exception ex) {
        throw new StageException(this, ex);
    }
}

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

public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de uniones con params {}", params);
    if (params == null) {
        params = new HashMap<>();
    }/*from   w  w w .jav  a  2  s.c  o m*/
    if (!params.containsKey(Constantes.CONTAINSKEY_MAX)) {
        params.put(Constantes.CONTAINSKEY_MAX, 10);
    } else {
        params.put(Constantes.CONTAINSKEY_MAX, Math.min((Integer) params.get(Constantes.CONTAINSKEY_MAX), 100));
    }
    if (params.containsKey(Constantes.CONTAINSKEY_PAGINA)) {
        Long pagina = (Long) params.get(Constantes.CONTAINSKEY_PAGINA);
        Long offset = (pagina - 1) * (Integer) params.get(Constantes.CONTAINSKEY_MAX);
        params.put(Constantes.CONTAINSKEY_OFFSET, offset.intValue());
    }
    if (!params.containsKey(Constantes.CONTAINSKEY_OFFSET)) {
        params.put(Constantes.CONTAINSKEY_OFFSET, 0);
    }
    Criteria criteria = currentSession().createCriteria(Union.class);
    Criteria countCriteria = currentSession().createCriteria(Union.class);

    if (params.containsKey(Constantes.CONTAINSKEY_FILTRO)) {
        String filtro = (String) params.get(Constantes.CONTAINSKEY_FILTRO);
        Disjunction propiedades = Restrictions.disjunction();
        propiedades.add(Restrictions.ilike("nombre", filtro, MatchMode.ANYWHERE));
        criteria.add(propiedades);
        countCriteria.add(propiedades);
    }
    if (params.containsKey(Constantes.CONTAINSKEY_ORDER)) {
        String campo = (String) params.get(Constantes.CONTAINSKEY_ORDER);
        if (params.get(Constantes.CONTAINSKEY_SORT).equals(Constantes.CONTAINSKEY_DESC)) {
            criteria.addOrder(Order.desc(campo));
        } else {
            criteria.addOrder(Order.asc(campo));
        }
    }
    if (!params.containsKey(Constantes.CONTAINSKEY_REPORTE)) {
        criteria.setFirstResult((Integer) params.get(Constantes.CONTAINSKEY_OFFSET));
        criteria.setMaxResults((Integer) params.get(Constantes.CONTAINSKEY_MAX));
    }
    params.put(Constantes.CONTAINSKEY_UNIONES, criteria.list());

    countCriteria.setProjection(Projections.rowCount());
    params.put(Constantes.CONTAINSKEY_CANTIDAD, (Long) countCriteria.list().get(0));

    return params;
}

From source file:com.emental.mindraider.ui.outline.OutlineSorterJPanel.java

public OutlineSorterJPanel() {
    setLayout(new BorderLayout());

    // table with archived concepts (title)
    // let table model to load discarded concepts itself
    tableModel = new SorterTableModel();
    table = new JTable(tableModel);
    table.getSelectionModel().addListSelectionListener(new SorterListSelectionListener(table, tableModel));
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setFillsViewportHeight(true);//from   w w w  . j a va2  s  . c  o m
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.getColumnModel().getColumn(COLUMN_NAME).setPreferredWidth(150);
    table.getColumnModel().getColumn(COLUMN_ANNOTATION).setPreferredWidth(220);
    table.getColumnModel().getColumn(COLUMN_CREATED).setPreferredWidth(60);
    table.getColumnModel().getColumn(COLUMN_MODIFIED).setPreferredWidth(60);
    table.getColumnModel().getColumn(COLUMN_REVISION).setPreferredWidth(35);

    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
    table.setRowSorter(sorter);
    sorter.setComparator(COLUMN_REVISION, new Comparator<Long>() {
        @Override
        public int compare(Long o1, Long o2) {
            return o2.intValue() - o1.intValue();
        }
    });
    final Comparator<String> timestampComparator = new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            if (OutlineTreeInstance.getCreatedTimestampFromHtml(o2) > OutlineTreeInstance
                    .getCreatedTimestampFromHtml(o1)) {
                return 1;
            } else {
                if (OutlineTreeInstance.getCreatedTimestampFromHtml(o2) == OutlineTreeInstance
                        .getCreatedTimestampFromHtml(o1)) {
                    return 0;
                } else {
                    return -1;
                }
            }
        }
    };
    sorter.setComparator(COLUMN_MODIFIED, timestampComparator);
    sorter.setComparator(COLUMN_CREATED, timestampComparator);

    JScrollPane scroll = new JScrollPane(table);
    scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    add(scroll, BorderLayout.CENTER);
}

From source file:mx.edu.um.mateo.inventario.dao.impl.AlmacenDaoHibernate.java

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

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

    return params;
}