use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class DefaultWidgetFactory method getWidget.
private Widget getWidget(final DTCellValue52 defaultValue) {
final DTColumnConfig52 column = getPlugin().editingCol();
final Pattern52 pattern = getPlugin().editingPattern();
if (column instanceof ActionSetFieldCol52) {
final ActionSetFieldCol52 col52 = (ActionSetFieldCol52) column;
return factory().getWidget(pattern, col52, defaultValue);
} else if (column instanceof ConditionCol52) {
final ConditionCol52 col52 = (ConditionCol52) column;
return factory().getWidget(pattern, col52, defaultValue);
} else if (column instanceof ActionInsertFactCol52) {
final ActionInsertFactCol52 col52 = (ActionInsertFactCol52) column;
return factory().getWidget(col52, defaultValue);
}
throw new UnsupportedOperationException("The column type is not supported by the 'DefaultWidget'");
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPage method initialise.
@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);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPage method isComplete.
@Override
public void isComplete(final Callback<Boolean> callback) {
// Do all Patterns have unique bindings?
final boolean arePatternBindingsUnique = getValidator().arePatternBindingsUnique();
// Signal duplicates to other pages
final DuplicatePatternsEvent event = new DuplicatePatternsEvent(arePatternBindingsUnique);
duplicatePatternsEvent.fire(event);
// Are all Actions defined?
boolean areActionInsertFieldsDefined = true;
for (List<ActionInsertFactCol52> actions : patternToActionsMap.values()) {
for (ActionInsertFactCol52 a : actions) {
if (!getValidator().isActionValid(a)) {
areActionInsertFieldsDefined = false;
break;
}
}
}
// Signal Action Insert Fact Fields to other pages
final ActionInsertFactFieldsDefinedEvent eventFactFields = new ActionInsertFactFieldsDefinedEvent(areActionInsertFieldsDefined);
actionInsertFactFieldsDefinedEvent.fire(eventFactFields);
callback.callback(arePatternBindingsUnique && areActionInsertFieldsDefined);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class ActionInsertFactFieldsPage method makeResult.
@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);
}
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 in project drools-wb by kiegroup.
the class RowExpander method addActionColumns.
private void addActionColumns() {
for (ActionCol52 a : model.getActionCols()) {
if (a instanceof ActionSetFieldCol52) {
ActionSetFieldCol52 afc = (ActionSetFieldCol52) a;
addColumn(afc);
} else if (a instanceof ActionInsertFactCol52) {
ActionInsertFactCol52 aif = (ActionInsertFactCol52) a;
addColumn(aif);
}
}
}
Aggregations