Search in sources :

Example 31 with IdSelectionOptions

use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.

the class ReportGridService method getByIdAndSelectionOptions.

public ReportGrid getByIdAndSelectionOptions(long id, IdSelectionOptions idSelectionOptions) {
    // WARNING:  The grid computation is very slow if given a large person tree.
    // Therefore we restrict it to EXACT only behaviour.
    // If you are changing this please ensure you have tested with realistic test data.
    IdSelectionOptions opts = idSelectionOptions.entityReference().kind() == EntityKind.PERSON ? ImmutableIdSelectionOptions.copyOf(idSelectionOptions).withScope(HierarchyQueryScope.EXACT) : idSelectionOptions;
    ReportGridDefinition definition = reportGridDao.getGridDefinitionById(id);
    if (definition == null) {
        return null;
    }
    ReportGridInstance instance = mkInstance(id, opts);
    return ImmutableReportGrid.builder().definition(definition).instance(instance).build();
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) ImmutableIdSelectionOptions(org.finos.waltz.model.ImmutableIdSelectionOptions)

Example 32 with IdSelectionOptions

use of org.finos.waltz.model.IdSelectionOptions 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)

Example 33 with IdSelectionOptions

use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.

the class BookmarkServiceTest method bookmarksCanBeRemovedBySelector.

@Test
public void bookmarksCanBeRemovedBySelector() {
    EntityReference appRef1 = mkAppRef();
    EntityReference appRef2 = mkAppRef();
    IdSelectionOptions a1_opts = mkOpts(appRef1, HierarchyQueryScope.EXACT);
    IdSelectionOptions a2_opts = mkOpts(appRef2, HierarchyQueryScope.EXACT);
    createBookmark(appRef1, "a");
    createBookmark(appRef1, "b");
    createBookmark(appRef2, "c");
    int numRemoved = svc.deleteByBookmarkIdSelector(a1_opts);
    assertEquals(2, numRemoved, "both app1 bookmarks should have been removed");
    assertEquals(emptySet(), svc.findByBookmarkIdSelector(a1_opts), "no app1 bookmarks should be left");
    assertEquals(1, svc.findByBookmarkIdSelector(a2_opts).size(), "the app2 bookmark should remain");
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 34 with IdSelectionOptions

use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.

the class FlowClassificationCalculator method update.

private int[] update(DataType dataType, EntityReference vantageRef) {
    LOG.debug("Updating ratings for flow classification rule - dataType name: {}, id: {}, vantage point: {}", dataType.name(), dataType.id().get(), vantageRef);
    IdSelectionOptions selectorOptions = mkOpts(vantageRef);
    Select<Record1<Long>> selector = appIdSelectorFactory.apply(selectorOptions);
    Set<Long> dataTypeDescendents = entityHierarchyDao.findDesendents(dataType.entityReference()).stream().map(d -> d.id().get()).collect(Collectors.toSet());
    Collection<DataTypeDecorator> impactedDecorators = logicalFlowDecoratorDao.findByEntityIdSelector(selector, Optional.of(EntityKind.APPLICATION)).stream().filter(decorator -> dataTypeDescendents.contains(decorator.decoratorEntity().id())).collect(toList());
    Collection<DataTypeDecorator> reRatedDecorators = ratingsCalculator.calculate(impactedDecorators);
    Set<DataTypeDecorator> modifiedDecorators = SetUtilities.minus(fromCollection(reRatedDecorators), fromCollection(impactedDecorators));
    LOG.debug("Need to update {} ratings due to auth source change - dataType name: {}, id: {}, parent: {}", modifiedDecorators.size(), dataType.name(), dataType.id().get(), vantageRef);
    return updateDecorators(modifiedDecorators);
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) EntityKind(org.finos.waltz.model.EntityKind) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) DataType(org.finos.waltz.model.datatype.DataType) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) LogicalFlowDecoratorRatingsCalculator(org.finos.waltz.service.data_flow_decorator.LogicalFlowDecoratorRatingsCalculator) EntityHierarchyDao(org.finos.waltz.data.entity_hierarchy.EntityHierarchyDao) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) Select(org.jooq.Select) Logger(org.slf4j.Logger) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Collection(java.util.Collection) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) Set(java.util.Set) Collectors(java.util.stream.Collectors) Collectors.toList(java.util.stream.Collectors.toList) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) LogicalFlowDecoratorDao(org.finos.waltz.data.datatype_decorator.LogicalFlowDecoratorDao) SetUtilities(org.finos.waltz.common.SetUtilities) EntityReference(org.finos.waltz.model.EntityReference) Optional(java.util.Optional) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) SetUtilities.fromCollection(org.finos.waltz.common.SetUtilities.fromCollection) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 35 with IdSelectionOptions

use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.

the class EntityStatisticEndpoint method calculateStatTallyRoute.

private TallyPack<String> calculateStatTallyRoute(Request request, Response response) throws IOException {
    IdSelectionOptions idSelectionOptions = WebUtilities.readIdSelectionOptionsFromBody(request);
    RollupKind rollupKind = extractRollupKind(request);
    Long statisticId = WebUtilities.getId(request);
    return entityStatisticService.calculateStatTally(statisticId, rollupKind, idSelectionOptions);
}
Also used : RollupKind(org.finos.waltz.model.entity_statistic.RollupKind) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Aggregations

IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)39 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)15 EntityReference (org.finos.waltz.model.EntityReference)14 Record1 (org.jooq.Record1)9 DSLContext (org.jooq.DSLContext)8 EntityKind (org.finos.waltz.model.EntityKind)7 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)6 ApplicationIdSelectorFactory (org.finos.waltz.data.application.ApplicationIdSelectorFactory)5 LogicalFlowService (org.finos.waltz.service.logical_flow.LogicalFlowService)5 Collection (java.util.Collection)4 List (java.util.List)4 GenericSelector (org.finos.waltz.data.GenericSelector)4 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)4 Set (java.util.Set)3 MeasurableIdSelectorFactory (org.finos.waltz.data.measurable.MeasurableIdSelectorFactory)3 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)3 Collections.emptySet (java.util.Collections.emptySet)2 Collectors (java.util.stream.Collectors)2 Collectors.toList (java.util.stream.Collectors.toList)2 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)2