use of com.khartec.waltz.model.EntityKind 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.EntityKind in project waltz by khartec.
the class MeasurableRelationshipEndpoint method getReference.
private EntityReference getReference(String qualifier, Request request) {
EntityKind kind = readEnum(request, "kind" + qualifier, EntityKind.class, s -> null);
long id = getLong(request, "id" + qualifier);
return mkRef(kind, id);
}
use of com.khartec.waltz.model.EntityKind in project waltz by khartec.
the class EntityHierarchyEndpoint method buildByKindRoute.
private int buildByKindRoute(Request request, Response response) {
requireRole(userRoleService, request, ADMIN);
EntityKind kind = getKind(request);
LOG.info("Building entity hierarchy for kind: {}", kind);
return entityHierarchyService.buildFor(kind);
}
use of com.khartec.waltz.model.EntityKind in project waltz by khartec.
the class EntityIdSelectorFactory method apply.
@Override
public final Select<Record1<Long>> apply(EntityIdSelectionOptions options) {
checkNotNull(options, "options cannot be null");
EntityKind desiredKind = options.desiredKind();
EntityReference ref = options.entityReference();
switch(ref.kind()) {
case APP_GROUP:
return mkForAppGroup(ref, options.scope());
case PERSON:
return mkForPerson(desiredKind, ref, options.scope());
case ORG_UNIT:
return mkForOrgUnit(ref, options.scope());
default:
throw new IllegalArgumentException("Cannot create selector for entity kind: " + ref.kind());
}
}
use of com.khartec.waltz.model.EntityKind in project waltz by khartec.
the class LogicalFlowDecoratorDao method summarizeForCondition.
private List<DecoratorRatingSummary> summarizeForCondition(Condition condition) {
// this is intentionally TARGET only as we use to calculate auth source stats
Condition dataFlowJoinCondition = LOGICAL_FLOW.ID.eq(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID);
Collection<Field<?>> groupingFields = newArrayList(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_KIND, LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID, LOGICAL_FLOW_DECORATOR.RATING);
Field<Integer> countField = DSL.count(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID).as("count");
return dsl.select(groupingFields).select(countField).from(LOGICAL_FLOW_DECORATOR).innerJoin(LOGICAL_FLOW).on(dsl.renderInlined(dataFlowJoinCondition)).where(dsl.renderInlined(condition)).groupBy(groupingFields).fetch(r -> {
EntityKind decoratorEntityKind = EntityKind.valueOf(r.getValue(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_KIND));
long decoratorEntityId = r.getValue(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID);
EntityReference decoratorRef = EntityReference.mkRef(decoratorEntityKind, decoratorEntityId);
AuthoritativenessRating rating = AuthoritativenessRating.valueOf(r.getValue(LOGICAL_FLOW_DECORATOR.RATING));
Integer count = r.getValue(countField);
return ImmutableDecoratorRatingSummary.builder().decoratorEntityReference(decoratorRef).rating(rating).count(count).build();
});
}
Aggregations