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;
}
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);
}
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);
}
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);
}
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());
}
Aggregations