Search in sources :

Example 6 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString 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 7 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString 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 8 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.

the class StarModelDialog method ok.

private void ok() {
    if (Utils.isEmpty(wModelName.getText())) {
        MessageBox box = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
        box.setText(BaseMessages.getString(PKG, "StarModelDialog.ErrorModelHasNoName.Title"));
        box.setMessage(BaseMessages.getString(PKG, "StarModelDialog.ErrorModelHasNoName.Message"));
        box.open();
        return;
    }
    logicalModel.setName(new LocalizedString(locale, wModelName.getText()));
    logicalModel.setDescription(new LocalizedString(locale, wModelDescription.getText()));
    factTable.setName(new LocalizedString(locale, wFactTableName.getText()));
    factTable.setDescription(new LocalizedString(locale, wFactTableDescription.getText()));
    factTable.setProperty(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME, wPhysicalFactName.getText());
    String factName = ConceptUtil.getName(factTable, locale);
    System.out.println("Fact name = " + factName + " has " + factTable.getLogicalColumns().size() + " columns");
    // Add the relationships informational
    // 
    getRelationshipsFromFact();
    logicalModel.getLogicalRelationships().clear();
    logicalModel.getLogicalRelationships().addAll(logicalRelationships);
    // System.out.println("Fact name = "+factName+" has "+factTable.getLogicalColumns().size()+" columns");
    // If the fact table is not yet in the table list, add it.
    // If it is, replace it.
    // 
    int factIndex = ConceptUtil.indexOfFactTable(logicalModel);
    if (factIndex < 0) {
        logicalModel.getLogicalTables().add(factTable);
    }
    System.out.println("Fact name = " + factName + " has " + factTable.getLogicalColumns().size() + " columns");
    dispose();
}
Also used : LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 9 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.

the class StarModelDialog method newTable.

protected boolean newTable(Shell shell, LogicalModel logicalModel) {
    LogicalTable logicalTable = new LogicalTable(logicalModel, null);
    logicalTable.setId(UUID.randomUUID().toString());
    logicalTable.setName(new LocalizedString(locale, "New table"));
    logicalTable.setDescription(new LocalizedString(locale, "New table description"));
    DimensionTableDialog dialog = new DimensionTableDialog(shell, logicalTable, locale);
    if (dialog.open() != null) {
        logicalModel.addLogicalTable(logicalTable);
        return true;
    }
    return false;
}
Also used : LogicalTable(org.pentaho.metadata.model.LogicalTable) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Example 10 with LocalizedString

use of org.pentaho.metadata.model.concept.types.LocalizedString 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

LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)25 LogicalColumn (org.pentaho.metadata.model.LogicalColumn)11 LogicalTable (org.pentaho.metadata.model.LogicalTable)10 LogicalModel (org.pentaho.metadata.model.LogicalModel)8 Domain (org.pentaho.metadata.model.Domain)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 Category (org.pentaho.metadata.model.Category)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 TableItem (org.eclipse.swt.widgets.TableItem)3 Matchers.anyString (org.mockito.Matchers.anyString)3 List (java.util.List)2 MessageBox (org.eclipse.swt.widgets.MessageBox)2 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)2 DatabaseConnection (org.pentaho.database.model.DatabaseConnection)2 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)2 Concept (org.pentaho.metadata.model.concept.Concept)2