List of usage examples for java.lang Integer shortValue
public short shortValue()
From source file:pltag.parser.ShadowStringTree.java
public Map<Short, Short> getOffsetNodeIds() { DualHashBidiMap<Short, Short> map = new DualHashBidiMap<Short, Short>(); for (Integer id : tree.getNodes()) { map.put(id.shortValue(), id == elemIpiNode ? prefixIpiNode : (short) (id + absolutePosOfRootInPrefixTree)); }//w w w . jav a 2s . co m return map; }
From source file:gr.abiss.calipso.model.base.AuditableResource.java
@PreUpdate @PrePersist/*from ww w . j a va 2s . co m*/ public void normalizePath() throws UnsupportedEncodingException { // set path if (this.getPath() == null) { StringBuffer path = new StringBuffer(); if (this.getParent() != null) { path.append(this.getParent().getPath()); } path.append(getPathSeparator()); path.append(this.getName()); this.setPath(path.toString()); } // set path level Integer pathLevel = StringUtils.countMatches(this.getPath(), getPathSeparator()); this.setPathLevel(pathLevel.shortValue()); }
From source file:org.mifos.ui.core.controller.ProductCategoryPreviewController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") ProductCategoryFormBean formBean, BindingResult result) { String viewName = REDIRECT_TO_ADMIN_SCREEN; ModelAndView modelAndView = new ModelAndView(); if (StringUtils.isNotBlank(edit)) { viewName = "editCategoryInformation"; modelAndView.setViewName(viewName); modelAndView.addObject("formBean", formBean); modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder() .withLink("admin.viewproductcategories", "viewProductCategories.ftl") .withLink(formBean.getProductCategoryName(), "").build()); } else if (StringUtils.isNotBlank(cancel)) { viewName = REDIRECT_TO_ADMIN_SCREEN; modelAndView.setViewName(viewName); } else if (result.hasErrors()) { viewName = "categoryPreview"; modelAndView.setViewName(viewName); modelAndView.addObject("formBean", formBean); modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder() .withLink("admin.viewproductcategories", "viewProductCategories.ftl") .withLink(formBean.getProductCategoryName(), "").build()); } else {/*from ww w.j a va 2s.co m*/ Integer productStatusId = Integer.parseInt(formBean.getProductCategoryStatusId()); Integer productTypeId = Integer.parseInt(formBean.getProductTypeId()); CreateOrUpdateProductCategory productCategory = new CreateOrUpdateProductCategory( productTypeId.shortValue(), formBean.getProductCategoryName(), formBean.getProductCategoryDesc(), productStatusId.shortValue(), formBean.getGlobalPrdCategoryNum()); try { this.adminServiceFacade.updateProductCategory(productCategory); modelAndView.setViewName(REDIRECT_TO_ADMIN_SCREEN); } catch (BusinessRuleException e) { ObjectError error = new ObjectError("formBean", new String[] { e.getMessageKey() }, new Object[] {}, "default: "); result.addError(error); modelAndView.setViewName("categoryPreview"); modelAndView.addObject("formBean", formBean); modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder() .withLink("admin.viewproductcategories", "viewProductCategories.ftl") .withLink(formBean.getProductCategoryName(), "").build()); } } return modelAndView; }
From source file:org.apache.tomcat.util.net.puretls.PureTLSSocketFactory.java
private short[] getEnabledCiphers(short[] supportedCiphers) { short[] enabledCiphers = null; String attrValue = (String) attributes.get("ciphers"); if (attrValue != null) { Vector vec = null;//from w w w . j a va 2 s .c o m int fromIndex = 0; int index = attrValue.indexOf(',', fromIndex); while (index != -1) { String cipher = attrValue.substring(fromIndex, index).trim(); int cipherValue = SSLPolicyInt.getCipherSuiteNumber(cipher); /* * Check to see if the requested cipher is among the supported * ciphers, i.e., may be enabled */ if (cipherValue >= 0) { for (int i = 0; supportedCiphers != null && i < supportedCiphers.length; i++) { if (cipherValue == supportedCiphers[i]) { if (vec == null) { vec = new Vector(); } vec.addElement(new Integer(cipherValue)); break; } } } fromIndex = index + 1; index = attrValue.indexOf(',', fromIndex); } if (vec != null) { int nCipher = vec.size(); enabledCiphers = new short[nCipher]; for (int i = 0; i < nCipher; i++) { Integer value = (Integer) vec.elementAt(i); enabledCiphers[i] = value.shortValue(); } } } return enabledCiphers; }
From source file:org.mifos.application.servicefacade.SavingsProductAssembler.java
public SavingsOfferingBO fromDto(MifosUser user, SavingsProductDto savingsProductRequest) { try {/*from w ww .j av a2 s .co m*/ // FIXME - keithw - this is general assembler common to both savings and loans i.e. all products. so // ProductDao and ProductAssembler ProductDetailsDto productDetails = savingsProductRequest.getProductDetails(); String name = productDetails.getName(); String shortName = productDetails.getShortName(); String description = productDetails.getDescription(); Integer category = productDetails.getCategory(); ProductCategoryBO productCategory = this.loanProductDao.findActiveProductCategoryById(category); DateTime startDate = productDetails.getStartDate(); DateTime endDate = productDetails.getEndDate(); ApplicableTo applicableTo = ApplicableTo.fromInt(productDetails.getApplicableFor()); PrdApplicableMasterEntity applicableToEntity = this.loanProductDao .findApplicableProductType(applicableTo); PrdStatusEntity activeStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_ACTIVE); PrdStatusEntity inActiveStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.SAVINGS_INACTIVE); PrdStatusEntity selectedStatus = activeStatus; if (productDetails.getStatus() != null && inActiveStatus.getOfferingStatusId().equals(productDetails.getStatus().shortValue())) { selectedStatus = inActiveStatus; } String globalNum = generateProductGlobalNum(user); // savings specific SavingsType savingsType = SavingsType.fromInt(savingsProductRequest.getDepositType()); SavingsTypeEntity savingsTypeEntity = this.loanProductDao.retrieveSavingsType(savingsType); RecommendedAmntUnitEntity recommendedAmntUnitEntity = null; if (savingsProductRequest.getGroupMandatorySavingsType() != null) { RecommendedAmountUnit recommendedAmountType = RecommendedAmountUnit .fromInt(savingsProductRequest.getGroupMandatorySavingsType()); recommendedAmntUnitEntity = this.loanProductDao .retrieveRecommendedAmountType(recommendedAmountType); } Money amountForDeposit = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getAmountForDeposit())); Money maxWithdrawal = new Money(Money.getDefaultCurrency(), BigDecimal.valueOf(savingsProductRequest.getMaxWithdrawal())); // interest specific BigDecimal interestRate = savingsProductRequest.getInterestRate(); InterestCalcType interestCalcType = InterestCalcType .fromInt(savingsProductRequest.getInterestCalculationType()); InterestCalcTypeEntity interestCalcTypeEntity = this.savingsProductDao .retrieveInterestCalcType(interestCalcType); RecurrenceType recurrence = RecurrenceType .fromInt(savingsProductRequest.getInterestCalculationFrequencyPeriod().shortValue()); Integer every = savingsProductRequest.getInterestCalculationFrequency(); MeetingBO interestCalculationMeeting = new MeetingBO(recurrence, every.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_CALCULATION_TIME_PERIOD); Integer interestPostingEveryMonthFreq = savingsProductRequest.getInterestPostingMonthlyFrequency(); MeetingBO interestPostingMeeting = new MeetingBO(RecurrenceType.MONTHLY, interestPostingEveryMonthFreq.shortValue(), new Date(), MeetingType.SAVINGS_INTEREST_POSTING); Money minAmountForCalculation = new Money(Money.getDefaultCurrency(), savingsProductRequest.getMinBalanceForInterestCalculation()); GLCodeEntity depositGlEntity = this.generalLedgerDao .findGlCodeById(savingsProductRequest.getDepositGlCode().shortValue()); GLCodeEntity interestGlEntity = this.generalLedgerDao .findGlCodeById(savingsProductRequest.getInterestGlCode().shortValue()); MifosCurrency currency = Money.getDefaultCurrency(); return SavingsOfferingBO.createNew(user.getUserId(), globalNum, name, shortName, description, productCategory, startDate, endDate, applicableToEntity, currency, selectedStatus, savingsTypeEntity, recommendedAmntUnitEntity, amountForDeposit, maxWithdrawal, interestRate, interestCalcTypeEntity, interestCalculationMeeting, interestPostingMeeting, minAmountForCalculation, depositGlEntity, interestGlEntity); } catch (PersistenceException e) { throw new MifosRuntimeException(e); } catch (MeetingException e) { throw new MifosRuntimeException(e); } }
From source file:org.mifos.application.servicefacade.LoanProductAssembler.java
public LoanOfferingBO fromDto(MifosUser user, LoanProductRequest loanProductRequest) { try {//from w w w.j a v a 2 s . c o m Integer userId = user.getUserId(); ProductDetailsDto productDetails = loanProductRequest.getProductDetails(); String name = productDetails.getName(); String shortName = productDetails.getShortName(); String description = productDetails.getDescription(); Integer category = productDetails.getCategory(); boolean loanCycleCounter = loanProductRequest.isIncludeInLoanCycleCounter(); boolean waiverInterest = loanProductRequest.isWaiverInterest(); PrdStatusEntity activeStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.LOAN_ACTIVE); PrdStatusEntity inActiveStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.LOAN_INACTIVE); PrdStatusEntity selectedStatus = activeStatus; if (productDetails.getStatus() != null && inActiveStatus.getOfferingStatusId().equals(productDetails.getStatus().shortValue())) { selectedStatus = inActiveStatus; } MifosCurrency currency = Money.getDefaultCurrency(); if (AccountingRules.isMultiCurrencyEnabled()) { currency = AccountingRules.getCurrencyByCurrencyId(loanProductRequest.getCurrencyId().shortValue()); } ProductCategoryBO productCategory = this.loanProductDao.findActiveProductCategoryById(category); DateTime startDate = productDetails.getStartDate(); DateTime endDate = productDetails.getEndDate(); ApplicableTo applicableTo = ApplicableTo.fromInt(productDetails.getApplicableFor()); PrdApplicableMasterEntity applicableToEntity = this.loanProductDao .findApplicableProductType(applicableTo); LoanAmountCalculation loanAmountCalculation = this.loanProductCaluclationTypeAssembler .assembleLoanAmountCalculationFromDto(loanProductRequest.getLoanAmountDetails()); InterestType interestType = InterestType.fromInt(loanProductRequest.getInterestRateType()); Double minRate = loanProductRequest.getInterestRateRange().getMin().doubleValue(); Double maxRate = loanProductRequest.getInterestRateRange().getMax().doubleValue(); Double defaultRate = loanProductRequest.getInterestRateRange().getTheDefault().doubleValue(); InterestTypesEntity interestTypeEntity = this.loanProductDao.findInterestType(interestType); RecurrenceType recurrence = RecurrenceType .fromInt(loanProductRequest.getRepaymentDetails().getFrequencyType().shortValue()); Integer recurEvery = loanProductRequest.getRepaymentDetails().getRecurs(); LoanInstallmentCalculation loanInstallmentCalculation = this.loanProductCaluclationTypeAssembler .assembleLoanInstallmentCalculationFromDto( loanProductRequest.getRepaymentDetails().getInstallmentCalculationDetails()); GraceType gracePeriodType = GraceType .fromInt(loanProductRequest.getRepaymentDetails().getGracePeriodType()); GracePeriodTypeEntity gracePeriodTypeEntity = this.loanProductDao.findGracePeriodType(gracePeriodType); Integer gracePeriodDuration = loanProductRequest.getRepaymentDetails().getGracePeriodDuration(); List<FeeBO> applicableFees = new ArrayList<FeeBO>(); List<Integer> applicableFeeIds = loanProductRequest.getApplicableFees(); for (Integer feeId : applicableFeeIds) { FeeBO fee = ApplicationContextProvider.getBean(FeeDao.class).findById(feeId.shortValue()); applicableFees.add(fee); } List<FundBO> applicableFunds = new ArrayList<FundBO>(); List<Integer> applicableFundIds = loanProductRequest.getAccountDetails().getApplicableFunds(); for (Integer fundId : applicableFundIds) { FundBO fund = this.fundDao.findById(fundId.shortValue()); applicableFunds.add(fund); } List<PenaltyBO> applicablePenalties = new ArrayList<PenaltyBO>(); List<Integer> applicablePenaltyIds = loanProductRequest.getApplicablePenalties(); for (Integer penaltyId : applicablePenaltyIds) { PenaltyBO penalty = this.penaltyDao.findPenaltyById(penaltyId); applicablePenalties.add(penalty); } GLCodeEntity interestGlCode = this.generalLedgerDao .findGlCodeById(loanProductRequest.getAccountDetails().getInterestGlCodeId().shortValue()); GLCodeEntity principalGlCode = this.generalLedgerDao .findGlCodeById(loanProductRequest.getAccountDetails().getPrincipalClCodeId().shortValue()); String globalProductId = generateProductGlobalNum(user); LoanOfferingBO loanProduct = LoanOfferingBO.createNew(userId, globalProductId, name, shortName, description, productCategory, startDate, endDate, applicableToEntity, currency, interestTypeEntity, minRate, maxRate, defaultRate, recurrence, recurEvery, interestGlCode, principalGlCode, activeStatus, inActiveStatus, gracePeriodTypeEntity, gracePeriodDuration, waiverInterest, loanCycleCounter, loanAmountCalculation, loanInstallmentCalculation, applicableFees, applicableFunds, applicablePenalties); loanProduct.updateStatus(selectedStatus); return loanProduct; } catch (PersistenceException e) { throw new MifosRuntimeException(e); } }
From source file:org.slc.sli.ingestion.model.RecordHash.java
/** * Construct from compact, document-oriented database key/value map * * @param map/*from w w w .j a v a 2s. co m*/ * A key/value map whose fields are suitable for a document-oriented database that * has a need to keep fields short. * * @return The constructed object */ public RecordHash(Map<String, Object> map) { this(); if (null == map) { return; } id = binary2Hex((byte[]) map.get("_id")) + "_id"; hash = binary2Hex((byte[]) map.get("h")); created = ((Long) map.get("c")).longValue(); Long mapUpdated = (Long) map.get("u"); if (null == mapUpdated) { updated = created; } else { updated = mapUpdated.longValue(); } Integer mapVersion = (Integer) map.get("v"); if (null == mapVersion) { version = 0; } else { version = mapVersion.shortValue(); } String mapTenantId = (String) map.get("t"); if (null == mapTenantId) { tenantId = ""; } else { tenantId = mapTenantId; } }
From source file:com.ssic.education.handle.dao.ProLicenseDao.java
public List<ProLicense> findById(String id, Integer cerSource) { ProLicenseExample example = new ProLicenseExample(); ProLicenseExample.Criteria criteria = example.createCriteria(); if (StringUtils.isNotBlank(id)) { criteria.andRelationIdEqualTo(id); }/* w w w .j av a 2 s . co m*/ if (null != cerSource) { criteria.andCerSourceEqualTo(cerSource.shortValue()); } criteria.andStatEqualTo(DataStatus.ENABLED); List<ProLicense> proLicenses = mapper.selectByExample(example); return proLicenses; }
From source file:org.mifos.ui.core.controller.EditProductMixController.java
@RequestMapping(method = RequestMethod.GET) @ModelAttribute("formBean") public ProductMixFormBean showEditForm(@RequestParam(value = "productId", required = true) Integer productId) { List<ProductTypeDto> productTypes = this.adminServiceFacade.retrieveProductTypesApplicableToProductMix(); ProductMixFormBean formBean = productMixAssembler.createFormBean(productTypes); formBean.setProductId(productId.toString()); formBean.setProductTypeId("1"); ProductMixDetailsDto productMixDetails = adminServiceFacade .retrieveProductMixDetails(productId.shortValue(), formBean.getProductTypeId()); Map<String, String> productNameOptions = new LinkedHashMap<String, String>(); productNameOptions.put(productMixDetails.getPrdOfferingId().toString(), productMixDetails.getPrdOfferingName()); formBean.setProductNameOptions(productNameOptions); populateAllowedNotAllowedOptions(formBean, productMixDetails); return formBean; }
From source file:org.codehaus.groovy.grails.web.util.AbstractTypeConvertingMap.java
public Short getShort(String name, Integer defaultValue) { Short value = getShort(name); if (value == null && defaultValue != null) { value = defaultValue.shortValue(); }/*from www . j a va 2 s .c om*/ return value; }