use of org.finos.waltz.schema.Tables.MEASURABLE_RATING 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;
}
Aggregations