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