use of org.finos.waltz.model.application.LifecyclePhase 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.model.application.LifecyclePhase in project waltz by khartec.
the class ReportGridExtractor method writeExcelBody.
private int writeExcelBody(List<Tuple2<Application, ArrayList<Object>>> reportRows, SXSSFSheet sheet) {
AtomicInteger rowNum = new AtomicInteger(1);
reportRows.forEach(r -> {
long appId = r.v1.entityReference().id();
String appName = r.v1.name();
Optional<ExternalIdValue> assetCode = r.v1.assetCode();
LifecyclePhase lifecyclePhase = r.v1.lifecyclePhase();
List<Object> appInfo = asList(appId, appName, assetCode, lifecyclePhase.name());
List<Object> values = concat(appInfo, r.v2);
Row row = sheet.createRow(rowNum.getAndIncrement());
AtomicInteger colNum = new AtomicInteger(0);
for (Object value : values) {
Object v = value instanceof Optional ? ((Optional<?>) value).orElse(null) : value;
int nextColNum = colNum.getAndIncrement();
if (v == null) {
row.createCell(nextColNum);
} else if (v instanceof Number) {
Cell cell = row.createCell(nextColNum, CellType.NUMERIC);
cell.setCellValue(((Number) v).doubleValue());
} else if (v instanceof ExternalIdValue) {
Cell cell = row.createCell(nextColNum, CellType.STRING);
cell.setCellValue(((ExternalIdValue) v).value());
} else {
Cell cell = row.createCell(nextColNum);
cell.setCellValue(Objects.toString(v));
}
}
});
return rowNum.get();
}
use of org.finos.waltz.model.application.LifecyclePhase in project waltz by khartec.
the class ReportGridExtractor method simplify.
private List<Object> simplify(Tuple2<Application, ArrayList<Object>> row) {
long appId = row.v1.entityReference().id();
String appName = row.v1.name();
Optional<ExternalIdValue> assetCode = row.v1.assetCode();
LifecyclePhase lifecyclePhase = row.v1.lifecyclePhase();
List<Object> appInfo = asList(appId, appName, assetCode, lifecyclePhase.name());
return map(concat(appInfo, row.v2), value -> {
if (value == null)
return null;
if (value instanceof Optional) {
return ((Optional<?>) value).orElse(null);
} else {
return value;
}
});
}
use of org.finos.waltz.model.application.LifecyclePhase in project waltz by khartec.
the class AppGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
DSLContext dsl = getDsl(ctx);
ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
OrganisationalUnitService ouDao = ctx.getBean(OrganisationalUnitService.class);
List<String> animals = Unchecked.supplier(() -> readLines(getClass().getResourceAsStream("/app-names.txt"))).get();
OrganisationalUnit[] organisationalUnits = ouDao.findAll().toArray(new OrganisationalUnit[0]);
List<AppRegistrationRequest> registrationRequests = new ArrayList<>();
for (int i = 0; i < NUM_APPS; i++) {
String animal = randomPick(animals.toArray(new String[0])) + " - " + i;
OrganisationalUnit organisationalUnit = randomPick(organisationalUnits);
LifecyclePhase phase = rnd.nextInt(10) > 7 ? randomPick(LifecyclePhase.values()) : LifecyclePhase.PRODUCTION;
Criticality businessCriticality = rnd.nextInt(10) > 7 ? randomPick(Criticality.values()) : Criticality.HIGH;
AppRegistrationRequest app = ImmutableAppRegistrationRequest.builder().name(animal).assetCode("wltz-0" + i).description("All about " + animal).applicationKind(randomPick(ApplicationKind.values())).lifecyclePhase(phase).overallRating(randomPick(RagRating.R, RagRating.A, RagRating.A, RagRating.G, RagRating.G)).organisationalUnitId(organisationalUnit.id().get()).businessCriticality(businessCriticality).build();
registrationRequests.add(app);
}
registrationRequests.forEach(a -> applicationDao.registerApp(a, "admin"));
return null;
}
Aggregations