use of org.drools.workbench.models.datamodel.rule.IPattern in project drools by kiegroup.
the class BRLConditionColumnTest method testDiffDefinitions.
@Test
public void testDiffDefinitions() {
List<IPattern> definition1 = Arrays.asList(new FactPattern("Mock1"));
column1.setDefinition(definition1);
List<IPattern> definition2 = Arrays.asList(new FactPattern("Mock2"));
column2.setDefinition(definition2);
checkSingleDiff(FIELD_DEFINITION, definition1, definition2, column1, column2);
}
use of org.drools.workbench.models.datamodel.rule.IPattern in project drools-wb by kiegroup.
the class ExtendedGuidedDecisionTableBuilder method createBRLConditionColumn.
public static BRLConditionColumn createBRLConditionColumn() {
final BRLConditionColumn brlConditionColumn = new BRLConditionColumn();
final ArrayList<IPattern> definition = new ArrayList<>();
definition.add(mock(IPattern.class));
brlConditionColumn.setDefinition(definition);
final ArrayList<BRLConditionVariableColumn> childColumns = new ArrayList<>();
final BRLConditionVariableColumn brlConditionVariableColumn = new BRLConditionVariableColumn();
brlConditionVariableColumn.getFactType();
childColumns.add(brlConditionVariableColumn);
brlConditionColumn.setChildColumns(childColumns);
return brlConditionColumn;
}
use of org.drools.workbench.models.datamodel.rule.IPattern in project drools-wb by kiegroup.
the class RuleModelCloneVisitor method visitRuleModel.
public RuleModel visitRuleModel(RuleModel model) {
RuleModel clone = new RuleModel();
clone.modelVersion = model.modelVersion;
clone.name = model.name;
clone.parentName = model.parentName;
clone.setNegated(model.isNegated());
if (model.attributes != null) {
clone.attributes = new RuleAttribute[model.attributes.length];
for (int i = 0; i < model.attributes.length; i++) {
RuleAttribute attr = model.attributes[i];
clone.attributes[i] = (RuleAttribute) visit(attr);
}
}
if (model.metadataList != null) {
clone.metadataList = new RuleMetadata[model.metadataList.length];
for (int i = 0; i < model.metadataList.length; i++) {
RuleMetadata md = model.metadataList[i];
clone.metadataList[i] = (RuleMetadata) visit(md);
}
}
if (model.lhs != null) {
clone.lhs = new IPattern[model.lhs.length];
for (int i = 0; i < model.lhs.length; i++) {
IPattern pattern = model.lhs[i];
clone.lhs[i] = (IPattern) visit(pattern);
}
}
if (model.rhs != null) {
clone.rhs = new IAction[model.rhs.length];
for (int i = 0; i < model.rhs.length; i++) {
IAction action = model.rhs[i];
clone.rhs[i] = (IAction) visit(action);
}
}
return clone;
}
use of org.drools.workbench.models.datamodel.rule.IPattern in project drools-wb by kiegroup.
the class GuidedDecisionTableModelVisitor method getConsumedModelClasses.
public Set<String> getConsumedModelClasses() {
final Set<String> factTypes = new HashSet<String>();
// Extract Fact Types from model
for (CompositeColumn<?> cc : model.getConditions()) {
if (cc instanceof BRLConditionColumn) {
final List<IPattern> definition = ((BRLConditionColumn) cc).getDefinition();
factTypes.addAll(getConditionFactTypesFromRuleModel(definition));
} else if (cc instanceof Pattern52) {
factTypes.add(((Pattern52) cc).getFactType());
}
}
for (ActionCol52 c : model.getActionCols()) {
if (c instanceof BRLActionColumn) {
final List<IAction> definition = ((BRLActionColumn) c).getDefinition();
factTypes.addAll(getActionFactTypesFromRuleModel(definition));
} else if (c instanceof ActionInsertFactCol52) {
factTypes.add(((ActionInsertFactCol52) c).getFactType());
}
}
// Convert Fact Types into Fully Qualified Class Names
final Set<String> fullyQualifiedClassNames = new HashSet<String>();
for (String factType : factTypes) {
fullyQualifiedClassNames.add(convertToFullyQualifiedClassName(factType));
}
return fullyQualifiedClassNames;
}
use of org.drools.workbench.models.datamodel.rule.IPattern 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;
}
Aggregations