Search in sources :

Example 1 with EntityKind

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);
}
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 2 with EntityKind

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);
}
Also used : EntityKind(com.khartec.waltz.model.EntityKind)

Example 3 with EntityKind

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);
}
Also used : EntityKind(com.khartec.waltz.model.EntityKind)

Example 4 with EntityKind

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());
    }
}
Also used : EntityReference(com.khartec.waltz.model.EntityReference) EntityKind(com.khartec.waltz.model.EntityKind)

Example 5 with EntityKind

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();
    });
}
Also used : ImmutableEntityReference(com.khartec.waltz.model.ImmutableEntityReference) EntityReference(com.khartec.waltz.model.EntityReference) AuthoritativenessRating(com.khartec.waltz.model.rating.AuthoritativenessRating) EntityKind(com.khartec.waltz.model.EntityKind)

Aggregations

EntityKind (com.khartec.waltz.model.EntityKind)6 EntityReference (com.khartec.waltz.model.EntityReference)3 CollectionUtilities.map (com.khartec.waltz.common.CollectionUtilities.map)1 ListUtilities.newArrayList (com.khartec.waltz.common.ListUtilities.newArrayList)1 MapUtilities.groupBy (com.khartec.waltz.common.MapUtilities.groupBy)1 SetUtilities (com.khartec.waltz.common.SetUtilities)1 EntityNameUtilities (com.khartec.waltz.data.EntityNameUtilities)1 LogicalFlowDao (com.khartec.waltz.data.logical_flow.LogicalFlowDao)1 ACTOR (com.khartec.waltz.model.EntityKind.ACTOR)1 APPLICATION (com.khartec.waltz.model.EntityKind.APPLICATION)1 EntityReference.mkRef (com.khartec.waltz.model.EntityReference.mkRef)1 ImmutableEntityReference (com.khartec.waltz.model.ImmutableEntityReference)1 AuthoritativenessRating (com.khartec.waltz.model.rating.AuthoritativenessRating)1 LOGICAL_FLOW (com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW)1 LOGICAL_FLOW_DECORATOR (com.khartec.waltz.schema.tables.LogicalFlowDecorator.LOGICAL_FLOW_DECORATOR)1 EntityNamedNoteTypeRecord (com.khartec.waltz.schema.tables.records.EntityNamedNoteTypeRecord)1 DIConfiguration (com.khartec.waltz.service.DIConfiguration)1 Collection (java.util.Collection)1 Map (java.util.Map)1 Set (java.util.Set)1