List of usage examples for java.text NumberFormat getInstance
public static final NumberFormat getInstance()
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected void setAxisTickLabels(Axis axis, JRFont tickLabelFont, Paint tickLabelColor, String tickLabelMask, Integer baseFontSize) {/*from w w w . jav a 2 s.c o m*/ Boolean defaultAxisTickLabelsVisible = (Boolean) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABELS_VISIBLE); if (defaultAxisTickLabelsVisible != null && defaultAxisTickLabelsVisible.booleanValue()) { Font themeTickLabelFont = getFont( (JRFont) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_FONT), tickLabelFont, baseFontSize); axis.setTickLabelFont(themeTickLabelFont); RectangleInsets defaultTickLabelInsets = (RectangleInsets) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_INSETS); if (defaultTickLabelInsets != null) { axis.setTickLabelInsets(defaultTickLabelInsets); } Paint tickLabelPaint = tickLabelColor != null ? tickLabelColor : (Paint) getDefaultValue(defaultAxisPropertiesMap, ChartThemesConstants.AXIS_TICK_LABEL_PAINT); if (tickLabelPaint != null) { axis.setTickLabelPaint(tickLabelPaint); } TimeZone timeZone = getChartContext().getTimeZone(); if (axis instanceof DateAxis && timeZone != null) { // used when no mask is set ((DateAxis) axis).setTimeZone(timeZone); } if (tickLabelMask != null) { if (axis instanceof NumberAxis) { NumberFormat fmt = NumberFormat.getInstance(); if (fmt instanceof DecimalFormat) ((DecimalFormat) fmt).applyPattern(tickLabelMask); ((NumberAxis) axis).setNumberFormatOverride(fmt); } else if (axis instanceof DateAxis) { DateFormat fmt; if (tickLabelMask.equals("SHORT") || tickLabelMask.equals("DateFormat.SHORT")) fmt = DateFormat.getDateInstance(DateFormat.SHORT); else if (tickLabelMask.equals("MEDIUM") || tickLabelMask.equals("DateFormat.MEDIUM")) fmt = DateFormat.getDateInstance(DateFormat.MEDIUM); else if (tickLabelMask.equals("LONG") || tickLabelMask.equals("DateFormat.LONG")) fmt = DateFormat.getDateInstance(DateFormat.LONG); else if (tickLabelMask.equals("FULL") || tickLabelMask.equals("DateFormat.FULL")) fmt = DateFormat.getDateInstance(DateFormat.FULL); else fmt = new SimpleDateFormat(tickLabelMask); // FIXME fmt cannot be null if (fmt != null) { if (timeZone != null) { fmt.setTimeZone(timeZone); } ((DateAxis) axis).setDateFormatOverride(fmt); } else ((DateAxis) axis).setDateFormatOverride( DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)); } // ignore mask for other axis types. } } }
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;// www . jav a 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.kcs.service.impl.GenerateXmlServiceImpl.java
public byte[] generateXmlFxp(String dataSetDate, String tmpTcb) throws Exception { try {//from ww w . j ava 2 s . c om List<DatasetFxpBal> mainList = fxpDao.findMainList(dataSetDate, tmpTcb); if (CollectionUtil.isEmpty(mainList)) { logger.error("not found fxp main list"); return new byte[0]; } DatasetFxpBal o = mainList.get(0); DFFXP dffxp = fxpOf.createDFFXP(); HeadGenXMLControl head = headDao.getHeadGenXMLControlByDatasetCode("DF_FXP"); if (head != null) { dffxp.setName(head.getAttributesName()); dffxp.setType(head.getAttributesType()); dffxp.setSchemaVersion(head.getAttributesSchemaVersion()); } com.kcs.genxml.beans.fxp.DataSetCommonHeader dataSetCommonHeader = fxpOf.createDataSetCommonHeader(); dataSetCommonHeader.setDataSetDate(getXMLGregorianCalendarDate(o.getDataSetDate())); dataSetCommonHeader.setOrganizationId(o.getOrgId()); DFFXP.DFFXPHeader dFFXPHeader = fxpOf.createDFFXPDFFXPHeader(); DFFXP.DFFXPContent content = fxpOf.createDFFXPDFFXPContent(); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); for (DatasetFxpBal main : mainList) { nullToEmptyString(main); DFFXP.DFFXPContent.ContentRecordGroup contentRecordGroup = fxpOf .createDFFXPDFFXPContentContentRecordGroup(); contentRecordGroup.setBeginningBalance(nf.format(main.getBeginningBalance())); contentRecordGroup.setNewBuyContractAmount(nf.format(main.getNewBuyContractAmt())); contentRecordGroup.setNewSellContractAmount(nf.format(main.getNewSellContractAmt())); contentRecordGroup.setNetChangeInContractAmount(nf.format(main.getNetChgInContractAmt())); contentRecordGroup.setErrorTransaction(nf.format(main.getErrorTransaction())); contentRecordGroup.setOtherTransaction(nf.format(main.getOtherTransaction())); contentRecordGroup.setOptionNotionalAmount(nf.format(main.getOptionNotionalAmt())); contentRecordGroup.setOptionDeltaAmount(nf.format(main.getOptionDeltaAmt())); contentRecordGroup.setCashPositionAmount(nf.format(main.getCashPositionAmt())); content.getContentRecordGroup().add(contentRecordGroup); } dffxp.setCommonHeader(dataSetCommonHeader); dffxp.setDFFXPHeader(dFFXPHeader); dffxp.setDFFXPContent(content); return generateToBytes(dffxp); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:com.kcs.service.impl.GenerateXmlServiceImpl.java
@Override public byte[] generateXmlFxu(String dataSetDate, String tmpTcb) throws Exception { try {//from ww w . jav a 2 s. c o m List<DfFxu> mainList = fxuDao.findMainList(dataSetDate, tmpTcb); if (CollectionUtil.isEmpty(mainList)) { logger.error("not found fxp main list"); return new byte[0]; } DfFxu o = mainList.get(0); DFFXU dffxu = fxuOf.createDFFXU(); HeadGenXMLControl head = headDao.getHeadGenXMLControlByDatasetCode("DF_FXU"); if (head != null) { dffxu.setName(head.getAttributesName()); dffxu.setType(head.getAttributesType()); dffxu.setSchemaVersion(head.getAttributesSchemaVersion()); } com.kcs.genxml.beans.fxu.DataSetCommonHeader dataSetCommonHeader = fxuOf.createDataSetCommonHeader(); dataSetCommonHeader.setDataSetDate(getXMLGregorianCalendarDate(o.getDataSetDate())); dataSetCommonHeader.setOrganizationId(o.getOrgId()); DFFXU.DFFXUHeader dFFXUHeader = fxuOf.createDFFXUDFFXUHeader(); DFFXU.DFFXUContent content = fxuOf.createDFFXUDFFXUContent(); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); for (DfFxu main : mainList) { nullToEmptyString(main); DFFXU.DFFXUContent.ContentRecordGroup contentRecordGroup = fxuOf .createDFFXUDFFXUContentContentRecordGroup(); contentRecordGroup.setArrangementType(main.getArrgmtType()); contentRecordGroup.setLegType(main.getLegType()); contentRecordGroup.setUsdEquivalentAmount(nf.format(main.getUsdEquivlntAmt())); content.getContentRecordGroup().add(contentRecordGroup); } dffxu.setCommonHeader(dataSetCommonHeader); dffxu.setDFFXUHeader(dFFXUHeader); dffxu.setDFFXUContent(content); return generateToBytes(dffxu); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:com.kcs.service.impl.GenerateXmlServiceImpl.java
public byte[] generateXmlFxm(String dataSetDate, String tmpTcb) throws Exception { try {/* ww w . j a v a2 s. c o m*/ List<DfFxm> mainList = fxmDao.findMainList(dataSetDate, tmpTcb); if (CollectionUtil.isEmpty(mainList)) { logger.error("not found fxm main list"); return new byte[0]; } List<DfFxm> childList = fxmDao.findChildList(dataSetDate); DfFxm o = mainList.get(0); DFFXM dffxm = fxmOf.createDFFXM(); HeadGenXMLControl head = headDao.getHeadGenXMLControlByDatasetCode("DF_FXU"); if (head != null) { dffxm.setName(head.getAttributesName()); dffxm.setType(head.getAttributesType()); dffxm.setSchemaVersion(head.getAttributesSchemaVersion()); } com.kcs.genxml.beans.fxm.DataSetCommonHeader dataSetCommonHeader = fxmOf.createDataSetCommonHeader(); dataSetCommonHeader.setDataSetDate(getXMLGregorianCalendarDate(o.getDataSetDate())); dataSetCommonHeader.setOrganizationId(o.getOrgId()); DFFXM.DFFXMHeader dFFXMHeader = fxmOf.createDFFXMDFFXMHeader(); DFFXM.DFFXMContent content = fxmOf.createDFFXMDFFXMContent(); NumberFormat nf1 = NumberFormat.getInstance(); nf1.setMinimumFractionDigits(2); NumberFormat excRateNf = NumberFormat.getInstance(); excRateNf.setMinimumFractionDigits(7); for (DfFxm main : mainList) { nullToEmptyString(main); DFFXM.DFFXMContent.ContentRecordGroup contentRecordGroup = fxmOf .createDFFXMDFFXMContentContentRecordGroup(); contentRecordGroup.setTradeDate(getXmlDateFormatString(main.getTradeDate())); contentRecordGroup.setCounterPartyName(main.getCounterPtyName()); contentRecordGroup.setCounterPartyId(main.getCounterPtyId()); contentRecordGroup.setCounterPartyUniqueIdType(main.getCounterPtyUniqIdType()); contentRecordGroup.setCounterPartyType(main.getCounterPtyType()); contentRecordGroup.setFiArrangementNumber(main.getFiArrgmtNumber()); contentRecordGroup.setArrangementType(main.getArrgmtType()); contentRecordGroup.setLegType(main.getLegType()); contentRecordGroup.setCurrencyCode(com.kcs.genxml.beans.fxm.MV0072.fromValue(main.getCurrCode())); contentRecordGroup.setStartDate(getXMLGregorianCalendarDate(main.getStartDate())); contentRecordGroup.setMaturityDate(getXMLGregorianCalendarDate(main.getMaturityDate())); logger.debug("excRate1 : " + main.getExcRate1()); logger.debug("excRate2 : " + main.getExcRate2()); String tmpExcRate1 = ((BigDecimal.ZERO.equals(main.getExcRate1()) || main.getExcRate1() == null) ? "" : excRateNf.format(main.getExcRate1())); String tmpExcRate2 = ((BigDecimal.ZERO.equals(main.getExcRate2()) || main.getExcRate2() == null) ? "" : excRateNf.format(main.getExcRate2())); contentRecordGroup.setExchangeRate1(tmpExcRate1); contentRecordGroup.setExchangeRate2(tmpExcRate2); contentRecordGroup.setUsdEquivalentAmount(nf1.format(main.getUsdEquivlntAmt())); contentRecordGroup .setOptionDeltaUsdEquivalentAmount(getXmlString(main.getOptDeltaUsdEquivlntAmt())); contentRecordGroup.setTransactionPurposeCode(main.getTransPurposeCode()); contentRecordGroup.setPurposeRemarks(main.getPurposeRemarks()); DFFXM.DFFXMContent.ContentRecordGroup.RelatedFiGroupInfo relatedFiGroupInfo = fxmOf .createDFFXMDFFXMContentContentRecordGroupRelatedFiGroupInfo(); List<DfFxm> subChildList = filterRelateFiGroupInfoChild(main, childList); for (DfFxm child : subChildList) { DFFXM.DFFXMContent.ContentRecordGroup.RelatedFiGroupInfo.RelatedFiGroupDetails detail = fxmOf .createDFFXMDFFXMContentContentRecordGroupRelatedFiGroupInfoRelatedFiGroupDetails(); detail.setRelatedFiArrangementNumber(child.getRelatedFiArrgmNumber()); relatedFiGroupInfo.getRelatedFiGroupDetails().add(detail); } contentRecordGroup.setRelatedFiGroupInfo(relatedFiGroupInfo); contentRecordGroup.setArrangementRemarks(main.getArrgmtRemarks()); content.getContentRecordGroup().add(contentRecordGroup); } dffxm.setCommonHeader(dataSetCommonHeader); dffxm.setDFFXMHeader(dFFXMHeader); dffxm.setDFFXMContent(content); return generateToBytes(dffxm); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:com.kcs.service.impl.GenerateXmlServiceImpl.java
@Override public byte[] generateXmlOlb(String dataSetDate, String tmpTcb) throws Exception { try {/*from ww w . ja v a2s. co m*/ List<DfOlb> mainList = olbDao.findMainList(dataSetDate, tmpTcb); if (CollectionUtil.isEmpty(mainList)) { logger.error("not found olb main list"); return new byte[0]; } List<DfOlb> childList = olbDao.findChildList(dataSetDate, tmpTcb); DfOlb o = mainList.get(0); DSOLB dsolb = olbOf.createDSOLB(); HeadGenXMLControl head = headDao.getHeadGenXMLControlByDatasetCode("DS_OLB"); if (head != null) { dsolb.setName(head.getAttributesName()); dsolb.setType(head.getAttributesType()); dsolb.setSchemaVersion(head.getAttributesSchemaVersion()); } com.kcs.genxml.beans.olb.DataSetCommonHeader dataSetCommonHeader = olbOf.createDataSetCommonHeader(); dataSetCommonHeader.setDataSetDate(getXMLGregorianCalendarDate(o.getDataSetDate())); dataSetCommonHeader.setOrganizationId(o.getOrgId()); DSOLB.DSOLBHeader dSOLBHeader = olbOf.createDSOLBDSOLBHeader(); DSOLB.DSOLBContent content = olbOf.createDSOLBDSOLBContent(); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); for (DfOlb main : mainList) { nullToEmptyString(main); DSOLB.DSOLBContent.ContentRecordGroup contentRecordGroup = olbOf .createDSOLBDSOLBContentContentRecordGroup(); contentRecordGroup.setFiArrangementNumber(main.getFiArrgNo()); contentRecordGroup .setArrangementContractDate(getXMLGregorianCalendarDate(main.getArrgContractDate())); contentRecordGroup.setEffectiveDate(getXMLGregorianCalendarDate(main.getEffectiveDate())); contentRecordGroup.setMaturityDate(getXMLGregorianCalendarDate(main.getMaturityDate())); contentRecordGroup.setPrimaryInvolvedPartyId(main.getPrimaryInvPartyId()); contentRecordGroup.setPrimaryInvolvedPartyUniqueIdType(main.getPrimaryInvPartyUniqIdType()); contentRecordGroup.setPrimaryInvolvedPartyName(main.getPrimaryInvPartyName()); contentRecordGroup.setPrimaryInvolvedPartyType(main.getPrimaryInvPartyType()); contentRecordGroup .setCountryOfNonresident(com.kcs.genxml.beans.olb.MV0260.fromValue(main.getCountryOfNr())); contentRecordGroup.setArrangementType(main.getArrgType()); DSOLB.DSOLBContent.ContentRecordGroup.RelatedFiGroupInfo relatedFiGroupInfo = olbOf .createDSOLBDSOLBContentContentRecordGroupRelatedFiGroupInfo(); List<DfOlb> subChildList = filterRelateFiGroupInfoOlbChild(main, childList); for (DfOlb subChild : subChildList) { DSOLB.DSOLBContent.ContentRecordGroup.RelatedFiGroupInfo.RelatedFiGroupDetails detail = olbOf .createDSOLBDSOLBContentContentRecordGroupRelatedFiGroupInfoRelatedFiGroupDetails(); detail.setRelatedFiArrangementNumber(subChild.getRelatedFiArrgNo()); relatedFiGroupInfo.getRelatedFiGroupDetails().add(detail); } contentRecordGroup.setRelatedFiGroupInfo(relatedFiGroupInfo); contentRecordGroup.setCustomerInvestmentType(main.getCustInvestmentType()); contentRecordGroup.setInvestmentDescription(main.getInvestmentDesc()); contentRecordGroup.setFxArrangementType(main.getFxArrgType()); contentRecordGroup.setFxArrangementDescription(main.getFxArrgDesc()); contentRecordGroup.setIndexInvolvementType(main.getIndexInvolType()); contentRecordGroup.setLegType(main.getLegType()); contentRecordGroup.setPaymentInterestRateType(main.getPaymentIntRateType()); contentRecordGroup.setReceivedInterestRateType(main.getReceivedIntRateType()); contentRecordGroup.setCurrencyId(com.kcs.genxml.beans.olb.MV0272.fromValue(main.getCurrId())); contentRecordGroup.setThbOutstandingAmount( (main.getThbOutsAmt() == null ? "0.00" : nf.format(main.getThbOutsAmt()))); contentRecordGroup.setInvestorType(main.getInvestorType()); contentRecordGroup.setUnderlyingCurrencyId(main.getUndlyingCurrId()); contentRecordGroup.setUnderlyingPurposeType(main.getUndlyingPurposeType()); contentRecordGroup.setUnderlyingCustomerInvestmentType(main.getUndlyingCustInvestmentType()); contentRecordGroup.setUnderlyingPurposeDescription(main.getUndlyingPurposeDesc()); contentRecordGroup.setUnderlyingLocalCompanyName(main.getUndlyingLocalCompName()); contentRecordGroup.setNameOfNrBeneficiary(main.getNameOfNrBeneficiary()); content.getContentRecordGroup().add(contentRecordGroup); } dsolb.setCommonHeader(dataSetCommonHeader); dsolb.setDSOLBHeader(dSOLBHeader); dsolb.setDSOLBContent(content); return generateToBytes(dsolb); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:com.kcs.service.impl.GenerateXmlServiceImpl.java
@Override public byte[] generateXmlSlb(String dataSetDate, String tmpTcb) throws Exception { List<DfSlb> mainList = slbDao.findMainList(dataSetDate, tmpTcb); if (CollectionUtil.isEmpty(mainList)) { logger.error("not found slb main list"); return new byte[0]; }/*w ww .j a v a 2s . co m*/ DfSlb o = mainList.get(0); DSSLB dsslb = slbOf.createDSSLB(); HeadGenXMLControl head = headDao.getHeadGenXMLControlByDatasetCode("DS_SLB"); if (head != null) { dsslb.setName(head.getAttributesName()); dsslb.setType(head.getAttributesType()); dsslb.setSchemaVersion(head.getAttributesSchemaVersion()); } com.kcs.genxml.beans.slb.DataSetCommonHeader dataSetCommonHeader = slbOf.createDataSetCommonHeader(); dataSetCommonHeader.setDataSetDate(getXMLGregorianCalendarDate(o.getDataSetDate())); dataSetCommonHeader.setOrganizationId(o.getOrgId()); DSSLB.DSSLBHeader dSSLBHeader = slbOf.createDSSLBDSSLBHeader(); DSSLB.DSSLBContent content = slbOf.createDSSLBDSSLBContent(); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(2); for (DfSlb main : mainList) { nullToEmptyString(main); DSSLB.DSSLBContent.ContentRecordGroup contentRecordGroup = slbOf .createDSSLBDSSLBContentContentRecordGroup(); contentRecordGroup.setArrangementType(main.getArrgType()); contentRecordGroup.setFxArrangementType(main.getFxArrgType()); contentRecordGroup.setNumberOfTransaction(getXmlString(main.getNumberOfTransaction())); contentRecordGroup.setThbOutstandingAmount(nf.format(main.getThbOutstandingAmt())); content.getContentRecordGroup().add(contentRecordGroup); } dsslb.setCommonHeader(dataSetCommonHeader); dsslb.setDSSLBHeader(dSSLBHeader); dsslb.setDSSLBContent(content); return generateToBytes(dsslb); }
From source file:com.kcs.service.impl.GenerateXmlServiceImpl.java
public byte[] generateXmlFcr(String dataSetDate, String tmpTcb) throws Exception { try {/*from w w w. j av a 2 s.c om*/ List<DfFcr> mainList = fcrDao.findMainRoundNumberList(dataSetDate, tmpTcb); if (CollectionUtil.isEmpty(mainList)) { logger.error("not found slb main list"); return new byte[0]; } DfFcr o = mainList.get(0); DSFCR dsfcr = fcrOf.createDSFCR(); HeadGenXMLControl head = headDao.getHeadGenXMLControlByDatasetCode("DS_FCR"); if (head != null) { dsfcr.setName(head.getAttributesName()); dsfcr.setType(head.getAttributesType()); dsfcr.setSchemaVersion(head.getAttributesSchemaVersion()); } com.kcs.genxml.beans.fcr.DataSetCommonHeader dataSetCommonHeader = fcrOf.createDataSetCommonHeader(); dataSetCommonHeader.setDataSetDate(getXMLGregorianCalendarDate(o.getDataSetDate())); dataSetCommonHeader.setOrganizationId(o.getOrgId()); DSFCR.DSFCRHeader dSFCRHeader = fcrOf.createDSFCRDSFCRHeader(); DSFCR.DSFCRContent dSFCRContent = fcrOf.createDSFCRDSFCRContent(); NumberFormat nf = NumberFormat.getInstance(); String currencyArr[] = { "AUD", "BND", "CAD", "CHF", "CNY", "DKK", "EUR", "GBP", "HKD", "IDR", "INR", "JPY", "MYR", "NOK", "NZD", "PHP", "PKR", "SEK", "SGD", "USD" }; nf.setMinimumFractionDigits(7); for (DfFcr main : mainList) { List<DfFcr> childList = fcrDao.findChildList(main.getDataSetDate(), main.getRoundNumber(), tmpTcb); DSFCR.DSFCRContent.ContentRecordGroup contentRecordGroup = fcrOf .createDSFCRDSFCRContentContentRecordGroup(); contentRecordGroup.setRoundNumber(getXmlLongString(main.getRoundNumber())); for (String curr : currencyArr) { DfFcr child = getChildByCurrencyId(curr, childList); String createMethodName = "createDSFCRDSFCRContentContentRecordGroupCurrencyID" + curr; Method createMethod = fcrOf.getClass().getMethod(createMethodName); Object obj = createMethod.invoke(fcrOf); Method setSellingRate = obj.getClass().getMethod("setSellingRate", String.class); Method setSightBillRate = obj.getClass().getMethod("setSightBillRate", String.class); Method setTtRate = obj.getClass().getMethod("setTtRate", String.class); setSellingRate.invoke(obj, nf.format(child.getSellingRate())); setSightBillRate.invoke(obj, nf.format(child.getSightBillRate())); setTtRate.invoke(obj, nf.format(child.getTtRate())); String setCurrencyMethodName = "setCurrencyID" + curr; Method setCurrencyMethod = contentRecordGroup.getClass().getMethod(setCurrencyMethodName, obj.getClass()); setCurrencyMethod.invoke(contentRecordGroup, obj); } dSFCRContent.getContentRecordGroup().add(contentRecordGroup); } dsfcr.setCommonHeader(dataSetCommonHeader); dsfcr.setDSFCRHeader(dSFCRHeader); dsfcr.setDSFCRContent(dSFCRContent); return generateToBytes(dsfcr); } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:com.ah.be.admin.adminOperateImpl.BeOperateHMCentOSImpl.java
private static BeFileInfo getFileInfo(File fInput) { if (null == fInput) { return null; }/*from w w w . j a v a 2 s . co m*/ SimpleDateFormat stmp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String strFileTime = stmp.format(new Date(fInput.lastModified())); double dFileSize = fInput.length(); NumberFormat nbf = NumberFormat.getInstance(); nbf.setMaximumFractionDigits(2); nbf.setMaximumFractionDigits(2); String strFileSize = nbf.format(dFileSize / 1024); BeFileInfo oFileInfo = new BeFileInfo(); oFileInfo.setFileName(fInput.getName()); oFileInfo.setFileSize(strFileSize); oFileInfo.setCreateTime(strFileTime); return oFileInfo; }
From source file:com.kcs.service.impl.GenerateXmlServiceImpl.java
public byte[] generateXmlIia(String dataSetDate, String tmpTcb) throws Exception { try {/*ww w . j a v a 2 s . c o m*/ List<DfIia> mainList = iiaDao.findMainList(dataSetDate, tmpTcb); if (CollectionUtil.isEmpty(mainList)) { logger.error("not found slb main list"); return new byte[0]; } DfIia o = mainList.get(0); DSIIA dsiia = iiaOf.createDSIIA(); HeadGenXMLControl head = headDao.getHeadGenXMLControlByDatasetCode("DS_IIA"); if (head != null) { dsiia.setName(head.getAttributesName()); dsiia.setType(head.getAttributesType()); dsiia.setSchemaVersion(head.getAttributesSchemaVersion()); } com.kcs.genxml.beans.iia.DataSetCommonHeader dataSetCommonHeader = iiaOf.createDataSetCommonHeader(); dataSetCommonHeader.setDataSetDate(getXMLGregorianCalendarDate(o.getDataSetDate())); dataSetCommonHeader.setOrganizationId(o.getOrgId()); DSIIA.DSIIAHeader dSIIAHeader = iiaOf.createDSIIADSIIAHeader(); DSIIA.DSIIAContent content = iiaOf.createDSIIADSIIAContent(); NumberFormat nf1 = NumberFormat.getInstance(); nf1.setMinimumFractionDigits(2); NumberFormat nf2 = NumberFormat.getInstance(); nf2.setMinimumFractionDigits(7); for (DfIia main : mainList) { nullToEmptyString(main); DSIIA.DSIIAContent.ContentRecordGroup contentRecordGroup = iiaOf .createDSIIADSIIAContentContentRecordGroup(); contentRecordGroup.setArrangementType(main.getArragType()); contentRecordGroup.setPrimaryInvolvedPartyId(main.getPrimaryInvPartyId()); contentRecordGroup.setPrimaryInvolvedPartyUniqueIdType(main.getPrimaryInvPartyUniqIdType()); contentRecordGroup.setTransactionAmount(nf1.format(main.getTransactionAmt())); contentRecordGroup.setInterestRate(nf2.format(main.getInterestRate())); contentRecordGroup.setTransactionType(main.getTransactionType()); contentRecordGroup.setTerm(main.getTermUnit()); contentRecordGroup.setTermUnit(main.getTermUnit()); contentRecordGroup.setTimeOfAgreement(main.getTimeOfAgreement()); contentRecordGroup .setArrangementContractDate(getXMLGregorianCalendarDate(main.getArrgContractDate())); contentRecordGroup.setEffectiveDate(getXMLGregorianCalendarDate(main.getEffectiveDate())); contentRecordGroup.setMaturityDate(getXmlDateFormatString(main.getMaturityDate())); contentRecordGroup.setCallFlag(main.getCallFlag()); contentRecordGroup.setClearingFlag(main.getClearingFlag()); content.getContentRecordGroup().add(contentRecordGroup); } dsiia.setCommonHeader(dataSetCommonHeader); dsiia.setDSIIAHeader(dSIIAHeader); dsiia.setDSIIAContent(content); return generateToBytes(dsiia); } catch (Exception e) { e.printStackTrace(); throw e; } }