List of usage examples for java.lang Long intValue
public int intValue()
From source file:edu.umm.radonc.ca_dash.controllers.HistogramController.java
public ChartSeries buildHistogram(Long hospital) { double divisor = 1.0; ChartSeries histo = new ChartSeries(); dstats = getFacade().getDailyStats(startDate, endDate, hospital, selectedFilters, includeWeekends, patientsFlag, scheduledFlag); String label = "All"; //Freedman-Diaconis bin width binInterval = Math.floor(2.0 * (dstats.getPercentile(75.0) - dstats.getPercentile(25.0)) * Math.pow(dstats.getN(), (-1.0 / 3.0))); if (relativeModeFlag) { divisor = dstats.getN();// www . ja v a2s . co m } binInterval = (binInterval < 1.0) ? 1.0 : binInterval; double[] sortedValues = dstats.getSortedValues(); double currIntervalStart = 0.0; double currIntervalEnd = binInterval; double count = 0.0; for (int i = 0; i < sortedValues.length; i++) { if (sortedValues[i] < currIntervalEnd) { count += 1.0; } else { String intervalString = String.format("%d", (int) Math.ceil(currIntervalStart)) + " - " + String.format("%d", (int) Math.floor(currIntervalEnd) - 1); histo.set(intervalString, count / divisor); currIntervalStart = currIntervalEnd; currIntervalEnd += binInterval; count = 0.0; i--; } } String intervalString = String.format("%d", (int) Math.ceil(currIntervalStart)) + " - " + String.format("%d", (int) (dstats.getMax())); histo.set(intervalString, count / divisor); if (hospital > 0) { label = getHospitalFacade().find(hospital.intValue()).getHospitalname(); } histo.setLabel(label); String[] colorset = (String[]) ColorMap.getMap().get(label); histogram.setSeriesColors(colorset[0]); return histo; }
From source file:it.geosolutions.geofence.gui.server.service.impl.ProfilesManagerServiceImpl.java
public PagingLoadResult<UserGroup> getProfiles(int offset, int limit, boolean full) throws ApplicationException { int start = offset; List<UserGroup> profileListDTO = new ArrayList<UserGroup>(); if (full) {/*w w w . j ava 2 s .c o m*/ UserGroup all_profile = new UserGroup(); all_profile.setId(-1); all_profile.setName("*"); all_profile.setEnabled(true); all_profile.setDateCreation(null); profileListDTO.add(all_profile); } long profilesCount = geofenceRemoteService.getUserGroupAdminService().getCount(null) + 1; Long t = new Long(profilesCount); int page = (start == 0) ? start : (start / limit); List<ShortGroup> profilesList = geofenceRemoteService.getUserGroupAdminService().getList(null, page, limit); if (profilesList == null) { if (logger.isErrorEnabled()) { logger.error("No profile found on server"); } throw new ApplicationException("No profile found on server"); } Iterator<ShortGroup> it = profilesList.iterator(); while (it.hasNext()) { ShortGroup short_profile = it.next(); it.geosolutions.geofence.core.model.UserGroup remote_profile; try { remote_profile = geofenceRemoteService.getUserGroupAdminService().get(short_profile.getId()); } catch (NotFoundServiceEx e) { if (logger.isErrorEnabled()) { logger.error("Details for profile " + short_profile.getName() + " not found on Server!"); } throw new ApplicationException( "Details for profile " + short_profile.getName() + " not found on Server!"); } UserGroup local_profile = new UserGroup(); local_profile.setId(short_profile.getId()); local_profile.setName(remote_profile.getName()); local_profile.setDateCreation(remote_profile.getDateCreation()); local_profile.setEnabled(remote_profile.getEnabled()); // TODO: use specific API methods in order to load UserGroup custom props // local_profile.setCustomProps(remote_profile.getCustomProps()); profileListDTO.add(local_profile); } return new RpcPageLoadResult<UserGroup>(profileListDTO, offset, t.intValue()); }
From source file:org.geoserver.geofence.gui.server.service.impl.ProfilesManagerServiceImpl.java
public PagingLoadResult<UserGroupModel> getProfiles(int offset, int limit, boolean full) throws ApplicationException { int start = offset; List<UserGroupModel> profileListDTO = new ArrayList<UserGroupModel>(); if (full) {//from www .j a v a 2 s . c om UserGroupModel all_profile = new UserGroupModel(); all_profile.setId(-1); all_profile.setName("*"); all_profile.setEnabled(true); all_profile.setDateCreation(null); profileListDTO.add(all_profile); } long profilesCount = geofenceRemoteService.getUserGroupAdminService().getCount(null) + 1; Long t = new Long(profilesCount); int page = (start == 0) ? start : (start / limit); List<ShortGroup> profilesList = geofenceRemoteService.getUserGroupAdminService().getList(null, page, limit); if (profilesList == null) { if (logger.isErrorEnabled()) { logger.error("No profile found on server"); } throw new ApplicationException("No profile found on server"); } Iterator<ShortGroup> it = profilesList.iterator(); while (it.hasNext()) { ShortGroup short_profile = it.next(); org.geoserver.geofence.core.model.UserGroup remote_profile; try { remote_profile = geofenceRemoteService.getUserGroupAdminService().get(short_profile.getId()); } catch (NotFoundServiceEx e) { if (logger.isErrorEnabled()) { logger.error("Details for profile " + short_profile.getName() + " not found on Server!"); } throw new ApplicationException( "Details for profile " + short_profile.getName() + " not found on Server!"); } UserGroupModel local_profile = new UserGroupModel(); local_profile.setId(short_profile.getId()); local_profile.setName(remote_profile.getName()); local_profile.setDateCreation(remote_profile.getDateCreation()); local_profile.setEnabled(remote_profile.getEnabled()); // TODO: use specific API methods in order to load UserGroup custom props // local_profile.setCustomProps(remote_profile.getCustomProps()); profileListDTO.add(local_profile); } return new RpcPageLoadResult<UserGroupModel>(profileListDTO, offset, t.intValue()); }
From source file:com.redhat.rhn.frontend.xmlrpc.system.test.SystemHandlerTest.java
public void testDeleteSystems() throws Exception { Server server = ServerFactoryTest.createTestServer(admin, true); Long sid = server.getId(); Integer id = new Integer(sid.intValue()); Server test = SystemManager.lookupByIdAndUser(sid, admin); assertNotNull(test);/* www .j av a2 s. c om*/ //ok, we have an admin with a server he has access to List sids = new ArrayList(); sids.add(id); try { handler.deleteSystems(regular, sids); fail("SystemHandler.deleteSystems allowed unauthorized deletion"); } catch (FaultException e) { //success } assertEquals(1, handler.deleteSystems(admin, sids)); List<OperationDetailsDto> ops = SsmOperationManager.allOperations(admin); for (OperationDetailsDto op : ops) { assertEquals(op.getDescription(), LocalizationService.getInstance().getMessage(SsmDeleteServersAction.OPERATION_NAME)); } }
From source file:com.biosis.biosislite.vistas.AsignarPermiso.java
private boolean erroresFormulario() { int errores = 0; Date fechaInicio = dcFechaInicio.getDate(); String mensaje = ""; if (integrantes.isEmpty()) { errores++;//from w ww . j ava 2 s. co m mensaje += ">Debe seleccionar uno o mas empleados\n"; } if (dcFechaInicio.getDate() == null || dcFechaFin.getDate() == null) { if (!radHora.isSelected()) { errores++; mensaje += "Una o ms fechas ingresadas incorrectamente \n"; } else if (radFecha.isSelected()) { errores++; mensaje += "Una o ms fechas ingresadas incorrectamente \n"; } } else { if (radFecha.isSelected()) { Date fechaFin = dcFechaFin.getDate(); if (fechaInicio.compareTo(fechaFin) > 0) { errores++; mensaje += ">La fecha de inicio debe ser menor que la fecha de fin\n"; } //Traemos los dnis de los empleados Permiso paraComprobar = this.controlador.getSeleccionado(); //List<String> dnis = new ArrayList<>(); for (AsignacionPermiso asignacion : paraComprobar.getAsignacionPermisoList()) { //dnis.add(asignacion.getEmpleado()); System.out.println(asignacion.getEmpleado()); // List<AsignacionPermiso> lista = ac.buscarXFechaDni(asignacion.getEmpleado(), fechaInicio); int conteoPorFecha = ac.contarXEmpleadoEntreFechaPorFecha(empleadoSeleccionado, fechaInicio, fechaFin); if (conteoPorFecha == 0) { } else if (accion != Controlador.MODIFICAR) { errores++; mensaje += "El empleado " + asignacion.getEmpleado() + " tiene conflicto con un permiso aadido anteriormente \n Ingrese otro rango de fechas \n"; break; } } } } //Traemos los permisos por dni if (radHora.isSelected()) { Date horaInicio = (Date) spHoraInicio.getValue(); Date horaFin = (Date) spHoraFin.getValue(); if (horaInicio.compareTo(horaFin) > 0) { errores++; mensaje += ">La hora de inicio debe ser menor que la hora de fin \n"; } Permiso paraComprobar = this.controlador.getSeleccionado(); for (AsignacionPermiso asignacion : paraComprobar.getAsignacionPermisoList()) { List<AsignacionPermiso> lista = ac.buscarXHora(asignacion.getEmpleado(), fechaInicio); Long conteoPorHora = lista.stream() .filter(perm -> (horaInicio.compareTo(perm.getPermiso().getHoraInicio()) <= 0 && horaFin.compareTo(perm.getPermiso().getHoraInicio()) >= 0) || (perm.getPermiso().getHoraInicio().compareTo(horaInicio) <= 0 && perm.getPermiso().getHoraFin().compareTo(horaInicio) >= 0)) .count(); if (conteoPorHora.intValue() == 0) { } else { errores++; mensaje += ">El empleado " + asignacion.getEmpleado() + " tiene conflicto con un permiso aadido anteriormente \n Ingrese otro rango de horas\n"; break; } } } if (errores > 0) { JOptionPane.showMessageDialog(this, "Se ha(n) encontrado el(los) siguiente(s) error(es):\n" + mensaje, "Mensaje del sistema", JOptionPane.ERROR_MESSAGE); } return errores != 0; }
From source file:com.hmsinc.epicenter.model.analysis.impl.MaterializedViewAnalysisQueries.java
@SuppressWarnings("unchecked") public org.hibernate.Criteria createGetCasesQuery(AnalysisParameters analysisParameters, Long offset, Long numRows) {//from w ww. j av a 2 s . c o m Validate.notNull(offset, "Offset must be set."); Validate.notNull(numRows, "Number of returned rows must be set."); Validate.notNull(analysisParameters.getDataType(), "Data type must be set."); Class<? extends Interaction> interactionClass = null; for (ClassificationTarget target : analysisParameters.getDataType().getTargets()) { Validate.notNull(target.getInteractionClass(), "Interaction class was null for " + target.toString()); if (interactionClass == null) { interactionClass = target.getInteractionClass(); } else { Validate.isTrue(interactionClass.equals(target.getInteractionClass()), "Inconsistent interaction classes"); } } // Query is a subselect of Interaction based on materialized view. final Class<? extends Serializable> mv = (analysisParameters.getClassifications() == null || analysisParameters.getClassifications().size() == 0 ? AnalysisView.class : ClassifiedAnalysisView.class); final QueryBuilder query = new QueryBuilder().addEntity(mv, "analysis").addProperty("distinct(analysis.id)") .addProperty("analysis.interactionDate").addOrder("analysis.interactionDate asc"); applyAttributes(query, analysisParameters); applyClassifications(query, analysisParameters); // Geography applyGeography(query, analysisParameters.getContainer().getClass(), analysisParameters); disableNestedLoops(entityManager); final Query q = query.toQuery((Session) entityManager.getDelegate(), true); q.setFirstResult(offset.intValue()); q.setMaxResults(numRows.intValue()); final List<Object[]> items = q.list(); final List<Long> interactionList = new ArrayList<Long>(); for (Object[] item : items) { interactionList.add((Long) item[0]); } Criteria ret = null; enableNestedLoops(entityManager); if (interactionList.size() > 0) { // We need to use a ResultTransformer here to avoid duplicate rows. ret = criteriaQuery(entityManager, interactionClass).setFetchMode("classifications", FetchMode.JOIN) .setFetchMode("patient", FetchMode.JOIN).setFetchMode("patientDetail", FetchMode.JOIN) .add(Restrictions.in("id", interactionList)) .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); } return ret; }
From source file:com.redhat.rhn.manager.system.SystemManager.java
/** * Returns the number of systems subscribed to the given channel. * * @param channelId identifies the channel * @param user user making the request * @return number of systems subscribed to the channel *///from ww w .ja va 2 s. c om public static int countSystemsSubscribedToChannel(Long channelId, User user) { Map<String, Long> params = new HashMap<String, Long>(2); params.put("user_id", user.getId()); params.put("org_id", user.getOrg().getId()); params.put("cid", channelId); SelectMode m = ModeFactory.getMode("System_queries", "count_systems_subscribed_to_channel"); DataResult<Map<String, Object>> dr = makeDataResult(params, params, null, m); Map<String, Object> result = dr.get(0); Long count = (Long) result.get("count"); return count.intValue(); }
From source file:com.redhat.rhn.manager.system.SystemManager.java
/** * Returns the number of systems subscribed to the channel that are * <strong>not</strong> in the given org. * * @param orgId identifies the filter org * @param cid identifies the channel//w w w . ja v a 2s . c o m * @return count of systems */ public static int countSubscribedToChannelWithoutOrg(Long orgId, Long cid) { SelectMode m = ModeFactory.getMode("System_queries", "count_systems_subscribed_to_channel_not_in_org"); Map<String, Object> params = new HashMap<String, Object>(); params.put("org_id", orgId); params.put("cid", cid); DataResult<Map<String, Object>> dr = m.execute(params); Map<String, Object> result = dr.get(0); Long count = (Long) result.get("count"); return count.intValue(); }
From source file:com.bhbsoft.videoconference.VideoConferenceApplicationAdapter.java
public synchronized List<Integer> listRoomBroadcast() { HashSet<Integer> broadcastList = new HashSet<Integer>(); IConnection current = Red5.getConnectionLocal(); String streamid = current.getClient().getId(); for (Set<IConnection> conset : current.getScope().getConnections()) { for (IConnection conn : conset) { if (conn != null) { Client rcl = this.sessionManager.getClientByStreamId(conn.getClient().getId()); if (rcl == null) { // continue; } else if (rcl.getIsScreenClient() != null && rcl.getIsScreenClient()) { // continue; } else { if (!streamid.equals(rcl.getStreamid())) { // It is not needed to send back // that event to the actuall // Moderator // as it will be already triggered // in the result of this Function // in the Client Long id = Long.valueOf(rcl.getBroadCastID()); if (id != null && !broadcastList.contains(id)) { broadcastList.add(id.intValue()); }/*from w w w . j a v a 2s.c o m*/ } } } } } return new ArrayList<Integer>(broadcastList); }
From source file:com.redhat.rhn.manager.system.SystemManager.java
private static List<DuplicateSystemGrouping> listDuplicates(User user, String query, List<String> ignored, Long inactiveHours) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.HOUR, (0 - inactiveHours.intValue())); SelectMode ipMode = ModeFactory.getMode("System_queries", query); Date d = new Date(cal.getTimeInMillis()); Map<String, Object> params = new HashMap<String, Object>(); params.put("uid", user.getId()); params.put("inactive_date", d); DataResult<NetworkDto> nets;//from w w w .ja v a2 s . c o m if (ignored.isEmpty()) { nets = ipMode.execute(params); } else { nets = ipMode.execute(params, ignored); } List<DuplicateSystemGrouping> nodes = new ArrayList<DuplicateSystemGrouping>(); for (NetworkDto net : nets) { boolean found = false; for (DuplicateSystemGrouping node : nodes) { if (node.addIfMatch(net)) { found = true; break; } } if (!found) { nodes.add(new DuplicateSystemGrouping(net)); } } return nodes; }