List of usage examples for java.lang Float toString
public static String toString(float f)
From source file:com.moviejukebox.plugin.DefaultImagePlugin.java
/** * Draw the TV and HD logos onto the image * * @param movie The source movie/* w w w. j a v a 2 s .c om*/ * @param bi The image to draw on * @param imageType * @param beforeMainOverlay * @return The new image with the added logos */ @SuppressWarnings("deprecation") protected BufferedImage drawLogos(Movie movie, BufferedImage bi, String imageType, boolean beforeMainOverlay) { BufferedImage newBi = bi; // Issue 1937: Overlay configuration XML if (xmlOverlay) { for (LogoOverlay layer : overlayLayers) { if (layer.isBefore() != beforeMainOverlay) { continue; } boolean flag = false; List<StateOverlay> states = new ArrayList<>(); for (String name : layer.getNames()) { String value = Movie.UNKNOWN; if (checkLogoEnabled(name)) { if ("set".equalsIgnoreCase(name)) { value = ((THUMBNAIL.equalsIgnoreCase(imageType) || BANNER.equalsIgnoreCase(imageType) || FOOTER.equalsIgnoreCase(imageType)) && movie.isSetMaster()) ? countSetLogo ? Integer.toString(movie.getSetSize()) : TRUE : countSetLogo ? "0" : FALSE; } else if ("TV".equalsIgnoreCase(name)) { value = movie.isTVShow() ? TRUE : FALSE; } else if ("HD".equalsIgnoreCase(name)) { value = movie.isHD() ? highdefDiff ? movie.isHD1080() ? "hd1080" : "hd720" : "hd" : FALSE; } else if (SUBTITLE.equalsIgnoreCase(name) || "ST".equalsIgnoreCase(name)) { value = (StringTools.isNotValidString(movie.getSubtitles()) || "NO".equalsIgnoreCase(movie.getSubtitles())) ? FALSE : (blockSubTitle ? movie.getSubtitles() : TRUE); } else if (LANGUAGE.equalsIgnoreCase(name)) { value = movie.getLanguage(); } else if (RATING.equalsIgnoreCase(name)) { value = ((!movie.isTVShow() && !movie.isSetMaster()) || (movie.isTVShow() && movie.isSetMaster())) ? Integer.toString(realRating ? movie.getRating() : (int) (Math.floor(movie.getRating() / 10) * 10)) : Movie.UNKNOWN; } else if (VIDEOSOURCE.equalsIgnoreCase(name) || SOURCE.equalsIgnoreCase(name) || "VS".equalsIgnoreCase(name)) { value = movie.getVideoSource(); } else if ("videoout".equalsIgnoreCase(name) || "out".equalsIgnoreCase(name) || "VO".equalsIgnoreCase(name)) { value = movie.getVideoOutput(); } else if (VIDEOCODEC.equalsIgnoreCase(name) || VCODEC.equalsIgnoreCase(name) || "VC".equalsIgnoreCase(name)) { value = movie.getVideoCodec(); } else if (AUDIOCODEC.equalsIgnoreCase(name) || ACODEC.equalsIgnoreCase(name) || "AC".equalsIgnoreCase(name)) { value = movie.getAudioCodec(); if (!blockAudioCodec) { int pos = value.indexOf(Movie.SPACE_SLASH_SPACE); if (pos > -1) { value = value.substring(0, pos); } pos = value.indexOf(" ("); if (pos > -1) { value = value.substring(0, pos); } } else { while (value.contains(" (") && value.indexOf(" (") < value.indexOf(')')) { value = value.substring(0, value.indexOf(" (")) + value.substring(value.indexOf(')') + 1); } } } else if (AUDIOLANG.equalsIgnoreCase(name) || ALANG.equalsIgnoreCase(name) || "AL".equalsIgnoreCase(name)) { value = ""; for (String tmp : movie.getAudioCodec().split(Movie.SPACE_SLASH_SPACE)) { if (tmp.contains(" (") && tmp.indexOf(" (") < tmp.indexOf(')')) { tmp = tmp.substring(tmp.indexOf(" (") + 2, tmp.indexOf(')')); } else { tmp = Movie.UNKNOWN; } if (!blockAudioLang) { value = tmp; break; } if (StringUtils.isNotBlank(value)) { value += Movie.SPACE_SLASH_SPACE; } value += tmp; } if (StringTools.isNotValidString(value)) { value = Movie.UNKNOWN; } } else if (name.equalsIgnoreCase(AUDIOCHANNELS) || name.equalsIgnoreCase(CHANNELS)) { value = movie.getAudioChannels(); if (!blockAudioChannels) { int pos = value.indexOf(Movie.SPACE_SLASH_SPACE); if (pos > -1) { value = value.substring(0, pos); } } } else if (CONTAINER.equalsIgnoreCase(name)) { value = movie.getContainer(); } else if (ASPECT.equalsIgnoreCase(name)) { value = movie.getAspectRatio(); } else if ("fps".equalsIgnoreCase(name)) { value = Float.toString(movie.getFps()); } else if (CERTIFICATION.equalsIgnoreCase(name)) { value = movie.getCertification(); } else if (WATCHED.equalsIgnoreCase(name)) { if (imageType.equalsIgnoreCase(VIDEOIMAGE)) { value = movie.getFiles().toArray(new MovieFile[movie.getFiles().size()])[viIndex] .isWatched() ? TRUE : FALSE; } else if (movie.isTVShow() && blockWatched) { StringBuilder sbWatched = new StringBuilder(); boolean first = true; for (MovieFile mf : movie.getFiles()) { if (first) { first = false; } else { sbWatched.append(Movie.SPACE_SLASH_SPACE); } sbWatched.append(mf.isWatched() ? TRUE : FALSE); } value = sbWatched.toString(); } else { value = movie.isWatched() ? TRUE : FALSE; } } else if (EPISODE.equalsIgnoreCase(name)) { if (movie.isTVShow()) { if (blockEpisode) { StringBuilder sbEpisode = new StringBuilder(); boolean first = true; int firstPart, lastPart; for (MovieFile mf : movie.getFiles()) { firstPart = mf.getFirstPart(); lastPart = mf.getLastPart(); for (int part = firstPart; part <= lastPart; part++) { if (first) { first = false; } else { sbEpisode.append(Movie.SPACE_SLASH_SPACE); } sbEpisode.append(part); } } value = sbEpisode.toString(); } else { value = Integer.toString(movie.getFiles().size()); } } } else if ("top250".equalsIgnoreCase(name)) { value = movie.getTop250() > 0 ? TRUE : FALSE; } else if (KEYWORDS.equalsIgnoreCase(name)) { value = movie.getBaseFilename().toLowerCase(); } else if (COUNTRY.equalsIgnoreCase(name)) { value = movie.getCountriesAsString(); if (!blockCountry) { int pos = value.indexOf(Movie.SPACE_SLASH_SPACE); if (pos > -1) { value = value.substring(0, pos); } } } else if (COMPANY.equalsIgnoreCase(name)) { value = movie.getCompany(); if (!blockCompany) { int pos = value.indexOf(Movie.SPACE_SLASH_SPACE); if (pos > -1) { value = value.substring(0, pos); } } } else if (AWARD.equalsIgnoreCase(name)) { value = ""; int awardCount = 0; Map<String, Integer> awards = new HashMap<>(); if (!movie.isSetMaster()) { for (AwardEvent awardEvent : movie.getAwards()) { for (Award award : awardEvent.getAwards()) { if (award.getWon() > 0) { if (blockAward) { awards.put((awardEventName ? (awardEvent.getName() + " - ") : "") + award.getName(), award.getWon()); } else if (countAward) { awardCount++; } else { value = TRUE; break; } } } if (!blockAward && !countAward && StringTools.isValidString(value)) { break; } } } if (blockAward) { ValueComparator bvc = new ValueComparator(awards); Map<String, Integer> sortedAwards = new TreeMap<>(bvc); sortedAwards.putAll(awards); StringBuilder sbAwards = new StringBuilder(); boolean first = value.isEmpty(); // Append the separator only if the "value" is not empty for (String award : sortedAwards.keySet()) { if (first) { first = false; } else { sbAwards.append(Movie.SPACE_SLASH_SPACE); } sbAwards.append(award); } value += sbAwards.toString(); } value = (StringTools.isNotValidString(value) && !countAward) ? blockAward ? Movie.UNKNOWN : FALSE : countAward ? Integer.toString(awardCount) : value; } else { value = PropertiesUtil.getProperty(name, Movie.UNKNOWN); } } StateOverlay state = new StateOverlay(layer.getLeft(), layer.getTop(), layer.getAlign(), layer.getValign(), layer.getWidth(), layer.getHeight(), value); states.add(state); } for (int inx = 0; inx < layer.getNames().size(); inx++) { String name = layer.getNames().get(inx); String value = states.get(inx).getValue(); String filename = Movie.UNKNOWN; if (checkLogoEnabled(name)) { if (!blockLanguage && LANGUAGE.equalsIgnoreCase(name) && StringTools.isValidString(value)) { filename = "languages/English.png"; } String[] values = value.split(Movie.SPACE_SLASH_SPACE); for (String splitValue : values) { value = splitValue; for (ImageOverlay img : layer.getImages()) { if (img.getName().equalsIgnoreCase(name)) { boolean accept = false; if (img.getValues().size() == 1 && cmpOverlayValue(name, img.getValue(), value)) { accept = true; } else if (img.getValues().size() > 1) { accept = true; for (int i = 0; i < layer.getNames().size(); i++) { accept = accept && cmpOverlayValue(layer.getNames().get(i), img.getValues().get(i), states.get(i).getValue()); if (!accept) { break; } } } if (!accept) { continue; } File imageFile = new File(overlayResources + img.getFilename()); if (imageFile.exists()) { if (StringTools.isNotValidString(filename)) { filename = img.getFilename(); } else { filename += Movie.SPACE_SLASH_SPACE + img.getFilename(); } } break; } } } flag = flag || StringTools.isValidString(filename); } states.get(inx).setFilename(filename); } if (!flag) { continue; } if (!layer.getPositions().isEmpty()) { for (ConditionOverlay cond : layer.getPositions()) { flag = true; for (int i = 0; i < layer.getNames().size(); i++) { String name = layer.getNames().get(i); String condition = cond.getValues().get(i); String value = states.get(i).getValue(); flag = flag && cmpOverlayValue(name, condition, value); if (!flag) { break; } } if (flag) { for (int i = 0; i < layer.getNames().size(); i++) { PositionOverlay pos = cond.getPositions().get(i); states.get(i).setLeft(pos.getLeft()); states.get(i).setTop(pos.getTop()); states.get(i).setAlign(pos.getAlign()); states.get(i).setValign(pos.getValign()); } break; } } } for (int i = 0; i < layer.getNames().size(); i++) { StateOverlay state = states.get(i); String name = layer.getNames().get(i); if (!blockLanguage && LANGUAGE.equalsIgnoreCase(name)) { newBi = drawLanguage(movie, newBi, getOverlayX(newBi.getWidth(), 62, state.getLeft(), state.getAlign()), getOverlayY(newBi.getHeight(), 40, state.getTop(), state.getValign())); continue; } String filename = state.getFilename(); if (StringTools.isNotValidString(filename)) { continue; } if (((blockAudioCodec && ((AUDIOCODEC.equalsIgnoreCase(name) || ACODEC.equalsIgnoreCase(name) || "AC".equalsIgnoreCase(name)))) || (blockAudioChannels && (AUDIOCHANNELS.equalsIgnoreCase(name) || CHANNELS.equalsIgnoreCase(name))) || (blockAudioLang && (AUDIOLANG.equalsIgnoreCase(name) || ALANG.equalsIgnoreCase(name) || "AL".equalsIgnoreCase(name))) || (blockCountry && COUNTRY.equalsIgnoreCase(name)) || (blockCompany && COMPANY.equalsIgnoreCase(name)) || (blockAward && AWARD.equalsIgnoreCase(name)) || (blockWatched && WATCHED.equalsIgnoreCase(name)) || (blockEpisode && EPISODE.equalsIgnoreCase(name)) || (blockSubTitle && SUBTITLE.equalsIgnoreCase(name)) || (blockLanguage && LANGUAGE.equalsIgnoreCase(name))) && (overlayBlocks.get(name) != null)) { newBi = drawBlock(movie, newBi, name, filename, state.getLeft(), state.getAlign(), state.getWidth(), state.getTop(), state.getValign(), state.getHeight()); continue; } try { BufferedImage biSet = GraphicTools.loadJPEGImage(overlayResources + filename); Graphics2D g2d = newBi.createGraphics(); g2d.drawImage(biSet, getOverlayX(newBi.getWidth(), biSet.getWidth(), state.getLeft(), state.getAlign()), getOverlayY(newBi.getHeight(), biSet.getHeight(), state.getTop(), state.getValign()), state.getWidth().matches(D_PLUS) ? Integer.parseInt(state.getWidth()) : biSet.getWidth(), state.getHeight().matches(D_PLUS) ? Integer.parseInt(state.getHeight()) : biSet.getHeight(), null); g2d.dispose(); } catch (FileNotFoundException ex) { LOG.warn("Failed to load {} {}, please ensure it is valid", overlayResources, filename); } catch (IOException ex) { LOG.warn( "Failed drawing overlay to image file: Please check that {} is in the resources directory.", filename); } if ("set".equalsIgnoreCase(name)) { newBi = drawSetSize(movie, newBi); } } } } else if (beforeMainOverlay) { if (addHDLogo) { newBi = drawLogoHD(movie, newBi, addTVLogo); } if (addTVLogo) { newBi = drawLogoTV(movie, newBi, addHDLogo); } if (addLanguage) { newBi = drawLanguage(movie, newBi, 1, 1); } if (addSubTitle) { newBi = drawSubTitle(movie, newBi); } // Should only really happen on set's thumbnails. if (imageType.equalsIgnoreCase(THUMBNAIL) && movie.isSetMaster()) { // Draw the set logo if requested. if (addSetLogo) { newBi = drawSet(movie, newBi); LOG.debug("Drew set logo on {}", movie.getTitle()); } newBi = drawSetSize(movie, newBi); } } return newBi; }
From source file:com.cellbots.logger.LoggerActivity.java
private String numberDisplayFormatter(float value) { String displayedText = Float.toString(value); if (value >= 0) { displayedText = " " + displayedText; }/*from w w w. j a v a 2s .c o m*/ if (displayedText.length() > 8) { displayedText = displayedText.substring(0, 8); } while (displayedText.length() < 8) { displayedText = displayedText + " "; } return displayedText; }
From source file:er.extensions.foundation.ERXProperties.java
/** * <div class="en">//from w w w . j av a 2 s . com * Cover method for returning a float for a * given system property with a default value. * </div> * * <div class="ja"> * ?? float ???? * </div> * * @param s <div class="en">system property</div> * <div class="ja"></div> * @param defaultValue <div class="en">default value</div> * <div class="ja"></div> * * @return <div class="en">float value of the system property or the default value</div> * <div class="ja">float </div> */ public static float floatForKeyWithDefault(final String s, final float defaultValue) { final String propertyName = getApplicationSpecificPropertyName(s); float value; Object cachedValue = _cache.get(propertyName); if (UndefinedMarker.equals(cachedValue)) { value = defaultValue; } else if (cachedValue instanceof Float) { value = ((Float) cachedValue).floatValue(); } else { Float objValue = ERXValueUtilities.FloatValueWithDefault(ERXSystem.getProperty(propertyName), null); _cache.put(s, objValue == null ? (Object) UndefinedMarker : objValue); if (objValue == null) { value = defaultValue; } else { value = objValue.floatValue(); } if (retainDefaultsEnabled() && objValue == null) { System.setProperty(propertyName, Float.toString(defaultValue)); } } return value; }
From source file:org.egov.restapi.util.ValidationUtil.java
/** * Validates Vacant Land details//from w ww . j a v a 2 s. c om * * @param createPropDetails * @param errorDetails * @return ErrorDetails * @throws ParseException */ public ErrorDetails validateVacantLandDetails(final CreatePropertyDetails createPropDetails, final ErrorDetails errorDetails) { final VacantLandDetails vacantLandDetails = createPropDetails.getVacantLandDetails(); if (vacantLandDetails == null) { errorDetails.setErrorCode(VACANT_LAND_DETAILS_REQ_CODE); errorDetails.setErrorMessage(VACANT_LAND_DETAILS_REQ_MSG); return errorDetails; } else { if (StringUtils.isBlank(vacantLandDetails.getSurveyNumber())) { errorDetails.setErrorCode(SURVEY_NO_REQ_CODE); errorDetails.setErrorMessage(SURVEY_NO_REQ_MSG); return errorDetails; } else if (StringUtils.isBlank(vacantLandDetails.getPattaNumber())) { errorDetails.setErrorCode(PATTA_NO_REQ_CODE); errorDetails.setErrorMessage(PATTA_NO_REQ_MSG); return errorDetails; } if (vacantLandDetails.getVacantLandArea() == null) { errorDetails.setErrorCode(VACANT_LAND_AREA_REQ_CODE); errorDetails.setErrorMessage(VACANT_LAND_AREA_REQ_MSG); return errorDetails; } else if (Float.valueOf(vacantLandDetails.getVacantLandArea()) == 0.0) { errorDetails.setErrorCode(AREA_GREATER_THAN_ZERO_CODE); errorDetails.setErrorMessage(AREA_GREATER_THAN_ZERO_MSG); return errorDetails; } else { final Pattern pattern = Pattern.compile(DIGITS_FLOAT_INT_DBL); final Matcher matcher = pattern.matcher(Float.toString(vacantLandDetails.getVacantLandArea())); if (!matcher.matches()) { errorDetails.setErrorCode(VL_AREA_NUMBER_REQ_CODE); errorDetails.setErrorMessage(VL_AREA_NUMBER_REQ_MSG); return errorDetails; } } if (vacantLandDetails.getMarketValue() == null) { errorDetails.setErrorCode(MARKET_AREA_VALUE_REQ_CODE); errorDetails.setErrorMessage(MARKET_AREA_VALUE_REQ_MSG); return errorDetails; } else if (vacantLandDetails.getMarketValue().compareTo(BigDecimal.ZERO) == 0) { errorDetails.setErrorCode(MARKET_VALUE_GREATER_THAN_ZERO_CODE); errorDetails.setErrorMessage(MARKET_VALUE_GREATER_THAN_ZERO_MSG); return errorDetails; } else { final Pattern pattern = Pattern.compile(DIGITS_FLOAT_INT_DBL); final Matcher matcher = pattern.matcher(vacantLandDetails.getMarketValue().toString()); if (!matcher.matches()) { errorDetails.setErrorCode(MKT_VAL_NUMBER_REQ_CODE); errorDetails.setErrorMessage(MKT_VAL_NUMBER_REQ_MSG); return errorDetails; } } if (vacantLandDetails.getCurrentCapitalValue() == null) { errorDetails.setErrorCode(CURRENT_CAPITAL_VALUE_REQ_CODE); errorDetails.setErrorMessage(CURRENT_CAPITAL_VALUE_REQ_MSG); return errorDetails; } else if (vacantLandDetails.getCurrentCapitalValue().compareTo(BigDecimal.ZERO) == 0) { errorDetails.setErrorCode(CURRENT_CAPITAL_VALUE_GREATER_THAN_ZERO_CODE); errorDetails.setErrorMessage(CURRENT_CAPITAL_VALUE_GREATER_THAN_ZERO_MSG); return errorDetails; } else if (StringUtils.isBlank(vacantLandDetails.getEffectiveDate())) { errorDetails.setErrorCode(EFFECTIVE_DATE_REQ_CODE); errorDetails.setErrorMessage(EFFECTIVE_DATE_REQ_MSG); return errorDetails; } if (vacantLandDetails.getVacantLandPlot() == null) { errorDetails.setErrorCode(VACANTLAND_AREA_REQ); errorDetails.setErrorMessage(VACANTLAND_AREA_REQ_MSG); return errorDetails; } if (vacantLandPlotAreaRepository.findOne(vacantLandDetails.getVacantLandPlot()) == null) { errorDetails.setErrorCode(VACANT_PLOT_AREA_TYPE_DOESNT_EXIST); errorDetails.setErrorMessage(VACANT_PLOT_AREA_TYPE_DOESNT_EXIST_MSG); return errorDetails; } if (vacantLandDetails.getLayoutApprovalAuthority() == null) { errorDetails.setErrorCode(LAYOUT_AUTHORITY_REQ); errorDetails.setErrorMessage(LAYOUT_AUTHORITY_REQ_MSG); return errorDetails; } if (layoutApprovalAuthorityRepo.findOne(vacantLandDetails.getLayoutApprovalAuthority()) == null) { errorDetails.setErrorCode(LAYOUT_AUTH_DOESNT_EXIST); errorDetails.setErrorMessage(LAYOUT_AUTH_DOESNT_EXIST_MSG); return errorDetails; } if (vacantLandDetails.getLayoutPermitNumber().isEmpty() && !NO_APPROVAL.equals(layoutApprovalAuthorityRepo .findOne(vacantLandDetails.getLayoutApprovalAuthority()).getName())) { errorDetails.setErrorCode(LAYOUT_AUTHORITY_NUM); errorDetails.setErrorMessage(LAYOUT_AUTHORITY_NUM_MSG); return errorDetails; } if (vacantLandDetails.getLayoutPermitDate().isEmpty() && !NO_APPROVAL.equals(layoutApprovalAuthorityRepo .findOne(vacantLandDetails.getLayoutApprovalAuthority()).getName())) { errorDetails.setErrorCode(LAYOUT_AUTHORITY_DATE); errorDetails.setErrorMessage(LAYOUT_AUTHORITY_DATE_MSG); return errorDetails; } final SurroundingBoundaryDetails surBoundaryDetails = createPropDetails.getSurroundingBoundaryDetails(); if (surBoundaryDetails == null) { errorDetails.setErrorCode(SURROUNDING_BOUNDARY_DETAILS_REQ_CODE); errorDetails.setErrorMessage(SURROUNDING_BOUNDARY_DETAILS_REQ_MSG); return errorDetails; } else if (StringUtils.isBlank(surBoundaryDetails.getNorthBoundary())) { errorDetails.setErrorCode(NORTH_BOUNDARY_REQ_CODE); errorDetails.setErrorMessage(NORTH_BOUNDARY_REQ_MSG); return errorDetails; } else if (StringUtils.isBlank(surBoundaryDetails.getSouthBoundary())) { errorDetails.setErrorCode(SOUTH_BOUNDARY_REQ_CODE); errorDetails.setErrorMessage(SOUTH_BOUNDARY_REQ_MSG); return errorDetails; } else if (StringUtils.isBlank(surBoundaryDetails.getEastBoundary())) { errorDetails.setErrorCode(EAST_BOUNDARY_REQ_CODE); errorDetails.setErrorMessage(EAST_BOUNDARY_REQ_MSG); return errorDetails; } else if (StringUtils.isBlank(surBoundaryDetails.getWestBoundary())) { errorDetails.setErrorCode(WEST_BOUNDARY_REQ_CODE); errorDetails.setErrorMessage(WEST_BOUNDARY_REQ_MSG); return errorDetails; } } return errorDetails; }
From source file:org.eclipse.gyrex.cloud.internal.preferences.ZooKeeperBasedPreferences.java
@Override public void putFloat(final String key, final float value) { put(key, Float.toString(value)); }
From source file:eu.optimis.service_manager.rest.ServiceManagerREST.java
/** * Returns the initial trust value of an infrastructure provider. * <p/>//from ww w .j a v a2 s .c o m * This operation is exposed through this URL: * <p/> * <code>/services/{serviceId}/ip/initialtrustvalue</code> * * @param serviceId * the id of the service * * @param ipId * the infrastructure provider id * * @return initial trust value */ @GET @Path("/services/{serviceId}/{ipId}/initialtrustvalue") public String getInitialTrustValue(@PathParam("serviceId") String serviceId, @PathParam("ipId") String ipId) { LOGGER.debug("ServiceManagerREST: getInitialTrustValue() called for serviceId: " + serviceId + " with ipId: " + ipId); float initialTrustValue; try { initialTrustValue = serviceManager.getInitialTrustValue(serviceId, ipId); } catch (ItemNotFoundException itemNotFoundException) { LOGGER.error("ServiceManagerREST: Cannot get infrastructure provider ids for service with id '" + serviceId + "': " + itemNotFoundException.getMessage()); throw new WebApplicationException(Response.Status.NOT_FOUND); } return Float.toString(initialTrustValue); }
From source file:eu.optimis.service_manager.rest.ServiceManagerREST.java
/** * Returns the initial risk value of an infrastructure provider. * <p/>//w w w . j a v a 2s.c o m * This operation is exposed through this URL: * <p/> * <code>/services/{serviceId}/ip/initialriskvalue</code> * * @param serviceId * the id of the service * * @param ipId * the infrastructure provider id * * @return initial risk value */ @GET @Path("/services/{serviceId}/{ipId}/initialriskvalue") public String getInitialRiskValue(@PathParam("serviceId") String serviceId, @PathParam("ipId") String ipId) { LOGGER.debug("ServiceManagerREST: getInitialRiskValue() called for serviceId: " + serviceId + " with ipId: " + ipId); float initialRiskValue; try { initialRiskValue = serviceManager.getInitialRiskValue(serviceId, ipId); } catch (ItemNotFoundException itemNotFoundException) { LOGGER.error("ServiceManagerREST: Cannot get infrastructure provider ids for service with id '" + serviceId + "': " + itemNotFoundException.getMessage()); throw new WebApplicationException(Response.Status.NOT_FOUND); } return Float.toString(initialRiskValue); }
From source file:Logica.Usuario.java
/** * * @param items/*w w w . j a v a 2s .c o m*/ * @param sol * @param proveedor * @return * @throws RemoteException */ @Override public boolean aprobarItems(ArrayList<ItemInventario> items, solicitudPr sol, ArrayList<String> proveedor) throws RemoteException { EntityManagerFactory emf = Persistence.createEntityManagerFactory("Biot_ServerPU"); boolean itxActualizado = false; Double numsol = new Double(sol.getNum_sol().toString()); try { SolicitudPrJpaController contr = new SolicitudPrJpaController(emf); SolicitudPr solicitud = contr.findSolicitudPr(numsol); solicitud.setIdAo(sol.getIdAO()); EntityManager em = emf.createEntityManager(); Query q = em.createNamedQuery("Itxsol.findSol_Item"); q.setParameter("numSol", numsol); ItxsolJpaController con = new ItxsolJpaController(emf); int indexProv = 0; ArrayList<ItemInventario> itemsAprobado = this.getItemsAprobado(sol.getNum_sol(), "NO"); for (ItemInventario item : items) { ItemJpaController itemJpaController = new ItemJpaController(emf); Item findItem = itemJpaController.findItem(item.getNumero()); findItem.setPrecio(new Double(Float.toString(item.getPrecio()))); q.setParameter("cinterno", findItem); List<Itxsol> resultList = q.getResultList(); Itxsol get = resultList.get(0); Itxsol found = con.findItxsol(get.getId()); found.setAprobado("SI"); found.setCantidadaprobada(new Double(item.getCantidadSolicitada())); found.setGenerado("NO"); found.setNitProveedor(proveedor.get(indexProv)); con.edit(found); itxActualizado = true; itemJpaController.edit(findItem); this.asociarItem(item.getNumero(), proveedor.get(indexProv), Float.toString(item.getPrecio())); indexProv++; Tablamostrar tablamostrar = new Tablamostrar(); tablamostrar.setIdArchivo(sol.getNum_sol().doubleValue()); tablamostrar.setIdUsuario(sol.getIdAO()); tablamostrar.setTipoArchivo("SolicitudRev"); tablamostrar.setMostrar("SI"); TablamostrarJpaController conTabla = new TablamostrarJpaController(emf); conTabla.create(tablamostrar); } if (itemsAprobado.size() == items.size()) { solicitud.setRevisado("SI"); contr.edit(solicitud); } } catch (Exception ex) { Logger.getLogger(Usuario.class.getName()).log(Level.SEVERE, null, ex); } emf.close(); return itxActualizado; }
From source file:org.pentaho.di.trans.steps.accessinput.AccessInputMeta.java
/** * Returns kettle type from Microsoft Access database also convert data to prepare kettle value * * @param : MS Access column/* w w w . j a v a 2 s. com*/ * @param : destination field name * @param : MS Access column value * @return valuemeta and data */ public static ValueMetaAndData getValueMetaAndData(Column c, String name, Object data) { ValueMetaAndData valueMetaData = new ValueMetaAndData(); // get data Object o = data; // Get column type DataType type = c.getType(); int sourceValueType = ValueMetaInterface.TYPE_STRING; // Find corresponding Kettle type for each MS Access type // We have to take of Meta AND data switch (type) { case BINARY: sourceValueType = ValueMeta.TYPE_BINARY; break; case BOOLEAN: sourceValueType = ValueMeta.TYPE_BOOLEAN; if (o != null) { o = Boolean.valueOf(o.toString()); } break; case DOUBLE: sourceValueType = ValueMeta.TYPE_NUMBER; break; case FLOAT: sourceValueType = ValueMeta.TYPE_BIGNUMBER; if (o != null) { o = new BigDecimal(Float.toString((Float) o)); } break; case INT: sourceValueType = ValueMeta.TYPE_NUMBER; if (o != null) { o = Double.parseDouble(o.toString()); } break; case BYTE: sourceValueType = ValueMeta.TYPE_NUMBER; if (o != null) { o = Double.parseDouble(o.toString()); } break; case LONG: sourceValueType = ValueMeta.TYPE_INTEGER; if (o != null) { Integer i = (Integer) o; o = i.longValue(); } break; case MEMO: // Should be considered as String break; case MONEY: sourceValueType = ValueMeta.TYPE_BIGNUMBER; break; case NUMERIC: sourceValueType = ValueMeta.TYPE_BIGNUMBER; break; case SHORT_DATE_TIME: sourceValueType = ValueMeta.TYPE_DATE; break; default: // Default it's string if (o != null) { o = o.toString(); } break; } ValueMetaInterface sourceValueMeta = new ValueMeta(name == null ? c.getName() : name, sourceValueType); sourceValueMeta.setLength(c.getLength(), c.getPrecision()); // set value meta data and return it valueMetaData.setValueMeta(sourceValueMeta); if (o != null) { valueMetaData.setValueData(o); } return valueMetaData; }
From source file:eu.optimis.service_manager.rest.ServiceManagerREST.java
/** * Returns the initial eco value of an infrastructure provider. * <p/>/* w w w .ja v a 2 s . c om*/ * This operation is exposed through this URL: * <p/> * <code>/services/{serviceId}/ip/initialecovalue</code> * * @param serviceId * the id of the service * * @param ipId * the infrastructure provider id * * @return initial eco value */ @GET @Path("/services/{serviceId}/{ipId}/initialecovalue") public String getInitialEcoValue(@PathParam("serviceId") String serviceId, @PathParam("ipId") String ipId) { LOGGER.debug("ServiceManagerREST: getInitialEcoValue() called for serviceId: " + serviceId + " with ipId: " + ipId); float initialEcoValue; try { initialEcoValue = serviceManager.getInitialEcoValue(serviceId, ipId); } catch (ItemNotFoundException itemNotFoundException) { LOGGER.error("ServiceManagerREST: Cannot get infrastructure provider ids for service with id '" + serviceId + "': " + itemNotFoundException.getMessage()); throw new WebApplicationException(Response.Status.NOT_FOUND); } return Float.toString(initialEcoValue); }