当前位置: 首页>>代码示例>>Java>>正文


Java LogicalModel类代码示例

本文整理汇总了Java中org.pentaho.metadata.model.LogicalModel的典型用法代码示例。如果您正苦于以下问题:Java LogicalModel类的具体用法?Java LogicalModel怎么用?Java LogicalModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LogicalModel类属于org.pentaho.metadata.model包,在下文中一共展示了LogicalModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: StarModelDialog

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
public StarModelDialog(Shell parent, LogicalModel logicalModel, String locale) {
  super(parent, SWT.DIALOG_TRIM);
  this.logicalModel = logicalModel;
  this.props = PropsUI.getInstance();
  this.locale = locale;
  
  List<LogicalTable> factTables = ConceptUtil.findLogicalTables(logicalModel, TableType.FACT);
  if (factTables.isEmpty()) {
    this.factTable = new LogicalTable();
    this.factTable.setId(UUID.randomUUID().toString());
    this.factTable.setProperty(DefaultPropertyID.TABLE_TYPE.getId(), TableType.FACT);
    logicalModel.addLogicalTable(this.factTable);
  } else {
    this.factTable = factTables.get(0);
  }    
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:17,代码来源:StarModelDialog.java

示例2: testQuotedTargetTable

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testQuotedTargetTable() throws Exception {
  LogicalModel businessModel = getTestModel( TargetTableType.TABLE, "`tableName`", "`schemaName`" );
  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"
      + "    <Table name=\"tableName\" schema=\"schemaName\"/>\n"
      + "      <Level name=\"Lvl1\" uniqueMembers=\"false\" column=\"pc1\" type=\"Numeric\">\n" + "      </Level>\n"
      + "    </Hierarchy>\n" + "  </Dimension>\n" + "  <Cube name=\"Cube1\">\n"
      + "    <Table name=\"tableName\" schema=\"schemaName\" />\n"
      + "    <DimensionUsage name=\"Dim1\" source=\"Dim1\" foreignKey=\"pc2\"/>\n"
      + "    <Measure name=\"bc1\" column=\"pc1\" aggregator=\"sum\"/>\n" + "  </Cube>\n"
      + "</Schema>", data );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:17,代码来源:MondrianModelExporterTest.java

示例3: testIndexOfFactTable

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testIndexOfFactTable() throws Exception {
  final LogicalModel logicalModel = mock( LogicalModel.class );

  final LogicalTable logicalTable1 = mock( LogicalTable.class );
  when( logicalTable1.getProperty( eq( DefaultPropertyID.TABLE_TYPE.getId() ) ) ).thenReturn( TableType.DIMENSION );
  final LogicalTable logicalTable2 = mock( LogicalTable.class );
  when( logicalTable2.getProperty( eq( DefaultPropertyID.TABLE_TYPE.getId() ) ) ).thenReturn( TableType.FACT );
  final LogicalTable logicalTable3 = mock( LogicalTable.class );
  when( logicalTable3.getProperty( eq( DefaultPropertyID.TABLE_TYPE.getId() ) ) ).thenReturn( TableType.DIMENSION );
  when( logicalModel.getLogicalTables() ).thenReturn( new LinkedList<LogicalTable>() {
    {
      add( logicalTable1 );
      add( logicalTable2 );
      add( logicalTable3 );
    }
  } );

  final int indexOfFactTable = ConceptUtil.indexOfFactTable( logicalModel );
  assertEquals( 1, indexOfFactTable );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:22,代码来源:ConceptUtilTest.java

示例4: populateElement

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
private static IMetaStoreElement populateElement(IMetaStore metaStore, LogicalModel model) throws MetaStoreException {
  try {
    IMetaStoreElement element = metaStore.newElement();
    element.setName(model.getName(defaultLocale));
    element.addChild( metaStore.newAttribute(Attribute.ID_MODEL_DESCRIPTION.id, model.getDescription(defaultLocale)) );

    IMetaStoreAttribute logicalTablesAttribute = metaStore.newAttribute(Attribute.ID_LOGICAL_TABLES.id, model.getDescription(defaultLocale));
    element.addChild(logicalTablesAttribute);
    for (LogicalTable logicalTable : model.getLogicalTables()) {

      IMetaStoreAttribute logicalTableAttribute = metaStore.newAttribute(Attribute.ID_LOGICAL_TABLE.id, model.getDescription(defaultLocale));
      logicalTablesAttribute.addChild(logicalTableAttribute);

      //

      // Save the ID as well as the name (for safety)
      //
      logicalTableAttribute.addChild(metaStore.newAttribute(Attribute.ID_LOGICAL_TABLE_ID.id, logicalTable.getId()));
      logicalTableAttribute.addChild(metaStore.newAttribute(Attribute.ID_LOGICAL_TABLE_NAME.id, logicalTable.getName()));
    }

    return element;
  } catch(Exception e) {
    throw new MetaStoreException("Unable to populate metastore element from logical model", e);
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:27,代码来源:ModelMetaStoreUtil.java

示例5: testQueryXmlSerialization

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testQueryXmlSerialization() throws PentahoMetadataException {
  LogicalModel model = domain.findLogicalModel( "MODEL_1" );
  Query query = new Query( domain, model );
  Category category = model.findCategory( Settings.getBusinessCategoryIDPrefix() + "newdatasource" );
  LogicalColumn column = category.findLogicalColumn( "bc_CUSTOMERNAME" );
  query.getSelections().add( new Selection( category, column, null ) );
  query.getConstraints().add( new Constraint( CombinationType.AND, "[CATEGORY.bc_CUSTOMERNAME] = \"bob\"" ) );
  query.getOrders().add( new Order( new Selection( category, column, null ), Order.Type.ASC ) );

  QueryXmlHelper helper = new QueryXmlHelper();
  String xml = helper.toXML( query );
  InMemoryMetadataDomainRepository repo = new InMemoryMetadataDomainRepository();
  try {
    repo.storeDomain( domain, true );
  } catch ( Exception e ) {
    e.printStackTrace();
    fail();
  }
  Query newQuery = null;
  newQuery = helper.fromXML( repo, xml );
  // verify that when we serialize and deserialize, the xml stays the same.
  assertEquals( xml, helper.toXML( newQuery ) );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:25,代码来源:SQLModelGeneratorIT.java

示例6: hasFactsInIt

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
/**
 * See if the business column specified has a fact in it.<br>
 * We verify the formula specified in the column to see if it contains calculations with any aggregated column.<br>
 * We even do this nested down through the used business columns in the formula.<br>
 * 
 * @param model
 *          The business model to reference.
 * @param businessColumn
 *          The column to verify for facts.
 * @param parameters
 *          Parameters to be used during query generation.
 * @param genAsPreparedStatement
 *          Forces the method generate query as prepared statement.
 * @param databaseMeta
 *          The database to reference.
 * @param locale
 *          The locale to use.
 * @return true if the business column uses any aggregation in the formula or is aggregated itself.
 */
protected boolean hasFactsInIt( LogicalModel model, Selection businessColumn, Map<String, Object> parameters,
    boolean genAsPreparedStatement, DatabaseMeta databaseMeta, String locale ) {
  if ( businessColumn.hasAggregate() ) {
    return true;
  }

  // Parse the formula in the business column to see which tables and columns are involved...
  //
  SqlAndTables sqlAndTables =
      getBusinessColumnSQL( model, businessColumn, null, parameters, genAsPreparedStatement, databaseMeta, locale );
  for ( Selection column : sqlAndTables.getUsedColumns() ) {
    if ( column.hasAggregate() ) {
      return true;
    }
  }

  // Nothing found
  //
  return false;

}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:41,代码来源:SqlGenerator.java

示例7: testGenerateDimensionTransformations

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testGenerateDimensionTransformations() throws Exception {
  final LogicalModel logicalModel = mock( LogicalModel.class );
  when( jobGenerator.domain.getLogicalModels() ).thenReturn( new LinkedList<LogicalModel>() { {
      add( logicalModel );
    } } );

  final LogicalTable logicalTable = mock( LogicalTable.class );
  when( logicalTable.getProperty( eq( DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME ) ) )
      .thenReturn( "test_table_name" );
  when( logicalModel.getLogicalTables() ).thenReturn( new LinkedList<LogicalTable>() { {
      add( logicalTable );
    } } );

  when( logicalTable.getProperty( eq( DefaultPropertyID.TABLE_TYPE.getId() ) ) ).thenReturn( TableType.DIMENSION );
  when( logicalTable.getProperty( eq( DefaultIDs.LOGICAL_TABLE_DIMENSION_TYPE ) ) ).thenReturn( DimensionType.JUNK_DIMENSION.name() );

  final List<TransMeta> transMetas = jobGenerator.generateDimensionTransformations();

  assertNotNull( transMetas );
  assertEquals( 1, transMetas.size() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:23,代码来源:JobGeneratorTest.java

示例8: handleFormula

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
public void handleFormula( LogicalModel model, LogicalTable table, String databaseToTest, String mqlFormula,
    String expectedSql ) {
  // retrieve various databases here
  DatabaseMeta databaseMeta = new DatabaseMeta( "", databaseToTest, "Native", "", "", "", "", "" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
  try {
    SqlOpenFormula formula = new SqlOpenFormula( model, table, databaseMeta, mqlFormula, null, null, false );
    formula.parseAndValidate();
    String sql = formula.generateSQL( "en_US" ); //$NON-NLS-1$
    Assert.assertNotNull( sql );
    sql = sql.trim();
    Assert.assertEquals( expectedSql, sql );
  } catch ( Exception e ) {
    e.printStackTrace();
    Assert.fail();
  }
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:17,代码来源:SqlOpenFormulaIT.java

示例9: testModelAggFunctions

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testModelAggFunctions() throws Exception {
  LogicalModel model = getDefaultModel();
  LogicalColumn bc2 = model.findLogicalColumn( "bc2" ); //$NON-NLS-1$
  LogicalColumn bcs1 = model.findLogicalColumn( "bcs1" ); //$NON-NLS-1$

  DatabaseMeta databaseMeta = new DatabaseMeta( "", "ORACLE", "Native", "", "", "", "", "" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
  Query myTest = new Query( null, model );

  myTest.getSelections().add( new AliasedSelection( null, bcs1, null, "alias1" ) );
  myTest.getSelections().add( new AliasedSelection( null, bc2, null, null ) );
  myTest.getSelections().add( new AliasedSelection( null, bcs1, null, null ) );

  myTest.getConstraints().add( new Constraint( CombinationType.AND, "[bt2.bc2] > 10" ) );
  myTest.getConstraints().add( new Constraint( CombinationType.AND, "[alias1.bcs1] >= 30" ) );
  // SQLQueryTest.printOutJava(new AdvancedSqlGenerator().generateSql(myTest, "en_US", null,
  // databaseMeta).getQuery());
  TestHelper.assertEqualsIgnoreWhitespaces( "SELECT \n" + "          SUM(bt1_alias1.pc1) AS COL0\n"
      + "         ,bt2.pc2 AS COL1\n" + "         ,SUM(bt1.pc1) AS COL2\n" + "FROM \n" + "          pt1 bt1\n"
      + "         ,pt2 bt2\n" + "         ,pt1 bt1_alias1\n" + "WHERE \n" + "          (\n"
      + "             bt1.pc1 = bt2.pc2\n" + "          )\n" + "      AND (\n"
      + "             bt1_alias1.pc1 = bt2.pc2\n" + "          )\n" + "      AND ((\n"
      + "              bt2.pc2  > 10\n" + "          ))\n" + "GROUP BY \n" + "          bt2.pc2\n" + "HAVING \n"
      + "          (\n" + "              SUM(bt1_alias1.pc1)  >= 30\n" + "          )\n", new AdvancedSqlGenerator()
      .generateSql( myTest, "en_US", null, databaseMeta ).getQuery() );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:27,代码来源:AdvancedQueryIT.java

示例10: testGetUniqueLogicalTables

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testGetUniqueLogicalTables() throws Exception {
  final LogicalModel logicalModel = mock( LogicalModel.class );
  when( jobGenerator.domain.getLogicalModels() ).thenReturn( new LinkedList<LogicalModel>() { {
      add( logicalModel );
    } } );

  final LogicalTable logicalTable = mock( LogicalTable.class );
  when( logicalTable.getProperty( eq( DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME ) ) )
      .thenReturn( "test_table_name" );
  when( logicalModel.getLogicalTables() ).thenReturn( new LinkedList<LogicalTable>() { {
      add( logicalTable );
    } } );

  final List<LogicalTable> uniqueLogicalTables = jobGenerator.getUniqueLogicalTables();

  assertNotNull( uniqueLogicalTables );
  assertEquals( 1, uniqueLogicalTables.size() );
  assertEquals( logicalTable, uniqueLogicalTables.get( 0 ) );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:JobGeneratorTest.java

示例11: testDegenerateViewGen

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testDegenerateViewGen() throws Exception {
  LogicalModel businessModel = getTestModel( TargetTableType.INLINE_SQL, "select * from customer", "" );
  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"
      + "</Schema>", data );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:18,代码来源:MondrianModelExporterTest.java

示例12: 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 );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:23,代码来源:MondrianModelExporterTest.java

示例13: testWriteAndParseLevelFormatter

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testWriteAndParseLevelFormatter() throws Exception {
  Domain domain = parser.parseXmi( getClass().getResourceAsStream( "/example_olap.xmi" ) );
  LogicalModel analysisModel = domain.getLogicalModels().get( 0 );
  @SuppressWarnings( "unchecked" )
  List<OlapDimension> dims = (List<OlapDimension>) analysisModel.getProperty( LogicalModel.PROPERTY_OLAP_DIMS );

  OlapHierarchyLevel firstLevel = dims.get( 0 ).getHierarchies().get( 0 ).getHierarchyLevels().get( 0 );
  firstLevel.setFormatter( "InlineMemberFormatter" );

  String xmi = parser.generateXmi( domain );
  assertTrue( xmi.contains( "<CWM:TaggedValue tag=\"HIERARCHY_LEVEL_FORMATTER\" value=\"InlineMemberFormatter\"" ) );

  domain = parser.parseXmi( new ByteArrayInputStream( xmi.getBytes() ) );
  analysisModel = domain.getLogicalModels().get( 0 );
  @SuppressWarnings( "unchecked" )
  List<OlapDimension> parsedDims = (List<OlapDimension>) analysisModel.getProperty( LogicalModel.PROPERTY_OLAP_DIMS );
  firstLevel = parsedDims.get( 0 ).getHierarchies().get( 0 ).getHierarchyLevels().get( 0 );
  assertEquals( "InlineMemberFormatter", firstLevel.getFormatter() );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:21,代码来源:XmiParserIT.java

示例14: testUnquotedTargetTable

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testUnquotedTargetTable() throws Exception {
  LogicalModel businessModel = getTestModel( TargetTableType.TABLE, "tableName", "schemaName" );
  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"
      + "    <Table name=\"tableName\" schema=\"schemaName\" />\n"
      + "      <Level name=\"Lvl1\" uniqueMembers=\"false\" column=\"pc1\" type=\"Numeric\">\n" + "      </Level>\n"
      + "    </Hierarchy>\n" + "  </Dimension>\n" + "  <Cube name=\"Cube1\">\n"
      + "    <Table name=\"tableName\" schema=\"schemaName\" />\n"
      + "    <DimensionUsage name=\"Dim1\" source=\"Dim1\" foreignKey=\"pc2\"/>\n"
      + "    <Measure name=\"bc1\" column=\"pc1\" aggregator=\"sum\"/>\n" + "  </Cube>\n"
      + "</Schema>", data );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:17,代码来源:MondrianModelExporterTest.java

示例15: testLimitedQuery

import org.pentaho.metadata.model.LogicalModel; //导入依赖的package包/类
@Test
public void testLimitedQuery() throws Exception {
  LogicalModel model = TestHelper.buildDefaultModel();
  LogicalColumn bc1 = model.findLogicalColumn( "bc1" );
  DatabaseMeta databaseMeta = new DatabaseMeta( "", "HYPERSONIC", "Native", "", "", "", "", "" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
  Query query = new Query( null, model );
  query.setLimit( 10 );

  query.getSelections().add( new Selection( null, bc1, null ) );

  SqlGenerator generator = new SqlGenerator();

  MappedQuery mquery = generator.generateSql( query, "en_US", null, databaseMeta );

  TestHelper.assertEqualsIgnoreWhitespaces( "SELECT TOP 10 DISTINCT bt1.pc1 AS COL0 FROM pt1 bt1", mquery.getQuery() );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:17,代码来源:SqlGeneratorIT.java


注:本文中的org.pentaho.metadata.model.LogicalModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。