Example usage for org.springframework.context.annotation Condition toString

List of usage examples for org.springframework.context.annotation Condition toString

Introduction

In this page you can find the example usage for org.springframework.context.annotation Condition toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.khartec.waltz.jobs.DataFlowHarness.java

private static SelectOrderByStep<Record2<String, Integer>> bigQuery(DSLContext dsl,
        Select<Record1<Long>> appIdSelector) {
    WithStep flows = dsl.with("flows")
            .as(DSL.selectDistinct(DATA_FLOW.SOURCE_ENTITY_ID, DATA_FLOW.TARGET_ENTITY_ID).from(DATA_FLOW));

    ImmutableDataFlowMeasures.Builder builder = ImmutableDataFlowMeasures.builder();

    Condition inboundCondition = DSL.field("SOURCE_ENTITY_ID").notIn(appIdSelector)
            .and(DSL.field("TARGET_ENTITY_ID").in(appIdSelector));

    Condition outboundCondition = DSL.field("SOURCE_ENTITY_ID").in(appIdSelector)
            .and(DSL.field("TARGET_ENTITY_ID").notIn(appIdSelector));

    Condition intraCondition = DSL.field("SOURCE_ENTITY_ID").in(appIdSelector)
            .and(DSL.field("TARGET_ENTITY_ID").in(appIdSelector));

    // TODO:  query goes at least twice as slowly if you don't toString() the condition...
    SelectOrderByStep<Record2<String, Integer>> query = flows
            .select(DSL.value("inConnCount").as("name"), DSL.count()).from("flows")
            .where(inboundCondition.toString())
            .union(DSL.select(DSL.value("outConnCount").as("name"), DSL.count()).from("flows")
                    .where(outboundCondition.toString()))
            .union(DSL.select(DSL.value("intraConnCount").as("name"), DSL.count()).from("flows")
                    .where(intraCondition.toString()));

    return query;

}