use of org.jooq.Record1 in project waltz by khartec.
the class SurveyRunGenerator method remove.
@Override
public boolean remove(ApplicationContext ctx) {
DSLContext dsl = getDsl(ctx);
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);
return false;
}
use of org.jooq.Record1 in project waltz by khartec.
the class ChangeInitiativeHarness method main.
public static void main(String[] args) throws ParseException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ChangeInitiativeDao dao = ctx.getBean(ChangeInitiativeDao.class);
ChangeInitiativeIdSelectorFactory selectorFactory = new ChangeInitiativeIdSelectorFactory();
IdSelectionOptions opts = mkOpts(mkRef(EntityKind.APP_GROUP, 2), HierarchyQueryScope.EXACT);
Select<Record1<Long>> selector = selectorFactory.apply(opts);
dsl.fetch(selector).formatCSV(System.out);
dao.findForSelector(selector);
}
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 = new ApplicationIdSelectorFactory();
DSLContext dsl = ctx.getBean(DSLContext.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
IdSelectionOptions options = mkOpts(EntityReference.mkRef(EntityKind.DATA_TYPE, 5000L), HierarchyQueryScope.CHILDREN);
Select<Record1<Long>> selector = factory.apply(options);
dsl.settings().withRenderFormatted(true);
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 MeasurableRatingExporterHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ApplicationIdSelectorFactory applicationIdSelectorFactory = new ApplicationIdSelectorFactory();
Select<Record1<Long>> appSelector = applicationIdSelectorFactory.apply(IdSelectionOptions.mkOpts(mkRef(EntityKind.ORG_UNIT, 10L), HierarchyQueryScope.CHILDREN));
//
//
// long categoryId = 1L;
//
// Measurable m = MEASURABLE.as("m");
// Application app = APPLICATION.as("app");
// MeasurableCategory mc = MEASURABLE_CATEGORY.as("mc");
// MeasurableRating mr = MEASURABLE_RATING.as("mr");
// RatingScheme rs = RATING_SCHEME.as("rs");
// RatingSchemeItem rsi = RATING_SCHEME_ITEM.as("rsi");
//
//
// SelectConditionStep<Record> qry = dsl
// .select(m.NAME.as("Taxonomy Item Name"), m.EXTERNAL_ID.as("Taxonomy Item Code"))
// .select(app.NAME.as("App Name"), app.ASSET_CODE.as("App Code"), app.ID.as("App Waltz Id"), app.KIND.as("App Kind"))
// .select(rsi.NAME.as("Rating Name"), rsi.CODE.as("Rating Code"))
// .select(mr.DESCRIPTION.as("Rating Description"), mr.LAST_UPDATED_AT.as("Last Updated Time"), mr.LAST_UPDATED_BY.as("Last Updated By"))
// .from(m)
// .innerJoin(mr).on(mr.MEASURABLE_ID.eq(m.ID))
// .innerJoin(app).on(app.ID.eq(mr.ENTITY_ID))
// .innerJoin(mc).on(mc.ID.eq(m.MEASURABLE_CATEGORY_ID))
// .innerJoin(rs).on(rs.ID.eq(mc.RATING_SCHEME_ID))
// .innerJoin(rsi).on(rsi.SCHEME_ID.eq(rs.ID))
// .where(app.ENTITY_LIFECYCLE_STATUS.eq(EntityLifecycleStatus.ACTIVE.name()))
// .and(m.MEASURABLE_CATEGORY_ID.eq(categoryId))
// .and(mr.ENTITY_KIND.eq(EntityKind.APPLICATION.name()))
// .and(mr.ENTITY_ID.in(appSelector));
//
// String csv = qry.fetch().formatCSV();
// System.out.println(csv);
}
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)));
}
Aggregations