コード例 #1
0
  // Make a new Cell for ActionSetField columns
  private DecoratedGridCellValueAdaptor<? extends Comparable<?>> derieveCellFromAction(
      ActionSetFieldCol52 col) {

    // Check if the column has a "Value List" or an enumeration. Value List takes precedence
    final String factType = model.getBoundFactType(col.getBoundName());
    final String fieldName = col.getFactField();
    if (model.hasValueList(col)) {
      return makeValueListCell(col);

    } else if (sce.hasEnums(factType, fieldName)) {
      return makeEnumCell(factType, fieldName);
    }

    return derieveCellFromModel(col);
  }
コード例 #2
0
  // Get Cell applicable to Model's data-type
  private DecoratedGridCellValueAdaptor<? extends Comparable<?>> derieveCellFromModel(
      DTColumnConfig52 col) {

    // Extended Entry...
    DecoratedGridCellValueAdaptor<? extends Comparable<?>> cell = makeTextCell();

    // Get a cell based upon the data-type
    String type = model.getType(col, sce);

    if (type.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) {
      cell = makeNumericCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_NUMERIC_BIGDECIMAL)) {
      cell = makeNumericBigDecimalCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_NUMERIC_BIGINTEGER)) {
      cell = makeNumericBigIntegerCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_NUMERIC_BYTE)) {
      cell = makeNumericByteCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_NUMERIC_DOUBLE)) {
      cell = makeNumericDoubleCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_NUMERIC_FLOAT)) {
      cell = makeNumericFloatCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_NUMERIC_INTEGER)) {
      cell = makeNumericIntegerCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_NUMERIC_LONG)) {
      cell = makeNumericLongCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_NUMERIC_SHORT)) {
      cell = makeNumericShortCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_BOOLEAN)) {
      cell = makeBooleanCell();
    } else if (type.equals(SuggestionCompletionEngine.TYPE_DATE)) {
      cell = makeDateCell();
    }

    return cell;
  }
コード例 #3
0
  // Get the Data Type corresponding to a given column
  protected DTDataTypes52 getDataType(BaseColumn column) {

    // Limited Entry are simply boolean
    if (column instanceof LimitedEntryCol) {
      return DTDataTypes52.BOOLEAN;
    }

    // Action Work Items are always boolean
    if (column instanceof ActionWorkItemCol52) {
      return DTDataTypes52.BOOLEAN;
    }

    // Actions setting Field Values from Work Item Result Parameters are always boolean
    if (column instanceof ActionWorkItemSetFieldCol52
        || column instanceof ActionWorkItemInsertFactCol52) {
      return DTDataTypes52.BOOLEAN;
    }

    // Operators "is null" and "is not null" require a boolean cell
    if (column instanceof ConditionCol52) {
      ConditionCol52 cc = (ConditionCol52) column;
      if (cc.getOperator() != null
          && (cc.getOperator().equals("== null") || cc.getOperator().equals("!= null"))) {
        return DTDataTypes52.BOOLEAN;
      }
    }

    // Extended Entry...
    return model.getTypeSafeType(column, sce);
  }
コード例 #4
0
 /**
  * Construct a new column of data for the underlying model
  *
  * @return
  */
 public List<DTCellValue52> makeColumnData(BaseColumn column) {
   List<DTCellValue52> data = new ArrayList<DTCellValue52>();
   for (int iRow = 0; iRow < model.getData().size(); iRow++) {
     DTCellValue52 cell = makeModelCellValue(column);
     data.add(cell);
   }
   return data;
 }
コード例 #5
0
  // Get a cell for a Value List
  private DecoratedGridCellValueAdaptor<? extends Comparable<?>> makeValueListCell(
      DTColumnConfig52 col) {

    // Columns with "Value Lists" are always Text (for now)
    PopupValueListDropDownEditCell pudd =
        new PopupValueListDropDownEditCell(model.getValueList(col), isReadOnly);
    DecoratedGridCellValueAdaptor<? extends Comparable<?>> cell =
        new DecoratedGridCellValueAdaptor<String>(pudd, eventBus);
    return cell;
  }
コード例 #6
0
 /**
  * Convert a column of domain data to that suitable for the UI
  *
  * @param column
  * @param columnData
  * @return
  */
 public List<CellValue<? extends Comparable<?>>> convertColumnData(
     BaseColumn column, List<DTCellValue52> columnData) {
   List<CellValue<? extends Comparable<?>>> data =
       new ArrayList<CellValue<? extends Comparable<?>>>();
   for (int iRow = 0; iRow < model.getData().size(); iRow++) {
     DTCellValue52 dcv = columnData.get(iRow);
     CellValue<? extends Comparable<?>> cell = convertModelCellValue(column, dcv);
     data.add(cell);
   }
   return data;
 }
コード例 #7
0
 /**
  * Construct a new row of data for the underlying model
  *
  * @return
  */
 public List<DTCellValue52> makeRowData() {
   List<DTCellValue52> data = new ArrayList<DTCellValue52>();
   List<BaseColumn> columns = model.getExpandedColumns();
   // Use allColumns.size() - 1 to exclude the Analysis column that is not stored in the general
   // grid data
   for (int iCol = 0; iCol < columns.size() - 1; iCol++) {
     BaseColumn column = columns.get(iCol);
     DTCellValue52 cell = makeModelCellValue(column);
     data.add(cell);
   }
   return data;
 }
コード例 #8
0
  // Make a new Cell for Condition columns
  private DecoratedGridCellValueAdaptor<? extends Comparable<?>> derieveCellFromCondition(
      ConditionCol52 col) {

    // Operators "is null" and "is not null" require a boolean cell
    if (col.getOperator() != null
        && (col.getOperator().equals("== null") || col.getOperator().equals("!= null"))) {
      return makeBooleanCell();
    }

    // Check if the column has a "Value List" or an enumeration. Value List takes precedence
    final String factType = model.getPattern(col).getFactType();
    final String fieldName = col.getFactField();
    if (model.hasValueList(col)) {
      return makeValueListCell(col);

    } else if (sce.hasEnums(factType, fieldName)) {
      return makeEnumCell(factType, fieldName);
    }

    return derieveCellFromModel(col);
  }
コード例 #9
0
  /**
   * Construct a new row of data for the MergableGridWidget
   *
   * @return
   */
  @Override
  public DynamicDataRow makeUIRowData() {
    DynamicDataRow data = new DynamicDataRow();
    List<BaseColumn> columns = model.getExpandedColumns();
    for (BaseColumn column : columns) {
      DTCellValue52 dcv = makeModelCellValue(column);
      DTDataTypes52 dataType = getDataType(column);
      assertDTCellValue(dataType, dcv);
      CellValue<? extends Comparable<?>> cell = convertModelCellValue(column, dcv);
      data.add(cell);
    }

    return data;
  }
コード例 #10
0
  private ListBox loadPatterns() {
    Set<String> vars = new HashSet<String>();
    ListBox patterns = new ListBox();

    for (Object o : model.getActionCols()) {
      ActionCol52 col = (ActionCol52) o;
      if (col instanceof ActionInsertFactCol52) {
        ActionInsertFactCol52 c = (ActionInsertFactCol52) col;
        if (!vars.contains(c.getBoundName())) {
          patterns.addItem(
              c.getFactType() + " [" + c.getBoundName() + "]",
              c.getFactType() + " " + c.getBoundName());
          vars.add(c.getBoundName());
        }
      }
    }

    return patterns;
  }
コード例 #11
0
  @Test
  public void testImpossibleMatchesString() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    ConditionCol52 name = new ConditionCol52();
    name.setFactField("name");
    name.setOperator("==");
    name.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(name);

    ConditionCol52 notName = new ConditionCol52();
    notName.setFactField("name");
    notName.setOperator("!=");
    notName.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(notName);

    ConditionCol52 nameIn = new ConditionCol52();
    nameIn.setFactField("name");
    nameIn.setOperator("in");
    nameIn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(nameIn);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52("Homer"),
                new DTCellValue52("Bart"),
                new DTCellValue52((String) null),
                new DTCellValue52("Row 1 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52("Homer"),
                new DTCellValue52("Homer"),
                new DTCellValue52((String) null),
                new DTCellValue52("Row 2 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52("Homer"),
                new DTCellValue52((String) null),
                new DTCellValue52((String) null),
                new DTCellValue52("Row 3 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("4")),
                new DTCellValue52("Row 4 description"),
                new DTCellValue52((String) null),
                new DTCellValue52("Bart"),
                new DTCellValue52((String) null),
                new DTCellValue52("Row 4 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("5")),
                new DTCellValue52("Row 5 description"),
                new DTCellValue52("Homer"),
                new DTCellValue52((String) null),
                new DTCellValue52("Marge,Lisa"),
                new DTCellValue52("Row 5 message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getImpossibleMatchesSize());
    assertEquals(1, analysisData.get(1).getImpossibleMatchesSize());
    assertEquals(0, analysisData.get(2).getImpossibleMatchesSize());
    assertEquals(0, analysisData.get(3).getImpossibleMatchesSize());
    assertEquals(1, analysisData.get(4).getImpossibleMatchesSize());
  }
コード例 #12
0
  @Test
  public void testConflictingMatchCombination() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    ConditionCol52 ageMinimum = new ConditionCol52();
    ageMinimum.setFactField("age");
    ageMinimum.setOperator(">=");
    ageMinimum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(ageMinimum);

    ConditionCol52 ageMaximum = new ConditionCol52();
    ageMaximum.setFactField("age");
    ageMaximum.setOperator("<=");
    ageMaximum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(ageMaximum);

    ConditionCol52 approved = new ConditionCol52();
    approved.setFactField("approved");
    approved.setOperator("==");
    approved.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(approved);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(new BigDecimal("20")),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52("Row 1 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52(new BigDecimal("21")),
                new DTCellValue52(new BigDecimal("40")),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52("Row 2 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52(new BigDecimal("41")),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52("Row 3 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("4")),
                new DTCellValue52("Row 4 description"),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(new BigDecimal("25")),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 4 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("5")),
                new DTCellValue52("Row 5 description"),
                new DTCellValue52(new BigDecimal("26")),
                new DTCellValue52(new BigDecimal("60")),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 5 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("6")),
                new DTCellValue52("Row 6 description"),
                new DTCellValue52(new BigDecimal("50")),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 6 message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getConflictingMatchSize());
    assertEquals(0, analysisData.get(1).getConflictingMatchSize());
    assertEquals(0, analysisData.get(2).getConflictingMatchSize());
    assertEquals(0, analysisData.get(3).getConflictingMatchSize());
    assertEquals(1, analysisData.get(4).getConflictingMatchSize());
    assertEquals(1, analysisData.get(5).getConflictingMatchSize());
  }
コード例 #13
0
  @Test
  public void testConflictingMatchLimitedEntry() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    LimitedEntryConditionCol52 child = new LimitedEntryConditionCol52();
    child.setFactField("age");
    child.setOperator("<");
    child.setValue(new DTCellValue52(new BigDecimal("18")));
    child.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(child);

    LimitedEntryConditionCol52 adult = new LimitedEntryConditionCol52();
    adult.setFactField("age");
    adult.setOperator(">=");
    adult.setValue(new DTCellValue52(new BigDecimal("18")));
    adult.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(adult);

    LimitedEntryConditionCol52 pensioner = new LimitedEntryConditionCol52();
    pensioner.setFactField("age");
    pensioner.setOperator(">=");
    pensioner.setValue(new DTCellValue52(new BigDecimal("65")));
    pensioner.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(pensioner);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 1 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52("Row 2 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52(Boolean.FALSE),
                new DTCellValue52(Boolean.TRUE),
                new DTCellValue52("Row 3 message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getConflictingMatchSize());
    assertEquals(1, analysisData.get(1).getConflictingMatchSize());
    assertEquals(1, analysisData.get(2).getConflictingMatchSize());
  }
コード例 #14
0
  @Test
  @Ignore("TODO fix GUVNOR-1677 duplication")
  public void testDuplicatedMatchNumeric() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    ConditionCol52 ageMinimum = new ConditionCol52();
    ageMinimum.setFactField("age");
    ageMinimum.setOperator(">=");
    ageMinimum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(ageMinimum);

    ConditionCol52 ageMaximum = new ConditionCol52();
    ageMaximum.setFactField("age");
    ageMaximum.setOperator("<=");
    ageMaximum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(ageMaximum);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52(new BigDecimal("20")),
                new DTCellValue52("Same message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52(new BigDecimal("21")),
                new DTCellValue52(new BigDecimal("40")),
                new DTCellValue52("Same message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52(new BigDecimal("30")),
                new DTCellValue52(new BigDecimal("60")),
                new DTCellValue52("Same message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("4")),
                new DTCellValue52("Row 4 description"),
                new DTCellValue52(new BigDecimal("50")),
                new DTCellValue52((BigDecimal) null),
                new DTCellValue52("Same message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getDuplicatedMatchSize());
    assertEquals(1, analysisData.get(1).getDuplicatedMatchSize());
    assertEquals(2, analysisData.get(2).getDuplicatedMatchSize());
    assertEquals(1, analysisData.get(3).getDuplicatedMatchSize());

    assertEquals(0, analysisData.get(0).getConflictingMatchSize());
    assertEquals(0, analysisData.get(1).getConflictingMatchSize());
    assertEquals(0, analysisData.get(2).getConflictingMatchSize());
    assertEquals(0, analysisData.get(3).getConflictingMatchSize());
  }
コード例 #15
0
 private boolean unique(String header) {
   for (ActionCol52 o : model.getActionCols()) {
     if (o.getHeader().equals(header)) return false;
   }
   return true;
 }
コード例 #16
0
  public ActionInsertColumnPopup(
      SuggestionCompletionEngine sce,
      final GuidedDecisionTable52 model,
      final GenericColumnCommand refreshGrid,
      final ActionInsertFactCol52 col,
      final boolean isNew) {
    this.editingCol = cloneActionInsertColumn(col);
    this.model = model;
    this.sce = sce;

    // Set-up factory for common widgets
    factory = new DTCellValueWidgetFactory(model, sce);

    setTitle(constants.ActionColumnConfigurationInsertingANewFact());
    setModal(false);

    // Fact being inserted
    HorizontalPanel pattern = new HorizontalPanel();
    pattern.add(patternLabel);
    doPatternLabel();

    Image changePattern =
        new ImageButton(
            images.edit(),
            constants.ChooseAPatternThatThisColumnAddsDataTo(),
            new ClickHandler() {
              public void onClick(ClickEvent w) {
                showChangePattern(w);
              }
            });
    pattern.add(changePattern);
    addAttribute(constants.Pattern(), pattern);

    // Fact field being set
    HorizontalPanel field = new HorizontalPanel();
    field.add(fieldLabel);
    Image editField =
        new ImageButton(
            images.edit(),
            constants.EditTheFieldThatThisColumnOperatesOn(),
            new ClickHandler() {
              public void onClick(ClickEvent w) {
                showFieldChange();
              }
            });
    field.add(editField);
    addAttribute(constants.Field(), field);
    doFieldLabel();

    // Column header
    final TextBox header = new TextBox();
    header.setText(col.getHeader());
    header.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            editingCol.setHeader(header.getText());
          }
        });
    addAttribute(constants.ColumnHeaderDescription(), header);

    // Optional value list
    if (model.getTableFormat() == TableFormat.EXTENDED_ENTRY) {
      final TextBox valueList = new TextBox();
      valueList.setText(editingCol.getValueList());
      valueList.addChangeHandler(
          new ChangeHandler() {
            public void onChange(ChangeEvent event) {
              editingCol.setValueList(valueList.getText());
            }
          });
      HorizontalPanel vl = new HorizontalPanel();
      vl.add(valueList);
      vl.add(new InfoPopup(constants.ValueList(), constants.ValueListsExplanation()));
      addAttribute(constants.optionalValueList(), vl);
    }

    // Default Value
    if (model.getTableFormat() == TableFormat.EXTENDED_ENTRY) {
      addAttribute(constants.DefaultValue(), DTCellValueWidgetFactory.getDefaultEditor(editingCol));
    }

    // Limited entry value widget
    limitedEntryValueAttributeIndex =
        addAttribute(constants.LimitedEntryValue(), limitedEntryValueWidgetContainer);
    makeLimitedValueWidget();

    // Logical insertion
    addAttribute(
        constants.LogicallyAssertAFactTheFactWillBeRetractedWhenTheSupportingEvidenceIsRemoved(),
        doInsertLogical());

    // Hide column tick-box
    addAttribute(
        constants.HideThisColumn(), DTCellValueWidgetFactory.getHideColumnIndicator(editingCol));

    Button apply = new Button(constants.ApplyChanges());
    apply.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent w) {
            if (null == editingCol.getHeader() || "".equals(editingCol.getHeader())) {
              Window.alert(constants.YouMustEnterAColumnHeaderValueDescription());
              return;
            }
            if (isNew) {
              if (!unique(editingCol.getHeader())) {
                Window.alert(constants.ThatColumnNameIsAlreadyInUsePleasePickAnother());
                return;
              }

            } else {
              if (!col.getHeader().equals(editingCol.getHeader())) {
                if (!unique(editingCol.getHeader())) {
                  Window.alert(constants.ThatColumnNameIsAlreadyInUsePleasePickAnother());
                  return;
                }
              }
            }

            // Pass new\modified column back for handling
            refreshGrid.execute(editingCol);
            hide();
          }
        });
    addAttribute("", apply);
  }
コード例 #17
0
  @Test
  public void testImpossibleMatchesDate() throws ParseException {
    SuggestionCompletionEngine sce = buildSuggestionCompletionEngine();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    GuidedDecisionTable52 dt = new GuidedDecisionTable52();

    Pattern52 driverPattern = new Pattern52();
    driverPattern.setBoundName("driverPattern");
    driverPattern.setFactType("Driver");

    ConditionCol52 dateOfBirthMinimum = new ConditionCol52();
    dateOfBirthMinimum.setFactField("dateOfBirth");
    dateOfBirthMinimum.setOperator(">=");
    dateOfBirthMinimum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(dateOfBirthMinimum);

    ConditionCol52 dateOfBirthMaximum = new ConditionCol52();
    dateOfBirthMaximum.setFactField("dateOfBirth");
    dateOfBirthMaximum.setOperator("<=");
    dateOfBirthMaximum.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    driverPattern.getConditions().add(dateOfBirthMaximum);

    dt.getConditionPatterns().add(driverPattern);

    ActionSetFieldCol52 message = new ActionSetFieldCol52();
    message.setFactField("message");
    dt.getActionCols().add(message);

    @SuppressWarnings("unchecked")
    List<List<DTCellValue52>> data =
        Arrays.asList(
            Arrays.asList(
                new DTCellValue52(new BigDecimal("1")),
                new DTCellValue52("Row 1 description"),
                new DTCellValue52(dateFormat.parse("1981-01-01")),
                new DTCellValue52(dateFormat.parse("2001-01-01")),
                new DTCellValue52("Row 1 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("2")),
                new DTCellValue52("Row 2 description"),
                new DTCellValue52(dateFormat.parse("2001-01-01")),
                new DTCellValue52(dateFormat.parse("1981-01-01")),
                new DTCellValue52("Row 2 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("3")),
                new DTCellValue52("Row 3 description"),
                new DTCellValue52((Date) null),
                new DTCellValue52(dateFormat.parse("2001-01-01")),
                new DTCellValue52("Row 3 message")),
            Arrays.asList(
                new DTCellValue52(new BigDecimal("4")),
                new DTCellValue52("Row 4 description"),
                new DTCellValue52(dateFormat.parse("1981-01-01")),
                new DTCellValue52((Date) null),
                new DTCellValue52("Row 4 message")));

    dt.setData(data);

    DecisionTableAnalyzer analyzer = new DecisionTableAnalyzer(sce);
    List<Analysis> analysisData = analyzer.analyze(dt);

    assertEquals(data.size(), analysisData.size());
    assertEquals(0, analysisData.get(0).getImpossibleMatchesSize());
    assertEquals(1, analysisData.get(1).getImpossibleMatchesSize());
    assertEquals(0, analysisData.get(2).getImpossibleMatchesSize());
    assertEquals(0, analysisData.get(3).getImpossibleMatchesSize());
  }