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);
}
}
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()));
}
}
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;
}
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;
}
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);
}
}
}
}
Aggregations