use of org.finos.waltz.schema.tables.records.LogicalFlowRecord in project waltz by khartec.
the class LogicalFlowGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
FlowClassificationRuleDao flowClassificationRuleDao = ctx.getBean(FlowClassificationRuleDao.class);
ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<FlowClassificationRule> flowClassificationRules = flowClassificationRuleDao.findByEntityKind(EntityKind.ORG_UNIT);
List<Application> apps = applicationDao.findAll();
List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();
LocalDateTime now = LocalDateTime.now();
Set<LogicalFlow> expectedFlows = flowClassificationRules.stream().flatMap(a -> {
long orgUnitId = a.parentReference().id();
return randomlySizedIntStream(0, 40).mapToObj(i -> randomAppPick(apps, orgUnitId).map(target -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null));
}).filter(Objects::nonNull).collect(toSet());
Set<LogicalFlow> probableFlows = flowClassificationRules.stream().flatMap(a -> randomlySizedIntStream(0, 30).mapToObj(i -> randomAppPick(apps, randomPick(orgUnits).id().get()).map(target -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null))).filter(Objects::nonNull).collect(toSet());
Set<LogicalFlow> randomFlows = apps.stream().flatMap(a -> randomlySizedIntStream(0, 5).mapToObj(i -> randomAppPick(apps, randomPick(orgUnits).id().get()).map(target -> ImmutableLogicalFlow.builder().source(a.entityReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null))).filter(Objects::nonNull).collect(toSet());
Set<LogicalFlow> all = new HashSet<>();
all.addAll(randomFlows);
all.addAll(expectedFlows);
all.addAll(probableFlows);
Set<LogicalFlow> deduped = uniqBy(all, x -> Tuple.tuple(x.source(), x.target()));
log("--- saving: " + deduped.size());
Set<LogicalFlowRecord> records = SetUtilities.map(deduped, df -> LogicalFlowDao.TO_RECORD_MAPPER.apply(df, dsl));
dsl.batchStore(records).execute();
log("--- done");
return null;
}
use of org.finos.waltz.schema.tables.records.LogicalFlowRecord in project waltz by khartec.
the class LogicalFlowDao method addFlow.
public LogicalFlow addFlow(LogicalFlow flow) {
if (restoreFlow(flow, flow.lastUpdatedBy())) {
return getBySourceAndTarget(flow.source(), flow.target());
} else {
LogicalFlowRecord record = TO_RECORD_MAPPER.apply(flow, dsl);
record.store();
return ImmutableLogicalFlow.copyOf(flow).withId(record.getId());
}
}
use of org.finos.waltz.schema.tables.records.LogicalFlowRecord in project waltz by khartec.
the class WaltzUtilities method mkLogicalFlowRecord.
public static LogicalFlowRecord mkLogicalFlowRecord(long sourceAppId, long targetAppId, String provenance) {
LogicalFlowRecord record = new LogicalFlowRecord();
record.setSourceEntityId(sourceAppId);
record.setTargetEntityId(targetAppId);
record.setSourceEntityKind(EntityKind.APPLICATION.name());
record.setTargetEntityKind(EntityKind.APPLICATION.name());
record.setCreatedBy("admin");
record.setCreatedAt(nowUtcTimestamp());
record.setLastUpdatedBy("admin");
record.setLastUpdatedAt(nowUtcTimestamp());
record.setProvenance(provenance);
record.setEntityLifecycleStatus(EntityLifecycleStatus.ACTIVE.name());
record.setIsRemoved(false);
return record;
}
Aggregations