use of org.pentaho.metadata.model.LogicalTable in project pentaho-kettle by pentaho.
the class StarModelPainter method draw.
public void draw() {
gc.setAntialias(true);
Point center = new Point(area.x / 2, area.y / 2);
gc.setBackground(EColor.BACKGROUND);
gc.setForeground(EColor.BLACK);
gc.fillRectangle(0, 0, area.x, area.y);
// gc.drawText("bounds: x="+rect.x+", y="+rect.y+", height="+rect.height+", width="+rect.width, 10, 10);
List<LogicalTable> tableList = new ArrayList<LogicalTable>();
tableList.addAll(logicalModel.getLogicalTables());
// Find the fact...
//
LogicalTable fact = null;
for (LogicalTable logicalTable : tableList) {
if (TableType.FACT == ConceptUtil.getTableType(logicalTable)) {
fact = logicalTable;
}
}
if (fact != null) {
tableList.remove(fact);
}
int maxWidth = Integer.MIN_VALUE;
for (LogicalTable table : tableList) {
String name = table.getName(locale);
if (!Utils.isEmpty(name)) {
Point p = gc.textExtent(name);
if (p.x > maxWidth)
maxWidth = p.x;
}
}
List<TablePoint> points = new ArrayList<TablePoint>();
if (fact != null) {
points.add(new TablePoint(fact, center));
}
//
if (!tableList.isEmpty()) {
List<TablePoint> dimPoints = getCirclePoints(center, center.x - maxWidth / 2 - 20, center.y - 20, tableList);
points.addAll(dimPoints);
}
//
for (LogicalRelationship rel : logicalRelationships) {
LogicalTable fromTable = rel.getFromTable();
LogicalTable toTable = rel.getToTable();
Point from = findPointOfTable(points, fromTable);
Point to = findPointOfTable(points, toTable);
if (from != null && to != null) {
gc.drawLine(from.x, from.y, to.x, to.y);
}
}
//
for (TablePoint tablePoint : points) {
LogicalTable table = tablePoint.logicalTable;
Point point = tablePoint.point;
drawCircleName(point, table);
}
}
use of org.pentaho.metadata.model.LogicalTable in project pentaho-kettle by pentaho.
the class ConceptUtilTest method testFindLogicalColumn.
@Test
public void testFindLogicalColumn() throws Exception {
final LogicalTable logicalTable = mock(LogicalTable.class);
final AttributeType attribute = AttributeType.ATTRIBUTE;
final LogicalColumn logicalColumn1 = mock(LogicalColumn.class);
when(logicalColumn1.getProperty(DefaultIDs.LOGICAL_COLUMN_ATTRIBUTE_TYPE)).thenReturn(attribute.name());
final LogicalColumn logicalColumn2 = mock(LogicalColumn.class);
when(logicalColumn2.getProperty(DefaultIDs.LOGICAL_COLUMN_ATTRIBUTE_TYPE)).thenReturn(attribute.name());
when(logicalTable.getLogicalColumns()).thenReturn(new LinkedList<LogicalColumn>() {
{
add(logicalColumn1);
add(logicalColumn2);
}
});
assertNull(ConceptUtil.findLogicalColumn(logicalTable, AttributeType.ATTRIBUTE_HISTORICAL));
final LogicalColumn result = ConceptUtil.findLogicalColumn(logicalTable, attribute);
assertEquals(logicalColumn1, result);
}
use of org.pentaho.metadata.model.LogicalTable in project pentaho-kettle by pentaho.
the class ConceptUtilTest method testGetDimensionType.
@Test
public void testGetDimensionType() throws Exception {
final LogicalTable logicalTable = mock(LogicalTable.class);
final DimensionType dtDate = DimensionType.DATE;
when(logicalTable.getProperty(DefaultIDs.LOGICAL_TABLE_DIMENSION_TYPE)).thenReturn(dtDate.name());
final DimensionType dimensionType = ConceptUtil.getDimensionType(logicalTable);
assertEquals(dtDate, dimensionType);
}
use of org.pentaho.metadata.model.LogicalTable in project pentaho-platform by pentaho.
the class MetadataQueryComponentIT method getBasicDomain.
public Domain getBasicDomain() {
SqlPhysicalModel model = new SqlPhysicalModel();
SqlDataSource dataSource = new SqlDataSource();
dataSource.setDatabaseName("SampleData");
dataSource.setDialectType("HYPERSONIC");
dataSource.setType(DataSourceType.JNDI);
model.setDatasource(dataSource);
SqlPhysicalTable table = new SqlPhysicalTable(model);
table.setId("PT1");
model.getPhysicalTables().add(table);
table.setTargetTableType(TargetTableType.INLINE_SQL);
table.setTargetTable("select distinct customername, salesrepemployeenumber from customers");
SqlPhysicalColumn column = new SqlPhysicalColumn(table);
column.setId("PC1");
column.setTargetColumn("CUSTOMERNAME");
column.setName(new LocalizedString("en_US", "Customer Name"));
column.setDescription(new LocalizedString("en_US", "Customer Name Desc"));
column.setDataType(DataType.STRING);
table.getPhysicalColumns().add(column);
SqlPhysicalColumn column2 = new SqlPhysicalColumn(table);
column2.setId("PC2");
column2.setTargetColumn("SALESREPEMPLOYEENUMBER");
column2.setName(new LocalizedString("en_US", "Sales Rep"));
column2.setDescription(new LocalizedString("en_US", "Sales Rep Employee Number"));
column2.setDataType(DataType.NUMERIC);
table.getPhysicalColumns().add(column2);
LogicalModel logicalModel = new LogicalModel();
logicalModel.setPhysicalModel(model);
logicalModel.setId("MODEL");
logicalModel.setName(new LocalizedString("en_US", "My Model"));
logicalModel.setDescription(new LocalizedString("en_US", "A Description of the Model"));
LogicalTable logicalTable = new LogicalTable();
logicalTable.setId("LT");
logicalTable.setPhysicalTable(table);
logicalModel.getLogicalTables().add(logicalTable);
LogicalColumn logicalColumn = new LogicalColumn();
logicalColumn.setId("LC_CUSTOMERNAME");
logicalColumn.setPhysicalColumn(column);
logicalColumn.setLogicalTable(logicalTable);
logicalTable.addLogicalColumn(logicalColumn);
LogicalColumn logicalColumn2 = new LogicalColumn();
logicalColumn2.setId("LC_SALESREP");
logicalColumn2.setPhysicalColumn(column2);
logicalColumn2.setLogicalTable(logicalTable);
logicalTable.addLogicalColumn(logicalColumn2);
Category mainCategory = new Category();
mainCategory.setId("CATEGORY");
mainCategory.setName(new LocalizedString("en_US", "Category"));
mainCategory.addLogicalColumn(logicalColumn);
mainCategory.addLogicalColumn(logicalColumn2);
logicalModel.getCategories().add(mainCategory);
Domain domain = new Domain();
domain.setId("DOMAIN");
domain.addPhysicalModel(model);
domain.addLogicalModel(logicalModel);
return domain;
}
Aggregations