Search in sources :

Example 1 with ScenarioAxisItem

use of org.finos.waltz.schema.tables.ScenarioAxisItem in project waltz by khartec.

the class ScenarioExtractor method extract.

private Object extract(Request request, Response response) throws Exception {
    long scenarioId = WebUtilities.getId(request);
    Measurable rowMeasurable = MEASURABLE.as("rowMeasurable");
    Measurable colMeasurable = MEASURABLE.as("colMeasurable");
    ScenarioAxisItem rowAxisItem = SCENARIO_AXIS_ITEM.as("rowAxisItem");
    ScenarioAxisItem colAxisItem = SCENARIO_AXIS_ITEM.as("colAxisItem");
    Condition rowMeasurableJoin = rowMeasurable.ID.eq(SCENARIO_RATING_ITEM.ROW_ID).and(SCENARIO_RATING_ITEM.ROW_KIND.eq(EntityKind.MEASURABLE.name()));
    Condition colMeasurableJoin = colMeasurable.ID.eq(SCENARIO_RATING_ITEM.COLUMN_ID).and(SCENARIO_RATING_ITEM.COLUMN_KIND.eq(EntityKind.MEASURABLE.name()));
    Condition appJoin = APPLICATION.ID.eq(SCENARIO_RATING_ITEM.DOMAIN_ITEM_ID).and(SCENARIO_RATING_ITEM.DOMAIN_ITEM_KIND.eq(EntityKind.APPLICATION.name()));
    Condition rowAxisItemJoin = rowAxisItem.DOMAIN_ITEM_ID.eq(SCENARIO_RATING_ITEM.ROW_ID).and(rowAxisItem.ORIENTATION.eq(AxisOrientation.ROW.name())).and(rowAxisItem.SCENARIO_ID.eq(SCENARIO_RATING_ITEM.SCENARIO_ID));
    Condition colAxisItemJoin = colAxisItem.DOMAIN_ITEM_ID.eq(SCENARIO_RATING_ITEM.COLUMN_ID).and(colAxisItem.ORIENTATION.eq(AxisOrientation.COLUMN.name())).and(colAxisItem.SCENARIO_ID.eq(SCENARIO_RATING_ITEM.SCENARIO_ID));
    SelectConditionStep<Record6<String, String, String, String, String, String>> qry = dsl.select(APPLICATION.NAME.as("Application"), APPLICATION.ASSET_CODE.as("App Asset Code"), colMeasurable.NAME.as("Column"), rowMeasurable.NAME.as("Row"), RATING_SCHEME_ITEM.NAME.as("Rating"), SCENARIO_RATING_ITEM.DESCRIPTION.as("Description")).from(SCENARIO_RATING_ITEM).innerJoin(APPLICATION).on(appJoin).innerJoin(rowMeasurable).on(rowMeasurableJoin).innerJoin(colMeasurable).on(colMeasurableJoin).innerJoin(rowAxisItem).on(rowAxisItemJoin).innerJoin(colAxisItem).on(colAxisItemJoin).innerJoin(SCENARIO).on(SCENARIO.ID.eq(scenarioId)).innerJoin(ROADMAP).on(ROADMAP.ID.eq(SCENARIO.ROADMAP_ID)).innerJoin(RATING_SCHEME_ITEM).on(RATING_SCHEME_ITEM.SCHEME_ID.eq(ROADMAP.RATING_SCHEME_ID).and(RATING_SCHEME_ITEM.CODE.eq(SCENARIO_RATING_ITEM.RATING))).where(SCENARIO_RATING_ITEM.SCENARIO_ID.eq(scenarioId));
    String scenarioName = dsl.select(SCENARIO.NAME).from(SCENARIO).where(SCENARIO.ID.eq(scenarioId)).fetchOne(SCENARIO.NAME);
    String suggestedFilename = "scenario-" + scenarioName;
    return writeExtract(suggestedFilename, qry, request, response);
}
Also used : Condition(org.jooq.Condition) Measurable(org.finos.waltz.schema.tables.Measurable) ScenarioAxisItem(org.finos.waltz.schema.tables.ScenarioAxisItem) Record6(org.jooq.Record6)

Aggregations

Measurable (org.finos.waltz.schema.tables.Measurable)1 ScenarioAxisItem (org.finos.waltz.schema.tables.ScenarioAxisItem)1 Condition (org.jooq.Condition)1 Record6 (org.jooq.Record6)1