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