use of org.pentaho.agilebi.modeler.models.JoinTableModel in project data-access by pentaho.
the class MultitableGuiModel method processAvailableTables.
public void processAvailableTables(List<String> tables) {
List<JoinTableModel> joinTables = new ArrayList<JoinTableModel>();
if (tables.size() > 0) {
mainLoop: for (String table : tables) {
JoinTableModel joinTable = new JoinTableModel();
joinTable.setName(table);
for (JoinTableModel selectedTable : selectedTables.getChildren()) {
if (selectedTable.equals(joinTable)) {
continue mainLoop;
}
}
joinTables.add(joinTable);
}
Collections.sort(joinTables, new Comparator<JoinTableModel>() {
@Override
public int compare(JoinTableModel joinTableModel, JoinTableModel joinTableModel1) {
return joinTableModel.getName().compareTo(joinTableModel1.getName());
}
});
}
setAvailableTables(new AbstractModelList<JoinTableModel>(joinTables));
}
use of org.pentaho.agilebi.modeler.models.JoinTableModel in project data-access by pentaho.
the class MultitableGuiModel method computeJoins.
private void computeJoins(MultiTableDatasourceDTO dto) {
this.joins.clear();
for (JoinRelationshipModel join : dto.getSchemaModel().getJoins()) {
for (JoinTableModel selectedTable : this.selectedTables) {
if (tablesAreEqual(selectedTable.getName(), join.getLeftKeyFieldModel().getParentTable().getName())) {
join.getLeftKeyFieldModel().getParentTable().setName(selectedTable.getName());
} else {
if (tablesAreEqual(selectedTable.getName(), join.getRightKeyFieldModel().getParentTable().getName())) {
join.getRightKeyFieldModel().getParentTable().setName(selectedTable.getName());
}
}
}
}
this.joins.addAll(dto.getSchemaModel().getJoins());
}
use of org.pentaho.agilebi.modeler.models.JoinTableModel in project data-access by pentaho.
the class TablesSelectionStep method checkExistingJoinsStillValid.
private void checkExistingJoinsStillValid() {
Set<String> allTables = new HashSet<String>();
for (JoinTableModel tbl : joinGuiModel.getSelectedTables()) {
allTables.add(tbl.getName());
}
List<JoinRelationshipModel> toRemove = new ArrayList<JoinRelationshipModel>();
for (JoinRelationshipModel join : joinGuiModel.getJoins()) {
if (!allTables.contains(join.getLeftKeyFieldModel().getParentTable().getName()) || !allTables.contains(join.getRightKeyFieldModel().getParentTable().getName())) {
toRemove.add(join);
}
}
for (JoinRelationshipModel join : toRemove) {
joinGuiModel.getJoins().remove(join);
}
}
use of org.pentaho.agilebi.modeler.models.JoinTableModel in project data-access by pentaho.
the class JoinDefinitionsStep method setBindings.
public void setBindings() {
BindingFactory bf = new GwtBindingFactory(document);
bf.createBinding(this.joinGuiModel.getLeftTables(), "children", this.leftTables, "elements");
bf.createBinding(this.joinGuiModel.getRightTables(), "children", this.rightTables, "elements");
bf.createBinding(this.leftTables, "selectedItem", this.joinGuiModel, "leftJoinTable");
bf.createBinding(this.rightTables, "selectedItem", this.joinGuiModel, "rightJoinTable");
bf.createBinding(this.joinGuiModel.getJoins(), "children", this.joinsList, "elements");
bf.createBinding(this.joinsList, "selectedItem", this.joinGuiModel, "selectedJoin");
bf.createBinding(this.leftTables, "selectedItem", this.leftKeyFieldList, "elements", new TableSelectionConvertor(this.leftTables));
bf.createBinding(this.rightTables, "selectedItem", this.rightKeyFieldList, "elements", new TableSelectionConvertor(this.rightTables));
this.leftKeyFieldBinding = bf.createBinding(this.leftKeyFieldList, "selectedIndex", this.joinGuiModel, "leftKeyField", new BindingConvertor<Integer, JoinFieldModel>() {
@Override
public JoinFieldModel sourceToTarget(final Integer index) {
JoinTableModel joinTable = joinGuiModel.getLeftJoinTable();
if (joinTable != null) {
List<JoinFieldModel> fields = joinTable.getFields();
if (index == -1 || fields.isEmpty()) {
return null;
}
return fields.get(index);
}
return null;
}
@Override
public Integer targetToSource(final JoinFieldModel value) {
return null;
}
});
this.rightKeyFieldBinding = bf.createBinding(this.rightKeyFieldList, "selectedIndex", this.joinGuiModel, "rightKeyField", new BindingConvertor<Integer, JoinFieldModel>() {
@Override
public JoinFieldModel sourceToTarget(final Integer index) {
JoinTableModel joinTable = joinGuiModel.getRightJoinTable();
if (joinTable != null) {
List<JoinFieldModel> fields = joinTable.getFields();
if (index == -1 || fields.isEmpty()) {
return null;
}
return fields.get(index);
}
return null;
}
@Override
public Integer targetToSource(final JoinFieldModel value) {
return null;
}
});
}
use of org.pentaho.agilebi.modeler.models.JoinTableModel in project data-access by pentaho.
the class MultitableGuiModel method computeJoinDefinitionStepTables.
public void computeJoinDefinitionStepTables() {
this.leftTables.clear();
this.rightTables.clear();
if (this.doOlap) {
this.leftTables.add(this.factTable);
for (JoinTableModel table : this.selectedTables) {
if (table.equals(this.factTable)) {
continue;
} else {
this.rightTables.add(table);
}
}
} else {
this.leftTables.addAll(this.selectedTables);
this.rightTables.addAll(this.selectedTables);
}
}
Aggregations