use of org.finos.waltz.schema.Tables.MEASURABLE_CATEGORY in project waltz by khartec.
the class MeasurableHelper method createMeasurableCategory.
public long createMeasurableCategory(String name) {
Set<MeasurableCategory> categories = categoryService.findByExternalId(name);
return CollectionUtilities.maybeFirst(categories).map(c -> c.id().get()).orElseGet(() -> {
long schemeId = ratingSchemeHelper.createEmptyRatingScheme("test");
MeasurableCategoryRecord record = dsl.newRecord(MEASURABLE_CATEGORY);
record.setDescription(name);
record.setName(name);
record.setExternalId(name);
record.setRatingSchemeId(schemeId);
record.setLastUpdatedBy("admin");
record.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
record.setEditable(false);
record.store();
return record.getId();
});
}
use of org.finos.waltz.schema.Tables.MEASURABLE_CATEGORY 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;
}
Aggregations