Search in sources :

Example 51 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class LogicalFlowIdSelectorFactory method wrapAppIdSelector.

private Select<Record1<Long>> wrapAppIdSelector(IdSelectionOptions options) {
    Select<Record1<Long>> appIdSelector = applicationIdSelectorFactory.apply(options);
    Condition sourceCondition = LOGICAL_FLOW.SOURCE_ENTITY_ID.in(appIdSelector).and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name()));
    Condition targetCondition = LOGICAL_FLOW.TARGET_ENTITY_ID.in(appIdSelector).and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()));
    return DSL.select(LOGICAL_FLOW.ID).from(LOGICAL_FLOW).where(sourceCondition.or(targetCondition)).and(LOGICAL_NOT_REMOVED);
}
Also used : Condition(org.jooq.Condition) Record1(org.jooq.Record1)

Example 52 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class ChangeInitiativeIdSelectorFactory method mkForRef.

private Select<Record1<Long>> mkForRef(IdSelectionOptions options) {
    EntityReference ref = options.entityReference();
    Select<Record1<Long>> aToB = DSL.selectDistinct(ENTITY_RELATIONSHIP.ID_A.as("id")).from(ENTITY_RELATIONSHIP).where(ENTITY_RELATIONSHIP.KIND_A.eq(EntityKind.CHANGE_INITIATIVE.name())).and(ENTITY_RELATIONSHIP.KIND_B.eq(ref.kind().name())).and(ENTITY_RELATIONSHIP.ID_B.eq(ref.id()));
    Select<Record1<Long>> bToA = DSL.selectDistinct(ENTITY_RELATIONSHIP.ID_B.as("id")).from(ENTITY_RELATIONSHIP).where(ENTITY_RELATIONSHIP.KIND_B.eq(EntityKind.CHANGE_INITIATIVE.name())).and(ENTITY_RELATIONSHIP.KIND_A.eq(ref.kind().name())).and(ENTITY_RELATIONSHIP.ID_A.eq(ref.id()));
    return DSL.selectFrom(aToB.union(bToA).asTable());
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) Record1(org.jooq.Record1)

Example 53 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class GenericSelectorFactory method apply.

public GenericSelector apply(IdSelectionOptions selectionOptions) {
    EntityKind kind = selectionOptions.entityReference().kind();
    ImmutableGenericSelector.Builder builder = ImmutableGenericSelector.builder().kind(kind);
    if (selectionOptions.scope() == HierarchyQueryScope.EXACT) {
        Select<Record1<Long>> select = DSL.select(DSL.val(selectionOptions.entityReference().id()));
        return builder.selector(select).build();
    }
    Select<Record1<Long>> ids = applySelectorForKind(kind, selectionOptions);
    builder.selector(ids);
    return builder.build();
}
Also used : EntityKind(org.finos.waltz.model.EntityKind) Record1(org.jooq.Record1)

Example 54 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class FlowClassificationCalculator method update.

private int[] update(DataType dataType, EntityReference vantageRef) {
    LOG.debug("Updating ratings for flow classification rule - dataType name: {}, id: {}, vantage point: {}", dataType.name(), dataType.id().get(), vantageRef);
    IdSelectionOptions selectorOptions = mkOpts(vantageRef);
    Select<Record1<Long>> selector = appIdSelectorFactory.apply(selectorOptions);
    Set<Long> dataTypeDescendents = entityHierarchyDao.findDesendents(dataType.entityReference()).stream().map(d -> d.id().get()).collect(Collectors.toSet());
    Collection<DataTypeDecorator> impactedDecorators = logicalFlowDecoratorDao.findByEntityIdSelector(selector, Optional.of(EntityKind.APPLICATION)).stream().filter(decorator -> dataTypeDescendents.contains(decorator.decoratorEntity().id())).collect(toList());
    Collection<DataTypeDecorator> reRatedDecorators = ratingsCalculator.calculate(impactedDecorators);
    Set<DataTypeDecorator> modifiedDecorators = SetUtilities.minus(fromCollection(reRatedDecorators), fromCollection(impactedDecorators));
    LOG.debug("Need to update {} ratings due to auth source change - dataType name: {}, id: {}, parent: {}", modifiedDecorators.size(), dataType.name(), dataType.id().get(), vantageRef);
    return updateDecorators(modifiedDecorators);
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) EntityKind(org.finos.waltz.model.EntityKind) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) DataType(org.finos.waltz.model.datatype.DataType) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) LogicalFlowDecoratorRatingsCalculator(org.finos.waltz.service.data_flow_decorator.LogicalFlowDecoratorRatingsCalculator) EntityHierarchyDao(org.finos.waltz.data.entity_hierarchy.EntityHierarchyDao) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) Select(org.jooq.Select) Logger(org.slf4j.Logger) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Collection(java.util.Collection) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) Set(java.util.Set) Collectors(java.util.stream.Collectors) Collectors.toList(java.util.stream.Collectors.toList) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) LogicalFlowDecoratorDao(org.finos.waltz.data.datatype_decorator.LogicalFlowDecoratorDao) SetUtilities(org.finos.waltz.common.SetUtilities) EntityReference(org.finos.waltz.model.EntityReference) Optional(java.util.Optional) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) SetUtilities.fromCollection(org.finos.waltz.common.SetUtilities.fromCollection) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 55 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class PhysicalSpecificationIdSelectorFactory method mkForFlowDiagram.

private Select<Record1<Long>> mkForFlowDiagram(IdSelectionOptions options) {
    SelectorUtilities.ensureScopeIsExact(options);
    Select<Record1<Long>> flowSelector = physicalFlowIdSelectorFactory.apply(options);
    Condition condition = PHYSICAL_FLOW.ID.in(flowSelector).and(getLifecycleCondition(options));
    return selectViaPhysicalFlowJoin(condition);
}
Also used : Condition(org.jooq.Condition) Record1(org.jooq.Record1)

Aggregations

Record1 (org.jooq.Record1)58 Condition (org.jooq.Condition)22 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)16 DSLContext (org.jooq.DSLContext)14 Select (org.jooq.Select)10 ApplicationIdSelectorFactory (org.finos.waltz.data.application.ApplicationIdSelectorFactory)9 EntityReference (org.finos.waltz.model.EntityReference)8 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)8 Record (org.jooq.Record)7 IdSelectionOptions (com.khartec.waltz.model.IdSelectionOptions)5 EntityKind (org.finos.waltz.model.EntityKind)5 EntityReference (com.khartec.waltz.model.EntityReference)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)4 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)4 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)4 DSL (org.jooq.impl.DSL)4 java.util (java.util)3 ArrayList (java.util.ArrayList)3