Search in sources :

Example 1 with LogicalFlowIdSelectorFactory

use of org.finos.waltz.data.logical_flow.LogicalFlowIdSelectorFactory 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)

Example 2 with LogicalFlowIdSelectorFactory

use of org.finos.waltz.data.logical_flow.LogicalFlowIdSelectorFactory in project waltz by khartec.

the class DataFlowHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    LogicalFlowService service = ctx.getBean(LogicalFlowService.class);
    LogicalFlowDao dao = ctx.getBean(LogicalFlowDao.class);
    LogicalFlowIdSelectorFactory factory = new LogicalFlowIdSelectorFactory();
    IdSelectionOptions options = IdSelectionOptions.mkOpts(EntityReference.mkRef(EntityKind.ORG_UNIT, 5000), HierarchyQueryScope.CHILDREN);
    Select<Record1<Long>> selector = factory.apply(options);
    System.out.println(selector);
    List<LogicalFlow> flows = dao.findBySelector(selector);
    flows.forEach(System.out::println);
    // by data type
    EntityReference dataType = EntityReference.mkRef(EntityKind.DATA_TYPE, 6000);
    IdSelectionOptions dataTypeOptions = IdSelectionOptions.mkOpts(dataType, HierarchyQueryScope.CHILDREN);
    List<LogicalFlow> byDataTypeFlows = service.findBySelector(dataTypeOptions);
    byDataTypeFlows.forEach(System.out::println);
    System.out.println(byDataTypeFlows.size());
}
Also used : LogicalFlowIdSelectorFactory(org.finos.waltz.data.logical_flow.LogicalFlowIdSelectorFactory) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Aggregations

LogicalFlowIdSelectorFactory (org.finos.waltz.data.logical_flow.LogicalFlowIdSelectorFactory)2 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)1 EntityReference (org.finos.waltz.model.EntityReference)1 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)1 Application (org.finos.waltz.schema.tables.Application)1 OrganisationalUnit (org.finos.waltz.schema.tables.OrganisationalUnit)1 LogicalFlowService (org.finos.waltz.service.logical_flow.LogicalFlowService)1 DSLContext (org.jooq.DSLContext)1 Record1 (org.jooq.Record1)1