Search in sources :

Example 1 with GenericMatcher

use of org.whole.lang.matchers.GenericMatcher in project whole by wholeplatform.

the class TestsHelpers method updateFilterBody.

public static IEntity updateFilterBody(IEntity pattern, IEntity model, Sequence sequence) {
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    boolean match = false;
    while (!match) {
        try {
            bindings.wEnterScope();
            // try to match
            new GenericMatcher().withBindings(bindings).match(applyFilter(sequence, EntityUtils.clone(pattern), bindings), applyFilter(sequence, EntityUtils.clone(model), bindings));
            // eventually matches
            match = true;
        } catch (MatchException e) {
            // update normalization
            sequence.wAdd(QueriesEntityFactory.instance.createDelete(QueriesUtils.createRootPath(e.pattern)));
        } finally {
            // clear scope
            bindings.wExitScope();
        }
    }
    return sequence;
}
Also used : IBindingManager(org.whole.lang.bindings.IBindingManager) MatchException(org.whole.lang.matchers.MatchException) GenericMatcher(org.whole.lang.matchers.GenericMatcher)

Aggregations

IBindingManager (org.whole.lang.bindings.IBindingManager)1 GenericMatcher (org.whole.lang.matchers.GenericMatcher)1 MatchException (org.whole.lang.matchers.MatchException)1