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