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