use of org.finos.waltz.schema.tables.records.EntityRelationshipRecord in project waltz by khartec.
the class ChangeInitiativeGenerator method buildEntityRelationships.
private static Stream<TableRecord<?>> buildEntityRelationships(EntityKind kind, String relKind, List<Long> ciIds, List<Long> targetIds, double ratioWithCi, int maxLinks) {
List<Tuple2<Long, Long>> targetAndCiIds = targetIds.stream().flatMap(targetId -> RND.nextDouble() <= ratioWithCi ? randomPick(ciIds, RND.nextInt(maxLinks)).stream().map(ciId -> tuple(targetId, ciId)) : Stream.empty()).distinct().collect(toList());
LOG.info("Creating {} records for relationship kind: {}", targetAndCiIds.size(), kind);
return targetAndCiIds.stream().map(t -> {
EntityRelationshipRecord record = new EntityRelationshipRecord();
record.setKindA(kind.name());
record.setIdA(t.v1);
record.setKindB(EntityKind.CHANGE_INITIATIVE.name());
record.setIdB(t.v2);
record.setRelationship(relKind);
record.setProvenance(SAMPLE_DATA_PROVENANCE);
return record;
});
}
Aggregations