Search in sources :

Example 41 with Record1

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;
}
Also used : Condition(org.jooq.Condition) DSLContext(org.jooq.DSLContext) Record1(org.jooq.Record1)

Example 42 with Record1

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);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ChangeInitiativeDao(org.finos.waltz.data.change_initiative.ChangeInitiativeDao) DSLContext(org.jooq.DSLContext) ChangeInitiativeIdSelectorFactory(org.finos.waltz.data.change_initiative.ChangeInitiativeIdSelectorFactory) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 43 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 = 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");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) DSLContext(org.jooq.DSLContext) Application(org.finos.waltz.model.application.Application) ApplicationService(org.finos.waltz.service.application.ApplicationService) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 44 with Record1

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);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) DSLContext(org.jooq.DSLContext) Record1(org.jooq.Record1)

Example 45 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(org.finos.waltz.model.ImmutableIdSelectionOptions) 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