Search in sources :

Example 26 with IdSelectionOptions

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

the class AssetCostHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    CostService svc = ctx.getBean(CostService.class);
    IdSelectionOptions bill = mkOpts(mkRef(EntityKind.PERSON, 1234));
    IdSelectionOptions jennifer = mkOpts(mkRef(EntityKind.PERSON, 5678));
    IdSelectionOptions scott = mkOpts(mkRef(EntityKind.PERSON, 9876));
    IdSelectionOptions infra = mkOpts(mkRef(EntityKind.ORG_UNIT, 1234));
    long tco = 6L;
    long cirrus = 7L;
    // time("tco cost summary for infra", () -> svc.summariseByCostKindAndSelector(tco, infra, EntityKind.APPLICATION, 20));
    // time("cirrus cost summary for infra", () -> svc.summariseByCostKindAndSelector(cirrus, infra, EntityKind.APPLICATION, 20));
    // //        time("cost summary for bill", () -> svc.summariseByCostKindAndSelector(tco, bill, EntityKind.APPLICATION, 20));
    // time("tco cost summary for scott", () -> svc.summariseByCostKindAndSelector(tco, scott, EntityKind.APPLICATION, 20));
    time("cirrus cost summary for jennifer", () -> svc.summariseByCostKindAndSelector(cirrus, jennifer, EntityKind.APPLICATION, 20));
    time("cirrus cost summary for bill", () -> svc.summariseByCostKindAndSelector(cirrus, bill, EntityKind.APPLICATION, 20));
    time("cirrus cost summary for scott", () -> svc.summariseByCostKindAndSelector(cirrus, scott, EntityKind.APPLICATION, 20));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) CostService(org.finos.waltz.service.cost.CostService) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 27 with IdSelectionOptions

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

the class ApplicationExtractor method register.

@Override
public void register() {
    post(WebUtilities.mkPath("data-extract", "application", "by-selector"), (request, response) -> {
        IdSelectionOptions idSelectionOptions = WebUtilities.readIdSelectionOptionsFromBody(request);
        Select<Record1<Long>> idSelector = applicationIdSelectorFactory.apply(idSelectionOptions);
        Condition condition = Application.APPLICATION.ID.in(idSelector).and(SelectorUtilities.mkApplicationConditions(idSelectionOptions));
        SelectConditionStep<?> qry = prepareExtractQuery(condition);
        String fileName = String.format("application-for-%s-%s", idSelectionOptions.entityReference().kind().name().toLowerCase(), idSelectionOptions.entityReference().id());
        LOG.debug("extracted applications for entity ref {}", idSelectionOptions.entityReference());
        return writeExtract(fileName, qry, request, response);
    });
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 28 with IdSelectionOptions

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

the class ComplexityExtractor method register.

@Override
public void register() {
    String findBySelectorPath = WebUtilities.mkPath("data-extract", "complexity", "target-kind", ":kind", "selector");
    post(findBySelectorPath, (request, response) -> {
        IdSelectionOptions idSelectionOptions = WebUtilities.readIdSelectionOptionsFromBody(request);
        EntityKind targetKind = WebUtilities.getKind(request);
        GenericSelector genericSelector = genericSelectorFactory.applyForKind(targetKind, idSelectionOptions);
        SelectConditionStep<Record> qry = dsl.select(ENTITY_NAME_FIELD.as("Entity Name")).select(COMPLEXITY.ENTITY_ID).select(COMPLEXITY_KIND.NAME.as("Complexity Kind")).select(COMPLEXITY.SCORE.as("Score")).select(COMPLEXITY.PROVENANCE).from(COMPLEXITY).innerJoin(COMPLEXITY_KIND).on(COMPLEXITY.COMPLEXITY_KIND_ID.eq(COMPLEXITY_KIND.ID)).where(COMPLEXITY.ENTITY_ID.in(genericSelector.selector()).and(COMPLEXITY.ENTITY_KIND.eq(genericSelector.kind().name())));
        return writeExtract(mkFilename(idSelectionOptions), qry, request, response);
    });
}
Also used : GenericSelector(org.finos.waltz.data.GenericSelector) Record(org.jooq.Record) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) EntityKind(org.finos.waltz.model.EntityKind)

Example 29 with IdSelectionOptions

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

the class PeopleExtractor method registerExtractForApp.

private void registerExtractForApp(String path) {
    post(path, (request, response) -> {
        EntityReference entityRef = WebUtilities.getEntityReference(request);
        IdSelectionOptions selectionOptions = mkOpts(entityRef, HierarchyQueryScope.determineUpwardsScopeForKind(entityRef.kind()));
        GenericSelector selector = genericSelectorFactory.apply(selectionOptions);
        SelectSeekStep1<Record5<String, String, String, String, String>, String> qry = dsl.select(PERSON.DISPLAY_NAME.as("Name"), PERSON.TITLE.as("Title"), PERSON.OFFICE_PHONE.as("Telephone"), PERSON.EMAIL.as("Email"), INVOLVEMENT_KIND.NAME.as("Role")).from(PERSON).innerJoin(INVOLVEMENT).on(INVOLVEMENT.EMPLOYEE_ID.eq(PERSON.EMPLOYEE_ID)).innerJoin(INVOLVEMENT_KIND).on(INVOLVEMENT_KIND.ID.eq(INVOLVEMENT.KIND_ID)).where(INVOLVEMENT.ENTITY_ID.in(selector.selector()).and(INVOLVEMENT.ENTITY_KIND.eq(selector.kind().name()))).orderBy(PERSON.DISPLAY_NAME);
        return writeExtract("involved_people", qry, request, response);
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) WebUtilities.getEntityReference(org.finos.waltz.web.WebUtilities.getEntityReference) GenericSelector(org.finos.waltz.data.GenericSelector) Record5(org.jooq.Record5) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 30 with IdSelectionOptions

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

the class PhysicalFlowExtractor method register.

@Override
public void register() {
    post(WebUtilities.mkPath("data-extract", "physical-flows", "all", ":kind", ":id"), (request, response) -> {
        EntityReference ref = WebUtilities.getEntityReference(request);
        String fileName = "physical-flows-all-" + ref.id();
        return writeReportResults(response, preparePhysicalFlows(prepareAllFlowsQuery(ref), parseExtractFormat(request), fileName, getTagsMap()));
    });
    post(WebUtilities.mkPath("data-extract", "physical-flows", "produces", ":kind", ":id"), (request, response) -> {
        EntityReference ref = WebUtilities.getEntityReference(request);
        String fileName = "physical-flows-produces-" + ref.id();
        return writeReportResults(response, preparePhysicalFlows(prepareProducesQuery(ref), parseExtractFormat(request), fileName, getTagsMap()));
    });
    post(WebUtilities.mkPath("data-extract", "physical-flows", "consumes", ":kind", ":id"), (request, response) -> {
        EntityReference ref = WebUtilities.getEntityReference(request);
        String fileName = "physical-flows-consumes-" + ref.id();
        SelectConditionStep<Record> qry = prepareConsumesQuery(ref);
        Map<Long, List<String>> tags = getTagsMap();
        return writeReportResults(response, preparePhysicalFlows(qry, parseExtractFormat(request), fileName, tags));
    });
    post(WebUtilities.mkPath("data-extract", "physical-flows", "by-selector"), (request, response) -> {
        IdSelectionOptions idSelectionOptions = WebUtilities.readIdSelectionOptionsFromBody(request);
        Select<Record1<Long>> idSelector = physicalFlowIdSelectorFactory.apply(idSelectionOptions);
        Condition condition = PhysicalFlow.PHYSICAL_FLOW.ID.in(idSelector).and(physicalFlowIdSelectorFactory.getLifecycleCondition(idSelectionOptions));
        SelectConditionStep<Record> qry = getQuery(condition);
        Map<Long, List<String>> tags = getTagsMap();
        String fileName = String.format("physical-flows-for-%s-%s", idSelectionOptions.entityReference().kind().name().toLowerCase(), idSelectionOptions.entityReference().id());
        return writeReportResults(response, preparePhysicalFlows(qry, parseExtractFormat(request), fileName, tags));
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) 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