pentaho$modeler
void
void fireTablesChanged()
void
void fireFieldsChanged()
pentaho$modeler
return availableTables;
  private void fireTablesChanged() {
    firePropertyChange("availableTables", null, this.availableTables); //$NON-NLS-1$
    // Add in new physical tables/columns
      // see if the table is in the availableTables list
      AvailableTable aTable = availableTables.findAvailableTable(table.getName(LocalizedString.DEFAULT_LOCALE));
      if (aTable == null) {
        // new table, make sure we add it
        availableTables.add(new AvailableTable(table));
AvailableItemCollection
AvailableItemCollection getAvailableTables()
return availableFields;

  private void fireFieldsChanged() {
    firePropertyChange("availableFields", null, this.availableFields); //$NON-NLS-1$
    // Add in new physical columns
      for(IPhysicalColumn column : table.getPhysicalColumns()) {
        boolean exists = false;
        inner:
        for(AvailableField field : this.availableFields) {
          if (field.isSameUnderlyingPhysicalColumn(column)) {
            exists = true;
            break inner;
AvailableFieldCollection
AvailableFieldCollection getAvailableFields()
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FBaseModelerWorkspaceHelper.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FBaseModelerWorkspaceHelper.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/BaseModelerWorkspaceHelper.java
    for (AvailableTable table : workspace.getAvailableTables().getAsAvailableTablesList()) {
      for( AvailableField field : table.getAvailableFields() ) {
        LogicalTable parentTable = workspace.findLogicalTable(field.getPhysicalColumn().getPhysicalTable(), ModelerPerspective.ANALYSIS);
        DataType dataType = field.getPhysicalColumn().getDataType();
        if( dataType == DataType.NUMERIC) {
          // create a measure
          MeasureMetaData measure = workspace.createMeasureForNode(field);
          workspace.getModel().getMeasures().add(measure);
        }
        // create a dimension
        workspace.addDimensionFromNode(workspace.createColumnBackedNode(field, ModelerPerspective.ANALYSIS));
      }

    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();

        for (AvailableTable aTable : tablesList) {
          if (aTable.isSameUnderlyingPhysicalTable(table)) {
            for( AvailableField field : aTable.getAvailableFields() ) {
              if (field.getPhysicalColumn().getPhysicalTable().getId().equals(table.getId())) {
                category.add(workspace.createFieldForParentWithNode(category, field));
              }
            }

  public static String getCorrespondingOlapColumnId(LogicalColumn lc) {
    String tableId = lc.getLogicalTable().getId().replaceAll("BT", "LC");
    String olapColId = tableId + OLAP_SUFFIX + "_" + lc.getPhysicalColumn().getId();
    return olapColId;
  }

    List<AvailableField> fields = workspace.getAvailableFields();
    for( AvailableField field : fields ) {
      LogicalTable parentTable = workspace.findLogicalTable(field.getPhysicalColumn().getPhysicalTable(), ModelerPerspective.ANALYSIS);
      DataType dataType = field.getPhysicalColumn().getDataType();
      if( dataType == DataType.NUMERIC) {
        // create a measure
        MeasureMetaData measure = workspace.createMeasureForNode(field);
        workspace.getModel().getMeasures().add(measure);
      }
      // create a dimension
      workspace.addDimensionFromNode(workspace.createColumnBackedNode(field, ModelerPerspective.ANALYSIS));
        List<AvailableField> fields = workspace.getAvailableFields();
        for( AvailableField field : fields ) {
          if (field.getPhysicalColumn().getPhysicalTable().getId().equals(table.getId())) {
            category.add(workspace.createFieldForParentWithNode(category, field));
LogicalColumn lc
src/org/pentaho/agilebi/modeler/BaseModelerWorkspaceHelper.java
String tableId = lc.getLogicalTable().getId().replaceAll("BT", "LC");
    String olapColId = tableId + OLAP_SUFFIX + "_" + lc.getPhysicalColumn().getId();
    return olapColId;
String getCorrespondingOlapColumnId(LogicalColumn lc)
@@ -234,12 +234,6 @@ protected void populateCategories(ModelerWorkspace workspace) {
   }
 
 
-  public static String getCorrespondingOlapColumnId(LogicalColumn lc) {
-    String tableId = lc.getLogicalTable().getId().replaceAll("BT", "LC");
-    String olapColId = tableId + OLAP_SUFFIX + "_" + lc.getPhysicalColumn().getId();
-    return olapColId;
-  }
-
   public static void duplicateLogicalTablesForDualModelingMode(LogicalModel model) {
     String locale = "en-US";
     int tableCount = model.getLogicalTables().size();
@@ -271,18 +265,19 @@ public void autoModelFlat( ModelerWorkspace workspace ) throws ModelerException
       }
     }
 
-    List<AvailableField> fields = workspace.getAvailableFields();
-    for( AvailableField field : fields ) {
-      LogicalTable parentTable = workspace.findLogicalTable(field.getPhysicalColumn().getPhysicalTable(), ModelerPerspective.ANALYSIS);
-      DataType dataType = field.getPhysicalColumn().getDataType();
-      if( dataType == DataType.NUMERIC) {
-        // create a measure
-        MeasureMetaData measure = workspace.createMeasureForNode(field);
-        workspace.getModel().getMeasures().add(measure);
-      }
-      // create a dimension
-      workspace.addDimensionFromNode(workspace.createColumnBackedNode(field, ModelerPerspective.ANALYSIS));
+    for (AvailableTable table : workspace.getAvailableTables().getAsAvailableTablesList()) {
+      for( AvailableField field : table.getAvailableFields() ) {
+        LogicalTable parentTable = workspace.findLogicalTable(field.getPhysicalColumn().getPhysicalTable(), ModelerPerspective.ANALYSIS);
+        DataType dataType = field.getPhysicalColumn().getDataType();
+        if( dataType == DataType.NUMERIC) {
+          // create a measure
+          MeasureMetaData measure = workspace.createMeasureForNode(field);
+          workspace.getModel().getMeasures().add(measure);
+        }
+        // create a dimension
+        workspace.addDimensionFromNode(workspace.createColumnBackedNode(field, ModelerPerspective.ANALYSIS));
 
+      }
     }
     workspace.setModelIsChanging(prevChangeState);
     workspace.setSelectedNode(workspace.getModel());
@@ -344,18 +339,25 @@ public void autoModelRelationalFlat(ModelerWorkspace workspace) throws ModelerEx
 
     List<? extends IPhysicalTable> tables = workspace.getDomain().getPhysicalModels().get(0).getPhysicalTables();
     Set<String> tableIds = new HashSet<String>();
+
+    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();
+
     for (IPhysicalTable table : tables) {
       if (!tableIds.contains(table.getId())) {
         tableIds.add(table.getId());
         String catName = getCleanCategoryName(table.getName(getLocale()), workspace, tableIds.size());
         CategoryMetaData category = new CategoryMetaData(catName);
 
-        List<AvailableField> fields = workspace.getAvailableFields();
-        for( AvailableField field : fields ) {
-          if (field.getPhysicalColumn().getPhysicalTable().getId().equals(table.getId())) {
-            category.add(workspace.createFieldForParentWithNode(category, field));
+        for (AvailableTable aTable : tablesList) {
+          if (aTable.isSameUnderlyingPhysicalTable(table)) {
+            for( AvailableField field : aTable.getAvailableFields() ) {
+              if (field.getPhysicalColumn().getPhysicalTable().getId().equals(table.getId())) {
+                category.add(workspace.createFieldForParentWithNode(category, field));
+              }
+            }
           }
         }
+
         relationalModelNode.getCategories().add(category);
       }
     }
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FBaseModelerWorkspaceHelper.java
ebbd9bf6263fdf503ca195253cfda9d1fa133e2a
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FCategoryTreeHelper.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FCategoryTreeHelper.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/CategoryTreeHelper.java
      if (obj instanceof AvailableTable) {
        AvailableTable table = (AvailableTable)obj;
        for (AvailableField field : table.getAvailableFields()) {
          addAvailableField(field);
      } else if (obj instanceof AvailableField) {
        AvailableField availableField = (AvailableField)obj;
        addAvailableField(availableField);

  private void addAvailableField(AvailableField availableField) {
    AbstractMetaDataModelNode theNode = null;
    Object selectedTreeItem = getSelectedTreeItem();
    // depending on the parent
    if (selectedTreeItem == null) {
      // null - cannot add fields at this level
    } else if (selectedTreeItem instanceof CategoryMetaData) {
      // category - add as a field
      theNode = workspace.createFieldForParentWithNode((CategoryMetaData) selectedTreeItem, availableField);
      CategoryMetaData theCategory = (CategoryMetaData) selectedTreeItem;
      theCategory.add((FieldMetaData) theNode);
    }
    if (theNode != null) {
      theNode.setParent((AbstractMetaDataModelNode) selectedTreeItem);
    }
  }


obj instanceof AvailableField
src/org/pentaho/agilebi/modeler/CategoryTreeHelper.java
AvailableField availableField = (AvailableField)obj;
        addAvailableField(availableField);

  private void addAvailableField(AvailableField availableField) {
    AbstractMetaDataModelNode theNode = null;
    Object selectedTreeItem = getSelectedTreeItem();
    // depending on the parent
    if (selectedTreeItem == null) {
      // null - cannot add fields at this level
else if (obj instanceof AvailableField)
selectedTreeItem instanceof CategoryMetaData
src/org/pentaho/agilebi/modeler/CategoryTreeHelper.java
// category - add as a field
      theNode = workspace.createFieldForParentWithNode((CategoryMetaData) selectedTreeItem, availableField);
      CategoryMetaData theCategory = (CategoryMetaData) selectedTreeItem;
      theCategory.add((FieldMetaData) theNode);
else if (selectedTreeItem instanceof CategoryMetaData)
    AbstractMetaDataModelNode theNode = null;
    Object selectedTreeItem = getSelectedTreeItem();
      if (obj instanceof AvailableField) {
        AvailableField availableField = (AvailableField)obj;
        // depending on the parent
        if (selectedTreeItem == null) {
          // null - cannot add fields at this level
        } else if (selectedTreeItem instanceof CategoryMetaData) {
          // category - add as a field
          theNode = workspace.createFieldForParentWithNode((CategoryMetaData) selectedTreeItem, availableField);
          CategoryMetaData theCategory = (CategoryMetaData) selectedTreeItem;
          theCategory.add((FieldMetaData) theNode);
        }
        if (theNode != null) {
          theNode.setParent((AbstractMetaDataModelNode) selectedTreeItem);

selectedTreeItem == null
src/org/pentaho/agilebi/modeler/CategoryTreeHelper.java
// null - cannot add fields at this level
parent
        if (selectedTreeItem == null)
selectedTreeItem instanceof CategoryMetaData
src/org/pentaho/agilebi/modeler/CategoryTreeHelper.java
// category - add as a field
          theNode = workspace.createFieldForParentWithNode((CategoryMetaData) selectedTreeItem, availableField);
          CategoryMetaData theCategory = (CategoryMetaData) selectedTreeItem;
          theCategory.add((FieldMetaData) theNode);
else if (selectedTreeItem instanceof CategoryMetaData)
@@ -49,28 +49,38 @@ public void removeField() {
   public void addField(Object[] selectedFields) {
     boolean prevChangeState = workspace.isModelChanging();
     workspace.setRelationalModelIsChanging(true);
-    AbstractMetaDataModelNode theNode = null;
-    Object selectedTreeItem = getSelectedTreeItem();
 
     for (Object obj : selectedFields) {
-      if (obj instanceof AvailableField) {
-        AvailableField availableField = (AvailableField)obj;
-        // depending on the parent
-        if (selectedTreeItem == null) {
-          // null - cannot add fields at this level
-        } else if (selectedTreeItem instanceof CategoryMetaData) {
-          // category - add as a field
-          theNode = workspace.createFieldForParentWithNode((CategoryMetaData) selectedTreeItem, availableField);
-          CategoryMetaData theCategory = (CategoryMetaData) selectedTreeItem;
-          theCategory.add((FieldMetaData) theNode);
-        }
-        if (theNode != null) {
-          theNode.setParent((AbstractMetaDataModelNode) selectedTreeItem);
+      if (obj instanceof AvailableTable) {
+        AvailableTable table = (AvailableTable)obj;
+        for (AvailableField field : table.getAvailableFields()) {
+          addAvailableField(field);
         }
+      } else if (obj instanceof AvailableField) {
+        AvailableField availableField = (AvailableField)obj;
+        addAvailableField(availableField);
       }
     }
     workspace.setRelationalModelIsChanging(prevChangeState);
   }
+
+  private void addAvailableField(AvailableField availableField) {
+    AbstractMetaDataModelNode theNode = null;
+    Object selectedTreeItem = getSelectedTreeItem();
+    // depending on the parent
+    if (selectedTreeItem == null) {
+      // null - cannot add fields at this level
+    } else if (selectedTreeItem instanceof CategoryMetaData) {
+      // category - add as a field
+      theNode = workspace.createFieldForParentWithNode((CategoryMetaData) selectedTreeItem, availableField);
+      CategoryMetaData theCategory = (CategoryMetaData) selectedTreeItem;
+      theCategory.add((FieldMetaData) theNode);
+    }
+    if (theNode != null) {
+      theNode.setParent((AbstractMetaDataModelNode) selectedTreeItem);
+    }
+  }
+
   @Override
   public void clearTreeModel(){
     workspace.setRelationalModelIsChanging(true);

https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FCategoryTreeHelper.java
3175f8d5a4ee2310be79dbe4859bbfb4ec86e5d8
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FColResolverController.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FColResolverController.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/ColResolverController.java
    availableCols.setElements(workspace.getAvailableTables().getAsAvailableTablesList().get(0).getAvailableFields());
      ColumnBackedNode cnode = workspace.createColumnBackedNode(workspace.getAvailableTables().getAsAvailableTablesList().get(0).getAvailableFields().get(idx), workspace.getCurrentModelerPerspective());
    availableCols.setElements(workspace.getAvailableFields());
      ColumnBackedNode cnode = workspace.createColumnBackedNode(workspace.getAvailableFields().get(idx), workspace.getCurrentModelerPerspective());
@@ -43,7 +43,7 @@ public ColResolverController() {
   public void show( ModelerWorkspace workspace, ColumnBackedNode node ) {
     this.workspace = workspace;
     this.node = node;
-    availableCols.setElements(workspace.getAvailableFields());
+    availableCols.setElements(workspace.getAvailableTables().getAsAvailableTablesList().get(0).getAvailableFields());
     dialog.show();
   }
 
@@ -57,7 +57,7 @@ public void init() {
   public void done() {
     int idx = this.availableCols.getSelectedIndex();
     if (idx > -1) {
-      ColumnBackedNode cnode = workspace.createColumnBackedNode(workspace.getAvailableFields().get(idx), workspace.getCurrentModelerPerspective());
+      ColumnBackedNode cnode = workspace.createColumnBackedNode(workspace.getAvailableTables().getAsAvailableTablesList().get(0).getAvailableFields().get(idx), workspace.getCurrentModelerPerspective());
       LogicalColumn lCol = cnode.getLogicalColumn();
       node.setLogicalColumn(lCol);
       workspace.setDirty(true);
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FColResolverController.java
2122a1b313e38279481e8502863af8241ef3d675
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FModelerController.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FModelerController.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/ModelerController.java
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
  private IAvailableItem[] selectedFields = new IAvailableItem[]{};
  @Bindable
  public void setSelectedFieldsChanged(Object selected) {
    if (selected != null && selected instanceof IAvailableItem) {
      selectedFields = new IAvailableItem[]{(IAvailableItem)selected};
    }
  }

    fieldListBinding = bf.createBinding(workspace.getAvailableTables(), "children", FIELD_LIST_ID,
    selectedFieldsBinding = bf.createBinding(FIELD_LIST_ID, "selectedItem", this,
        "selectedFieldsChanged"); //$NON-NLS-1$//$NON-NLS-2$
              IAvailableItem item = selectedFields[0];
              if (item instanceof AvailableField) {
                AvailableField f = (AvailableField)selectedFields[0];
                if(f != null){
                  ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.ANALYSIS);
                  theMeasure.setLogicalColumn(node.getLogicalColumn());
                  workspace.setDirty(true);
                }
              IAvailableItem item = selectedFields[0];
              if (item instanceof AvailableField) {
                AvailableField f = (AvailableField)selectedFields[0];
                ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.ANALYSIS);
                theLevel.setLogicalColumn(node.getLogicalColumn());
                workspace.setDirty(true);
              }
              IAvailableItem item = selectedFields[0];
              if (item instanceof AvailableField) {
                AvailableField f = (AvailableField)selectedFields[0];
                ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.REPORTING);
                theField.setLogicalColumn(node.getLogicalColumn());
                workspace.setDirty(true);
              }
    IAvailableItem[] f = new IAvailableItem[aFields.length];
      if (aFields[i] instanceof AvailableField) {
        f[i] = (AvailableField)aFields[i];
      } else if (aFields[i] instanceof AvailableTable) {
        f[i] = (AvailableTable)aFields[i];
      }
      selectedFields = new IAvailableItem[]{};
Object selected
src/org/pentaho/agilebi/modeler/ModelerController.java
if (selected != null && selected instanceof IAvailableItem) {
      selectedFields = new IAvailableItem[]{(IAvailableItem)selected
void setSelectedFieldsChanged(Object selected)
aFields[i] instanceof AvailableTable
src/org/pentaho/agilebi/modeler/ModelerController.java
f[i] = (AvailableTable)aFields[i];
else if (aFields[i] instanceof AvailableTable)
import java.util.*;
  private AvailableField[] selectedFields;
    fieldListBinding = bf.createBinding(workspace, "availableFields", FIELD_LIST_ID,
    selectedFieldsBinding = bf.createBinding(FIELD_LIST_ID, "selectedItems", this,
        "selectedFields"); //$NON-NLS-1$//$NON-NLS-2$
              AvailableField f = selectedFields[0];
              if(f != null){
                ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.ANALYSIS);
                theMeasure.setLogicalColumn(node.getLogicalColumn());
                workspace.setDirty(true);
              AvailableField f = selectedFields[0];
              ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.ANALYSIS);
              theLevel.setLogicalColumn(node.getLogicalColumn());
              workspace.setDirty(true);
              AvailableField f = selectedFields[0];
              ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.REPORTING);
              theField.setLogicalColumn(node.getLogicalColumn());
              workspace.setDirty(true);
    AvailableField[] f = new AvailableField[aFields.length];
      f[i] = (AvailableField)aFields[i];
      selectedFields = new AvailableField[]{};
@@ -35,7 +35,10 @@
 import org.pentaho.ui.xul.stereotype.Bindable;
 import org.pentaho.ui.xul.util.XulDialogCallback;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * XUL Event Handler for the modeling interface. This class interacts with a ModelerModel to store state.
@@ -55,7 +58,7 @@ public class ModelerController extends AbstractXulEventHandler {
   private XulTree dimensionTree;
   private XulTree categoriesTree;
   private XulDeck propDeck;
-  private AvailableField[] selectedFields;
+  private IAvailableItem[] selectedFields = new IAvailableItem[]{};
 
   private XulDeck modelDeck;
   private XulVbox reportingPanel;
@@ -117,6 +120,13 @@ public void addField() {
     }
   }
 
+  @Bindable
+  public void setSelectedFieldsChanged(Object selected) {
+    if (selected != null && selected instanceof IAvailableItem) {
+      selectedFields = new IAvailableItem[]{(IAvailableItem)selected};
+    }
+  }
+
   @Bindable
   public void init() throws ModelerException {
 
@@ -135,10 +145,10 @@ public void init() throws ModelerException {
     modelTabbox = (XulTabbox) document.getElementById("modelTabbox");
 
     bf.setBindingType(Type.ONE_WAY);
-    fieldListBinding = bf.createBinding(workspace, "availableFields", FIELD_LIST_ID,
+    fieldListBinding = bf.createBinding(workspace.getAvailableTables(), "children", FIELD_LIST_ID,
         "elements"); //$NON-NLS-1$ //$NON-NLS-2$
-    selectedFieldsBinding = bf.createBinding(FIELD_LIST_ID, "selectedItems", this,
-        "selectedFields"); //$NON-NLS-1$//$NON-NLS-2$
+    selectedFieldsBinding = bf.createBinding(FIELD_LIST_ID, "selectedItem", this,
+        "selectedFieldsChanged"); //$NON-NLS-1$//$NON-NLS-2$
 
     modelTreeBinding = bf.createBinding(workspace, "model", dimensionTree, "elements"); //$NON-NLS-1$//$NON-NLS-2$
     relModelTreeBinding = bf.createBinding(workspace, "relationalModel", categoriesTree, "elements"); //$NON-NLS-1$//$NON-NLS-2$
@@ -341,11 +351,14 @@ public void onClose( XulComponent sender, Status returnCode, Object retVal ) {
                 "" + retVal, workspaceHelper.getLocale()); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
 
             if (selectedFields.length > 0) {
-              AvailableField f = selectedFields[0];
-              if(f != null){
-                ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.ANALYSIS);
-                theMeasure.setLogicalColumn(node.getLogicalColumn());
-                workspace.setDirty(true);
+              IAvailableItem item = selectedFields[0];
+              if (item instanceof AvailableField) {
+                AvailableField f = (AvailableField)selectedFields[0];
+                if(f != null){
+                  ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.ANALYSIS);
+                  theMeasure.setLogicalColumn(node.getLogicalColumn());
+                  workspace.setDirty(true);
+                }
               }
             }
 
@@ -419,10 +432,13 @@ public void onClose( XulComponent sender, Status returnCode, Object retVal ) {
             LevelMetaData theLevel = new LevelMetaData(theHierarchy, "" + retVal);
 
             if (selectedFields.length > 0) {
-              AvailableField f = selectedFields[0];
-              ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.ANALYSIS);
-              theLevel.setLogicalColumn(node.getLogicalColumn());
-              workspace.setDirty(true);
+              IAvailableItem item = selectedFields[0];
+              if (item instanceof AvailableField) {
+                AvailableField f = (AvailableField)selectedFields[0];
+                ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.ANALYSIS);
+                theLevel.setLogicalColumn(node.getLogicalColumn());
+                workspace.setDirty(true);
+              }
             }
 
             theLevel.validate();
@@ -528,10 +544,13 @@ public void onClose( XulComponent sender, Status returnCode, Object retVal ) {
             FieldMetaData theField = new FieldMetaData(theCategory, "" + retVal, "", "" + retVal, workspaceHelper.getLocale());
 
             if (selectedFields.length > 0) {
-              AvailableField f = selectedFields[0];
-              ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.REPORTING);
-              theField.setLogicalColumn(node.getLogicalColumn());
-              workspace.setDirty(true);
+              IAvailableItem item = selectedFields[0];
+              if (item instanceof AvailableField) {
+                AvailableField f = (AvailableField)selectedFields[0];
+                ColumnBackedNode node = workspace.createColumnBackedNode(f, ModelerPerspective.REPORTING);
+                theField.setLogicalColumn(node.getLogicalColumn());
+                workspace.setDirty(true);
+              }
             }
 
             theField.validate();
@@ -707,17 +726,21 @@ public Object targetToSource( Boolean value ) {
 
   @Bindable
   public void setSelectedFields( Object[] aFields ) {
-    AvailableField[] f = new AvailableField[aFields.length];
+    IAvailableItem[] f = new IAvailableItem[aFields.length];
     for(int i=0; i<aFields.length; i++){
-      f[i] = (AvailableField)aFields[i];
+      if (aFields[i] instanceof AvailableField) {
+        f[i] = (AvailableField)aFields[i];
+      } else if (aFields[i] instanceof AvailableTable) {
+        f[i] = (AvailableTable)aFields[i];
+      }
     }
     selectedFields = f;
   }
 
   @Bindable
   public Object[] getSelectedFields() {
     if (selectedFields == null) {
-      selectedFields = new AvailableField[]{};
+      selectedFields = new IAvailableItem[]{};
     }
     return selectedFields;
   }
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FModelerController.java
d1b830ab79e71b25b6833f73b9bbedde1992a52c
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FModelerWorkspace.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FModelerWorkspace.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/ModelerWorkspace.java
  private static final long serialVersionUID = 2058731810283858276L;
  private AvailableItemCollection availableTables = new AvailableItemCollection();
  public AvailableItemCollection getAvailableTables() {
    return availableTables;
  private void fireTablesChanged() {
    firePropertyChange("availableTables", null, this.availableTables); //$NON-NLS-1$
    // Add in new physical tables/columns
      // see if the table is in the availableTables list
      AvailableTable aTable = availableTables.findAvailableTable(table.getName(LocalizedString.DEFAULT_LOCALE));
      if (aTable == null) {
        // new table, make sure we add it
        availableTables.add(new AvailableTable(table));
      } else {
        // table already exists here, make sure all the fields are accounted for
          boolean exists = false;
          inner:
          for(AvailableField field : aTable.getAvailableFields()) {
            if (field.isSameUnderlyingPhysicalColumn(column)) {
            }
          }
          if (!exists) {
            AvailableField field = new AvailableField(column);
            aTable.getAvailableFields().add(field);
            Collections.sort(aTable.getAvailableFields(), fieldComparator);
    // Remove available tables/fields that no longer exist correspond to an available physical column
    List<AvailableTable> tablesToRemove = new ArrayList<AvailableTable>();
    List<AvailableTable> tablesList = availableTables.getAsAvailableTablesList();
    for (AvailableTable aTable : tablesList) {
        List<AvailableField> toRemove = new ArrayList<AvailableField>();
        boolean tableExists = false;
        for (AvailableField field : aTable.getAvailableFields()) {
          boolean exists = false;
          inner:
          for (IPhysicalTable table : newDomain.getPhysicalModels().get(0).getPhysicalTables()) {
            if (aTable.isSameUnderlyingPhysicalTable(table)) {
              tableExists = true;
              for(IPhysicalColumn column : table.getPhysicalColumns()) {
                if (field.isSameUnderlyingPhysicalColumn(column)) {
                    exists = true;
                    break inner;
                }
              }
            }
          }
          if (!exists) {
            toRemove.add(field);
          }
        }
        aTable.getAvailableFields().removeAll(toRemove);
        workspaceHelper.sortFields(aTable.getAvailableFields());

        if (!tableExists) {
          tablesToRemove.add(aTable);
        }
              }
    availableTables.removeAll(tablesToRemove);
    // TODO, sort the tables???


    fireTablesChanged();
        for (AvailableTable table : tablesList) {
            if (table.containsUnderlyingPhysicalColumn(measure.getLogicalColumn().getPhysicalColumn())) {
              // the physical column backing this measure is still available, it is ok
              found = true;
              break inner;
            }
            }
              for (AvailableTable table : tablesList) {
                  if (table.containsUnderlyingPhysicalColumn(lm.getLogicalColumn().getPhysicalColumn())) {
                    // the physical column backing this level is still available, it is ok
                    found = true;
                    break inner;
                  }
                  }
          for (AvailableTable table : tablesList) {
              if (table.containsUnderlyingPhysicalColumn(field.getLogicalColumn().getPhysicalColumn())) {
                // the physical column backing this field is still available, it is ok
                found = true;
                break inner;
              }
              }
  public void setAvailableTables(AvailableItemCollection tables){
    this.availableTables = tables;
    firePropertyChange("availableTables", null, getAvailableTables()); //$NON-NLS-1$

    this.availableTables.clear();
      availableTables.add(new AvailableTable(table));
    firePropertyChange("availableTables", null, getAvailableTables()); //$NON-NLS-1$
          // create new logical columns
          AvailableField field = new AvailableField(level.getLogicalColumn().getPhysicalColumn());
          ColumnBackedNode node = createColumnBackedNode(field, ModelerPerspective.ANALYSIS);
          level.setLogicalColumn(node.getLogicalColumn());
      AvailableField field = new AvailableField(measure.getLogicalColumn().getPhysicalColumn());
      ColumnBackedNode node = createColumnBackedNode(field, ModelerPerspective.ANALYSIS);
      measure.setLogicalColumn(node.getLogicalColumn());
      fireTablesChanged();
      fireTablesChanged();
src/org/pentaho/agilebi/modeler/ModelerWorkspace.java
return availableTables;
  private void fireTablesChanged() {
    firePropertyChange("availableTables", null, this.availableTables); //$NON-NLS-1$
    // Add in new physical tables/columns
      // see if the table is in the availableTables list
      AvailableTable aTable = availableTables.findAvailableTable(table.getName(LocalizedString.DEFAULT_LOCALE));
      if (aTable == null) {
        // new table, make sure we add it
        availableTables.add(new AvailableTable(table));
AvailableItemCollection getAvailableTables()
  private AvailableFieldCollection availableFields = new AvailableFieldCollection();
//  private AvailableFieldCollection availableOlapFields = new AvailableFieldCollection();
  public AvailableFieldCollection getAvailableFields() {
    return availableFields;

  private void fireFieldsChanged() {
    firePropertyChange("availableFields", null, this.availableFields); //$NON-NLS-1$
    // Add in new physical columns
      for(IPhysicalColumn column : table.getPhysicalColumns()) {
        boolean exists = false;
        inner:
        for(AvailableField field : this.availableFields) {
          if (field.isSameUnderlyingPhysicalColumn(column)) {
            exists = true;
            break inner;
          }
        }
        if (!exists) {
          AvailableField field = new AvailableField(column);
          availableFields.add(field);
          Collections.sort(availableFields, fieldComparator);
        }
      }
    }

    // Remove available fields that no longer exist correspond to an available physical column
    List<AvailableField> toRemove = new ArrayList<AvailableField>();
    for (AvailableField field : availableFields) {
      boolean exists = false;
      inner:
      for (IPhysicalTable table : newDomain.getPhysicalModels().get(0).getPhysicalTables()) {
          if (field.isSameUnderlyingPhysicalColumn(column)) {
      if (!exists) {
        toRemove.add(field);
      }
    availableFields.removeAll(toRemove);
    workspaceHelper.sortFields(availableFields);
    fireFieldsChanged();
        for (AvailableField field : availableFields) {
          if (field.isSameUnderlyingPhysicalColumn(measure.getLogicalColumn().getPhysicalColumn())) {
            // the physical column backing this measure is still available, it is ok
            found = true;
            break inner;
        }
      }
              for (AvailableField field : availableFields) {
                if (field.isSameUnderlyingPhysicalColumn(lm.getLogicalColumn().getPhysicalColumn())) {
                  // the physical column backing this level is still available, it is ok
                  found = true;
                  break inner;
              }
            }
          for (AvailableField af : availableFields) {
            if (af.isSameUnderlyingPhysicalColumn(field.getLogicalColumn().getPhysicalColumn())) {
              // the physical column backing this field is still available, it is ok
              found = true;
              break inner;
          }
        }
  public void setAvailableFields(AvailableFieldCollection fields){
    this.availableFields = fields;
    firePropertyChange("availableFields", null, getAvailableFields()); //$NON-NLS-1$

    this.availableFields.clear();
      for (IPhysicalColumn column : table.getPhysicalColumns()) {
        AvailableField field = new AvailableField(column);
        availableFields.add(field);
      }
    workspaceHelper.sortFields(availableFields);

    firePropertyChange("availableFields", null, getAvailableFields()); //$NON-NLS-1$
          String olapColumnId = BaseModelerWorkspaceHelper.getCorrespondingOlapColumnId(level.getLogicalColumn());
          LogicalColumn olapCol = model.findLogicalColumn(olapColumnId);
          level.setLogicalColumn(olapCol);
      String olapColumnId = BaseModelerWorkspaceHelper.getCorrespondingOlapColumnId(measure.getLogicalColumn());
      LogicalColumn olapCol = model.findLogicalColumn(olapColumnId);
      measure.setLogicalColumn(olapCol);
      fireFieldsChanged();
      fireFieldsChanged();
src/org/pentaho/agilebi/modeler/ModelerWorkspace.java
return availableFields;

  private void fireFieldsChanged() {
    firePropertyChange("availableFields", null, this.availableFields); //$NON-NLS-1$
    // Add in new physical columns
      for(IPhysicalColumn column : table.getPhysicalColumns()) {
        boolean exists = false;
        inner:
        for(AvailableField field : this.availableFields) {
          if (field.isSameUnderlyingPhysicalColumn(column)) {
            exists = true;
            break inner;
AvailableFieldCollection getAvailableFields()
AvailableFieldCollection fields
src/org/pentaho/agilebi/modeler/ModelerWorkspace.java
this.availableFields = fields;
    firePropertyChange("availableFields", null, getAvailableFields()); //$NON-NLS-1$

    this.availableFields.clear();
      for (IPhysicalColumn column : table.getPhysicalColumns()) {
        AvailableField field = new AvailableField(column);
        availableFields.add(field);
void setAvailableFields(AvailableFieldCollection fields)
@@ -39,8 +39,8 @@
 @SuppressWarnings("unchecked")
 public class ModelerWorkspace extends XulEventSourceAdapter implements Serializable{
 
-  private AvailableFieldCollection availableFields = new AvailableFieldCollection();
-//  private AvailableFieldCollection availableOlapFields = new AvailableFieldCollection();
+  private static final long serialVersionUID = 2058731810283858276L;
+  private AvailableItemCollection availableTables = new AvailableItemCollection();
 
   private MainModelNode model;
   private RelationalModelNode relationalModel;
@@ -224,11 +224,10 @@ public void setDirty( boolean dirty ) {
   }
 
   @Bindable
-  public AvailableFieldCollection getAvailableFields() {
-    return availableFields;
+  public AvailableItemCollection getAvailableTables() {
+    return availableTables;
   }
 
-
   @Bindable
   public void setSelectedVisualization( String aVisualization ) {
     this.selectedVisualization = aVisualization;
@@ -313,8 +312,8 @@ public HierarchyMetaData createHierarchyForParentWithNode( DimensionMetaData par
     return hier;
   }
 
-  private void fireFieldsChanged() {
-    firePropertyChange("availableFields", null, this.availableFields); //$NON-NLS-1$
+  private void fireTablesChanged() {
+    firePropertyChange("availableTables", null, this.availableTables); //$NON-NLS-1$
   }
 
   private void fireModelChanged() {
@@ -407,60 +406,83 @@ public int compare( AvailableField arg0, AvailableField arg1 ) {
 
     LogicalModel logicalModel = newDomain.getLogicalModels().get(0);
 
-    // Add in new physical columns
+    // Add in new physical tables/columns
     for (IPhysicalTable table : newDomain.getPhysicalModels().get(0).getPhysicalTables()) {
-      for(IPhysicalColumn column : table.getPhysicalColumns()) {
-        boolean exists = false;
-        inner:
-        for(AvailableField field : this.availableFields) {
-          if (field.isSameUnderlyingPhysicalColumn(column)) {
-            exists = true;
-            break inner;
-          }
-        }
-        if (!exists) {
-          AvailableField field = new AvailableField(column);
-          availableFields.add(field);
-          Collections.sort(availableFields, fieldComparator);
-        }
-      }
-    }
-
-    // Remove available fields that no longer exist correspond to an available physical column
-    List<AvailableField> toRemove = new ArrayList<AvailableField>();
-    for (AvailableField field : availableFields) {
-      boolean exists = false;
-      inner:
-      for (IPhysicalTable table : newDomain.getPhysicalModels().get(0).getPhysicalTables()) {
+      // see if the table is in the availableTables list
+      AvailableTable aTable = availableTables.findAvailableTable(table.getName(LocalizedString.DEFAULT_LOCALE));
+      if (aTable == null) {
+        // new table, make sure we add it
+        availableTables.add(new AvailableTable(table));
+      } else {
+        // table already exists here, make sure all the fields are accounted for
         for(IPhysicalColumn column : table.getPhysicalColumns()) {
-          if (field.isSameUnderlyingPhysicalColumn(column)) {
+          boolean exists = false;
+          inner:
+          for(AvailableField field : aTable.getAvailableFields()) {
+            if (field.isSameUnderlyingPhysicalColumn(column)) {
               exists = true;
               break inner;
+            }
+          }
+          if (!exists) {
+            AvailableField field = new AvailableField(column);
+            aTable.getAvailableFields().add(field);
+            Collections.sort(aTable.getAvailableFields(), fieldComparator);
           }
         }
       }
-      if (!exists) {
-        toRemove.add(field);
-      }
     }
-    availableFields.removeAll(toRemove);
-    workspaceHelper.sortFields(availableFields);
 
-    fireFieldsChanged();
+    // Remove available tables/fields that no longer exist correspond to an available physical column
+    List<AvailableTable> tablesToRemove = new ArrayList<AvailableTable>();
+    List<AvailableTable> tablesList = availableTables.getAsAvailableTablesList();
 
+    for (AvailableTable aTable : tablesList) {
+        List<AvailableField> toRemove = new ArrayList<AvailableField>();
+        boolean tableExists = false;
+        for (AvailableField field : aTable.getAvailableFields()) {
+          boolean exists = false;
+          inner:
+          for (IPhysicalTable table : newDomain.getPhysicalModels().get(0).getPhysicalTables()) {
+            if (aTable.isSameUnderlyingPhysicalTable(table)) {
+              tableExists = true;
+              for(IPhysicalColumn column : table.getPhysicalColumns()) {
+                if (field.isSameUnderlyingPhysicalColumn(column)) {
+                    exists = true;
+                    break inner;
+                }
+              }
+            }
+          }
+          if (!exists) {
+            toRemove.add(field);
+          }
+        }
+        aTable.getAvailableFields().removeAll(toRemove);
+        workspaceHelper.sortFields(aTable.getAvailableFields());
+
+        if (!tableExists) {
+          tablesToRemove.add(aTable);
+        }
+              }
+    availableTables.removeAll(tablesToRemove);
+    // TODO, sort the tables???
+
+
+    fireTablesChanged();
 
     for (MeasureMetaData measure : model.getMeasures()) {
       boolean found = false;
       if (measure.getLogicalColumn() != null) {
         inner:
-        for (AvailableField field : availableFields) {
-          if (field.isSameUnderlyingPhysicalColumn(measure.getLogicalColumn().getPhysicalColumn())) {
-            // the physical column backing this measure is still available, it is ok
-            found = true;
-            break inner;
+        for (AvailableTable table : tablesList) {
+            if (table.containsUnderlyingPhysicalColumn(measure.getLogicalColumn().getPhysicalColumn())) {
+              // the physical column backing this measure is still available, it is ok
+              found = true;
+              break inner;
+            }
+            }
           }
-        }
-      }
       if (!found) {
         // the physical column that backed this measure no longer exists in the model.
         // therefore, we must invalidate it's logical column
@@ -475,14 +497,14 @@ public int compare( AvailableField arg0, AvailableField arg1 ) {
             boolean found = false;
             if (lm.getLogicalColumn() != null) {
               inner:
-              for (AvailableField field : availableFields) {
-                if (field.isSameUnderlyingPhysicalColumn(lm.getLogicalColumn().getPhysicalColumn())) {
-                  // the physical column backing this level is still available, it is ok
-                  found = true;
-                  break inner;
+              for (AvailableTable table : tablesList) {
+                  if (table.containsUnderlyingPhysicalColumn(lm.getLogicalColumn().getPhysicalColumn())) {
+                    // the physical column backing this level is still available, it is ok
+                    found = true;
+                    break inner;
+                  }
+                  }
                 }
-              }
-            }
             if (!found) {
               // the physical column that backed this level no longer exists in the model.
               // therefore, we must invalidate it's logical column
@@ -500,14 +522,14 @@ public int compare( AvailableField arg0, AvailableField arg1 ) {
         boolean found = false;
         if (field.getLogicalColumn() != null) {
           inner:
-          for (AvailableField af : availableFields) {
-            if (af.isSameUnderlyingPhysicalColumn(field.getLogicalColumn().getPhysicalColumn())) {
-              // the physical column backing this field is still available, it is ok
-              found = true;
-              break inner;
+          for (AvailableTable table : tablesList) {
+              if (table.containsUnderlyingPhysicalColumn(field.getLogicalColumn().getPhysicalColumn())) {
+                // the physical column backing this field is still available, it is ok
+                found = true;
+                break inner;
+              }
+              }
             }
-          }
-        }
         if (!found) {
           // the physical column that backed this field no longer exists in the model.
           // therefore, we must invalidate it's logical column
@@ -552,12 +574,12 @@ public void setSchemaName( String schemaName ) {
     this.schemaName = schemaName;
   }
 
-  public void setAvailableFields(AvailableFieldCollection fields){
-    this.availableFields = fields;
-    firePropertyChange("availableFields", null, getAvailableFields()); //$NON-NLS-1$
-
+  public void setAvailableTables(AvailableItemCollection tables){
+    this.availableTables = tables;
+    firePropertyChange("availableTables", null, getAvailableTables()); //$NON-NLS-1$
   }
 
+
   public void setDomain( Domain d ) {
     setDomain(d, true);
   }
@@ -570,7 +592,7 @@ protected void setDomain(Domain d, boolean upConvertDesired) {
     this.model.getDimensions().clear();
     this.model.getMeasures().clear();
     this.relationalModel.getCategories().clear();
-    this.availableFields.clear();
+    this.availableTables.clear();
 
     // remove all logical columns from existing logical tables
     for (LogicalTable table : d.getLogicalModels().get(0).getLogicalTables()) {
@@ -581,15 +603,10 @@ protected void setDomain(Domain d, boolean upConvertDesired) {
     if (upConvertDesired) needsUpConverted = upConvertLegacyModel();
 
     for (IPhysicalTable table : domain.getPhysicalModels().get(0).getPhysicalTables()) {
-      for (IPhysicalColumn column : table.getPhysicalColumns()) {
-        AvailableField field = new AvailableField(column);
-        availableFields.add(field);
-      }
+      availableTables.add(new AvailableTable(table));
     }
 
-    workspaceHelper.sortFields(availableFields);
-
-    firePropertyChange("availableFields", null, getAvailableFields()); //$NON-NLS-1$
+    firePropertyChange("availableTables", null, getAvailableTables()); //$NON-NLS-1$
 
     LogicalModel lModel = domain.getLogicalModels().get(0);
 
@@ -697,18 +714,19 @@ private void upConvertMeasuresAndDimensions() {
     for (DimensionMetaData dim : getModel().getDimensions()) {
       for (HierarchyMetaData hier : dim) {
         for (LevelMetaData level : hier) {
-          String olapColumnId = BaseModelerWorkspaceHelper.getCorrespondingOlapColumnId(level.getLogicalColumn());
-          LogicalColumn olapCol = model.findLogicalColumn(olapColumnId);
-          level.setLogicalColumn(olapCol);
+          // create new logical columns
+          AvailableField field = new AvailableField(level.getLogicalColumn().getPhysicalColumn());
+          ColumnBackedNode node = createColumnBackedNode(field, ModelerPerspective.ANALYSIS);
+          level.setLogicalColumn(node.getLogicalColumn());
         }
       }
     }
 
     // set the measure logical column references to the new olap columns
     for (MeasureMetaData measure : getModel().getMeasures()) {
-      String olapColumnId = BaseModelerWorkspaceHelper.getCorrespondingOlapColumnId(measure.getLogicalColumn());
-      LogicalColumn olapCol = model.findLogicalColumn(olapColumnId);
-      measure.setLogicalColumn(olapCol);
+      AvailableField field = new AvailableField(measure.getLogicalColumn().getPhysicalColumn());
+      ColumnBackedNode node = createColumnBackedNode(field, ModelerPerspective.ANALYSIS);
+      measure.setLogicalColumn(node.getLogicalColumn());
     }
 
     return;
@@ -761,7 +779,7 @@ public void setModelIsChanging( boolean changing ) {
   public void setModelIsChanging( boolean changing, boolean fireChanged ) {
     this.modelIsChanging = changing;
     if (!changing && fireChanged) {
-      fireFieldsChanged();
+      fireTablesChanged();
       model.validateTree();
       isValid();
       fireModelChanged();
@@ -776,7 +794,7 @@ public void setRelationalModelIsChanging( boolean changing ) {
   public void setRelationalModelIsChanging( boolean changing, boolean fireChanged ) {
     this.modelIsChanging = changing;
     if (!changing && fireChanged) {
-      fireFieldsChanged();
+      fireTablesChanged();
       relationalModel.validateTree();
       isValid();
       fireRelationalModelChanged();
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FModelerWorkspace.java
32edcfe9ad798d149b5c5fc8845d11d3b94e430f
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fgwt%2Fservices%2FIGwtModelerService.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fgwt%2Fservices%2FIGwtModelerService.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/gwt/services/IGwtModelerService.java
import com.google.gwt.user.client.rpc.AsyncCallback;
import org.pentaho.agilebi.modeler.ModelerWorkspace;
import org.pentaho.agilebi.modeler.gwt.BogoPojo;
import org.pentaho.agilebi.modeler.nodes.AvailableFieldCollection;
import org.pentaho.agilebi.modeler.nodes.MainModelNode;
import org.pentaho.metadata.model.Domain;
import org.pentaho.ui.xul.XulServiceCallback;
@@ -1,14 +1,7 @@
 package org.pentaho.agilebi.modeler.gwt.services;
 
-import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.rpc.RemoteService;
-import org.pentaho.agilebi.modeler.ModelerWorkspace;
-import org.pentaho.agilebi.modeler.gwt.BogoPojo;
-import org.pentaho.agilebi.modeler.nodes.AvailableFieldCollection;
-import org.pentaho.agilebi.modeler.nodes.MainModelNode;
 import org.pentaho.agilebi.modeler.services.IModelerService;
-import org.pentaho.metadata.model.Domain;
-import org.pentaho.ui.xul.XulServiceCallback;
 
 /**
  * User: nbaker
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fgwt%2Fservices%2FIGwtModelerService.java
22dfedd96bbf6e440f5aaae263bc13736b970508
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fgwt%2Fservices%2FIGwtModelerServiceAsync.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fgwt%2Fservices%2FIGwtModelerServiceAsync.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/gwt/services/IGwtModelerServiceAsync.java
import org.pentaho.agilebi.modeler.ModelerWorkspace;
import org.pentaho.agilebi.modeler.nodes.AvailableFieldCollection;
import org.pentaho.agilebi.modeler.nodes.MainModelNode;
@@ -1,10 +1,7 @@
 package org.pentaho.agilebi.modeler.gwt.services;
 
 import com.google.gwt.user.client.rpc.AsyncCallback;
-import org.pentaho.agilebi.modeler.ModelerWorkspace;
 import org.pentaho.agilebi.modeler.gwt.BogoPojo;
-import org.pentaho.agilebi.modeler.nodes.AvailableFieldCollection;
-import org.pentaho.agilebi.modeler.nodes.MainModelNode;
 import org.pentaho.metadata.model.Domain;
 
 /**
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fgwt%2Fservices%2FIGwtModelerServiceAsync.java
47e411cf8ba8a8bf4259e4d33593d28d63b943ea
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fnodes%2FAvailableField.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fnodes%2FAvailableField.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/nodes/AvailableField.java
public class AvailableField extends AbstractAvailableItem implements Serializable, IAvailableItem {

  private static final String FIELD_IMAGE = "";
    setImage(FIELD_IMAGE);
    setImage(FIELD_IMAGE);
    return getName();

import org.pentaho.ui.xul.stereotype.Bindable;
public class AvailableField implements Serializable {
  private String name, displayName;
    

    setDisplayName(physicalColumn.getName(LocalizedString.DEFAULT_LOCALE));
  }

  @Bindable
  public String getName() {
    return name;
  }

  @Bindable
  public void setName(String name) {
    this.name = name;
  @Bindable
  public String getDisplayName() {
    return displayName;
  }

  @Bindable
  public void setDisplayName(String displayName) {
    this.displayName = displayName;
  }



    return name;
  
src/org/pentaho/agilebi/modeler/nodes/AvailableField.java
return name;
String getName()
String name
src/org/pentaho/agilebi/modeler/nodes/AvailableField.java
this.name = name;
  @Bindable
  public String getDisplayName() {
    return displayName;
void setName(String name)
String displayName
src/org/pentaho/agilebi/modeler/nodes/AvailableField.java
this.displayName = displayName;
void setDisplayName(String displayName)
@@ -19,54 +19,31 @@
 import org.pentaho.metadata.model.IPhysicalColumn;
 import org.pentaho.metadata.model.IPhysicalTable;
 import org.pentaho.metadata.model.concept.types.LocalizedString;
-import org.pentaho.ui.xul.stereotype.Bindable;
 
 import java.io.Serializable;
 
-public class AvailableField implements Serializable {
+public class AvailableField extends AbstractAvailableItem implements Serializable, IAvailableItem {
 
   private static final long serialVersionUID = -4430951279551589688L;
   
   private transient IPhysicalColumn physicalColumn;
-  private String name, displayName;
+
+  private static final String FIELD_IMAGE = "";
 
   public static String MEASURE_PROP = "potential_measure";
 
   public AvailableField(){
-    
+    setImage(FIELD_IMAGE);
   }
 
-
   public AvailableField(IPhysicalColumn physicalColumn) {
     setPhysicalColumn(physicalColumn);
     setName(physicalColumn.getName(LocalizedString.DEFAULT_LOCALE));
-    setDisplayName(physicalColumn.getName(LocalizedString.DEFAULT_LOCALE));
-  }
-
-  @Bindable
-  public String getName() {
-    return name;
-  }
-
-  @Bindable
-  public void setName(String name) {
-    this.name = name;
+    setImage(FIELD_IMAGE);
   }
 
-  @Bindable
-  public String getDisplayName() {
-    return displayName;
-  }
-
-  @Bindable
-  public void setDisplayName(String displayName) {
-    this.displayName = displayName;
-  }
-
-
-
   public String toString() {
-    return name;
+    return getName();
   }
 
   public IPhysicalColumn getPhysicalColumn() {
@@ -93,5 +70,5 @@ public boolean isPossibleMeasure(){
   public void setPossibleMeasure(boolean possibleMeasure){
     getPhysicalColumn().setProperty(MEASURE_PROP, ""+possibleMeasure);
   }
-  
+
 }
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fnodes%2FAvailableField.java
6f4c2ecf117a709a32ecf18d7b1f4dece912d902
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fres%2Fpanel.xul
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fres%2Fpanel.xul?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/res/panel.xul
        <tree id="fieldList" flex="1" editable="false" hiddenrootnode="true" preserveselection="true">
          <treecols>
            <treecol flex="1" label="" primary="true"
              pen:binding="name" pen:childrenbinding="children"
              pen:imagebinding="image" editable="false"
              pen:expandedbinding="expanded"/>
          </treecols>
          <treechildren>
            <treeitem container="true" open="true">
              <treerow>
                <treecell label="" />
              </treerow>
              <treechildren></treechildren>
            </treeitem>
          </treechildren>

        </tree>
      </editpanel>
        <listbox id="fieldList" flex="1" seltype="multi"
          pen:binding="name" ondrag="modeler.onFieldListDrag()"
          pen:drageffect="copy">
          <listitem label="field" />
          <listitem label="field" />
          <listitem label="field" />
          <listitem label="field" />
          <listitem label="field" />
          <listitem label="field" />
        </listbox>
      </editpanel>
@@ -41,18 +41,25 @@
           <toolbarbutton id="addField" image="images/insert_to_model.png" onclick="modeler.addField()" tooltiptext="${add}"/>
         </toolbar>
 
-        <listbox id="fieldList" flex="1" seltype="multi"
-          pen:binding="name" ondrag="modeler.onFieldListDrag()"
-          pen:drageffect="copy">
-          <listitem label="field" />
-          <listitem label="field" />
-          <listitem label="field" />
-          <listitem label="field" />
-          <listitem label="field" />
-          <listitem label="field" />
-        </listbox>
-      </editpanel>
+        <tree id="fieldList" flex="1" editable="false" hiddenrootnode="true" preserveselection="true">
+          <treecols>
+            <treecol flex="1" label="" primary="true"
+              pen:binding="name" pen:childrenbinding="children"
+              pen:imagebinding="image" editable="false"
+              pen:expandedbinding="expanded"/>
+          </treecols>
+          <treechildren>
+            <treeitem container="true" open="true">
+              <treerow>
+                <treecell label="" />
+              </treerow>
+              <treechildren></treechildren>
+            </treeitem>
+          </treechildren>
+
+        </tree>
 
+      </editpanel>
       <deck id="modelDeck" flex="1">
 
         <tabbox id="modelTabbox" flex="1" >
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fres%2Fpanel.xul
1392e0bacc8a1a4b5f3f8054537fa039b134ef8c
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fservices%2FIModelerService.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fservices%2FIModelerService.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/services/IModelerService.java
import org.pentaho.agilebi.modeler.ModelerWorkspace;
import org.pentaho.agilebi.modeler.nodes.AvailableField;
import org.pentaho.agilebi.modeler.nodes.AvailableFieldCollection;
import org.pentaho.agilebi.modeler.nodes.MainModelNode;
import org.pentaho.ui.xul.XulServiceCallback;

import java.util.List;
@@ -1,14 +1,7 @@
 package org.pentaho.agilebi.modeler.services;
 
-import org.pentaho.agilebi.modeler.ModelerWorkspace;
 import org.pentaho.agilebi.modeler.gwt.BogoPojo;
-import org.pentaho.agilebi.modeler.nodes.AvailableField;
-import org.pentaho.agilebi.modeler.nodes.AvailableFieldCollection;
-import org.pentaho.agilebi.modeler.nodes.MainModelNode;
 import org.pentaho.metadata.model.Domain;
-import org.pentaho.ui.xul.XulServiceCallback;
-
-import java.util.List;
 
 /**
  * User: nbaker
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fservices%2FIModelerService.java
60e5d5cdbcbac15a8d545ac175dae521afe03af6
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fservices%2FIModelerServiceAsync.java
https://api.github.com/repos/pentaho/modeler/contents/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fservices%2FIModelerServiceAsync.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
src/org/pentaho/agilebi/modeler/services/IModelerServiceAsync.java
import org.pentaho.agilebi.modeler.ModelerWorkspace;
import org.pentaho.agilebi.modeler.nodes.AvailableFieldCollection;
import org.pentaho.agilebi.modeler.nodes.MainModelNode;
@@ -1,8 +1,5 @@
 package org.pentaho.agilebi.modeler.services;
 
-import org.pentaho.agilebi.modeler.ModelerWorkspace;
-import org.pentaho.agilebi.modeler.nodes.AvailableFieldCollection;
-import org.pentaho.agilebi.modeler.nodes.MainModelNode;
 import org.pentaho.agilebi.modeler.gwt.BogoPojo;
 import org.pentaho.metadata.model.Domain;
 import org.pentaho.ui.xul.XulServiceCallback;
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Fservices%2FIModelerServiceAsync.java
dd051353834ea4369b5d27991a03ec47a6003707
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FAvailableColumnsTest.java
https://api.github.com/repos/pentaho/modeler/contents/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FAvailableColumnsTest.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
test-src/org/pentaho/agilebi/modeler/AvailableColumnsTest.java
import org.pentaho.agilebi.modeler.nodes.AvailableTable;
import java.util.List;

import static org.junit.Assert.*;

    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();
    int fields = tablesList.get(0).getAvailableFields().size();
    AvailableField field1 = tablesList.get(0).getAvailableFields().get(0);
    AvailableField field2 = tablesList.get(0).getAvailableFields().get(1);
import org.junit.Before;
import static org.junit.Assert.*;

    int fields = workspace.getAvailableFields().size();
    AvailableField field1 = workspace.getAvailableFields().get(0);
    AvailableField field2 = workspace.getAvailableFields().get(1);
@@ -1,12 +1,14 @@
 package org.pentaho.agilebi.modeler;
 
-import org.junit.Before;
 import org.junit.Test;
-import static org.junit.Assert.*;
-
 import org.pentaho.agilebi.modeler.nodes.AvailableField;
+import org.pentaho.agilebi.modeler.nodes.AvailableTable;
 import org.pentaho.metadata.model.LogicalModel;
 
+import java.util.List;
+
+import static org.junit.Assert.*;
+
 /**
  * User: nbaker
  * Date: 4/8/11
@@ -17,14 +19,15 @@ public class AvailableColumnsTest extends AbstractModelerTest{
   public void testAvailableColumnPossibleMeasure() throws ModelerException {
     super.generateTestDomain();
     LogicalModel logicalModel = workspace.getDomain().getLogicalModels().get(0);
-    int fields = workspace.getAvailableFields().size();
+    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();
+    int fields = tablesList.get(0).getAvailableFields().size();
     assertTrue(fields > 2);
 
     // replicating work that would be done by the auto-modeler
-    AvailableField field1 = workspace.getAvailableFields().get(0);
+    AvailableField field1 = tablesList.get(0).getAvailableFields().get(0);
     field1.setPossibleMeasure(true);
 
-    AvailableField field2 = workspace.getAvailableFields().get(1);
+    AvailableField field2 = tablesList.get(0).getAvailableFields().get(1);
     field2.setPossibleMeasure(false);
 
     assertTrue(field1.isPossibleMeasure());
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FAvailableColumnsTest.java
2858ac4c60cdeaf2034d9068702d73e5bbc2dfb1
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FBaseModelerWorkspaceHelperTest.java
https://api.github.com/repos/pentaho/modeler/contents/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FBaseModelerWorkspaceHelperTest.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
test-src/org/pentaho/agilebi/modeler/BaseModelerWorkspaceHelperTest.java
import org.pentaho.agilebi.modeler.nodes.*;
    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();

    int fields = tablesList.get(0).getAvailableFields().size();
    assertEquals(fields, tablesList.get(0).getAvailableFields().size());
    assertEquals(tablesList.get(0).getAvailableFields().size(), categories.get(0).getLogicalColumns().size());
    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();

    assertEquals(tablesList.get(0).getAvailableFields().size(), categories.get(0).getLogicalColumns().size());
    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();
    for (AvailableField af : tablesList.get(0).getAvailableFields()) {
import org.junit.Before;
import org.junit.BeforeClass;
import org.pentaho.agilebi.modeler.nodes.AvailableField;
import org.pentaho.agilebi.modeler.nodes.CategoryMetaData;
import org.pentaho.agilebi.modeler.nodes.FieldMetaData;
import org.pentaho.agilebi.modeler.nodes.RelationalModelNode;
import org.pentaho.agilebi.modeler.util.ModelerSourceUtil;
import org.pentaho.agilebi.modeler.util.SpoonModelerMessages;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.Props;
import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.exception.KettleException;
    int fields = workspace.getAvailableFields().size();
    assertEquals(fields, workspace.getAvailableFields().size());
    assertEquals(workspace.getAvailableFields().size(), categories.get(0).getLogicalColumns().size());
    assertEquals(workspace.getAvailableFields().size(), categories.get(0).getLogicalColumns().size());
    for (AvailableField af : workspace.getAvailableFields()) {
  @Test
  public void testGetCorrespondingOlapColumnId() {
    String origTableId = "BT_CUSTOMERS_CUSTOMERS";
    String origColumnId = "LC_CUSTOMERS_CUSTOMERNUMBER";
    String olapColumnId = "LC_CUSTOMERS_CUSTOMERS_OLAP_CUSTOMERNUMBER";

    LogicalTable ltOrig = new LogicalTable();
    ltOrig.setId(origTableId);

    LogicalColumn lcOrig = new LogicalColumn();
    lcOrig.setId(origColumnId);
    lcOrig.setLogicalTable(ltOrig);
    IPhysicalColumn pc = new SqlPhysicalColumn();
    pc.setId("CUSTOMERNUMBER");
    lcOrig.setPhysicalColumn(pc);

    assertEquals(olapColumnId, BaseModelerWorkspaceHelper.getCorrespondingOlapColumnId(lcOrig));

  }



test-src/org/pentaho/agilebi/modeler/BaseModelerWorkspaceHelperTest.java
String origTableId = "BT_CUSTOMERS_CUSTOMERS";
    String origColumnId = "LC_CUSTOMERS_CUSTOMERNUMBER";
    String olapColumnId = "LC_CUSTOMERS_CUSTOMERS_OLAP_CUSTOMERNUMBER";

    LogicalTable ltOrig = new LogicalTable();
    ltOrig.setId(origTableId);

    LogicalColumn lcOrig = new LogicalColumn();
    lcOrig.setId(origColumnId);
    lcOrig.setLogicalTable(ltOrig);
    IPhysicalColumn pc = new SqlPhysicalColumn();
    pc.setId("CUSTOMERNUMBER");
    lcOrig.setPhysicalColumn(pc);

    assertEquals(olapColumnId, BaseModelerWorkspaceHelper.getCorrespondingOlapColumnId(lcOrig));
void testGetCorrespondingOlapColumnId()
@@ -1,19 +1,8 @@
 package org.pentaho.agilebi.modeler;
 
-import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
-import org.pentaho.agilebi.modeler.nodes.AvailableField;
-import org.pentaho.agilebi.modeler.nodes.CategoryMetaData;
-import org.pentaho.agilebi.modeler.nodes.FieldMetaData;
-import org.pentaho.agilebi.modeler.nodes.RelationalModelNode;
-import org.pentaho.agilebi.modeler.util.ModelerSourceUtil;
+import org.pentaho.agilebi.modeler.nodes.*;
 import org.pentaho.agilebi.modeler.util.ModelerWorkspaceHelper;
-import org.pentaho.agilebi.modeler.util.SpoonModelerMessages;
-import org.pentaho.di.core.KettleEnvironment;
-import org.pentaho.di.core.Props;
-import org.pentaho.di.core.database.DatabaseMeta;
-import org.pentaho.di.core.exception.KettleException;
 import org.pentaho.metadata.model.*;
 import org.pentaho.metadata.model.concept.types.AggregationType;
 import org.pentaho.metadata.model.concept.types.DataType;
@@ -78,17 +67,19 @@ public void testFieldAggregations() throws ModelerException{
   public void testPopulateCategories() throws ModelerException {
     ModelerWorkspaceHelper helper = new ModelerWorkspaceHelper(LOCALE);
     LogicalModel logicalModel = workspace.getDomain().getLogicalModels().get(0);
-    int fields = workspace.getAvailableFields().size();
+    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();
+
+    int fields = tablesList.get(0).getAvailableFields().size();
     helper.autoModelFlat(workspace);
     helper.autoModelRelationalFlat(workspace);
     helper.populateCategories(workspace);
 
     List<Category> categories = logicalModel.getCategories();
 
     assertEquals(1, categories.size());
-    assertEquals(fields, workspace.getAvailableFields().size());
+    assertEquals(fields, tablesList.get(0).getAvailableFields().size());
     System.out.println(logicalModel.getLogicalTables().get(0).getLogicalColumns().size());
-    assertEquals(workspace.getAvailableFields().size(), categories.get(0).getLogicalColumns().size());
+    assertEquals(tablesList.get(0).getAvailableFields().size(), categories.get(0).getLogicalColumns().size());
 
     for (LogicalColumn lCol : categories.get(0).getLogicalColumns()) {
       FieldMetaData orig = null;
@@ -121,9 +112,11 @@ public void testPopulateCategories_MultipleCategoriesAggregationTypesAndFormatMa
     spiceUpRelationalModel(workspace.getRelationalModel());
     helper.populateCategories(workspace);
 
+    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();
+
     List<Category> categories = logicalModel.getCategories();
     assertEquals(2, categories.size());
-    assertEquals(workspace.getAvailableFields().size(), categories.get(0).getLogicalColumns().size());
+    assertEquals(tablesList.get(0).getAvailableFields().size(), categories.get(0).getLogicalColumns().size());
     System.out.println(logicalModel.getLogicalTables().get(0).getLogicalColumns().size());
 
     assertEquals(1, categories.get(1).getLogicalColumns().size());
@@ -159,10 +152,11 @@ private void spiceUpRelationalModel(RelationalModelNode model) {
 
   private CategoryMetaData createCategoryMetaData(String name) {
     CategoryMetaData cat = new CategoryMetaData(name);
+    List<AvailableTable> tablesList = workspace.getAvailableTables().getAsAvailableTablesList();
 
     FieldMetaData field = null;
     AvailableField avaialbleField = null;
-    for (AvailableField af : workspace.getAvailableFields()) {
+    for (AvailableField af : tablesList.get(0).getAvailableFields()) {
       if (af.getPhysicalColumn().getDataType() == DataType.NUMERIC) {
         avaialbleField = af;
         break;
@@ -176,26 +170,4 @@ private CategoryMetaData createCategoryMetaData(String name) {
     return cat;
   }
 
-  @Test
-  public void testGetCorrespondingOlapColumnId() {
-    String origTableId = "BT_CUSTOMERS_CUSTOMERS";
-    String origColumnId = "LC_CUSTOMERS_CUSTOMERNUMBER";
-    String olapColumnId = "LC_CUSTOMERS_CUSTOMERS_OLAP_CUSTOMERNUMBER";
-
-    LogicalTable ltOrig = new LogicalTable();
-    ltOrig.setId(origTableId);
-
-    LogicalColumn lcOrig = new LogicalColumn();
-    lcOrig.setId(origColumnId);
-    lcOrig.setLogicalTable(ltOrig);
-    IPhysicalColumn pc = new SqlPhysicalColumn();
-    pc.setId("CUSTOMERNUMBER");
-    lcOrig.setPhysicalColumn(pc);
-
-    assertEquals(olapColumnId, BaseModelerWorkspaceHelper.getCorrespondingOlapColumnId(lcOrig));
-
-  }
-
-
-
 }
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FBaseModelerWorkspaceHelperTest.java
371ae06a5669ac12d41e348588f8b01948911c65
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FModelerWorkspaceTest.java
https://api.github.com/repos/pentaho/modeler/contents/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FModelerWorkspaceTest.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
test-src/org/pentaho/agilebi/modeler/ModelerWorkspaceTest.java
    for (AvailableTable table : workspace.getAvailableTables().getAsAvailableTablesList()) {
        if (table.containsUnderlyingPhysicalColumn(lc.getPhysicalColumn())) {
          return true;
        }
    for (AvailableField field : workspace.getAvailableFields()) {
      if (field.getPhysicalColumn().getId().equals(lc.getPhysicalColumn().getId())) {
        return true;
      }
@@ -113,10 +113,10 @@ private boolean isReferencedTableReportingVersion(LogicalColumn logicalColumn) {
   }
 
   private boolean isColumnReferencedInAvailableFields(LogicalColumn lc) {
-    for (AvailableField field : workspace.getAvailableFields()) {
-      if (field.getPhysicalColumn().getId().equals(lc.getPhysicalColumn().getId())) {
-        return true;
-      }
+    for (AvailableTable table : workspace.getAvailableTables().getAsAvailableTablesList()) {
+        if (table.containsUnderlyingPhysicalColumn(lc.getPhysicalColumn())) {
+          return true;
+        }
     }
     return false;
   }
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2FModelerWorkspaceTest.java
32307bd573933efbb67d0a3a92d26d95cfc2c0a9
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Futil%2FModelerSourceUtilTest.java
https://api.github.com/repos/pentaho/modeler/contents/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Futil%2FModelerSourceUtilTest.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
test-src/org/pentaho/agilebi/modeler/util/ModelerSourceUtilTest.java
import org.junit.BeforeClass;
import org.pentaho.agilebi.modeler.ModelerMessagesHolder;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.core.Props;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.metadata.model.LogicalColumn;
import java.util.List;

    // make sure the column id's & names are not equal between the copies
    List<LogicalColumn> orig = logicalModel.getLogicalTables().get(0).getLogicalColumns();
    List<LogicalColumn> copy = logicalModel.getLogicalTables().get(1).getLogicalColumns();
    for(int i = 0; i < physicalColumns; i++) {
      assertCopiesAreKosher(orig.get(i), copy.get(i));
    }
  }

  private void assertCopiesAreKosher(LogicalColumn lc1, LogicalColumn lc2) {
    assertEquals(lc1.getPhysicalColumn(), lc2.getPhysicalColumn());

    String newColName = lc1.getLogicalTable().getId().replaceAll("BT", "LC");
    newColName += "_OLAP_" + lc1.getPhysicalColumn().getId();
    
    assertEquals(newColName, lc2.getId());
    assertEquals(lc1.getAggregationType(), lc2.getAggregationType());
    assertEquals(lc1.getDataType(), lc2.getDataType());
@@ -17,23 +17,15 @@
 
 package org.pentaho.agilebi.modeler.util;
 
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.pentaho.agilebi.modeler.AbstractModelerTest;
 import org.pentaho.agilebi.modeler.BaseModelerWorkspaceHelper;
 import org.pentaho.agilebi.modeler.ModelerException;
-import org.pentaho.agilebi.modeler.ModelerMessagesHolder;
-import org.pentaho.di.core.KettleEnvironment;
-import org.pentaho.di.core.Props;
 import org.pentaho.di.core.database.DatabaseMeta;
-import org.pentaho.di.core.exception.KettleException;
 import org.pentaho.metadata.model.Domain;
-import org.pentaho.metadata.model.LogicalColumn;
 import org.pentaho.metadata.model.LogicalModel;
 import org.pentaho.metadata.model.LogicalTable;
 
-import java.util.List;
-
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;
 
@@ -114,23 +106,6 @@ public void testDuplicateLogicalTablesForDualModelingMode() throws ModelerExcept
     LogicalTable copyTable = logicalModel.getLogicalTables().get(1);
     assertEquals(origTable.getId() + "_OLAP", copyTable.getId());
 
-    // make sure the column id's & names are not equal between the copies
-    List<LogicalColumn> orig = logicalModel.getLogicalTables().get(0).getLogicalColumns();
-    List<LogicalColumn> copy = logicalModel.getLogicalTables().get(1).getLogicalColumns();
-    for(int i = 0; i < physicalColumns; i++) {
-      assertCopiesAreKosher(orig.get(i), copy.get(i));
-    }
-  }
-
-  private void assertCopiesAreKosher(LogicalColumn lc1, LogicalColumn lc2) {
-    assertEquals(lc1.getPhysicalColumn(), lc2.getPhysicalColumn());
-
-    String newColName = lc1.getLogicalTable().getId().replaceAll("BT", "LC");
-    newColName += "_OLAP_" + lc1.getPhysicalColumn().getId();
-    
-    assertEquals(newColName, lc2.getId());
-    assertEquals(lc1.getAggregationType(), lc2.getAggregationType());
-    assertEquals(lc1.getDataType(), lc2.getDataType());
   }
 
   public static DatabaseMeta getDatabaseMeta() {
https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Futil%2FModelerSourceUtilTest.java
5cee45d03b0b809fd63874514de4df8d10f33de0
modified
https://github.com/pentaho/modeler/blob/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Futil%2FTableModelerSourceTest.java
https://api.github.com/repos/pentaho/modeler/contents/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Futil%2FTableModelerSourceTest.java?ref=e8949857917389cb594a4fcbd8ede077af7f24e7
test-src/org/pentaho/agilebi/modeler/util/TableModelerSourceTest.java
import org.junit.Test;

  @Test
  public void test() {
    // come back to this
  }

test-src/org/pentaho/agilebi/modeler/util/TableModelerSourceTest.java
// come back to this
void test()
@@ -17,10 +17,16 @@
 
 package org.pentaho.agilebi.modeler.util;
 
+import org.junit.Test;
+
 /**
  * Created: 3/31/11
  *
  * @author rfellows
  */
 public class TableModelerSourceTest {
+  @Test
+  public void test() {
+    // come back to this
+  }
 }

https://github.com/pentaho/modeler/raw/e8949857917389cb594a4fcbd8ede077af7f24e7/test-src%2Forg%2Fpentaho%2Fagilebi%2Fmodeler%2Futil%2FTableModelerSourceTest.java
84e11d0c65372165268c58f685e8a7a7b280bee2
modified
pentaho$modeler
return availableTables;
  private void fireTablesChanged() {
    firePropertyChange("availableTables", null, this.availableTables); //$NON-NLS-1$
    // Add in new physical tables/columns
      // see if the table is in the availableTables list
      AvailableTable aTable = availableTables.findAvailableTable(table.getName(LocalizedString.DEFAULT_LOCALE));
      if (aTable == null) {
        // new table, make sure we add it
        availableTables.add(new AvailableTable(table));
AvailableItemCollection
AvailableItemCollection getAvailableTables()
return availableFields;

  private void fireFieldsChanged() {
    firePropertyChange("availableFields", null, this.availableFields); //$NON-NLS-1$
    // Add in new physical columns
      for(IPhysicalColumn column : table.getPhysicalColumns()) {
        boolean exists = false;
        inner:
        for(AvailableField field : this.availableFields) {
          if (field.isSameUnderlyingPhysicalColumn(column)) {
            exists = true;
            break inner;
AvailableFieldCollection
AvailableFieldCollection getAvailableFields()