use of org.finos.waltz.schema.Tables.MEASURABLE in project waltz by khartec.
the class MeasurableRatingGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
DSLContext dsl = getDsl(ctx);
List<Long> appIds = getAppIds(dsl);
List<Long> mIds = dsl.select(MEASURABLE.ID).from(MEASURABLE).where(MEASURABLE.CONCRETE.isTrue()).fetch().getValues(MEASURABLE.ID);
List<MeasurableRatingRecord> records = appIds.stream().flatMap(appId -> randomlySizedIntStream(0, MAX_RATINGS_PER_APP).mapToObj(idx -> Tuple.tuple(appId, randomPick(mIds)))).map(t -> {
MeasurableRatingRecord record = dsl.newRecord(MEASURABLE_RATING);
record.setEntityId(t.v1);
record.setEntityKind(EntityKind.APPLICATION.name());
record.setRating(randomPick("R", "A", "G"));
record.setMeasurableId(t.v2);
record.setLastUpdatedBy("admin");
record.setProvenance(SAMPLE_DATA_PROVENANCE);
return record;
}).collect(Collectors.toList());
Set<MeasurableRatingRecord> dedupedRecords = uniqBy(records, r -> Tuple.tuple(r.getMeasurableId(), r.getEntityId()));
dsl.batchStore(dedupedRecords).execute();
return null;
}
use of org.finos.waltz.schema.Tables.MEASURABLE in project waltz by khartec.
the class HigherEducationTaxonomyImport method updateParentIdsUsingExtIds.
private int updateParentIdsUsingExtIds(DSLContext tx, long categoryId) {
// clear existing parent ids
dsl.update(MEASURABLE).setNull(MEASURABLE.PARENT_ID).where(MEASURABLE.MEASURABLE_CATEGORY_ID.eq(categoryId)).execute();
Measurable c = MEASURABLE.as("c");
Measurable p = MEASURABLE.as("p");
return tx.update(c).set(c.PARENT_ID, DSL.select(p.ID).from(p).where(p.EXTERNAL_ID.eq(c.EXTERNAL_PARENT_ID)).and(p.MEASURABLE_CATEGORY_ID.eq(categoryId))).where(c.MEASURABLE_CATEGORY_ID.eq(categoryId)).execute();
}
use of org.finos.waltz.schema.Tables.MEASURABLE 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);
}
Aggregations