Search in sources :

Example 11 with LogicalColumn

use of org.pentaho.metadata.model.LogicalColumn in project data-access by pentaho.

the class MetadataServiceUtil method createCategory.

/**
 * Creates a lightweight, serializable category objects from a logical model category
 *
 * @param m
 * @param c
 * @return
 */
private Category createCategory(LogicalModel m, org.pentaho.metadata.model.Category c) {
    // create a thin category object
    Category cat = new Category();
    cat.setName(c.getName(getLocale()));
    cat.setId(c.getId());
    List<Column> columns = new ArrayList<Column>();
    for (LogicalColumn col : c.getLogicalColumns()) {
        columns.add(createColumn(m, col, c));
    }
    cat.setColumns(columns.toArray(new Column[columns.size()]));
    return cat;
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) Category(org.pentaho.platform.dataaccess.metadata.model.impl.Category) LogicalColumn(org.pentaho.metadata.model.LogicalColumn) IPhysicalColumn(org.pentaho.metadata.model.IPhysicalColumn) Column(org.pentaho.platform.dataaccess.metadata.model.impl.Column) ArrayList(java.util.ArrayList)

Example 12 with LogicalColumn

use of org.pentaho.metadata.model.LogicalColumn in project data-access by pentaho.

the class DataAccessServiceTestBase method getDomain.

/**
 * Provide a mock domain
 *
 * @return
 */
private Domain getDomain() {
    LogicalColumn logicalColumn1;
    LogicalColumn logicalColumn2;
    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 thisDomain = new Domain();
    thisDomain.addPhysicalModel(model);
    thisDomain.addLogicalModel(logicalModel);
    return thisDomain;
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) LogicalColumn(org.pentaho.metadata.model.LogicalColumn) SqlDataSource(org.pentaho.metadata.model.SqlDataSource) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) SqlPhysicalColumn(org.pentaho.metadata.model.SqlPhysicalColumn) LogicalTable(org.pentaho.metadata.model.LogicalTable) SqlPhysicalModel(org.pentaho.metadata.model.SqlPhysicalModel) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) Domain(org.pentaho.metadata.model.Domain) SqlPhysicalTable(org.pentaho.metadata.model.SqlPhysicalTable)

Example 13 with LogicalColumn

use of org.pentaho.metadata.model.LogicalColumn in project pentaho-kettle by pentaho.

the class DimensionTableDialog method ok.

private void ok() {
    if (Utils.isEmpty(wTableName.getText())) {
        MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
        box.setText(BaseMessages.getString(PKG, "DimensionTableDialog.ErrorDimensionHasNoName.Title"));
        box.setMessage(BaseMessages.getString(PKG, "DimensionTableDialog.ErrorDimensionHasNoName.Message"));
        box.open();
        return;
    }
    logicalTable.setName(new LocalizedString(locale, wTableName.getText()));
    logicalTable.setDescription(new LocalizedString(locale, wTableDescription.getText()));
    logicalTable.setProperty(DefaultPropertyID.TABLE_TYPE.getId(), TableType.DIMENSION);
    logicalTable.setProperty(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME, wPhysicalName.getText());
    logicalTable.setProperty(DefaultIDs.LOGICAL_TABLE_DIMENSION_TYPE, wDimensionType.getText());
    // name, description, field type, physical column name, data type, length, precision,
    // source db, source table, source column, conversion remarks
    // 
    logicalTable.getLogicalColumns().clear();
    int nr = wAttributes.nrNonEmpty();
    for (int i = 0; i < nr; i++) {
        TableItem item = wAttributes.getNonEmpty(i);
        LogicalColumn logicalColumn = new LogicalColumn();
        logicalColumn.setId(UUID.randomUUID().toString());
        int col = 1;
        logicalColumn.setName(new LocalizedString(locale, item.getText(col++)));
        logicalColumn.setDescription(new LocalizedString(locale, item.getText(col++)));
        String fieldTypeString = item.getText(col++);
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_ATTRIBUTE_TYPE, AttributeType.getAttributeType(fieldTypeString).name());
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_PHYSICAL_COLUMN_NAME, item.getText(col++));
        String dataTypeString = item.getText(col++);
        logicalColumn.setDataType(Utils.isEmpty(dataTypeString) ? null : DataType.valueOf(dataTypeString));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_LENGTH, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_PRECISION, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_SOURCE_DB, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_SOURCE_TABLE, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_SOURCE_COLUMN, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_CONVERSION_REMARKS, item.getText(col++));
        logicalColumn.setLogicalTable(logicalTable);
        logicalTable.getLogicalColumns().add(logicalColumn);
    }
    dispose();
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) TableItem(org.eclipse.swt.widgets.TableItem) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 14 with LogicalColumn

use of org.pentaho.metadata.model.LogicalColumn in project pentaho-kettle by pentaho.

the class StarModelDialog method refreshFactAttributesList.

protected void refreshFactAttributesList() {
    wFactAttributes.clearAll();
    for (LogicalColumn column : factTable.getLogicalColumns()) {
        addLogicalColumnToFactAttributesList(column);
    }
    wFactAttributes.removeEmptyRows();
    wFactAttributes.setRowNums();
    wFactAttributes.optWidth(true);
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn)

Example 15 with LogicalColumn

use of org.pentaho.metadata.model.LogicalColumn in project pentaho-kettle by pentaho.

the class StarModelDialog method getFactColumns.

private void getFactColumns() {
    factTable.getLogicalColumns().clear();
    int nr = wFactAttributes.nrNonEmpty();
    for (int i = 0; i < nr; i++) {
        TableItem item = wFactAttributes.getNonEmpty(i);
        LogicalColumn logicalColumn = new LogicalColumn();
        int col = 1;
        logicalColumn.setId(UUID.randomUUID().toString());
        logicalColumn.setName(new LocalizedString(locale, item.getText(col++)));
        logicalColumn.setDescription(new LocalizedString(locale, item.getText(col++)));
        String fieldTypeString = item.getText(col++);
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_ATTRIBUTE_TYPE, AttributeType.getAttributeType(fieldTypeString).name());
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_PHYSICAL_COLUMN_NAME, item.getText(col++));
        logicalColumn.setDataType(ConceptUtil.getDataType(item.getText(col++)));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_DIMENSION_NAME, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_LENGTH, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_PRECISION, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_SOURCE_DB, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_SOURCE_TABLE, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_SOURCE_COLUMN, item.getText(col++));
        logicalColumn.setProperty(DefaultIDs.LOGICAL_COLUMN_CONVERSION_REMARKS, item.getText(col++));
        logicalColumn.setLogicalTable(factTable);
        factTable.getLogicalColumns().add(logicalColumn);
    }
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) TableItem(org.eclipse.swt.widgets.TableItem) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Aggregations

LogicalColumn (org.pentaho.metadata.model.LogicalColumn)30 LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)16 LogicalTable (org.pentaho.metadata.model.LogicalTable)12 ArrayList (java.util.ArrayList)10 LogicalModel (org.pentaho.metadata.model.LogicalModel)9 Domain (org.pentaho.metadata.model.Domain)8 Category (org.pentaho.metadata.model.Category)7 Test (org.junit.Test)5 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)4 SqlDataSource (org.pentaho.metadata.model.SqlDataSource)4 SqlPhysicalColumn (org.pentaho.metadata.model.SqlPhysicalColumn)4 SqlPhysicalModel (org.pentaho.metadata.model.SqlPhysicalModel)4 SqlPhysicalTable (org.pentaho.metadata.model.SqlPhysicalTable)4 AggregationType (org.pentaho.metadata.model.concept.types.AggregationType)4 Point (org.pentaho.di.core.gui.Point)3 StepMeta (org.pentaho.di.trans.step.StepMeta)3 List (java.util.List)2 Document (org.dom4j.Document)2 Element (org.dom4j.Element)2 TableItem (org.eclipse.swt.widgets.TableItem)2