Example usage for java.lang Number longValue

List of usage examples for java.lang Number longValue

Introduction

In this page you can find the example usage for java.lang Number longValue.

Prototype

public abstract long longValue();

Source Link

Document

Returns the value of the specified number as a long .

Usage

From source file:org.mifos.customers.personnel.persistence.LegacyPersonnelDao.java

public boolean getActiveChildrenForLoanOfficer(Short personnelId, Short officeId) throws PersistenceException {
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("userId", personnelId);
    queryParameters.put("officeId", officeId);
    Number count = (Number) execUniqueResultNamedQuery(NamedQueryConstants.GET_ACTIVE_CUSTOMERS_FOR_LO,
            queryParameters);/*  w ww  .j  av  a2  s  .co  m*/
    if (count != null) {
        return count.longValue() > 0;
    }
    return false;
}

From source file:org.mifos.customers.personnel.persistence.LegacyPersonnelDao.java

public boolean isUserExistWithGovernmentId(String governmentId) throws PersistenceException {

    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("GOVT_ID", governmentId);
    Number count = (Number) execUniqueResultNamedQuery(NamedQueryConstants.GET_PERSONNEL_WITH_GOVERNMENTID,
            queryParameters);/* ww  w  . j a  va 2  s  .c  om*/
    if (count != null) {
        return count.longValue() > 0;
    }
    return false;
}

From source file:org.ala.spatial.services.dao.ActionDAOImpl.java

@Override
public void addAction(Action action) {
    logger.info("Adding a new " + action.getType() + " action by " + action.getEmail() + " via "
            + action.getAppid());//from w w  w  .j  a  va 2 s . c o  m
    logger.info("\nlayers: " + action.getService().getLayers() + "\nextra: " + action.getService().getExtra());
    action.setTime(new Timestamp(new Date().getTime()));

    SqlParameterSource sprm = new BeanPropertySqlParameterSource(action.getService());
    Number serviceId = insertService.executeAndReturnKey(sprm);
    action.getService().setId(serviceId.longValue());
    action.setServiceid(serviceId.longValue());

    SqlParameterSource parameters = new BeanPropertySqlParameterSource(action);
    Number actionId = insertAction.executeAndReturnKey(parameters);
    action.setId(actionId.longValue());

}

From source file:org.kalypso.zml.ui.chart.layer.themes.ZmlSinglePointLayer.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override//  w ww .ja  va 2 s  . com
public IDataRange<Double> getDomainRange() {
    if (ArrayUtils.isEmpty(m_descriptors))
        return null;

    Number min = Long.MAX_VALUE;
    Number max = -Long.MAX_VALUE;

    for (final ZmlSinglePointBean bean : m_descriptors) {
        final DateRange dateRange = bean.getDateRange();

        min = Math.min(dateRange.getFrom().getTime(), min.longValue());
        max = Math.max(dateRange.getTo().getTime(), max.longValue());
    }

    return new DataRange(min, max);
}

From source file:com.dsf.dbxtract.cdc.journal.JournalExecutor.java

/**
 * Memorizes the last imported window_id from journal table
 * /*from   w  w w. j a va  2s.c  o m*/
 * @param rows
 */
private void markLastLoaded(CuratorFramework client, List<Map<String, Object>> rows) {

    if (rows == null || rows.isEmpty())
        return;

    Long lastWindowId = 0L;
    for (Map<String, Object> row : rows) {
        Number windowId = (Number) row.get("window_id");
        if (windowId.longValue() > lastWindowId.longValue()) {
            lastWindowId = windowId.longValue();
        }
    }

    String k = getPrefix() + "/lastWindowId";
    String s = lastWindowId.toString();
    try {
        if (client.checkExists().forPath(k) == null)
            client.create().withMode(CreateMode.PERSISTENT).forPath(k);

        client.setData().forPath(k, s.getBytes());

    } catch (Exception e) {
        logger.error("failed to update last window_id", e);
    }
}

From source file:eionet.webq.service.UserFileServiceImpl.java

@Override
public int saveBasedOnWebForm(UserFile file, ProjectFile webForm) throws FileNotAvailableException {
    String emptyInstanceUrl = webForm.getEmptyInstanceUrl();
    // only query if file name is empty
    if (StringUtils.isEmpty(file.getName())) {
        String fn = defaultIfEmpty(webForm.getNewXmlFileName(), "new_form.xml");
        char numDelim = '_';
        char extensionDelim = '.';
        Number userWebFormFileCount = storage.getUserWebFormFileMaxNum(userId(), webForm.getXmlSchema(), fn,
                numDelim, extensionDelim);

        int lastIndexOfDot = fn.lastIndexOf(extensionDelim);
        long fileNum = (userWebFormFileCount != null) ? userWebFormFileCount.longValue() + 1 : 1;
        if (lastIndexOfDot > 0) {
            fn = fn.substring(0, lastIndexOfDot) + numDelim + fileNum + fn.substring(lastIndexOfDot);
        } else {//from   www  .  j a  va2  s  .  c  o m
            fn = fn + numDelim + fileNum;
        }
        file.setName(fn);
    }
    file.setXmlSchema(webForm.getXmlSchema());
    return isNotEmpty(emptyInstanceUrl) ? saveWithContentFromRemoteLocation(file, emptyInstanceUrl)
            : save(file);
}

From source file:org.apache.tajo.storage.json.JsonLineDeserializer.java

/**
 *
 *
 * @param object//from  ww  w. ja  v a 2  s  .c o m
 * @param pathElements
 * @param depth
 * @param fieldIndex
 * @param output
 * @throws IOException
 */
private void getValue(JSONObject object, String fullPath, String[] pathElements, int depth, int fieldIndex,
        Tuple output) throws IOException {
    String fieldName = pathElements[depth];

    if (!object.containsKey(fieldName)) {
        output.put(fieldIndex, NullDatum.get());
    }

    switch (types.get(fullPath)) {
    case BOOLEAN:
        String boolStr = object.getAsString(fieldName);
        if (boolStr != null) {
            output.put(fieldIndex, DatumFactory.createBool(boolStr.equals("true")));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case CHAR:
        String charStr = object.getAsString(fieldName);
        if (charStr != null) {
            output.put(fieldIndex, DatumFactory.createChar(charStr));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case INT1:
    case INT2:
        Number int2Num = object.getAsNumber(fieldName);
        if (int2Num != null) {
            output.put(fieldIndex, DatumFactory.createInt2(int2Num.shortValue()));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case INT4:
        Number int4Num = object.getAsNumber(fieldName);
        if (int4Num != null) {
            output.put(fieldIndex, DatumFactory.createInt4(int4Num.intValue()));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case INT8:
        Number int8Num = object.getAsNumber(fieldName);
        if (int8Num != null) {
            output.put(fieldIndex, DatumFactory.createInt8(int8Num.longValue()));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case FLOAT4:
        Number float4Num = object.getAsNumber(fieldName);
        if (float4Num != null) {
            output.put(fieldIndex, DatumFactory.createFloat4(float4Num.floatValue()));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case FLOAT8:
        Number float8Num = object.getAsNumber(fieldName);
        if (float8Num != null) {
            output.put(fieldIndex, DatumFactory.createFloat8(float8Num.doubleValue()));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case TEXT:
        String textStr = object.getAsString(fieldName);
        if (textStr != null) {
            output.put(fieldIndex, DatumFactory.createText(textStr));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case TIMESTAMP:
        String timestampStr = object.getAsString(fieldName);
        if (timestampStr != null) {
            output.put(fieldIndex, DatumFactory.createTimestamp(timestampStr, timezone));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case TIME:
        String timeStr = object.getAsString(fieldName);
        if (timeStr != null) {
            output.put(fieldIndex, DatumFactory.createTime(timeStr));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case DATE:
        String dateStr = object.getAsString(fieldName);
        if (dateStr != null) {
            output.put(fieldIndex, DatumFactory.createDate(dateStr));
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;
    case BIT:
    case BINARY:
    case VARBINARY:
    case BLOB: {
        Object jsonObject = object.getAsString(fieldName);

        if (jsonObject == null) {
            output.put(fieldIndex, NullDatum.get());
            break;
        }

        output.put(fieldIndex, DatumFactory.createBlob(Base64.decodeBase64((String) jsonObject)));
        break;
    }

    case RECORD:
        JSONObject nestedObject = (JSONObject) object.get(fieldName);
        if (nestedObject != null) {
            getValue(nestedObject, fullPath + "/" + pathElements[depth + 1], pathElements, depth + 1,
                    fieldIndex, output);
        } else {
            output.put(fieldIndex, NullDatum.get());
        }
        break;

    case NULL_TYPE:
        output.put(fieldIndex, NullDatum.get());
        break;

    default:
        throw new TajoRuntimeException(
                new NotImplementedException("" + types.get(fullPath).name() + " for json"));
    }
}

From source file:org.mifos.customers.personnel.persistence.LegacyPersonnelDao.java

public boolean isUserExist(String displayName, Date dob) throws PersistenceException {
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("DISPLAY_NAME", displayName);
    queryParameters.put("DOB", dob);
    Number count = (Number) execUniqueResultNamedQuery(
            NamedQueryConstants.GET_PERSONNEL_WITH_DOB_AND_DISPLAYNAME, queryParameters);
    if (count != null) {
        return count.longValue() > 0;
    }/* w  ww  .jav a 2 s .  c o m*/
    return false;
}

From source file:org.openepics.discs.ccdb.core.ejb.ApplicationService.java

private void checkSlotsTable() {
    final Number oldSchemaColumns = (Number) em.createNativeQuery("SELECT COUNT(*) "
            + "FROM information_schema.columns " + "WHERE table_schema = 'public' " + "AND table_name = 'slot' "
            + "AND column_name IN " + "('beamline_position', 'global_x', 'global_y', 'global_z', "
            + "'global_pitch', 'global_roll', 'global_yaw')").getSingleResult();
    if (oldSchemaColumns.longValue() > 0) {
        LOGGER.log(Level.WARNING, "Database table 'slot' contains columns which are no longer needed. "
                + "Execute 'postgres-db-schemas/slot_update1.sql' SQL queries to remove them.");
        LOGGER.log(Level.WARNING,
                "* * * THIS IS A POSTGRESQL SCRIPT. TRANSLATE IF USING ANOTHER BACKEND! * * *");
    }/*from   w  w  w . ja va2s  .  co m*/
}

From source file:org.jnap.core.persistence.jpa.DaoSupport.java

/**
 * /*from  w w  w .  j a  v a  2s .c o m*/
 * @param query
 * @return
 */
protected Long count(Query query) {
    Number quantity = (Number) query.getSingleResult();
    return quantity == null ? 0 : quantity.longValue();
}