Search in sources :

Example 1 with SyntaxObject

use of org.ovirt.engine.core.searchbackend.SyntaxObject in project ovirt-engine by oVirt.

the class SearchableListModel method isSearchValidForServerSideSorting.

/**
 * Returns {@code true} if this model's {@linkplain #getSearchString search string}
 * allows the use of server-side sorting.
 * <p>
 * This method returns {@code false} if:
 * <ul>
 * <li>search string contains syntax error(s)
 * <li>search string contains {@code SORTBY} syntax object
 * </ul>
 * Otherwise, this method returns {@code true}.
 */
public boolean isSearchValidForServerSideSorting() {
    ISyntaxChecker syntaxChecker = getConfigurator().getSyntaxChecker();
    if (syntaxChecker == null) {
        return true;
    }
    String search = getSearchString();
    SyntaxContainer syntaxResult = syntaxChecker.analyzeSyntaxState(search, true);
    if (syntaxResult.getError() != SyntaxError.NO_ERROR) {
        return false;
    }
    for (SyntaxObject syntaxObject : syntaxResult) {
        if (syntaxObject.getType() == SyntaxObjectType.SORTBY) {
            return false;
        }
    }
    return true;
}
Also used : SyntaxContainer(org.ovirt.engine.core.searchbackend.SyntaxContainer) ISyntaxChecker(org.ovirt.engine.core.searchbackend.ISyntaxChecker) SyntaxObject(org.ovirt.engine.core.searchbackend.SyntaxObject)

Aggregations

ISyntaxChecker (org.ovirt.engine.core.searchbackend.ISyntaxChecker)1 SyntaxContainer (org.ovirt.engine.core.searchbackend.SyntaxContainer)1 SyntaxObject (org.ovirt.engine.core.searchbackend.SyntaxObject)1