List of usage examples for java.lang Long intValue
public int intValue()
From source file:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java
public List<javax.servlet.http.Cookie> getCookies() { List<javax.servlet.http.Cookie> result = new LinkedList<javax.servlet.http.Cookie>(); Set<Cookie> cookies = driver.manage().getCookies(); for (Cookie cookie : cookies) { javax.servlet.http.Cookie c = new javax.servlet.http.Cookie(cookie.getName(), cookie.getValue()); c.setDomain(cookie.getDomain()); Date expire = cookie.getExpiry(); if (expire == null) { c.setMaxAge(-1);/*ww w . ja v a 2s. c om*/ } else { Date now = Calendar.getInstance().getTime(); // Convert milli-second to second Long second = Long.valueOf((expire.getTime() - now.getTime()) / 1000); c.setMaxAge(second.intValue()); } c.setPath(cookie.getPath()); c.setSecure(cookie.isSecure()); result.add(c); } return result; }
From source file:de.jaide.courier.email.MessageHandlerEMail.java
/** * Loads the SMTP configuration from a JSON file. * //w w w. ja va 2s. co m * @param smtpConfigurationJsonLocation The SMTP configuration to load. Needs to be an absolute URL, e.g. "/configs/smtp.json" that is * loaded from the * classpath. * @throws IOException Thrown, if the SMTP configuration couldn't be read. */ private void loadSmtpConfigurations(String smtpConfigurationJsonLocation) { /* * Now load the SMTP configuration JSON file and try to parse it. */ try { /* * Load the JSON-based SMTP configuration file. */ JSONArray keyArray = (JSONArray) new JSONParser() .parse(IOUtils.toString((InputStream) MessageHandlerEMail.class .getResource(smtpConfigurationJsonLocation).getContent())); /* * Iterate through the outer array */ for (int i = 0; i < keyArray.size(); i++) { /* * Iterate through the inner array of configuration keys. */ JSONObject keysArray = (JSONObject) keyArray.get(i); for (Object keyObject : keysArray.keySet()) { /* * Get the name of the key... */ String key = (String) keyObject; JSONObject configArray = (JSONObject) keysArray.get(key); /* * ... and load the associated configuration values. */ String smtpHostname = (String) configArray.get("smtpHostname"); Long smtpPort = (Long) (configArray.get("smtpPort")); Boolean tls = (Boolean) configArray.get("tls"); Boolean ssl = (Boolean) configArray.get("ssl"); String username = (String) configArray.get("username"); String password = (String) configArray.get("password"); String fromEMail = (String) configArray.get("fromEMail"); String fromSenderName = (String) configArray.get("fromSenderName"); /* * Use the obtained values and create a new SMTP configuration. */ SmtpConfiguration smtpConfiguration = new SmtpConfiguration(key, smtpHostname, smtpPort.intValue(), tls, ssl, username, password, fromEMail, fromSenderName); smtpConfigurations.put(key, smtpConfiguration); } } } catch (IOException ioe) { throw new RuntimeException("SMTP configuration not found at '" + smtpConfigurationJsonLocation + "'", ioe); } catch (ParseException pe) { throw new RuntimeException( "SMTP configuration couldn't be loaded from '" + smtpConfigurationJsonLocation + "'", pe); } }
From source file:com.aimluck.eip.project.ProjectTaskSelectData.java
/** * ???? <BR>/*from ww w . jav a 2s . co m*/ * * @param rundata * RunData * @param context * Context * @return ResultList */ @Override protected ResultList<EipTProjectTask> selectList(RunData rundata, Context context) { if (null == selectedProjectId) { return null; } setSessionParams(rundata, context); SQLTemplate<EipTProjectTask> sqltemp = null; SQLTemplate<EipTProjectTask> sqlCountTemp = null; sqltemp = Database.sql(EipTProjectTask.class, getFetchQuery(rundata, context)); sqlCountTemp = Database.sql(EipTProjectTask.class, getCountQuery(rundata, context)); setPostgresParams(sqltemp, sqlCountTemp); ResultList<EipTProjectTask> list = new ResultList<EipTProjectTask>(); // ?? List<DataRow> result = sqltemp.fetchListAsDataRow(); for (int i = 0; i < result.size(); i++) { DataRow row = result.get(i); Object parentTaskId = row.get("parent_task_id"); Object explanation = row.get("explanation"); Object startPlanDate = row.get("start_plan_date"); Object endPlanDate = row.get("end_plan_date"); Object startDate = row.get("start_date"); Object endDate = row.get("end_date"); Object updateDate = row.get("update_date"); EipTProjectTask task = new EipTProjectTask(); // ID task.setTaskId(row.get("task_id").toString()); // ?? task.setTaskName(row.get("task_name").toString()); // ID if (parentTaskId != null) { task.setParentTaskId(Integer.valueOf(parentTaskId.toString())); } // ID task.setProjectId(Integer.valueOf(row.get("project_id").toString())); // task.setTracker(row.get("tracker").toString()); // if (explanation != null) { task.setExplanation(explanation.toString()); } // task.setStatus(row.get("status").toString()); // task.setPriority(row.get("priority").toString()); // if (startPlanDate == null) { task.setStartPlanDate(ProjectUtils.getEmptyDate()); } else { task.setStartPlanDate((Date) startPlanDate); } // if (endPlanDate == null) { task.setEndPlanDate(ProjectUtils.getEmptyDate()); } else { task.setEndPlanDate((Date) endPlanDate); } // if (startDate == null) { task.setStartDate(ProjectUtils.getEmptyDate()); } else { task.setStartDate((Date) startDate); } // if (endDate == null) { task.setEndDate(ProjectUtils.getEmptyDate()); } else { task.setEndDate((Date) endDate); } // task.setPlanWorkload(new BigDecimal(row.get("plan_workload").toString())); // ? task.setProgressRate(Integer.valueOf(row.get("progress_rate").toString())); // task.setUpdateDate((Date) updateDate); // ?? task.setIndent(Integer.valueOf(row.get("indent").toString())); list.add(task); } // ? int count = 0; List<DataRow> countResult = sqlCountTemp.fetchListAsDataRow(); for (DataRow row : countResult) { Long tmp = (Long) row.get("count"); count = tmp != null ? tmp.intValue() : 0; } // ? setPageParam(count); taskCount = count; // if (!getWhereList().isEmpty()) { indentFlg = false; } return list; }
From source file:fr.univrouen.poste.web.candidat.MyPosteCandidatureController.java
@RequestMapping(value = "/{id}/reviewFile/{idFile}") @PreAuthorize("hasPermission(#id, 'review')") public void downloadReviewFile(@PathVariable("id") Long id, @PathVariable("idFile") Long idFile, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException { try {// ww w .j a v a 2 s . c o m PosteCandidature postecandidature = PosteCandidature.findPosteCandidature(id); MemberReviewFile memberReviewFile = MemberReviewFile.findMemberReviewFile(idFile); // byte[] file = postecandidatureFile.getBigFile().getBinaryFile(); String filename = memberReviewFile.getFilename(); Long size = memberReviewFile.getFileSize(); String contentType = memberReviewFile.getContentType(); response.setContentType(contentType); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); response.setContentLength(size.intValue()); IOUtils.copy(memberReviewFile.getBigFile().getBinaryFile().getBinaryStream(), response.getOutputStream()); Calendar cal = Calendar.getInstance(); Date currentTime = cal.getTime(); //postecandidature.setModification(currentTime); logService.logActionFile(LogService.DOWNLOAD_REVIEW_ACTION, postecandidature, memberReviewFile, 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()); } }
From source file:com.inkubator.hrm.service.impl.LoanNewApplicationServiceImpl.java
@Override @Transactional(readOnly = true, isolation = Isolation.REPEATABLE_READ, propagation = Propagation.SUPPORTS, timeout = 50) public List<LoanHistoryViewModel> getListLoanHistoryByEmpDataId(Long empDataId) throws Exception { List<LoanHistoryViewModel> listLoanHistory = loanNewApplicationDao.getListLoanHistoryByEmpDataId(empDataId); for (LoanHistoryViewModel loanHistModel : listLoanHistory) { List<LoanNewApplicationInstallment> listInstallment = calculateLoanNewApplicationInstallment( loanHistModel.getLoanInterestRate().doubleValue(), loanHistModel.getTotalNumberOfInstallment(), DateTimeUtil.getDateFrom(loanHistModel.getLoanPaymentDate(), loanHistModel.getBuffer(), CommonUtilConstant.DATE_FORMAT_MONTH), loanHistModel.getLoanNominal().doubleValue(), loanHistModel.getTypeOfInterest()); LoanNewApplicationInstallment installmentMax = Lambda.selectMax(listInstallment, Lambda.on(LoanNewApplicationInstallment.class).getTotalPayment()); LoanNewApplicationInstallment lastInstallment = Lambda.selectMax(listInstallment, Lambda.on(LoanNewApplicationInstallment.class).getInstallmentDate()); loanHistModel.setInstallmentNominal(installmentMax.getTotalPayment()); loanHistModel.setLastPaymentDate(lastInstallment.getInstallmentDate()); Long totalAlreadyPaidInstallment = loanNewApplicationInstallmentDao .getTotalInstallmentByLoanNewApplicationId(loanHistModel.getLoanNewApplicationId()); loanHistModel.setTotalAlreadyPaidInstallment( totalAlreadyPaidInstallment == null ? 0 : totalAlreadyPaidInstallment.intValue()); }// ww w. java 2 s . c o m return listLoanHistory; }
From source file:fr.univrouen.poste.web.candidat.MyPosteCandidatureController.java
@RequestMapping(value = "/{id}/{idFile}") @PreAuthorize("hasPermission(#id, 'view')") public void downloadCandidatureFile(@PathVariable("id") Long id, @PathVariable("idFile") Long idFile, HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException { try {/*w w w.j a v a2 s.c o m*/ PosteCandidature postecandidature = PosteCandidature.findPosteCandidature(id); PosteCandidatureFile postecandidatureFile = PosteCandidatureFile.findPosteCandidatureFile(idFile); String filename = postecandidatureFile.getFilename(); Long size = postecandidatureFile.getFileSize(); String contentType = postecandidatureFile.getContentType(); response.setContentType(contentType); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); response.setContentLength(size.intValue()); IOUtils.copy(postecandidatureFile.getBigFile().getBinaryFile().getBinaryStream(), response.getOutputStream()); Calendar cal = Calendar.getInstance(); Date currentTime = cal.getTime(); logService.logActionFile(LogService.DOWNLOAD_ACTION, postecandidature, postecandidatureFile, 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()); } }
From source file:com.abiquo.server.core.enterprise.EnterpriseDAO.java
public DefaultEntityCurrentUsed getEnterpriseResourceUsage(final int enterpriseId) { Object[] vmResources = (Object[]) getSession().createSQLQuery(SUM_VM_RESOURCES) .setParameter("enterpriseId", enterpriseId).uniqueResult(); Long cpu = vmResources[0] == null ? 0 : ((BigDecimal) vmResources[0]).longValue(); Long ram = vmResources[1] == null ? 0 : ((BigDecimal) vmResources[1]).longValue(); Long hd = vmResources[2] == null ? 0 : ((BigDecimal) vmResources[2]).longValue(); BigDecimal extraHd = (BigDecimal) getSession().createSQLQuery(SUM_EXTRA_HD_RESOURCES) .setParameter("enterpriseId", enterpriseId).uniqueResult(); Long hdTot = extraHd == null ? hd : hd + extraHd.longValue() * 1024 * 1024; Long storage = getStorageUsage(enterpriseId) * 1024 * 1024; // Storage usage is stored in MB Long publiIp = getPublicIPUsage(enterpriseId); Long vlanCount = getVLANUsage(enterpriseId); // TODO repository // XXX checking null resource utilization (if any resource allocated) DefaultEntityCurrentUsed used = new DefaultEntityCurrentUsed(cpu.intValue(), ram, hdTot); used.setStorage(storage);//from ww w.j a v a 2s .com used.setPublicIp(publiIp); used.setVlanCount(vlanCount); return used; }
From source file:it.attocchi.jpa2.JpaController.java
public <T extends Serializable> int getItemCount(Class<T> classObj) throws Exception { int returnValue = 0; EntityManager em = getEntityManager(); try {/*from w w w. j a v a 2s. c o m*/ // StringBuffer hsqlQuery = new StringBuffer(); // hsqlQuery.append("select count(*) from "); // hsqlQuery.append(classObj.getCanonicalName()); // hsqlQuery.append(" as o"); // Query q = em.createQuery(hsqlQuery.toString()); // // returnValue = ((Long) q.getSingleResult()).intValue(); CriteriaBuilder qb = em.getCriteriaBuilder(); CriteriaQuery<Long> cq = qb.createQuery(Long.class); cq.select(qb.count(cq.from(classObj))); Long res = em.createQuery(cq).getSingleResult(); return res.intValue(); } catch (Exception e) { throw e; } finally { // Close the database connection: if (!globalTransactionOpen) { // if (em.getTransaction().isActive()) // em.getTransaction().rollback(); closeEm(); // em.close(); } } }
From source file:com.viettel.util.excel.DynamicExport.java
public void setRowHeight(int r1, int c1, int r2, int c2, Long value) throws Exception { if (value.equals(0L)) { value = 500L;/*from w w w . ja v a2 s . co m*/ } for (int i = r1; i <= r2; i++) { view.setRowHeight(i, value.intValue()); } }
From source file:gov.utah.dts.sdc.actions.BaseCommercialStudentAction.java
public Integer getTrainingTime() throws Exception { List list = (List) getTrainingList(); Long totalTime = 1L; // Set greater than 0 for (int i = 0; i < list.size(); i++) { CommercialTimes time = (CommercialTimes) list.get(i); Long startTime = time.getStartTime().getTime(); Long endTime = time.getEndTime().getTime(); totalTime = totalTime + (endTime - startTime); }// ww w .j a va2 s. com Long hours = (totalTime / 3600000L); return hours.intValue(); }