Search in sources :

Example 1 with WorkingMemory

use of org.drools.verifier.components.WorkingMemory in project drools by kiegroup.

the class PatternDescrVisitor method visitPatternDescr.

private Pattern visitPatternDescr(PatternDescr descr, VerifierComponent parent, int orderNumber) throws UnknownDescriptionException {
    objectType = data.getObjectTypeByFullName(descr.getObjectType());
    if (objectType == null) {
        Import objectImport = data.getImportByName(descr.getObjectType());
        if (objectImport != null) {
            objectType = ObjectTypeFactory.createObjectType(descr, objectImport);
        } else {
            objectType = ObjectTypeFactory.createObjectType(descr, descr.getObjectType());
        }
        data.add(objectType);
    }
    pattern = new Pattern(descr, rule);
    if (parent != null) {
        pattern.setParentPath(parent.getPath());
        pattern.setParentType(parent.getVerifierComponentType());
    }
    pattern.setObjectTypePath(objectType.getPath());
    pattern.setName(objectType.getName());
    pattern.setPatternNot(solvers.getRuleSolver().isChildNot());
    pattern.setPatternExists(solvers.getRuleSolver().isExists());
    pattern.setPatternForall(solvers.getRuleSolver().isForall());
    pattern.setOrderNumber(orderNumber);
    if (descr.getIdentifier() != null) {
        PatternVariable patternVariable = new PatternVariable(rule);
        patternVariable.setName(descr.getIdentifier());
        patternVariable.setParentPath(pattern.getPath());
        patternVariable.setParentType(pattern.getVerifierComponentType());
        data.add(patternVariable);
    }
    // visit source.
    if (descr.getSource() != null) {
        visit(descr.getSource());
    } else {
        if (workingMemory == null) {
            workingMemory = new WorkingMemory();
            data.add(workingMemory);
        }
        pattern.setSourcePath(workingMemory.getPath());
        pattern.setSourceType(workingMemory.getVerifierComponentType());
    }
    solvers.startPatternSolver(pattern);
    visit(descr.getConstraint());
    solvers.endPatternSolver();
    data.add(pattern);
    return pattern;
}
Also used : Pattern(org.drools.verifier.components.Pattern) PatternVariable(org.drools.verifier.components.PatternVariable) Import(org.drools.verifier.components.Import) WorkingMemory(org.drools.verifier.components.WorkingMemory)

Aggregations

Import (org.drools.verifier.components.Import)1 Pattern (org.drools.verifier.components.Pattern)1 PatternVariable (org.drools.verifier.components.PatternVariable)1 WorkingMemory (org.drools.verifier.components.WorkingMemory)1