@Override
  public void getOperatorCompletions(
      final Pattern52 selectedPattern,
      final ConditionCol52 selectedCondition,
      final Callback<String[]> callback) {

    final String factType = selectedPattern.getFactType();
    final String factField = selectedCondition.getFactField();
    this.oracle.getOperatorCompletions(
        factType,
        factField,
        new Callback<String[]>() {
          @Override
          public void callback(final String[] ops) {
            // Operators "in" and "not in" are only allowed if the Calculation Type is a Literal
            final List<String> filteredOps = new ArrayList<String>();
            for (String op : ops) {
              filteredOps.add(op);
            }
            if (BaseSingleFieldConstraint.TYPE_LITERAL
                != selectedCondition.getConstraintValueType()) {
              filteredOps.remove("in");
              filteredOps.remove("not in");
            }

            final String[] displayOps = new String[filteredOps.size()];
            filteredOps.toArray(displayOps);
            callback.callback(displayOps);
          }
        });
  }
  private String getType(final Pattern52 pattern, final ConditionCol52 col) {

    // Columns with "Value Lists" etc are always Text (for now)
    if (hasValueList(col)) {
      return DataType.TYPE_STRING;
    }

    // Operator "in" and "not in" requires a List as the value. These are always Text (for now)
    if (OperatorsOracle.operatorRequiresList(col.getOperator())) {
      return DataType.TYPE_STRING;
    }

    // Literals without operators are always Text (as the user can specify the operator "in cell")
    if (col.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_LITERAL) {
      if (col.getOperator() == null || "".equals(col.getOperator())) {
        return DataType.TYPE_STRING;
      }
    }

    // Formula are always Text (as the user can specify anything "in cell")
    if (col.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_PREDICATE) {
      return DataType.TYPE_STRING;
    }

    // Predicates are always Text (as the user can specify anything "in cell")
    if (col.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_RET_VALUE) {
      return DataType.TYPE_STRING;
    }

    // Otherwise lookup from SuggestionCompletionEngine
    final String factType = pattern.getFactType();
    final String fieldName = col.getFactField();
    return getTypeFromDataOracle(factType, fieldName);
  }
  @Override
  public void isComplete(final Callback<Boolean> callback) {
    // Have all patterns conditions been defined?
    boolean areConditionsDefined = true;
    for (Pattern52 p : model.getPatterns()) {
      for (ConditionCol52 c : p.getChildColumns()) {
        if (!getValidator().isConditionValid(c)) {
          areConditionsDefined = false;
          break;
        }
      }
    }

    // Signal Condition definitions to other pages
    final ConditionsDefinedEvent event = new ConditionsDefinedEvent(areConditionsDefined);
    conditionsDefinedEvent.fire(event);

    callback.callback(areConditionsDefined);
  }
 public String getBoundFactType(String boundName) {
   for (CompositeColumn<?> cc : this.model.getConditions()) {
     if (cc instanceof Pattern52) {
       final Pattern52 p = (Pattern52) cc;
       if (p.isBound() && p.getBoundName().equals(boundName)) {
         return p.getFactType();
       }
     } else if (cc instanceof BRLConditionColumn) {
       final BRLConditionColumn brl = (BRLConditionColumn) cc;
       for (IPattern p : brl.getDefinition()) {
         if (p instanceof FactPattern) {
           FactPattern fp = (FactPattern) p;
           if (fp.isBound() && fp.getBoundName().equals(boundName)) {
             return fp.getFactType();
           }
         }
       }
     }
   }
   return new String();
 }
  private String getType(final Pattern52 pattern, final ActionSetFieldCol52 col) {

    // Columns with "Value Lists" etc are always Text (for now)
    if (hasValueList(col)) {
      return DataType.TYPE_STRING;
    }

    // Otherwise lookup from SuggestionCompletionEngine
    final String factType = pattern.getFactType();
    final String fieldName = col.getFactField();
    return getTypeFromDataOracle(factType, fieldName);
  }
  @Override
  public void selectPattern(final Pattern52 pattern) {

    // Pattern is null when programmatically deselecting an item
    if (pattern == null) {
      return;
    }

    // Add Fact fields
    final String type = pattern.getFactType();
    oracle.getFieldCompletions(
        type,
        new Callback<ModelField[]>() {
          @Override
          public void callback(final ModelField[] fields) {
            final List<AvailableField> availableFields = new ArrayList<AvailableField>();
            for (ModelField modelField : fields) {
              final String fieldName = modelField.getName();
              final String fieldType = oracle.getFieldType(type, fieldName);
              final String fieldDisplayType =
                  HumanReadableDataTypes.getUserFriendlyTypeName(fieldType);
              final AvailableField field =
                  new AvailableField(
                      fieldName,
                      fieldType,
                      fieldDisplayType,
                      BaseSingleFieldConstraint.TYPE_LITERAL);
              availableFields.add(field);
            }

            // Add predicates
            if (model.getTableFormat() == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY) {
              final AvailableField field =
                  new AvailableField(
                      GuidedDecisionTableConstants.INSTANCE.DecisionTableWizardPredicate(),
                      BaseSingleFieldConstraint.TYPE_PREDICATE);
              availableFields.add(field);
            }

            view.setAvailableFields(availableFields);
            view.setChosenConditions(pattern.getChildColumns());
          }
        });
  }
  @Override
  public boolean requiresValueList(
      final Pattern52 selectedPattern, final ConditionCol52 selectedCondition) {
    // Don't show a Value List if either the Fact\Field is empty
    final String factType = selectedPattern.getFactType();
    final String factField = selectedCondition.getFactField();
    boolean enableValueList =
        !((factType == null || "".equals(factType)) || (factField == null || "".equals(factField)));

    // Don't show Value List if operator does not accept one
    if (enableValueList) {
      enableValueList = validator.doesOperatorAcceptValueList(selectedCondition);
    }

    // Don't show a Value List if the Fact\Field has an enumeration
    if (enableValueList) {
      enableValueList = !oracle.hasEnums(factType, factField);
    }
    return enableValueList;
  }
 @Override
 public boolean hasEnum(final Pattern52 selectedPattern, final ConditionCol52 selectedCondition) {
   final String factType = selectedPattern.getFactType();
   final String factField = selectedCondition.getFactField();
   return oracle.hasEnums(factType, factField);
 }
 @Override
 public void setChosenConditions(final Pattern52 pattern, final List<ConditionCol52> conditions) {
   pattern.getChildColumns().clear();
   pattern.getChildColumns().addAll(conditions);
 }