protected void addParentBandDataToParametersRecursively(BandData parentBand, Map<String, Object> currentParams) { while (parentBand != null) { addParentBandDataToParameters(parentBand, currentParams); parentBand = parentBand.getParentBand(); } }
protected void addParentBandDataToParametersRecursively(BandData parentBand, Map<String, Object> currentParams) { while (parentBand != null) { addParentBandDataToParameters(parentBand, currentParams); parentBand = parentBand.getParentBand(); } }
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; }
/** * Maintains visitedBands to continue bypass on the same * level after return from deeper level of hierarchy. * Creates iterator for each level. */ @Override public boolean next() throws JRException { List<BandData> children = currentBand.getChildrenList(); if (children != null && !children.isEmpty() && !visitedBands.containsKey(currentBand)) { currentIterator = children.iterator(); visitedBands.put(currentBand, currentIterator); } else if (currentIterator == null) { currentIterator = Collections.singletonList(currentBand).iterator(); } if (currentIterator.hasNext()) { currentBand = currentIterator.next(); if (readBands.contains(currentBand) || currentBand.getData().isEmpty()) return next(); return true; } else { BandData parentBand = currentBand.getParentBand(); currentBand = parentBand; currentIterator = visitedBands.get(parentBand); if (parentBand == null || parentBand.equals(root)) return false; return next(); } }
/** * Maintains visitedBands to continue bypass on the same * level after return from deeper level of hierarchy. * Creates iterator for each level. */ @Override public boolean next() throws JRException { List<BandData> children = currentBand.getChildrenList(); if (children != null && !children.isEmpty() && !visitedBands.containsKey(currentBand)) { currentIterator = children.iterator(); visitedBands.put(currentBand, currentIterator); } else if (currentIterator == null) { currentIterator = Collections.singletonList(currentBand).iterator(); } if (currentIterator.hasNext()) { currentBand = currentIterator.next(); if (readBands.contains(currentBand) || currentBand.getData().isEmpty()) return next(); return true; } else { BandData parentBand = currentBand.getParentBand(); currentBand = parentBand; currentIterator = visitedBands.get(parentBand); if (parentBand == null || parentBand.equals(root)) return false; return next(); } }
protected Row findNextRowForHBand(BandData band, Range templateRange, List<Row> resultSheetRows) { Row firstRow = null; boolean isFirstLevelBand = BandData.ROOT_BAND_NAME.equals(band.getParentBand().getName()); //we suppose that when we render HORIZONTAL first level band, it should not be any right offset if (isFirstLevelBand || (previousRangeBandData != null && !previousRangeBandData.getParentBand().equals(band.getParentBand()))) { setPreviousRangeVerticalOffset(0, null); } Range lastRenderedRange = getLastRenderedBandForThisLevel(band); if (lastRenderedRange != null) {//this band has been already rendered at least once BandData lastRenderedBand = bandsForRanges.bandForResultRange(lastRenderedRange); LastRowBandVisitor bandVisitor = new LastRowBandVisitor(); lastRenderedBand.visit(bandVisitor); if (resultSheetRows.size() > bandVisitor.lastRow) {//get next row firstRow = resultSheetRows.get(bandVisitor.lastRow); } } else if (!isFirstLevelBand) { firstRow = findNextRowForChildBand(band, templateRange, resultSheetRows); } else {//this is the first render firstRow = findNextRowForFirstRender(templateRange, resultSheetRows); } return firstRow; }
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 Row findNextRowForHBand(BandData band, Range templateRange, List<Row> resultSheetRows) { Row firstRow = null; boolean isFirstLevelBand = BandData.ROOT_BAND_NAME.equals(band.getParentBand().getName()); //we suppose that when we render HORIZONTAL first level band, it should not be any right offset if (isFirstLevelBand || (previousRangeBandData != null && !previousRangeBandData.getParentBand().equals(band.getParentBand()))) { setPreviousRangeVerticalOffset(0, null); } Range lastRenderedRange = getLastRenderedBandForThisLevel(band); if (lastRenderedRange != null) {//this band has been already rendered at least once BandData lastRenderedBand = bandsForRanges.bandForResultRange(lastRenderedRange); LastRowBandVisitor bandVisitor = new LastRowBandVisitor(); lastRenderedBand.visit(bandVisitor); if (resultSheetRows.size() > bandVisitor.lastRow) {//get next row firstRow = resultSheetRows.get(bandVisitor.lastRow); } } else if (!isFirstLevelBand) { firstRow = findNextRowForChildBand(band, templateRange, resultSheetRows); } else {//this is the first render firstRow = findNextRowForFirstRender(templateRange, resultSheetRows); } return firstRow; }
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 Row findNextRowForChildBand(BandData band, Range templateRange, List<Row> resultSheetRows) { BandData parentBand = band.getParentBand(); Range resultParentRange = bandsForRanges.resultForBand(parentBand); Range templateParentRange = bandsForRanges.templateForBand(parentBand); if (resultParentRange != null && templateParentRange != null) { if (templateParentRange.getFirstRow() == templateRange.getFirstRow()) { if (resultSheetRows.size() > resultParentRange.getFirstRow() - 1) {//get current row return resultSheetRows.get(resultParentRange.getFirstRow() - 1); } } else { LastRowBandVisitor bandVisitor = new LastRowBandVisitor(); band.getParentBand().visit(bandVisitor); if (resultSheetRows.size() > bandVisitor.lastRow) {//get next row return resultSheetRows.get(bandVisitor.lastRow); } } } return null; }
protected Row findNextRowForChildBand(BandData band, Range templateRange, List<Row> resultSheetRows) { BandData parentBand = band.getParentBand(); Range resultParentRange = bandsForRanges.resultForBand(parentBand); Range templateParentRange = bandsForRanges.templateForBand(parentBand); if (resultParentRange != null && templateParentRange != null) { if (templateParentRange.getFirstRow() == templateRange.getFirstRow()) { if (resultSheetRows.size() > resultParentRange.getFirstRow() - 1) {//get current row return resultSheetRows.get(resultParentRange.getFirstRow() - 1); } } else { LastRowBandVisitor bandVisitor = new LastRowBandVisitor(); band.getParentBand().visit(bandVisitor); if (resultSheetRows.size() > bandVisitor.lastRow) {//get next row return resultSheetRows.get(bandVisitor.lastRow); } } } return null; }
@SuppressWarnings("unchecked") protected String processQueryTemplate(String query, BandData parentBand, Map<String, Object> reportParams) { try { GStringTemplateEngine engine = new GStringTemplateEngine(); Map bindings = new HashMap(); if (reportParams != null) { bindings.putAll(reportParams); } while (parentBand != null) { if (parentBand.getData() != null) { bindings.put(parentBand.getName(), parentBand.getData()); } parentBand = parentBand.getParentBand(); } return engine.createTemplate(query).make(bindings).toString(); } catch (ClassNotFoundException | IOException e) { throw new DataLoadingException(String.format("An error occurred while loading processing query template [%s]", query), e); } }
@SuppressWarnings("unchecked") protected String processQueryTemplate(String query, BandData parentBand, Map<String, Object> reportParams) { try { GStringTemplateEngine engine = new GStringTemplateEngine(); Map bindings = new HashMap(); if (reportParams != null) { bindings.putAll(reportParams); } while (parentBand != null) { if (parentBand.getData() != null) { bindings.put(parentBand.getName(), parentBand.getData()); } parentBand = parentBand.getParentBand(); } return engine.createTemplate(query).make(bindings).toString(); } catch (ClassNotFoundException e) { throw new DataLoadingException(String.format("An error occurred while loading processing query template [%s]", query), e); } catch (IOException e) { throw new DataLoadingException(String.format("An error occurred while loading processing query template [%s]", query), e); } }
protected Row findNextRowForVBand(BandData band, Range templateRange, List<Row> resultSheetRows) { Row firstRow = null; boolean isFirstLevelBand = BandData.ROOT_BAND_NAME.equals(band.getParentBand().getName()); setPreviousRangeVerticalOffset(0, null); Range lastRenderedRange = getLastRenderedBandForThisLevel(band); if (lastRenderedRange != null) {//this band has been already rendered at least once int shiftBetweenTemplateRangeAndLastRenderedRange = lastRenderedRange.getFirstColumn() - templateRange.getFirstColumn(); int widthOfTheRange = templateRange.getLastColumn() - templateRange.getFirstColumn() + 1; setPreviousRangeVerticalOffset(shiftBetweenTemplateRangeAndLastRenderedRange + widthOfTheRange, band); if (resultSheetRows.size() > lastRenderedRange.getFirstRow() - 1) {//get current row firstRow = resultSheetRows.get(lastRenderedRange.getFirstRow() - 1); } } else if (!isFirstLevelBand) { firstRow = findNextRowForChildBand(band, templateRange, resultSheetRows); } else {//this is the first render firstRow = findNextRowForFirstRender(templateRange, resultSheetRows); } return firstRow; }
protected Row findNextRowForVBand(BandData band, Range templateRange, List<Row> resultSheetRows) { Row firstRow = null; boolean isFirstLevelBand = BandData.ROOT_BAND_NAME.equals(band.getParentBand().getName()); setPreviousRangeVerticalOffset(0, null); Range lastRenderedRange = getLastRenderedBandForThisLevel(band); if (lastRenderedRange != null) {//this band has been already rendered at least once int shiftBetweenTemplateRangeAndLastRenderedRange = lastRenderedRange.getFirstColumn() - templateRange.getFirstColumn(); int widthOfTheRange = templateRange.getLastColumn() - templateRange.getFirstColumn() + 1; setPreviousRangeVerticalOffset(shiftBetweenTemplateRangeAndLastRenderedRange + widthOfTheRange, band); if (resultSheetRows.size() > lastRenderedRange.getFirstRow() - 1) {//get current row firstRow = resultSheetRows.get(lastRenderedRange.getFirstRow() - 1); } } else if (!isFirstLevelBand) { firstRow = findNextRowForChildBand(band, templateRange, resultSheetRows); } else {//this is the first render firstRow = findNextRowForFirstRender(templateRange, resultSheetRows); } return firstRow; }
Bounds parentBounds = templateBounds.get(band.getParentBand().getName()); Range parentRange = bandsToResultRanges.get(band.getParentBand()); if (BandData.ROOT_BAND_NAME.equals(band.getParentBand().getName())) { 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();
Bounds parentBounds = templateBounds.get(band.getParentBand().getName()); Range parentRange = bandsToResultRanges.get(band.getParentBand()); if (BandData.ROOT_BAND_NAME.equals(band.getParentBand().getName())) { 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();
protected void fillTables(XDispatchHelper xDispatchHelper) throws com.sun.star.uno.Exception { List<String> tablesNames = TableManager.getTablesNames(xComponent); for (String tableName : tablesNames) { TableManager tableManager = new TableManager(xComponent, tableName); BandFinder bandFinder = new BandFinder(tableManager).find(); BandData band = bandFinder.getBand(); String bandName = bandFinder.getBandName(); int numberOfRowWithAliases = tableManager.findRowWithAliases(); if (band != null && numberOfRowWithAliases > -1) { XTextTable xTextTable = tableManager.getXTextTable(); // try to select one cell without it workaround int columnCount = xTextTable.getColumns().getCount(); if (columnCount < 2) { xTextTable.getColumns().insertByIndex(columnCount, 1); } fillTable(band.getName(), band.getParentBand(), tableManager, xDispatchHelper, numberOfRowWithAliases); // end of workaround -> if (columnCount < 2) { xTextTable.getColumns().removeByIndex(columnCount, 1); } } else if (numberOfRowWithAliases > -1 && rootBand.getFirstLevelBandDefinitionNames() != null && rootBand.getFirstLevelBandDefinitionNames().contains(bandName)) { //if table is linked with band and has aliases on it, but no band data found - //we are removing the row tableManager.deleteRow(numberOfRowWithAliases); } } }
protected void fillTables(XDispatchHelper xDispatchHelper) throws com.sun.star.uno.Exception { List<String> tablesNames = TableManager.getTablesNames(xComponent); for (String tableName : tablesNames) { TableManager tableManager = new TableManager(xComponent, tableName); BandFinder bandFinder = new BandFinder(tableManager).find(); BandData band = bandFinder.getBand(); String bandName = bandFinder.getBandName(); int numberOfRowWithAliases = tableManager.findRowWithAliases(); if (band != null && numberOfRowWithAliases > -1) { XTextTable xTextTable = tableManager.getXTextTable(); // try to select one cell without it workaround int columnCount = xTextTable.getColumns().getCount(); if (columnCount < 2) { xTextTable.getColumns().insertByIndex(columnCount, 1); } fillTable(band.getName(), band.getParentBand(), tableManager, xDispatchHelper, numberOfRowWithAliases); // end of workaround -> if (columnCount < 2) { xTextTable.getColumns().removeByIndex(columnCount, 1); } } else if (numberOfRowWithAliases > -1 && rootBand.getFirstLevelBandDefinitionNames() != null && rootBand.getFirstLevelBandDefinitionNames().contains(bandName)) { //if table is linked with band and has aliases on it, but no band data found - //we are removing the row tableManager.deleteRow(numberOfRowWithAliases); } } }