List of usage examples for java.lang Double toString
public String toString()
From source file:it.govpay.web.rs.dars.monitoraggio.pagamenti.ReportisticaPagamentiHandler.java
@Override public Map<String, Voce<String>> getVoci(EstrattoConto entry, BasicBD bd) throws ConsoleException { Map<String, Voce<String>> valori = new HashMap<String, Voce<String>>(); Date dataPagamento = entry.getDataPagamento(); String statoPagamento = Utils.getInstance(this.getLanguage()) .getMessageFromResourceBundle(this.nomeServizio + ".statoPagamento.ok"); Double importo = entry.getImportoPagato() != null ? entry.getImportoPagato() : 0D; //String statoPagamentoLabel = Utils.getInstance(this.getLanguage()).getMessageWithParamsFromResourceBundle(this.nomeServizio + ".label.sottotitolo.ok", this.sdf.format(dataPagamento)); // Stato//from ww w. j a v a 2 s. com if (entry.getIdRr() != null) { statoPagamento = Utils.getInstance(this.getLanguage()) .getMessageFromResourceBundle(this.nomeServizio + ".statoPagamento.revocato"); } valori.put( Utils.getInstance(this.getLanguage()) .getMessageFromResourceBundle(this.nomeServizio + ".statoPagamento.id"), new Voce<String>(statoPagamento, statoPagamento)); valori.put( Utils.getInstance(this.getLanguage()) .getMessageFromResourceBundle(this.nomeServizio + ".statoVersamento.id"), new Voce<String>( Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle( this.nomeServizio + ".statoVersamento." + entry.getStatoVersamento().name()), entry.getStatoVersamento().name())); valori.put( Utils.getInstance(this.getLanguage()) .getMessageFromResourceBundle(this.nomeServizio + ".importoPagato.id"), new Voce<String>(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle( this.nomeServizio + ".importoPagato.label"), importo.toString() + "")); if (dataPagamento != null) { valori.put( Utils.getInstance(this.getLanguage()) .getMessageFromResourceBundle(this.nomeServizio + ".dataPagamento.id"), new Voce<String>(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle( this.nomeServizio + ".dataPagamento.label"), this.sdf.format(dataPagamento))); } if (entry.getIur() != null) { valori.put( Utils.getInstance(this.getLanguage()) .getMessageFromResourceBundle(this.nomeServizio + ".iur.id"), new Voce<String>(Utils.getInstance(this.getLanguage()) .getMessageFromResourceBundle(this.nomeServizio + ".iur.label"), entry.getIur())); } if (entry.getCodSingoloVersamentoEnte() != null) { valori.put( Utils.getInstance(this.getLanguage()) .getMessageFromResourceBundle(this.nomeServizio + ".codSingoloVersamentoEnte.id"), new Voce<String>( Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle( this.nomeServizio + ".codSingoloVersamentoEnte.label"), entry.getCodSingoloVersamentoEnte())); } return valori; }
From source file:com.tao.realweb.util.StringUtil.java
/** * ? //from w w w .j ava 2 s.co m * * @param money * @param style * ? [default]???? such as #.00, #.# * @return */ public static String moneyToString(Object money, String style) { if (money != null && style != null && (money instanceof Double || money instanceof Float)) { Double num = (Double) money; if (style.equalsIgnoreCase("default")) { // ?? 0 ? ,???.0 if (num == 0) { // ?0 return ""; } else if ((num * 10 % 10) == 0) { // ? return Integer.toString((int) num.intValue()); } else { // ? return num.toString(); } } else { DecimalFormat df = new DecimalFormat(style); return df.format(num); } } return null; }
From source file:net.cbtltd.rest.AbstractReservation.java
/** * Gets the search quote for product./*from w w w . j a v a2s . co m*/ * * @param sqlSession the current SQL session. * @param agentid the agentid * @param productid the productid * @param fromdate the fromdate * @param todate the todate * @param currency the currency * @param terms the terms * @return the quote */ private static Quote getProductQuote(SqlSession sqlSession, String agentid, String productid, String fromdate, String todate, Integer guestCount, Boolean checkexactmatch, String currency, Boolean terms) { Quote result = null; Integer personCount = 0; try { /* Product check */ Product product = sqlSession.getMapper(ProductMapper.class).read(productid); if (product == null) { throw new ServiceException(Error.product_id, productid); } if (product.getAssignedtomanager() == null || !product.getAssignedtomanager()) { return null; } if (product.notState(Constants.CREATED)) { throw new ServiceException(Error.product_inactive, productid); } if (product.noRank()) { throw new ServiceException(Error.product_not_online, productid); } if (product.notType(Product.Type.Accommodation.name())) { throw new ServiceException(Error.product_type, productid + " not Accommodation"); } /* Filter by guests count */ if (product.getAdult() != null) { personCount = product.getAdult(); if (product.getChild() != null) { personCount += product.getChild(); } if (guestCount != null) { if (personCount < guestCount) { return null; } } } /* Filter by manager related to channel partner */ List<String> listManagerIds = sqlSession.getMapper(ChannelPartnerMapper.class) .readRelatedManagersByPartyId(Integer.valueOf(agentid)); if (!listManagerIds.contains(product.getSupplierid())) { return null; } Party party = sqlSession.getMapper(PartyMapper.class).read(product.getSupplierid()); Reservation reservation = new Reservation(); reservation.setProductid(productid); reservation.setFromdate(Constants.parseDate(fromdate)); reservation.setTodate(Constants.parseDate(todate)); reservation.setOrganizationid(product.getSupplierid()); reservation.setActorid(Party.NO_ACTOR); reservation.setAgentid(agentid); reservation.setDate(new Date()); reservation.setDuedate(reservation.getDate()); reservation.setDonedate(null); /* TODO: CHECK what to do whith this */ //reservation.setQuantity(ReservationService.getAvailable(sqlSession, reservation)); reservation.setQuantity(1); // reservation.setUnit(product.getUnit()); reservation.setCurrency(product.getCurrency()); reservation.setNotes("XML Reservation Request"); reservation.setState(Reservation.State.Provisional.name()); reservation.setAltpartyid(product.getAltpartyid()); PropertyManagerInfo propertyManagerInfo = sqlSession.getMapper(PropertyManagerInfoMapper.class) .readbypmid(Integer.valueOf(party.getId())); currency = PartyService.checkbookingnetCurrency(currency, propertyManagerInfo); result = computeQuote(sqlSession, fromdate, todate, currency, terms, null, product, reservation, false); if (reservation.getPrice() == 0.0 && reservation.getCost() == 0.0 && reservation.getExtra() == 0.0) { return null; } result.setBedroom(product.getRoom() == null ? "1" : product.getRoom().toString()); // default 1 result.setBathroom(product.getBathroom() == null ? "1" : product.getBathroom().toString()); // default 1 // result.setMainstay(""); String address = product.getAddress() == null ? "" : Arrays.toString(product.getAddress()); result.setAddress(address); result.setManagerName(party == null ? "" : party.getName()); // String picture = getImageUrl(sqlSession, product); // Integer picturesSize = getImagesQuantity(sqlSession, product); List<String> productImages = ImageService.getProductRegularImageURLs(sqlSession, product.getId()); String picture = productImages.size() > 0 ? productImages.get(0) : ""; Integer picturesSize = productImages.size(); result.setGuests(personCount.toString()); result.setPictureLocation(picture); result.setPicturesQuantity(picturesSize); Double lng = product.getLongitude() == null ? 0 : product.getLongitude(); // FIXME : workaround Double lat = product.getLatitude() == null ? 0 : product.getLatitude();// FIXME : workaround result.setLongitude(lng.toString()); result.setLatitude(lat.toString()); result.updatePriceCheckInDayRule(); result.updateExactMatch(); PropertyManagerInfo pmInfo = sqlSession.getMapper(PropertyManagerInfoMapper.class) .readbypmid(Integer.valueOf(party.getId())); if (pmInfo != null) { result.setInquiryOnly(pmInfo.isInquireOnly()); } else { result.setInquiryOnly(true); } if (checkexactmatch && !result.getExactmatch()) { return null; } LOG.debug(result); } catch (Throwable x) { if (x != null && x.getMessage() != null && !x.getMessage().startsWith(Error.product_not_available.name())) { LOG.error("getQuote " + agentid + " " + x.getMessage()); } result = new Quote(productid, fromdate, todate, Currency.Code.USD.name(), x.getMessage()); } return result; }
From source file:com.commander4j.sys.JHostList.java
public boolean checkUpdatedHosts() { boolean result = false; if (Common.updateMODE.equals("AUTOMATIC")) { Double currentHostVersion = Double.valueOf(Common.hostVersion); logger.debug("Current Host File Version = " + String.valueOf(currentHostVersion)); String hostUpdatePath = Common.hostUpdatePath; if (hostUpdatePath.equals("") == true) { logger.debug("No hosts file update location specified, checking application update url."); hostUpdatePath = Common.updateURL; if (hostUpdatePath.equals("") == true) { logger.debug("No application update location specified. Hosts update will not occur."); } else { hostUpdatePath = StringUtils.removeIgnoreCase(hostUpdatePath, "file:"); int windowsDriveLetter = hostUpdatePath.indexOf(":"); if (windowsDriveLetter > 0) { hostUpdatePath = StringUtils.substring(hostUpdatePath, windowsDriveLetter - 1); }//from w ww. j a v a 2s.c o m hostUpdatePath = JUtility.formatPath(hostUpdatePath); hostUpdatePath = StringUtils.replaceIgnoreCase(hostUpdatePath, "updates.xml", "hosts.xml"); logger.debug("Using application update url to check for updated hosts."); } } Common.hostUpdatePath = hostUpdatePath; // See if updatedHosts location specified if (hostUpdatePath.equals("") == false) { logger.debug("Updated Host Path = [" + hostUpdatePath + "]"); if (Files.exists(Paths.get(hostUpdatePath))) { logger.debug("Updated Host Path = [" + hostUpdatePath + "] found."); Double updatedHostVersion = JXMLHost.checkHostVersion(hostUpdatePath); logger.debug("Updated Host File Version = " + String.valueOf(updatedHostVersion)); if (updatedHostVersion > currentHostVersion) { logger.debug("Copying Updated Host File [" + hostUpdatePath + "]"); try { File destDir = new File(System.getProperty("user.dir") + File.separator + "xml" + File.separator + "hosts"); File srcFile = new File(hostUpdatePath); FileUtils.copyFileToDirectory(srcFile, destDir); result = true; } catch (Exception e) { logger.debug("Error Copying Updated Host File :" + e.getMessage()); } } else { logger.debug("Current hosts file is up to date " + currentHostVersion.toString()); } } else { logger.debug("Updated Host Path = " + hostUpdatePath + " not found."); } } } return result; }
From source file:com.consult.app.controller.WebController.java
/** * ???/* ww w.j a v a2 s.c o m*/ * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping(value = "getsmslocatebalance", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResultObjectResponse getSmsLocateBalance(@RequestBody TypeRequest req, HttpServletResponse response, HttpServletRequest request) { ResultObjectResponse rp = new ResultObjectResponse(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long adminId = Cookie.checkAdminUser(strId); Double balance = PositionHelper.queryBalance(); rp.setInfo(balance.toString()); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; }
From source file:edu.harvard.iq.dvn.core.web.ExploreDataPage.java
private String fillInGaps(String stringIn) { String[] stringInSplit = stringIn.split(","); Double firstVal = new Double(0); Double endVal = new Double(0); boolean gapFound = false; int indexUpdate = 0; int firstIndex = 0; int lastIndex = 0; for (int i = 0; i < stringInSplit.length; i++) { if (!gapFound && !stringInSplit[i].trim().isEmpty()) { firstVal = new Double(stringInSplit[i].trim()); firstIndex = i;// w ww . j ava 2 s.c om } if (!gapFound && firstVal != 0 && stringInSplit[i].trim().isEmpty()) { gapFound = true; indexUpdate = i; } if (gapFound && !stringInSplit[i].trim().isEmpty() && lastIndex == 0) { endVal = new Double(stringInSplit[i].trim()); lastIndex = i; } } Double interVal = (firstVal * (lastIndex - indexUpdate) + endVal) / (lastIndex - firstIndex); stringInSplit[indexUpdate] = interVal.toString(); String retString = ""; for (int i = 0; i < stringInSplit.length; i++) { retString += stringInSplit[i] + ","; } return retString; }
From source file:mondrian.test.loader.MondrianFoodMartLoader.java
/** * String representation of the column in the result set, suitable for * inclusion in a SQL insert statement.<p/> * * The column in the result set is transformed according to the type in * the column parameter.<p/>/* www . jav a 2s. co m*/ * * Different DBMSs (and drivers) return different Java types for a given * column; {@link ClassCastException}s may occur. * * @param rs ResultSet row to process * @param column Column to process * @return String representation of column value */ private String columnValue(ResultSet rs, Column column) throws Exception { Object obj = rs.getObject(column.name); String columnType = column.typeName; if (obj == null) { return "NULL"; } /* * Output for an INTEGER column, handling Doubles and Integers * in the result set */ if (columnType.startsWith(Type.Integer.name)) { if (obj.getClass() == Double.class) { try { Double result = (Double) obj; return integerFormatter.format(result.doubleValue()); } catch (ClassCastException cce) { LOGGER.error("CCE: " + column.name + " to Long from: " + obj.getClass().getName() + " - " + obj.toString()); throw cce; } } else { try { int result = ((Number) obj).intValue(); return Integer.toString(result); } catch (ClassCastException cce) { LOGGER.error("CCE: " + column.name + " to Integer from: " + obj.getClass().getName() + " - " + obj.toString()); throw cce; } } /* * Output for an SMALLINT column, handling Integers * in the result set */ } else if (columnType.startsWith(Type.Smallint.name)) { if (obj instanceof Boolean) { return (Boolean) obj ? "1" : "0"; } else { try { Integer result = (Integer) obj; return result.toString(); } catch (ClassCastException cce) { LOGGER.error("CCE: " + column.name + " to Integer from: " + obj.getClass().getName() + " - " + obj.toString()); throw cce; } } /* * Output for an BIGINT column, handling Doubles and Longs * in the result set */ } else if (columnType.startsWith("BIGINT")) { if (obj.getClass() == Double.class) { try { Double result = (Double) obj; return integerFormatter.format(result.doubleValue()); } catch (ClassCastException cce) { LOGGER.error("CCE: " + column.name + " to Double from: " + obj.getClass().getName() + " - " + obj.toString()); throw cce; } } else { try { Long result = (Long) obj; return result.toString(); } catch (ClassCastException cce) { LOGGER.error("CCE: " + column.name + " to Long from: " + obj.getClass().getName() + " - " + obj.toString()); throw cce; } } /* * Output for a String, managing embedded quotes */ } else if (columnType.startsWith("VARCHAR")) { return embedQuotes((String) obj); /* * Output for a TIMESTAMP */ } else { if (columnType.startsWith("TIMESTAMP")) { Timestamp ts = (Timestamp) obj; // REVIEW jvs 26-Nov-2006: Is it safe to replace // these with dialect.quoteTimestampLiteral, etc? switch (dialect.getDatabaseProduct()) { case ORACLE: case LUCIDDB: case NEOVIEW: return "TIMESTAMP '" + ts + "'"; default: return "'" + ts + "'"; } //return "'" + ts + "'" ; /* * Output for a DATE */ } else if (columnType.startsWith("DATE")) { Date dt = (Date) obj; switch (dialect.getDatabaseProduct()) { case ORACLE: case LUCIDDB: case NEOVIEW: return "DATE '" + dateFormatter.format(dt) + "'"; default: return "'" + dateFormatter.format(dt) + "'"; } /* * Output for a FLOAT */ } else if (columnType.startsWith(Type.Real.name)) { Float result = (Float) obj; return result.toString(); /* * Output for a DECIMAL(length, places) */ } else if (columnType.startsWith("DECIMAL")) { final Matcher matcher = decimalDataTypeRegex.matcher(columnType); if (!matcher.matches()) { throw new Exception("Bad DECIMAL column type for " + columnType); } DecimalFormat formatter = new DecimalFormat(decimalFormat(matcher.group(1), matcher.group(2))); if (obj.getClass() == Double.class) { try { Double result = (Double) obj; return formatter.format(result.doubleValue()); } catch (ClassCastException cce) { LOGGER.error("CCE: " + column.name + " to Double from: " + obj.getClass().getName() + " - " + obj.toString()); throw cce; } } else { // should be (obj.getClass() == BigDecimal.class) try { BigDecimal result = (BigDecimal) obj; return formatter.format(result); } catch (ClassCastException cce) { LOGGER.error("CCE: " + column.name + " to BigDecimal from: " + obj.getClass().getName() + " - " + obj.toString()); throw cce; } } /* * Output for a BOOLEAN (Postgres) or BIT (other DBMSs) */ } else if (columnType.startsWith("BOOLEAN") || columnType.startsWith("BIT")) { Boolean result = (Boolean) obj; return result.toString(); /* * Output for a BOOLEAN - TINYINT(1) (MySQL) */ } else if (columnType.startsWith("TINYINT(1)")) { return (Boolean) obj ? "1" : "0"; } } throw new Exception("Unknown column type: " + columnType + " for column: " + column.name); }
From source file:ispyb.client.mx.results.ViewResultsAction.java
public void getResultData(ActionMapping mapping, ActionForm actForm, HttpServletRequest request, HttpServletResponse response) {/* w w w . jav a 2s . co m*/ LOG.debug("getResultData"); List<String> errors = new ArrayList<String>(); try { List<AutoProcessingInformation> autoProcList = new ArrayList<AutoProcessingInformation>(); BreadCrumbsForm bar = BreadCrumbsForm.getIt(request); boolean displayOutputParam = false; boolean displayDenzoContent = false; // booleans to fix which tab will be selected by default boolean isEDNACharacterisation = false; boolean isAutoprocessing = false; String rMerge = (String) request.getSession().getAttribute(Constants.RSYMM); String iSigma = (String) request.getSession().getAttribute(Constants.ISIGMA); double rMerge_d = DEFAULT_RMERGE; double iSigma_d = DEFAULT_ISIGMA; int nbRemoved = 0; try { if (rMerge != null && !rMerge.equals("undefined") && !rMerge.equals("")) rMerge_d = Double.parseDouble(rMerge); if (iSigma != null && !iSigma.equals("undefined") && !iSigma.equals("")) iSigma_d = Double.parseDouble(iSigma); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } Integer dataCollectionId = null; List<List<AutoProcStatus3VO>> interruptedAutoProcEvents1 = new ArrayList<List<AutoProcStatus3VO>>(); DataCollection3VO dc = null; // Just one of them could be visible on the bar if (bar.getSelectedDataCollection() != null) { dataCollectionId = bar.getSelectedDataCollection().getDataCollectionId(); } if (dataCollectionId == null && request.getParameter(Constants.DATA_COLLECTION_ID) != null) dataCollectionId = new Integer(request.getParameter(Constants.DATA_COLLECTION_ID)); if (dataCollectionId == null && request.getSession().getAttribute(Constants.DATA_COLLECTION_ID) != null) dataCollectionId = new Integer( (Integer) request.getSession().getAttribute(Constants.DATA_COLLECTION_ID)); if (dataCollectionId == null) { errors.add("dataCollectionId is null"); HashMap<String, Object> data = new HashMap<String, Object>(); data.put("errors", errors); // data => Gson GSonUtils.sendToJs(response, data, "dd-MM-yyyy HH:mm:ss"); return; } dc = dataCollectionService.findByPk(dataCollectionId, false, true); // interrupted autoProc if (dc != null) { List<AutoProcIntegration3VO> autoProcIntegrationList = dc.getAutoProcIntegrationsList(); if (autoProcIntegrationList != null) { for (Iterator<AutoProcIntegration3VO> au = autoProcIntegrationList.iterator(); au.hasNext();) { AutoProcIntegration3VO autoProcIntegration = au.next(); if (autoProcIntegration.getAutoProcProgramVO() == null && autoProcIntegration.getAutoProcStatusList() != null) { List<AutoProcStatus3VO> events = autoProcIntegration.getAutoProcStatusList(); interruptedAutoProcEvents1.add(events); } } } } for (int i = 0; i < 2; i++) { boolean anomalous = (i > 0); List<AutoProc3VO> autoProcsAnomalous = apService .findByAnomalousDataCollectionIdAndOrderBySpaceGroupNumber(dataCollectionId, anomalous); if (autoProcsAnomalous != null) { nbRemoved = 0; LOG.debug("..nbAutoProc " + anomalous + " found before rMerge =" + autoProcsAnomalous.size()); for (Iterator<AutoProc3VO> a = autoProcsAnomalous.iterator(); a.hasNext();) { AutoProc3VO apv = a.next(); List<AutoProcScalingStatistics3VO> scalingStatistics = apssService .findByAutoProcId(apv.getAutoProcId(), "innerShell"); boolean existsUnderRmergeAndOverSigma = false; for (Iterator<AutoProcScalingStatistics3VO> j = scalingStatistics.iterator(); j .hasNext();) { AutoProcScalingStatistics3VO stats = j.next(); if (stats.getRmerge() != null && stats.getRmerge() < rMerge_d && stats.getMeanIoverSigI() > iSigma_d) existsUnderRmergeAndOverSigma = true; } if (!existsUnderRmergeAndOverSigma) { a.remove(); nbRemoved = nbRemoved + 1; } } LOG.debug("..nbAutoProc " + anomalous + " found=" + autoProcsAnomalous.size()); for (Iterator<AutoProc3VO> iterator = autoProcsAnomalous.iterator(); iterator.hasNext();) { AutoProc3VO o = iterator.next(); String cmdLine = ""; if (o.getAutoProcProgramVO() != null && o.getAutoProcProgramVO().getProcessingPrograms() != null) { cmdLine = o.getAutoProcProgramVO().getProcessingPrograms(); } float refinedCellA = ((float) ((int) (o.getRefinedCellA() * 10))) / 10; // round to 1 dp float refinedCellB = ((float) ((int) (o.getRefinedCellB() * 10))) / 10; // round to 1 dp float refinedCellC = ((float) ((int) (o.getRefinedCellC() * 10))) / 10; // round to 1 dp float refinedCellAlpha = ((float) ((int) (o.getRefinedCellAlpha() * 10))) / 10; // round to 1 dp float refinedCellBeta = ((float) ((int) (o.getRefinedCellBeta() * 10))) / 10; // round to 1 dp float refinedCellGamma = ((float) ((int) (o.getRefinedCellGamma() * 10))) / 10; // round to 1 dp String anoTxt = "OFF (Friedel pairs merged)"; // false if (anomalous) { anoTxt = "ON (Friedel pairs unmerged)"; // true } // String anomalousS = anomalous+"= "+anoTxt; AutoProcessingInformation info = new AutoProcessingInformation(o.getAutoProcId(), cmdLine, o.getSpaceGroup(), anoTxt, refinedCellA, refinedCellB, refinedCellC, refinedCellAlpha, refinedCellBeta, refinedCellGamma); autoProcList.add(info); } } } Integer autoProcIdSelected = (Integer) request.getSession().getAttribute("lastAutoProcIdSelected"); // check if autoProcIdSelected is in the list boolean idExists = false; if (autoProcIdSelected != null) { for (Iterator<AutoProcessingInformation> iterator = autoProcList.iterator(); iterator.hasNext();) { AutoProcessingInformation info = iterator.next(); if (info.getAutoProcId().equals(autoProcIdSelected)) { idExists = true; break; } } } if (!idExists) { autoProcIdSelected = null; } List<DataCollection3VO> listLastCollectVO = new ArrayList<DataCollection3VO>(); if (dc != null) listLastCollectVO.add(dc); AutoProcShellWrapper wrapper = ViewDataCollectionAction.getAutoProcStatistics(listLastCollectVO, rMerge_d, iSigma_d); int dcIndex = 0; // is autoproc ? List<AutoProc3VO> autoProcs = apService.findByDataCollectionId(dataCollectionId); if (autoProcs != null && autoProcs.size() > 0) isAutoprocessing = true; String beamLineName = ""; String proposal = ""; String proteinAcronym = ""; String pdbFileName = ""; String experimentType = ""; if (dc != null) { beamLineName = dc.getDataCollectionGroupVO().getSessionVO().getBeamlineName(); proposal = dc.getDataCollectionGroupVO().getSessionVO().getProposalVO().getCode() + dc.getDataCollectionGroupVO().getSessionVO().getProposalVO().getNumber(); BLSample3VO sample = dc.getDataCollectionGroupVO().getBlSampleVO(); if (sample != null && sample.getCrystalVO() != null && sample.getCrystalVO().getProteinVO() != null) proteinAcronym = sample.getCrystalVO().getProteinVO().getAcronym(); if (sample != null && sample.getCrystalVO() != null && sample.getCrystalVO().hasPdbFile()) { pdbFileName = sample.getCrystalVO().getPdbFileName(); } experimentType = dc.getDataCollectionGroupVO().getExperimentType(); } AutoProc3VO autoProc = null; AutoProcScalingStatistics3VO autoProcStatisticsOverall = null; AutoProcScalingStatistics3VO autoProcStatisticsInner = null; AutoProcScalingStatistics3VO autoProcStatisticsOuter = null; ScreeningOutputLattice3VO lattice = null; ScreeningOutput3VO screeningOutput = null; String snapshotFullPath = ""; boolean hasSnapshot = false; Screening3VO[] tabScreening = null; if (dc != null) { snapshotFullPath = dc.getXtalSnapshotFullPath1(); snapshotFullPath = PathUtils.FitPathToOS(snapshotFullPath); if (snapshotFullPath != null) hasSnapshot = (new File(snapshotFullPath)).exists(); autoProc = wrapper.getAutoProcs()[dcIndex]; autoProcStatisticsOverall = wrapper.getScalingStatsOverall()[dcIndex]; autoProcStatisticsInner = wrapper.getScalingStatsInner()[dcIndex]; autoProcStatisticsOuter = wrapper.getScalingStatsOuter()[dcIndex]; DataCollectionGroup3VO dcGroup = dataCollectionGroupService .findByPk(dc.getDataCollectionGroupVOId(), false, true); tabScreening = dcGroup.getScreeningsTab(); } if (tabScreening != null && tabScreening.length > 0) { displayOutputParam = true;// there is at least 1 screening so we display the output params Screening3VO screeningVO = tabScreening[0]; ScreeningOutput3VO[] screeningOutputTab = screeningVO.getScreeningOutputsTab(); if (screeningOutputTab != null && screeningOutputTab.length > 0) { if (screeningOutputTab[0].getScreeningOutputLatticesTab() != null && screeningOutputTab[0].getScreeningOutputLatticesTab().length > 0) { lattice = screeningOutputTab[0].getScreeningOutputLatticesTab()[0]; } screeningOutput = screeningOutputTab[0]; } } String autoprocessingStatus = ""; String autoprocessingStep = ""; if (wrapper != null && wrapper.getAutoProcs() != null && wrapper.getAutoProcs().length > dcIndex) { AutoProcIntegration3VO autoProcIntegration = wrapper.getAutoProcIntegrations()[dcIndex]; if (autoProcIntegration != null) { List<AutoProcStatus3VO> autoProcEvents = autoProcIntegration.getAutoProcStatusList(); if (autoProcEvents != null && autoProcEvents.size() > 0) { AutoProcStatus3VO st = autoProcEvents.get(autoProcEvents.size() - 1); autoprocessingStatus = st.getStatus(); autoprocessingStep = st.getStep(); } } } boolean hasAutoProcAttachment = false; if (wrapper != null && wrapper.getAutoProcs() != null) { for (int a = 0; a < autoProcs.size(); a++) { Integer autoProcProgramId = autoProcs.get(a).getAutoProcProgramVOId(); if (autoProcProgramId != null) { List<AutoProcProgramAttachment3VO> attachments = appService .findByPk(autoProcProgramId, true).getAttachmentListVOs(); if (attachments != null && attachments.size() > 0) { hasAutoProcAttachment = true; break; } } } } DataCollectionBean dataCollection = null; if (dc != null) { dataCollection = new DataCollectionBean(dc, beamLineName, proposal, proteinAcronym, pdbFileName, experimentType, hasSnapshot, autoProc, autoProcStatisticsOverall, autoProcStatisticsInner, autoProcStatisticsOuter, screeningOutput, lattice, autoprocessingStatus, autoprocessingStep, hasAutoProcAttachment); } BeamLineSetup3VO beamline = null; Session3VO session = null; Detector3VO detector = null; String fullDenzoPath = null; boolean DenzonContentPresent = false; if (dc != null) { // beamline setup beamline = dc.getDataCollectionGroupVO().getSessionVO().getBeamLineSetupVO(); // Session session = dc.getDataCollectionGroupVO().getSessionVO(); // Detector detector = dc.getDetectorVO(); // energy DecimalFormat df3 = (DecimalFormat) NumberFormat.getInstance(Locale.US); df3.applyPattern("#####0.000"); Double energy = null; if (dc.getWavelength() != null && dc.getWavelength().compareTo(new Double(0)) != 0) energy = Constants.WAVELENGTH_TO_ENERGY_CONSTANT / dc.getWavelength(); if (energy != null) dataCollection.setEnergy(new Double(df3.format(energy))); else dataCollection.setEnergy(null); // axis start label String axisStartLabel = dc.getRotationAxis() == null ? "" : dc.getRotationAxis() + " start"; dataCollection.setAxisStartLabel(axisStartLabel); // totalExposureTime if (dc.getExposureTime() != null && dc.getNumberOfImages() != null) { dataCollection.setTotalExposureTime( new Double(df3.format(dataCollection.getExposureTime() * dc.getNumberOfImages()))); } // kappa Double kappa = dc.getKappaStart(); String kappaStr = ""; if (kappa == null || kappa.equals(Constants.SILLY_NUMBER)) kappaStr = new String("0"); else kappaStr = new String(kappa.toString()); dataCollection.setKappa(kappaStr); // phi Double phi = dc.getPhiStart(); String phiStr = ""; if (phi == null || phi.equals(Constants.SILLY_NUMBER)) phiStr = new String("0"); else phiStr = new String(phi.toString()); dataCollection.setPhi(phiStr); // undulatorGaps DecimalFormat df2 = (DecimalFormat) NumberFormat.getInstance(Locale.US); // DecimalFormat df2 = new DecimalFormat("##0.##"); df2.applyPattern("##0.##"); StringBuffer buf = new StringBuffer(); // if no type then there is no meaningful value // if no undulator 1 then no 2 and no 3 if (beamline.getUndulatorType1() != null && beamline.getUndulatorType1().length() > 0) { if (dc.getUndulatorGap1() != null && !dc.getUndulatorGap1().equals(Constants.SILLY_NUMBER)) { Double gap1 = new Double(df2.format(dc.getUndulatorGap1())); buf.append(gap1.toString()).append(" mm "); } if (beamline.getUndulatorType2() != null && beamline.getUndulatorType2().length() > 0) { if (dc.getUndulatorGap2() != null && !dc.getUndulatorGap2().equals(Constants.SILLY_NUMBER)) { Double gap2 = new Double(df2.format(dc.getUndulatorGap2())); buf.append(gap2.toString()).append(" mm "); } if (beamline.getUndulatorType3() != null && beamline.getUndulatorType3().length() > 0) { if (dc.getUndulatorGap3() != null && !dc.getUndulatorGap3().equals(Constants.SILLY_NUMBER)) { Double gap3 = new Double(df2.format(dc.getUndulatorGap3())); buf.append(gap3.toString()).append(" mm "); } } } } String undulatorGaps = buf.toString(); dataCollection.setUndulatorGaps(undulatorGaps); DecimalFormat nf1 = (DecimalFormat) NumberFormat.getInstance(Locale.UK); nf1.applyPattern("#"); DecimalFormat df5 = (DecimalFormat) NumberFormat.getInstance(Locale.US); df5.applyPattern("#####0.00000"); // slitGapHorizontalMicro Integer slitGapHorizontalMicro = null; if (dc.getSlitGapHorizontal() != null) { // in DB beamsize unit is mm, display is in micrometer => conversion slitGapHorizontalMicro = new Integer( nf1.format(dc.getSlitGapHorizontal().doubleValue() * 1000)); } dataCollection.setSlitGapHorizontalMicro(slitGapHorizontalMicro); // slitGapVerticalMicro Integer slitGapVerticalMicro = null; if (dc.getSlitGapVertical() != null) { // in DB beamsize unit is mm, display is in micrometer => conversion slitGapVerticalMicro = new Integer(nf1.format(dc.getSlitGapVertical().doubleValue() * 1000)); } dataCollection.setSlitGapVerticalMicro(slitGapVerticalMicro); // detectorPixelSizeHorizontalMicro Double detectorPixelSizeHorizontalMicro = null; if (detector != null && detector.getDetectorPixelSizeHorizontal() != null) { // in DB pixel size unit is mm, detectorPixelSizeHorizontalMicro = new Double( df5.format(detector.getDetectorPixelSizeHorizontal())); } dataCollection.setDetectorPixelSizeHorizontalMicro(detectorPixelSizeHorizontalMicro); // detectorPixelSizeHorizontalMicro Double detectorPixelSizeVerticalMicro = null; if (detector != null && detector.getDetectorPixelSizeVertical() != null) { // in DB pixel size unit is mm, detectorPixelSizeVerticalMicro = new Double( df5.format(detector.getDetectorPixelSizeVertical())); } dataCollection.setDetectorPixelSizeVerticalMicro(detectorPixelSizeVerticalMicro); // beamSizeAtSampleXMicro Integer beamSizeAtSampleXMicro = null; if (dc.getBeamSizeAtSampleX() != null) { // in DB beamsize unit is mm, display is in micrometer => conversion beamSizeAtSampleXMicro = new Integer( nf1.format(dc.getBeamSizeAtSampleX().doubleValue() * 1000)); } dataCollection.setBeamSizeAtSampleXMicro(beamSizeAtSampleXMicro); // beamSizeAtSampleYMicro Integer beamSizeAtSampleYMicro = null; if (dc.getBeamSizeAtSampleY() != null) { // in DB beamsize unit is mm, display is in micrometer => conversion beamSizeAtSampleYMicro = new Integer( nf1.format(dc.getBeamSizeAtSampleY().doubleValue() * 1000)); } dataCollection.setBeamSizeAtSampleYMicro(beamSizeAtSampleYMicro); // beamDivergenceHorizontalInt Integer beamDivergenceHorizontalInt = null; if (beamline.getBeamDivergenceHorizontal() != null) { beamDivergenceHorizontalInt = new Integer(nf1.format(beamline.getBeamDivergenceHorizontal())); } dataCollection.setBeamDivergenceHorizontalInt(beamDivergenceHorizontalInt); // beamDivergenceVerticalInt Integer beamDivergenceVerticalInt = null; if (beamline.getBeamDivergenceVertical() != null) { beamDivergenceVerticalInt = new Integer(nf1.format(beamline.getBeamDivergenceVertical())); } dataCollection.setBeamDivergenceVerticalInt(beamDivergenceVerticalInt); // DNA or EDNA Content present ? String fullDNAPath = PathUtils.getFullDNAPath(dc); String fullEDNAPath = PathUtils.getFullEDNAPath(dc); boolean EDNAContentPresent = (new File(fullEDNAPath + EDNA_FILES_INDEX_FILE)).exists() || (new File(fullDNAPath + Constants.DNA_FILES_INDEX_FILE)).exists(); isEDNACharacterisation = EDNAContentPresent; // Denzo Content present ? if (Constants.DENZO_ENABLED) { fullDenzoPath = FileUtil.GetFullDenzoPath(dc); DenzonContentPresent = (new File(fullDenzoPath)).exists(); displayDenzoContent = DisplayDenzoContent(dc); if (DenzonContentPresent) // Check html file present { File denzoIndex = new File(fullDenzoPath + DENZO_HTML_INDEX); if (!denzoIndex.exists()) { errors.add("Denzo File does not exist " + denzoIndex); DenzonContentPresent = false; } } } } // HashMap<String, Object> data = new HashMap<String, Object>(); // context path data.put("contextPath", request.getContextPath()); // autoProcList data.put("autoProcList", autoProcList); // autoProcIdSelected data.put("autoProcIdSelected", autoProcIdSelected); // rMerge & iSigma data.put("rMerge", rMerge); data.put("iSigma", iSigma); data.put("nbRemoved", nbRemoved); data.put("dataCollectionId", dataCollectionId); data.put("dataCollection", dataCollection); // beamlinesetup data.put("beamline", beamline); // session data.put("session", session); // detector data.put("detector", detector); // interrupted autoProc data.put("interruptedAutoProcEvents", interruptedAutoProcEvents1); // displayOutputParam data.put("displayOutputParam", displayOutputParam); // isEDNACharacterisation data.put("isEDNACharacterisation", isEDNACharacterisation); // isAutoprocessing data.put("isAutoprocessing", isAutoprocessing); // displayDenzoContent data.put("displayDenzoContent", displayDenzoContent); // DenzonContentPresent data.put("DenzonContentPresent", DenzonContentPresent); // fullDenzoPath data.put("fullDenzoPath", fullDenzoPath); // data => Gson GSonUtils.sendToJs(response, data, "dd-MM-yyyy HH:mm:ss"); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.sundevils.web.controller.TopController.java
@RequestMapping(value = "/moddeltransaction", method = { RequestMethod.POST, RequestMethod.GET }) public ModelAndView modifyDeleteTransaction(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException, SQLException { String role = ""; String requestType = ""; String[] authRequests = null; Double newAmount = 0.0; String transactionAmount = ""; role = (String) session.getAttribute("Role"); double amount = 0.0; double balance = 0.0; String accountNumber = ""; double sourceAmount = 0.0; String sourceAccountNumber = ""; boolean sourceFlag = true; Boolean status = true;//from w w w . ja v a 2s.c o m Boolean statusSource = true; if (role == null) { ModelAndView model = new ModelAndView(); model.setViewName("index"); return model; } if (role.equals("EMPLOYEE")) { ModelAndView model = new ModelAndView(); model.setViewName("moddeltransaction"); List<TransactionDetails> transDetails = new ArrayList<TransactionDetails>(); RequestAuthorize authorize = new RequestAuthorize(); try { if (request.getParameter("submit") != null) { authRequests = request.getParameterValues("check"); requestType = request.getParameter("Type"); if (authRequests != null) { if (requestType.equals("Modify")) { if (authRequests.length > 1) model.addObject("multiplemodify", "Please check only one transaction while modifying."); else { newAmount = Double.parseDouble(request.getParameter(authRequests[0])); transactionAmount = (String) session.getAttribute("AMOUNT"); Double difference = newAmount - Double.parseDouble(transactionAmount); if (newAmount > 0 || !newAmount.toString().matches("[0-9]+$")) { accountNumber = authorize.getDestinationAccount(authRequests[0]); sourceAccountNumber = authorize.getSourceAccount(authRequests[0]); status = authorize.checkAccountNumber(accountNumber); statusSource = authorize.checkAccountNumber(sourceAccountNumber); if (status && statusSource) { amount = authorize.getDestinationBalance(accountNumber); sourceAmount = authorize.getSourceBalance(sourceAccountNumber); if (!(sourceAmount >= difference)) { model.addObject("greatervalue", "Insufficint funds in the account"); } else { authorize.approveModifySourceTransaction(newAmount, "approvedmodify", sourceAmount - difference, authRequests); authorize.approveModifyTransaction(newAmount, "approvedmodify", newAmount + amount, authRequests); model.addObject("success", "The modifcation of normal transaction/s is successfully done"); } } else { model.addObject("destinationerror", "Destination account does not exist. Please delete the transaction"); } } else { model.addObject("zeroerror", "Amounts should be positive"); } } } else if (requestType.equals("Delete")) { balance = authorize.getBalance(authRequests); if (authRequests.length > 1) sourceFlag = authorize.checkSameSource(authRequests); if (sourceFlag) { sourceAccountNumber = authorize.getSourceAccount(authRequests[0]); status = authorize.checkAccountNumber(sourceAccountNumber); if (status) { sourceAmount = authorize.getSourceBalance(sourceAccountNumber); authorize.rejectTransaction("approveddelete", balance + sourceAmount, authRequests); authorize.deleteTransaction(authRequests); model.addObject("success", "The deletion of normal transaction/s is successfully done"); } else { model.addObject("destinationerror", "Destination account does not exist. Please delete the transaction"); } } } } else { model.addObject("select", "Please select atleast one line item to continue"); } } } catch (Exception e) { model.addObject("zeroerror", "Amounts should include numbers only"); } ResultSet rs = authorize.getModDelHandler("pendingapproval", "PAYMENT", 10000); try { while (rs.next()) { TransactionDetails view = new TransactionDetails(); view.setUserName(rs.getString("username")); view.setTransactionId(rs.getString("transactionid")); view.setTransactionAmount(rs.getString("transactionamount")); session.setAttribute("AMOUNT", rs.getString("transactionamount")); view.setNewAmount(rs.getString("newamount")); view.setSourceAccount(rs.getString("sourceaccountnumber")); view.setDestAccount(rs.getString("destinationaccountnumber")); view.setDateandTime(rs.getString("dateandtime")); view.setTransferType(rs.getString("transfertype")); view.setStatus(rs.getString("status")); transDetails.add(view); } model.addObject("transactionApprove", transDetails); } catch (SQLException e) { e.printStackTrace(); } return model; } else { ModelAndView model = new ModelAndView(); model.setViewName("index"); return model; } }