use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class SurveyRunExtractor method getSurveysForEntity.
private SelectWhereStep<?> getSurveysForEntity(EntityReference entityReference) {
IdSelectionOptions idSelectionOptions = mkOpts(entityReference);
GenericSelector genericSelectorForChangeInitiativeIds = genericSelectorFactory.applyForKind(EntityKind.CHANGE_INITIATIVE, idSelectionOptions);
GenericSelector genericSelectorForApplications = genericSelectorFactory.applyForKind(EntityKind.APPLICATION, idSelectionOptions);
SelectConditionStep<Record14<String, String, String, String, Long, String, String, String, String, Date, String, Date, String, Date>> applicationSurveySelect = DSL.select(ORGANISATIONAL_UNIT.NAME.as("Org Unit"), APPLICATION.ASSET_CODE.as("Entity Id"), APPLICATION.NAME.as("Entity Name"), SURVEY_INSTANCE.ENTITY_KIND.as("Entity Kind"), SURVEY_INSTANCE.ID.as("Survey Instance Id"), SURVEY_TEMPLATE.NAME.as("Survey Template"), SURVEY_RUN.NAME.as("Survey Run"), PERSON.DISPLAY_NAME.as("Survey Owner"), SURVEY_INSTANCE.STATUS.as("Status"), SURVEY_INSTANCE.DUE_DATE.as("Due Date"), SURVEY_INSTANCE.SUBMITTED_BY.as("Submitted By"), DSL.date(SURVEY_INSTANCE.SUBMITTED_AT).as("Submitted At"), SURVEY_INSTANCE.APPROVED_BY.as("Approved By"), DSL.date(SURVEY_INSTANCE.APPROVED_AT).as("Approved At")).from(SURVEY_INSTANCE).innerJoin(SURVEY_RUN).on(SURVEY_INSTANCE.SURVEY_RUN_ID.eq(SURVEY_RUN.ID)).innerJoin(SURVEY_TEMPLATE).on(SURVEY_RUN.SURVEY_TEMPLATE_ID.eq(SURVEY_TEMPLATE.ID).and(SURVEY_TEMPLATE.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))).innerJoin(APPLICATION).on(SURVEY_INSTANCE.ENTITY_KIND.eq(EntityKind.APPLICATION.name()).and(APPLICATION.ID.eq(SURVEY_INSTANCE.ENTITY_ID))).innerJoin(ORGANISATIONAL_UNIT).on(APPLICATION.ORGANISATIONAL_UNIT_ID.eq(ORGANISATIONAL_UNIT.ID)).leftJoin(PERSON).on(SURVEY_RUN.OWNER_ID.eq(PERSON.ID)).where(SURVEY_INSTANCE.ORIGINAL_INSTANCE_ID.isNull().and(APPLICATION.ENTITY_LIFECYCLE_STATUS.eq(EntityLifecycleStatus.ACTIVE.name()).and(APPLICATION.IS_REMOVED.isFalse().and(APPLICATION.ID.in(genericSelectorForApplications.selector())))));
SelectConditionStep<Record14<String, String, String, String, Long, String, String, String, String, Date, String, Date, String, Date>> changeInitiativeSurveySelect = DSL.select(ORGANISATIONAL_UNIT.NAME.as("Org Unit"), CHANGE_INITIATIVE.EXTERNAL_ID.as("Entity Id"), CHANGE_INITIATIVE.NAME.as("Entity Name"), SURVEY_INSTANCE.ENTITY_KIND.as("Entity Kind"), SURVEY_INSTANCE.ID.as("Survey Instance Id"), SURVEY_TEMPLATE.NAME.as("Survey Template"), SURVEY_RUN.NAME.as("Survey Run"), PERSON.DISPLAY_NAME.as("Survey Owner"), SURVEY_INSTANCE.STATUS.as("Status"), SURVEY_INSTANCE.DUE_DATE.as("Due Date"), SURVEY_INSTANCE.SUBMITTED_BY.as("Submitted By"), DSL.date(SURVEY_INSTANCE.SUBMITTED_AT).as("Submitted At"), SURVEY_INSTANCE.APPROVED_BY.as("Approved By"), DSL.date(SURVEY_INSTANCE.APPROVED_AT).as("Approved At")).from(SURVEY_INSTANCE).innerJoin(SURVEY_RUN).on(SURVEY_INSTANCE.SURVEY_RUN_ID.eq(SURVEY_RUN.ID)).innerJoin(SURVEY_TEMPLATE).on(SURVEY_RUN.SURVEY_TEMPLATE_ID.eq(SURVEY_TEMPLATE.ID).and(SURVEY_TEMPLATE.TARGET_ENTITY_KIND.eq(EntityKind.CHANGE_INITIATIVE.name()))).innerJoin(CHANGE_INITIATIVE).on(SURVEY_INSTANCE.ENTITY_KIND.eq(EntityKind.CHANGE_INITIATIVE.name()).and(CHANGE_INITIATIVE.ID.eq(SURVEY_INSTANCE.ENTITY_ID))).innerJoin(ORGANISATIONAL_UNIT).on(CHANGE_INITIATIVE.ORGANISATIONAL_UNIT_ID.eq(ORGANISATIONAL_UNIT.ID)).leftJoin(PERSON).on(SURVEY_RUN.OWNER_ID.eq(PERSON.ID)).where(SURVEY_INSTANCE.ORIGINAL_INSTANCE_ID.isNull().and(CHANGE_INITIATIVE.ID.in(genericSelectorForChangeInitiativeIds.selector())));
return dsl.selectFrom(applicationSurveySelect.union(changeInitiativeSurveySelect).asTable());
}
use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class RoadmapGenerator method populateScenario.
private void populateScenario(ApplicationContext ctx, Scenario scenario) {
ScenarioAxisItemDao scenarioAxisItemDao = getScenarioAxisItemDao(ctx);
MeasurableRatingService measurableRatingService = getMeasurableRatingService(ctx);
scenario.id().ifPresent(scenarioId -> {
Collection<ScenarioAxisItem> axisItems = scenarioAxisItemDao.findForScenarioId(scenarioId);
Map<AxisOrientation, Collection<ScenarioAxisItem>> byOrientation = groupBy(ScenarioAxisItem::axisOrientation, axisItems);
IdSelectionOptions options = mkOpts(scenario.entityReference());
Map<Long, Collection<MeasurableRating>> ratingsByMeasurableId = groupBy(MeasurableRating::measurableId, measurableRatingService.findByMeasurableIdSelector(options));
List<ScenarioRatingItemRecord> scenarioRatingItems = IntStream.range(0, randomIntBetween(10, 300)).mapToObj(i -> tuple(randomPick(byOrientation.get(AxisOrientation.COLUMN)), randomPick(byOrientation.get(AxisOrientation.ROW)))).map(t -> t.map1(d -> d.domainItem().id()).map2(d -> d.domainItem().id())).map(t -> t.concat(tuple(randomPick(ratingsByMeasurableId.get(t.v1)), randomPick(ratingsByMeasurableId.get(t.v2))))).map(t -> {
MeasurableRating rating = t.v3 != null ? t.v3 : t.v4;
ScenarioRatingItemRecord record = getDsl(ctx).newRecord(SCENARIO_RATING_ITEM);
record.setScenarioId(scenarioId);
record.setColumnId(t.v1);
record.setColumnKind(EntityKind.MEASURABLE.name());
record.setRowId(t.v2);
record.setRowKind(EntityKind.MEASURABLE.name());
record.setDomainItemId(rating.entityReference().id());
record.setDomainItemKind(rating.entityReference().kind().name());
record.setRating(String.valueOf(rating.rating()));
record.setLastUpdatedBy("admin");
record.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
return record;
}).collect(Collectors.toList());
getDsl(ctx).batchInsert(scenarioRatingItems).execute();
});
}
use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class ChangeInitiativeHarness method main.
public static void main(String[] args) throws ParseException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ChangeInitiativeDao dao = ctx.getBean(ChangeInitiativeDao.class);
ChangeInitiativeIdSelectorFactory selectorFactory = new ChangeInitiativeIdSelectorFactory();
IdSelectionOptions opts = mkOpts(mkRef(EntityKind.APP_GROUP, 2), HierarchyQueryScope.EXACT);
Select<Record1<Long>> selector = selectorFactory.apply(opts);
dsl.fetch(selector).formatCSV(System.out);
dao.findForSelector(selector);
}
use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class DatabaseHarness method main.
public static void main(String[] args) throws ParseException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DatabaseInformationService databaseInfoService = ctx.getBean(DatabaseInformationService.class);
DatabaseInformationDao databaseDao = ctx.getBean(DatabaseInformationDao.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
/*
List<DatabaseInformation> dbs = databaseDao.findByApplicationId(801L);
System.out.println(dbs.size());
List<Tally<String>> eolCounts = calculateStringTallies(
dsl,
DATABASE_INFORMATION,
DSL.when(DATABASE_INFORMATION.END_OF_LIFE_DATE.lt(DSL.currentDate()), DSL.inline(EndOfLifeStatus.END_OF_LIFE.name()))
.otherwise(DSL.inline(EndOfLifeStatus.NOT_END_OF_LIFE.name())),
DSL.trueCondition());
System.out.println(eolCounts);
*/
IdSelectionOptions options = IdSelectionOptions.mkOpts(EntityReference.mkRef(EntityKind.ORG_UNIT, 10), HierarchyQueryScope.CHILDREN);
for (int i = 0; i < 5; i++) {
HarnessUtilities.time("stats", () -> databaseInfoService.calculateStatsForAppIdSelector(options));
}
}
use of org.finos.waltz.model.IdSelectionOptions in project waltz by khartec.
the class ApplicationIdSelectorHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
ApplicationIdSelectorFactory factory = new ApplicationIdSelectorFactory();
DSLContext dsl = ctx.getBean(DSLContext.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
IdSelectionOptions options = mkOpts(EntityReference.mkRef(EntityKind.DATA_TYPE, 5000L), HierarchyQueryScope.CHILDREN);
Select<Record1<Long>> selector = factory.apply(options);
dsl.settings().withRenderFormatted(true);
List<Application> apps = applicationService.findByAppIdSelector(options);
System.out.println("--- sz: " + apps.size());
apps.forEach(System.out::println);
System.out.println("--- done");
}
Aggregations