Search in sources :

Example 1 with SoftwarePackage

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");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DatabaseInformationRecord(com.khartec.waltz.schema.tables.records.DatabaseInformationRecord) DSLContext(org.jooq.DSLContext) SoftwarePackage(com.khartec.waltz.model.software_catalog.SoftwarePackage) LinkedList(java.util.LinkedList) Date(java.sql.Date) LocalDate(java.time.LocalDate)

Example 2 with SoftwarePackage

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");
}
Also used : SoftwarePackageDao(com.khartec.waltz.data.software_catalog.SoftwarePackageDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) SoftwarePackage(com.khartec.waltz.model.software_catalog.SoftwarePackage)

Example 3 with SoftwarePackage

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");
}
Also used : SoftwarePackageDao(com.khartec.waltz.data.software_catalog.SoftwarePackageDao) IntStream(java.util.stream.IntStream) SoftwarePackageDao(com.khartec.waltz.data.software_catalog.SoftwarePackageDao) ApplicationDao(com.khartec.waltz.data.application.ApplicationDao) SoftwareUsageRecord(com.khartec.waltz.schema.tables.records.SoftwareUsageRecord) ListUtilities(com.khartec.waltz.common.ListUtilities) Random(java.util.Random) Collectors(java.util.stream.Collectors) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) List(java.util.List) DIConfiguration(com.khartec.waltz.service.DIConfiguration) SoftwarePackage(com.khartec.waltz.model.software_catalog.SoftwarePackage) DSLContext(org.jooq.DSLContext) SOFTWARE_USAGE(com.khartec.waltz.schema.tables.SoftwareUsage.SOFTWARE_USAGE) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Random(java.util.Random) DSLContext(org.jooq.DSLContext) SoftwareUsageRecord(com.khartec.waltz.schema.tables.records.SoftwareUsageRecord) ApplicationDao(com.khartec.waltz.data.application.ApplicationDao) SoftwarePackage(com.khartec.waltz.model.software_catalog.SoftwarePackage)

Aggregations

SoftwarePackage (com.khartec.waltz.model.software_catalog.SoftwarePackage)3 DSLContext (org.jooq.DSLContext)3 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 SoftwarePackageDao (com.khartec.waltz.data.software_catalog.SoftwarePackageDao)2 ListUtilities (com.khartec.waltz.common.ListUtilities)1 ApplicationDao (com.khartec.waltz.data.application.ApplicationDao)1 SOFTWARE_USAGE (com.khartec.waltz.schema.tables.SoftwareUsage.SOFTWARE_USAGE)1 DatabaseInformationRecord (com.khartec.waltz.schema.tables.records.DatabaseInformationRecord)1 SoftwareUsageRecord (com.khartec.waltz.schema.tables.records.SoftwareUsageRecord)1 DIConfiguration (com.khartec.waltz.service.DIConfiguration)1 Date (java.sql.Date)1 LocalDate (java.time.LocalDate)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1