Search in sources :

Example 31 with Record1

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

the class AttestationInstanceService method findAttestationInstanceSummaryForSelector.

public Set<ApplicationAttestationSummaryCounts> findAttestationInstanceSummaryForSelector(ApplicationAttestationInstanceInfo applicationAttestationInstanceInfo) {
    Condition condition = getApplicationAttestationFilterCondition(applicationAttestationInstanceInfo.filters());
    ApplicationIdSelectorFactory applicationIdSelectorFactory = new ApplicationIdSelectorFactory();
    Select<Record1<Long>> appIds = applicationIdSelectorFactory.apply(applicationAttestationInstanceInfo.selectionOptions());
    return attestationInstanceDao.findAttestationInstanceSummaryForSelector(appIds, condition);
}
Also used : Condition(org.jooq.Condition) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) Record1(org.jooq.Record1)

Example 32 with Record1

use of org.jooq.Record1 in project torodb by torodb.

the class AbstractMetaDataWriteInterface method writeMetaInfo.

@Override
public String writeMetaInfo(DSLContext dsl, MetaInfoKey key, String newValue) {
    Condition c = kvTable.KEY.eq(key.getKeyName());
    Optional<String> oldValue = dsl.select(kvTable.VALUE).from(kvTable).where(c).fetchOptional().map(Record1::value1);
    if (oldValue.isPresent()) {
        int updatedRows = dsl.update(kvTable).set(kvTable.KEY, key.getKeyName()).set(kvTable.VALUE, newValue).where(c).execute();
        assert updatedRows == 1;
    } else {
        int newRows = dsl.insertInto(kvTable, kvTable.KEY, kvTable.VALUE).values(key.getKeyName(), newValue).execute();
        assert newRows == 1;
    }
    return oldValue.orElse(null);
}
Also used : Condition(org.jooq.Condition) Record1(org.jooq.Record1)

Example 33 with Record1

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

the class SurveyRunService method generateSurveyInstanceRecipients.

public List<SurveyInstanceRecipient> generateSurveyInstanceRecipients(long surveyRunId) {
    SurveyRun surveyRun = surveyRunDao.getById(surveyRunId);
    checkNotNull(surveyRun, "surveyRun " + surveyRunId + " not found");
    SurveyTemplate surveyTemplate = surveyTemplateDao.getById(surveyRun.surveyTemplateId());
    checkNotNull(surveyTemplate, "surveyTemplate " + surveyRun.surveyTemplateId() + " not found");
    IdSelectorFactory idSelectorFactory = idSelectorFactoryProvider.getForKind(surveyTemplate.targetEntityKind());
    Select<Record1<Long>> idSelector = idSelectorFactory.apply(surveyRun.selectionOptions());
    Map<EntityReference, List<Person>> entityRefToPeople = involvementDao.findPeopleByEntitySelectorAndInvolvement(surveyTemplate.targetEntityKind(), idSelector, surveyRun.involvementKindIds());
    return entityRefToPeople.entrySet().stream().flatMap(e -> e.getValue().stream().map(p -> ImmutableSurveyInstanceRecipient.builder().surveyInstance(ImmutableSurveyInstance.builder().surveyEntity(e.getKey()).surveyRunId(surveyRun.id().get()).status(SurveyInstanceStatus.NOT_STARTED).dueDate(surveyRun.dueDate()).build()).person(p).build())).distinct().collect(toList());
}
Also used : SetUtilities.fromCollection(com.khartec.waltz.common.SetUtilities.fromCollection) IdSelectorFactory(com.khartec.waltz.data.IdSelectorFactory) InvolvementDao(com.khartec.waltz.data.involvement.InvolvementDao) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Autowired(org.springframework.beans.factory.annotation.Autowired) SurveyInstanceRecipientDao(com.khartec.waltz.data.survey.SurveyInstanceRecipientDao) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) Map(java.util.Map) PersonDao(com.khartec.waltz.data.person.PersonDao) ImmutableChangeLog(com.khartec.waltz.model.changelog.ImmutableChangeLog) com.khartec.waltz.model.survey(com.khartec.waltz.model.survey) Select(org.jooq.Select) SurveyRunDao(com.khartec.waltz.data.survey.SurveyRunDao) SurveyTemplateDao(com.khartec.waltz.data.survey.SurveyTemplateDao) Checks.checkNotNull(com.khartec.waltz.common.Checks.checkNotNull) com.khartec.waltz.model(com.khartec.waltz.model) Set(java.util.Set) IdSelectorFactoryProvider(com.khartec.waltz.data.IdSelectorFactoryProvider) Objects(java.util.Objects) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Person(com.khartec.waltz.model.person.Person) LocalDate(java.time.LocalDate) SurveyInstanceDao(com.khartec.waltz.data.survey.SurveyInstanceDao) ChangeLogService(com.khartec.waltz.service.changelog.ChangeLogService) Checks.checkTrue(com.khartec.waltz.common.Checks.checkTrue) IdSelectorFactory(com.khartec.waltz.data.IdSelectorFactory) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Record1(org.jooq.Record1)

Example 34 with Record1

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

the class AuthSourceRatingCalculator method update.

private int[] update(DataType dataType, EntityReference vantageRef) {
    LOG.info("Updating ratings for auth source - dataType: {}, vantage point: {}", dataType, vantageRef);
    IdSelectionOptions selectorOptions = mkOpts(vantageRef, HierarchyQueryScope.CHILDREN);
    Select<Record1<Long>> selector = appIdSelectorFactory.apply(selectorOptions);
    Collection<LogicalFlowDecorator> impactedDecorators = logicalFlowDecoratorDao.findByEntityIdSelectorAndKind(EntityKind.APPLICATION, selector, EntityKind.DATA_TYPE).stream().filter(decorator -> decorator.decoratorEntity().id() == dataType.id().get()).collect(toList());
    Collection<LogicalFlowDecorator> reRatedDecorators = ratingsCalculator.calculate(impactedDecorators);
    Set<LogicalFlowDecorator> modifiedDecorators = SetUtilities.minus(fromCollection(reRatedDecorators), fromCollection(impactedDecorators));
    LOG.info("Need to update {} ratings due to auth source change - dataType: {}, parent: {}", modifiedDecorators.size(), dataType, vantageRef);
    return updateDecorators(modifiedDecorators);
}
Also used : Logger(org.slf4j.Logger) SetUtilities.fromCollection(com.khartec.waltz.common.SetUtilities.fromCollection) SetUtilities(com.khartec.waltz.common.SetUtilities) ApplicationIdSelectorFactory(com.khartec.waltz.data.application.ApplicationIdSelectorFactory) LogicalFlowDecoratorDao(com.khartec.waltz.data.data_flow_decorator.LogicalFlowDecoratorDao) Checks.checkNotNull(com.khartec.waltz.common.Checks.checkNotNull) LogicalFlowDecoratorRatingsCalculator(com.khartec.waltz.service.data_flow_decorator.LogicalFlowDecoratorRatingsCalculator) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) HierarchyQueryScope(com.khartec.waltz.model.HierarchyQueryScope) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) EntityReference(com.khartec.waltz.model.EntityReference) EntityKind(com.khartec.waltz.model.EntityKind) DataTypeDao(com.khartec.waltz.data.data_type.DataTypeDao) LogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator) Collectors.toList(java.util.stream.Collectors.toList) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) DataType(com.khartec.waltz.model.datatype.DataType) IdSelectionOptions.mkOpts(com.khartec.waltz.model.IdSelectionOptions.mkOpts) Select(org.jooq.Select) LogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 35 with Record1

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

the class PhysicalSpecificationIdSelectorFactory method mkForFlowDiagram.

private Select<Record1<Long>> mkForFlowDiagram(IdSelectionOptions options) {
    ensureScopeIsExact(options);
    Select<Record1<Long>> flowSelector = physicalFlowIdSelectorFactory.apply(options);
    Condition condition = PHYSICAL_FLOW.ID.in(flowSelector);
    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