Java Code Examples for org.pentaho.reporting.engine.classic.core.MasterReport#setAutoSort()
The following examples show how to use
org.pentaho.reporting.engine.classic.core.MasterReport#setAutoSort() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SortOrderReportPreProcessorTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testSortOrderCalculationRelational() throws ReportProcessingException { DesignTimeDataSchemaModel model = new DesignTimeDataSchemaModel( new MasterReport() ); RelationalReportBuilder builder = new RelationalReportBuilder( model ); builder.addGroup( "Group-A" ); builder.addGroup( "Group-B" ); builder.addGroup( "Group-C" ); MasterReport report = builder.createReport(); report.setAutoSort( Boolean.TRUE ); ReportPreProcessor reportPreProcessor = create(); MasterReport materialized = materializePreData( report, reportPreProcessor ); Object attribute = materialized .getAttribute( AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.COMPUTED_SORT_CONSTRAINTS ); Assert.assertTrue( attribute instanceof List ); List<SortConstraint> sc = (List<SortConstraint>) attribute; Assert.assertEquals( 3, sc.size() ); Assert.assertEquals( new SortConstraint( "Group-A", true ), sc.get( 0 ) ); Assert.assertEquals( new SortConstraint( "Group-B", true ), sc.get( 1 ) ); Assert.assertEquals( new SortConstraint( "Group-C", true ), sc.get( 2 ) ); }
Example 2
Source File: CrosstabSortingIT.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testSorting() throws ResourceException { URL url = getClass().getResource( "crosstab-sorting.prpt" ); MasterReport report = (MasterReport) new ResourceManager().createDirectly( url, MasterReport.class ).getResource(); report.setAutoSort( true ); SortOrderReportPreProcessor p = new SortOrderReportPreProcessor(); List<SortConstraint> sortConstraints = p.computeSortConstraints( report.getReportFooter().getSubReport( 0 ) ); List<SortConstraint> expectedSortConstraints = new ArrayList<SortConstraint>(); expectedSortConstraints.add( new SortConstraint( "year", true ) ); expectedSortConstraints.add( new SortConstraint( "month", true ) ); Assert.assertEquals( expectedSortConstraints, sortConstraints ); DebugReportRunner.execGraphics2D( report ); }
Example 3
Source File: SortOrderReportPreProcessorTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testSortOrderCalculationCrosstab() throws ReportProcessingException { ContextAwareDataSchemaModel model = new DesignTimeDataSchemaModel( new MasterReport() ); CrosstabBuilder builder = new CrosstabBuilder( model ); builder.addDetails( "Details", null ); builder.addRowDimension( "Row-A" ); builder.addRowDimension( "Row-B" ); builder.addOtherDimension( "Other-A" ); builder.addOtherDimension( "Other-B" ); builder.addColumnDimension( "Col-A" ); builder.addColumnDimension( "Col-B" ); MasterReport report = builder.createReport(); report.setAutoSort( Boolean.TRUE ); ReportPreProcessor reportPreProcessor = create(); MasterReport materialized = materializePreData( report, reportPreProcessor ); Object attribute = materialized .getAttribute( AttributeNames.Internal.NAMESPACE, AttributeNames.Internal.COMPUTED_SORT_CONSTRAINTS ); Assert.assertTrue( attribute instanceof List ); List<SortConstraint> sc = (List<SortConstraint>) attribute; Assert.assertEquals( 6, sc.size() ); Assert.assertEquals( new SortConstraint( "Other-A", true ), sc.get( 0 ) ); Assert.assertEquals( new SortConstraint( "Other-B", true ), sc.get( 1 ) ); Assert.assertEquals( new SortConstraint( "Row-A", true ), sc.get( 2 ) ); Assert.assertEquals( new SortConstraint( "Row-B", true ), sc.get( 3 ) ); Assert.assertEquals( new SortConstraint( "Col-A", true ), sc.get( 4 ) ); Assert.assertEquals( new SortConstraint( "Col-B", true ), sc.get( 5 ) ); }
Example 4
Source File: WizardEditorModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private static MasterReport createDefaultReport() { final MasterReport report = new MasterReport(); report.setAutoSort( Boolean.TRUE ); report.setDataFactory( new CompoundDataFactory() ); report.setQuery( null ); return report; }
Example 5
Source File: EmbeddedWizard.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public AbstractReportDefinition run( final AbstractReportDefinition original ) throws ReportProcessingException { // Set the report if we have one otherwise create a new one if ( original != null ) { wizardController.getEditorModel().setReportDefinition( original, true ); } else { final MasterReport report = new MasterReport(); report.setDataFactory( new CompoundDataFactory() ); report.setQuery( null ); report.setAutoSort( Boolean.TRUE ); wizardController.getEditorModel().setReportDefinition( report, false ); } // Create the gui try { final SwingXulLoader loader = new SwingXulLoader(); loader.setOuterContext( owner ); final XulDomContainer mainWizardContainer = new SwingXulLoader().loadXul( MAIN_WIZARD_PANEL ); new WizardContentPanel( wizardController ).addContent( mainWizardContainer ); mainWizardContainer.setOuterContext( this.owner ); wizardController.registerMainXULContainer( mainWizardContainer ); wizardController.onLoad(); final Document documentRoot = mainWizardContainer.getDocumentRoot(); final XulComponent root = documentRoot.getRootElement(); if ( !( root instanceof XulDialog ) ) { throw new XulException( Messages.getInstance().getString( "EMBEDDED_WIZARD.Root_Error" ) + " " + root ); //$NON-NLS-1$ //$NON-NLS-2$ } dialog = (XulDialog) root; // This is a hack to get the JDialog (this wizard) to become the parent window of windows/dialogs // that the wizard creates. final DesignTimeContext context = new DefaultWizardDesignTimeContext ( wizardController.getEditorModel(), (Window) dialog.getRootObject(), designTimeContext ); dataSourceAndQueryStep.setDesignTimeContext( context ); wizardController.setDesignTimeContext( context ); // if we're doing an edit drop into the layout step if ( wizardController.getEditorModel().isEditing() ) { if ( wizardController.getStep( 0 ).isValid() ) { wizardController.setActiveStep( 1 ); // initializes the data if ( wizardController.getStep( 1 ).isValid() ) { wizardController.setActiveStep( 2 ); } } } dialog.show(); } catch ( Exception e ) { DebugLog.log( "Failed to initialize the wizard", e ); return null; } // ----------------------------------- if ( !wizardController.isFinished() ) { return null; } final AbstractReportDefinition reportDefinition = wizardController.getEditorModel().getReportDefinition(); try { final WizardSpecification spec = wizardController.getEditorModel().getReportSpec(); WizardProcessorUtil.applyWizardSpec( reportDefinition, spec ); WizardProcessorUtil.ensureWizardProcessorIsAdded( reportDefinition, null ); } catch ( Exception ex ) { throw new IllegalStateException(); } if ( reportDefinition instanceof MasterReport ) { return WizardProcessorUtil.materialize( (MasterReport) reportDefinition, new WizardProcessor() ); } else if ( reportDefinition instanceof SubReport ) { return WizardProcessorUtil.materialize( (SubReport) reportDefinition, new WizardProcessor() ); } else { throw new IllegalStateException(); } }
Example 6
Source File: NewReportAction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
public static MasterReport prepareMasterReport() { final MasterReport report = new MasterReport(); report.setAutoSort( Boolean.TRUE ); report.setDataFactory( new CompoundDataFactory() ); report.setQuery( null ); report.setQueryLimitInheritance( Boolean.TRUE ); report.getRelationalGroup( 0 ).getHeader() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE ); report.getRelationalGroup( 0 ).getFooter() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE ); report.getDetailsFooter() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE ); report.getDetailsHeader() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE ); report.getNoDataBand() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE ); report.getWatermark() .setAttribute( ReportDesignerParserModule.NAMESPACE, ReportDesignerParserModule.HIDE_IN_LAYOUT_GUI_ATTRIBUTE, Boolean.TRUE ); try { final MemoryDocumentBundle bundle = (MemoryDocumentBundle) report.getBundle(); if ( bundle.isEntryExists( TRANSLATIONS_PROPERTIES ) == false ) { final String defaultMessage = ActionMessages.getString( "Translations.DefaultContent" ); final OutputStream outputStream = bundle.createEntry( TRANSLATIONS_PROPERTIES, "text/plain" ); // NON-NLS outputStream.write( defaultMessage.getBytes( "ISO-8859-1" ) ); // NON-NLS outputStream.close(); bundle.getWriteableDocumentMetaData() .setEntryAttribute( TRANSLATIONS_PROPERTIES, BundleUtilities.STICKY_FLAG, "true" ); // NON-NLS } } catch ( Exception ex ) { // ignore, its not that important .. DebugLog.log( "Failed to created default translation entry", ex ); // NON-NLS } return report; }