use of org.jooq.DSLContext in project waltz by khartec.
the class MeasurablesGenerator method main.
public static void main(String[] args) throws IOException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
generateRegions(dsl);
}
use of org.jooq.DSLContext in project waltz by khartec.
the class PhysicalFlowGenerator method main.
public static void main(String[] args) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<PhysicalSpecification> specifications = dsl.select(PHYSICAL_SPECIFICATION.fields()).select(owningEntityNameField).from(PHYSICAL_SPECIFICATION).fetch(PhysicalSpecificationDao.TO_DOMAIN_MAPPER);
List<Tuple2<Long, EntityReference>> allLogicalFLows = dsl.select(LOGICAL_FLOW.ID, LOGICAL_FLOW.SOURCE_ENTITY_ID, LOGICAL_FLOW.SOURCE_ENTITY_KIND).from(LOGICAL_FLOW).fetch(r -> Tuple.tuple(r.getValue(LOGICAL_FLOW.ID), mkRef(EntityKind.valueOf(r.getValue(LOGICAL_FLOW.SOURCE_ENTITY_KIND)), r.getValue(LOGICAL_FLOW.SOURCE_ENTITY_ID))));
Map<EntityReference, Collection<Long>> flowIdsBySource = groupBy(t -> t.v2(), t -> t.v1(), allLogicalFLows);
System.out.println("---removing demo records");
dsl.deleteFrom(PHYSICAL_FLOW).where(PHYSICAL_FLOW.PROVENANCE.eq(provenance)).execute();
final int flowBatchSize = 100000;
List<PhysicalFlowRecord> flowBatch = new ArrayList<PhysicalFlowRecord>((int) (flowBatchSize * 1.2));
for (PhysicalSpecification spec : specifications) {
Collection<Long> flowIds = flowIdsBySource.get(spec.owningEntity());
if (!isEmpty(flowIds)) {
List<PhysicalFlowRecord> physicalFlowRecords = mkPhysicalFlowRecords(spec, new LinkedList<>(flowIds));
flowBatch.addAll(physicalFlowRecords);
}
if (flowBatch.size() >= flowBatchSize) {
System.out.println(String.format("--- saving records: count: %s", flowBatch.size()));
dsl.batchInsert(flowBatch).execute();
flowBatch.clear();
}
}
System.out.println(String.format("--- saving records: count: %s", flowBatch.size()));
dsl.batchInsert(flowBatch).execute();
flowBatch.clear();
System.out.println("---done");
}
use of org.jooq.DSLContext in project waltz by khartec.
the class PhysicalSpecificationGenerator method main.
public static void main(String[] args) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<Long> appIds = dsl.select(APPLICATION.ID).from(APPLICATION).fetch(APPLICATION.ID);
List<PhysicalSpecificationRecord> records = appIds.stream().flatMap(appId -> IntStream.range(0, rnd.nextInt(4)).mapToObj(i -> tuple(appId, i))).map(t -> {
String name = mkName(t.v2);
PhysicalSpecificationRecord record = dsl.newRecord(PHYSICAL_SPECIFICATION);
record.setOwningEntityId(t.v1);
record.setOwningEntityKind(EntityKind.APPLICATION.name());
record.setFormat(randomPick(DataFormatKind.values()).name());
record.setProvenance("DEMO");
record.setDescription("Desc " + name + " " + t.v2);
record.setName(name);
record.setExternalId("ext-" + t.v1 + "." + t.v2);
record.setLastUpdatedBy("admin");
return record;
}).collect(Collectors.toList());
System.out.println("---deleting old demo records");
dsl.deleteFrom(PHYSICAL_SPECIFICATION).where(PHYSICAL_SPECIFICATION.PROVENANCE.eq("DEMO")).execute();
System.out.println("---saving: " + records.size());
dsl.batchInsert(records).execute();
System.out.println("---done");
}
use of org.jooq.DSLContext in project waltz by khartec.
the class ProcessGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
Set<TableRecord<?>> records = new HashSet<>();
for (long g = 1; g < 5; g++) {
ProcessRecord record = new ProcessRecord();
record.setDescription("Process Group: " + g);
record.setName("Process Group " + g);
record.setId(g);
record.setLevel(1);
record.setLevel_1(g);
records.add(record);
for (long p = 0; p < 10; p++) {
long id = (g * 100) + p;
ProcessRecord record2 = new ProcessRecord();
String name = randomPick(p1) + " " + randomPick(p2);
record2.setDescription("Process: " + name);
record2.setName(name);
record2.setId(id);
record2.setParentId(g);
record2.setLevel(2);
record2.setLevel_1(g);
record2.setLevel_2(id);
records.add(record2);
}
}
System.out.println("-- deleting");
dsl.deleteFrom(PROCESS).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 ServerGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
ServerInformationDao serverDao = ctx.getBean(ServerInformationDao.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
dsl.delete(SERVER_INFORMATION).where(SERVER_INFORMATION.PROVENANCE.eq("RANDOM_GENERATOR")).execute();
commonHostNames.clear();
List<ServerInformation> servers = ListUtilities.newArrayList();
IntStream.range(0, 10_000).forEach(i -> {
String hostName = mkHostName(i);
boolean isCommonHost = commonHostNames.contains(hostName);
servers.add(ImmutableServerInformation.builder().hostname(hostName).environment(isCommonHost ? SampleData.environments[0] : randomPick(SampleData.environments)).location(isCommonHost ? SampleData.locations[0] : randomPick(SampleData.locations)).operatingSystem(isCommonHost ? SampleData.operatingSystems[0] : randomPick(SampleData.operatingSystems)).operatingSystemVersion(isCommonHost ? SampleData.operatingSystemVersions[0] : randomPick(SampleData.operatingSystemVersions)).country("UK").assetCode("wltz-0" + rnd.nextInt(4000)).hardwareEndOfLifeDate(rnd.nextInt(10) > 5 ? Date.valueOf(LocalDate.now().plusMonths(rnd.nextInt(12 * 6) - (12 * 3))) : null).operatingSystemEndOfLifeDate(rnd.nextInt(10) > 5 ? Date.valueOf(LocalDate.now().plusMonths(rnd.nextInt(12 * 6) - (12 * 3))) : null).virtual(isCommonHost || rnd.nextInt(10) > 7).provenance("RANDOM_GENERATOR").lifecycleStatus(randomPick(LifecycleStatus.values())).build());
});
// servers.forEach(System.out::println);
serverDao.bulkSave(servers);
}
Aggregations