use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class FlowClassificationRuleEndpoint method calculateConsumersForDataTypeIdSelectorRoute.
private List<Entry<EntityReference, Collection<EntityReference>>> calculateConsumersForDataTypeIdSelectorRoute(Request request, Response response) throws IOException {
IdSelectionOptions options = WebUtilities.readIdSelectionOptionsFromBody(request);
Map<EntityReference, Collection<EntityReference>> result = flowClassificationRuleService.calculateConsumersForDataTypeIdSelector(options);
return WebUtilities.simplifyMapToList(result);
}
use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class DataTypeUsageEndpoint method findForUsageKindByDataTypeSelectorRoute.
private Map<Long, Collection<EntityReference>> findForUsageKindByDataTypeSelectorRoute(Request request, Response response) throws IOException {
IdSelectionOptions options = WebUtilities.readIdSelectionOptionsFromBody(request);
UsageKind usageKind = WebUtilities.readEnum(request, "usage-kind", UsageKind.class, s -> UsageKind.ORIGINATOR);
return dataTypeUsageService.findForUsageKindByDataTypeIdSelector(usageKind, options);
}
use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class EntityCostExtractor method registerCostsForSelector.
private void registerCostsForSelector(String costsForSelectorPath) {
post(costsForSelectorPath, (request, response) -> {
IdSelectionOptions idSelectionOptions = WebUtilities.readIdSelectionOptionsFromBody(request);
EntityKind targetKind = WebUtilities.getKind(request);
GenericSelector genericSelector = genericSelectorFactory.applyForKind(targetKind, idSelectionOptions);
SelectJoinStep<Record1<Integer>> latestYear = DSL.select(DSL.max(COST.YEAR)).from(COST);
SelectSeekStep2<Record, String, Long> qry = dsl.select(COST.ENTITY_ID.as("Entity ID"), COST.ENTITY_KIND.as("Entity Kind")).select(ENTITY_NAME_FIELD.as("Name")).select(COST_KIND.NAME.as("Kind"), COST_KIND.DESCRIPTION.as("Kind Description")).select(COST.YEAR.as("Year"), COST.AMOUNT.as("Amount"), COST.PROVENANCE.as("Provenance")).from(COST).innerJoin(COST_KIND).on(COST.COST_KIND_ID.eq(COST_KIND.ID)).where(COST.ENTITY_ID.in(genericSelector.selector()).and(COST.ENTITY_KIND.eq(genericSelector.kind().name()))).and(COST.YEAR.eq(latestYear)).orderBy(ENTITY_NAME_FIELD.as("Name"), COST.COST_KIND_ID);
return writeExtract(mkFilename(idSelectionOptions.entityReference()), qry, request, response);
});
}
use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class MeasurableRatingExtractor method registerAllocations.
private void registerAllocations(String path) {
post(path, (request, response) -> {
long categoryId = WebUtilities.getId(request);
IdSelectionOptions selectionOpts = WebUtilities.readIdSelectionOptionsFromBody(request);
Select<Record1<Long>> appSelector = applicationIdSelectorFactory.apply(selectionOpts);
SelectSelectStep<Record> reportColumns = dsl.select(m.NAME.as("Taxonomy Item Name"), m.EXTERNAL_ID.as("Taxonomy Item Code")).select(app.NAME.as("App Name"), app.ASSET_CODE.as("App Code"), app.ID.as("App Waltz Id"), app.KIND.as("App Kind")).select(rsi.NAME.as("Rating Name"), rsi.CODE.as("Rating Code")).select(mr.DESCRIPTION.as("Rating Description"), mr.LAST_UPDATED_AT.as("Last Updated Time"), mr.LAST_UPDATED_BY.as("Last Updated By")).select(mrd.PLANNED_DECOMMISSION_DATE.as("Planned Decommission Date")).select(replacementAppName.as("Replacement App Name"), replacementAppExtId.as("Replacement External Id"), mrr.PLANNED_COMMISSION_DATE.as("Replacement Commission Date")).select(ou.NAME.as("Org Unit Name"));
Condition reportConditions = app.ENTITY_LIFECYCLE_STATUS.eq(EntityLifecycleStatus.ACTIVE.name()).and(m.MEASURABLE_CATEGORY_ID.eq(categoryId)).and(m.ENTITY_LIFECYCLE_STATUS.ne(EntityLifecycleStatus.REMOVED.name())).and(mr.ENTITY_KIND.eq(EntityKind.APPLICATION.name())).and(mr.ENTITY_ID.in(appSelector)).and(rsi.CODE.eq(mr.RATING));
SelectConditionStep<Record> qry = reportColumns.from(m).innerJoin(mr).on(mr.MEASURABLE_ID.eq(m.ID)).innerJoin(app).on(app.ID.eq(mr.ENTITY_ID)).innerJoin(mc).on(mc.ID.eq(m.MEASURABLE_CATEGORY_ID)).innerJoin(rs).on(rs.ID.eq(mc.RATING_SCHEME_ID)).innerJoin(rsi).on(rsi.SCHEME_ID.eq(rs.ID)).leftJoin(mrd).on(mrd.MEASURABLE_ID.eq(mr.MEASURABLE_ID).and(mrd.ENTITY_ID.eq(mr.ENTITY_ID)).and(mrd.ENTITY_KIND.eq(mr.ENTITY_KIND))).leftJoin(mrr).on(mrr.DECOMMISSION_ID.eq(mrd.ID)).leftJoin(ou).on(ou.ID.eq(app.ORGANISATIONAL_UNIT_ID)).where(reportConditions);
String categoryName = dsl.select(mc.NAME).from(mc).where(mc.ID.eq(categoryId)).fetchOne(mc.NAME);
String suggestedFilename = toCamelCase(categoryName);
return writeExtract(suggestedFilename, qry, request, response);
});
}
use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class MeasurableRatingExtractor method registerUnmappedAllocations.
private void registerUnmappedAllocations(String path) {
post(path, (request, response) -> {
long categoryId = WebUtilities.getId(request);
IdSelectionOptions selectionOpts = WebUtilities.readIdSelectionOptionsFromBody(request);
Select<Record1<Long>> appIds = applicationIdSelectorFactory.apply(selectionOpts);
SelectConditionStep<Record1<Long>> appIdsAssignedToAnyMeasurableInTheCategory = dsl.selectDistinct(MEASURABLE_RATING.ENTITY_ID).from(MEASURABLE_RATING).join(MEASURABLE).on(MEASURABLE.ID.eq(MEASURABLE_RATING.MEASURABLE_ID)).where(MEASURABLE_RATING.ENTITY_KIND.eq(EntityKind.APPLICATION.name()).and(MEASURABLE.MEASURABLE_CATEGORY_ID.eq(categoryId)));
SelectSeekStep1<Record5<String, String, Long, String, String>, String> qry = dsl.selectDistinct(app.NAME.as("App Name"), app.ASSET_CODE.as("App Code"), app.ID.as("App Waltz Id"), app.KIND.as("App Kind"), ou.NAME.as("Org Unit Name")).from(app).leftJoin(ou).on(ou.ID.eq(app.ORGANISATIONAL_UNIT_ID)).where(app.ID.in(appIds)).and(app.ID.notIn(appIdsAssignedToAnyMeasurableInTheCategory)).orderBy(app.NAME);
String categoryName = dsl.select(mc.NAME).from(mc).where(mc.ID.eq(categoryId)).fetchOne(mc.NAME);
String suggestedFilename = toCamelCase(categoryName) + "-Unmapped-Applications";
return writeExtract(suggestedFilename, qry, request, response);
});
}
Aggregations