@Override
  public void initialise() {
    view.init(this);
    view.setValidator(getValidator());

    patternToActionsMap.clear();

    // Set-up validator for the pattern-to-action mapping voodoo
    getValidator().setPatternToActionInsertFactFieldsMap(patternToActionsMap);

    // Set-up a factory for value editors
    view.setDTCellValueWidgetFactory(
        DTCellValueWidgetFactory.getInstance(model, oracle, false, allowEmptyValues()));

    // Available types
    final List<String> availableTypes = Arrays.asList(oracle.getFactTypes());
    view.setAvailableFactTypes(availableTypes);

    // Existing ActionInsertFactCols (should be empty for a new Decision Table)
    for (ActionCol52 a : model.getActionCols()) {
      if (a instanceof ActionInsertFactCol52) {
        final ActionInsertFactCol52 aif = (ActionInsertFactCol52) a;
        final ActionInsertFactFieldsPattern p = lookupExistingInsertFactPattern(aif.getBoundName());
        final List<ActionInsertFactCol52> actions = patternToActionsMap.get(p);
        getValidator().addActionPattern(p);
        actions.add(aif);
      }
    }
    view.setChosenPatterns(new ArrayList<ActionInsertFactFieldsPattern>());
    view.setAvailableFields(new ArrayList<AvailableField>());
    view.setChosenFields(new ArrayList<ActionInsertFactCol52>());

    content.setWidget(view);
  }
  @Override
  public void makeResult(final GuidedDecisionTable52 model) {
    // Copy actions to decision table model
    int fi = 1;
    for (Map.Entry<ActionInsertFactFieldsPattern, List<ActionInsertFactCol52>> ps :
        patternToActionsMap.entrySet()) {
      final ActionInsertFactFieldsPattern p = ps.getKey();
      if (!getValidator().isPatternValid(p)) {
        String binding = NEW_FACT_PREFIX + (fi++);
        p.setBoundName(binding);
        while (!getValidator().isPatternBindingUnique(p)) {
          binding = NEW_FACT_PREFIX + (fi++);
          p.setBoundName(binding);
        }
      }

      final String factType = p.getFactType();
      final String boundName = p.getBoundName();
      final boolean isLogicalInsert = p.isInsertedLogically();

      for (ActionInsertFactCol52 aif : ps.getValue()) {
        aif.setFactType(factType);
        aif.setBoundName(boundName);
        aif.setInsertLogical(isLogicalInsert);
        model.getActionCols().add(aif);
      }
    }
  }
 public ActionInsertFactCol52ActionInsertFactAdaptor(final ActionInsertFactCol52 action) {
   PortablePreconditions.checkNotNull("action", action);
   this.action = action;
   this.setFactType(action.getFactType());
   final ActionFieldValue afv = new ActionFieldValue();
   afv.setField(action.getFactField());
   afv.setNature(BaseSingleFieldConstraint.TYPE_LITERAL);
   afv.setType(action.getType());
   super.addFieldValue(afv);
 }
  private String getType(final ActionInsertFactCol52 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 = col.getFactType();
    final String fieldName = col.getFactField();
    return getTypeFromDataOracle(factType, fieldName);
  }
 @Override
 public void assertDefaultValue(final ActionInsertFactCol52 selectedAction) {
   final List<String> valueList = Arrays.asList(modelUtils.getValueList(selectedAction));
   if (valueList.size() > 0) {
     final String defaultValue = cellUtils.asString(selectedAction.getDefaultValue());
     if (!valueList.contains(defaultValue)) {
       selectedAction.getDefaultValue().clearValues();
     }
   } else {
     // Ensure the Default Value has been updated to represent the column's data-type.
     final DTCellValue52 defaultValue = selectedAction.getDefaultValue();
     final DataType.DataTypes dataType = cellUtils.getDataType(selectedAction);
     cellUtils.assertDTCellValue(dataType, defaultValue);
   }
 }
 @Override
 public boolean hasEnums(final ActionInsertFactCol52 selectedAction) {
   for (Map.Entry<ActionInsertFactFieldsPattern, List<ActionInsertFactCol52>> e :
       this.patternToActionsMap.entrySet()) {
     if (e.getValue().contains(selectedAction)) {
       final String factType = e.getKey().getFactType();
       final String factField = selectedAction.getFactField();
       return this.oracle.hasEnums(factType, factField);
     }
   }
   return false;
 }
 @Override
 public String getBoundName() {
   return action.getBoundName();
 }
 @Override
 public boolean isBound() {
   return !(action.getBoundName() == null || "".equals(action.getBoundName()));
 }
 public boolean hasValueList(final ActionInsertFactCol52 col) {
   if (col.getValueList() != null && !"".equals(col.getValueList())) {
     return true;
   }
   return false;
 }
 private String[] getValueList(final ActionInsertFactCol52 col) {
   if (col.getValueList() != null && !"".equals(col.getValueList())) {
     return col.getValueList().split(",");
   }
   return new String[0];
 }