use of com.khartec.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 = ctx.getBean(ApplicationIdSelectorFactory.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
IdSelectionOptions options = IdSelectionOptions.mkOpts(EntityReference.mkRef(EntityKind.MEASURABLE, 1L), HierarchyQueryScope.EXACT);
Select<Record1<Long>> selector = factory.apply(options);
System.out.println(selector);
List<Application> apps = applicationService.findByAppIdSelector(options);
System.out.println("--- sz: " + apps.size());
apps.forEach(System.out::println);
System.out.println("--- done");
}
use of com.khartec.waltz.service.application.ApplicationService in project waltz by khartec.
the class AppGenerator method main.
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
OrganisationalUnitService ouDao = ctx.getBean(OrganisationalUnitService.class);
List<String> animals = IOUtilities.readLines(AppGenerator.class.getClassLoader().getResourceAsStream("animals.txt"));
OrganisationalUnit[] organisationalUnits = ouDao.findAll().toArray(new OrganisationalUnit[0]);
List<AppRegistrationRequest> registrationRequests = new ArrayList<>();
for (int i = 0; i < 5000; 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);
}
dsl.deleteFrom(AUTHORITATIVE_SOURCE).execute();
dsl.deleteFrom(APPLICATION).execute();
registrationRequests.forEach(a -> applicationDao.registerApp(a, "admin"));
}
use of com.khartec.waltz.service.application.ApplicationService in project waltz by khartec.
the class AssetCostGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
ApplicationService applicationService = ctx.getBean(ApplicationService.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<AssetCostRecord> appDevCosts = generateRecords(applicationService, "APPLICATION_DEVELOPMENT", 100_0000);
List<AssetCostRecord> infraCosts = generateRecords(applicationService, "INFRASTRUCTURE", 5_000);
dsl.deleteFrom(ASSET_COST).where(ASSET_COST.YEAR.eq(year)).and(ASSET_COST.PROVENANCE.eq(provenance)).execute();
dsl.batchInsert(appDevCosts).execute();
dsl.batchInsert(infraCosts).execute();
}
use of com.khartec.waltz.service.application.ApplicationService in project waltz by khartec.
the class FlowGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
AuthoritativeSourceDao authSourceDao = ctx.getBean(AuthoritativeSourceDao.class);
ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
LogicalFlowService dataFlowDao = ctx.getBean(LogicalFlowService.class);
OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<AuthoritativeSource> authSources = authSourceDao.findByEntityKind(EntityKind.ORG_UNIT);
List<Application> apps = applicationDao.findAll();
List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();
Set<LogicalFlow> expectedFlows = authSources.stream().flatMap(a -> {
long orgUnitId = a.parentReference().id();
return IntStream.range(0, rnd.nextInt(40)).mapToObj(i -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(randomAppPick(apps, orgUnitId)).build());
}).collect(toSet());
Set<LogicalFlow> probableFlows = authSources.stream().flatMap(a -> IntStream.range(0, rnd.nextInt(30)).mapToObj(i -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(randomAppPick(apps, randomPick(orgUnits).id().get())).build())).collect(toSet());
Set<LogicalFlow> randomFlows = apps.stream().flatMap(a -> IntStream.range(0, rnd.nextInt(5)).mapToObj(i -> {
EntityReference target = randomAppPick(apps, randomPick(orgUnits).id().get());
return ImmutableLogicalFlow.builder().source(a.entityReference()).target(target).lastUpdatedBy("admin").build();
})).collect(toSet());
dsl.deleteFrom(LOGICAL_FLOW).execute();
Set<LogicalFlow> all = new HashSet<>();
all.addAll(randomFlows);
all.addAll(expectedFlows);
all.addAll(probableFlows);
System.out.println("--- saving: " + all.size());
Set<LogicalFlowRecord> records = SetUtilities.map(all, df -> LogicalFlowDao.TO_RECORD_MAPPER.apply(df, dsl));
dsl.batchStore(records).execute();
System.out.println("--- done");
}
use of com.khartec.waltz.service.application.ApplicationService in project waltz by khartec.
the class AdditiveFlowGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
AuthoritativeSourceDao authSourceDao = ctx.getBean(AuthoritativeSourceDao.class);
ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
LogicalFlowService dataFlowDao = ctx.getBean(LogicalFlowService.class);
OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<AuthoritativeSource> authSources = authSourceDao.findByEntityKind(EntityKind.ORG_UNIT);
List<Application> apps = applicationDao.findAll();
Application referenceApplication = applicationDao.getById(APPLICATION_ID);
List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();
Set<LogicalFlow> expectedFlows = authSources.stream().map(a -> {
long orgUnitId = a.parentReference().id();
if (referenceApplication.organisationalUnitId().equals(orgUnitId)) {
return Optional.of(ImmutableLogicalFlow.builder().source(a.applicationReference()).target(referenceApplication.entityReference()).build());
} else {
return Optional.<LogicalFlow>empty();
}
}).filter(o -> o.isPresent()).map(o -> o.get()).collect(toSet());
Set<LogicalFlow> randomTargetFlows = IntStream.range(0, rnd.nextInt(APPROX_FLOW_GENERATION_COUNT / 2)).mapToObj(i -> {
EntityReference target = randomAppPick(apps, randomPick(orgUnits).id().get());
return ImmutableLogicalFlow.builder().source(referenceApplication.entityReference()).target(target).build();
}).collect(toSet());
Set<LogicalFlow> randomSourceFlows = IntStream.range(0, rnd.nextInt(APPROX_FLOW_GENERATION_COUNT / 2)).mapToObj(i -> {
EntityReference source = randomAppPick(apps, randomPick(orgUnits).id().get());
return ImmutableLogicalFlow.builder().source(source).target(referenceApplication.entityReference()).build();
}).collect(toSet());
dsl.delete(LOGICAL_FLOW).where(LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(APPLICATION_ID)).or(LOGICAL_FLOW.TARGET_ENTITY_ID.eq(APPLICATION_ID)).execute();
Set<LogicalFlow> all = new HashSet<>();
all.addAll(randomTargetFlows);
all.addAll(randomSourceFlows);
all.addAll(expectedFlows);
System.out.println("--- saving: " + all.size());
Set<LogicalFlowRecord> records = SetUtilities.map(all, df -> LogicalFlowDao.TO_RECORD_MAPPER.apply(df, dsl));
dsl.batchStore(records).execute();
System.out.println("--- done");
}
Aggregations