Search in sources :

Example 1 with MeasurableService

use of org.finos.waltz.service.measurable.MeasurableService 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 MeasurableService

use of org.finos.waltz.service.measurable.MeasurableService in project waltz by khartec.

the class AllocationHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    AllocationSchemeService schemesService = ctx.getBean(AllocationSchemeService.class);
    MeasurableService measurableService = ctx.getBean(MeasurableService.class);
    MeasurableCategoryDao categoryDao = ctx.getBean(MeasurableCategoryDao.class);
    MeasurableRatingService ratingService = ctx.getBean(MeasurableRatingService.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    Tuple4<Application, MeasurableCategory, List<Measurable>, AllocationScheme> stuff = setup(dsl, schemesService, measurableService, categoryDao, applicationService);
    addRating(ratingService, stuff, 0);
    addRating(ratingService, stuff, 1);
    // addRating(ratingService, stuff, 2);
    // addAllocation(dsl, stuff, 0, 50);
    addAllocation(dsl, stuff, 1, 20);
    Long measurableCategory = stuff.v2.id().get();
    dumpRatings(dsl, stuff.v4);
    dumpAllocs(dsl, stuff.v4);
    doDiff(dsl, measurableCategory);
    System.out.println(ratingService.findByCategory(measurableCategory));
}
Also used : MeasurableRatingService(org.finos.waltz.service.measurable_rating.MeasurableRatingService) ImmutableAllocationScheme(org.finos.waltz.model.allocation_scheme.ImmutableAllocationScheme) AllocationScheme(org.finos.waltz.model.allocation_scheme.AllocationScheme) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) MeasurableCategoryDao(org.finos.waltz.data.measurable_category.MeasurableCategoryDao) AllocationSchemeService(org.finos.waltz.service.allocation_schemes.AllocationSchemeService) MeasurableCategory(org.finos.waltz.model.measurable_category.MeasurableCategory) List(java.util.List) ApplicationService(org.finos.waltz.service.application.ApplicationService)

Aggregations

List (java.util.List)2 MeasurableService (org.finos.waltz.service.measurable.MeasurableService)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 OptionalUtilities (org.finos.waltz.common.OptionalUtilities)1 MeasurableIdSelectorFactory (org.finos.waltz.data.measurable.MeasurableIdSelectorFactory)1 MeasurableCategoryDao (org.finos.waltz.data.measurable_category.MeasurableCategoryDao)1 EntityKind (org.finos.waltz.model.EntityKind)1 EntityReference (org.finos.waltz.model.EntityReference)1 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)1 HierarchyQueryScope (org.finos.waltz.model.HierarchyQueryScope)1 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)1 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)1 AllocationScheme (org.finos.waltz.model.allocation_scheme.AllocationScheme)1 ImmutableAllocationScheme (org.finos.waltz.model.allocation_scheme.ImmutableAllocationScheme)1 Measurable (org.finos.waltz.model.measurable.Measurable)1 MeasurableCategory (org.finos.waltz.model.measurable_category.MeasurableCategory)1 DIConfiguration (org.finos.waltz.service.DIConfiguration)1 AllocationSchemeService (org.finos.waltz.service.allocation_schemes.AllocationSchemeService)1 ApplicationService (org.finos.waltz.service.application.ApplicationService)1 MeasurableRatingService (org.finos.waltz.service.measurable_rating.MeasurableRatingService)1