Example usage for java.lang Short equals

List of usage examples for java.lang Short equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:Main.java

public static void main(String[] args) {
    Short shortValue1 = new Short("10");
    Short shortValue2 = new Short("11");

    System.out.println(shortValue1.equals(shortValue2));
}

From source file:org.mifos.config.struts.actionform.CustomFieldsActionForm.java

private void validateDefaultValue(ActionErrors errors, HttpServletRequest request) {
    if (StringUtils.isBlank(dataType)) {
        Locale locale = getUserContext(request).getPreferredLocale();
        ResourceBundle resources = ResourceBundle.getBundle(FilePaths.CONFIGURATION_UI_RESOURCE_PROPERTYFILE,
                locale);// w  w w . j  a  va2  s . c o  m
        String dataTypeParam = resources.getString("configuration.data_type");
        addError(errors, dataType, "errors.mandatory_selectbox", dataTypeParam);
        return;
    }
    Short dataTypeValue = Short.parseShort(dataType);
    if (dataTypeValue.equals(CustomFieldType.NUMERIC.getValue()) && (StringUtils.isNotBlank(defaultValue))) {
        try {
            Double.parseDouble(defaultValue);
        } catch (NumberFormatException e) {
            addError(errors, defaultValue, "errors.default_value_not_number", new String[] { null });
        }
    } else if (dataTypeValue.equals(CustomFieldType.DATE.getValue())
            && (StringUtils.isNotBlank(defaultValue))) {
        try {
            // for now just use this function to validate the string.
            // need to check more when the exact format is specified
            DateUtils.getDate(defaultValue);

        } catch (Exception e) {
            addError(errors, defaultValue, "errors.default_value_not_date", new String[] { null });
        }
    }

}

From source file:org.mifos.accounts.savings.struts.action.SavingsDepositWithdrawalAction.java

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession/*  www .  ja v  a2 s  . co m*/
public ActionForward makePayment(final ActionMapping mapping, final ActionForm form,
        final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response)
        throws Exception {
    SavingsBO savedAccount = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    SavingsBO savings = savingsDao.findById(savedAccount.getAccountId());
    checkVersionMismatch(savedAccount.getVersionNo(), savings.getVersionNo());
    savings.setVersionNo(savedAccount.getVersionNo());

    SavingsDepositWithdrawalActionForm actionForm = (SavingsDepositWithdrawalActionForm) form;
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    Date trxnDate = getDateFromString(actionForm.getTrxnDate(), uc.getPreferredLocale());
    monthClosingServiceFacade.validateTransactionDate(trxnDate);

    Date meetingDate = new CustomerPersistence()
            .getLastMeetingDateForCustomer(savings.getCustomer().getCustomerId());
    boolean repaymentIndependentOfMeetingEnabled = new ConfigurationPersistence()
            .isRepaymentIndepOfMeetingEnabled();
    if (!savings.isTrxnDateValid(trxnDate, meetingDate, repaymentIndependentOfMeetingEnabled)) {
        throw new AccountException(AccountConstants.ERROR_INVALID_TRXN);
    }

    Long savingsId = Long.valueOf(savings.getAccountId());
    Long customerId = Long.valueOf(savings.getCustomer().getCustomerId());
    if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
        customerId = Long.valueOf(actionForm.getCustomerId());
    }

    Locale preferredLocale = uc.getPreferredLocale();
    LocalDate dateOfDepositOrWithdrawalTransaction = new LocalDate(trxnDate);
    Double amount = Double.valueOf(actionForm.getAmount());
    Integer modeOfPayment = Integer.valueOf(actionForm.getPaymentTypeId());
    String receiptId = actionForm.getReceiptId();
    LocalDate dateOfReceipt = null;
    if (StringUtils.isNotBlank(actionForm.getReceiptDate())) {
        dateOfReceipt = new LocalDate(getDateFromString(actionForm.getReceiptDate(), preferredLocale));
    }

    try {
        Short trxnTypeId = Short.valueOf(actionForm.getTrxnTypeId());
        if (trxnTypeId.equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue())) {

            SavingsDepositDto savingsDeposit = new SavingsDepositDto(savingsId, customerId,
                    dateOfDepositOrWithdrawalTransaction, amount, modeOfPayment, receiptId, dateOfReceipt,
                    preferredLocale);
            this.savingsServiceFacade.deposit(savingsDeposit);

        } else if (trxnTypeId.equals(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue())) {

            SavingsWithdrawalDto savingsWithdrawal = new SavingsWithdrawalDto(savingsId, customerId,
                    dateOfDepositOrWithdrawalTransaction, amount, modeOfPayment, receiptId, dateOfReceipt,
                    preferredLocale);
            this.savingsServiceFacade.withdraw(savingsWithdrawal);
        }
    } catch (BusinessRuleException e) {
        throw new AccountException(e.getMessageKey(), e);
    }

    return mapping.findForward(ActionForwards.account_details_page.toString());
}

From source file:org.mifos.customers.struts.action.CustSearchAction.java

@TransactionDemarcate(conditionToken = true)
public ActionForward getOfficeHomePage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    Short loggedUserLevel = getUserContext(request).getLevelId();
    if (loggedUserLevel.equals(PersonnelLevel.LOAN_OFFICER.getValue())) {
        return loadMainSearch(mapping, form, request, response);
    }/*from   w ww . j  av  a2  s. com*/
    return preview(mapping, form, request, response);
}

From source file:org.mifos.accounts.savings.struts.action.SavingsDepositWithdrawalAction.java

@TransactionDemarcate(joinToken = true)
public ActionForward reLoad(final ActionMapping mapping, final ActionForm form,
        final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response)
        throws Exception {

    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    SavingsDepositWithdrawalActionForm actionForm = (SavingsDepositWithdrawalActionForm) form;
    SavingsBO savingsInSession = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);

    if (actionForm.getTrxnTypeId() != null && actionForm.getTrxnTypeId() != Constants.EMPTY_STRING) {

        Long savingsId = savingsInSession.getAccountId().longValue();
        SavingsBO savings = this.savingsDao.findById(savingsId);

        Integer customerId = savings.getCustomer().getCustomerId();
        if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
            customerId = Integer.valueOf(actionForm.getCustomerId());
        }//ww w  .j a  va 2s  .  co m
        DepositWithdrawalReferenceDto depositWithdrawalReferenceDto = this.savingsServiceFacade
                .retrieveDepositWithdrawalReferenceData(savingsId, customerId);

        Short trxnTypeId = Short.valueOf(actionForm.getTrxnTypeId());
        // added for defect 1587 [start]
        LegacyAcceptedPaymentTypeDao persistence = legacyAcceptedPaymentTypeDao;
        if (trxnTypeId.equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue())) {
            if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
                actionForm.setAmount(depositWithdrawalReferenceDto.getDepositDue());
            }
            List<PaymentTypeEntity> depositPaymentTypes = persistence.getAcceptedPaymentTypesForATransaction(
                    uc.getLocaleId(), TrxnTypes.savings_deposit.getValue());
            SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, depositPaymentTypes, request);
        } else {
            actionForm.setAmount(depositWithdrawalReferenceDto.getWithdrawalDue());
            List<PaymentTypeEntity> withdrawalPaymentTypes = persistence.getAcceptedPaymentTypesForATransaction(
                    uc.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
            SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, withdrawalPaymentTypes, request);
        }
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}

From source file:org.mifos.application.meeting.business.MeetingBO.java

public boolean isDayOfMonthDifferent(Short dayOfMonth) {
    return !dayOfMonth.equals(this.getMeetingDetails().getDayNumber());
}

From source file:com.igorbaiborodine.example.mybatis.customer.TestCustomerMapper.java

@Test
public void testSelectByPrimaryKey() {
    Short customerId = new Short("1");
    Customer customer = _customerMapper.selectByPrimaryKey(customerId);

    assertNotNull("test select by primary key failed - customer must not be null", customer);
    _logger.debug(String.format("retrieved ", customer.toString()));
    assertTrue("test select by primary key failed - customer id must not be different",
            customerId.equals(customer.getCustomerId()));
}

From source file:org.mifos.config.struts.action.CustomFieldsAction.java

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    CustomFieldsActionForm actionForm = (CustomFieldsActionForm) form;
    Locale locale = getUserLocale(request);
    CustomFieldDefinitionEntity customField = (CustomFieldDefinitionEntity) SessionUtils
            .getAttribute(ConfigurationConstants.CURRENT_CUSTOM_FIELD, request);
    Short dataType = Short.parseShort(actionForm.getDataType());
    if (dataType.equals(CustomFieldType.DATE.getValue())) {
        customField.setDefaultValue(changeDefaultValueDateToDBFormat(actionForm.getDefaultValue(), locale));
    } else {//from w w  w.  ja v  a2 s  .  c o  m
        customField.setDefaultValue(actionForm.getDefaultValue());
    }
    YesNoFlag flag = null;
    if (actionForm.isMandatoryField()) {
        flag = YesNoFlag.YES;
    } else {
        flag = YesNoFlag.NO;
    }
    customField.setMandatoryFlag(flag.getValue());
    Short localeId = getUserContext(request).getLocaleId();
    String labelName = actionForm.getLabelName();
    customField.setLabel(labelName);

    ApplicationConfigurationPersistence persistence = new ApplicationConfigurationPersistence();
    persistence.updateCustomField(customField);
    // MifosConfiguration.getInstance().reload();
    request.setAttribute("category", actionForm.getCategory());
    MifosConfiguration.getInstance().updateLabelKey(customField.getLookUpEntity().getEntityType(), labelName,
            localeId);
    logger.debug("Inside update method");
    return mapping.findForward(ActionForwards.update_success.toString());
}

From source file:org.mifos.config.struts.action.CustomFieldsAction.java

private void setFormAttributes(CustomFieldsActionForm actionForm, Short editedCustomFieldId,
        HttpServletRequest request) throws Exception {
    UserContext userContext = getUserContext(request);
    MasterPersistence masterPersistence = new MasterPersistence();
    CustomFieldDefinitionEntity customField = masterPersistence
            .retrieveOneCustomFieldDefinition(editedCustomFieldId);
    actionForm.setCategoryType(customField.getEntityType().toString()); // entity
                                                                        // type
                                                                        // id

    String label = customField.getLabel();
    actionForm.setLabelName(label);/*from  www .  ja  va2s.  co m*/
    String entityTypeName = getEntityTypeName(customField.getEntityType(), userContext);
    actionForm.setCategoryTypeName(entityTypeName);
    String customFieldCategory = CustomFieldCategory.fromInt(customField.getEntityType().intValue()).name();
    request.setAttribute("category", customFieldCategory);
    Locale locale = getUserLocale(request);
    String dataTypeName = getDataType(customField.getFieldType(), locale);
    Short fieldType = customField.getFieldType();
    String defaultValue = customField.getDefaultValue();
    if (fieldType.equals(CustomFieldType.DATE.getValue()) && StringUtils.isNotBlank(defaultValue)) {
        actionForm.setDefaultValue(DateUtils.getUserLocaleDate(locale, defaultValue));
    } else {
        actionForm.setDefaultValue(defaultValue);
    }
    actionForm.setDataType(fieldType.toString());
    actionForm.setMandatoryField(customField.isMandatory());
    actionForm.setMandatoryStringValue(customField.getMandatoryStringValue(locale));
    List<CustomFieldsListBoxData> dataTypes = new ArrayList<CustomFieldsListBoxData>();
    CustomFieldsListBoxData dataType = new CustomFieldsListBoxData();
    dataType.setName(dataTypeName);
    dataType.setId(customField.getFieldType());
    dataTypes.add(dataType);
    SessionUtils.setCollectionAttribute(ConfigurationConstants.CURRENT_DATA_TYPE, dataTypes, request);
    List<CustomFieldsListBoxData> categories = new ArrayList<CustomFieldsListBoxData>();
    CustomFieldsListBoxData category = new CustomFieldsListBoxData();
    category.setName(entityTypeName);
    category.setId(customField.getEntityType());
    categories.add(category);
    SessionUtils.setCollectionAttribute(ConfigurationConstants.CURRENT_CATEGORY, categories, request);
    SessionUtils.setAttribute(ConfigurationConstants.CURRENT_CUSTOM_FIELD, customField, request);

}

From source file:org.mifos.customers.personnel.business.PersonnelBO.java

private void updateNoOfTries() {
    final Short MAXTRIES = 5;
    if (!isLocked()) {
        Short newNoOfTries = (short) (getNoOfTries() + 1);
        if (newNoOfTries.equals(MAXTRIES)) {
            lock();/*from  w  w w .  j  a  v a  2s  . co m*/
        }
        this.noOfTries = newNoOfTries;
    }
}