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));
}
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);
});
}
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);
});
}
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);
});
}
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));
});
}
Aggregations