Search in sources :

Example 1 with QBuilder

use of com.github.rutledgepaulv.qbuilders.builders.QBuilder in project downlords-faf-client by FAForever.

the class LogicalNodeControllerTest method setUp.

@Before
public void setUp() throws Exception {
    instance = new LogicalNodeController(i18n);
    loadFxml("theme/vault/search/logical_node.fxml", clazz -> {
        if (clazz == instance.getClass()) {
            return instance;
        } else if (clazz == SpecificationController.class) {
            return specificationController;
        }
        return mock(clazz);
    });
    qBuilder = new QBuilder();
}
Also used : QBuilder(com.github.rutledgepaulv.qbuilders.builders.QBuilder) Before(org.junit.Before)

Example 2 with QBuilder

use of com.github.rutledgepaulv.qbuilders.builders.QBuilder in project downlords-faf-client by FAForever.

the class SpecificationControllerTest method setUp.

@Before
public void setUp() throws Exception {
    instance = new SpecificationController(i18n);
    loadFxml("theme/vault/search/specification.fxml", clazz -> {
        if (clazz == instance.getClass()) {
            return instance;
        }
        return mock(clazz);
    });
    qBuilder = new QBuilder();
}
Also used : QBuilder(com.github.rutledgepaulv.qbuilders.builders.QBuilder) Before(org.junit.Before)

Example 3 with QBuilder

use of com.github.rutledgepaulv.qbuilders.builders.QBuilder in project downlords-faf-client by FAForever.

the class SearchController method buildQuery.

/**
 * Builds the query string if possible, returns empty string if not. A query string can not be built if the user
 * selected no or invalid values.
 */
private String buildQuery(SpecificationController initialSpecification, List<LogicalNodeController> queryNodes) {
    QBuilder qBuilder = new QBuilder();
    Optional<Condition> condition = initialSpecification.appendTo(qBuilder);
    if (!condition.isPresent()) {
        return "";
    }
    for (LogicalNodeController queryNode : queryNodes) {
        Optional<Condition> currentCondition = queryNode.appendTo(condition.get());
        if (!currentCondition.isPresent()) {
            break;
        }
        condition = currentCondition;
    }
    return (String) condition.get().query(new RSQLVisitor());
}
Also used : Condition(com.github.rutledgepaulv.qbuilders.conditions.Condition) QBuilder(com.github.rutledgepaulv.qbuilders.builders.QBuilder) LogicalNodeController(com.faforever.client.query.LogicalNodeController) RSQLVisitor(com.github.rutledgepaulv.qbuilders.visitors.RSQLVisitor)

Aggregations

QBuilder (com.github.rutledgepaulv.qbuilders.builders.QBuilder)3 Before (org.junit.Before)2 LogicalNodeController (com.faforever.client.query.LogicalNodeController)1 Condition (com.github.rutledgepaulv.qbuilders.conditions.Condition)1 RSQLVisitor (com.github.rutledgepaulv.qbuilders.visitors.RSQLVisitor)1