Search in sources :

Example 1 with APPLICATION_GROUP_ENTRY

use of org.finos.waltz.schema.Tables.APPLICATION_GROUP_ENTRY in project waltz by khartec.

the class AppGroupEntryGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    List<Long> appIds = getAppIds(dsl);
    List<Long> groupIds = dsl.select(APPLICATION_GROUP.ID).from(APPLICATION_GROUP).fetch(APPLICATION_GROUP.ID);
    List<ApplicationGroupEntryRecord> records = groupIds.stream().flatMap(id -> randomlySizedIntStream(0, 25).mapToLong(idx -> randomPick(appIds)).distinct().mapToObj(appId -> {
        ApplicationGroupEntryRecord record = dsl.newRecord(APPLICATION_GROUP_ENTRY);
        record.setGroupId(id);
        record.setApplicationId(appId);
        return record;
    })).collect(Collectors.toList());
    dsl.batchStore(records).execute();
    return null;
}
Also used : ApplicationGroupEntryRecord(org.finos.waltz.schema.tables.records.ApplicationGroupEntryRecord) List(java.util.List) Map(java.util.Map) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) RandomUtilities.randomlySizedIntStream(org.finos.waltz.common.RandomUtilities.randomlySizedIntStream) APPLICATION_GROUP(org.finos.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP) DSLContext(org.jooq.DSLContext) ApplicationGroupEntryRecord(org.finos.waltz.schema.tables.records.ApplicationGroupEntryRecord) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) APPLICATION_GROUP_ENTRY(org.finos.waltz.schema.Tables.APPLICATION_GROUP_ENTRY) DSLContext(org.jooq.DSLContext)

Aggregations

List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 RandomUtilities.randomPick (org.finos.waltz.common.RandomUtilities.randomPick)1 RandomUtilities.randomlySizedIntStream (org.finos.waltz.common.RandomUtilities.randomlySizedIntStream)1 APPLICATION_GROUP_ENTRY (org.finos.waltz.schema.Tables.APPLICATION_GROUP_ENTRY)1 APPLICATION_GROUP (org.finos.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP)1 ApplicationGroupEntryRecord (org.finos.waltz.schema.tables.records.ApplicationGroupEntryRecord)1 DSLContext (org.jooq.DSLContext)1 ApplicationContext (org.springframework.context.ApplicationContext)1