use of com.khartec.waltz.schema.tables.records.PhysicalSpecificationRecord in project waltz by khartec.
the class PhysicalSpecificationDao method create.
public Long create(PhysicalSpecification specification) {
checkNotNull(specification, "specification cannot be null");
checkFalse(specification.id().isPresent(), "specification must not have an id");
PhysicalSpecificationRecord record = dsl.newRecord(PHYSICAL_SPECIFICATION);
record.setOwningEntityKind(specification.owningEntity().kind().name());
record.setOwningEntityId(specification.owningEntity().id());
record.setName(specification.name());
record.setExternalId(specification.externalId().orElse(""));
record.setDescription(specification.description());
record.setFormat(specification.format().name());
record.setLastUpdatedAt(Timestamp.valueOf(specification.lastUpdatedAt()));
record.setLastUpdatedBy(specification.lastUpdatedBy());
record.setIsRemoved(specification.isRemoved());
record.setProvenance("waltz");
record.store();
return record.getId();
}
use of com.khartec.waltz.schema.tables.records.PhysicalSpecificationRecord 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");
}
Aggregations