use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.
the class ModelMetaDataEnhancer method getHeaderMetaData.
public HeaderMetaData getHeaderMetaData() {
int columnIndex = 0;
final Map<Integer, ModelMetaData> map = new HashMap<>();
for (final BaseColumn baseColumn : model.getExpandedColumns()) {
if (baseColumn instanceof ConditionCol52) {
map.put(columnIndex, new ModelMetaData(model.getPattern((ConditionCol52) baseColumn), PatternType.LHS));
} else if (baseColumn instanceof ActionInsertFactCol52) {
final ActionInsertFactCol52 aif = (ActionInsertFactCol52) baseColumn;
map.put(columnIndex, new ModelMetaData(aif.getFactType(), aif.getBoundName(), PatternType.RHS));
} else if (baseColumn instanceof ActionSetFieldCol52) {
final ActionSetFieldCol52 asf = (ActionSetFieldCol52) baseColumn;
map.put(columnIndex, new ModelMetaData(getFactType(asf), asf.getBoundName(), PatternType.RHS));
}
columnIndex++;
}
return new HeaderMetaData(map);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.
the class DefaultGuidedDecisionTableLinkManagerTest method fieldConstraintLinksToActionUpdateField.
@Test
public void fieldConstraintLinksToActionUpdateField() {
// Columns: Row#[0], Description[1], Condition[2], Action[3]
final GuidedDecisionTable52 dt1 = new GuidedDecisionTable52();
final Pattern52 p1 = new Pattern52();
p1.setBoundName("$f");
p1.setFactType("Fact");
final ConditionCol52 p1c1 = new ConditionCol52();
p1c1.setFactField("field");
p1.getChildColumns().add(p1c1);
dt1.getConditions().add(p1);
final ActionSetFieldCol52 asf = new ActionSetFieldCol52();
asf.setBoundName("$f");
asf.setFactField("field");
dt1.getActionCols().add(asf);
// Columns: Row#[0], Description[1], Condition[2]
final GuidedDecisionTable52 dt2 = new GuidedDecisionTable52();
final Pattern52 p2 = new Pattern52();
p2.setBoundName("$f");
p2.setFactType("Fact");
final ConditionCol52 p2c1 = new ConditionCol52();
p2c1.setFactField("field");
p2.getChildColumns().add(p2c1);
dt2.getConditions().add(p2);
manager.link(dt1, dt2, (s, t) -> {
assertEquals(3, s);
assertEquals(2, t);
});
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.
the class DependentEnumsUtilities method getDependentColumnIndexes.
@Override
public Set<Integer> getDependentColumnIndexes(final Context context) {
final int iBaseColIndex = context.getColumnIndex();
final Set<Integer> dependentColumnIndexes = new HashSet<Integer>();
// Get the column for the cell being edited
final List<BaseColumn> allColumns = this.model.getExpandedColumns();
final BaseColumn baseColumn = allColumns.get(iBaseColIndex);
// Get values for all Constraints or Actions on the same pattern as the baseColumn
if (baseColumn instanceof BRLConditionVariableColumn) {
final BRLConditionVariableColumn baseBRLConditionColumn = (BRLConditionVariableColumn) baseColumn;
final BRLConditionColumn brl = model.getBRLColumn(baseBRLConditionColumn);
final RuleModel rm = new RuleModel();
IPattern[] lhs = new IPattern[brl.getDefinition().size()];
brl.getDefinition().toArray(lhs);
rm.lhs = lhs;
final RuleModelPeerVariableVisitor peerVariableVisitor = new RuleModelPeerVariableVisitor(rm, baseBRLConditionColumn.getVarName());
List<ValueHolder> peerVariables = peerVariableVisitor.getPeerVariables();
// Add other variables values
for (ValueHolder valueHolder : peerVariables) {
switch(valueHolder.getType()) {
case TEMPLATE_KEY:
if (oracle.isDependentEnum(baseBRLConditionColumn.getFactType(), baseBRLConditionColumn.getFactField(), valueHolder.getFieldName())) {
final BRLConditionVariableColumn vc = getConditionVariableColumnIndex(brl.getChildColumns(), valueHolder.getValue());
final int iCol = allColumns.indexOf(vc);
dependentColumnIndexes.add(iCol);
}
break;
}
}
} else if (baseColumn instanceof BRLActionVariableColumn) {
final BRLActionVariableColumn baseBRLActionColumn = (BRLActionVariableColumn) baseColumn;
final BRLActionColumn brl = model.getBRLColumn(baseBRLActionColumn);
final RuleModel rm = new RuleModel();
IAction[] rhs = new IAction[brl.getDefinition().size()];
brl.getDefinition().toArray(rhs);
rm.rhs = rhs;
final RuleModelPeerVariableVisitor peerVariableVisitor = new RuleModelPeerVariableVisitor(rm, baseBRLActionColumn.getVarName());
List<ValueHolder> peerVariables = peerVariableVisitor.getPeerVariables();
// Add other variables values
for (ValueHolder valueHolder : peerVariables) {
switch(valueHolder.getType()) {
case TEMPLATE_KEY:
if (oracle.isDependentEnum(baseBRLActionColumn.getFactType(), baseBRLActionColumn.getFactField(), valueHolder.getFieldName())) {
final BRLActionVariableColumn vc = getActionVariableColumnIndex(brl.getChildColumns(), valueHolder.getValue());
final int iCol = allColumns.indexOf(vc);
dependentColumnIndexes.add(iCol);
}
break;
}
}
} else if (baseColumn instanceof ConditionCol52) {
final ConditionCol52 baseConditionColumn = (ConditionCol52) baseColumn;
final Pattern52 basePattern = this.model.getPattern(baseConditionColumn);
for (ConditionCol52 cc : basePattern.getChildColumns()) {
if (oracle.isDependentEnum(basePattern.getFactType(), baseConditionColumn.getFactField(), cc.getFactField())) {
dependentColumnIndexes.add(allColumns.indexOf(cc));
}
}
} else if (baseColumn instanceof ActionSetFieldCol52) {
final ActionSetFieldCol52 baseActionColumn = (ActionSetFieldCol52) baseColumn;
final Pattern52 basePattern = model.getConditionPattern(baseActionColumn.getBoundName());
final String binding = baseActionColumn.getBoundName();
for (ActionCol52 ac : this.model.getActionCols()) {
if (ac instanceof ActionSetFieldCol52) {
final ActionSetFieldCol52 asf = (ActionSetFieldCol52) ac;
if (asf.getBoundName().equals(binding)) {
if (oracle.isDependentEnum(basePattern.getFactType(), baseActionColumn.getFactField(), asf.getFactField())) {
dependentColumnIndexes.add(allColumns.indexOf(ac));
}
}
}
}
} else if (baseColumn instanceof ActionInsertFactCol52) {
final ActionInsertFactCol52 baseActionColumn = (ActionInsertFactCol52) baseColumn;
final String binding = baseActionColumn.getBoundName();
for (ActionCol52 ac : this.model.getActionCols()) {
if (ac instanceof ActionInsertFactCol52) {
final ActionInsertFactCol52 aif = (ActionInsertFactCol52) ac;
if (aif.getBoundName().equals(binding)) {
if (oracle.isDependentEnum(baseActionColumn.getFactType(), baseActionColumn.getFactField(), aif.getFactField())) {
dependentColumnIndexes.add(allColumns.indexOf(ac));
}
}
}
}
}
return dependentColumnIndexes;
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.
the class LimitedEntryDropDownManager method getDependentColumnIndexes.
@Override
public Set<Integer> getDependentColumnIndexes(Context context) {
final Set<Integer> dependentColumnIndexes = new HashSet<Integer>();
final Pattern52 basePattern = context.getBasePattern();
final BaseColumn baseColumn = context.getBaseColumn();
// Get values for all Constraints or Actions on the same pattern as the baseColumn
if (baseColumn instanceof ConditionCol52 && basePattern != null) {
final ConditionCol52 baseConditionColumn = (ConditionCol52) baseColumn;
for (ConditionCol52 cc : basePattern.getChildColumns()) {
if (oracle.isDependentEnum(basePattern.getFactType(), baseConditionColumn.getFactField(), cc.getFactField())) {
dependentColumnIndexes.add(model.getExpandedColumns().indexOf(cc));
}
}
} else if (baseColumn instanceof ActionSetFieldCol52 && basePattern != null) {
final ActionSetFieldCol52 baseActionColumn = (ActionSetFieldCol52) baseColumn;
final String binding = baseActionColumn.getBoundName();
for (ActionCol52 ac : this.model.getActionCols()) {
if (ac instanceof ActionSetFieldCol52) {
final ActionSetFieldCol52 asf = (ActionSetFieldCol52) ac;
if (asf.getBoundName().equals(binding)) {
if (oracle.isDependentEnum(basePattern.getFactType(), baseActionColumn.getFactField(), asf.getFactField())) {
dependentColumnIndexes.add(model.getExpandedColumns().indexOf(ac));
}
}
}
}
} else if (baseColumn instanceof ActionInsertFactCol52) {
final ActionInsertFactCol52 baseActionColumn = (ActionInsertFactCol52) baseColumn;
final String binding = baseActionColumn.getBoundName();
for (ActionCol52 ac : this.model.getActionCols()) {
if (ac instanceof ActionInsertFactCol52) {
final ActionInsertFactCol52 aif = (ActionInsertFactCol52) ac;
if (aif.getBoundName().equals(binding)) {
if (oracle.isDependentEnum(baseActionColumn.getFactType(), baseActionColumn.getFactField(), aif.getFactField())) {
dependentColumnIndexes.add(model.getExpandedColumns().indexOf(ac));
}
}
}
}
}
return dependentColumnIndexes;
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.
the class LimitedEntryDropDownManager method getCurrentValueMap.
@Override
public Map<String, String> getCurrentValueMap(Context context) {
Map<String, String> currentValueMap = new HashMap<String, String>();
final Pattern52 basePattern = context.getBasePattern();
final BaseColumn baseColumn = context.getBaseColumn();
// Get values for all Constraints or Actions on the same pattern as the baseColumn
if (baseColumn instanceof ConditionCol52 && basePattern != null) {
for (ConditionCol52 cc : basePattern.getChildColumns()) {
if (cc instanceof LimitedEntryCol) {
currentValueMap.put(cc.getFactField(), getValue((LimitedEntryCol) cc));
}
}
} else if (baseColumn instanceof ActionSetFieldCol52) {
ActionSetFieldCol52 baseActionColumn = (ActionSetFieldCol52) baseColumn;
final String binding = baseActionColumn.getBoundName();
for (ActionCol52 ac : this.model.getActionCols()) {
if (ac instanceof ActionSetFieldCol52) {
final ActionSetFieldCol52 asf = (ActionSetFieldCol52) ac;
if (asf.getBoundName().equals(binding)) {
if (asf instanceof LimitedEntryCol) {
currentValueMap.put(asf.getFactField(), getValue((LimitedEntryCol) asf));
}
}
}
}
} else if (baseColumn instanceof ActionInsertFactCol52) {
ActionInsertFactCol52 baseActionColumn = (ActionInsertFactCol52) baseColumn;
final String binding = baseActionColumn.getBoundName();
for (ActionCol52 ac : this.model.getActionCols()) {
if (ac instanceof ActionInsertFactCol52) {
final ActionInsertFactCol52 aif = (ActionInsertFactCol52) ac;
if (aif.getBoundName().equals(binding)) {
if (aif instanceof LimitedEntryCol) {
currentValueMap.put(aif.getFactField(), getValue((LimitedEntryCol) aif));
}
}
}
}
}
return currentValueMap;
}
Aggregations