Search in sources :

Example 1 with APPLICATION_GROUP

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

the class BookmarkGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    List<EntityReference> appRefs = dsl.select(APPLICATION.NAME, APPLICATION.ID).from(APPLICATION).fetch(r -> EntityReference.mkRef(EntityKind.APPLICATION, r.value2(), r.value1()));
    List<EntityReference> measurableRefs = dsl.select(MEASURABLE.NAME, MEASURABLE.ID).from(MEASURABLE).fetch(r -> EntityReference.mkRef(EntityKind.MEASURABLE, r.value2(), r.value1()));
    List<EntityReference> ouRefs = dsl.select(ORGANISATIONAL_UNIT.NAME, ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT).fetch(r -> EntityReference.mkRef(EntityKind.ORG_UNIT, r.value2(), r.value1()));
    List<EntityReference> appGroupRefs = dsl.select(APPLICATION_GROUP.NAME, APPLICATION_GROUP.ID).from(APPLICATION_GROUP).fetch(r -> EntityReference.mkRef(EntityKind.APP_GROUP, r.value2(), r.value1()));
    List<EntityReference> refs = ListUtilities.concat(appRefs, measurableRefs, ouRefs, appGroupRefs);
    List<BookmarkRecord> bookmarks = refs.stream().flatMap(r -> RandomUtilities.randomlySizedIntStream(2, 15).mapToObj(idx -> {
        BookmarkRecord record = dsl.newRecord(BOOKMARK);
        record.setParentKind(r.kind().name());
        record.setParentId(r.id());
        record.setTitle(mkText(r.name().get()));
        record.setDescription(mkText(r.name().get()));
        record.setKind(randomPick(bookmarkKinds));
        record.setUrl(mkUrl(r.name().get()));
        record.setProvenance(SAMPLE_DATA_PROVENANCE);
        record.setLastUpdatedBy("admin");
        record.setUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
        record.setCreatedAt(DateTimeUtilities.nowUtcTimestamp());
        return record;
    })).collect(Collectors.toList());
    dsl.batchStore(bookmarks).execute();
    return null;
}
Also used : APPLICATION(org.finos.waltz.schema.tables.Application.APPLICATION) EntityKind(org.finos.waltz.model.EntityKind) Random(java.util.Random) BookmarkRecord(org.finos.waltz.schema.tables.records.BookmarkRecord) BOOKMARK(org.finos.waltz.schema.tables.Bookmark.BOOKMARK) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) RandomUtilities(org.finos.waltz.common.RandomUtilities) List(java.util.List) ORGANISATIONAL_UNIT(org.finos.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) MEASURABLE(org.finos.waltz.schema.tables.Measurable.MEASURABLE) ListUtilities(org.finos.waltz.common.ListUtilities) Map(java.util.Map) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) APPLICATION_GROUP(org.finos.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP) EntityReference(org.finos.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) EntityReference(org.finos.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) BookmarkRecord(org.finos.waltz.schema.tables.records.BookmarkRecord)

Example 2 with APPLICATION_GROUP

use of org.finos.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP 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)

Example 3 with APPLICATION_GROUP

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

the class AppGroupGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    List<ApplicationGroupRecord> groupRecords = Arrays.stream(names).map(n -> {
        ApplicationGroupRecord record = dsl.newRecord(APPLICATION_GROUP);
        record.setName(n);
        record.setKind(AppGroupKind.PUBLIC.name());
        record.setDescription(format("%s : Description of %s", SAMPLE_DATA_PROVENANCE, n));
        return record;
    }).collect(Collectors.toList());
    dsl.batchStore(groupRecords).execute();
    return null;
}
Also used : ApplicationGroupRecord(org.finos.waltz.schema.tables.records.ApplicationGroupRecord) AppGroupKind(org.finos.waltz.model.app_group.AppGroupKind) Arrays(java.util.Arrays) List(java.util.List) DSL(org.jooq.impl.DSL) APPLICATION_GROUP_ENTRY(org.finos.waltz.schema.tables.ApplicationGroupEntry.APPLICATION_GROUP_ENTRY) ApplicationGroupRecord(org.finos.waltz.schema.tables.records.ApplicationGroupRecord) Map(java.util.Map) APPLICATION_GROUP(org.finos.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP) DSLContext(org.jooq.DSLContext) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) DSLContext(org.jooq.DSLContext)

Aggregations

List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 APPLICATION_GROUP (org.finos.waltz.schema.tables.ApplicationGroup.APPLICATION_GROUP)3 DSLContext (org.jooq.DSLContext)3 ApplicationContext (org.springframework.context.ApplicationContext)3 RandomUtilities.randomPick (org.finos.waltz.common.RandomUtilities.randomPick)2 String.format (java.lang.String.format)1 Arrays (java.util.Arrays)1 Random (java.util.Random)1 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)1 ListUtilities (org.finos.waltz.common.ListUtilities)1 RandomUtilities (org.finos.waltz.common.RandomUtilities)1 RandomUtilities.randomlySizedIntStream (org.finos.waltz.common.RandomUtilities.randomlySizedIntStream)1 EntityKind (org.finos.waltz.model.EntityKind)1 EntityReference (org.finos.waltz.model.EntityReference)1 AppGroupKind (org.finos.waltz.model.app_group.AppGroupKind)1 APPLICATION_GROUP_ENTRY (org.finos.waltz.schema.Tables.APPLICATION_GROUP_ENTRY)1 APPLICATION (org.finos.waltz.schema.tables.Application.APPLICATION)1 APPLICATION_GROUP_ENTRY (org.finos.waltz.schema.tables.ApplicationGroupEntry.APPLICATION_GROUP_ENTRY)1