Search in sources :

Example 11 with ApplicationIdSelectorFactory

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

the class MeasurableIdSelectorFactory method mkViaAppSelector.

private Select<Record1<Long>> mkViaAppSelector(IdSelectionOptions options) {
    ApplicationIdSelectorFactory applicationIdSelectorFactory = new ApplicationIdSelectorFactory();
    Select<Record1<Long>> validAppIds = applicationIdSelectorFactory.apply(options);
    SelectConditionStep<Record1<Long>> measurableIds = DSL.selectDistinct(MEASURABLE_RATING.MEASURABLE_ID).from(MEASURABLE_RATING).where(MEASURABLE_RATING.ENTITY_ID.in(validAppIds));
    return DSL.selectDistinct(ENTITY_HIERARCHY.ANCESTOR_ID).from(ENTITY_HIERARCHY).where(ENTITY_HIERARCHY.KIND.eq(EntityKind.MEASURABLE.name())).and(ENTITY_HIERARCHY.ID.in(measurableIds));
}
Also used : ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory)

Example 12 with ApplicationIdSelectorFactory

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

the class ChangeReporter method main.

public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationIdSelectorFactory selectorFactory = new ApplicationIdSelectorFactory();
    LocalDateTime exerciseStart = LocalDateTime.of(2018, 06, 04, 0, 1).truncatedTo(ChronoUnit.DAYS);
    LocalDateTime dayBeforeYesterday = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(1);
    LocalDateTime yesterday = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
    // BCBS239
    EntityReference appGroupRef = EntityReference.mkRef(EntityKind.APP_GROUP, 10862);
    Select<Record1<Long>> appSelector = mkSelector(selectorFactory, appGroupRef);
    Tuple3<String, LocalDateTime, LocalDateTime> dayPeriod = Tuple.tuple("day", dayBeforeYesterday, yesterday);
    Tuple3<String, LocalDateTime, LocalDateTime> cumulativePeriod = Tuple.tuple("cumulative", exerciseStart, yesterday);
    dumpReport(dsl, dayPeriod, appGroupRef, appSelector);
    dumpReport(dsl, cumulativePeriod, appGroupRef, appSelector);
}
Also used : LocalDateTime(java.time.LocalDateTime) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) EntityReference(org.finos.waltz.model.EntityReference)

Example 13 with ApplicationIdSelectorFactory

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

the class ServerHarness method main.

public static void main(String[] args) {
    System.out.println("start");
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIBaseConfiguration.class);
    ServerInformationDao serverInfoDao = ctx.getBean(ServerInformationDao.class);
    IdSelectionOptions mOpts = mkOpts(mkRef(EntityKind.MEASURABLE, 1), HierarchyQueryScope.CHILDREN);
    IdSelectionOptions pOpts = mkOpts(mkRef(EntityKind.PERSON, 2), HierarchyQueryScope.CHILDREN);
    IdSelectionOptions ouOpts = mkOpts(mkRef(EntityKind.ORG_UNIT, 3), HierarchyQueryScope.CHILDREN);
    IdSelectionOptions agOpts = mkOpts(mkRef(EntityKind.APP_GROUP, 4), HierarchyQueryScope.EXACT);
    System.out.println("start timer");
    ListUtilities.asList(mOpts, pOpts, ouOpts, agOpts).forEach(opts -> {
        FunctionUtilities.time("stats: " + opts.entityReference(), () -> {
            Select<Record1<Long>> selector = new ApplicationIdSelectorFactory().apply(opts);
            return serverInfoDao.calculateStatsForAppSelector(selector);
        });
    });
    System.out.println("end");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ServerInformationDao(org.finos.waltz.data.server_information.ServerInformationDao) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) 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