Search in sources :

Example 1 with MeasurableIdSelectorFactory

use of org.finos.waltz.data.measurable.MeasurableIdSelectorFactory in project waltz by khartec.

the class MeasurableHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    MeasurableIdSelectorFactory factory = new MeasurableIdSelectorFactory();
    MeasurableService measurableService = ctx.getBean(MeasurableService.class);
    EntityReference ref = mkRef(EntityKind.PERSON, 172272);
    IdSelectionOptions options = mkOpts(ref, HierarchyQueryScope.CHILDREN);
    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(measurables.size());
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) OptionalUtilities(org.finos.waltz.common.OptionalUtilities) EntityKind(org.finos.waltz.model.EntityKind) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) DIConfiguration(org.finos.waltz.service.DIConfiguration) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) List(java.util.List) Measurable(org.finos.waltz.model.measurable.Measurable) Record1(org.jooq.Record1) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) EntityReference(org.finos.waltz.model.EntityReference) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) Select(org.jooq.Select) HierarchyQueryScope(org.finos.waltz.model.HierarchyQueryScope) Measurable(org.finos.waltz.model.measurable.Measurable) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) EntityReference(org.finos.waltz.model.EntityReference) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 2 with MeasurableIdSelectorFactory

use of org.finos.waltz.data.measurable.MeasurableIdSelectorFactory in project waltz by khartec.

the class MeasurableRatingHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    MeasurableRatingDao measurableRatingDao = ctx.getBean(MeasurableRatingDao.class);
    MeasurableIdSelectorFactory measurableIdSelectorFactory = new MeasurableIdSelectorFactory();
    EntityReference direct = mkRef(MEASURABLE, 18310);
    EntityReference indirect = mkRef(MEASURABLE, 18064);
    IdSelectionOptions directOpts = IdSelectionOptions.mkOpts(direct, CHILDREN);
    IdSelectionOptions indirectOpts = IdSelectionOptions.mkOpts(indirect, CHILDREN);
    Select<Record1<Long>> directSelector = measurableIdSelectorFactory.apply(directOpts);
    Select<Record1<Long>> indirectSelector = measurableIdSelectorFactory.apply(indirectOpts);
    List<MeasurableRatingTally> directTallies = measurableRatingDao.statsForRelatedMeasurable(directSelector);
    List<MeasurableRatingTally> indirectTallies = measurableRatingDao.statsForRelatedMeasurable(indirectSelector);
    List<Tally<Long>> tallies = measurableRatingDao.tallyByMeasurableCategoryId(1L);
    System.out.println(tallies);
}
Also used : Tally(org.finos.waltz.model.tally.Tally) MeasurableRatingTally(org.finos.waltz.model.tally.MeasurableRatingTally) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) MeasurableRatingDao(org.finos.waltz.data.measurable_rating.MeasurableRatingDao) EntityReference(org.finos.waltz.model.EntityReference) MeasurableRatingTally(org.finos.waltz.model.tally.MeasurableRatingTally) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 3 with MeasurableIdSelectorFactory

use of org.finos.waltz.data.measurable.MeasurableIdSelectorFactory in project waltz by khartec.

the class RemoveTaxonomy method main.

public static void main(String[] args) {
    final String categoryExtId = "FUNCTION_3_1";
    LOG.debug("Starting removal process for taxonomy {}", categoryExtId);
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ctx.getBean(DSLContext.class).transaction(tx -> {
        DSLContext dsl = DSL.using(tx);
        Long categoryId = dsl.select(MEASURABLE_CATEGORY.ID).from(MEASURABLE_CATEGORY).where(MEASURABLE_CATEGORY.EXTERNAL_ID.eq(categoryExtId)).fetchOne(MEASURABLE_CATEGORY.ID);
        if (categoryId == null) {
            LOG.error("Could not find taxonomy with external id: {}", categoryExtId);
            return;
        }
        MeasurableIdSelectorFactory selectorFactory = new MeasurableIdSelectorFactory();
        Select<Record1<Long>> measurableIdSelector = selectorFactory.apply(mkOpts(mkRef(EntityKind.MEASURABLE_CATEGORY, categoryId), HierarchyQueryScope.EXACT));
        removeAssociatedRatings(dsl, measurableIdSelector);
        removeBookmarks(dsl, measurableIdSelector);
        removeEntityRelationships(dsl, measurableIdSelector);
        removeFlowDiagramLinks(dsl, measurableIdSelector);
        removeEntitySvgDiagram(dsl, measurableIdSelector);
        removeInvolvements(dsl, measurableIdSelector);
        removeRatingScheme(dsl, categoryId);
        removeMeasurables(dsl, measurableIdSelector);
        removeCategory(dsl, categoryId);
        throw new IllegalArgumentException("Aborting, comment this line if you really mean to execute this removal");
    });
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) DSLContext(org.jooq.DSLContext) Record1(org.jooq.Record1)

Example 4 with MeasurableIdSelectorFactory

use of org.finos.waltz.data.measurable.MeasurableIdSelectorFactory in project waltz by khartec.

the class UnionHarness method measurableIdSelectorFactory_mkForFlowDiagram.

private static void measurableIdSelectorFactory_mkForFlowDiagram(ApplicationContext ctx) {
    Select<Record1<Long>> selector = new MeasurableIdSelectorFactory().apply(mkOpts(mkRef(EntityKind.FLOW_DIAGRAM, 12L)));
    List<Measurable> measurables = ctx.getBean(MeasurableDao.class).findByMeasurableIdSelector(selector);
    System.out.println(measurables.size());
}
Also used : Measurable(org.finos.waltz.model.measurable.Measurable) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) MeasurableDao(org.finos.waltz.data.measurable.MeasurableDao) Record1(org.jooq.Record1)

Aggregations

MeasurableIdSelectorFactory (org.finos.waltz.data.measurable.MeasurableIdSelectorFactory)4 Record1 (org.jooq.Record1)4 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 EntityReference (org.finos.waltz.model.EntityReference)2 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)2 Measurable (org.finos.waltz.model.measurable.Measurable)2 List (java.util.List)1 OptionalUtilities (org.finos.waltz.common.OptionalUtilities)1 MeasurableDao (org.finos.waltz.data.measurable.MeasurableDao)1 MeasurableRatingDao (org.finos.waltz.data.measurable_rating.MeasurableRatingDao)1 EntityKind (org.finos.waltz.model.EntityKind)1 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)1 HierarchyQueryScope (org.finos.waltz.model.HierarchyQueryScope)1 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)1 MeasurableRatingTally (org.finos.waltz.model.tally.MeasurableRatingTally)1 Tally (org.finos.waltz.model.tally.Tally)1 DIConfiguration (org.finos.waltz.service.DIConfiguration)1 MeasurableService (org.finos.waltz.service.measurable.MeasurableService)1 DSLContext (org.jooq.DSLContext)1 Select (org.jooq.Select)1