Search in sources :

Example 6 with IdSelectionOptions

use of com.khartec.waltz.model.IdSelectionOptions in project waltz by khartec.

the class AuthoritativeSourceEndpoint method calculateConsumersForDataTypeIdSelectorRoute.

private List<Entry<EntityReference, Collection<EntityReference>>> calculateConsumersForDataTypeIdSelectorRoute(Request request, Response response) throws IOException {
    IdSelectionOptions options = readIdSelectionOptionsFromBody(request);
    Map<EntityReference, Collection<EntityReference>> result = authoritativeSourceService.calculateConsumersForDataTypeIdSelector(options);
    return simplifyMapToList(result);
}
Also used : EntityReference(com.khartec.waltz.model.EntityReference) Collection(java.util.Collection) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions)

Example 7 with IdSelectionOptions

use of com.khartec.waltz.model.IdSelectionOptions in project waltz by khartec.

the class LogicalFlowExtractor method register.

@Override
public void register() {
    post(mkPath("data-extract", "logical-flows"), (request, response) -> {
        IdSelectionOptions options = readIdSelectionOptionsFromBody(request);
        CSVSerializer serializer = extract(options);
        return writeFile("logical-flows.csv", serializer, response);
    });
}
Also used : IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions)

Example 8 with IdSelectionOptions

use of com.khartec.waltz.model.IdSelectionOptions in project waltz by khartec.

the class AuthSourceRatingCalculator method update.

private int[] update(DataType dataType, EntityReference vantageRef) {
    LOG.info("Updating ratings for auth source - dataType: {}, vantage point: {}", dataType, vantageRef);
    IdSelectionOptions selectorOptions = mkOpts(vantageRef, HierarchyQueryScope.CHILDREN);
    Select<Record1<Long>> selector = appIdSelectorFactory.apply(selectorOptions);
    Collection<LogicalFlowDecorator> impactedDecorators = logicalFlowDecoratorDao.findByEntityIdSelectorAndKind(EntityKind.APPLICATION, selector, EntityKind.DATA_TYPE).stream().filter(decorator -> decorator.decoratorEntity().id() == dataType.id().get()).collect(toList());
    Collection<LogicalFlowDecorator> reRatedDecorators = ratingsCalculator.calculate(impactedDecorators);
    Set<LogicalFlowDecorator> modifiedDecorators = SetUtilities.minus(fromCollection(reRatedDecorators), fromCollection(impactedDecorators));
    LOG.info("Need to update {} ratings due to auth source change - dataType: {}, parent: {}", modifiedDecorators.size(), dataType, vantageRef);
    return updateDecorators(modifiedDecorators);
}
Also used : Logger(org.slf4j.Logger) SetUtilities.fromCollection(com.khartec.waltz.common.SetUtilities.fromCollection) SetUtilities(com.khartec.waltz.common.SetUtilities) ApplicationIdSelectorFactory(com.khartec.waltz.data.application.ApplicationIdSelectorFactory) LogicalFlowDecoratorDao(com.khartec.waltz.data.data_flow_decorator.LogicalFlowDecoratorDao) Checks.checkNotNull(com.khartec.waltz.common.Checks.checkNotNull) LogicalFlowDecoratorRatingsCalculator(com.khartec.waltz.service.data_flow_decorator.LogicalFlowDecoratorRatingsCalculator) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) HierarchyQueryScope(com.khartec.waltz.model.HierarchyQueryScope) Autowired(org.springframework.beans.factory.annotation.Autowired) Set(java.util.Set) EntityReference(com.khartec.waltz.model.EntityReference) EntityKind(com.khartec.waltz.model.EntityKind) DataTypeDao(com.khartec.waltz.data.data_type.DataTypeDao) LogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator) Collectors.toList(java.util.stream.Collectors.toList) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) DataType(com.khartec.waltz.model.datatype.DataType) IdSelectionOptions.mkOpts(com.khartec.waltz.model.IdSelectionOptions.mkOpts) Select(org.jooq.Select) LogicalFlowDecorator(com.khartec.waltz.model.data_flow_decorator.LogicalFlowDecorator) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 9 with IdSelectionOptions

use of com.khartec.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 = ctx.getBean(LogicalFlowIdSelectorFactory.class);
    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.IS_REMOVED.isFalse()).fetch();
    System.out.printf("got records: %s", fetch.size());
}
Also used : LogicalFlowIdSelectorFactory(com.khartec.waltz.data.logical_flow.LogicalFlowIdSelectorFactory) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) OrganisationalUnit(com.khartec.waltz.schema.tables.OrganisationalUnit) Application(com.khartec.waltz.schema.tables.Application) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions)

Example 10 with IdSelectionOptions

use of com.khartec.waltz.model.IdSelectionOptions 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 = ctx.getBean(LogicalFlowIdSelectorFactory.class);
    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(com.khartec.waltz.data.logical_flow.LogicalFlowIdSelectorFactory) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) LogicalFlowService(com.khartec.waltz.service.logical_flow.LogicalFlowService) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) EntityReference(com.khartec.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) LogicalFlowDao(com.khartec.waltz.data.logical_flow.LogicalFlowDao) IdSelectionOptions(com.khartec.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Aggregations

IdSelectionOptions (com.khartec.waltz.model.IdSelectionOptions)12 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)6 Record1 (org.jooq.Record1)5 EntityReference (com.khartec.waltz.model.EntityReference)4 DSLContext (org.jooq.DSLContext)4 ApplicationIdSelectorFactory (com.khartec.waltz.data.application.ApplicationIdSelectorFactory)3 LogicalFlowDao (com.khartec.waltz.data.logical_flow.LogicalFlowDao)2 LogicalFlowIdSelectorFactory (com.khartec.waltz.data.logical_flow.LogicalFlowIdSelectorFactory)2 EntityKind (com.khartec.waltz.model.EntityKind)2 HierarchyQueryScope (com.khartec.waltz.model.HierarchyQueryScope)2 IdSelectionOptions.mkOpts (com.khartec.waltz.model.IdSelectionOptions.mkOpts)2 RollupKind (com.khartec.waltz.model.entity_statistic.RollupKind)2 LogicalFlow (com.khartec.waltz.model.logical_flow.LogicalFlow)2 LogicalFlowService (com.khartec.waltz.service.logical_flow.LogicalFlowService)2 Collection (java.util.Collection)2 Select (org.jooq.Select)2 Checks.checkNotNull (com.khartec.waltz.common.Checks.checkNotNull)1 OptionalUtilities (com.khartec.waltz.common.OptionalUtilities)1 SetUtilities (com.khartec.waltz.common.SetUtilities)1 SetUtilities.fromCollection (com.khartec.waltz.common.SetUtilities.fromCollection)1