Search in sources :

Example 1 with EntityReference

use of com.khartec.waltz.model.EntityReference 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)

Example 2 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class FlowLineageHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    LogicalFlowDao flowDao = ctx.getBean(LogicalFlowDao.class);
    EntityReference ref1 = mkRef(APPLICATION, 25662);
    EntityReference ref2 = mkRef(ACTOR, 10);
    EntityReference ref3 = mkRef(APPLICATION, 25612);
    findIncomingByRefs(dsl, SetUtilities.fromArray(ref1, ref2, ref3));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityReference(com.khartec.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) LogicalFlowDao(com.khartec.waltz.data.logical_flow.LogicalFlowDao)

Example 3 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class FlowLineageHarness method findIncomingByRefs.

private static void findIncomingByRefs(DSLContext dsl, Set<EntityReference> entityReferences) {
    Map<EntityKind, Collection<EntityReference>> refsByKind = groupBy(ref -> ref.kind(), entityReferences);
    Condition anyTargetMatches = refsByKind.entrySet().stream().map(entry -> LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(entry.getKey().name()).and(LOGICAL_FLOW.TARGET_ENTITY_ID.in(map(entry.getValue(), ref -> ref.id())))).collect(Collectors.reducing(DSL.falseCondition(), (acc, c) -> acc.or(c)));
    System.out.println(anyTargetMatches);
    Field<String> SOURCE_NAME_FIELD = EntityNameUtilities.mkEntityNameField(LOGICAL_FLOW.SOURCE_ENTITY_ID, LOGICAL_FLOW.SOURCE_ENTITY_KIND, newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR));
    dsl.select(LOGICAL_FLOW.fields()).select(SOURCE_NAME_FIELD).from(LOGICAL_FLOW).where(anyTargetMatches.and(LogicalFlowDao.NOT_REMOVED)).forEach(System.out::println);
    dsl.select().from(LOGICAL_FLOW_DECORATOR).innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID)).where(anyTargetMatches).forEach(System.out::println);
}
Also used : Condition(org.jooq.Condition) DSL(org.jooq.impl.DSL) SetUtilities(com.khartec.waltz.common.SetUtilities) ACTOR(com.khartec.waltz.model.EntityKind.ACTOR) ParseException(org.jooq.tools.json.ParseException) Collection(java.util.Collection) MapUtilities.groupBy(com.khartec.waltz.common.MapUtilities.groupBy) Set(java.util.Set) EntityReference(com.khartec.waltz.model.EntityReference) Field(org.jooq.Field) ListUtilities.newArrayList(com.khartec.waltz.common.ListUtilities.newArrayList) Collectors(java.util.stream.Collectors) Condition(org.jooq.Condition) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityKind(com.khartec.waltz.model.EntityKind) CollectionUtilities.map(com.khartec.waltz.common.CollectionUtilities.map) DIConfiguration(com.khartec.waltz.service.DIConfiguration) LOGICAL_FLOW_DECORATOR(com.khartec.waltz.schema.tables.LogicalFlowDecorator.LOGICAL_FLOW_DECORATOR) EntityNameUtilities(com.khartec.waltz.data.EntityNameUtilities) LogicalFlowDao(com.khartec.waltz.data.logical_flow.LogicalFlowDao) Map(java.util.Map) APPLICATION(com.khartec.waltz.model.EntityKind.APPLICATION) DSLContext(org.jooq.DSLContext) EntityReference.mkRef(com.khartec.waltz.model.EntityReference.mkRef) LOGICAL_FLOW(com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) Collection(java.util.Collection) EntityKind(com.khartec.waltz.model.EntityKind)

Example 4 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class MeasurableHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    MeasurableIdSelectorFactory factory = ctx.getBean(MeasurableIdSelectorFactory.class);
    MeasurableService measurableService = ctx.getBean(MeasurableService.class);
    EntityReference ref = mkRef(EntityKind.FLOW_DIAGRAM, 2);
    IdSelectionOptions options = mkOpts(ref, HierarchyQueryScope.EXACT);
    Select<Record1<Long>> selector = factory.apply(options);
    System.out.println("--selector");
    System.out.println(selector);
    System.out.println("---");
    List<Measurable> measurables = measurableService.findByMeasurableIdSelector(options);
    measurables.forEach(System.out::println);
    System.out.println("-----");
    measurables.stream().filter(m -> OptionalUtilities.contentsEqual(m.id(), 486L)).forEach(System.out::println);
    System.out.println("-----");
}
Also used : Measurable(com.khartec.waltz.model.measurable.Measurable) HierarchyQueryScope(com.khartec.waltz.model.HierarchyQueryScope) EntityReference(com.khartec.waltz.model.EntityReference) OptionalUtilities(com.khartec.waltz.common.OptionalUtilities) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityKind(com.khartec.waltz.model.EntityKind) MeasurableService(com.khartec.waltz.service.measurable.MeasurableService) List(java.util.List) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) DIConfiguration(com.khartec.waltz.service.DIConfiguration) Record1(org.jooq.Record1) MeasurableIdSelectorFactory(com.khartec.waltz.data.measurable.MeasurableIdSelectorFactory) IdSelectionOptions.mkOpts(com.khartec.waltz.model.IdSelectionOptions.mkOpts) Select(org.jooq.Select) EntityReference.mkRef(com.khartec.waltz.model.EntityReference.mkRef) Measurable(com.khartec.waltz.model.measurable.Measurable) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(com.khartec.waltz.data.measurable.MeasurableIdSelectorFactory) EntityReference(com.khartec.waltz.model.EntityReference) MeasurableService(com.khartec.waltz.service.measurable.MeasurableService) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 5 with EntityReference

use of com.khartec.waltz.model.EntityReference in project waltz by khartec.

the class ServerComplexityHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    OrganisationalUnitDao ouDao = ctx.getBean(OrganisationalUnitDao.class);
    ServerComplexityService serverService = ctx.getBean(ServerComplexityService.class);
    ComplexityRatingService complexityService = ctx.getBean(ComplexityRatingService.class);
    // EntityReference entityReference = EntityReference.mkRef(EntityKind.PERSON, 1);
    EntityReference entityReference = EntityReference.mkRef(EntityKind.PERSON, 63);
    List<ComplexityRating> complexity = FunctionUtilities.time("complexity", () -> complexityService.findForAppIdSelector(IdSelectionOptions.mkOpts(entityReference, HierarchyQueryScope.CHILDREN)));
}
Also used : OrganisationalUnitDao(com.khartec.waltz.data.orgunit.OrganisationalUnitDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ComplexityRatingService(com.khartec.waltz.service.complexity.ComplexityRatingService) ServerComplexityService(com.khartec.waltz.service.complexity.ServerComplexityService) EntityReference(com.khartec.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) ComplexityRating(com.khartec.waltz.model.complexity.ComplexityRating)

Aggregations

EntityReference (com.khartec.waltz.model.EntityReference)33 EntityKind (com.khartec.waltz.model.EntityKind)11 DSLContext (org.jooq.DSLContext)9 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)9 List (java.util.List)8 ListUtilities.newArrayList (com.khartec.waltz.common.ListUtilities.newArrayList)6 Collection (java.util.Collection)6 LogicalFlowDao (com.khartec.waltz.data.logical_flow.LogicalFlowDao)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Checks.checkNotNull (com.khartec.waltz.common.Checks.checkNotNull)4 SetUtilities (com.khartec.waltz.common.SetUtilities)4 IdSelectionOptions (com.khartec.waltz.model.IdSelectionOptions)4 LogicalFlow (com.khartec.waltz.model.logical_flow.LogicalFlow)4 LOGICAL_FLOW (com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW)4 DIConfiguration (com.khartec.waltz.service.DIConfiguration)4 EntityReference.mkRef (com.khartec.waltz.model.EntityReference.mkRef)3 ImmutableEntityReference (com.khartec.waltz.model.ImmutableEntityReference)3 Application (com.khartec.waltz.model.application.Application)3 OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)3 LogicalFlowService (com.khartec.waltz.service.logical_flow.LogicalFlowService)3