Search in sources :

Example 56 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.

the class GuidedDecisionTableUpgradeHelper2 method upgrade.

/**
 * Convert the data-types in the Decision Table model
 *
 * @param source
 * @return The new DTModel
 */
public GuidedDecisionTable52 upgrade(GuidedDecisionTable52 source) {
    final GuidedDecisionTable52 destination = source;
    // These are the columns we want to update
    final int iRowNumberColumnIndex = 0;
    Integer iSalienceColumnIndex = null;
    Integer iDurationColumnIndex = null;
    // Find the Salience and Duration column indexes
    List<BaseColumn> allColumns = destination.getExpandedColumns();
    for (int iCol = 0; iCol < allColumns.size(); iCol++) {
        final BaseColumn column = allColumns.get(iCol);
        if (column instanceof AttributeCol52) {
            AttributeCol52 attributeCol = (AttributeCol52) column;
            final String attributeName = attributeCol.getAttribute();
            if (GuidedDecisionTable52.SALIENCE_ATTR.equals(attributeName)) {
                iSalienceColumnIndex = iCol;
            } else if (GuidedDecisionTable52.DURATION_ATTR.equals(attributeName)) {
                iDurationColumnIndex = iCol;
            }
        }
    }
    // Update data-types
    for (List<DTCellValue52> row : destination.getData()) {
        // Row numbers are Integers
        final int rowNumberValue = row.get(iRowNumberColumnIndex).getNumericValue().intValue();
        row.get(iRowNumberColumnIndex).setNumericValue(rowNumberValue);
        // Salience should be an Integer
        if (iSalienceColumnIndex != null) {
            final Number salienceValue = row.get(iSalienceColumnIndex).getNumericValue();
            if (salienceValue == null) {
                row.get(iSalienceColumnIndex).setNumericValue((Integer) null);
            } else {
                row.get(iSalienceColumnIndex).setNumericValue(salienceValue.intValue());
            }
        }
        // Duration should be a Long
        if (iDurationColumnIndex != null) {
            final Number durationValue = row.get(iDurationColumnIndex).getNumericValue();
            if (durationValue == null) {
                row.get(iDurationColumnIndex).setNumericValue((Long) null);
            } else {
                row.get(iDurationColumnIndex).setNumericValue(durationValue.longValue());
            }
        }
    }
    return destination;
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 57 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceFirstHitPolicyTest method blockUseOfActivationGroup.

@Test(expected = IllegalArgumentException.class)
public void blockUseOfActivationGroup() {
    final AttributeCol52 attributeCol52 = new AttributeCol52();
    attributeCol52.setAttribute("activation-group");
    attributeCol52.setDefaultValue(new DTCellValue52("test"));
    dtable.getAttributeCols().add(attributeCol52);
    GuidedDTDRLPersistence.getInstance().marshal(dtable);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 58 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceResolvedHitPolicyTest method blockUseOfActivationGroup.

@Test(expected = IllegalArgumentException.class)
public void blockUseOfActivationGroup() {
    final AttributeCol52 attributeCol52 = new AttributeCol52();
    attributeCol52.setAttribute("activation-group");
    attributeCol52.setDefaultValue(new DTCellValue52("test"));
    dtable.getAttributeCols().add(attributeCol52);
    GuidedDTDRLPersistence.getInstance().marshal(dtable);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 59 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceRuleOrderHitPolicyTest method blockUseOfSalience.

@Test(expected = IllegalArgumentException.class)
public void blockUseOfSalience() {
    final AttributeCol52 attributeCol52 = new AttributeCol52();
    attributeCol52.setAttribute("salience");
    attributeCol52.setDefaultValue(new DTCellValue52("123"));
    dtable.getAttributeCols().add(attributeCol52);
    GuidedDTDRLPersistence.getInstance().marshal(dtable);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 60 with AttributeCol52

use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools-wb by kiegroup.

the class ColumnsPagePresenterTest method testRefreshAttributeWidgetWhenAttributeColumnsIsEmpty.

@Test
public void testRefreshAttributeWidgetWhenAttributeColumnsIsEmpty() {
    final List<AttributeCol52> attributeColumns = new ArrayList<>();
    final AttributeColumnConfigRow attributeColumnConfigRow = mock(AttributeColumnConfigRow.class);
    final Label blankSlate = mock(Label.class);
    doReturn(verticalPanel).when(presenter).getAttributeWidget();
    doReturn(attributeColumnConfigRow).when(this.attributeColumnConfigRow).get();
    doReturn(blankSlate).when(presenter).blankSlate();
    presenter.refreshAttributeWidget(attributeColumns);
    verify(verticalPanel).add(blankSlate);
    verify(attributeColumnConfigRow, never()).init(any(), any());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) ArrayList(java.util.ArrayList) Label(com.google.gwt.user.client.ui.Label) AttributeColumnConfigRow(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.control.AttributeColumnConfigRow) Test(org.junit.Test)

Aggregations

AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)86 Test (org.junit.Test)55 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)30 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)20 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)14 ArrayList (java.util.ArrayList)12 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)12 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)10 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)10 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)9 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)8 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)8 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)7 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)6 DataListener (org.drools.template.parser.DataListener)6 ConversionResult (org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult)6 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)5 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)5