/** * 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); }
public ColumnBackedNode createColumnBackedNode( AvailableField field, ModelerPerspective perspective) { String locale = workspaceHelper.getLocale(); ColumnBackedNode node = new BaseColumnBackedMetaData(field.getName()); LogicalTable lTab = findLogicalTable(field.getPhysicalColumn().getPhysicalTable(), perspective); LogicalColumn lCol = null; if (lCol == null) { lCol = new LogicalColumn(); lCol.setLogicalTable(lTab); // lCol.setParentConcept(lTab); lCol.setPhysicalColumn(field.getPhysicalColumn()); lCol.setDataType(field.getPhysicalColumn().getDataType()); if (field.getPhysicalColumn().getAggregationList() != null) { lCol.setAggregationList(field.getPhysicalColumn().getAggregationList()); } if (field.getPhysicalColumn().getAggregationType() != null) { lCol.setAggregationType(field.getPhysicalColumn().getAggregationType()); } lCol.setName(new LocalizedString(locale, field.getPhysicalColumn().getName(locale))); String colId = "LC_" + toId(lTab.getPhysicalTable().getName(locale)) + "_" + toId(field.getPhysicalColumn().getId()); // lCol.setDescription(new LocalizedString(locale, // field.getPhysicalColumn().getName(locale))); if (perspective == ModelerPerspective.ANALYSIS) { colId += BaseModelerWorkspaceHelper.OLAP_SUFFIX; } colId = BaseModelerWorkspaceHelper.uniquify(colId, lTab.getLogicalColumns()); lCol.setId(colId); lTab.addLogicalColumn(lCol); } node.setLogicalColumn(lCol); return node; }