use of com.khartec.waltz.model.software_catalog.SoftwarePackage in project waltz by khartec.
the class DatabaseGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<String> codes = dsl.select(APPLICATION.ASSET_CODE).from(APPLICATION).fetch(APPLICATION.ASSET_CODE);
List<DatabaseInformationRecord> databaseRecords = new LinkedList<>();
for (int i = 0; i < 300; i++) {
int num = rnd.nextInt(10);
for (int j = 0; j < num; j++) {
SoftwarePackage pkg = ArrayUtilities.randomPick(DatabaseSoftwarePackages.dbs);
DatabaseInformationRecord databaseRecord = dsl.newRecord(DATABASE_INFORMATION);
databaseRecord.setDatabaseName("DB_LON_" + i + "_" + j);
databaseRecord.setInstanceName("DB_INST_" + i);
databaseRecord.setEnvironment(ArrayUtilities.randomPick("PROD", "PROD", "QA", "DEV", "DEV"));
databaseRecord.setDbmsVendor(pkg.vendor());
databaseRecord.setDbmsName(pkg.name());
databaseRecord.setDbmsVersion(pkg.version());
databaseRecord.setExternalId("ext_" + i + "_" + j);
databaseRecord.setProvenance("RANDOM_GENERATOR");
databaseRecord.setAssetCode(randomPick(codes));
databaseRecord.setLifecycleStatus(ArrayUtilities.randomPick(LifecycleStatus.values()).toString());
databaseRecord.setEndOfLifeDate(rnd.nextInt(10) > 5 ? Date.valueOf(LocalDate.now().plusMonths(rnd.nextInt(12 * 6) - (12 * 3))) : null);
databaseRecords.add(databaseRecord);
}
}
// insert duplicate database instance records (more than one app using the same database)
SoftwarePackage dupDbPackage = ArrayUtilities.randomPick(DatabaseSoftwarePackages.dbs);
String dupDbEnvironment = ArrayUtilities.randomPick("PROD", "PROD", "QA", "DEV", "DEV");
Date dupDbEolDate = rnd.nextInt(10) > 5 ? Date.valueOf(LocalDate.now().plusMonths(rnd.nextInt(12 * 6) - (12 * 3))) : null;
for (int i = 0; i < 10; i++) {
DatabaseInformationRecord databaseRecord = dsl.newRecord(DATABASE_INFORMATION);
databaseRecord.setDatabaseName("DB_LON_REF_DATA");
databaseRecord.setInstanceName("DB_INST_REF_DATA");
databaseRecord.setEnvironment(dupDbEnvironment);
databaseRecord.setDbmsVendor(dupDbPackage.vendor());
databaseRecord.setDbmsName(dupDbPackage.name());
databaseRecord.setDbmsVersion(dupDbPackage.version());
databaseRecord.setExternalId("ext_ref_data");
databaseRecord.setProvenance("RANDOM_GENERATOR");
databaseRecord.setAssetCode(randomPick(codes));
databaseRecord.setLifecycleStatus(ArrayUtilities.randomPick(LifecycleStatus.values()).toString());
databaseRecord.setEndOfLifeDate(dupDbEolDate);
databaseRecords.add(databaseRecord);
}
System.out.println("-- deleting db records");
dsl.deleteFrom(DATABASE_INFORMATION).where(DATABASE_INFORMATION.PROVENANCE.eq("RANDOM_GENERATOR")).execute();
System.out.println("-- storing db records ( " + databaseRecords.size() + " )");
databaseRecords.forEach(r -> r.store());
System.out.println("-- done inserting db records");
System.out.println("-- done");
}
use of com.khartec.waltz.model.software_catalog.SoftwarePackage in project waltz by khartec.
the class SoftwarePackageGenerator 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);
List<SoftwarePackage> softwarePackages = ListUtilities.builder(SoftwarePackage.class).addAll(DatabaseSoftwarePackages.dbs).addAll(AppServerSoftwarePackages.appServers).addAll(MiddlewareSoftwarePackages.middleware).build();
System.out.println("-- deleting all software packages");
dsl.deleteFrom(SOFTWARE_PACKAGE).where(SOFTWARE_PACKAGE.PROVENANCE.eq(SampleDataUtilities.SAMPLE_DATA_PROVENANCE)).execute();
System.out.println(" -- storing packages ( " + softwarePackages.size() + " )");
softwarePackageDao.bulkStore(softwarePackages);
System.out.println(" -- done");
}
use of com.khartec.waltz.model.software_catalog.SoftwarePackage 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