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());
}
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));
}
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);
}
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("-----");
}
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)));
}
Aggregations