use of org.finos.waltz.service.application.ApplicationService in project waltz by khartec.
the class DiagramToDotExport method main.
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
FlowDiagramService flowDiagramService = ctx.getBean(FlowDiagramService.class);
FlowDiagramEntityService flowDiagramEntityService = ctx.getBean(FlowDiagramEntityService.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
LogicalFlowService logicalFlowService = ctx.getBean(LogicalFlowService.class);
EntityReference diagRef = mkRef(EntityKind.FLOW_DIAGRAM, 1L);
IdSelectionOptions options = IdSelectionOptions.mkOpts(diagRef, HierarchyQueryScope.EXACT);
List<Application> apps = applicationService.findByAppIdSelector(options);
List<LogicalFlow> flows = logicalFlowService.findBySelector(options);
Map<Long, Application> appsById = indexBy(a -> a.id().get(), apps);
System.out.println("------");
String digraph = String.format("digraph G { %s %s}", renderApplications(apps), renderFlows(flows, appsById));
System.out.println(digraph);
System.out.println("-----");
/*
digraph G {
"Welcome" -> "To"
"To" -> "Web"
"To" -> "GraphViz!"
}
*/
}
use of org.finos.waltz.service.application.ApplicationService in project waltz by khartec.
the class InvolvementImporter method main.
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
PersonService personService = ctx.getBean(PersonService.class);
Map<String, Application> appsByExtId = indexBy(a -> ExternalIdValue.orElse(a.assetCode(), null), applicationService.findAll());
Map<String, Person> peopleByName = indexBy(p -> toSurnameFirstname(p.displayName()).toLowerCase(), personService.all());
Siphon<String[]> incorrectSizeSiphon = mkSiphon(arr -> arr.length != 3);
Siphon<Tuple2<String, ?>> unknownAppSiphon = mkSiphon(t -> !appsByExtId.containsKey(t.v1));
Siphon<Tuple2<?, String>> unknownPersonSiphon = mkSiphon(t -> !peopleByName.containsKey(t.v2.toLowerCase()));
Siphon<Tuple2<Application, ?>> retiredAppSiphon = mkSiphon(t -> t.v1.lifecyclePhase() == LifecyclePhase.RETIRED);
List<Tuple2<Application, Person>> r = IOUtilities.streamLines(classLoader.getResourceAsStream(fileName)).map(line -> line.split("\t")).filter(d -> incorrectSizeSiphon.test(d)).map(arr -> Tuple.tuple(arr[1], arr[0])).filter(t -> unknownAppSiphon.test(t)).map(t -> t.map1(extId -> appsByExtId.get(extId))).filter(t -> retiredAppSiphon.test(t)).filter(t -> unknownPersonSiphon.test(t)).map(t -> t.map2(n -> peopleByName.get(n.toLowerCase()))).collect(Collectors.toList());
Set<Application> distinctApps = r.stream().map(t -> t.v1).distinct().collect(Collectors.toSet());
Set<Person> distinctPeople = r.stream().map(t -> t.v2).distinct().collect(Collectors.toSet());
System.out.println("----");
System.out.println("Wrong size count: " + incorrectSizeSiphon.getResults().size());
System.out.println("Apps not found count: " + unknownAppSiphon.getResults().size());
System.out.println("Retired app count: " + retiredAppSiphon.getResults().size());
System.out.println("Person not found count: " + unknownPersonSiphon.getResults().size());
System.out.println("----");
System.out.println("Good record count: " + r.size());
System.out.println("Distinct App count: " + distinctApps.size());
System.out.println("Distinct People count: " + distinctPeople.size());
Map<String, Long> unknownPersonCounts = countBy(Tuple2::v2, unknownPersonSiphon.getResults());
DebugUtilities.dump(unknownPersonCounts);
}
use of org.finos.waltz.service.application.ApplicationService in project waltz by khartec.
the class LogicalFlowGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
FlowClassificationRuleDao flowClassificationRuleDao = ctx.getBean(FlowClassificationRuleDao.class);
ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<FlowClassificationRule> flowClassificationRules = flowClassificationRuleDao.findByEntityKind(EntityKind.ORG_UNIT);
List<Application> apps = applicationDao.findAll();
List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();
LocalDateTime now = LocalDateTime.now();
Set<LogicalFlow> expectedFlows = flowClassificationRules.stream().flatMap(a -> {
long orgUnitId = a.parentReference().id();
return randomlySizedIntStream(0, 40).mapToObj(i -> randomAppPick(apps, orgUnitId).map(target -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null));
}).filter(Objects::nonNull).collect(toSet());
Set<LogicalFlow> probableFlows = flowClassificationRules.stream().flatMap(a -> randomlySizedIntStream(0, 30).mapToObj(i -> randomAppPick(apps, randomPick(orgUnits).id().get()).map(target -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null))).filter(Objects::nonNull).collect(toSet());
Set<LogicalFlow> randomFlows = apps.stream().flatMap(a -> randomlySizedIntStream(0, 5).mapToObj(i -> randomAppPick(apps, randomPick(orgUnits).id().get()).map(target -> ImmutableLogicalFlow.builder().source(a.entityReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null))).filter(Objects::nonNull).collect(toSet());
Set<LogicalFlow> all = new HashSet<>();
all.addAll(randomFlows);
all.addAll(expectedFlows);
all.addAll(probableFlows);
Set<LogicalFlow> deduped = uniqBy(all, x -> Tuple.tuple(x.source(), x.target()));
log("--- saving: " + deduped.size());
Set<LogicalFlowRecord> records = SetUtilities.map(deduped, df -> LogicalFlowDao.TO_RECORD_MAPPER.apply(df, dsl));
dsl.batchStore(records).execute();
log("--- done");
return null;
}
use of org.finos.waltz.service.application.ApplicationService in project waltz by khartec.
the class AllocationHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
AllocationSchemeService schemesService = ctx.getBean(AllocationSchemeService.class);
MeasurableService measurableService = ctx.getBean(MeasurableService.class);
MeasurableCategoryDao categoryDao = ctx.getBean(MeasurableCategoryDao.class);
MeasurableRatingService ratingService = ctx.getBean(MeasurableRatingService.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
Tuple4<Application, MeasurableCategory, List<Measurable>, AllocationScheme> stuff = setup(dsl, schemesService, measurableService, categoryDao, applicationService);
addRating(ratingService, stuff, 0);
addRating(ratingService, stuff, 1);
// addRating(ratingService, stuff, 2);
// addAllocation(dsl, stuff, 0, 50);
addAllocation(dsl, stuff, 1, 20);
Long measurableCategory = stuff.v2.id().get();
dumpRatings(dsl, stuff.v4);
dumpAllocs(dsl, stuff.v4);
doDiff(dsl, measurableCategory);
System.out.println(ratingService.findByCategory(measurableCategory));
}
use of org.finos.waltz.service.application.ApplicationService 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