Search in sources :

Example 1 with ORGANISATIONAL_UNIT

use of org.finos.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT 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 ORGANISATIONAL_UNIT

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

the class FlowClassificationRuleGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    List<Long> appIds = getAppIds(dsl);
    List<Long> ouIds = dsl.select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT).fetch(ORGANISATIONAL_UNIT.ID);
    List<Long> typeIds = dsl.select(DATA_TYPE.ID).from(DATA_TYPE).fetch(DATA_TYPE.ID);
    List<AuthoritativenessRatingValue> classificationValues = asList(AuthoritativenessRatingValue.of("PRIMARY"), AuthoritativenessRatingValue.of("SECONDARY"), AuthoritativenessRatingValue.DISCOURAGED, AuthoritativenessRatingValue.NO_OPINION);
    List<String> colors = asList(HexStrings.AMBER, HexStrings.RED, HexStrings.GREEN);
    Set<FlowClassificationRecord> classificationRecords = classificationValues.stream().map(v -> {
        FlowClassificationRecord record = dsl.newRecord(FLOW_CLASSIFICATION);
        record.setCode(v.value());
        record.setName(capitalise(v.value()));
        record.setColor(randomPick(colors));
        return record;
    }).collect(toSet());
    dsl.batchInsert(classificationRecords).execute();
    List<Long> classificationIds = dsl.select(FLOW_CLASSIFICATION.ID).from(FLOW_CLASSIFICATION).where(FLOW_CLASSIFICATION.CODE.notIn(AuthoritativenessRatingValue.DISCOURAGED.value(), AuthoritativenessRatingValue.NO_OPINION.value())).fetch(FLOW_CLASSIFICATION.ID);
    List<FlowClassificationRuleRecord> records = typeIds.stream().flatMap(t -> IntStream.range(0, 2 + rnd.nextInt(2)).mapToObj(i -> {
        FlowClassificationRuleRecord record = dsl.newRecord(FLOW_CLASSIFICATION_RULE);
        record.setDataTypeId(t);
        record.setFlowClassificationId(randomPick(classificationIds));
        record.setApplicationId(randomPick(appIds));
        record.setParentId(randomPick(ouIds));
        record.setParentKind(EntityKind.ORG_UNIT.name());
        record.setProvenance(SAMPLE_DATA_PROVENANCE);
        record.setLastUpdatedAt(nowUtcTimestamp());
        record.setLastUpdatedBy(SAMPLE_DATA_USER);
        return record;
    })).collect(Collectors.toList());
    dsl.batchStore(records).execute();
    return null;
}
Also used : IntStream(java.util.stream.IntStream) AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) FLOW_CLASSIFICATION(org.finos.waltz.schema.Tables.FLOW_CLASSIFICATION) StringUtilities.capitalise(org.finos.waltz.common.StringUtilities.capitalise) HexStrings(org.finos.waltz.common.ColorUtilities.HexStrings) EntityKind(org.finos.waltz.model.EntityKind) Set(java.util.Set) Random(java.util.Random) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) RandomUtilities(org.finos.waltz.common.RandomUtilities) FLOW_CLASSIFICATION_RULE(org.finos.waltz.schema.Tables.FLOW_CLASSIFICATION_RULE) List(java.util.List) DateTimeUtilities.nowUtcTimestamp(org.finos.waltz.common.DateTimeUtilities.nowUtcTimestamp) FlowClassificationRecord(org.finos.waltz.schema.tables.records.FlowClassificationRecord) FlowClassificationRuleRecord(org.finos.waltz.schema.tables.records.FlowClassificationRuleRecord) ORGANISATIONAL_UNIT(org.finos.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT) ListUtilities.asList(org.finos.waltz.common.ListUtilities.asList) Map(java.util.Map) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) DSLContext(org.jooq.DSLContext) Collectors.toSet(java.util.stream.Collectors.toSet) DATA_TYPE(org.finos.waltz.schema.tables.DataType.DATA_TYPE) FlowClassificationRuleRecord(org.finos.waltz.schema.tables.records.FlowClassificationRuleRecord) FlowClassificationRecord(org.finos.waltz.schema.tables.records.FlowClassificationRecord) AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) DSLContext(org.jooq.DSLContext)

Example 3 with ORGANISATIONAL_UNIT

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

the class InvolvementGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = ctx.getBean(DSLContext.class);
    List<String> developers = getEmployeeIdsByTitle(dsl, "%Developer%");
    List<String> managers = getEmployeeIdsByTitle(dsl, "%Manager%");
    List<String> analysts = getEmployeeIdsByTitle(dsl, "%Analyst%");
    List<String> administrators = getEmployeeIdsByTitle(dsl, "%Administrator%");
    List<String> qa = getEmployeeIdsByTitle(dsl, "%QA%");
    List<String> directors = getEmployeeIdsByTitle(dsl, "%Director%");
    List<Long> orgUnitIds = dsl.select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT).fetch(ORGANISATIONAL_UNIT.ID);
    Map<String, Long> involvementKindMap = dsl.select(INVOLVEMENT_KIND.NAME, INVOLVEMENT_KIND.ID).from(INVOLVEMENT_KIND).fetch().stream().collect(toMap(r -> r.getValue(INVOLVEMENT_KIND.NAME), r -> r.getValue(INVOLVEMENT_KIND.ID)));
    List<Long> inHouseApps = getAppIdsByKind(dsl, ApplicationKind.IN_HOUSE);
    List<Long> hostedApps = getAppIdsByKind(dsl, ApplicationKind.INTERNALLY_HOSTED);
    List<Long> externalApps = getAppIdsByKind(dsl, ApplicationKind.EXTERNALLY_HOSTED);
    List<Long> eucApps = getAppIdsByKind(dsl, ApplicationKind.EUC);
    List<InvolvementRecord> devInvolvements = inHouseApps.stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, developers, involvementKindMap.get("Developer"), 7)).collect(Collectors.toList());
    List<InvolvementRecord> qaInvolvements = concat(inHouseApps, hostedApps).stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, qa, involvementKindMap.get("Quality Assurance"), 3)).collect(Collectors.toList());
    List<InvolvementRecord> projectManagerInvolvements = concat(inHouseApps, externalApps, hostedApps, eucApps).stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, managers, involvementKindMap.get("Project Manager"), 1)).collect(Collectors.toList());
    List<InvolvementRecord> supportManagerInvolvments = concat(inHouseApps, externalApps, hostedApps).stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, managers, involvementKindMap.get("Support Manager"), 1)).collect(Collectors.toList());
    List<InvolvementRecord> analystInvolvments = concat(inHouseApps, externalApps, hostedApps).stream().map(id -> toAppRef(id)).flatMap(appRef -> mkInvolvments(appRef, analysts, involvementKindMap.get("Business Analyst"), 3)).collect(Collectors.toList());
    List<InvolvementRecord> ouArchitects = orgUnitIds.stream().map(id -> new InvolvementRecord(EntityKind.ORG_UNIT.name(), id, randomPick(directors), SAMPLE_DATA_PROVENANCE, Long.valueOf(rnd.nextInt(13) + 1), true)).collect(Collectors.toList());
    List<InvolvementRecord> ouSponsors = orgUnitIds.stream().map(id -> new InvolvementRecord(EntityKind.ORG_UNIT.name(), id, randomPick(directors), SAMPLE_DATA_PROVENANCE, Long.valueOf(rnd.nextInt(13) + 1), true)).collect(Collectors.toList());
    List<InvolvementRecord> categoryInvolvements = dsl.select(MEASURABLE_CATEGORY.ID).from(MEASURABLE_CATEGORY).fetch(MEASURABLE_CATEGORY.ID).stream().map(id -> new InvolvementRecord(EntityKind.MEASURABLE_CATEGORY.name(), id, randomPick(directors), SAMPLE_DATA_PROVENANCE, Long.valueOf(rnd.nextInt(13) + 1), true)).collect(Collectors.toList());
    dsl.batchInsert(devInvolvements).execute();
    dsl.batchInsert(qaInvolvements).execute();
    dsl.batchInsert(supportManagerInvolvments).execute();
    dsl.batchInsert(projectManagerInvolvements).execute();
    dsl.batchInsert(analystInvolvments).execute();
    dsl.batchInsert(ouArchitects).execute();
    dsl.batchInsert(ouSponsors).execute();
    dsl.batchInsert(categoryInvolvements).execute();
    System.out.println("Done");
    return null;
}
Also used : IntStream(java.util.stream.IntStream) APPLICATION(org.finos.waltz.schema.tables.Application.APPLICATION) INVOLVEMENT_KIND(org.finos.waltz.schema.tables.InvolvementKind.INVOLVEMENT_KIND) EntityKind(org.finos.waltz.model.EntityKind) ImmutableEntityReference(org.finos.waltz.model.ImmutableEntityReference) Random(java.util.Random) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) InvolvementRecord(org.finos.waltz.schema.tables.records.InvolvementRecord) MEASURABLE_CATEGORY(org.finos.waltz.schema.Tables.MEASURABLE_CATEGORY) RandomUtilities(org.finos.waltz.common.RandomUtilities) List(java.util.List) Stream(java.util.stream.Stream) ORGANISATIONAL_UNIT(org.finos.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT) Collectors.toMap(java.util.stream.Collectors.toMap) INVOLVEMENT(org.finos.waltz.schema.tables.Involvement.INVOLVEMENT) Map(java.util.Map) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) EntityReference(org.finos.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) ApplicationKind(org.finos.waltz.model.application.ApplicationKind) ListUtilities.concat(org.finos.waltz.common.ListUtilities.concat) PERSON(org.finos.waltz.schema.tables.Person.PERSON) DSLContext(org.jooq.DSLContext) InvolvementRecord(org.finos.waltz.schema.tables.records.InvolvementRecord)

Aggregations

List (java.util.List)3 Map (java.util.Map)3 Random (java.util.Random)3 Collectors (java.util.stream.Collectors)3 RandomUtilities (org.finos.waltz.common.RandomUtilities)3 RandomUtilities.randomPick (org.finos.waltz.common.RandomUtilities.randomPick)3 EntityKind (org.finos.waltz.model.EntityKind)3 ORGANISATIONAL_UNIT (org.finos.waltz.schema.tables.OrganisationalUnit.ORGANISATIONAL_UNIT)3 DSLContext (org.jooq.DSLContext)3 ApplicationContext (org.springframework.context.ApplicationContext)3 IntStream (java.util.stream.IntStream)2 EntityReference (org.finos.waltz.model.EntityReference)2 APPLICATION (org.finos.waltz.schema.tables.Application.APPLICATION)2 Set (java.util.Set)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1 HexStrings (org.finos.waltz.common.ColorUtilities.HexStrings)1 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)1 DateTimeUtilities.nowUtcTimestamp (org.finos.waltz.common.DateTimeUtilities.nowUtcTimestamp)1