Search in sources :

Example 6 with JoinTableModel

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));
}
Also used : JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) ArrayList(java.util.ArrayList) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Example 7 with JoinTableModel

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());
}
Also used : JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) JoinRelationshipModel(org.pentaho.agilebi.modeler.models.JoinRelationshipModel)

Example 8 with JoinTableModel

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);
    }
}
Also used : JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) ArrayList(java.util.ArrayList) JoinRelationshipModel(org.pentaho.agilebi.modeler.models.JoinRelationshipModel) HashSet(java.util.HashSet)

Example 9 with JoinTableModel

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;
        }
    });
}
Also used : JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) JoinFieldModel(org.pentaho.agilebi.modeler.models.JoinFieldModel) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Example 10 with JoinTableModel

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);
    }
}
Also used : JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel)

Aggregations

JoinTableModel (org.pentaho.agilebi.modeler.models.JoinTableModel)11 ArrayList (java.util.ArrayList)6 JoinRelationshipModel (org.pentaho.agilebi.modeler.models.JoinRelationshipModel)4 JoinFieldModel (org.pentaho.agilebi.modeler.models.JoinFieldModel)3 SchemaModel (org.pentaho.agilebi.modeler.models.SchemaModel)3 LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)3 BindingFactory (org.pentaho.ui.xul.binding.BindingFactory)2 GwtBindingFactory (org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)2 AbstractModelList (org.pentaho.ui.xul.util.AbstractModelList)2 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 MultiTableDatasourceDTO (org.pentaho.platform.dataaccess.datasource.wizard.service.impl.MultiTableDatasourceDTO)1 XulException (org.pentaho.ui.xul.XulException)1 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)1 XulMenuList (org.pentaho.ui.xul.components.XulMenuList)1