List of usage examples for java.lang Long intValue
public int intValue()
From source file:com.qiangbang.controller.wap.BusinessController.java
/** * ??//from www .j a va2 s.c om */ public void shopDetail() { UserService userService = Duang.duang(UserService.class); int uid = getParaToInt(); int count = userService.getBusCount(uid);// double busamount = userService.getBusSumPrice(uid);// Business business = Business.me.findByUid(uid); Record record = Evaluate.me.findAvgService(uid); double avgService = 0; double avgSpeed = 0; double avgQuality = 0; int sum = 0; int goodper = 0; HashMap<String, Object> res = new HashMap<String, Object>(); if (record != null) { BigDecimal serv = record.getBigDecimal("serv"); avgService = serv == null ? 0 : serv.doubleValue(); BigDecimal speed = record.getBigDecimal("speed"); avgSpeed = speed == null ? 0 : speed.doubleValue(); BigDecimal qua = record.getBigDecimal("qua"); avgQuality = qua == null ? 0 : qua.doubleValue(); res.put("avgService", avgService); res.put("avgSpeed", avgSpeed); res.put("avgQuality", avgQuality); double allavg = avgService + avgSpeed + avgQuality; if (allavg > 0) { res.put("allavg", allavg / 3); } else { res.put("allavg", 0); } Long esum = record.getLong("esum"); sum = esum == null ? 0 : esum.intValue(); Long good = record.getLong("good"); goodper = good == null ? 0 : good.intValue(); if (sum == 0 || goodper == 0) { res.put("goodpercent", 0); } else { res.put("goodpercent", ((goodper / sum) * 100)); } } setAttr("res", res); setAttr("count", count); setAttr("busamount", busamount); setAttr("business", business); setAttr("evalrec", record); setAttr("isself", 0); render("shop/index.jsp"); }
From source file:iddb.web.security.dao.SessionDAO.java
public void cleanUp(Long expire) { String sql;/*from w ww. j a v a2 s . c o m*/ sql = "delete from user_session where created < ?"; Connection conn = null; try { conn = ConnectionFactory.getMasterConnection(); PreparedStatement st = conn.prepareStatement(sql); st.setTimestamp(1, new Timestamp(DateUtils.addDays(new Date(), expire.intValue() * -1).getTime())); int r = st.executeUpdate(); log.debug("Removed {} sessions", Integer.toString(r)); } catch (SQLException e) { log.error("cleanUp", e); } catch (IOException e) { log.error("cleanUp", e); } finally { try { if (conn != null) conn.close(); } catch (Exception e) { } } }
From source file:com.qiangbang.controller.wap.BusinessController.java
public void index() { Users users = (Users) getRequest().getSession().getAttribute("users"); if (users == null) { System.out.println("business index session usess is null"); redirect(//from ww w .j a va2 s. com "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx042031f85a80d192&redirect_uri=http://qb.qq12306.cn/wapIndex/wxcallBack&response_type=code&scope=snsapi_base&state=2#wechat_redirect"); return; } UserService userService = Duang.duang(UserService.class); int uid = users.getInt("id"); int count = userService.getBusCount(uid);// double busamount = userService.getBusSumPrice(uid);// Business business = Business.me.findByUid(uid); Record record = Evaluate.me.findAvgService(uid); double avgService = 0; double avgSpeed = 0; double avgQuality = 0; int sum = 0; int goodper = 0; // Constants.MSGMAP.put(uid+"","??!"); HashMap<String, Object> res = new HashMap<String, Object>(); if (record != null) { BigDecimal serv = record.getBigDecimal("serv"); avgService = serv == null ? 0 : serv.doubleValue(); BigDecimal speed = record.getBigDecimal("speed"); avgSpeed = speed == null ? 0 : speed.doubleValue(); BigDecimal qua = record.getBigDecimal("qua"); avgQuality = qua == null ? 0 : qua.doubleValue(); res.put("avgService", avgService); res.put("avgSpeed", avgSpeed); res.put("avgQuality", avgQuality); double allavg = avgService + avgSpeed + avgQuality; if (allavg > 0) { res.put("allavg", allavg / 3); } else { res.put("allavg", 0); } Long esum = record.getLong("esum"); sum = esum == null ? 0 : esum.intValue(); Long good = record.getLong("good"); goodper = good == null ? 0 : good.intValue(); if (sum == 0 || goodper == 0) { res.put("goodpercent", 0); } else { res.put("goodpercent", ((goodper / sum) * 100)); } } setAttr("res", res); setAttr("count", count); setAttr("busamount", busamount); setAttr("business", business); setAttr("evalrec", record); setAttr("isself", 1); render("shop/index.jsp"); }
From source file:no.dusken.aranea.service.ImageServiceImpl.java
public Integer getImageNumberByPerson(Person p) { Long numberOfImages = 0L; try {/*ww w.ja v a 2 s . c o m*/ Map<String, Object> map = new HashMap<String, Object>(); map.put("person", p); numberOfImages = (Long) DataAccessUtils .uniqueResult(genericDao.getByNamedQuery("imagenumber_byPerson", map)); } catch (DataAccessException dae) { log.info("Unable to get number of images", dae); } return numberOfImages.intValue(); }
From source file:com.sfs.captor.controller.RequirementAction.java
/** * Add business rule action//from w w w. j a va2s . com * * @return outcome */ public void addBusinessRule() { Long cnt = getRequirementRuleCount(); this.requirementRule = new RequirementRule(cnt.intValue() + 1); // product release is inherited this.requirementRule.setProductRelease(this.requirement.getProductRelease()); }
From source file:org.exoplatform.addons.es.client.ElasticIndexingClient.java
private void logBulkResponseItem(JSONObject item, long executionTime) { for (Map.Entry operation : (Set<Map.Entry>) item.entrySet()) { String operationName = operation.getKey() == null ? null : (String) operation.getKey(); if (operation.getValue() != null) { JSONObject operationDetails = (JSONObject) operation.getValue(); String index = operationDetails.get("_index") == null ? null : (String) operationDetails.get("_index"); String type = operationDetails.get("_type") == null ? null : (String) operationDetails.get("_type"); String id = operationDetails.get("_id") == null ? null : (String) operationDetails.get("_id"); Long status = operationDetails.get("status") == null ? null : (Long) operationDetails.get("status"); String error = operationDetails.get("error") == null ? null : (String) ((JSONObject) operationDetails.get("error")).get("reason"); Integer httpStatusCode = status == null ? null : status.intValue(); if (ElasticIndexingAuditTrail.isError(httpStatusCode)) { auditTrail.logRejectedDocumentBulkOperation(operationName, id, index, type, httpStatusCode, error, executionTime); } else { if (auditTrail.isFullLogEnabled()) { auditTrail.logAcceptedBulkOperation(operationName, id, index, type, httpStatusCode, error, executionTime); }/*from w w w .j a v a 2s .co m*/ } } } }
From source file:de.bps.onyx.util.ExamPool.java
private byte[] getContentPackage(RepositoryEntry repositoryEntry) { File cpFile = FileResourceManager.getInstance().getFileResource(repositoryEntry.getOlatResource()); if (cpFile == null || !cpFile.exists()) { cpFile = getCP(repositoryEntry); }// w w w . j av a 2 s .co m Long fileLength = cpFile.length(); byte[] contentPackage = new byte[fileLength.intValue()]; java.io.FileInputStream inp = null; try { inp = new java.io.FileInputStream(cpFile); inp.read(contentPackage); } catch (FileNotFoundException e) { log.error("Missing file: " + cpFile.getAbsolutePath(), e); } catch (IOException e) { log.error("Error copying file: " + cpFile.getAbsolutePath(), e); } finally { IOUtils.closeQuietly(inp); } return contentPackage; }
From source file:de.iteratec.iteraplan.persistence.dao.GenericBaseDAO.java
/** {@inheritDoc} */ public boolean doesObjectWithDifferentIdExist(final T identifier, final String name) { Assert.notNull(name);/*from w ww . j ava 2s .c o m*/ HibernateCallback<Long> callback = new HibernateCallback<Long>() { public Long doInHibernate(Session session) { Criteria c = session.createCriteria(getPersistentClass()); c.setProjection(Projections.count(getNameAttribute())); c.add(Restrictions.eq(getNameAttribute(), name.trim()).ignoreCase()); if (identifier != null) { c.add(Restrictions.ne("id", identifier)); } Object result = c.uniqueResult(); // if Hibernate returns an Integer, convert it to long if (result instanceof Integer) { return Long.valueOf(((Integer) result).longValue()); } // otherwise we expect a Long to be returned return (Long) result; } }; Long count = getHibernateTemplate().execute(callback); return count.intValue() > 0 ? true : false; }
From source file:org.kuali.mobility.push.dao.DeviceDaoImpl.java
public boolean doesDeviceHaveUsername(String deviceid) { Query query = getEntityManager().createNamedQuery("Device.hasUsernameForDeviceId"); query.setParameter("deviceId", deviceid); Long matches = (Long) query.getSingleResult(); return (matches.intValue() != 0); }
From source file:fr.univrouen.poste.web.membre.PosteAPourvoirController.java
@RequestMapping(value = "/{id}/{idFile}") @PreAuthorize("hasPermission(#id, 'viewposte')") public void downloadPosteFile(@PathVariable("id") Long id, @PathVariable("idFile") Long idFile, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException { try {/*from w ww. j ava2 s . c o m*/ PosteAPourvoir poste = PosteAPourvoir.findPosteAPourvoir(id); PosteAPourvoirFile posteFile = PosteAPourvoirFile.findPosteAPourvoirFile(idFile); String filename = posteFile.getFilename(); Long size = posteFile.getFileSize(); String contentType = posteFile.getContentType(); response.setContentType(contentType); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); response.setContentLength(size.intValue()); IOUtils.copy(posteFile.getBigFile().getBinaryFile().getBinaryStream(), response.getOutputStream()); Calendar cal = Calendar.getInstance(); Date currentTime = cal.getTime(); logService.logActionPosteFile(LogService.DOWNLOAD_ACTION, poste, posteFile, request, currentTime); } catch (IOException ioe) { String ip = request.getRemoteAddr(); logger.warn("Download IOException, that can be just because the client [" + ip + "] canceled the download process : " + ioe.getCause()); } }