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;
}
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();
}
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();
}
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;
}
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);
}
}
Aggregations