Search in sources :

Example 1 with JoinRelationshipModel

use of org.pentaho.agilebi.modeler.models.JoinRelationshipModel in project data-access by pentaho.

the class JoinDefinitionsStep method createJoin.

@Bindable
public void createJoin() {
    JoinRelationshipModel join = new JoinRelationshipModel();
    join.setLeftKeyFieldModel(this.joinGuiModel.getLeftKeyField());
    join.setRightKeyFieldModel(this.joinGuiModel.getRightKeyField());
    if (this.validator.isValid(join)) {
        this.joinGuiModel.addJoin(join);
        this.parentDatasource.setFinishable(this.validator.allTablesJoined());
    } else {
        ((MultiTableDatasource) this.parentDatasource).displayErrors(this.validator.getError());
    }
}
Also used : JoinRelationshipModel(org.pentaho.agilebi.modeler.models.JoinRelationshipModel) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 2 with JoinRelationshipModel

use of org.pentaho.agilebi.modeler.models.JoinRelationshipModel in project data-access by pentaho.

the class SerializeMultiTableServiceIT method getSchema.

private SchemaModel getSchema() {
    List<JoinRelationshipModel> joins = new ArrayList<JoinRelationshipModel>();
    JoinTableModel joinTable1 = new JoinTableModel();
    joinTable1.setName("CUSTOMERS");
    JoinTableModel joinTable2 = new JoinTableModel();
    joinTable2.setName("PRODUCTS");
    JoinRelationshipModel join1 = new JoinRelationshipModel();
    JoinFieldModel lField1 = new JoinFieldModel();
    lField1.setName("CUSTOMERNAME");
    lField1.setParentTable(joinTable1);
    join1.setLeftKeyFieldModel(lField1);
    JoinFieldModel rField1 = new JoinFieldModel();
    rField1.setName("PRODUCTCODE");
    rField1.setParentTable(joinTable2);
    join1.setRightKeyFieldModel(rField1);
    joins.add(join1);
    SchemaModel model = new SchemaModel();
    model.setJoins(joins);
    return model;
}
Also used : JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) SchemaModel(org.pentaho.agilebi.modeler.models.SchemaModel) ArrayList(java.util.ArrayList) JoinFieldModel(org.pentaho.agilebi.modeler.models.JoinFieldModel) JoinRelationshipModel(org.pentaho.agilebi.modeler.models.JoinRelationshipModel)

Example 3 with JoinRelationshipModel

use of org.pentaho.agilebi.modeler.models.JoinRelationshipModel in project data-access by pentaho.

the class JoinMetadataIT method getSchemaModel.

private SchemaModel getSchemaModel() {
    List<JoinRelationshipModel> joins = new ArrayList<JoinRelationshipModel>();
    JoinTableModel joinTable1 = new JoinTableModel();
    joinTable1.setName("CUSTOMERS");
    JoinTableModel joinTable2 = new JoinTableModel();
    joinTable2.setName("PRODUCTS");
    JoinRelationshipModel join1 = new JoinRelationshipModel();
    JoinFieldModel lField1 = new JoinFieldModel();
    lField1.setName("CUSTOMERNAME");
    lField1.setParentTable(joinTable1);
    join1.setLeftKeyFieldModel(lField1);
    JoinFieldModel rField1 = new JoinFieldModel();
    rField1.setName("PRODUCTCODE");
    rField1.setParentTable(joinTable2);
    join1.setRightKeyFieldModel(rField1);
    joins.add(join1);
    SchemaModel model = new SchemaModel();
    model.setJoins(joins);
    return model;
}
Also used : JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) SchemaModel(org.pentaho.agilebi.modeler.models.SchemaModel) ArrayList(java.util.ArrayList) JoinFieldModel(org.pentaho.agilebi.modeler.models.JoinFieldModel) JoinRelationshipModel(org.pentaho.agilebi.modeler.models.JoinRelationshipModel)

Example 4 with JoinRelationshipModel

use of org.pentaho.agilebi.modeler.models.JoinRelationshipModel 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 5 with JoinRelationshipModel

use of org.pentaho.agilebi.modeler.models.JoinRelationshipModel 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)

Aggregations

JoinRelationshipModel (org.pentaho.agilebi.modeler.models.JoinRelationshipModel)7 ArrayList (java.util.ArrayList)4 JoinTableModel (org.pentaho.agilebi.modeler.models.JoinTableModel)4 JoinFieldModel (org.pentaho.agilebi.modeler.models.JoinFieldModel)2 SchemaModel (org.pentaho.agilebi.modeler.models.SchemaModel)2 HashSet (java.util.HashSet)1 LogicalColumn (org.pentaho.metadata.model.LogicalColumn)1 LogicalRelationship (org.pentaho.metadata.model.LogicalRelationship)1 LogicalTable (org.pentaho.metadata.model.LogicalTable)1 LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)1 Bindable (org.pentaho.ui.xul.stereotype.Bindable)1