Search in sources :

Example 1 with PHYSICAL_FLOW

use of com.khartec.waltz.schema.tables.PhysicalFlow.PHYSICAL_FLOW in project waltz by khartec.

the class PhysicalFlowSearchDao method searchReports.

/**
 * A report is a physical flow which goes to an
 * external actor
 * @param query
 * @return
 */
public List<EntityReference> searchReports(String query) {
    if (isEmpty(query)) {
        return emptyList();
    }
    Field<String> nameField = DSL.concat(PHYSICAL_SPECIFICATION.NAME, DSL.value(" - "), ACTOR.NAME);
    Condition termMatcher = mkTerms(query).stream().reduce(DSL.trueCondition(), (acc, t) -> nameField.like("%" + t + "%"), (acc, t) -> acc.and(t));
    return dsl.select(PHYSICAL_FLOW.ID, nameField).from(PHYSICAL_FLOW).innerJoin(PHYSICAL_SPECIFICATION).on(PHYSICAL_FLOW.SPECIFICATION_ID.eq(PHYSICAL_SPECIFICATION.ID)).innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(PHYSICAL_FLOW.LOGICAL_FLOW_ID)).innerJoin(ACTOR).on(LOGICAL_FLOW.TARGET_ENTITY_ID.eq(ACTOR.ID).and(ACTOR.IS_EXTERNAL.eq(true))).where(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.ACTOR.name())).and(termMatcher).fetch().stream().map(r -> mkRef(EntityKind.PHYSICAL_FLOW, r.value1(), r.value2())).collect(Collectors.toList());
}
Also used : Condition(org.jooq.Condition) PHYSICAL_SPECIFICATION(com.khartec.waltz.schema.tables.PhysicalSpecification.PHYSICAL_SPECIFICATION) DSL(org.jooq.impl.DSL) Checks.checkNotNull(com.khartec.waltz.common.Checks.checkNotNull) Collections.emptyList(java.util.Collections.emptyList) Autowired(org.springframework.beans.factory.annotation.Autowired) EntityReference(com.khartec.waltz.model.EntityReference) Field(org.jooq.Field) Collectors(java.util.stream.Collectors) Condition(org.jooq.Condition) PHYSICAL_FLOW(com.khartec.waltz.schema.tables.PhysicalFlow.PHYSICAL_FLOW) EntityKind(com.khartec.waltz.model.EntityKind) List(java.util.List) ACTOR(com.khartec.waltz.schema.tables.Actor.ACTOR) DSLContext(org.jooq.DSLContext) StringUtilities.isEmpty(com.khartec.waltz.common.StringUtilities.isEmpty) SearchUtilities.mkTerms(com.khartec.waltz.data.SearchUtilities.mkTerms) Repository(org.springframework.stereotype.Repository) EntityReference.mkRef(com.khartec.waltz.model.EntityReference.mkRef) LOGICAL_FLOW(com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW)

Aggregations

Checks.checkNotNull (com.khartec.waltz.common.Checks.checkNotNull)1 StringUtilities.isEmpty (com.khartec.waltz.common.StringUtilities.isEmpty)1 SearchUtilities.mkTerms (com.khartec.waltz.data.SearchUtilities.mkTerms)1 EntityKind (com.khartec.waltz.model.EntityKind)1 EntityReference (com.khartec.waltz.model.EntityReference)1 EntityReference.mkRef (com.khartec.waltz.model.EntityReference.mkRef)1 ACTOR (com.khartec.waltz.schema.tables.Actor.ACTOR)1 LOGICAL_FLOW (com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW)1 PHYSICAL_FLOW (com.khartec.waltz.schema.tables.PhysicalFlow.PHYSICAL_FLOW)1 PHYSICAL_SPECIFICATION (com.khartec.waltz.schema.tables.PhysicalSpecification.PHYSICAL_SPECIFICATION)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Condition (org.jooq.Condition)1 DSLContext (org.jooq.DSLContext)1 Field (org.jooq.Field)1 DSL (org.jooq.impl.DSL)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Repository (org.springframework.stereotype.Repository)1