use of com.khartec.waltz.schema.tables.SoftwareUsage.SOFTWARE_USAGE in project waltz by khartec.
the class SoftwareUsageGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
SoftwarePackageDao softwarePackageDao = ctx.getBean(SoftwarePackageDao.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
ApplicationDao applicationDao = ctx.getBean(ApplicationDao.class);
List<SoftwarePackage> allSoftware = softwarePackageDao.findAll();
List<SoftwareUsageRecord> records = applicationDao.getAll().stream().flatMap(app -> IntStream.range(0, new Random().nextInt(4) + 1).mapToObj(x -> new SoftwareUsageRecord(app.id().get(), ListUtilities.randomPick(allSoftware).id().get(), "waltz-random"))).collect(Collectors.toList());
System.out.println("-- deleting all software usages");
dsl.deleteFrom(SOFTWARE_USAGE).where(SOFTWARE_USAGE.PROVENANCE.eq("waltz-sample")).execute();
System.out.println(" -- storing usages ( " + records.size() + " )");
dsl.batchInsert(records).execute();
System.out.println(" -- done");
}
Aggregations