Example usage for java.lang Short shortValue

List of usage examples for java.lang Short shortValue

Introduction

In this page you can find the example usage for java.lang Short shortValue.

Prototype

@HotSpotIntrinsicCandidate
public short shortValue() 

Source Link

Document

Returns the value of this Short as a short .

Usage

From source file:com.germinus.easyconf.ComponentProperties.java

public short getShort(String key, Filter filter) {
    Short value = getShort(key, filter, null);
    validateValue(key, value);//from www .  j a  v a2 s .co m
    return value.shortValue();
}

From source file:org.apache.ddlutils.platform.JdbcModelReader.java

/**
 * Converts the JDBC action value (one of the <code>importKey</code> constants in the
 * {@link DatabaseMetaData} class) to a {@link CascadeActionEnum}.
 * /*from w  w w.j a  v  a 2  s  . c o  m*/
 * @param jdbcActionValue The jdbc action value
 * @return The enum value
 */
protected CascadeActionEnum convertAction(Short jdbcActionValue) {
    CascadeActionEnum action = null;

    if (jdbcActionValue != null) {
        switch (jdbcActionValue.shortValue()) {
        case DatabaseMetaData.importedKeyCascade:
            action = CascadeActionEnum.CASCADE;
            break;
        case DatabaseMetaData.importedKeySetNull:
            action = CascadeActionEnum.SET_NULL;
            break;
        case DatabaseMetaData.importedKeySetDefault:
            action = CascadeActionEnum.SET_DEFAULT;
            break;
        case DatabaseMetaData.importedKeyRestrict:
            action = CascadeActionEnum.RESTRICT;
            break;
        }
    }
    return action;
}

From source file:org.apache.ddlutils.platform.JdbcModelReader.java

/**
 * Reads the next index spec from the result set.
 * //from   www . j  a  va  2s  .  c om
 * @param metaData     The database meta data
 * @param values       The index meta data as defined by {@link #getColumnsForIndex()}
 * @param knownIndices The already read indices for the current table
 */
protected void readIndex(DatabaseMetaDataWrapper metaData, Map values, Map knownIndices) throws SQLException {
    Short indexType = (Short) values.get("TYPE");

    // we're ignoring statistic indices
    if ((indexType != null) && (indexType.shortValue() == DatabaseMetaData.tableIndexStatistic)) {
        return;
    }

    String indexName = (String) values.get("INDEX_NAME");

    if (indexName != null) {
        Index index = (Index) knownIndices.get(indexName);

        if (index == null) {
            if (((Boolean) values.get("NON_UNIQUE")).booleanValue()) {
                index = new NonUniqueIndex();
            } else {
                index = new UniqueIndex();
            }

            index.setName(indexName);
            knownIndices.put(indexName, index);
        }

        IndexColumn indexColumn = new IndexColumn();

        indexColumn.setName((String) values.get("COLUMN_NAME"));
        if (values.containsKey("ORDINAL_POSITION")) {
            indexColumn.setOrdinalPosition(((Short) values.get("ORDINAL_POSITION")).intValue());
        }
        index.addColumn(indexColumn);
    }
}

From source file:org.mifos.customers.persistence.CustomerPersistence.java

private void updateAccountsForOneCustomer(final Integer customerId, final Short parentLO,
        final Connection connection) throws Exception {

    Statement statement = connection.createStatement();
    String sql = "update account " + " set personnel_id = " + parentLO.shortValue()
            + " where account.customer_id = " + customerId.intValue();
    statement.executeUpdate(sql);/*from  www. j  a va2 s . c o m*/
    statement.close();
}

From source file:org.mifos.customers.persistence.CustomerPersistence.java

/**
 * @deprecated use {@link CustomerDao#findCenterBySystemId(String)}.
 */// w  w w .  j  a va2 s .com
@Deprecated
public CustomerBO findBySystemId(final String globalCustNum, final Short levelId) throws PersistenceException {
    Map<String, String> queryParameters = new HashMap<String, String>();
    CustomerBO customer = null;
    queryParameters.put("globalCustNum", globalCustNum);
    if (levelId.shortValue() == CustomerLevel.CENTER.getValue()) {
        List<CenterBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_CENTER_BY_SYSTEMID,
                queryParameters);
        if (null != queryResult && queryResult.size() > 0) {
            customer = queryResult.get(0);
            initializeCustomer(customer);
        }
    } else if (levelId.shortValue() == CustomerLevel.GROUP.getValue()) {
        List<GroupBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_GROUP_BY_SYSTEMID,
                queryParameters);
        if (null != queryResult && queryResult.size() > 0) {
            customer = queryResult.get(0);
            initializeCustomer(customer);
        }

    } else if (levelId.shortValue() == CustomerLevel.CLIENT.getValue()) {
        List<ClientBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_CLIENT_BY_SYSTEMID,
                queryParameters);
        if (null != queryResult && queryResult.size() > 0) {
            customer = queryResult.get(0);
            initializeCustomer(customer);
        }
    }

    return customer;
}

From source file:org.mifos.config.AccountingRulesIntegrationTest.java

@Test
public void testGetNumberOfInterestDays() {
    Short interestDaysInConfig = AccountingRules.getNumberOfInterestDays();
    ConfigurationManager configMgr = ConfigurationManager.getInstance();
    Short insertedDays = 365;
    configMgr.setProperty(AccountingRulesConstants.NUMBER_OF_INTEREST_DAYS, insertedDays);
    Assert.assertEquals(insertedDays, AccountingRules.getNumberOfInterestDays());
    insertedDays = 360;//from  ww w .j  a  va  2 s  .  com
    // set new value
    configMgr.setProperty(AccountingRulesConstants.NUMBER_OF_INTEREST_DAYS, insertedDays);
    // return value from accounting rules class has to be the value defined
    // in the config file
    Assert.assertEquals(insertedDays, AccountingRules.getNumberOfInterestDays());
    insertedDays = 355;
    configMgr.setProperty(AccountingRulesConstants.NUMBER_OF_INTEREST_DAYS, insertedDays);
    // throw exception because the invalid value 355
    try {
        AccountingRules.getNumberOfInterestDays();
    } catch (RuntimeException e) {
        Assert.assertEquals(e.getMessage(),
                "Invalid number of interest days defined in property file " + insertedDays.shortValue());
    }
    // clear the NumberOfInterestDays property from the config file
    configMgr.clearProperty(AccountingRulesConstants.NUMBER_OF_INTEREST_DAYS);
    // throw exception because no interest days defined in config file
    try {
        AccountingRules.getNumberOfInterestDays();
    } catch (RuntimeException e) {
        Assert.assertEquals(e.getMessage(), "The number of interest days is not defined in the config file ");
    }

    configMgr.addProperty(AccountingRulesConstants.NUMBER_OF_INTEREST_DAYS, interestDaysInConfig);
}

From source file:org.mifos.application.servicefacade.AdminServiceFacadeWebTier.java

private boolean findDelete(PaymentTypeDto paymentType, List<PaymentTypeDto> paymentTypes) {
    if (paymentTypes == null) {
        return true;
    }//  w  w w.ja va 2s.  c  o m
    Short paymentTypeId = paymentType.getId();
    for (PaymentTypeDto paymentType2 : paymentTypes) {
        Short paymentId = paymentType2.getId();
        if (paymentId.shortValue() == paymentTypeId.shortValue()) {
            return false;
        }
    }
    return true;
}

From source file:org.mifos.application.servicefacade.AdminServiceFacadeWebTier.java

private boolean findNew(Short paymentTypeId, List<PaymentTypeDto> paymentTypes) {

    for (PaymentTypeDto paymentTypeData : paymentTypes) {
        Short paymentId = paymentTypeData.getId();
        if (paymentId.shortValue() == paymentTypeId.shortValue()) {
            return false;
        }//from   w  ww  .j  a v  a  2s.c o  m
    }
    return true;
}

From source file:org.mifos.framework.struts.action.MifosRequestProcessor.java

protected boolean checkProcessRoles(HttpServletRequest request, HttpServletResponse response,
        ActionMapping mapping) {//from  www  .j av a 2s  .co  m
    boolean returnValue = true;
    if (request.getSession() != null && request.getSession().getAttribute("UserContext") != null)

    {
        HttpSession session = request.getSession();
        ActivityMapper activityMapper = ActivityMapper.getInstance();
        String path = mapping.getPath();
        String method = request.getParameter("method");
        String key = path + "-" + method;
        Short activityId = null;
        if (null != method && (method.equals("cancel") || method.equals("validate")
                || method.equals("searchPrev") || method.equals("searchNext"))) {
            return true;
        }
        String activityKey = null;

        if (isReportRequest(request)) {
            String reportId = request.getParameter("reportId");
            activityKey = key + "-" + reportId;
            activityId = activityMapper.getActivityId(activityKey);
        } else {
            activityId = activityMapper.getActivityId(key);
            request.setAttribute(Globals.ERROR_KEY, null);
        }

        if (null == activityId) {
            activityKey = path + "-" + request.getParameter("viewPath");
            activityId = activityMapper.getActivityId(activityKey);
        }
        // Check for fine-grained permissions
        if (null == activityId) {
            activityKey = key + "-" + session.getAttribute(SecurityConstants.SECURITY_PARAM);
            activityId = activityMapper.getActivityId(activityKey);
        }
        if (null == activityId) {
            return false;
        } else if (activityId.shortValue() == 0) {
            return true;
        }
        returnValue = ApplicationContextProvider.getBean(LegacyRolesPermissionsDao.class).isActivityAllowed(
                (UserContext) session.getAttribute("UserContext"),
                setActivityContextFromRequest(request, activityId));
    }
    return returnValue;
}

From source file:org.mifos.application.servicefacade.AdminServiceFacadeWebTier.java

private void RemoveFromInList(List<PaymentTypeDto> list, Short paymentTypeId) {
    for (int i = list.size() - 1; i >= 0; i--) {
        if (list.get(i).getId().shortValue() == paymentTypeId.shortValue()) {
            list.remove(i);/* w w  w  .  j  a  v a 2s .  c  o m*/
        }
    }
}