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:br.ufc.deti.ecgweb.domain.exam.EcgService.java

public List<EcgSignalRange> getQrsComplexFromAlgorithm(Long channelId, Long algorithmId) {
    EcgChannel channel = ecgChannelRepository.findOne(channelId);

    List<EcgSignal> signals = channel.getSignals();
    int sampleRate = channel.getEcg().getSampleRate().intValue();

    AbstractComplexQrsAlgorithm algorithm = QrsComplexAlgorithmFactory
            .getComplexQrsAlgorithm(algorithmId.intValue());
    if (algorithm == null) {
        return new ArrayList<EcgSignalRange>();
    }//from ww w . j  av  a  2 s . c  om

    return algorithm.getQrsComplex(signals, sampleRate);
}

From source file:com.hmsinc.epicenter.webapp.remoting.EventService.java

/**
 * @param eventId/*from   w w w .j av a 2 s . c o m*/
 * @param type
 * @return
 */
@Secured("ROLE_USER")
@Transactional(readOnly = true)
@RemoteMethod
public String getEventChart(final Long eventId, final SurveillanceResultType type) {

    Validate.notNull(eventId);

    logger.debug("Loading event id: " + eventId);
    final Anomaly anomaly = surveillanceRepository.load(eventId, Anomaly.class);
    Validate.notNull(anomaly, "Invalid event id " + eventId);

    checkPermission(getPrincipal(), anomaly);

    final SurveillanceResultType actualType = SurveillanceResultType.POPULATION.equals(type)
            ? SurveillanceResultType.ACTUAL
            : type;

    Validate.isTrue(anomaly.getResult().getResults().containsKey(actualType),
            "SurveillanceResult " + actualType + " is not available.");

    TimeSeries ts = anomaly.getResult().getResults().get(actualType);

    if (SurveillanceResultType.POPULATION.equals(type)) {
        final Long population = anomaly.getGeography().getPopulation() == null
                ? geographyRepository.inferPopulation(anomaly.getGeography())
                : anomaly.getGeography().getPopulation();
        Validate.notNull(population,
                "Could not determine population for: " + anomaly.getGeography().getDisplayName());
        ts = populationRateNormalizer.normalize(ts, population.intValue());
    }

    final TimeSeriesChart chart = new TimeSeriesChart();
    chart.setYLabel(type.getDescription());

    chart.add(AnalysisService.getAttributeLabel(anomaly.getAnalysisParameters()), ts,
            ChartColor.VALUE.getColor(), LineStyle.SOLID);

    if (!SurveillanceResultType.POPULATION.equals(type)) {
        chart.add(anomaly.getMethod().getName(), ts, ResultType.THRESHOLD, ChartColor.THRESHOLD.getColor(),
                LineStyle.SOLID);
    }

    final TimeSeries current = queryService.getCurrentTimeSeriesForAnomaly(anomaly, type);

    if (current != null) {
        chart.add("Current Value", current, ChartColor.VALUE.getColor(), LineStyle.DASHED);
    }

    return chartService.getChartURL(chart);

}

From source file:dk.dma.epd.ship.EPDShip.java

/**
 * Returns the maritime id of the own-ship, or null if not defined
 * //  ww w .ja  v a2s. co  m
 * @return the maritime id of the own-ship
 */
@Override
public MaritimeId getMaritimeId() {
    Long mmsi = getMmsi();
    return mmsi != null ? new MmsiId(mmsi.intValue()) : null;
}

From source file:org.openmrs.module.mergeconcepts.api.db.hibernate.HibernateMergeConceptsDAO.java

/**
 * //www  . java  2  s.c  o m
 * @param conceptId
 * @return
 * @should return a count of the obs
 */
@Transactional
@Override
public Integer getObsCount(Integer conceptId) {
    Long obsWithQuestionConceptCount = null;
    Long obsWithAnswerConceptCount = null;

    Query query = sessionFactory.getCurrentSession()
            .createQuery("select count(*) from Obs where concept_id = :conceptId and voided = 0")
            .setParameter("conceptId", conceptId);
    obsWithQuestionConceptCount = (Long) query.uniqueResult();

    Query query2 = sessionFactory.getCurrentSession()
            .createQuery("select count(*) from Obs where value_coded = :conceptId and voided = 0")
            .setParameter("conceptId", conceptId);
    obsWithAnswerConceptCount = (Long) query2.uniqueResult();

    return obsWithQuestionConceptCount.intValue() + obsWithAnswerConceptCount.intValue();
}

From source file:com.abm.mainet.common.service.EmployeeService.java

@Override
public int validateEmployee(String emploginname, Long orgid) {
    int empCounter = 0;
    Long count = employeeJpaRepository.validateEmployee(emploginname, orgid);
    if (count != null) {
        empCounter = count.intValue();
    }//from  w  ww  .  j a  v a 2s. c o  m
    return empCounter;
}

From source file:com.alibaba.otter.node.etl.load.loader.db.DbLoadAction.java

/**
 * ??/*from w  w w . ja  va  2 s  . c o  m*/
 */
public DbLoadContext load(RowBatch rowBatch, WeightController controller) {
    Assert.notNull(rowBatch);
    Identity identity = rowBatch.getIdentity();
    DbLoadContext context = buildContext(identity);

    try {
        List<EventData> datas = rowBatch.getDatas();
        context.setPrepareDatas(datas);
        // ???
        datas = context.getPrepareDatas();
        if (datas == null || datas.size() == 0) {
            logger.info("##no eventdata for load, return");
            return context;
        }

        // ?DbBatchLoaderDateMediaSource??????DbLoadAction?
        // media source???source??
        context.setDataMediaSource(
                ConfigHelper.findDataMedia(context.getPipeline(), datas.get(0).getTableId()).getSource());
        interceptor.prepare(context);
        // ???
        datas = context.getPrepareDatas();
        // ?ddl?ddl/dml????batchcanal
        // ?ddl?ddlbatch??sql
        if (isDdlDatas(datas)) {
            doDdl(context, datas);
        } else {
            WeightBuckets<EventData> buckets = buildWeightBuckets(context, datas);
            List<Long> weights = buckets.weights();
            controller.start(weights);// weights?start
            if (CollectionUtils.isEmpty(datas)) {
                logger.info("##no eventdata for load");
            }
            adjustPoolSize(context); // ?manager?
            adjustConfig(context); // ??
            // ???
            // ??
            for (int i = 0; i < weights.size(); i++) {
                Long weight = weights.get(i);
                controller.await(weight.intValue());
                // ??weight?
                List<EventData> items = buckets.getItems(weight);
                logger.debug("##start load for weight:" + weight);
                // ??

                // ????pkI/U/D?
                items = DbLoadMerger.merge(items);
                // I/U/D?
                DbLoadData loadData = new DbLoadData();
                doBefore(items, context, loadData);
                // load?
                doLoad(context, loadData);
                controller.single(weight.intValue());
                logger.debug("##end load for weight:" + weight);
            }
        }
        interceptor.commit(context);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        interceptor.error(context);
    } catch (Exception e) {
        interceptor.error(context);
        throw new LoadException(e);
    }

    return context;// ??
}

From source file:gov.utah.dts.det.ccl.dao.impl.FacilityDaoImpl.java

@Override
public int searchFacilitiesCount(FacilitySearchCriteria criteria) {
    StringBuilder sb = new StringBuilder(FACILITY_SEARCH_COUNT_QUERY);
    buildSearchQueryString(sb, criteria, null);

    Query query = buildSearchQuery(sb.toString(), criteria);

    Long results = (Long) query.getSingleResult();
    return results.intValue();
}

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

@Override
@Transactional(readOnly = true)/*from  w  w  w  .  ja  v a  2s .  c om*/
public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de salidas 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(Salida.class);
    Criteria countCriteria = currentSession().createCriteria(Salida.class);
    criteria.createAlias("estatus", "est");
    countCriteria.createAlias("estatus", "est");

    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("clienteId")) {
        criteria.createCriteria("cliente").add(Restrictions.idEq(params.get("clienteId")));
        countCriteria.createCriteria("cliente").add(Restrictions.idEq(params.get("clienteId")));
    }

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

    if (params.containsKey("fechaIniciado")) {
        log.debug("Buscando desde {}", params.get("fechaIniciado"));
        criteria.add(Restrictions.ge("fechaCreacion", params.get("fechaIniciado")));
        countCriteria.add(Restrictions.ge("fechaCreacion", params.get("fechaIniciado")));
    } else {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 1);
        log.debug("Asignando busqueda desde {}", calendar.getTime());
        criteria.add(Restrictions.ge("fechaCreacion", calendar.getTime()));
        countCriteria.add(Restrictions.ge("fechaCreacion", calendar.getTime()));
    }

    if (params.containsKey("fechaTerminado")) {
        log.debug("Buscando hasta {}", params.get("fechaTerminado"));
        criteria.add(Restrictions.le("fechaCreacion", params.get("fechaTerminado")));
        countCriteria.add(Restrictions.le("fechaCreacion", params.get("fechaTerminado")));
    }

    if (params.containsKey(Constantes.ABIERTA) || params.containsKey(Constantes.CERRADA)
            || params.containsKey(Constantes.PENDIENTE) || params.containsKey(Constantes.FACTURADA)
            || params.containsKey(Constantes.CANCELADA)) {
        Disjunction propiedades = Restrictions.disjunction();
        if (params.containsKey(Constantes.ABIERTA)) {
            propiedades.add(Restrictions.eq("est.nombre", Constantes.ABIERTA));
        }
        if (params.containsKey(Constantes.CERRADA)) {
            propiedades.add(Restrictions.eq("est.nombre", Constantes.CERRADA));
        }
        if (params.containsKey(Constantes.PENDIENTE)) {
            propiedades.add(Restrictions.eq("est.nombre", Constantes.PENDIENTE));
        }
        if (params.containsKey(Constantes.FACTURADA)) {
            propiedades.add(Restrictions.eq("est.nombre", Constantes.FACTURADA));
        }
        if (params.containsKey(Constantes.CANCELADA)) {
            propiedades.add(Restrictions.eq("est.nombre", Constantes.CANCELADA));
        }
        criteria.add(propiedades);
        countCriteria.add(propiedades);
    }

    if (params.containsKey("filtro")) {
        String filtro = (String) params.get("filtro");
        Disjunction propiedades = Restrictions.disjunction();
        propiedades.add(Restrictions.ilike("folio", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("reporte", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("empleado", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("departamento", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("atendio", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("comentarios", 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 if (!params.containsKey("estatusId")) {
        criteria.addOrder(Order.asc("est.prioridad"));
    }
    criteria.addOrder(Order.desc("fechaModificacion"));

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

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

    return params;
}

From source file:com.macrosoft.core.orm.hibernate.HibernateDao.java

/**
 *  ?hql?:select max("+idClassName+") from "+entity+" where
 * "+idClassName+">0 "/*from   www.  j a v a2  s.  c  o m*/
 * 
 * @param idClassName
 *            id??,id
 * @param entity
 * @return
 */
public Integer getMax(String idClassName, final T entity) {
    Integer result = null;
    List list = null;
    String[] paramArr = null;
    try {
        String hql = "select max(" + idClassName + ") from " + entity.getClass().getName() + " where "
                + idClassName + ">0 ";
        list = this.find(hql, paramArr);
        if (list != null && list.size() > 0) {
            if (list.get(0) instanceof Integer) {
                result = (Integer) list.get(0) + 1;
            } else {
                if (list.get(0) instanceof Long) {
                    Long temp = (Long) list.get(0);
                    result = new Integer(temp.intValue() + 1);
                } else {
                    result = new Integer(1);
                }
            }
        }
    } catch (RuntimeException ex) {
        log.error(ex);
    } finally {
        CollectionUtils.clearList(list);
        list = null;
    }
    return result;
}

From source file:org.geoserver.geofence.gui.server.service.impl.GsUsersManagerServiceImpl.java

public PagingLoadResult<UsernameModel> getGsUsernames(int offset, int limit, boolean full)
        throws ApplicationException {
    int start = offset;

    List<UsernameModel> returnList = new ArrayList<UsernameModel>();

    logger.info("getGsUsernames()");

    if (full) {/* w ww.j av a 2s . c  o m*/
        UsernameModel all_user = new UsernameModel();
        all_user.setUsername("*");
        returnList.add(all_user);
    }

    long usersCount = geofenceRemoteService.getUserAdminService().getCount(null) + 1;

    logger.info("getGsUsernames(): count " + usersCount);

    Long t = new Long(usersCount);

    int page = (start == 0) ? start : (start / limit);

    List<ShortUser> usersList = geofenceRemoteService.getUserAdminService().getList(null, page, limit);

    if (usersList == null) {
        logger.error("No user found on server");
        throw new ApplicationException("No user found on server");
    }

    for (ShortUser user : usersList) {
        UsernameModel username = new UsernameModel(user.getName());
        returnList.add(username);
    }

    logger.info("getGsUsernames(): returning " + returnList.size() + " users");

    return new RpcPageLoadResult<UsernameModel>(returnList, offset, t.intValue());
}