List of usage examples for java.lang Long intValue
public int intValue()
From source file:gallery.web.controller.pages.types.WallpaperTagCloudType.java
public String getOptimizationPhraze(int cur_page, List<Pages> navigation) { if (navigation != null && navigation.size() > 1) { //getting pre last item Long id = navigation.get(navigation.size() - 2).getId(); Long count = optimizationService.getRowCount(OPTIMIZATION_WHERE, new Object[] { id, Boolean.TRUE }); if (count > 0) { int page_num = cur_page % count.intValue(); return (String) optimizationService.getSinglePropertyUOrdered("text", OPTIMIZATION_WHERE, new Object[] { id, Boolean.TRUE }, page_num); }//from w ww .j a v a 2 s . c o m } return null; }
From source file:org.tonguetied.audit.AuditRepositoryImpl.java
public PaginatedList<AuditLogRecord> getAuditLog(final Integer firstResult, final Integer maxResults) { Query query = getSession().getNamedQuery(QUERY_GET_AUDIT_LOG); if (firstResult != null) query.setFirstResult(firstResult); if (maxResults != null) query.setMaxResults(maxResults); Long maxListSize = 0L; final List<AuditLogRecord> queryList = query.list(); if (queryList.size() > 0) maxListSize = (Long) getSession().getNamedQuery(QUERY_AUDIT_LOG_RECORD_COUNT).uniqueResult(); return new PaginatedList<AuditLogRecord>(queryList, maxListSize.intValue()); }
From source file:com.ar.dev.tierra.api.dao.impl.ChartDAOImpl.java
@Override public List<Chart> getVentaMedioPago(int idMedioPago) { Calendar calendarInitial = Calendar.getInstance(); Calendar calendarClosing = Calendar.getInstance(); calendarInitial.set(Calendar.HOUR_OF_DAY, 0); calendarInitial.set(Calendar.MINUTE, 0); calendarInitial.set(Calendar.SECOND, 0); calendarInitial.set(Calendar.MILLISECOND, 0); Date fromDate = calendarInitial.getTime(); calendarClosing.set(Calendar.HOUR_OF_DAY, 23); calendarClosing.set(Calendar.MINUTE, 59); calendarClosing.set(Calendar.SECOND, 59); calendarClosing.set(Calendar.MILLISECOND, 59); Date toDate = calendarClosing.getTime(); int days = 0; List<Chart> chartMedioPago = new ArrayList<>(); while (days <= 6) { Chart chart = new Chart(); Criteria metodo = getSession().createCriteria(MetodoPagoFactura.class); metodo.add(Restrictions.eq("estado", true)); Criteria planPago = metodo.createCriteria("planPago"); Criteria tarjeta = planPago.createCriteria("tarjeta"); Criteria medioPago = tarjeta.createCriteria("medioPago"); medioPago.add(Restrictions.eq("idMedioPago", idMedioPago)); metodo.add(Restrictions.between("fechaCreacion", fromDate, toDate)); metodo.setProjection(Projections.rowCount()); Long counter = (Long) metodo.uniqueResult(); if (counter != null) { chart.setValue(counter.intValue()); } else {/* w ww. ja va 2 s. c o m*/ chart.setValue(0); } chart.setDate(fromDate); chartMedioPago.add(chart); calendarInitial.add(Calendar.DAY_OF_MONTH, -1); fromDate = calendarInitial.getTime(); calendarClosing.add(Calendar.DAY_OF_MONTH, -1); toDate = calendarClosing.getTime(); days++; } return chartMedioPago; }
From source file:com.caricah.iotracah.datastore.ignitecache.internal.impl.MessageHandler.java
private int getPartitionClientMessageId(String sessionId, boolean isInBound, long id) { String queryForCount = "SELECT " + "(SELECT MAX(messageId) FROM PublishMessage WHERE clientId = ? AND isInbound = ? AND id < ? ) " + "+ (SELECT COUNT(id) FROM PublishMessage WHERE clientId = ? AND isInbound = ? AND id <= ? ) " + " AS newId"; Object[] params = { sessionId, isInBound, id, sessionId, isInBound, id }; Long currentMax = getByQueryAsValue(Long.class, queryForCount, params).toBlocking().single(); if (Objects.isNull(currentMax)) { return 1; } else {/* w w w . j ava 2 s .c o m*/ return currentMax.intValue(); } }
From source file:mx.edu.um.mateo.inventario.dao.impl.CancelacionDaoHibernate.java
@Override @Transactional(readOnly = true)/*from www .j av a2 s. c o m*/ public Map<String, Object> lista(Map<String, Object> params) { log.debug("Buscando lista de cancelaciones con params {}", params); if (params == null) { params = new HashMap<>(); } if (!params.containsKey("max")) { params.put("max", 10); } else { params.put("max", Math.min((Integer) params.get("max"), 100)); } if (params.containsKey("pagina")) { Long pagina = (Long) params.get("pagina"); Long offset = (pagina - 1) * (Integer) params.get("max"); params.put("offset", offset.intValue()); } if (!params.containsKey("offset")) { params.put("offset", 0); } Criteria criteria = currentSession().createCriteria(Cancelacion.class); Criteria countCriteria = currentSession().createCriteria(Cancelacion.class); if (params.containsKey("almacen")) { criteria.createCriteria("almacen").add(Restrictions.idEq(params.get("almacen"))); countCriteria.createCriteria("almacen").add(Restrictions.idEq(params.get("almacen"))); } if (params.containsKey("fechaIniciado")) { log.debug("Buscando desde {}", params.get("fechaIniciado")); criteria.add(Restrictions.ge("fechaCreacion", params.get("fechaIniciado"))); countCriteria.add(Restrictions.ge("fechaCreacion", params.get("fechaIniciado"))); } else { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 1); log.debug("Asignando busqueda desde {}", calendar.getTime()); criteria.add(Restrictions.ge("fechaCreacion", calendar.getTime())); countCriteria.add(Restrictions.ge("fechaCreacion", calendar.getTime())); } if (params.containsKey("fechaTerminado")) { log.debug("Buscando hasta {}", params.get("fechaTerminado")); criteria.add(Restrictions.le("fechaCreacion", params.get("fechaTerminado"))); countCriteria.add(Restrictions.le("fechaCreacion", params.get("fechaTerminado"))); } if (params.containsKey("filtro")) { String filtro = (String) params.get("filtro"); Disjunction propiedades = Restrictions.disjunction(); propiedades.add(Restrictions.ilike("folio", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("comentarios", filtro, MatchMode.ANYWHERE)); criteria.add(propiedades); countCriteria.add(propiedades); } if (params.containsKey("order")) { String campo = (String) params.get("order"); if (params.get("sort").equals("desc")) { criteria.addOrder(Order.desc(campo)); } else { criteria.addOrder(Order.asc(campo)); } } else { criteria.addOrder(Order.desc("fechaCreacion")); } if (!params.containsKey("reporte")) { criteria.setFirstResult((Integer) params.get("offset")); criteria.setMaxResults((Integer) params.get("max")); } params.put("cancelaciones", criteria.list()); countCriteria.setProjection(Projections.rowCount()); params.put("cantidad", (Long) countCriteria.list().get(0)); return params; }
From source file:com.insoul.ti.controller.ContestEntryController.java
@RequestMapping("/list") public ModelAndView list(@Valid ContestEntryListRequest request, BindingResult result) { ModelAndView mv = createModelView(CONTEST_ENTRY_LIST, request); PageQuery query = request.init().getQuery(); ContestEntryCriteria criteria = new ContestEntryCriteria(); criteria.setLimit(query.getPage_size()); criteria.setOffset(Long.valueOf(query.getIndex()).intValue()); criteria.setContestId(request.getContestId()); criteria.setUserId(request.getUserId()); List<ContestEntry> list = contestEntryDAO.queryContestEntry(criteria); Long count = contestEntryDAO.countContestEntry(criteria); query.setCount((count == null || count <= 0L) ? 0 : count.intValue()); List<ContestEntryVO> voList = new ArrayList<ContestEntryVO>(); if (CollectionUtils.isNotEmpty(list)) { for (ContestEntry contestEntry : list) { voList.add(toContestEntryVO(contestEntry)); }// w w w . ja v a 2 s. c o m mv.addObject("query", query); mv.addObject("contestEntryList", voList); mv.addObject("success", true); mv.addObject("req", request); return mv; } mv.addObject("query", query); mv.addObject("contestEntryList", voList); mv.addObject("success", false); mv.addObject("req", request); return mv; }
From source file:com.m3.openid4java.server.MemcachedServerAssociationStore.java
void saveAssociation(ServerAssociation serverAssociation) throws Exception { Long expirationSeconds = (serverAssociation.getDatetimeToExpire().getTime() - System.currentTimeMillis()) / 1000;/* w w w . j a v a2 s .com*/ memcached.getClient().set(toKey(serverAssociation.getHandle()), expirationSeconds.intValue(), serverAssociation); }
From source file:com.almende.eve.state.redis.RedisState.java
@Override public int size() { Long res = Long.valueOf(0); final Jedis redis = provider.getInstance(); res = redis.scard(getId() + "_" + KEYS); provider.returnInstance(redis);/*from w w w . j a v a 2s .co m*/ return res.intValue(); }
From source file:de.ingrid.iplug.ckan.index.producer.CkanRecordSetProducer.java
@SuppressWarnings("unchecked") private void createRecordIdsFromSearch() { try {/*w w w .j a v a 2 s. co m*/ if (log.isDebugEnabled()) { log.debug("Requesting URL: " + searchUrl); } JSONObject parse = requestJsonUrl(searchUrl); Long count = (Long) parse.get("count"); JSONArray results = (JSONArray) parse.get("results"); this.recordIdIterator = results.iterator(); this.numRecords = count.intValue(); } catch (Exception e) { log.error("Error creating record ids.", e); } }
From source file:mx.edu.um.mateo.general.dao.impl.OrganizacionDaoHibernate.java
@Override @Transactional(readOnly = true)//from w ww.j a v a 2 s .com public Map<String, Object> lista(Map<String, Object> params) { log.debug("Buscando lista de organizaciones con params {}", params); if (params == null) { params = new HashMap<>(); } if (!params.containsKey("max")) { params.put("max", 10); } else { params.put("max", Math.min((Integer) params.get("max"), 100)); } if (params.containsKey("pagina")) { Long pagina = (Long) params.get("pagina"); Long offset = (pagina - 1) * (Integer) params.get("max"); params.put("offset", offset.intValue()); } if (!params.containsKey("offset")) { params.put("offset", 0); } Criteria criteria = currentSession().createCriteria(Organizacion.class); Criteria countCriteria = currentSession().createCriteria(Organizacion.class); if (params.containsKey("filtro")) { String filtro = (String) params.get("filtro"); Disjunction propiedades = Restrictions.disjunction(); propiedades.add(Restrictions.ilike("nombre", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("nombreCompleto", filtro, MatchMode.ANYWHERE)); criteria.add(propiedades); countCriteria.add(propiedades); } if (params.containsKey("order")) { String campo = (String) params.get("order"); if (params.get("sort").equals("desc")) { criteria.addOrder(Order.desc(campo)); } else { criteria.addOrder(Order.asc(campo)); } } if (!params.containsKey("reporte")) { criteria.setFirstResult((Integer) params.get("offset")); criteria.setMaxResults((Integer) params.get("max")); } params.put("organizaciones", criteria.list()); countCriteria.setProjection(Projections.rowCount()); params.put("cantidad", (Long) countCriteria.list().get(0)); return params; }