Esempio n. 1
0
  public String getType(DTColumnConfig col, SuggestionCompletionEngine sce) {
    String type = null;
    if (col instanceof AttributeCol) {
      AttributeCol at = (AttributeCol) col;
      type = at.getAttribute();
    } else if (col instanceof ConditionCol) {
      ConditionCol c = (ConditionCol) col;
      type = sce.getFieldType(c.getFactType(), c.getFactField());
    } else if (col instanceof ActionSetFieldCol) {
      ActionSetFieldCol c = (ActionSetFieldCol) col;
      type = sce.getFieldType(getBoundFactType(c.getBoundName()), c.getFactField());
    } else if (col instanceof ActionInsertFactCol) {
      ActionInsertFactCol c = (ActionInsertFactCol) col;
      type = sce.getFieldType(c.getFactType(), c.getFactField());
    }

    return type;
  }
Esempio n. 2
0
 private boolean isDataType(DTColumnConfig col, SuggestionCompletionEngine sce, String dataType) {
   if (col instanceof RowNumberCol) {
     throw new IllegalArgumentException(
         "Only ConditionCol and Actions permitted. Consider using one of the public is<DataType> methods.");
   }
   if (col instanceof DescriptionCol) {
     throw new IllegalArgumentException(
         "Only ConditionCol and Actions permitted. Consider using one of the public is<DataType> methods.");
   }
   if (col instanceof MetadataCol) {
     throw new IllegalArgumentException(
         "Only ConditionCol and Actions permitted. Consider using one of the public is<DataType> methods.");
   }
   if (col instanceof AttributeCol) {
     throw new IllegalArgumentException(
         "Only ConditionCol and Actions permitted. Consider using one of the public is<DataType> methods.");
   }
   if (col instanceof ConditionCol) {
     ConditionCol c = (ConditionCol) col;
     if (c.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_LITERAL) {
       if (c.getOperator() == null || "".equals(c.getOperator())) {
         return false;
       }
       String ft = sce.getFieldType(c.getFactType(), c.getFactField());
       if (ft != null && ft.equals(dataType)) {
         return true;
       }
     }
   } else if (col instanceof ActionSetFieldCol) {
     ActionSetFieldCol c = (ActionSetFieldCol) col;
     String ft = sce.getFieldType(getBoundFactType(c.getBoundName()), c.getFactField());
     if (ft != null && ft.equals(dataType)) {
       return true;
     }
   } else if (col instanceof ActionInsertFactCol) {
     ActionInsertFactCol c = (ActionInsertFactCol) col;
     String ft = sce.getFieldType(c.getFactType(), c.getFactField());
     if (ft != null && ft.equals(dataType)) {
       return true;
     }
   }
   return false;
 }
Esempio n. 3
0
  /**
   * This will return a list of valid values. if there is no such "enumeration" of values, then it
   * will return an empty array.
   */
  public String[] getValueList(DTColumnConfig col, SuggestionCompletionEngine sce) {
    if (col instanceof AttributeCol) {
      AttributeCol at = (AttributeCol) col;
      if ("no-loop".equals(at.getAttribute()) || "enabled".equals(at.getAttribute())) {
        return new String[] {"true", "false"};
      }
    } else if (col instanceof ConditionCol) {
      // conditions: if its a formula etc, just return String[0],
      // otherwise check with the sce
      ConditionCol c = (ConditionCol) col;
      if (c.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_RET_VALUE
          || c.getConstraintValueType() == BaseSingleFieldConstraint.TYPE_PREDICATE) {
        return new String[0];
      } else {
        if (c.getValueList() != null && !"".equals(c.getValueList())) {
          return c.getValueList().split(",");
        } else {
          String[] r = sce.getEnumValues(c.getFactType(), c.getFactField());
          return (r != null) ? r : new String[0];
        }
      }
    } else if (col instanceof ActionSetFieldCol) {
      ActionSetFieldCol c = (ActionSetFieldCol) col;
      if (c.getValueList() != null && !"".equals(c.getValueList())) {
        return c.getValueList().split(",");
      } else {
        String[] r = sce.getEnumValues(getBoundFactType(c.getBoundName()), c.getFactField());
        return (r != null) ? r : new String[0];
      }
    } else if (col instanceof ActionInsertFactCol) {
      ActionInsertFactCol c = (ActionInsertFactCol) col;
      if (c.getValueList() != null && !"".equals(c.getValueList())) {
        return c.getValueList().split(",");
      } else {
        String[] r = sce.getEnumValues(c.getFactType(), c.getFactField());
        return (r != null) ? r : new String[0];
      }
    }

    return new String[0];
  }