org.pentaho.aggdes.model.Schema Java Examples
The following examples show how to use
org.pentaho.aggdes.model.Schema.
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: MondrianSchemaLoaderTestIT.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
public void testMondrianStatisticsProvider() { MondrianSchemaLoader loader = new MondrianSchemaLoader(); Map<Parameter, Object> parameterValues = new HashMap<>(); parameterValues.put( loader.getParameters().get( 0 ), connectString ); parameterValues.put( loader.getParameters().get( 1 ), "Sales" ); Schema schema = loader.createSchema( parameterValues ); StatisticsProvider statsProvider = schema.getStatisticsProvider(); assertNotNull( statsProvider ); assertEquals( statsProvider.getFactRowCount(), 86837.0 ); List<Attribute> attributes = new ArrayList<>(); attributes.add( schema.getAttributes().get( 0 ) ); // spot check that these methods return a meaningful value assertEquals( statsProvider.getRowCount( attributes ), 3.0 ); assertEquals( statsProvider.getLoadTime( attributes ), 3.8555688E7 ); assertEquals( statsProvider.getSpace( attributes ), 20.0 ); }
Example #2
Source File: AggregateTableOutputFactory.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
public AggregateTableOutput createOutput(Schema schema, Aggregate aggregate, List<String> uniqueTableNames) { AggregateTableOutput output = new AggregateTableOutput(aggregate); String tableName = schema.getDialect().removeInvalidIdentifierCharacters(aggregate.getCandidateTableName()); tableName = Util.uniquify(tableName, schema.getDialect().getMaximumTableNameLength(), uniqueTableNames); output.setTableName(tableName); final List<String> columnNameList = new ArrayList<String>(); int maximumColumnNameLength = schema.getDialect().getMaximumColumnNameLength(); for (Attribute attribute : UnionIterator.over( aggregate.getAttributes(), aggregate.getMeasures())) { String name = Util.uniquify( attribute.getCandidateColumnName(), maximumColumnNameLength, columnNameList); output.getColumnOutputs().add(new AggregateTableOutput.ColumnOutput(name, attribute)); } return output; }
Example #3
Source File: AbstractMondrianSchemaProvider.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
public Schema loadSchema(String cubeName) throws AggDesignerException{ boolean validationHasErrors = doValidation(cubeName); if (validationHasErrors && !continueOnValidationErrors) { return null; } try { DatabaseMeta dbMeta = connectionModel.getDatabaseMeta(); final String mondrianConnectionUrl = MessageFormat.format( "Provider={0};Jdbc={1};JdbcUser={2};JdbcPassword={3};Catalog={4};JdbcDrivers={5}", "Mondrian", dbMeta.getURL(), dbMeta .getUsername(), dbMeta.getPassword(), "file:" + getMondrianSchemaFilename(), dbMeta.getDriverClass()); Map<Parameter, Object> parameterValues = new HashMap<Parameter, Object>(); parameterValues.put(mondrianSchemaLoader.getParameters().get(0), mondrianConnectionUrl); parameterValues.put(mondrianSchemaLoader.getParameters().get(1), cubeName); Schema newSchema = mondrianSchemaLoader.createSchema(parameterValues); return newSchema; } catch(KettleDatabaseException e){ throw new AggDesignerException("Error loading Schema from Mondrian file",e); } }
Example #4
Source File: AlgorithmStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 6 votes |
public Result run(Schema schema, Map<Parameter, Object> parameterValues, Progress progress) { canceled = false; int i = 0; while (!canceled && i < 3) { try { System.out.println("algorithm running"); Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } finally { i++; } } if (canceled) { System.out.println("algorithm canceled"); return null; } else { System.out.println("algorithm ended normally"); return new ResultStub(); } }
Example #5
Source File: RuleBasedAggregateTableOutputFactory.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public AggregateTableOutput createOutput(Schema schema, Aggregate aggregate, List<String> uniqueTableNames) { AggregateTableOutput output = new AggregateTableOutput(aggregate); String tableName = schema.getDialect().removeInvalidIdentifierCharacters(aggregate.getCandidateTableName()); tableName = Util.uniquify(tableName, schema.getDialect().getMaximumTableNameLength(), uniqueTableNames); output.setTableName(tableName); final List<String> columnNameList = new ArrayList<String>(); // TODO: throw an exception here if name is too large? // int maximumColumnNameLength = // schema.getDialect().getMaximumColumnNameLength(); for (Attribute attribute : UnionIterator.over( aggregate.getAttributes(), aggregate.getMeasures())) { if (attribute instanceof Measure) { String name = cleanse(((MondrianMeasure)attribute).getRolapStarMeasure().getName()); output.getColumnOutputs().add(new AggregateTableOutput.ColumnOutput(name, attribute)); } else { Level level = findLevel(schema, attribute); RolapCubeLevel rolapLevel = ((MondrianLevel)level).getRolapCubeLevel(); output.getColumnOutputs().add(new AggregateTableOutput.ColumnOutput( cleanse(rolapLevel.getHierarchy().getName()) + "_" + cleanse(rolapLevel.getName()), attribute)); } } return output; }
Example #6
Source File: SerializationService.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public void deserializeConnection(Schema schema, String rdbmsXml, String schemaXml) { XStream xstream = getXStream(schema); DatabaseMeta databaseMeta = (DatabaseMeta)xstream.fromXML(rdbmsXml); SchemaModel schemaModel = (SchemaModel)xstream.fromXML(schemaXml); //save off cubeName since setSelectedSchemaModel will clear it out String cubeName = schemaModel.getCubeName(); connectionModel.setDatabaseMeta(databaseMeta); connectionModel.setSelectedSchemaModel(schemaModel); connectionModel.setCubeName(cubeName); }
Example #7
Source File: AlgorithmStub.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public List<CostBenefit> computeAggregateCosts( Schema schema, Map<Parameter, Object> parameterValues, List<Aggregate> aggregateList) { return null; }
Example #8
Source File: SerializationService.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
private XStream getXStream(Schema schema) { XStream xstream = new XStream(new DomDriver()); xstream.registerConverter(new DatabaseMetaConverter()); xstream.registerConverter(new AggListConverter(aggList)); xstream.registerConverter(new AttributeConverter(schema)); xstream.registerConverter(new MeasureConverter(schema)); return xstream; }
Example #9
Source File: JdbcTemplateSqlExecutor.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public String removeCommentsAndSemicolons( Schema schema, String sql ) { if ( sql == null ) { return null; } String trimmed = sql.trim( ); String commentStart = null; StringBuilder sb = new StringBuilder( ); schema.getDialect( ).comment( sb, "" ); commentStart = sb.toString( ); // remove NL if necessary if ( commentStart.indexOf( NL ) >= 0 ) { commentStart = commentStart.substring( 0, commentStart.indexOf( NL ) ); } String[ ] lines = trimmed.split( NL ); StringBuilder newSql = new StringBuilder( ); boolean newLineNeeded = false; for ( int i = 0; i < lines.length; i++ ) { if ( !lines[i].startsWith( commentStart ) ) { if ( newLineNeeded ) { newSql.append( NL ); } newSql.append( lines[i] ); newLineNeeded = true; } } String noCommentSql = newSql.toString( ); if ( noCommentSql.endsWith( ";" ) ) { noCommentSql = noCommentSql.substring( 0, noCommentSql.length( ) - 1 ); } logger.debug( "clean sql: --[" + noCommentSql + "]--" ); return noCommentSql; }
Example #10
Source File: JdbcTemplateSqlExecutor.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public String[] removeCommentsAndSemicolons( Schema schema, String[] sql ) { String[] newsql = new String[sql.length]; for ( int i = 0; i < sql.length; i++ ) { newsql[i] = removeCommentsAndSemicolons( schema, sql[i] ); } return newsql; }
Example #11
Source File: AggregateTableOutputFactory.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public List<Output> createOutputs(Schema schema, List<Aggregate> aggregates) { List<Output> outputs = new ArrayList<Output>(); List<String> uniqueTableNames = new ArrayList<String>(); for (Aggregate aggregate : aggregates) { outputs.add(createOutput(schema, aggregate, uniqueTableNames)); } return outputs; }
Example #12
Source File: AbstractGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
/** * this is a common method shared by most generators */ public String generateFull(Schema schema, List<? extends Output> outputs) { StringBuilder sb = new StringBuilder(); for (Output output : outputs) { sb.append(generate(schema, output)); } return sb.toString(); }
Example #13
Source File: OutputServiceImplTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public String generateFull(Schema schema, List<? extends Output> outputs) { StringBuilder sb = new StringBuilder(); for (Output output : outputs) { sb.append(generate(schema, output)).append("\n"); } return sb.toString(); }
Example #14
Source File: AggregateImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public AggregateImpl(Schema schema, BitSetPlus bits) { this.schema = schema; this.bits = bits; this.rowCount = schema.getStatisticsProvider().getRowCount(getAttributes()); if (false) { System.out.println( "AggregateImpl: " + getDescription() + " bits=" + bits); } }
Example #15
Source File: AlgorithmImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public Aggregate createAggregate(Schema schema, List<Attribute> attributeList) { this.schema = schema; final BitSetPlus bitSet = new BitSetPlus(schema.getAttributes().size()); for (Attribute attribute : attributeList) { bitSet.set(schema.getAttributes().indexOf(attribute)); } return new AggregateImpl(schema, bitSet); }
Example #16
Source File: MondrianSchemaGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public String generateFull(Schema schema, List<? extends Output> outputs) { try { MondrianDef.Schema schemaDef = (MondrianDef.Schema)((RolapSchema)((MondrianSchema)schema).getRolapConnection().getSchema()).getXMLSchema().deepCopy(); // locate the cube MondrianDef.Cube currentCube = null; for (MondrianDef.Cube cube : schemaDef.cubes) { if (cube.name.equals(((MondrianSchema)schema).getRolapCube().getName())) { currentCube = cube; break; } } if (!(currentCube.fact instanceof MondrianDef.Table)) { throw new RuntimeException("Fact Table must be of type TABLE"); } MondrianDef.Table factTable = (MondrianDef.Table)currentCube.fact; List<MondrianDef.AggTable> aggTables = new ArrayList<MondrianDef.AggTable>(); if (factTable.aggTables != null) { for (MondrianDef.AggTable aggTable : factTable.aggTables) { aggTables.add(aggTable); } } for (Output output : outputs) { aggTables.add(generateMondrianDef(schema, output)); } factTable.aggTables = (MondrianDef.AggTable[])aggTables.toArray(new MondrianDef.AggTable[0]); return schemaDef.toXML(); } catch (XOMException e) { e.printStackTrace(); } return null; }
Example #17
Source File: MondrianSchemaGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
private RolapBaseCubeMeasure findRolapMeasure(Schema schema, Measure measure) { RolapCube cube = ((MondrianSchema)schema).getRolapCube(); for (RolapMember member : cube.getMeasuresMembers()) { // skip over calculated measures, etc if (member instanceof RolapBaseCubeMeasure) { RolapBaseCubeMeasure rolapMeasure = (RolapBaseCubeMeasure)member; if (rolapMeasure.getStarMeasure() == ((MondrianMeasure)measure).getRolapStarMeasure()) { return rolapMeasure; } } } return null; }
Example #18
Source File: MondrianSchemaGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
private Level findLevel(Schema schema, Attribute attribute) { for (Dimension dimension : schema.getDimensions()) { for (Hierarchy hierarchy : dimension.getHierarchies()) { for (Level level : hierarchy.getLevels()) { if (level.getAttribute() == attribute) { return level; } } } } System.out.println("failed to locate level for attribute " + attribute.getLabel()); return null; }
Example #19
Source File: OutputServiceImplTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public String generateFull(Schema schema, List<? extends Output> outputs) { StringBuilder sb = new StringBuilder(); for (Output output : outputs) { sb.append(generate(schema, output)).append("\n"); } return sb.toString(); }
Example #20
Source File: RuleBasedAggregateTableOutputFactory.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public List<Output> createOutputs(Schema schema, List<Aggregate> aggregates) { List<Output> outputs = new ArrayList<Output>(); List<String> uniqueTableNames = new ArrayList<String>(); for (Aggregate aggregate : aggregates) { outputs.add(createOutput(schema, aggregate, uniqueTableNames)); } return outputs; }
Example #21
Source File: PopulateTableGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
public String generate(Schema schema, Output output) { AggregateTableOutput tableOutput = (AggregateTableOutput)output; final Dialect dialect = schema.getDialect(); final StringBuilder buf = new StringBuilder(); dialect.comment(buf, "Populate aggregate table " + tableOutput.getTableName()); buf.append("INSERT INTO "); dialect.quoteIdentifier( buf, tableOutput.getCatalogName(), tableOutput.getSchemaName(), tableOutput.getTableName()); buf.append(" (").append(ResultHandlerImpl.NL); int k = -1; List<String> columnNameList = new ArrayList<String>(); for (AggregateTableOutput.ColumnOutput column : tableOutput.getColumnOutputs()) { ++k; if (k > 0) { buf.append(",").append(ResultHandlerImpl.NL); } buf.append(" "); dialect.quoteIdentifier(buf, column.getName()); columnNameList.add(column.getName()); } buf.append(")").append(ResultHandlerImpl.NL); String sql = schema.generateAggregateSql( tableOutput.getAggregate(), columnNameList); buf.append(sql); dialect.terminateCommand(buf); return buf.toString(); }
Example #22
Source File: CreateTableGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
/** * generates the table output * @param schema * @param output * @return */ public String generate(Schema schema, Output output) { AggregateTableOutput tableOutput = (AggregateTableOutput)output; final Dialect dialect = schema.getDialect(); final StringBuilder buf = new StringBuilder(); dialect.comment( buf, "Aggregate table " + tableOutput.getTableName()); dialect.comment( buf, "Estimated " + new Double(output.getAggregate().estimateRowCount()).intValue() + " rows, " + new Double(output.getAggregate().estimateSpace()).intValue() + " bytes"); buf.append("CREATE TABLE "); dialect.quoteIdentifier(buf, tableOutput.getCatalogName(), tableOutput.getSchemaName(), tableOutput.getTableName()); buf.append(" (").append(ResultHandlerImpl.NL); int i = -1; for (AggregateTableOutput.ColumnOutput columns : tableOutput.getColumnOutputs()) { ++i; if (i > 0) { buf.append(",").append(ResultHandlerImpl.NL); } String columnName = columns.getName(); buf.append(" "); dialect.quoteIdentifier(buf, columnName); buf.append(" "); buf.append(columns.getAttribute().getDatatype(dialect)); } buf.append(")"); dialect.terminateCommand(buf); return buf.toString(); }
Example #23
Source File: ConnectionControllerTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 5 votes |
@Test public void testConnect_Success() throws AggDesignerException { setupSchemaProviderDefaults(); controller.setSelectedSchemaProvider(); //mimics the apply having been pressed //now call connect context.checking(new Expectations() { { //using dialog stub here instead of a mock so we get thread blocking which is needed to have this test run sucessfully final XulDialog waitDialog = new XulDialogStub(); allowing(doc).getElementById(ConnectionController.ANON_WAIT_DIALOG); will(returnValue(waitDialog)); final XulDialog connDialog = context.mock(XulDialog.class); allowing(doc).getElementById(ConnectionController.CONNECTION_DIALOG); will(returnValue(connDialog)); one(connDialog).hide(); final Schema schema = context.mock(Schema.class); one(aSchemaProvider).loadSchema("testCube"); will(returnValue(schema)); one(model).getCubeName(); will(returnValue("testCube")); one(model).setSchema(schema); ignoring(model).setSchemaUpToDate(with(any(Boolean.class))); ignoring(outputService); } }); controller.connect(); //make sure the all the aggdesigner functionality is enabled after a successful connection assertTrue(workspace.isApplicationUnlocked()); }
Example #24
Source File: OutputServiceImplTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public Output createOutput(Schema schema, Aggregate aggregate) { return new OutputTestImpl(schema, aggregate); }
Example #25
Source File: AlgorithmImplTest.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public List<CostBenefit> computeAggregateCosts(Schema schema, Map<Parameter, Object> parameterValues, List<Aggregate> aggregateList) { computeAggCostsCalled = true; return new ArrayList<CostBenefit>(); }
Example #26
Source File: OutputServiceImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void setSchema(Schema schema) { this.schema = schema; }
Example #27
Source File: OutputServiceImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public void init(Schema schema) { setSchema(schema); }
Example #28
Source File: MondrianSchemaGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public boolean canGenerate(Schema schema, Output output) { return (output instanceof AggregateTableOutput); }
Example #29
Source File: MondrianSchemaGenerator.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public String generate(Schema schema, Output output) { return generateMondrianDef(schema, output).toXML(); }
Example #30
Source File: OutputServiceImpl.java From pentaho-aggdesigner with GNU General Public License v2.0 | 4 votes |
public OutputServiceImpl(Schema schema) { this(); this.schema = schema; }