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


Java AggregationType类代码示例

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


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

示例1: addOrderBy

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
protected void addOrderBy( Query query, Category category, String columnId, String aggregation, Order.Type orderType )
  throws PentahoMetadataException {

  if ( category == null ) {
    throw new PentahoMetadataException( Messages.getErrorString( "QueryXmlHelper.ERROR_0016_BUSINESS_CATEGORY_NULL" ) ); //$NON-NLS-1$ 
  }

  LogicalColumn column = category.findLogicalColumn( columnId );
  if ( column == null ) {
    throw new PentahoMetadataException( Messages.getErrorString(
        "QueryXmlHelper.ERROR_0013_BUSINESS_COL_NOT_FOUND", category.getId(), columnId ) ); //$NON-NLS-1$ 
  }

  // this code verifies the aggregation setting provided is a
  // valid option
  AggregationType aggsetting = null;
  if ( aggregation != null ) {
    AggregationType setting = AggregationType.valueOf( aggregation.toUpperCase() );
    if ( ( column.getAggregationType() == setting ) || column.getAggregationList() != null
        && column.getAggregationList().contains( setting ) ) {
      aggsetting = setting;
    }
  }

  query.getOrders().add( new Order( new Selection( category, column, aggsetting ), orderType ) );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:27,代码来源:QueryXmlHelper.java

示例2: convertAggType

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
private int convertAggType( AggregationType type ) {
  switch ( type ) {
    case NONE:
      return GroupByMeta.TYPE_GROUP_NONE;
    case AVERAGE:
      return GroupByMeta.TYPE_GROUP_AVERAGE;
    case SUM:
      return GroupByMeta.TYPE_GROUP_SUM;
    case COUNT:
      return GroupByMeta.TYPE_GROUP_COUNT_ALL;
    case COUNT_DISTINCT:
      return GroupByMeta.TYPE_GROUP_COUNT_DISTINCT;
    case MINIMUM:
      return GroupByMeta.TYPE_GROUP_MIN;
    case MAXIMUM:
      return GroupByMeta.TYPE_GROUP_MAX;
    default:
      return GroupByMeta.TYPE_GROUP_NONE;
  }
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:21,代码来源:InlineEtlQueryExecutor.java

示例3: testMultiTableColumnFormulasAggregate

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
/**
 * In this test we try to see to it :<br>
 * - that the formula engine picks the 2 specified columns from 2 different business tables<br>
 * - that we calculate the sum of the multiplication <br>
 */
@Test
public void testMultiTableColumnFormulasAggregate() throws Exception {
  LogicalColumn quantityOrdered = getOrdersModel().findLogicalColumn( "BC_ORDER_DETAILS_QUANTITYORDERED" );
  Assert.assertNotNull( "Expected to find the business column 'quantity ordered'", quantityOrdered );
  LogicalColumn buyPrice = getOrdersModel().findLogicalColumn( "BC_PRODUCTS_BUYPRICE" );
  Assert.assertNotNull( "Expected to find the business column 'buy price'", buyPrice );

  // let's remove the aggregations of the quantity ordered...
  //
  AggregationType qaBackup = quantityOrdered.getAggregationType();
  AggregationType paBackup = buyPrice.getAggregationType();
  quantityOrdered.setAggregationType( AggregationType.NONE );
  buyPrice.setAggregationType( AggregationType.NONE );

  // This changes the expected result...
  //
  String formula = "SUM( [BT_ORDER_DETAILS.BC_ORDER_DETAILS_QUANTITYORDERED] * [BT_PRODUCTS.BC_PRODUCTS_BUYPRICE] )";
  String sql = "SUM( BT_ORDER_DETAILS.QUANTITYORDERED  *  BT_PRODUCTS.BUYPRICE )";

  handleFormula( getOrdersModel(), "Hypersonic", formula, sql );

  // Set it back to the way it was for further testing.
  quantityOrdered.setAggregationType( qaBackup );
  buyPrice.setAggregationType( paBackup );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:31,代码来源:SqlOpenFormulaIT.java

示例4: testMultiTableColumnFormulasAggregate2

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
/**
 * In this test we try to test :<br>
 * - if the formula engine picks the 2 specified columns from 2 different business tables<br>
 * - if we calculate the multiplication of the sums <br>
 */
@Test
public void testMultiTableColumnFormulasAggregate2() throws Exception {
  LogicalColumn quantityOrdered = getOrdersModel().findLogicalColumn( "BC_ORDER_DETAILS_QUANTITYORDERED" );
  Assert.assertNotNull( "Expected to find the business column 'quantity ordered'", quantityOrdered );
  LogicalColumn buyPrice = getOrdersModel().findLogicalColumn( "BC_PRODUCTS_BUYPRICE" );
  Assert.assertNotNull( "Expected to find the business column 'buy price'", buyPrice );

  // let's enable the aggregations of the quantity ordered...
  //
  AggregationType qaBackup = quantityOrdered.getAggregationType();
  AggregationType paBackup = buyPrice.getAggregationType();
  quantityOrdered.setAggregationType( AggregationType.SUM );
  buyPrice.setAggregationType( AggregationType.SUM );

  // This changes the expected result...
  //
  String formula = "[BT_ORDER_DETAILS.BC_ORDER_DETAILS_QUANTITYORDERED] * [BT_PRODUCTS.BC_PRODUCTS_BUYPRICE]";
  String sql = "SUM(BT_ORDER_DETAILS.QUANTITYORDERED)  *  SUM(BT_PRODUCTS.BUYPRICE)";

  handleFormula( getOrdersModel(), "Hypersonic", formula, sql );

  // Set it back to the way it was for further testing.
  quantityOrdered.setAggregationType( qaBackup );
  buyPrice.setAggregationType( paBackup );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:31,代码来源:SqlOpenFormulaIT.java

示例5: getAggregationType

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
private AggregationType getAggregationType( AggType type ) {
  if ( type == null ) {
    return null;
  }
  switch ( type ) {
    case COUNT:
      return AggregationType.COUNT;
    case COUNT_DISTINCT:
      return AggregationType.COUNT_DISTINCT;
    case AVERAGE:
      return AggregationType.AVERAGE;
    case MAX:
      return AggregationType.MAXIMUM;
    case MIN:
      return AggregationType.MINIMUM;
    case SUM:
      return AggregationType.SUM;
    default:
      return AggregationType.NONE;
  }
}
 
开发者ID:pentaho,项目名称:mql-editor,代码行数:22,代码来源:MQLEditorServiceCWMDelegate.java

示例6: convertNewThinAggregationType

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
protected AggType convertNewThinAggregationType( AggregationType aggregationType ) {
  if ( aggregationType == null ) {
    return AggType.NONE;
  }

  switch ( aggregationType ) {
    case COUNT:
      return AggType.COUNT;
    case COUNT_DISTINCT:
      return AggType.COUNT_DISTINCT;
    case AVERAGE:
      return AggType.AVERAGE;
    case MINIMUM:
      return AggType.MIN;
    case MAXIMUM:
      return AggType.MAX;
    case SUM:
      return AggType.SUM;
    case NONE:
    default:
      return AggType.NONE;
  }
}
 
开发者ID:pentaho,项目名称:mql-editor,代码行数:24,代码来源:MQLEditorServiceDelegate.java

示例7: getActiveAggregationType

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
public AggregationType getActiveAggregationType() {
  if ( getAggregationType() == null ) {
    AggregationType aggType = logicalColumn.getAggregationType();
    if ( aggType == null ) {
      return AggregationType.NONE;
    } else {
      return aggType;
    }
  } else {
    return getAggregationType();
  }
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:13,代码来源:Selection.java

示例8: PropertyTypeRegistry

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
public PropertyTypeRegistry() {
  // load these from a spring config file?
  addPropertyType( String.class );
  addPropertyType( LocalizedString.class );
  addPropertyType( DataType.class );
  addPropertyType( TargetTableType.class );
  addPropertyType( TargetColumnType.class );
  addPropertyType( AggregationType.class );

  // this is for agg lists,
  // we will need another way to express lists
  addPropertyType( List.class );

  addPropertyType( Alignment.class );
  addPropertyType( Color.class );
  addPropertyType( ColumnWidth.class );
  addPropertyType( FieldType.class );
  addPropertyType( Font.class );
  addPropertyType( TableType.class );
  addPropertyType( RowLevelSecurity.class );
  addPropertyType( Security.class );
  addPropertyType( Double.class );
  addPropertyType( Boolean.class );
  addPropertyType( Date.class );

  // note that URL is not GWT compatible, we'll need to figure out what to do with this
  // once we move towards a fully supported thin client metadata editor
  addPropertyType( URL.class );

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

示例9: convertToMondrian

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
public static String convertToMondrian( AggregationType aggregationType ) {
  String typeDesc = null;
  switch ( aggregationType ) {
    case NONE:
      typeDesc = "none"; //$NON-NLS-1$
      break;
    case SUM:
      typeDesc = "sum"; //$NON-NLS-1$
      break;
    case AVERAGE:
      typeDesc = "avg"; //$NON-NLS-1$
      break;
    case COUNT:
      typeDesc = "count"; //$NON-NLS-1$
      break;
    case COUNT_DISTINCT:
      typeDesc = "distinct count"; //$NON-NLS-1$
      break;
    case MINIMUM:
      typeDesc = "min"; //$NON-NLS-1$
      break;
    case MAXIMUM:
      typeDesc = "max"; //$NON-NLS-1$
      break;
  }
  return typeDesc;
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:28,代码来源:MondrianModelExporter.java

示例10: testOrderByQuotedSQLGeneration

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
@Test
public void testOrderByQuotedSQLGeneration() {
  try {

    LogicalModel model = TestHelper.buildDefaultModel();
    LogicalColumn bc1 = model.findLogicalColumn( "bc1" );
    bc1.setProperty( IPhysicalColumn.AGGREGATIONTYPE_PROPERTY, AggregationType.SUM );
    LogicalColumn bc2 = model.findLogicalColumn( "bc2" );
    LogicalColumn bce2 = model.findLogicalColumn( "bce2" );
    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$ //$NON-NLS-8$
    databaseMeta.setQuoteAllFields( true );
    Query query = new Query( null, model );

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

    query.getConstraints().add( new Constraint( CombinationType.AND, "[bt1.bc1] > 25" ) ); //$NON-NLS-1$

    query.getOrders().add( new Order( new Selection( null, bc1, null ), Type.ASC ) );

    SqlGenerator generator = new SqlGenerator();

    MappedQuery mquery = generator.generateSql( query, "en_US", null, databaseMeta );
    // TestHelper.printOutJava(mquery.getQuery());

    TestHelper.assertEqualsIgnoreWhitespaces( "SELECT \n" + "          SUM(\"bt1\".\"pc1\") AS \"COL0\"\n"
        + "         ,\"bt2\".\"pc2\" AS \"COL1\"\n" + "         , \"bt2\".\"pc2\"  * 2 AS \"COL2\"\n" + "FROM \n"
        + "          \"pt1\" \"bt1\"\n" + "         ,\"pt2\" \"bt2\"\n" + "WHERE \n"
        + "          ( \"bt1\".\"pc1\" = \"bt2\".\"pc2\" )\n" + "GROUP BY \n" + "          \"bt2\".\"pc2\"\n"
        + "         , \"bt2\".\"pc2\"  * 2\n" + "HAVING \n" + "          (\n"
        + "              SUM(\"bt1\".\"pc1\")  > 25\n" + "          )\n" + "ORDER BY \n" + "          \"COL0\"\n",
        mquery.getQuery() );

  } catch ( Exception e ) {
    e.printStackTrace();
    Assert.fail();
  }
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:40,代码来源:SqlGeneratorIT.java

示例11: testQueryExecutionWithAggregationsAndConstraints

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
@Test
public void testQueryExecutionWithAggregationsAndConstraints() throws Exception {

  List<String> users = new ArrayList<String>();
  users.add( "suzy" );
  List<String> roles = new ArrayList<String>();
  roles.add( "Authenticated" );
  int defaultAcls = 31;
  InlineEtlModelGenerator gen =
      new InlineEtlModelGenerator( "testmodel", csvFilesPath, "example.csv", true,
          ",", "\"", true, users, roles, defaultAcls, "joe" );

  Domain domain = gen.generate();

  LogicalModel model = domain.getLogicalModels().get( 0 );
  Category category = model.getCategories().get( 0 );
  category.getLogicalColumns().get( 1 ).setDataType( DataType.NUMERIC );
  category.getLogicalColumns().get( 1 ).setAggregationType( AggregationType.SUM );
  Query query = new Query( domain, model );

  query.getSelections().add( new Selection( category, category.getLogicalColumns().get( 3 ), null ) );
  query.getSelections().add( new Selection( category, category.getLogicalColumns().get( 1 ), null ) );
  query.getConstraints().add( new Constraint( CombinationType.AND, "[bc_testmodel.bc_1_Data2] > 4.0" ) );
  query.getOrders().add(
      new Order( new Selection( category, category.getLogicalColumns().get( 3 ), null ), Order.Type.DESC ) );

  InlineEtlQueryExecutor executor = new InlineEtlQueryExecutor();
  IPentahoResultSet resultset = executor.executeQuery( query, csvFilesPath, null );

  Assert.assertEquals( 2, resultset.getRowCount() );
  Assert.assertEquals( 2, resultset.getColumnCount() );
  Assert.assertEquals( "bc_3_Data4", resultset.getMetaData().getColumnHeaders()[0][0] );
  Assert.assertEquals( "bc_1_Data2", resultset.getMetaData().getColumnHeaders()[0][1] );

  Assert.assertEquals( "String Value", resultset.getValueAt( 0, 0 ) );
  Assert.assertEquals( "Bigger String Value", resultset.getValueAt( 1, 0 ) );

  Assert.assertEquals( 19.5, resultset.getValueAt( 0, 1 ) );
  Assert.assertEquals( 5.7, resultset.getValueAt( 1, 1 ) );
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:41,代码来源:InlineEtlModelGeneratorIT.java

示例12: createLogicalTable

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
private LogicalTable createLogicalTable( String tblId, LogicalModel model, Category mainCat ) throws Exception {

    LogicalTable rtn = new LogicalTable();
    rtn.setId( "bt_" + tblId );
    rtn.setProperty( SqlPhysicalTable.TARGET_TABLE, "pt_" + tblId ); //$NON-NLS-1$
    createBusinessKeyColumn( tblId, "keya", rtn, mainCat ); // 0
    createBusinessKeyColumn( tblId, "keyb", rtn, mainCat ); // 1
    createBusinessKeyColumn( tblId, "keyc", rtn, mainCat ); // 2
    createBusinessKeyColumn( tblId, "keyd", rtn, mainCat ); // 3
    createBusinessKeyColumn( tblId, "keye", rtn, mainCat ); // 4
    createBusinessKeyColumn( tblId, "keyf", rtn, mainCat ); // 5
    createBusinessKeyColumn( tblId, "keyg", rtn, mainCat ); // 6
    createBusinessKeyColumn( tblId, "keyh", rtn, mainCat ); // 7
    createBusinessKeyColumn( tblId, "keyi", rtn, mainCat ); // 8
    createBusinessKeyColumn( tblId, "keyj", rtn, mainCat ); // 9
    createBusinessKeyColumn( tblId, "keyk", rtn, mainCat ); // 10
    createBusinessKeyColumn( tblId, "keyl", rtn, mainCat ); // 11

    LogicalColumn bcs1 = new LogicalColumn();
    bcs1.setId( "bcs_" + tblId );
    bcs1.setProperty( SqlPhysicalColumn.TARGET_COLUMN, "pc_" + tblId ); //$NON-NLS-1$
    bcs1.setProperty( IPhysicalColumn.AGGREGATIONTYPE_PROPERTY, AggregationType.SUM );
    bcs1.setLogicalTable( rtn );
    rtn.addLogicalColumn( bcs1 );
    mainCat.addLogicalColumn( bcs1 );
    model.addLogicalTable( rtn );
    return rtn;

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

示例13: setup

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
@Before
public void setup() {

  String locale = LocaleHelper.getLocale().toString();

  SqlPhysicalModel model = new SqlPhysicalModel();
  SqlDataSource dataSource = new SqlDataSource();
  dataSource.setDatabaseName( "SampleData" );
  model.setDatasource( dataSource );
  SqlPhysicalTable table = new SqlPhysicalTable( model );
  model.getPhysicalTables().add( table );
  table.setTargetTableType( TargetTableType.INLINE_SQL );
  table.setTargetTable( "select * from customers" );
  table.setId( "customers" );

  SqlPhysicalColumn column = new SqlPhysicalColumn( table );
  column.setTargetColumn( "customername" );
  column.setName( new LocalizedString( locale, "Customer Name" ) );
  column.setDescription( new LocalizedString( locale, "Customer Name Desc" ) );
  column.setDataType( DataType.STRING );
  column.setId( "cutomer_customername" );

  table.getPhysicalColumns().add( column );

  LogicalModel logicalModel = new LogicalModel();
  model.setId( "MODEL" );
  model.setName( new LocalizedString( locale, "My Model" ) );
  model.setDescription( new LocalizedString( locale, "A Description of the Model" ) );

  LogicalTable logicalTable = new LogicalTable();
  logicalTable.setId( "BT_CUSTOMERS" );
  logicalTable.setPhysicalTable( table );

  logicalModel.getLogicalTables().add( logicalTable );
  logicalModel.setName( new LocalizedString( locale, "My Model" ) );

  logicalColumn1 = new LogicalColumn();
  logicalColumn1.setId( "LC_CUSTOMERNAME" );
  logicalColumn1.setPhysicalColumn( column );
  logicalColumn1.setAggregationType( AggregationType.COUNT );
  logicalColumn1.setLogicalTable( logicalTable );
  logicalColumn1.setDataType( DataType.STRING );

  logicalColumn2 = new LogicalColumn();
  logicalColumn2.setId( "LC_CUSTOMERNUMBER" );
  logicalColumn2.setAggregationType( AggregationType.COUNT );
  logicalColumn2.setPhysicalColumn( column );
  logicalColumn2.setLogicalTable( logicalTable );
  logicalColumn2.setDataType( DataType.NUMERIC );


  logicalTable.addLogicalColumn( logicalColumn1 );
  logicalTable.addLogicalColumn( logicalColumn2 );


  domain = new Domain();
  domain.addPhysicalModel( model );
  domain.addLogicalModel( logicalModel );

  physicalColumn = column;

  SqlPhysicalColumn column2 = new SqlPhysicalColumn( table );
  column2.setTargetColumn( "customername" );
  column2.setName( new LocalizedString( locale, "Customer Number" ) );
  column2.setDescription( new LocalizedString( locale, "Customer Number" ) );
  column2.setDataType( DataType.NUMERIC );
  column2.setId( "customer_customernumber" );

  physicalColumn2 = column2;

  table.getPhysicalColumns().add( physicalColumn2 );
}
 
开发者ID:pentaho,项目名称:pdi-agile-bi-plugin,代码行数:73,代码来源:WorkspaceTest.java

示例14: importPhysicalColumnDefinition

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
private static IPhysicalColumn importPhysicalColumnDefinition( ValueMetaInterface v, SqlPhysicalTable physicalTable,
                                                               String locale,
                                                               final ImportStrategy importStrategy ) {
   // The name of the column in the database
  //
  String columnName = v.getName();

  // The field type?
  //
  FieldType fieldType = FieldType.guessFieldType( v.getName() );

  // Create a physical column.
  //
  SqlPhysicalColumn physicalColumn = new SqlPhysicalColumn( physicalTable );
  physicalColumn.setId( v.getName() );
  physicalColumn.setTargetColumn( columnName );
  physicalColumn.setFieldType( fieldType );
  physicalColumn.setAggregationType( AggregationType.NONE );

  // Set the localized name...
  //
  String niceName = beautifyName( importStrategy.displayName( v ) );
  physicalColumn.setName( new LocalizedString( locale, niceName ) );

  // Set the parent concept to the base concept...
  // physicalColumn.getConcept().setParentInterface(schemaMeta.findConcept(
  // Settings.getConceptNameBase()));

  // The data type...
  DataType dataType = getDataType( v );
  physicalColumn.setDataType( dataType );

  if ( null != v.getConversionMask() ) {
    physicalColumn.setProperty( "source_mask", v.getConversionMask() );
  }

  if ( null != v.getDecimalSymbol() ) {
    physicalColumn.setProperty( "source_decimalSymbol", v.getDecimalSymbol() );
  }

  if ( null != v.getGroupingSymbol() ) {
    physicalColumn.setProperty( "source_groupingSymbol", v.getGroupingSymbol() );
  }

  if ( null != v.getCurrencySymbol() ) {
    physicalColumn.setProperty( "source_currencySymbol", v.getCurrencySymbol() );
  }

  return physicalColumn;
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:51,代码来源:PhysicalTableImporter.java

示例15: AliasedSelection

import org.pentaho.metadata.model.concept.types.AggregationType; //导入依赖的package包/类
public AliasedSelection( Category category, LogicalColumn column, AggregationType agg, String alias ) {
  super( category, column, agg );
  this.alias = alias;
}
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:5,代码来源:AliasedSelection.java


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