Search in sources :

Example 1 with Record1

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

the class AbstractMetaDataReadInterface method readKv.

@Override
public Optional<String> readKv(DSLContext dsl, MetaInfoKey key) {
    KvTable<KvRecord> kvTable = getKvTable();
    Condition c = kvTable.KEY.eq(key.getKeyName());
    return dsl.select(kvTable.VALUE).from(kvTable).where(c).fetchOptional().map(Record1::value1);
}
Also used : Condition(org.jooq.Condition) KvRecord(com.torodb.backend.tables.records.KvRecord) Record1(org.jooq.Record1)

Example 2 with Record1

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

the class ApplicationIdSelectorHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ApplicationIdSelectorFactory factory = ctx.getBean(ApplicationIdSelectorFactory.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    IdSelectionOptions options = IdSelectionOptions.mkOpts(EntityReference.mkRef(EntityKind.MEASURABLE, 1L), HierarchyQueryScope.EXACT);
    Select<Record1<Long>> selector = factory.apply(options);
    System.out.println(selector);
    List<Application> apps = applicationService.findByAppIdSelector(options);
    System.out.println("--- sz: " + apps.size());
    apps.forEach(System.out::println);
    System.out.println("--- done");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationIdSelectorFactory(com.khartec.waltz.data.application.ApplicationIdSelectorFactory) DSLContext(org.jooq.DSLContext) Application(com.khartec.waltz.model.application.Application) ApplicationService(com.khartec.waltz.service.application.ApplicationService) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 3 with Record1

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

the class MeasurableHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    MeasurableIdSelectorFactory factory = ctx.getBean(MeasurableIdSelectorFactory.class);
    MeasurableService measurableService = ctx.getBean(MeasurableService.class);
    EntityReference ref = mkRef(EntityKind.FLOW_DIAGRAM, 2);
    IdSelectionOptions options = mkOpts(ref, HierarchyQueryScope.EXACT);
    Select<Record1<Long>> selector = factory.apply(options);
    System.out.println("--selector");
    System.out.println(selector);
    System.out.println("---");
    List<Measurable> measurables = measurableService.findByMeasurableIdSelector(options);
    measurables.forEach(System.out::println);
    System.out.println("-----");
    measurables.stream().filter(m -> OptionalUtilities.contentsEqual(m.id(), 486L)).forEach(System.out::println);
    System.out.println("-----");
}
Also used : Measurable(com.khartec.waltz.model.measurable.Measurable) HierarchyQueryScope(com.khartec.waltz.model.HierarchyQueryScope) EntityReference(com.khartec.waltz.model.EntityReference) OptionalUtilities(com.khartec.waltz.common.OptionalUtilities) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityKind(com.khartec.waltz.model.EntityKind) MeasurableService(com.khartec.waltz.service.measurable.MeasurableService) List(java.util.List) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) DIConfiguration(com.khartec.waltz.service.DIConfiguration) Record1(org.jooq.Record1) MeasurableIdSelectorFactory(com.khartec.waltz.data.measurable.MeasurableIdSelectorFactory) IdSelectionOptions.mkOpts(com.khartec.waltz.model.IdSelectionOptions.mkOpts) Select(org.jooq.Select) EntityReference.mkRef(com.khartec.waltz.model.EntityReference.mkRef) Measurable(com.khartec.waltz.model.measurable.Measurable) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(com.khartec.waltz.data.measurable.MeasurableIdSelectorFactory) EntityReference(com.khartec.waltz.model.EntityReference) MeasurableService(com.khartec.waltz.service.measurable.MeasurableService) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 4 with Record1

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

the class SurveyInstanceIdSelectorFactory method mkForOrgUnit.

private SelectConditionStep<Record1<Long>> mkForOrgUnit(EntityReference ref, HierarchyQueryScope scope) {
    ImmutableIdSelectionOptions ouSelectorOptions = ImmutableIdSelectionOptions.builder().entityReference(ref).scope(scope).build();
    Select<Record1<Long>> ouSelector = orgUnitIdSelectorFactory.apply(ouSelectorOptions);
    return dsl.selectDistinct(SURVEY_INSTANCE.ID).from(SURVEY_INSTANCE).where(SURVEY_INSTANCE.ENTITY_KIND.eq(ref.kind().name()).and(SURVEY_INSTANCE.ENTITY_ID.in(ouSelector)));
}
Also used : ImmutableIdSelectionOptions(com.khartec.waltz.model.ImmutableIdSelectionOptions) Record1(org.jooq.Record1)

Example 5 with Record1

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

the class SurveyRunGenerator method deleteSurveyRunsAndResponses.

private static void deleteSurveyRunsAndResponses(DSLContext dsl) {
    Condition previousSurveyRunCondition = SURVEY_RUN.NAME.like("% " + SURVEY_RUN_SUFFIX);
    Select<Record1<Long>> surveyRunIdSelector = DSL.select(SURVEY_RUN.ID).from(SURVEY_RUN).where(previousSurveyRunCondition);
    Select<Record1<Long>> surveyInstanceIdSelector = DSL.select(SURVEY_INSTANCE.ID).from(SURVEY_INSTANCE).where(SURVEY_INSTANCE.SURVEY_RUN_ID.in(surveyRunIdSelector));
    int deleteCount = dsl.deleteFrom(SURVEY_QUESTION_RESPONSE).where(SURVEY_QUESTION_RESPONSE.SURVEY_INSTANCE_ID.in(surveyInstanceIdSelector)).execute();
    LOG.debug("Deleted: {} existing question responses", deleteCount);
    deleteCount = dsl.deleteFrom(SURVEY_INSTANCE_RECIPIENT).where(SURVEY_INSTANCE_RECIPIENT.SURVEY_INSTANCE_ID.in(surveyInstanceIdSelector)).execute();
    LOG.debug("Deleted: {} existing instance recipients", deleteCount);
    deleteCount = dsl.deleteFrom(SURVEY_INSTANCE).where(SURVEY_INSTANCE.SURVEY_RUN_ID.in(surveyRunIdSelector)).execute();
    LOG.debug("Deleted: {} existing survey instances", deleteCount);
    deleteCount = dsl.deleteFrom(SURVEY_RUN).where(previousSurveyRunCondition).execute();
    LOG.debug("Deleted: {} existing survey runs", deleteCount);
}
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