Search in sources :

Example 1 with IdSelectionOptions

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

the class DataTypeDecoratorServiceTest method findByEntityIdSelector.

@Test
public void findByEntityIdSelector() {
    String username = mkName("findByEntityIdSelector");
    EntityReference a = appHelper.createNewApp("a", ouIds.a);
    EntityReference b = appHelper.createNewApp("b", ouIds.a1);
    IdSelectionOptions appOpts = mkOpts(a);
    assertThrows(IllegalArgumentException.class, () -> dtdSvc.findByEntityIdSelector(EntityKind.APPLICATION, appOpts), "If not logical flow kind or physical spec kind should throw exception");
    List<DataTypeDecorator> selectorForLfWhereNoDecorators = dtdSvc.findByEntityIdSelector(EntityKind.LOGICAL_DATA_FLOW, appOpts);
    assertEquals(emptyList(), selectorForLfWhereNoDecorators, "If no flows and decorators for selector returns empty list");
    LogicalFlow flow = lfHelper.createLogicalFlow(a, b);
    Long dtId = dataTypeHelper.createDataType("findByEntityIdSelector");
    Long dtId2 = dataTypeHelper.createDataType("findByEntityIdSelector2");
    dtdSvc.updateDecorators(username, flow.entityReference(), asSet(dtId, dtId2), emptySet());
    List<DataTypeDecorator> selectorWithDecorators = dtdSvc.findByEntityIdSelector(EntityKind.LOGICAL_DATA_FLOW, appOpts);
    assertEquals(asSet(dtId, dtId2), map(selectorWithDecorators, DataTypeDecorator::dataTypeId), "Returns all data types for flow selector");
    IdSelectionOptions flowOpts = mkOpts(flow.entityReference());
    List<DataTypeDecorator> selectorForPsWhereNoDecorators = dtdSvc.findByEntityIdSelector(EntityKind.PHYSICAL_SPECIFICATION, flowOpts);
    assertEquals(emptyList(), selectorForPsWhereNoDecorators, "If no flows and decorators for selector returns empty list");
    Long psId = psHelper.createPhysicalSpec(a, "findByEntityIdSelector");
    EntityReference specRef = mkRef(EntityKind.PHYSICAL_SPECIFICATION, psId);
    pfHelper.createPhysicalFlow(flow.entityReference().id(), psId, "findByEntityIdSelector");
    dtdSvc.updateDecorators(username, specRef, asSet(dtId, dtId2), emptySet());
    List<DataTypeDecorator> selectorForPs = dtdSvc.findByEntityIdSelector(EntityKind.PHYSICAL_SPECIFICATION, flowOpts);
    assertEquals(asSet(dtId, dtId2), map(selectorForPs, DataTypeDecorator::dataTypeId), "Returns all data types for spec selector");
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) 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 2 with IdSelectionOptions

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

the class FacetService method getApplicationKindTallies.

public List<Tally<String>> getApplicationKindTallies(IdSelectionOptions options) {
    // we don't want the facets to apply and filter out non selected kinds, so we default to all kinds
    IdSelectionOptions appOptions = mkOpts(options.entityReference(), options.scope());
    Select<Record1<Long>> appSelector = applicationIdSelectorFactory.apply(appOptions);
    return applicationDao.countByApplicationKind(appSelector);
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 3 with IdSelectionOptions

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

the class DiagramToDotExport method main.

public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    FlowDiagramService flowDiagramService = ctx.getBean(FlowDiagramService.class);
    FlowDiagramEntityService flowDiagramEntityService = ctx.getBean(FlowDiagramEntityService.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    LogicalFlowService logicalFlowService = ctx.getBean(LogicalFlowService.class);
    EntityReference diagRef = mkRef(EntityKind.FLOW_DIAGRAM, 1L);
    IdSelectionOptions options = IdSelectionOptions.mkOpts(diagRef, HierarchyQueryScope.EXACT);
    List<Application> apps = applicationService.findByAppIdSelector(options);
    List<LogicalFlow> flows = logicalFlowService.findBySelector(options);
    Map<Long, Application> appsById = indexBy(a -> a.id().get(), apps);
    System.out.println("------");
    String digraph = String.format("digraph G { %s %s}", renderApplications(apps), renderFlows(flows, appsById));
    System.out.println(digraph);
    System.out.println("-----");
/*
        digraph G {
            "Welcome" -> "To"
            "To" -> "Web"
            "To" -> "GraphViz!"
        }
        */
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) FlowDiagramEntityService(org.finos.waltz.service.flow_diagram.FlowDiagramEntityService) FlowDiagramService(org.finos.waltz.service.flow_diagram.FlowDiagramService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) Application(org.finos.waltz.model.application.Application) ApplicationService(org.finos.waltz.service.application.ApplicationService) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 4 with IdSelectionOptions

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

the class ChangeLogSummariesHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ChangeLogService svc = ctx.getBean(ChangeLogService.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    if (false) {
        // enable this if you want to randomize your changelog dates (i.e. for testing)
        dsl.update(CHANGE_LOG).set(CHANGE_LOG.CREATED_AT, DSL.timestampSub(DSL.now(), CHANGE_LOG.ID.plus(CHANGE_LOG.PARENT_ID).mod(360), DatePart.DAY)).execute();
    }
    IdSelectionOptions opts = mkOpts(mkRef(EntityKind.ORG_UNIT, 20), HierarchyQueryScope.CHILDREN);
    List<DateTally> res = time("findCountByDateForParentKindBySelector", () -> svc.findCountByDateForParentKindBySelector(EntityKind.APPLICATION, opts, Optional.empty()));
    System.out.println(res);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DateTally(org.finos.waltz.model.tally.DateTally) ChangeLogService(org.finos.waltz.service.changelog.ChangeLogService) DSLContext(org.jooq.DSLContext) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 5 with IdSelectionOptions

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

the class DataExtractHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    LogicalFlowIdSelectorFactory logicalFlowIdSelectorFactory = new LogicalFlowIdSelectorFactory();
    IdSelectionOptions options = IdSelectionOptions.mkOpts(EntityReference.mkRef(EntityKind.ORG_UNIT, 4326), HierarchyQueryScope.CHILDREN);
    Select<Record1<Long>> flowIdSelector = logicalFlowIdSelectorFactory.apply(options);
    Application sourceApp = APPLICATION.as("sourceApp");
    Application targetApp = APPLICATION.as("targetApp");
    OrganisationalUnit sourceOrgUnit = ORGANISATIONAL_UNIT.as("sourceOrgUnit");
    OrganisationalUnit targetOrgUnit = ORGANISATIONAL_UNIT.as("targetOrgUnit");
    Result<Record> fetch = dsl.select(LOGICAL_FLOW.fields()).select(SOURCE_NAME_FIELD, TARGET_NAME_FIELD).select(sourceApp.fields()).select(targetApp.fields()).select(sourceOrgUnit.fields()).select(targetOrgUnit.fields()).select(LOGICAL_FLOW_DECORATOR.fields()).from(LOGICAL_FLOW).leftJoin(sourceApp).on(LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(sourceApp.ID).and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))).leftJoin(targetApp).on(LOGICAL_FLOW.TARGET_ENTITY_ID.eq(targetApp.ID).and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))).leftJoin(sourceOrgUnit).on(sourceApp.ORGANISATIONAL_UNIT_ID.eq(sourceOrgUnit.ID)).leftJoin(targetOrgUnit).on(targetApp.ORGANISATIONAL_UNIT_ID.eq(targetOrgUnit.ID)).join(LOGICAL_FLOW_DECORATOR).on(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID.eq(LOGICAL_FLOW.ID).and(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_KIND.eq("DATA_TYPE"))).where(LOGICAL_FLOW.ID.in(flowIdSelector)).and(LOGICAL_FLOW.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name())).fetch();
    System.out.printf("got records: %s", fetch.size());
}
Also used : LogicalFlowIdSelectorFactory(org.finos.waltz.data.logical_flow.LogicalFlowIdSelectorFactory) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) OrganisationalUnit(org.finos.waltz.schema.tables.OrganisationalUnit) Application(org.finos.waltz.schema.tables.Application) 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