List of usage examples for java.lang Long intValue
public int intValue()
From source file:com.shengpay.website.common.service.impl.DepositeLimitServiceImpl.java
@Override public DepositLimitResponse queryLimit(String ptid, String ruleID, BigDecimal currentDepositAmount) { DepositLimitResponse response = new DepositLimitResponse(); DepositLimitDO limitDO = null;//from w w w .ja v a2 s. com try { limitDO = depositLimitDAO.queryLimitRecordByRule(ruleID); if (null != limitDO) { String productCode = limitDO.getProductCode(); //?? String depositCode = limitDO.getDepositCode(); //? String depositChannel = limitDO.getDepositChannel(); //? Long validTimeType = limitDO.getValidTime(); // 0 1 2 if (null != validTimeType) { response.setValidTimeType(validTimeType.intValue()); } //?? FundsStatQueryRequest request = new FundsStatQueryRequest(); request.setMemberId(ptid); request.setRulePackageId(2L); ProductPaymentPackage[] productGroups = buildProductPaymentPackage(productCode, depositCode, depositChannel); request.setProductGroup(productGroups); StatisPeriodEnum requestStatisPeriodEnum = null; if (0L == validTimeType) { requestStatisPeriodEnum = StatisPeriodEnum.DAY; // } else if (1L == validTimeType) { requestStatisPeriodEnum = StatisPeriodEnum.MONTH; // } else if (2L == validTimeType) { requestStatisPeriodEnum = StatisPeriodEnum.YEAR; // } request.setPeriod(requestStatisPeriodEnum); String sourceCode = "442"; request.setSourceCode(sourceCode); FundsStatQueryResponse fundsStatQueryResponse = fundsStatQueryService.query(request); int limitTimes = -1; BigDecimal limitAmount = null; if (null != fundsStatQueryResponse) { String returnCode = fundsStatQueryResponse.getReturnCode(); if (null != returnCode) { if ("0000".equals(returnCode) || "0002".equals(returnCode)) { try { limitTimes = fundsStatQueryResponse.getStatTimes(); limitAmount = new BigDecimal(fundsStatQueryResponse.getStatResult()); response.setDepositeAmount(limitAmount); } catch (Throwable t) { logger.error("Execute limit amount from FundsStatQueryService.query() make error!", t); } } } } Long timesRule = limitDO.getDepositTimes(); Long amountRule = limitDO.getDepositAmount(); if (null != timesRule) { response.setRuleTimes(timesRule); if (limitTimes >= timesRule) { response.setTimesLimit(Boolean.TRUE); } } if (null != amountRule) { response.setRuleAmount(amountRule); if (null != limitAmount) { if (currentDepositAmount != null) { //??+?? ?? limitAmount = limitAmount.add(currentDepositAmount); } if (limitAmount.doubleValue() > amountRule) { response.setAmountLimit(Boolean.TRUE); } } } response.setSuccess(Boolean.TRUE); } else { response.setSuccess(Boolean.FALSE); response.setErrorMessage("By ruleID[" + ruleID + "] query db is null."); } } catch (Throwable t) { response.setSuccess(Boolean.FALSE); response.setErrorMessage("Not found ruleID [" + ruleID + "]."); logger.error("execute query depositlimit make error!", t); } return response; }
From source file:com.abiquo.server.core.cloud.VirtualApplianceDAO.java
/** * @param user, only users with restricted VDCs. If no restricted then use user = null *//*from w w w . java 2 s . c o m*/ public List<VirtualAppliance> findByEnterprise(final Enterprise enterprise, final FilterOptions filterOptions, final User user) { if (filterOptions == null) { return findByEnterprise(enterprise); } // Check if the orderBy element is actually one of the available ones VirtualAppliance.OrderByEnum orderByEnum = VirtualAppliance.OrderByEnum .valueOf(filterOptions.getOrderBy().toUpperCase()); Integer limit = filterOptions.getLimit(); Integer startwith = filterOptions.getStartwith(); String filter = filterOptions.getFilter(); boolean asc = filterOptions.getAsc(); Criteria criteria = createCriteria(enterprise, filter, orderByEnum, asc); // Check if the page requested is bigger than the last one Long total = count(criteria); criteria = createCriteria(enterprise, filter, orderByEnum, asc); Integer totalResults = total.intValue(); limit = limit != 0 ? limit : totalResults; if (limit != null) { criteria.setMaxResults(limit); } if (startwith >= totalResults) { startwith = totalResults - limit; } criteria.setFirstResult(startwith); criteria.setMaxResults(limit); if (user != null) { criteria.createAlias(VirtualAppliance.VIRTUAL_DATACENTER_PROPERTY, "virtualdatacenter"); criteria.add( Restrictions.in("virtualdatacenter." + PersistentEntity.ID_PROPERTY, availableVdsToUser(user))); } List<VirtualAppliance> result = getResultList(criteria); PagedList<VirtualAppliance> page = new PagedList<VirtualAppliance>(); page.addAll(result); page.setCurrentElement(startwith); page.setPageSize(limit); page.setTotalResults(totalResults); return page; }
From source file:com.abiquo.server.core.cloud.VirtualApplianceDAO.java
public List<VirtualAppliance> findByVirtualDatacenter(final VirtualDatacenter virtualDatacenter, final FilterOptions filterOptions) { if (filterOptions == null) { return findByVirtualDatacenter(virtualDatacenter); }//from ww w. jav a2s. c o m // Check if the orderBy element is actually one of the available ones VirtualAppliance.OrderByEnum orderByEnum = VirtualAppliance.OrderByEnum .valueOf(filterOptions.getOrderBy().toUpperCase()); Integer limit = filterOptions.getLimit(); Integer startwith = filterOptions.getStartwith(); String filter = filterOptions.getFilter(); boolean asc = filterOptions.getAsc(); Criteria criteria = createCriteria(virtualDatacenter, filter, orderByEnum, asc); // Check if the page requested is bigger than the last one Long total = count(criteria); criteria = createCriteria(virtualDatacenter, filter, orderByEnum, asc); Integer totalResults = total.intValue(); limit = limit != 0 ? limit : totalResults; if (limit != null) { criteria.setMaxResults(limit); } if (startwith >= totalResults) { startwith = totalResults - limit; } criteria.setFirstResult(startwith); criteria.setMaxResults(limit); List<VirtualAppliance> result = getResultList(criteria); PagedList<VirtualAppliance> page = new PagedList<VirtualAppliance>(); page.addAll(result); page.setCurrentElement(startwith); page.setPageSize(limit); page.setTotalResults(totalResults); return page; }
From source file:com.abiquo.server.core.enterprise.EnterpriseDAO.java
public List<Enterprise> findByPricingTemplate(Integer firstElem, final PricingTemplate pt, final boolean included, final String filterName, final Integer numResults, final Integer idEnterprise) { // Check if the page requested is bigger than the last one Criteria criteria = createCriteria(pt, included, filterName, idEnterprise); Long total = count(criteria); if (firstElem >= total.intValue()) { firstElem = total.intValue() - numResults; }//from w w w. j a va2 s .co m criteria = createCriteria(pt, included, filterName, idEnterprise); criteria.setFirstResult(firstElem); criteria.setMaxResults(numResults); List<Enterprise> result = getResultList(criteria); PagedList<Enterprise> page = new PagedList<Enterprise>(); page.addAll(result); page.setCurrentElement(firstElem); page.setPageSize(numResults); page.setTotalResults(total.intValue()); return page; }
From source file:com.unistrong.tracker.handle.SpotHandle.java
/** * /*from ww w .j av a2 s. c o m*/ */ public Map<String, Object> statistic(String userIdStr, String deviceSn, String begin, String end, String targetIdStr, String appName) { Map<String, Object> rs = new HashMap<String, Object>(); HttpUtil.validateNull(new String[] { "sn" }, new String[] { deviceSn }); HttpUtil.validateLong(new String[] { "begin", "end" }, new String[] { begin, end }); Long userId = HttpUtil.getLong(userIdStr); Long beginLong = HttpUtil.getLong(begin); Long endLong = HttpUtil.getLong(end); Device device = deviceService.get(deviceSn); String unit = device.getType() == 2 ? MessageManager.CALORIE() : MessageManager.KIL(); Long now = System.currentTimeMillis(); String str = DateUtil.longStr(now, "yyyyMMdd"); Long todayLong = DateUtil.strLong(str, "yyyyMMdd"); List<Report> reports = new ArrayList<Report>(); if (endLong >= todayLong) { userId = getUserId(userIdStr, targetIdStr, appName, deviceSn); List<Spot> list = null; if (device.getType() == 1) { list = spotService.getTrack(deviceSn, todayLong, endLong); } else { list = spotService.getTrackGps(deviceSn, todayLong, endLong); } Report today = new Report(deviceSn, todayLong); SpotToWeb.statisticTodaySpeed(list, today, device.getType()); SpotToWeb.statisticToday(list, today, device.getType()); Long overSpeedTime = alarmService.overSpeedTime(deviceSn, todayLong, endLong);// today.setSpeeding(overSpeedTime.intValue()); long outFence = alarmService.outFenceTime(deviceSn, todayLong, endLong); today.setOutFence((int) outFence); reports.add(today); } String beginLongStr = DateUtil.longStr(beginLong, "yyyyMMdd"); Long beginLongDay = DateUtil.strLong(beginLongStr, "yyyyMMdd"); reports.addAll(reportService.find(deviceSn, beginLongDay, endLong)); int sumSpeeding = 0; for (Report report : reports) { sumSpeeding += report.getSpeeding(); } List<SpeedVo> speedVos = SpotToWeb.statisticSpeed(reports, device.getType()); long outFence = alarmService.outFenceTime(deviceSn, beginLongDay, endLong); rs.put("mileages", reports);// (? ) rs.put("speeding", sumSpeeding);// rs.put("outfence", outFence); rs.put("distributed", speedVos);// rs.put("unit", unit);// ?? return rs; }
From source file:com.seajas.search.profiler.controller.FeedController.java
/** * Retrieve the actual data.//from w w w . j a v a 2 s .c o m * * @param filterQuery * @param page * @param results * @return FeedPagingResult */ public FeedPagingResult retrieveData(final String filterQuery, final Integer page, final Integer results) { Long totalFeeds = profilerService.getFeedCount(filterQuery).longValue(); Integer actualPage = page != -1 ? page : totalFeeds == 0 ? 0 : (totalFeeds.intValue() - 1) / results; // Now retrieve the feeds List<Feed> feeds = profilerService.getPagedFeeds(actualPage * results, results, filterQuery); return new FeedPagingResult(actualPage, results, totalFeeds, feeds); }
From source file:com.interaction.example.odata.multicompany.ODataMulticompanyITCase.java
/** * GET item, check link to another entity *//*from w w w . j a va 2s . c o m*/ @Test public void getFlightLinksToFlightSchedule() throws Exception { ODataConsumer consumer = ODataJerseyConsumer.newBuilder(baseUri).build(); OEntity flight = consumer.getEntity(FLIGHT_ENTITYSET_NAME, 2).execute(); Long flightID = (Long) flight.getProperty("flightID").getValue(); assertEquals(2, flightID.intValue()); Long flightScheduleNum = (Long) flight.getProperty("flightScheduleNum").getValue(); // there should be one link to one flight schedule for this flight assertEquals(1, flight.getLinks().size()); assertTrue(containsLink(flight.getLinks(), FLIGHT_ENTITYSET_NAME + "(" + flightID + ")/flightSchedule") || containsLink(flight.getLinks(), FLIGHT_SCHEDULE_ENTITYSET_NAME + "(" + flightScheduleNum + ")")); }
From source file:org.fatal1t.forexapp.spring.api.adapters.APISyncAdapter.java
public GetTradingHoursResp GetTradingHours(GetTradingHoursReq request) { List<String> symbols = request.getSymbols(); GetTradingHoursResp data = null;//ww w. j a v a2s .co m try { TradingHoursResponse response = APICommandFactory.executeTradingHoursCommand(connector, symbols); data = new GetTradingHoursResp(); log.info("Prijata data: " + response.toString().substring(0, 10)); for (String symbol : response.getSymbols()) { SymbolTradingHours hours = new SymbolTradingHours(symbol); int index = response.getSymbols().indexOf(symbol); List<HoursRecord> respHours = response.getQuotes().get(index); if (respHours != null) { respHours.forEach((HoursRecord hour) -> { Long day = hour.getDay(); hours.getQuoteHours().add( new HourData(day.intValue(), new Time(hour.getFromT()), new Time(hour.getToT()))); }); } respHours = response.getTrading().get(index); if (respHours != null) { respHours.forEach((HoursRecord hour) -> { Long day = hour.getDay(); hours.getQuoteHours().add( new HourData(day.intValue(), new Time(hour.getFromT()), new Time(hour.getToT()))); }); } data.addSymbolTradingHours(hours); } } catch (APICommandConstructionException | APICommunicationException | APIReplyParseException | APIErrorResponse ex) { log.fatal("error v komunikaci "); log.fatal(ex); } return data; }
From source file:it.geosolutions.opensdi.operations.FolderManagerOperationController.java
/** * Download a file with a stream//from w w w . j a v a2 s.c o m * * @param resp * @param fileName * @param filePath * @return */ @SuppressWarnings("resource") private ResponseEntity<byte[]> download(HttpServletResponse resp, String fileName, String filePath) { final HttpHeaders headers = new HttpHeaders(); File toServeUp = new File(filePath); InputStream inputStream = null; try { inputStream = new FileInputStream(toServeUp); } catch (FileNotFoundException e) { // Also useful, this is a good was to serve down an error message String msg = "ERROR: Could not find the file specified."; headers.setContentType(MediaType.TEXT_PLAIN); return new ResponseEntity<byte[]>(msg.getBytes(), headers, HttpStatus.NOT_FOUND); } resp.setContentType("application/octet-stream"); resp.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); Long fileSize = toServeUp.length(); resp.setContentLength(fileSize.intValue()); OutputStream outputStream = null; try { outputStream = resp.getOutputStream(); } catch (IOException e) { String msg = "ERROR: Could not generate output stream."; headers.setContentType(MediaType.TEXT_PLAIN); return new ResponseEntity<byte[]>(msg.getBytes(), headers, HttpStatus.NOT_FOUND); } byte[] buffer = new byte[1024]; int read = 0; try { while ((read = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, read); } // close the streams to prevent memory leaks outputStream.flush(); outputStream.close(); inputStream.close(); } catch (Exception e) { String msg = "ERROR: Could not read file."; headers.setContentType(MediaType.TEXT_PLAIN); return new ResponseEntity<byte[]>(msg.getBytes(), headers, HttpStatus.NOT_FOUND); } return null; }
From source file:it.uniud.ailab.dcore.annotation.annotators.SimpleNGramGeneratorAnnotator.java
/** * Loads the nGram database according to the path and language specified in * the constructor./*www .ja va 2s. c o m*/ * * @param lang the language to search in the database * @throws IOException if the database file is nonexistent or non accessible * @throws ParseException if the database file is malformed * @throws NullPointerException if the language requested is not in the * database */ private void loadDatabase(Locale lang) throws IOException, ParseException { // Get the POS pattern file and parse it. InputStreamReader is = FileSystem.getInputStreamReaderFromPath(posDatabasePaths.get(lang)); BufferedReader reader = new BufferedReader(is); Object obj = (new JSONParser()).parse(reader); JSONObject fileblock = (JSONObject) obj; JSONArray pagesBlock = (JSONArray) fileblock.get("languages"); // Find the required language in the specified file Iterator<JSONObject> iterator = pagesBlock.iterator(); JSONObject languageBlock = null; while (iterator.hasNext()) { languageBlock = (iterator.next()); String currLanguage = (String) languageBlock.get("language"); if (currLanguage.equals(lang.getLanguage())) { break; } } // If the language is not supported by the database, stop the execution. if (languageBlock == null) { throw new NullPointerException( "Language " + lang.getLanguage() + " not found in file " + posDatabasePaths.get(lang)); } JSONArray patternBlock = (JSONArray) languageBlock.get("patterns"); try { maxGramSize = Integer.parseInt(languageBlock.get("maxGramSize").toString()); } catch (Exception e) { // the field is badly formatted or non-existent: set to default maxGramSize = DEFAULT_MAX_NGRAM_SIZE; ; } Iterator<JSONObject> patternIterator = patternBlock.iterator(); // put the patterns in the hashmap while (patternIterator.hasNext()) { JSONObject pattern = (patternIterator.next()); String POSpattern = (String) pattern.get("pattern"); Long nounCount = (Long) pattern.get("nounCount"); validPOSPatterns.put(POSpattern, nounCount.intValue()); } }