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();
}
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");
}
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");
}
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);
}
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);
}
Aggregations