List of usage examples for java.text NumberFormat getPercentInstance
public static final NumberFormat getPercentInstance()
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private CategoryPlot getCategoryPlot(List<cfCHARTSERIESData> series, String xAxisTitle, String yAxisTitle, String labelFormat, boolean bShowMarkers, int markerSize, boolean bShow3D, String tipStyle, String drillDownUrl, int xOffset, int yOffset, int yAxisUnits, String seriesPlacement, boolean bSortXAxis, int height, String[] yAxisSymbols, int gridLines) throws cfmRunTimeException { // Create a category plot CategoryPlot plot = new CategoryPlot(); // Set the domain axis (the x-axis) org.jfree.chart.axis.CategoryAxis categoryAxis; if (bShow3D)//from w ww . j a va 2 s .c o m categoryAxis = new CategoryAxis3D(xAxisTitle); else categoryAxis = new CategoryAxis(xAxisTitle); plot.setDomainAxis(categoryAxis); // Set the range axis (the y-axis) ValueAxis valueAxis; DateFormat dateFormat = null; NumberFormat numberFormat = null; // Ignore a label format of date if the y-axis is using symbols if (labelFormat.equals("date") && (yAxisSymbols == null)) { valueAxis = new DateAxis(yAxisTitle); dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); ((DateAxis) valueAxis).setDateFormatOverride(dateFormat); } else { if (yAxisSymbols != null) { valueAxis = new SymbolAxis(yAxisTitle, yAxisSymbols); ((SymbolAxis) valueAxis).setGridBandsVisible(false); ((SymbolAxis) valueAxis).setAutoRangeStickyZero(true); } else if (bShow3D) { valueAxis = new NumberAxis3D(yAxisTitle); } else { valueAxis = new NumberAxis(yAxisTitle); } if (labelFormat.equals("currency")) { ((NumberAxis) valueAxis).setNumberFormatOverride(NumberFormat.getCurrencyInstance()); numberFormat = NumberFormat.getCurrencyInstance(); } else if (labelFormat.equals("percent")) { numberFormat = NumberFormat.getPercentInstance(); numberFormat.setMaximumFractionDigits(3); // without this change .11443 // would be displayed as 11% // instead of 11.443% ((NumberAxis) valueAxis).setNumberFormatOverride(numberFormat); } else { numberFormat = NumberFormat.getInstance(); } if (yAxisUnits != 0) ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits)); } plot.setRangeAxis(valueAxis); // Add a dataset and renderer for each series int barChartDatasetIndex = -1; int hBarChartDatasetIndex = -1; int num = 0; MinMaxData minMax = new MinMaxData(); for (int i = 0; i < series.size(); i++) { cfCHARTSERIESData seriesData = series.get(i); // If the sortXAxis attribute was set to "yes" then sort the data. // NOTE: this attribute is only used with category charts. if (bSortXAxis) seriesData.sort(); DefaultCategoryDataset dataset; if ((barChartDatasetIndex != -1) && (seriesData.getType().equals("bar"))) { dataset = (DefaultCategoryDataset) plot.getDataset(barChartDatasetIndex); addSeriesDataToDataset(seriesData, dataset, minMax); // Set the paint style for this series setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(barChartDatasetIndex), dataset.getRowCount() - 1, height); // Add the color list for this series to the custom color renderer CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(barChartDatasetIndex); cr.addColors(getColorList(seriesData)); continue; } else if ((hBarChartDatasetIndex != -1) && (seriesData.getType().equals("horizontalbar"))) { dataset = (DefaultCategoryDataset) plot.getDataset(hBarChartDatasetIndex); addSeriesDataToDataset(seriesData, dataset, minMax); // Set the paint style for this series setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(hBarChartDatasetIndex), dataset.getRowCount() - 1, height); // Add the color list for this series to the custom color renderer CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(hBarChartDatasetIndex); cr.addColors(getColorList(seriesData)); continue; } else { dataset = new DefaultCategoryDataset(); addSeriesDataToDataset(seriesData, dataset, minMax); } plot.setDataset(num, dataset); AbstractCategoryItemRenderer renderer = null; if (seriesData.getType().equals("bar")) { plot.setOrientation(PlotOrientation.VERTICAL); renderer = getBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData)); ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setNegativeItemLabelPosition(position2); ((BarRenderer) renderer).setItemMargin(0.0); // The margin between items // in the same category categoryAxis.setCategoryMargin(0.2); // The margin between each category barChartDatasetIndex = num; } else if (seriesData.getType().equals("horizontalbar")) { plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer = getBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData)); if (bShow3D) { // change rendering order to ensure that bar overlapping is the // right way around plot.setRowRenderingOrder(org.jfree.util.SortOrder.DESCENDING); plot.setColumnRenderingOrder(org.jfree.util.SortOrder.DESCENDING); } ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT); renderer.setNegativeItemLabelPosition(position2); ((BarRenderer) renderer).setItemMargin(0.0); // The margin between items // in the same category categoryAxis.setCategoryMargin(0.2); // The margin between each category hBarChartDatasetIndex = num; } else if (seriesData.getType().equals("line")) { if (bShow3D) { renderer = new LineRenderer3D(); ((LineRenderer3D) renderer).setXOffset(xOffset); ((LineRenderer3D) renderer).setYOffset(yOffset); } else { renderer = new LineAndShapeRenderer(true, false); } // Enable/Disable displaying of markers ((LineAndShapeRenderer) renderer).setShapesVisible(bShowMarkers); // Set the shape of the markers based on the markerSize value ((LineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize)); } else if (seriesData.getType().equals("area")) { if (seriesPlacement.equals("stacked")) renderer = new StackedAreaRenderer(); // this doesn't work for some // reason else renderer = new AreaRenderer(); // Truncate the first and last values to match CFMX 7 ((AreaRenderer) renderer).setEndType(AreaRendererEndType.TRUNCATE); categoryAxis.setCategoryMargin(0.0); } else if (seriesData.getType().equals("step")) { renderer = new CategoryStepRenderer(true); } else if (seriesData.getType().equals("scatter")) { renderer = new LineAndShapeRenderer(false, true); // Set the shape of the markers based on the markerSize value ((LineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize)); } if (!tipStyle.equals("none")) { if (dateFormat != null) renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("({0}, {1}) = {2}", dateFormat)); else renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("({0}, {1}) = {2}", numberFormat)); } if (drillDownUrl != null) { if (dateFormat != null) renderer.setBaseItemURLGenerator( new com.newatlanta.bluedragon.CategoryURLGenerator(drillDownUrl, dateFormat)); else renderer.setBaseItemURLGenerator( new com.newatlanta.bluedragon.CategoryURLGenerator(drillDownUrl, numberFormat)); } if (seriesData.getSeriesColor() != null) renderer.setSeriesPaint(0, convertStringToColor(seriesData.getSeriesColor())); String dataLabelStyle = seriesData.getDataLabelStyle(); if (labelFormat.equals("date")) { if (dataLabelStyle.equals("none")) { renderer.setItemLabelsVisible(false); } else { setCategoryItemLabelsData(renderer, seriesData); if (dataLabelStyle.equals("value")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{2}", dateFormat, yAxisSymbols)); else if (dataLabelStyle.equals("rowlabel")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{0}", dateFormat, yAxisSymbols)); else if (dataLabelStyle.equals("columnlabel")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{1}", dateFormat, yAxisSymbols)); else if (dataLabelStyle.equals("pattern")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{1} {2}", dateFormat, yAxisSymbols)); else renderer.setItemLabelGenerator( new CategoryItemLabelGenerator(dataLabelStyle, dateFormat, yAxisSymbols)); } } else { if (dataLabelStyle.equals("none")) { renderer.setItemLabelsVisible(false); } else { setCategoryItemLabelsData(renderer, seriesData); if (dataLabelStyle.equals("value")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{2}", numberFormat, yAxisSymbols)); else if (dataLabelStyle.equals("rowlabel")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{0}", numberFormat, yAxisSymbols)); else if (dataLabelStyle.equals("columnlabel")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{1}", numberFormat, yAxisSymbols)); else if (dataLabelStyle.equals("pattern")) renderer.setItemLabelGenerator( new CategoryItemLabelGenerator("{1} {2} ({3} of {4})", numberFormat, yAxisSymbols)); else renderer.setItemLabelGenerator( new CategoryItemLabelGenerator(dataLabelStyle, numberFormat, yAxisSymbols)); } } // Add the renderer to the plot. // NOTE: this must be done before the setPaintStyle() call so the // DrawingSupplier object // will be set up properly for the generation of default colors. plot.setRenderer(num, renderer); // Set the paint style for this series (series 0) if (seriesData.getType().equals("bar") || seriesData.getType().equals("horizontalbar") || seriesData.getType().equals("area")) setPaintStyle(seriesData.getPaintStyle(), renderer, 0, height); num++; } // If gridLines was specified then we need to calculate the yAxisUnits if ((gridLines != -1) && (valueAxis instanceof NumberAxis)) { // Calculate the yAxisUnits we need to use to create the number of // gridLines yAxisUnits = calculateYAxisUnits(gridLines, minMax); // Set the yAxisUnits ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits)); } return plot; }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private XYPlot getXYPlot(List<cfCHARTSERIESData> series, String xAxisTitle, String yAxisTitle, String labelFormat, boolean bShowMarkers, int markerSize, boolean bShow3D, String tipStyle, String drillDownUrl, int xOffset, int yOffset, int yAxisUnits, String seriesPlacement, int height, int gridLines) throws cfmRunTimeException { // Create an XY plot XYPlot plot = new XYPlot(); ValueAxis domainAxis;/* ww w .j a va 2 s .co m*/ if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_NUMERIC_SERIES) { if (bShow3D) domainAxis = new NumberAxis3D(xAxisTitle); else domainAxis = new NumberAxis(xAxisTitle); } else { domainAxis = new DateAxis(xAxisTitle); } plot.setDomainAxis(domainAxis); ValueAxis valueAxis; DateFormat dateFormat = null; NumberFormat numberFormat = null; if (labelFormat.equals("date")) { valueAxis = new DateAxis(yAxisTitle); dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); ((DateAxis) valueAxis).setDateFormatOverride(dateFormat); } else { if (bShow3D) valueAxis = new NumberAxis3D(yAxisTitle); else valueAxis = new NumberAxis(yAxisTitle); if (labelFormat.equals("currency")) { ((NumberAxis) valueAxis).setNumberFormatOverride(NumberFormat.getCurrencyInstance()); numberFormat = NumberFormat.getCurrencyInstance(); } else if (labelFormat.equals("percent")) { numberFormat = NumberFormat.getPercentInstance(); numberFormat.setMaximumFractionDigits(3); // without this change .11443 // would be displayed as 11% // instead of 11.443% ((NumberAxis) valueAxis).setNumberFormatOverride(numberFormat); } else { numberFormat = NumberFormat.getInstance(); } if (yAxisUnits != 0) ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits)); } plot.setRangeAxis(valueAxis); // Add a dataset and renderer for each series int barChartDatasetIndex = -1; int hBarChartDatasetIndex = -1; int num = 0; MinMaxData minMax = new MinMaxData(); for (int i = 0; i < series.size(); i++) { cfCHARTSERIESData seriesData = series.get(i); XYSeriesCollection dataset; if ((barChartDatasetIndex != -1) && (seriesData.getType().equals("bar"))) { dataset = (XYSeriesCollection) plot.getDataset(barChartDatasetIndex); addSeriesDataToDataset(seriesData, dataset, minMax); // Set the paint style for this series setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(barChartDatasetIndex), dataset.getSeriesCount() - 1, height); // Add the color list for this series to the custom color renderer CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(barChartDatasetIndex); cr.addColors(getColorList(seriesData)); continue; } else if ((hBarChartDatasetIndex != -1) && (seriesData.getType().equals("horizontalbar"))) { dataset = (XYSeriesCollection) plot.getDataset(hBarChartDatasetIndex); addSeriesDataToDataset(seriesData, dataset, minMax); // Set the paint style for this series setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(hBarChartDatasetIndex), dataset.getSeriesCount() - 1, height); // Add the color list for this series to the custom color renderer CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(hBarChartDatasetIndex); cr.addColors(getColorList(seriesData)); continue; } else { dataset = new XYSeriesCollection(); addSeriesDataToDataset(seriesData, dataset, minMax); } plot.setDataset(num, dataset); XYItemRenderer renderer = null; if (seriesData.getType().equals("bar")) { plot.setOrientation(PlotOrientation.VERTICAL); renderer = getXYBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData)); ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setNegativeItemLabelPosition(position2); ((XYBarRenderer) renderer).setMargin(0.2); // The margin between each // category barChartDatasetIndex = num; } else if (seriesData.getType().equals("horizontalbar")) { plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer = getXYBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData)); ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT); renderer.setNegativeItemLabelPosition(position2); ((XYBarRenderer) renderer).setMargin(0.2); // The margin between each // category hBarChartDatasetIndex = num; } else if (seriesData.getType().equals("line")) { renderer = new XYLineAndShapeRenderer(true, false); // Enable/Disable displaying of markers ((XYLineAndShapeRenderer) renderer).setShapesVisible(bShowMarkers); // Set the shape of the markers based on the markerSize value ((XYLineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize)); } else if (seriesData.getType().equals("area")) { renderer = new CustomXYAreaRenderer(); } else if (seriesData.getType().equals("step")) { renderer = new CustomXYStepRenderer(); } else if (seriesData.getType().equals("scatter")) { renderer = new XYLineAndShapeRenderer(false, true); // Set the shape of the markers based on the markerSize value ((XYLineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize)); } if (!tipStyle.equals("none")) { if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_DATE_SERIES) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: {1}", DateFormat.getInstance(), DateFormat.getInstance())); } else { if (dateFormat != null) renderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator("{0}: {2}", dateFormat, dateFormat)); else renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", numberFormat, NumberFormat.getInstance())); } } if (drillDownUrl != null) { if (dateFormat != null) renderer.setURLGenerator( new com.newatlanta.bluedragon.XYURLGenerator(drillDownUrl, dateFormat)); else renderer.setURLGenerator( new com.newatlanta.bluedragon.XYURLGenerator(drillDownUrl, numberFormat)); } if (seriesData.getSeriesColor() != null) renderer.setSeriesPaint(0, convertStringToColor(seriesData.getSeriesColor())); String dataLabelStyle = seriesData.getDataLabelStyle(); if (labelFormat.equals("date")) { if (dataLabelStyle.equals("none")) { renderer.setItemLabelsVisible(false); } else { setXYItemLabelsData(renderer, seriesData); if (dataLabelStyle.equals("value")) renderer.setItemLabelGenerator( new StandardXYItemLabelGenerator("{2}", dateFormat, dateFormat)); else if (dataLabelStyle.equals("rowlabel")) renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{0}", NumberFormat.getInstance(), NumberFormat.getInstance())); else if (dataLabelStyle.equals("columnlabel")) renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{1}", NumberFormat.getInstance(), NumberFormat.getInstance())); else if (dataLabelStyle.equals("pattern")) renderer.setItemLabelGenerator(new XYItemLabelGenerator("{2}", dateFormat, dateFormat)); else renderer.setItemLabelGenerator( new XYItemLabelGenerator(dataLabelStyle, dateFormat, dateFormat)); } } else { if (dataLabelStyle.equals("none")) { renderer.setItemLabelsVisible(false); } else { setXYItemLabelsData(renderer, seriesData); if (dataLabelStyle.equals("value")) { renderer.setItemLabelGenerator( new StandardXYItemLabelGenerator("{2}", numberFormat, numberFormat)); } else if (dataLabelStyle.equals("rowlabel")) { renderer.setItemLabelGenerator( new StandardXYItemLabelGenerator("{0}", numberFormat, numberFormat)); } else if (dataLabelStyle.equals("columnlabel")) { if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_DATE_SERIES) { renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{1}", SimpleDateFormat.getInstance(), NumberFormat.getInstance())); } else { renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{1}", NumberFormat.getInstance(), NumberFormat.getInstance())); } } else if (dataLabelStyle.equals("pattern")) { if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_DATE_SERIES) { renderer.setItemLabelGenerator(new XYItemLabelGenerator("{1} {2} ({3} of {4})", SimpleDateFormat.getInstance(), numberFormat)); } else { renderer.setItemLabelGenerator(new XYItemLabelGenerator("{1} {2} ({3} of {4})", NumberFormat.getInstance(), numberFormat)); } } else { renderer.setItemLabelGenerator( new XYItemLabelGenerator(dataLabelStyle, NumberFormat.getInstance(), numberFormat)); } } } // Add the renderer to the plot. // NOTE: this must be done before the setPaintStyle() call so the // DrawingSupplier object // will be set up properly for the generation of default colors. plot.setRenderer(num, renderer); // Set the paint style for this series (series 0) if (seriesData.getType().equals("bar") || seriesData.getType().equals("horizontalbar") || seriesData.getType().equals("area")) setPaintStyle(seriesData.getPaintStyle(), renderer, 0, height); num++; } // If gridLines was specified then we need to calculate the yAxisUnits if ((gridLines != -1) && (valueAxis instanceof NumberAxis)) { // Calculate the yAxisUnits we need to use to create the number of // gridLines yAxisUnits = calculateYAxisUnits(gridLines, minMax); // Set the yAxisUnits ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits)); } return plot; }
From source file:com.att.pirates.controller.ProjectController.java
private static List<ProjectAppOwnerModel> getProjectAppOwners(String prismId) { List<ProjectAppOwnerModel> rc = new ArrayList<ProjectAppOwnerModel>(); // TODO: port over to hibernate later // logger.error(msgHeader + "getProjectAppOwners called with prismId: "+ prismId); ResultSet rs = null;//from ww w .j ava 2 s. c om Connection conn = null; PreparedStatement preparedStatement = null; try { conn = DBUtility.getDBConnection(); // SQL query command String SQL = " SELECT " + " apa.UUID " + " ,apa.DueDate " + " ,apa.CompletionDate " + " ,apa.PercentageComplete " + " ,apa.ArtifactName " + " ,apa.PRISMId " + " ,apa.ApplicationName " + " ,apa.ModuleId " + " ,apa.IsPrimaryOwner " + " ,apa.MileStoneId " + " ,apa.ExecutionPercentage " + " ,apa.ProjectCloseOutPercentage " + " ,isnull(apa.DateCreated,'') as DateCreated " + " ,apa.UpdatedByUUID " + " ,apa.SystemNote " + " ,app.ApplicationId " + " FROM AppProjectArtifactOwners apa join Applications app " + " On app.ApplicationName = apa.ApplicationName " + " Where apa.PRISMId = ? and apa.isPrimaryOwner = 1 " + " Order by apa.ApplicationName, apa.ArtifactName, apa.UUID "; preparedStatement = conn.prepareStatement(SQL); preparedStatement.setString(1, prismId); rs = preparedStatement.executeQuery(); int rowCount = 0; while (rs.next()) { rowCount++; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat yFormat = new SimpleDateFormat("MM/dd/yyyy"); // for percentage NumberFormat defaultFormat = NumberFormat.getPercentInstance(); defaultFormat.setMinimumFractionDigits(0); // String uuid = rs.getString("UUID"); // String theDueDate = rs.getString("DueDate"); String dueDate = yFormat.format(format.parse(theDueDate)); // String theCompDate = rs.getString("CompletionDate") == null ? "1900-01-01 14:58:00.00" : rs.getString("CompletionDate"); String completionDate = yFormat.format(format.parse(theCompDate)); // String pCompletedDtr = rs.getString("PercentageComplete") == null ? "0.00" : rs.getString("PercentageComplete"); double percentComplete = Double.parseDouble( rs.getString("PercentageComplete") == null ? "0" : rs.getString("PercentageComplete")); String PercentCompleted = defaultFormat.format(percentComplete); // String artifactName = rs.getString("ArtifactName"); // String applicationName = rs.getString("ApplicationName"); // String moduleId = rs.getString("ModuleId"); // String isPrimary = rs.getString("IsPrimaryOwner"); // String mileStoneId = rs.getString("MileStoneId"); // double ExecPercent = Double.parseDouble( rs.getString("ExecutionPercentage") == null ? "0" : rs.getString("ExecutionPercentage")); String ExecutionPercentage = defaultFormat.format(ExecPercent); // double prjCOPercent = Double.parseDouble(rs.getString("ProjectCloseOutPercentage") == null ? "0" : rs.getString("ProjectCloseOutPercentage")); String PrjCloseOutPercentage = defaultFormat.format(prjCOPercent); // String dCreated = rs.getString("DateCreated"); String dateCreated = yFormat.format(format.parse(dCreated)); // String updatedByUUID = rs.getString("UpdatedByUUID"); // String systemNote = rs.getString("SystemNote"); // String applicationId = rs.getString("ApplicationId"); // create a projectDetailPersonnel and add it to list ProjectAppOwnerModel p = new ProjectAppOwnerModel(); p.setUUID(uuid); p.setDueDate(dueDate); p.setCompletionDate(completionDate); p.setPercentageComplete(PercentCompleted); p.setPercentageCompleteStr(pCompletedDtr); p.setArtifactName(artifactName); p.setPrismId(prismId); p.setApplicationName(applicationName); p.setModuleId(moduleId); p.setIsPrimaryOwner(isPrimary.equalsIgnoreCase("1")); p.setMileStoneId(mileStoneId); p.setExecutionPercentage(ExecutionPercentage); p.setProjectCloseOutPercentage(PrjCloseOutPercentage); p.setDateCreated(dateCreated); p.setUpdatedByUUID(updatedByUUID); p.setSystemNote(systemNote); p.setApplicationId(applicationId); rc.add(p); } logger.error(msgHeader + "getProjectAppOwners called, got results: " + rowCount); } catch (SQLException e) { logger.error(e.getMessage()); } catch (Exception e) { logger.error(e.getMessage()); } finally { try { if (rs != null) rs.close(); } catch (Exception e) { } ; try { if (preparedStatement != null) preparedStatement.close(); } catch (Exception e) { } ; try { if (conn != null) conn.close(); } catch (Exception e) { } ; } return rc; }
From source file:com.att.pirates.controller.ProjectController.java
private static void getAppProjectArtifactHistory() { // TODO: port over to hibernate later artifactHistory = new ArrayList<AppProjectArtifactOwnersHistory>(); // logger.error(msgHeader + "getAppProjectArtifactHistory called. "); ResultSet rs = null;/*from w ww . j a v a 2 s . c o m*/ Connection conn = null; PreparedStatement preparedStatement = null; try { conn = DBUtility.getDBConnection(); // SQL query command String SQL = " Select UUID " + " ,DueDate " + " ,CompletionDate " + " ,PercentageComplete " + " ,ArtifactName " + " ,PRISMId " + " ,ApplicationName " + " ,ModuleId " + " ,IsPrimaryOwner " + " ,MileStoneId " + " ,ExecutionPercentage " + " ,ProjectCloseOutPercentage " + " ,DateLogged " + " ,DateCreated " + " ,SystemNote " + " ,UpdatedByUUID " + " from dbo.AppProjectArtifactOwnersHistory " + " order by PRISMId, ApplicationName, ArtifactName, DateLogged desc "; preparedStatement = conn.prepareStatement(SQL); rs = preparedStatement.executeQuery(); int rowCount = 0; while (rs.next()) { rowCount++; SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat yFormat = new SimpleDateFormat("MM/dd/yyyy"); // for percentage NumberFormat defaultFormat = NumberFormat.getPercentInstance(); defaultFormat.setMinimumFractionDigits(0); // String uuid = rs.getString("UUID"); // String theDueDate = rs.getString("DueDate"); String dueDate = yFormat.format(format.parse(theDueDate)); // String theCompDate = rs.getString("CompletionDate") == null ? "1900-01-01 14:58:00.00" : rs.getString("CompletionDate"); String completionDate = yFormat.format(format.parse(theCompDate)); // double percentComplete = Double.parseDouble( rs.getString("PercentageComplete") == null ? "0" : rs.getString("PercentageComplete")); String PercentCompleted = defaultFormat.format(percentComplete); // String artifactName = rs.getString("ArtifactName"); // String applicationName = rs.getString("ApplicationName"); // String moduleId = rs.getString("ModuleId"); // String isPrimary = rs.getString("IsPrimaryOwner"); // String mileStoneId = rs.getString("MileStoneId"); // double ExecPercent = Double.parseDouble( rs.getString("ExecutionPercentage") == null ? "0" : rs.getString("ExecutionPercentage")); String ExecutionPercentage = defaultFormat.format(ExecPercent); // double prjCOPercent = Double.parseDouble(rs.getString("ProjectCloseOutPercentage") == null ? "0" : rs.getString("ProjectCloseOutPercentage")); String PrjCloseOutPercentage = defaultFormat.format(prjCOPercent); // String logCreated = rs.getString("DateLogged"); String dateLogged = yFormat.format(format.parse(logCreated)); // String dCreated = rs.getString("DateCreated") == null ? rs.getString("DateLogged") : rs.getString("DateCreated"); String dateCreated = yFormat.format(format.parse(dCreated)); // String updatedByUUID = rs.getString("UpdatedByUUID"); // String systemNote = rs.getString("SystemNote"); // String prismID = rs.getString("PRISMId"); AppProjectArtifactOwnersHistory p = new AppProjectArtifactOwnersHistory(); p.setUUID(uuid); p.setDueDate(dueDate); p.setCompletionDate(completionDate); p.setPercentageComplete(PercentCompleted); p.setArtifactName(artifactName); p.setPRISMId(prismID); // PRISMId p.setApplicationName(applicationName); p.setModuleId(moduleId); p.setIsPrimaryOwner(isPrimary.equalsIgnoreCase("1")); p.setMileStoneId(mileStoneId); p.setExecutionPercentage(ExecutionPercentage); p.setProjectCloseOutPercentage(PrjCloseOutPercentage); p.setDateCreated(dateCreated); p.setUpdatedByUUID(updatedByUUID); p.setSystemNote(systemNote); p.setDateLogged(dateLogged); artifactHistory.add(p); } // logger.error(msgHeader + "getStatusHistoryListByApplicationOwner called, got results: "+rowCount); } catch (SQLException e) { logger.error(e.getMessage()); } catch (Exception e) { logger.error(e.getMessage()); } finally { try { if (rs != null) rs.close(); } catch (Exception e) { } ; try { if (preparedStatement != null) preparedStatement.close(); } catch (Exception e) { } ; try { if (conn != null) conn.close(); } catch (Exception e) { } ; } }