use of org.pentaho.metadata.model.LogicalRelationship in project data-access by pentaho.
the class MultitableGuiModel method generateLogicalRelationships.
@Deprecated
public List<LogicalRelationship> generateLogicalRelationships(List<JoinRelationshipModel> joins) {
String locale = LocalizedString.DEFAULT_LOCALE;
List<LogicalRelationship> logicalRelationships = new ArrayList<LogicalRelationship>();
for (JoinRelationshipModel join : joins) {
LogicalTable fromTable = new LogicalTable();
fromTable.setName(new LocalizedString(locale, join.getLeftKeyFieldModel().getParentTable().getName()));
LogicalTable toTable = new LogicalTable();
toTable.setName(new LocalizedString(locale, join.getRightKeyFieldModel().getParentTable().getName()));
LogicalColumn fromColumn = new LogicalColumn();
fromColumn.setName(new LocalizedString(locale, join.getLeftKeyFieldModel().getName()));
LogicalColumn toColumn = new LogicalColumn();
toColumn.setName(new LocalizedString(locale, join.getRightKeyFieldModel().getName()));
LogicalRelationship logicalRelationship = new LogicalRelationship();
logicalRelationship.setFromTable(fromTable);
logicalRelationship.setToTable(toTable);
logicalRelationship.setFromColumn(fromColumn);
logicalRelationship.setToColumn(toColumn);
logicalRelationships.add(logicalRelationship);
}
return logicalRelationships;
}
use of org.pentaho.metadata.model.LogicalRelationship in project pentaho-kettle by pentaho.
the class StarModelDialog method getRelationshipsFromFact.
protected void getRelationshipsFromFact() {
logicalRelationships = new ArrayList<LogicalRelationship>();
getFactColumns();
for (LogicalColumn column : factTable.getLogicalColumns()) {
String dimensionName = ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_DIMENSION_NAME);
if (!Utils.isEmpty(dimensionName)) {
LogicalTable dimensionTable = ConceptUtil.findDimensionWithName(logicalModel, dimensionName, locale);
if (dimensionTable != null) {
LogicalColumn tk = ConceptUtil.findLogicalColumn(dimensionTable, AttributeType.TECHNICAL_KEY);
if (tk == null) {
tk = ConceptUtil.findLogicalColumn(dimensionTable, AttributeType.SMART_TECHNICAL_KEY);
}
if (tk != null) {
LogicalTable fromTable = factTable;
LogicalColumn fromColumn = column;
LogicalTable toTable = dimensionTable;
LogicalColumn toColumn = tk;
LogicalRelationship relationship = new LogicalRelationship(logicalModel, fromTable, toTable, fromColumn, toColumn);
logicalRelationships.add(relationship);
}
}
}
}
}
use of org.pentaho.metadata.model.LogicalRelationship 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);
}
}
Aggregations