List of usage examples for java.lang Long intValue
public int intValue()
From source file:it.geosolutions.geofence.gui.server.service.impl.ProfilesManagerServiceImpl.java
public PagingLoadResult<ProfileCustomProps> getProfileCustomProps(int offset, int limit, UserGroup profile) { int start = offset; Long t = new Long(0); List<ProfileCustomProps> customPropsDTO = new ArrayList<ProfileCustomProps>(); if ((profile != null) && (profile.getId() >= 0)) { try {/* w w w .j a v a 2 s . c o m*/ logger.error("TODO: profile refactoring!!! custom props have been removed"); Map<String, String> customProperties = new HashMap<String, String>(); customProperties.put("NOTE", "Custom properties are no longer supported. Code is unstable"); // Map<String, String> customProperties = geofenceRemoteService.getUserGroupAdminService().getCustomProps(profile.getId()); if (customProperties == null) { if (logger.isErrorEnabled()) { logger.error("No property found on server"); } throw new ApplicationException("No rule found on server"); } long rulesCount = customProperties.size(); t = new Long(rulesCount); int page = (start == 0) ? start : (start / limit); SortedSet<String> sortedset = new TreeSet<String>(customProperties.keySet()); Iterator<String> it = sortedset.iterator(); while (it.hasNext()) { String key = it.next(); ProfileCustomProps property = new ProfileCustomProps(); property.setPropKey(key); property.setPropValue(customProperties.get(key)); customPropsDTO.add(property); } // for (String key : customProperties.keySet()) { // ProfileCustomProps property = new ProfileCustomProps(); // property.setPropKey(key); // property.setPropValue(customProperties.get(key)); // customPropsDTO.add(property); // } } catch (Exception e) { // do nothing! } } return new RpcPageLoadResult<ProfileCustomProps>(customPropsDTO, offset, t.intValue()); }
From source file:org.geoserver.geofence.gui.server.service.impl.ProfilesManagerServiceImpl.java
public PagingLoadResult<ProfileCustomProps> getProfileCustomProps(int offset, int limit, UserGroupModel profile) {//from w w w .j a va 2 s.c om int start = offset; Long t = new Long(0); List<ProfileCustomProps> customPropsDTO = new ArrayList<ProfileCustomProps>(); if ((profile != null) && (profile.getId() >= 0)) { try { logger.error("TODO: profile refactoring!!! custom props have been removed"); Map<String, String> customProperties = new HashMap<String, String>(); customProperties.put("NOTE", "Custom properties are no longer supported. Code is unstable"); // Map<String, String> customProperties = geofenceRemoteService.getUserGroupAdminService().getCustomProps(profile.getId()); if (customProperties == null) { if (logger.isErrorEnabled()) { logger.error("No property found on server"); } throw new ApplicationException("No rule found on server"); } long rulesCount = customProperties.size(); t = new Long(rulesCount); int page = (start == 0) ? start : (start / limit); SortedSet<String> sortedset = new TreeSet<String>(customProperties.keySet()); Iterator<String> it = sortedset.iterator(); while (it.hasNext()) { String key = it.next(); ProfileCustomProps property = new ProfileCustomProps(); property.setPropKey(key); property.setPropValue(customProperties.get(key)); customPropsDTO.add(property); } // for (String key : customProperties.keySet()) { // ProfileCustomProps property = new ProfileCustomProps(); // property.setPropKey(key); // property.setPropValue(customProperties.get(key)); // customPropsDTO.add(property); // } } catch (Exception e) { // do nothing! } } return new RpcPageLoadResult<ProfileCustomProps>(customPropsDTO, offset, t.intValue()); }
From source file:net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.java
@Override public List<javax.servlet.http.Cookie> getCookies() { List<javax.servlet.http.Cookie> result = new LinkedList<>(); Set<Cookie> cookies = wc.getCookieManager().getCookies(); for (Cookie cookie : cookies) { javax.servlet.http.Cookie c = new javax.servlet.http.Cookie(cookie.getName(), cookie.getValue()); c.setComment(cookie.toHttpClient().getComment()); c.setDomain(cookie.getDomain()); Date expire = cookie.toHttpClient().getExpiryDate(); if (expire == null) { c.setMaxAge(-1);//from w ww. j a v a 2s .com } 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.toHttpClient().isSecure()); c.setVersion(cookie.toHttpClient().getVersion()); result.add(c); } return result; }
From source file:mx.edu.um.mateo.activos.dao.impl.ActivoDaoHibernate.java
@Override @Transactional(readOnly = true)/*from w w w. ja v a 2 s .c o m*/ public Map<String, Object> lista(Map<String, Object> params) { log.debug("Buscando lista de activos 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(Activo.class); Criteria countCriteria = currentSession().createCriteria(Activo.class); criteria.createAlias("tipoActivo", "ta"); countCriteria.createAlias("tipoActivo", "ta"); if (params.containsKey("empresa")) { criteria.createCriteria("empresa").add(Restrictions.idEq(params.get("empresa"))); countCriteria.createCriteria("empresa").add(Restrictions.idEq(params.get("empresa"))); } if (params.containsKey("tipoActivoIds")) { criteria.add(Restrictions.in("ta.id", (List) params.get("tipoActivoIds"))); countCriteria.add(Restrictions.in("ta.id", (List) params.get("tipoActivoIds"))); } if (params.containsKey("cuentaId")) { criteria.createCriteria("centroCosto").add(Restrictions.eq("id.idCosto", params.get("cuentaId"))); countCriteria.createCriteria("centroCosto").add(Restrictions.eq("id.idCosto", params.get("cuentaId"))); } if (params.containsKey("proveedorId")) { criteria.createCriteria("proveedor").add(Restrictions.idEq(params.get("proveedorId"))); countCriteria.createCriteria("proveedor").add(Restrictions.idEq(params.get("proveedorId"))); } Date fechaIniciado = null; if (params.containsKey("fechaIniciado")) { fechaIniciado = (Date) params.get("fechaIniciado"); criteria.add(Restrictions.ge("fechaCompra", fechaIniciado)); countCriteria.add(Restrictions.ge("fechaCompra", fechaIniciado)); } Date fechaTerminado = null; if (params.containsKey("fechaTerminado")) { Calendar cal = Calendar.getInstance(); cal.setTime((Date) params.get("fechaTerminado")); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); fechaTerminado = cal.getTime(); criteria.add(Restrictions.le("fechaCompra", fechaTerminado)); countCriteria.add(Restrictions.le("fechaCompra", fechaTerminado)); } if (params.containsKey("bajas")) { if (fechaIniciado != null) { criteria.add(Restrictions.eq("inactivo", true)); countCriteria.add(Restrictions.eq("inactivo", true)); criteria.add(Restrictions.ge("fechaInactivo", fechaIniciado)); countCriteria.add(Restrictions.ge("fechaInactivo", fechaIniciado)); if (fechaTerminado != null) { criteria.add(Restrictions.le("fechaInactivo", fechaTerminado)); countCriteria.add(Restrictions.le("fechaInactivo", fechaTerminado)); } } else if (fechaTerminado != null) { criteria.add(Restrictions.eq("inactivo", true)); countCriteria.add(Restrictions.eq("inactivo", true)); criteria.add(Restrictions.le("fechaInactivo", fechaTerminado)); countCriteria.add(Restrictions.le("fechaInactivo", fechaTerminado)); } else { criteria.add(Restrictions.eq("inactivo", true)); countCriteria.add(Restrictions.eq("inactivo", true)); } } else { criteria.add(Restrictions.eq("inactivo", false)); countCriteria.add(Restrictions.eq("inactivo", false)); } if (params.containsKey("reubicaciones")) { if (fechaIniciado != null) { criteria.add(Restrictions.isNotNull("fechaReubicado")); countCriteria.add(Restrictions.isNotNull("fechaReubicado")); criteria.add(Restrictions.ge("fechaReubicado", fechaIniciado)); countCriteria.add(Restrictions.ge("fechaReubicado", fechaIniciado)); if (fechaTerminado != null) { criteria.add(Restrictions.le("fechaReubicado", fechaIniciado)); countCriteria.add(Restrictions.le("fechaReubicado", fechaIniciado)); } } else if (fechaTerminado != null) { criteria.add(Restrictions.isNotNull("fechaReubicado")); countCriteria.add(Restrictions.isNotNull("fechaReubicado")); criteria.add(Restrictions.le("fechaReubicado", fechaIniciado)); countCriteria.add(Restrictions.le("fechaReubicado", fechaIniciado)); } else { criteria.add(Restrictions.isNotNull("fechaReubicado")); countCriteria.add(Restrictions.isNotNull("fechaReubicado")); } } if (params.containsKey("responsableNombre")) { criteria.add(Restrictions.ilike("responsable", (String) params.get("responsable"), MatchMode.ANYWHERE)); countCriteria .add(Restrictions.ilike("responsable", (String) params.get("responsable"), MatchMode.ANYWHERE)); } 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("procedencia", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("factura", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("pedimento", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("poliza", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("codigo", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("descripcion", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("marca", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("modelo", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("ubicacion", filtro, MatchMode.ANYWHERE)); propiedades.add(Restrictions.ilike("responsable", filtro, MatchMode.ANYWHERE)); criteria.add(propiedades); countCriteria.add(propiedades); } if (params.containsKey("order")) { criteria.addOrder(Order.asc("ta.cuenta.id.idCtaMayor")); 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.asc("ta.cuenta.id.idCtaMayor")); criteria.addOrder(Order.desc("folio")); } if (!params.containsKey("reporte")) { criteria.setFirstResult((Integer) params.get("offset")); criteria.setMaxResults((Integer) params.get("max")); } params.put("activos", criteria.list()); countCriteria.setProjection(Projections.rowCount()); params.put("cantidad", (Long) countCriteria.list().get(0)); ProjectionList list = Projections.projectionList(); list.add(Projections.sum("depreciacionAnual"), "depreciacionAnual"); list.add(Projections.sum("depreciacionMensual"), "depreciacionMensual"); list.add(Projections.sum("depreciacionAcumulada"), "depreciacionAcumulada"); list.add(Projections.sum("moi"), "moi"); list.add(Projections.groupProperty("fechaDepreciacion"), "fechaDepreciacion"); countCriteria.setProjection(list); List<?> proyecciones = countCriteria.list(); Iterator<?> iterator = proyecciones.iterator(); if (iterator.hasNext()) { Object[] obj = (Object[]) iterator.next(); NumberFormat nf = DecimalFormat.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); Date fecha; if (obj[4] != null) { fecha = (Date) obj[4]; } else { fecha = new Date(); } params.put("resumen", new String[] { nf.format(obj[0]), nf.format(obj[1]), nf.format(obj[2]), nf.format(obj[3]), sdf.format(fecha) }); } return params; }
From source file:com.sonetel.ui.dialpad.DialerFragment.java
private void placeCallWithOption(Bundle b) { if (service == null) { return;//from ww w . j av a2 s .co m } String toCall = ""; Long accountToUse = SipProfile.INVALID_ID; // Find account to use SipProfile acc = accountChooserButton.getSelectedAccount(); if (acc != null) { accountToUse = acc.id; } // Find number to dial if (isDigit) { toCall = PhoneNumberUtils.stripSeparators(digits.getText().toString()); } else { toCall = digits.getText().toString(); } if (TextUtils.isEmpty(toCall)) { return; } // Well we have now the fields, clear theses fields digits.getText().clear(); // -- MAKE THE CALL --// if (accountToUse >= 0) { // It is a SIP account, try to call service for that try { service.makeCallWithOptions(toCall, accountToUse.intValue(), b); } catch (RemoteException e) { Log.e(THIS_FILE, "Service can't be called to make the call"); } } else if (accountToUse != SipProfile.INVALID_ID) { // It's an external account, find correct external account // String actualCall = toCall; if (accountToUse == -2) { if (!isRoaming()) { if (actualCall != null) { if (!actualCall.equalsIgnoreCase("")) { pDialog = new ProgressDialog(getActivity()); pDialog.setTitle("Sonetel call thru"); pDialog.setMessage("Authenticating..."); pDialog.setIndeterminate(true); pDialog.show(); CallHandlerPlugin ch = new CallHandlerPlugin(getActivity()); ch.loadFrom(accountToUse, actualCall, toCall, new OnLoadListener() { @Override public void onLoad(CallHandlerPlugin ch) { // placePluginCall(ch); } }); } else { Location_Finder LocFinder = new Location_Finder(getActivity()); if (LocFinder.getContryName().startsWith("your")) Toast.makeText(getActivity(), "Country of your current location unknown. Call thru not available.", Toast.LENGTH_LONG).show(); else Toast.makeText(getActivity(), "No Call thru access number available in " + LocFinder.getContryName(), Toast.LENGTH_LONG).show(); return; } } else { Location_Finder LocFinder = new Location_Finder(getActivity()); if (LocFinder.getContryName().startsWith("your")) Toast.makeText(getActivity(), "Country of your current location unknown. Call thru not available.", Toast.LENGTH_LONG).show(); else Toast.makeText(getActivity(), "No Call thru access number available in " + LocFinder.getContryName(), Toast.LENGTH_LONG).show(); return; } } else Toast.makeText(getActivity(), "Call thru is not available when roaming. Please buy a local SIM card if you want to use Call thru in this country.", Toast.LENGTH_LONG).show(); } else if (accountToUse == -3) { CallHandlerPlugin ch = new CallHandlerPlugin(getActivity()); pDialog = new ProgressDialog(getActivity()); pDialog.setTitle("Sonetel call back"); pDialog.setMessage("Please wait. You will receive a call in a moment."); pDialog.setIndeterminate(true); pDialog.show(); ch.loadFrom(accountToUse, actualCall, toCall, new OnLoadListener() { @Override public void onLoad(CallHandlerPlugin ch) { // placePluginCall(ch); } }); } } }
From source file:it.geosolutions.geofence.gui.server.service.impl.GsUsersManagerServiceImpl.java
public PagingLoadResult<GSUser> getGsUsers(int offset, int limit, boolean full) throws ApplicationException { int start = offset; List<GSUser> usersListDTO = new ArrayList<GSUser>(); if (full) {/*w w w. j av a2 s . c o m*/ GSUser all_user = new GSUser(); all_user.setId(-1); all_user.setName("*"); all_user.setFullName("*"); all_user.setEnabled(true); all_user.setAdmin(false); all_user.setEmailAddress(null); all_user.setDateCreation(null); usersListDTO.add(all_user); } long usersCount = geofenceRemoteService.getUserAdminService().getCount(null) + 1; Long t = new Long(usersCount); int page = (start == 0) ? start : (start / limit); List<ShortUser> usersList = geofenceRemoteService.getUserAdminService().getList(null, page, limit); if (usersList == null) { if (logger.isErrorEnabled()) { logger.error("No user found on server"); } throw new ApplicationException("No user found on server"); } for (ShortUser short_usr : usersList) { it.geosolutions.geofence.core.model.GSUser remote_user; try { remote_user = geofenceRemoteService.getUserAdminService().getFull(short_usr.getId()); } catch (NotFoundServiceEx e) { if (logger.isErrorEnabled()) { logger.error("Details for profile " + short_usr.getName() + " not found on Server!"); } throw new ApplicationException(e); } GSUser local_user = new GSUser(); local_user.setId(short_usr.getId()); local_user.setName(remote_user.getName()); local_user.setFullName(remote_user.getFullName()); local_user.setEnabled(remote_user.getEnabled()); local_user.setAdmin(remote_user.isAdmin()); local_user.setEmailAddress(remote_user.getEmailAddress()); local_user.setDateCreation(remote_user.getDateCreation()); local_user.setPassword(remote_user.getPassword()); /*logger.error("TODO: profile refactoring!!!");*/ //it.geosolutions.geofence.core.model.UserGroup remote_profile = remote_user.getGroups().iterator().next(); for (it.geosolutions.geofence.core.model.UserGroup remote_profile : remote_user.getGroups()) { UserGroup local_group = new UserGroup(); local_group.setId(remote_profile.getId()); local_group.setName(remote_profile.getName()); local_group.setDateCreation(remote_profile.getDateCreation()); local_group.setEnabled(remote_profile.getEnabled()); local_user.getUserGroups().add(local_group); } usersListDTO.add(local_user); } return new RpcPageLoadResult<GSUser>(usersListDTO, offset, t.intValue()); }
From source file:org.opennms.ng.services.collectd.Collectd.java
/** * Process the event. This event is generated when a managed node which * supports SNMP gains a new interface. In this situation the * CollectableService object representing the primary SNMP interface of * the node must be reinitialized. The CollectableService object * associated with the primary SNMP interface for the node will be marked * for reinitialization. Reinitializing the CollectableService object * consists of calling the ServiceCollector.release() method followed by * the ServiceCollector.initialize() method which will refresh attributes * such as the interface key list and number of interfaces (both of which * most likely have changed). Reinitialization will take place the next * time the CollectableService is popped from an interval queue for * collection. If any errors occur scheduling the service no error is * returned./*from w w w . j a v a 2s.c om*/ * * @param event The event to process. * @throws InsufficientInformationException */ private void handleReinitializePrimarySnmpInterface(Event event) throws InsufficientInformationException { EventUtils.checkNodeId(event); EventUtils.checkInterface(event); Long nodeid = event.getNodeid(); String ipAddress = event.getInterface(); // Mark the primary SNMP interface for reinitialization in // order to update any modified attributes associated with // the collectable service.. // // Iterate over the CollectableService objects in the // updates map and mark any which have the same interface // address for reinitialization // OnmsIpInterface iface = null; synchronized (getCollectableServices()) { Iterator<CollectableService> iter = getCollectableServices().iterator(); while (iter.hasNext()) { CollectableService cSvc = iter.next(); final InetAddress addr = (InetAddress) cSvc.getAddress(); final String addrString = str(addr); LOG.debug("Comparing CollectableService ip address = {} and event ip interface = {}", addrString, ipAddress); if (addrString != null && addrString.equals(ipAddress)) { synchronized (cSvc) { if (iface == null) { iface = getIpInterface(nodeid.intValue(), ipAddress); } // Got a match! Retrieve the CollectorUpdates object // associated // with this CollectableService. CollectorUpdates updates = cSvc.getCollectorUpdates(); // Now set the reinitialization flag updates.markForReinitialization(iface); LOG.debug( "reinitializePrimarySnmpInterfaceHandler: marking {} for reinitialization for service SNMP.", ipAddress); } } } } }
From source file:org.geoserver.geofence.gui.server.service.impl.GsUsersManagerServiceImpl.java
public PagingLoadResult<GSUserModel> getGsUsers(int offset, int limit, boolean full) throws ApplicationException { int start = offset; List<GSUserModel> usersListDTO = new ArrayList<GSUserModel>(); if (full) {/*from ww w. j a v a2 s .c o m*/ GSUserModel all_user = new GSUserModel(); all_user.setId(-1); all_user.setName("*"); all_user.setFullName("*"); all_user.setEnabled(true); all_user.setAdmin(false); all_user.setEmailAddress(null); all_user.setDateCreation(null); usersListDTO.add(all_user); } long usersCount = geofenceRemoteService.getUserAdminService().getCount(null) + 1; Long t = new Long(usersCount); int page = (start == 0) ? start : (start / limit); List<ShortUser> usersList = geofenceRemoteService.getUserAdminService().getList(null, page, limit); if (usersList == null) { if (logger.isErrorEnabled()) { logger.error("No user found on server"); } throw new ApplicationException("No user found on server"); } for (ShortUser short_usr : usersList) { org.geoserver.geofence.core.model.GSUser remote_user; try { remote_user = geofenceRemoteService.getUserAdminService().getFull(short_usr.getId()); } catch (NotFoundServiceEx e) { if (logger.isErrorEnabled()) { logger.error("Details for profile " + short_usr.getName() + " not found on Server!"); } throw new ApplicationException(e); } GSUserModel local_user = new GSUserModel(); local_user.setId(short_usr.getId()); local_user.setName(remote_user.getName()); local_user.setFullName(remote_user.getFullName()); local_user.setEnabled(remote_user.getEnabled()); local_user.setAdmin(remote_user.isAdmin()); local_user.setEmailAddress(remote_user.getEmailAddress()); local_user.setDateCreation(remote_user.getDateCreation()); local_user.setPassword(remote_user.getPassword()); /*logger.error("TODO: profile refactoring!!!");*/ //org.geoserver.geofence.core.model.UserGroup remote_profile = remote_user.getGroups().iterator().next(); for (org.geoserver.geofence.core.model.UserGroup remote_profile : remote_user.getGroups()) { UserGroupModel local_group = new UserGroupModel(); local_group.setId(remote_profile.getId()); local_group.setName(remote_profile.getName()); local_group.setDateCreation(remote_profile.getDateCreation()); local_group.setEnabled(remote_profile.getEnabled()); local_user.getUserGroups().add(local_group); } usersListDTO.add(local_user); } return new RpcPageLoadResult<GSUserModel>(usersListDTO, offset, t.intValue()); }
From source file:com.knowgate.dfs.FileSystem.java
/** * <p>Get file length</p>/*from ww w . j ava 2 s . c o m*/ * Currently only local and network files length can be queried</p> * @param sFullURI File URI (protocol+path) * @return File length in bytes * @throws IOException */ public int filelen(String sFullURI) throws IOException { File oFile; Long oFLng; int iFLen; if (DebugFile.trace) { DebugFile.writeln("Begin FileSystem.filelen(" + sFullURI + ")"); DebugFile.incIdent(); } oFile = new File(sFullURI); if (oFile.exists()) { oFLng = new Long(oFile.length()); iFLen = oFLng.intValue(); } else throw new IOException("File " + sFullURI + " does not exists"); if (DebugFile.trace) { DebugFile.decIdent(); DebugFile.writeln("End FileSystem.filelen() : " + String.valueOf(iFLen)); } return iFLen; }
From source file:autoInsurance.BeiJPiccImpl.java
String readFile2Strng(String filePath) throws Exception { File file = new File(filePath); Long filelength = file.length(); byte[] filecontent = new byte[filelength.intValue()]; FileInputStream in = new FileInputStream(file); in.read(filecontent);/* ww w. j a va2 s. co m*/ in.close(); return new String(filecontent, "utf-8"); }