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.newatlanta.appengine.vfs.provider.GaeFileObject.java

public int getBlockSize() throws FileSystemException {
    Long blockSize = (Long) metadata.getProperty(BLOCK_SIZE);
    if (blockSize == null) {
        throw new FileSystemException("Failed to get block size");
    }// w ww  .  jav a  2s  . com
    return blockSize.intValue();
}

From source file:edu.wustl.geneconnect.postwork.MetadataManager.java

public Path getPath(String path) {
    String[] pathNodes = path.split(PATH_NODES_DELIMITER);
    Long sourceNodeId = new Long(pathNodes[0]);
    Long destinationNodeId = new Long(pathNodes[pathNodes.length - 1]);
    MultiMap pathMap = (MultiMap) masterPathList.get(sourceNodeId.intValue());
    Collection possiblePathsFromSrcToDest = (Collection) pathMap.get(destinationNodeId);

    if (possiblePathsFromSrcToDest != null) {
        Path currentPath = null;/*from   ww  w. j  a  va2  s .  co  m*/
        for (Iterator iter = possiblePathsFromSrcToDest.iterator(); iter.hasNext();) {
            currentPath = (Path) iter.next();
            if (path.equals(currentPath.getCompletePath())) {
                return currentPath;
            }
        }
    }
    return null;
}

From source file:com.taobao.ad.easyschedule.dao.reportjobrt.impl.JPAReportJobRtDAOImpl.java

@Override
public Integer getCount(final int status, final Date startTime, final Date endTime) {
    Long count = (Long) super.getJpaTemplate().execute(new JpaCallback() {

        @Override//  w w w  . j  a v  a  2s. c o m
        public Object doInJpa(EntityManager em) throws PersistenceException {
            return em.createQuery(
                    "select count(*) from es_report_job_rt t where  t.createTime<=?1 and t.createTime >?2 and t.status=?3")
                    .setParameter(1, endTime).setParameter(2, startTime).setParameter(3, status)
                    .getSingleResult();

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

From source file:com.abiquo.server.core.pricing.CostCodeDAO.java

public Collection<CostCode> find(final String filter, final String orderBy, final boolean desc,
        final int offset, int numResults) {
    Criteria criteria = createCriteria(filter, orderBy, desc);

    Long total = count(criteria);

    criteria = createCriteria(filter, orderBy, desc);
    numResults = (int) (numResults != 0 ? numResults : total);
    if (numResults != 0) {
        criteria.setFirstResult(offset * numResults);
        criteria.setMaxResults(numResults);
    }//from w  ww.j  a v a  2s. c o  m

    List<CostCode> result = getResultList(criteria);

    PagedList<CostCode> page = new PagedList<CostCode>();
    page.addAll(result);
    if (numResults != 0) {
        page.setCurrentElement(offset);
        page.setPageSize(numResults);
    }
    page.setTotalResults(total.intValue());

    return page;
}

From source file:com.abiquo.server.core.pricing.CurrencyDAO.java

public Collection<Currency> find(final String filter, final String orderBy, final boolean desc,
        final int offset, int numResults) {
    Criteria criteria = createCriteria(filter, orderBy, desc);

    Long total = count(criteria);

    criteria = createCriteria(filter, orderBy, desc);
    numResults = (int) (numResults != 0 ? numResults : total);
    if (numResults != 0) {
        criteria.setFirstResult(offset * numResults);
        criteria.setMaxResults(numResults);
    }/* w  w w. j a v  a  2  s .  com*/

    List<Currency> result = getResultList(criteria);

    PagedList<Currency> page = new PagedList<Currency>();
    page.addAll(result);
    if (numResults != 0) {
        page.setCurrentElement(offset);
        page.setPageSize(numResults);
    }
    page.setTotalResults(total.intValue());

    return page;
}

From source file:edu.ku.brc.specify.toycode.mexconabio.CollectionStats.java

@Override
public void process(int type, int options) {
    if (loadInstsFromDB) {
        discoverInstCodesAndTotals();/*from  w  w w.  j  ava  2s.  c om*/
    } else {
        loadInstCodesAndtotals();
    }

    for (CollStatSQLDefs csqd : getStatSQL()) {
        if (csqd.getType() == StatType.eTotalNumRecords)
            continue;

        System.out.println(csqd.getType().toString());
        for (Object[] row : BasicSQLUtils.query(dbSrcConn, csqd.getSQL())) {
            //String  instCode = (String)row[0];
            Integer providerId = (Integer) row[0];
            Long count = (Long) row[1];

            CollStatInfo csi = instHashMap.get(providerId);
            if (csi != null) {
                csi.setValue(csqd.getType(), count.intValue());
            } else {
                System.err.println("Couldn't find institution[" + providerId + "]");
            }
        }
    }

    for (CollStatInfo csi : institutions) {
        System.out.println("\n-------------------" + csi.getTitle() + "-------------------");
        for (CollStatSQLDefs csqd : getStatSQL()) {
            System.out.println(
                    String.format("%15s %10d", csqd.getType().toString(), csi.getValue(csqd.getType())));
        }
    }

    saveInstitutions();
}

From source file:com.abiquo.server.core.enterprise.UserDAO.java

public Collection<User> find(final Enterprise enterprise, final Role role, final String filter,
        final String orderBy, final boolean desc, final boolean connected, final Integer offset,
        final Integer numResults) {
    String[] filters = new String[] {};

    if (filter != null) {
        filters = filter.split("\\s+");
    }/*w  w  w .  ja  va 2s . c  o  m*/
    Criteria criteria = createCriteria(enterprise, role, filters, orderBy, desc, connected);
    Long total = count(criteria);
    criteria = createCriteria(enterprise, role, filters, orderBy, desc, connected);

    criteria.setFirstResult(offset * numResults);
    criteria.setMaxResults(numResults);

    List<User> result = getResultList(criteria);

    PagedList<User> page = new PagedList<User>();
    page.addAll(result);
    page.setCurrentElement(offset);
    page.setPageSize(numResults);
    page.setTotalResults(total.intValue());

    return page;
}

From source file:com.clustercontrol.sql.util.JdbcDriverUtil.java

public JdbcDriverUtil() {
    m_log.debug("initializing configuration for sql monitoring...");

    //JDBC??/*  w w w.java2 s  .  c om*/
    Integer count = HinemosPropertyUtil.getHinemosPropertyNum(JDBC_DRIVER, Long.valueOf(3)).intValue();
    m_log.debug("use " + count + " jdbc drivers for sql monitoring.");

    for (int i = 1; i <= count.intValue(); i++) {
        String name = HinemosPropertyUtil.getHinemosPropertyStr(JDBC_DRIVER_NAME + i, "");
        if ("".equals(name)) {
            continue;
        }
        String classname = HinemosPropertyUtil.getHinemosPropertyStr(JDBC_DRIVER_CLASSNAME + i, "");
        if ("".equals(classname)) {
            continue;
        }
        Long loginTimeout = HinemosPropertyUtil.getHinemosPropertyNum(JDBC_DRIVER_LOGINTIMEOUT + i, null);
        if (loginTimeout == null) {
            continue;
        }
        String properties = HinemosPropertyUtil.getHinemosPropertyStr(JDBC_DRIVER_PROPERTIES + i, "");
        // JDBC_DRIVER_PROPERTIES???

        m_log.debug("setting jdbc driver " + i + " : " + name + "(classname = " + classname
                + ", login_timeout = " + loginTimeout + ")");
        jdbcProperties.put(classname,
                new JdbcDriverProperties(classname, name, loginTimeout.intValue(), properties, i));
    }
}

From source file:org.openrepose.filters.clientauth.common.AuthenticationHandler.java

private Integer safeEndpointsTtl() {
    final Long endpointsTtl;

    if (endpointsConfiguration != null) {
        endpointsTtl = endpointsConfiguration.getCacheTimeout();
    } else {//from  www .j av  a  2 s .  c  o  m
        return null;
    }

    if (endpointsTtl >= Integer.MAX_VALUE) {
        return Integer.MAX_VALUE;
    }

    return endpointsTtl.intValue();
}

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

/**
 * Gets a line listing of visits using optional paging.
 * // w  w  w.j  av  a 2  s  .  co m
 * @param <T>
 * @param classifierId
 * @param classifierCategory
 * @param start
 * @param end
 * @param geoType
 * @param geoId
 * @param patientLocation
 * @param pageSize
 * @param pageNum
 * @return
 */
@Secured("ROLE_USER")
@Transactional(readOnly = true)
@RemoteMethod
public <T extends Geography> ListView<CasesDTO> getCases(final AnalysisParametersDTO paramsDTO,
        final Integer offset, final Integer numRows) {

    final AnalysisParameters params = convertParameters(paramsDTO);

    SpatialSecurity.checkAggregateOnlyAccess(getPrincipal(), params.getContainer());

    logger.debug("Getting cases for: {}  [offset: {}, numRows: {}]", new Object[] { params, offset, numRows });

    // Hibernate should cache this
    final Long total = analysisRepository.getCasesCount(params);

    final Long offsetL = offset == null ? null : Long.valueOf(offset.longValue());
    final Long numRowsL = numRows == null ? null : Long.valueOf(numRows.longValue());

    final List<? extends Interaction> interactions = analysisRepository.getCases(params, offsetL, numRowsL);

    logger.debug("Got {} cases.", interactions.size());

    // Build the ListView
    final ListView<CasesDTO> cases = new ListView<CasesDTO>(total.intValue());
    for (final Interaction a : interactions) {

        // Only copy the requested classifications into the view
        final Set<String> clz = new HashSet<String>();

        for (Classification cc : a.getClassifications()) {
            if (params.getClassifications() == null || params.getClassifications().size() == 0
                    || params.getClassifications().contains(cc)) {
                clz.add(cc.getCategory());
            }
        }

        if (params.getClassifications() == null || params.getClassifications().size() == 0 || clz.size() > 0) {
            cases.getItems().add(filterFacility(new CasesDTO(a, clz), a));
        }
        // Evict from the cache since we're done.
        analysisRepository.evict(a);

    }
    return cases;
}