Search in sources :

Example 6 with ApplicationIdSelectorFactory

use of org.finos.waltz.data.application.ApplicationIdSelectorFactory in project waltz by khartec.

the class AttestationInstanceService method findApplicationAttestationInstancesForKindAndSelector.

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

Example 7 with ApplicationIdSelectorFactory

use of org.finos.waltz.data.application.ApplicationIdSelectorFactory 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 8 with ApplicationIdSelectorFactory

use of org.finos.waltz.data.application.ApplicationIdSelectorFactory in project waltz by khartec.

the class ScenarioPopulator method main.

public static void main(String[] args) {
    LoggingUtilities.configureLogging();
    // these two parameters specify which roadmap to use and what set of applications to use in the population.
    long roadmapId = 62L;
    IdSelectionOptions appSelectionOptions = IdSelectionOptions.mkOpts(mkRef(EntityKind.APP_GROUP, 11261L));
    Select<Record1<Long>> appSelector = new ApplicationIdSelectorFactory().apply(appSelectionOptions);
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    dsl.transaction(context -> {
        DSLContext tx = context.dsl();
        Timestamp now = DateTimeUtilities.nowUtcTimestamp();
        scrub(tx, roadmapId);
        SelectConditionStep<Record> qry = tx.select(road.NAME).select(mc.NAME).select(s.NAME, s.ID, s.EFFECTIVE_DATE).select(cai.DOMAIN_ITEM_ID, cai.DOMAIN_ITEM_KIND).select(rai.DOMAIN_ITEM_ID, rai.DOMAIN_ITEM_KIND).select(mr.ENTITY_ID, mr.ENTITY_KIND, mr.RATING).select(pd.PLANNED_DECOMMISSION_DATE).select(repl.ENTITY_ID, repl.ENTITY_KIND, repl.PLANNED_COMMISSION_DATE).select(inclCurrent).select(inclReplacement).from(road).innerJoin(mc).on(mc.ID.eq(road.ROW_TYPE_ID)).innerJoin(s).on(s.ROADMAP_ID.eq(road.ID)).innerJoin(cai).on(cai.SCENARIO_ID.eq(s.ID)).and(cai.ORIENTATION.eq(AxisOrientation.COLUMN.name())).innerJoin(rai).on(rai.SCENARIO_ID.eq(s.ID)).and(rai.ORIENTATION.eq(AxisOrientation.ROW.name())).innerJoin(mr).on(mr.MEASURABLE_ID.eq(rai.DOMAIN_ITEM_ID)).leftJoin(pd).on(pd.ENTITY_ID.eq(mr.ENTITY_ID)).and(pd.ENTITY_KIND.eq(mr.ENTITY_KIND)).and(mr.MEASURABLE_ID.eq(pd.MEASURABLE_ID)).leftJoin(repl).on(pd.ID.eq(repl.DECOMMISSION_ID)).where(road.ID.eq(roadmapId)).and(mr.ENTITY_ID.in(appSelector)).and(mr.ENTITY_KIND.eq(EntityKind.APPLICATION.name()));
        int[] insertResult = qry.fetch().stream().flatMap(r -> mkRecordsFromRow(tx, r, now)).collect(collectingAndThen(Collectors.toSet(), tx::batchInsert)).execute();
    });
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) ScenarioRatingItemRecord(org.finos.waltz.schema.tables.records.ScenarioRatingItemRecord) Timestamp(java.sql.Timestamp) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 9 with ApplicationIdSelectorFactory

use of org.finos.waltz.data.application.ApplicationIdSelectorFactory 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 10 with ApplicationIdSelectorFactory

use of org.finos.waltz.data.application.ApplicationIdSelectorFactory 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)

Aggregations

ApplicationIdSelectorFactory (org.finos.waltz.data.application.ApplicationIdSelectorFactory)13 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)10 Record1 (org.jooq.Record1)8 DSLContext (org.jooq.DSLContext)6 EntityReference (org.finos.waltz.model.EntityReference)4 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)4 Condition (org.jooq.Condition)4 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)3 Application (org.finos.waltz.model.application.Application)3 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)3 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStreamWriter (java.io.OutputStreamWriter)2 java.util (java.util)2 Collections.emptyList (java.util.Collections.emptyList)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)2 MapUtilities.groupBy (org.finos.waltz.common.MapUtilities.groupBy)2 SetUtilities.fromCollection (org.finos.waltz.common.SetUtilities.fromCollection)2