本文整理汇总了Java中org.pentaho.metadata.model.LogicalModel.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java LogicalModel.setProperty方法的具体用法?Java LogicalModel.setProperty怎么用?Java LogicalModel.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.metadata.model.LogicalModel
的用法示例。
在下文中一共展示了LogicalModel.setProperty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRoles
import org.pentaho.metadata.model.LogicalModel; //导入方法依赖的package包/类
@Test
public void testRoles() throws Exception {
LogicalModel businessModel = getTestModel( TargetTableType.INLINE_SQL, "select * from customer", "" );
List<OlapRole> roles = new ArrayList<OlapRole>();
roles.add( new OlapRole( "California Manager", "<SchemaGrant></SchemaGrant>" ) );
businessModel.setProperty( LogicalModel.PROPERTY_OLAP_ROLES, roles );
MondrianModelExporter exporter = new MondrianModelExporter( businessModel, "en_US" );
String data = exporter.createMondrianModelXML();
TestHelper.assertEqualsIgnoreWhitespaces( "<Schema name=\"model\">\n" + " <Dimension name=\"Dim1\">\n"
+ " <Hierarchy name=\"Hier1\" hasAll=\"false\">\n" + " <View alias=\"FACT\">\n"
+ " <SQL dialect=\"generic\">\n" + " <![CDATA[select * from customer]]>\n" + " </SQL>\n"
+ " </View>\n" + " <Level name=\"Lvl1\" uniqueMembers=\"false\" column=\"pc1\" type=\"Numeric\">\n"
+ " </Level>\n" + " </Hierarchy>\n" + " </Dimension>\n" + " <Cube name=\"Cube1\">\n"
+ " <View alias=\"FACT\">\n" + " <SQL dialect=\"generic\">\n"
+ " <![CDATA[select * from customer]]>\n" + " </SQL>\n" + " </View>\n"
+ " <DimensionUsage name=\"Dim1\" source=\"Dim1\" foreignKey=\"pc2\"/>\n"
+ " <Measure name=\"bc1\" column=\"pc1\" aggregator=\"sum\"/>\n" + " </Cube>\n"
+ " <Role name=\">California Manager\"> <SchemaGrant></SchemaGrant> </Role>\n"
+ "</Schema>", data );
}
示例2: generateDomain
import org.pentaho.metadata.model.LogicalModel; //导入方法依赖的package包/类
/**
* Generates a {@link Domain} from the database meta, schema name, and table name. It additionally sets "SUPPORTS_OLAP"
* to {@code true} for all models.
*
* @return a domain that is backed by the database meta, schema name, and table name
* @throws ModelerException if we cannot generate the domain
*/
public Domain generateDomain() throws ModelerException {
Domain d = ModelerSourceUtil.generateDomain(getDatabaseMeta(), getSchemaName(), getTableName());
for(LogicalModel lModel : d.getLogicalModels()) {
lModel.setProperty("SUPPORTS_OLAP", Boolean.TRUE.toString() );
}
return d;
}
示例3: serializeIntoDomain
import org.pentaho.metadata.model.LogicalModel; //导入方法依赖的package包/类
/**
* Serialize the properties of this source into the domain provided.
*
* @param d Domain to serialize to
*/
@Override
public void serializeIntoDomain(Domain d) {
LogicalModel lm = d.getLogicalModels().get(0);
lm.setProperty(getSourceTypePropertyName(), getSourceType() );
lm.setProperty(getFilenamePropertyName(), Const.NVL(getFilename(), EMPTY_STRING) );
lm.setProperty(getRepositoryNamePropertyName(), Const.NVL(getRepositoryName(), EMPTY_STRING) );
lm.setProperty(getMetaIdPropertyName(), Const.NVL(getMetaId(), EMPTY_STRING) );
}
示例4: initialize
import org.pentaho.metadata.model.LogicalModel; //导入方法依赖的package包/类
@Test
public void initialize() throws ModelerException {
KettleModelerSource source = new KettleModelerSource();
String tableName = "tableName";
String schemaName = "schemaName";
String fileName = "fileName";
String repositoryName = "repositoryName";
String metaId = "metaId";
SqlPhysicalTable table = new SqlPhysicalTable();
SqlDataSource dataSource = new SqlDataSource();
dataSource.setHostname("hostname");
SqlPhysicalModel model = new SqlPhysicalModel();
model.setDatasource(dataSource);
model.addPhysicalTable(table);
LogicalModel lm = new LogicalModel();
Domain domain = new Domain();
domain.addPhysicalModel(model);
domain.addLogicalModel(lm);
// Set the properties KettleModelerSource will look for when extracting values
lm.setProperty(source.getFilenamePropertyName(), fileName );
lm.setProperty(source.getRepositoryNamePropertyName(), repositoryName );
lm.setProperty(source.getMetaIdPropertyName(), metaId );
table.setProperty("target_table", tableName );
table.setProperty("target_schema", schemaName );
source.initialize(domain);
assertEquals(tableName, source.getTableName());
assertEquals(schemaName, source.getSchemaName());
assertEquals(repositoryName, source.getRepositoryName());
assertEquals(metaId , source.getMetaId());
}
示例5: testLegacyJoinOrderLogic
import org.pentaho.metadata.model.LogicalModel; //导入方法依赖的package包/类
/**
* Since the legacy join compare logic is non-deterministic, it is not safe to build any expected test results on the
* generated SQL. The fallback is to validate that the legacy code path is traversed when the "legacy_join_order"
* boolean set to true in the model. To do this, the test verifies that logging output is as expected.
*
* @throws PentahoMetadataException
*/
@Test
public void testLegacyJoinOrderLogic() throws PentahoMetadataException {
Logger logger = Logger.getLogger( SQLJoin.class.getName() );
ByteArrayOutputStream out = new ByteArrayOutputStream();
Appender appender = new WriterAppender( new SimpleLayout(), out );
logger.addAppender( appender );
try {
RelationshipType[] typesToTest = new RelationshipType[] { RelationshipType._0_N, RelationshipType._1_1 };
for ( RelationshipType firstRel : typesToTest ) {
for ( RelationshipType secondRel : typesToTest ) {
final LogicalModel model = new LogicalModel();
model.setId( "model_01" );
Category mainCat = new Category();
mainCat.setId( "cat_01" );
model.getCategories().add( mainCat );
LogicalTable[] tables = getTablesWithRelationships( firstRel, secondRel, mainCat, model );
DatabaseMeta databaseMeta = new DatabaseMeta( "", "ORACLE", "Native", "", "", "", "", "" );
Query myTest = new Query( null, model );
myTest.getSelections().add( new Selection( null, tables[ 0 ].getLogicalColumns().get( 0 ), null ) );
myTest.getSelections().add( new Selection( null, tables[ 1 ].getLogicalColumns().get( 0 ), null ) );
myTest.getSelections().add( new Selection( null, tables[ 2 ].getLogicalColumns().get( 0 ), null ) );
SqlGenerator generator = new SqlGenerator();
// first verify the legacy logic is not used if the property is not set
generator.generateSql( myTest, "en_US", null, databaseMeta );
Assert.assertTrue( "Did not expect to use the legacy SQLJoin.compareTo() logic.", !out.toString().contains(
"Using legacy SQLJoin compare." ) );
// set the property and make sure the legacy logic is used
model.setProperty( "legacy_join_order", true );
generator.generateSql( myTest, "en_US", null, databaseMeta );
Assert.assertTrue( "Should have used legacy SQLJoin.compareTo() logic.", out.toString().contains(
"Using legacy SQLJoin compare." ) );
out.reset(); // clear out accumulated logs for next run
}
}
} finally {
logger.removeAppender( appender );
}
}
示例6: testOlapRoles
import org.pentaho.metadata.model.LogicalModel; //导入方法依赖的package包/类
@Test
public void testOlapRoles() throws Exception {
XmiParser parser = new XmiParser();
Domain domain = parser.parseXmi( getClass().getResourceAsStream( "/example_olap.xmi" ) );
List<OlapRole> roles = new ArrayList<OlapRole>();
roles.add( new OlapRole( "California Manager", "<SchemaGrant/>" ) );
roles.add( new OlapRole( "Maryland Manager", "<SchemaGrant/>" ) );
LogicalModel model = domain.getLogicalModels().get( 0 );
model.setProperty( LogicalModel.PROPERTY_OLAP_ROLES, roles );
String xmi = parser.generateXmi( domain );
ByteArrayInputStream is = new ByteArrayInputStream( xmi.getBytes() );
Domain domain2 = parser.parseXmi( is );
SerializationService serializer = new SerializationService();
String xml1 = serializeWithOrderedHashmaps( domain );
String xml2 = serializeWithOrderedHashmaps( domain2 );
assertEquals( xml1, xml2 );
}
示例7: getTestModel
import org.pentaho.metadata.model.LogicalModel; //导入方法依赖的package包/类
private LogicalModel getTestModel( TargetTableType tableType, String targetTable, String targetSchema,
boolean hiddenMembers ) {
List<OlapDimension> dimensions = new ArrayList<OlapDimension>();
OlapDimension dimension = new OlapDimension();
dimension.setName( "Dim1" );
List<OlapHierarchy> hierarchies = new ArrayList<OlapHierarchy>();
OlapHierarchy hierarchy = new OlapHierarchy();
hierarchy.setName( "Hier1" );
List<OlapHierarchyLevel> hierarchyLevels = new ArrayList<OlapHierarchyLevel>();
OlapHierarchyLevel level = new OlapHierarchyLevel();
level.setName( "Lvl1" );
level.setHidden( hiddenMembers );
hierarchyLevels.add( level );
hierarchy.setHierarchyLevels( hierarchyLevels );
hierarchies.add( hierarchy );
dimension.setHierarchies( hierarchies );
dimensions.add( dimension );
List<OlapCube> cubes = new ArrayList<OlapCube>();
OlapCube cube = new OlapCube();
cube.setName( "Cube1" );
cubes.add( cube );
List<OlapMeasure> measures = new ArrayList<OlapMeasure>();
OlapMeasure measure = new OlapMeasure();
measure.setName( "Meas1" );
measures.add( measure );
measure.setHidden( hiddenMembers );
cube.setOlapMeasures( measures );
List<OlapDimensionUsage> dimensionUsages = new ArrayList<OlapDimensionUsage>();
OlapDimensionUsage dimUsage = new OlapDimensionUsage();
dimensionUsages.add( dimUsage );
cube.setOlapDimensionUsages( dimensionUsages );
dimUsage.setName( "Dim1" );
dimUsage.setOlapDimension( dimension );
LogicalModel businessModel = TestHelper.buildDefaultModel();
LogicalTable logicalTable = businessModel.getLogicalTables().get( 0 );
hierarchy.setLogicalTable( logicalTable );
List<LogicalColumn> logicalColumns = new ArrayList<LogicalColumn>();
level.setReferenceColumn( logicalTable.getLogicalColumns().get( 0 ) );
level.setLogicalColumns( new ArrayList<LogicalColumn>() );
logicalTable.setProperty( SqlPhysicalTable.TARGET_TABLE, targetTable );
logicalTable.setProperty( SqlPhysicalTable.TARGET_SCHEMA, targetSchema );
LogicalColumn m = logicalTable.getLogicalColumns().get( 0 );
m.setAggregationType( AggregationType.SUM );
measure.setLogicalColumn( m );
businessModel.getLogicalTables().get( 0 ).setProperty( SqlPhysicalTable.TARGET_TABLE_TYPE, tableType );
cube.setLogicalTable( businessModel.getLogicalTables().get( 0 ) );
businessModel.setProperty( "olap_dimensions", dimensions );
businessModel.setProperty( "olap_cubes", cubes );
businessModel.setName( new LocalizedString( "en_US", "model" ) );
return businessModel;
}