Search in sources :

Example 1 with JoinTableModel

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

the class MultitableGuiModel method populateJoinGuiModel.

public void populateJoinGuiModel(Domain domain, MultiTableDatasourceDTO dto, List tables) {
    this.selectedTables.clear();
    // Populate "selectedTables" from availableTables using logicalRelationships.
    AbstractModelList<JoinTableModel> selectedTablesList = new AbstractModelList<JoinTableModel>();
    if (dto != null) {
        for (String selectedTable : dto.getSelectedTables()) {
            this.selectTable(selectedTable, selectedTablesList, tables);
        }
        this.selectedTables.addAll(selectedTablesList);
        // Populates joins.
        this.computeJoins(dto);
        // Populate fact table.
        if (dto.isDoOlap()) {
            for (JoinTableModel table : this.selectedTables) {
                if (tablesAreEqual(table.getName(), dto.getSchemaModel().getFactTable().getName())) {
                    this.setFactTable(table);
                    break;
                }
            }
        }
    }
    // Populate available tables discarding selected tables.
    this.processAvailableTables(tables);
    if (domain != null) {
        // Existing joinTableModels will not have fields. We can add these from the domain.
        this.addFieldsToTables(domain, this.availableTables);
    }
}
Also used : JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) AbstractModelList(org.pentaho.ui.xul.util.AbstractModelList) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Example 2 with JoinTableModel

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

the class TablesSelectionStep method setBindings.

public void setBindings() {
    BindingFactory bf = new GwtBindingFactory(document);
    bf.createBinding(this.joinGuiModel.getAvailableTables(), "children", this.availableTables, "elements");
    bf.createBinding(this.joinGuiModel.getSelectedTables(), "children", this.selectedTables, "elements");
    bf.createBinding(this.joinGuiModel.getSelectedTables(), "children", this.factTables, "elements", new BindingConvertor<AbstractModelList<JoinTableModel>, Collection<JoinTableModel>>() {

        @Override
        public Collection<JoinTableModel> sourceToTarget(AbstractModelList<JoinTableModel> list) {
            List<JoinTableModel> tables = new ArrayList<JoinTableModel>();
            tables.addAll(list.asList());
            JoinTableModel emptyOption = new JoinTableModel();
            emptyOption.setName(MessageHandler.getString("multitable.SELECT_TABLE"));
            // Empty option must be always 0.
            tables.add(0, emptyOption);
            return tables;
        }

        @Override
        public AbstractModelList<JoinTableModel> targetToSource(final Collection<JoinTableModel> list) {
            return null;
        }
    });
    bf.createBinding(this.joinGuiModel, "schemas", this.schemas, "elements", new BindingConvertor<List<String>, Collection<String>>() {

        @Override
        public Collection<String> sourceToTarget(List<String> list) {
            List<String> tables = new ArrayList<String>();
            tables.addAll(list);
            return tables;
        }

        @Override
        public List<String> targetToSource(final Collection<String> list) {
            return null;
        }
    });
    bf.createBinding(this.factTables, "selectedIndex", this.joinGuiModel, "factTable", new BindingConvertor<Integer, JoinTableModel>() {

        @Override
        public JoinTableModel sourceToTarget(final Integer index) {
            if (index == -1) {
                return null;
            }
            // Index 0 represents [select table] option.
            // To be valid index must not be 0.
            checkValidState();
            int i = (int) index;
            i--;
            return i < 0 ? null : joinGuiModel.getSelectedTables().get(i);
        }

        @Override
        public Integer targetToSource(final JoinTableModel value) {
            return joinGuiModel.getSelectedTables().indexOf(value);
        }
    });
    // use a binding to handle the visibility state of the schema type radio group
    try {
        bf.createBinding(joinGuiModel, "doOlap", "factTableVbox", "visible").fireSourceChanged();
    } catch (Exception e) {
        e.printStackTrace();
        mtdatasource.displayErrors(new JoinError(e.getMessage(), e.getMessage()));
    }
}
Also used : XulException(org.pentaho.ui.xul.XulException) JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) Collection(java.util.Collection) AbstractModelList(org.pentaho.ui.xul.util.AbstractModelList) XulMenuList(org.pentaho.ui.xul.components.XulMenuList) ArrayList(java.util.ArrayList) List(java.util.List) AbstractModelList(org.pentaho.ui.xul.util.AbstractModelList) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Example 3 with JoinTableModel

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

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

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

the class MultitableGuiModel method selectTable.

private void selectTable(String selectedTable, AbstractModelList<JoinTableModel> selectedTablesList, List databaseTables) {
    for (Object table : databaseTables) {
        if (tablesAreEqual(table.toString(), selectedTable)) {
            if (!selectedTablesList.contains(table)) {
                JoinTableModel joinTable = new JoinTableModel();
                joinTable.setName(table.toString());
                selectedTablesList.add(joinTable);
            }
        }
    }
}
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