use of org.jooq.DSLContext in project waltz by khartec.
the class ChangeInitiativeGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<Long> groupIds = dsl.select(APPLICATION_GROUP.ID).from(APPLICATION_GROUP).fetch(APPLICATION_GROUP.ID);
List<String> employeeIds = dsl.select(PERSON.EMPLOYEE_ID).from(PERSON).fetch(PERSON.EMPLOYEE_ID);
List<Long> orgUnitIds = dsl.select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT).fetch(ORGANISATIONAL_UNIT.ID);
List<TableRecord<?>> records = LongStream.range(0, 400).mapToObj(i -> {
String name = randomPick(p1) + " " + randomPick(p2) + " " + randomPick(p3);
Long ouId = randomPick(orgUnitIds.toArray(new Long[0]));
return Tuple.tuple(i, name, ouId);
}).map(t -> buildChangeInitiativeRecord(t)).flatMap(r -> Stream.concat(Stream.of(r), buildLinks(r, groupIds, employeeIds))).collect(toList());
System.out.println("-- deleting");
dsl.deleteFrom(CHANGE_INITIATIVE).execute();
System.out.println("-- inserting");
dsl.batchInsert(records).execute();
System.out.println(" -- done");
}
use of org.jooq.DSLContext in project waltz by khartec.
the class ChangeLogGenerator method main.
public static void main(String[] args) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
// get applications and emails
List<Long> appIds = dsl.select(APPLICATION.ID).from(APPLICATION).fetch(APPLICATION.ID);
List<String> emails = dsl.select(PERSON.EMAIL).from(PERSON).fetch(PERSON.EMAIL);
Set<ChangeLogRecord> records = emails.stream().flatMap(email -> Stream.of(mkChangeLog(randomPick(appIds), email), mkChangeLog(randomPick(appIds), randomPick(emails)))).collect(toSet());
dsl.deleteFrom(CHANGE_LOG).execute();
dsl.batchInsert(records).execute();
System.out.println("Inserted " + records.size() + " change log entries");
}
use of org.jooq.DSLContext in project waltz by khartec.
the class DataTypeGenerator method main.
public static void main(String[] args) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
dsl.deleteFrom(DATA_TYPE).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "BOOK").set(DATA_TYPE.DESCRIPTION, "Book Data").set(DATA_TYPE.NAME, "Book Data").set(DATA_TYPE.ID, 1000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "PARTY").set(DATA_TYPE.DESCRIPTION, "Party Data").set(DATA_TYPE.NAME, "Counterparty etc.").set(DATA_TYPE.ID, 2000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "PRICING").set(DATA_TYPE.DESCRIPTION, "Pricing Data").set(DATA_TYPE.NAME, "Pricing Data").set(DATA_TYPE.ID, 3000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "TRADE").set(DATA_TYPE.DESCRIPTION, "Trade Data").set(DATA_TYPE.NAME, "Transactions etc.").set(DATA_TYPE.ID, 4000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "RATE").set(DATA_TYPE.DESCRIPTION, "Rates").set(DATA_TYPE.NAME, "Interest rates etc").set(DATA_TYPE.ID, 5000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "CURRENCY").set(DATA_TYPE.DESCRIPTION, "Currency").set(DATA_TYPE.NAME, "Currencies etc").set(DATA_TYPE.ID, 6000L).execute();
dsl.insertInto(DATA_TYPE).set(DATA_TYPE.CODE, "VIRTUAL_CURRENCIES").set(DATA_TYPE.DESCRIPTION, "Virtual Currencies eg: Bitcoin").set(DATA_TYPE.NAME, "Virtual Currencies").set(DATA_TYPE.ID, 6100L).set(DATA_TYPE.PARENT_ID, 6000L).execute();
}
use of org.jooq.DSLContext 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 org.jooq.DSLContext in project waltz by khartec.
the class EndUserAppInvolvmentGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<Long> appIds = dsl.select(END_USER_APPLICATION.ID).from(END_USER_APPLICATION).fetch(END_USER_APPLICATION.ID);
List<String> empIds = dsl.select(PERSON.EMPLOYEE_ID).from(PERSON).innerJoin(PERSON_HIERARCHY).on(PERSON.EMPLOYEE_ID.eq(PERSON_HIERARCHY.EMPLOYEE_ID)).where(PERSON_HIERARCHY.LEVEL.lt(4)).fetch(PERSON.EMPLOYEE_ID);
List<InvolvementRecord> records = ListUtilities.map(appIds, id -> {
InvolvementRecord record = dsl.newRecord(INVOLVEMENT);
record.setProvenance("RANDOM_GENERATOR");
record.setEmployeeId(randomPick(empIds));
record.setEntityId(id);
record.setEntityKind(EntityKind.END_USER_APPLICATION.name());
record.setKindId(Long.valueOf(rnd.nextInt(13) + 1));
return record;
});
System.out.println("---saving: " + records.size());
dsl.batchInsert(records).execute();
System.out.println("---done");
}
Aggregations