public BandData getChildByName(String bandName) { if (bandName == null) { throw new NullPointerException("Parameter bandName can not be null."); } List<BandData> childrenByName = getChildrenByName(bandName); return childrenByName.isEmpty() ? null : childrenByName.get(0); }
public BandData getChildByName(String bandName) { if (bandName == null) { throw new NullPointerException("Parameter bandName can not be null."); } List<BandData> childrenByName = getChildrenByName(bandName); return childrenByName.isEmpty() ? null : childrenByName.get(0); }
protected List<KeyValueEntity> getEntries(PivotTableDescription configuration) { List<BandData> childrenByName = rootBand.getChildrenByName(configuration.getBandName()); if (childrenByName == null) return Collections.emptyList(); return childrenByName.stream() .filter(band -> band.getData() != null && !band.getData().isEmpty()) .map(band -> { KeyValueEntity entity = new KeyValueEntity(); band.getData().forEach(entity::setValue); return entity; }) .collect(Collectors.toList()); } }
public List<BandData> findBandsRecursively(String name) { BandData firstBand = findBandRecursively(name); if (firstBand == null) { return Collections.emptyList(); } List<BandData> allBands = firstBand.getParentBand() != null ? firstBand.getParentBand().getChildrenByName(name) : Collections.singletonList(firstBand); return allBands; }
public List<BandData> findBandsRecursively(String name) { BandData firstBand = findBandRecursively(name); if (firstBand == null) { return Collections.emptyList(); } List<BandData> allBands = firstBand.getParentBand() != null ? firstBand.getParentBand().getChildrenByName(name) : Collections.singletonList(firstBand); return allBands; }
protected BandData createNewBand(String bandName) { BandData newParentBand = new BandData(bandName); List<BandData> childrenList = root.getChildrenByName(bandName); root.getChildrenBands().remove(bandName); newParentBand.addChildren(childrenList); childrenList.forEach(childBand -> childBand.setParentBand(newParentBand)); visitedBands.put(newParentBand, newParentBand.getChildrenList().iterator()); return newParentBand; }
protected BandData createNewBand(String bandName) { BandData newParentBand = new BandData(bandName); List<BandData> childrenList = root.getChildrenByName(bandName); root.getChildrenBands().remove(bandName); newParentBand.addChildren(childrenList); childrenList.forEach(childBand -> childBand.setParentBand(newParentBand)); visitedBands.put(newParentBand, newParentBand.getChildrenList().iterator()); return newParentBand; }
protected Range getLastRenderedBandForThisLevel(BandData band) { List<BandData> sameLevelBands = band.getParentBand().getChildrenByName(band.getName()); for (BandData sameLevelBand : sameLevelBands) { Range range = bandsForRanges.resultForBand(sameLevelBand); if (range != null) { return lastRenderedRangeForBandName.get(band.getName()); } } return null; }
protected Range getLastRenderedBandForThisLevel(BandData band) { List<BandData> sameLevelBands = band.getParentBand().getChildrenByName(band.getName()); for (BandData sameLevelBand : sameLevelBands) { Range range = bandsForRanges.resultForBand(sameLevelBand); if (range != null) { return lastRenderedRangeForBandName.get(band.getName()); } } return null; }
private String convertSerialChart(SerialChartDescription description) { List<Map<String, Object>> data = new ArrayList<>(); List<BandData> childrenByName = rootBand.getChildrenByName(description.getBandName()); for (BandData bandData : childrenByName) { data.add(bandData.getData()); } return new ChartToJsonConverter(((ReportTemplate) reportTemplate).getReport().getLocName()) .convertSerialChart(description, data); }
protected String convertPieChart(PieChartDescription description) { List<Map<String, Object>> data = new ArrayList<>(); List<BandData> childrenByName = rootBand.getChildrenByName(description.getBandName()); for (BandData bandData : childrenByName) { data.add(bandData.getData()); } return new ChartToJsonConverter(((ReportTemplate) reportTemplate).getReport().getLocName()) .convertPieChart(description, data); } }
@Test public void testGetChildren() { BandData root = createData(); BandData band1 = root.getChildByName("Band1"); BandData band2 = root.getChildByName("Band2"); BandData band3 = root.getChildByName("Band3"); assertNotNull(band1); assertNotNull(band2); assertNotNull(band3); BandData band11 = band1.getChildByName("Band11"); BandData band12 = band1.getChildByName("Band12"); BandData band13 = band1.getChildByName("Band13"); BandData band14 = band1.getChildByName("Band14"); assertNotNull(band11); assertNotNull(band12); assertNotNull(band13); assertNotNull(band14); BandData alsoBand1 = root.getChildrenByName("Band1").get(0); BandData alsoBand14 = alsoBand1.getChildrenByName("Band14").get(0); assertSame(alsoBand1, band1); assertSame(alsoBand14, band14); }
protected void fillTable(String name, BandData parentBand, TableManager tableManager, XDispatchHelper xDispatchHelper, int numberOfRowWithAliases) throws com.sun.star.uno.Exception { // Lock clipboard, cause uno uses it to grow tables, relevant for desktops synchronized (clipboardLock) { XTextTable xTextTable = tableManager.getXTextTable(); if (officeIntegration.isDisplayDeviceAvailable()) { clearClipboard(); } List<BandData> childrenByName = parentBand.getChildrenByName(name); for (BandData ignored : childrenByName) { tableManager.copyRow(xDispatchHelper, as(XTextDocument.class, xComponent).getCurrentController(), numberOfRowWithAliases); } int i = numberOfRowWithAliases; for (BandData child : childrenByName) { if (name.equals(child.getName())) { fillRow(child, tableManager, i); i++; } } tableManager.deleteRow(i); } }
protected void fillTable(String name, BandData parentBand, TableManager tableManager, XDispatchHelper xDispatchHelper, int numberOfRowWithAliases) throws com.sun.star.uno.Exception { // Lock clipboard, cause uno uses it to grow tables, relevant for desktops synchronized (clipboardLock) { XTextTable xTextTable = tableManager.getXTextTable(); if (officeIntegration.isDisplayDeviceAvailable()) { clearClipboard(); } List<BandData> childrenByName = parentBand.getChildrenByName(name); for (BandData ignored : childrenByName) { tableManager.copyRow(xDispatchHelper, as(XTextDocument.class, xComponent).getCurrentController(), numberOfRowWithAliases); } int i = numberOfRowWithAliases; for (BandData child : childrenByName) { if (name.equals(child.getName())) { fillRow(child, tableManager, i); i++; } } tableManager.deleteRow(i); } }
@Test public void testXls() throws Exception { BandData root = createRootBand(); BandData date = new BandData("Date", root); BandData dateHeader = new BandData("DateHeader", root); date.addData("date", new Date()); root.addChild(dateHeader); root.addChild(date); List<BandData> band1objects = root.getChildrenByName("Band1"); for (int i = 0; i < band1objects.size(); i++) { BandData bandData = band1objects.get(i); if (i % 2 == 0) { bandData.addData("theStyle", "red"); } } FileOutputStream outputStream = new FileOutputStream("./result/smoke/result.xls"); ReportFormatter formatter = new DefaultFormatterFactory().createFormatter(new FormatterFactoryInput("xls", root, new ReportTemplateImpl("", "./modules/core/test/smoketest/test.xls", "./modules/core/test/smoketest/test.xls", ReportOutputType.xls), outputStream)); formatter.renderDocument(); IOUtils.closeQuietly(outputStream); }
@Test public void testDataLinkage() { Report report = createReport(); BandData rootBand = new BandData(BandData.ROOT_BAND_NAME); rootBand.setData(new HashMap<>()); rootBand.addReportFieldFormats(report.getReportFieldFormats()); rootBand.setFirstLevelBandDefinitionNames(new HashSet<>()); new DataExtractorImpl(new DefaultLoaderFactory().setGroovyDataLoader( new GroovyDataLoader(new DefaultScriptingImpl()))).extractData(report, new HashMap<>(), rootBand); List<BandData> bands = rootBand.getChildrenByName("Band1"); for (BandData band : bands) { if (((Integer)1).equals(band.getParameterValue("link"))) { Assert.assertEquals(1, band.getParameterValue("col1")); Assert.assertEquals(10, band.getParameterValue("col2")); Assert.assertEquals(100, band.getParameterValue("col3")); } else if (((Integer)2).equals(band.getParameterValue("link"))) { Assert.assertEquals(2, band.getParameterValue("col1")); Assert.assertEquals(20, band.getParameterValue("col2")); Assert.assertEquals(200, band.getParameterValue("col3")); } } }
List<BandData> sameBands = band.getParentBand().getChildrenByName(band.getName()); if (sameBands.size() > 0 && sameBands.get(sameBands.size() - 1) == band) {//check if this vertical band is last vertical band with same name rownum += addedRowNumbers.size();
List<BandData> sameBands = band.getParentBand().getChildrenByName(band.getName()); if (sameBands.size() > 0 && sameBands.get(sameBands.size() - 1) == band) {//check if this vertical band is last vertical band with same name rownum += addedRowNumbers.size();