Skip to content

Commit

Permalink
Merge pull request #6067 from davidwatkins73/waltz-6065-flow-export-bug
Browse files Browse the repository at this point in the history
Fixing flow export
  • Loading branch information
jessica-woodland-scott-db authored May 24, 2022
2 parents 8d3b7b3 + cbf4bd3 commit e0add81
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public Map<EntityReference, Collection<EntityReference>> calculateConsumersForDa
applicationNameField)
.from(LOGICAL_FLOW)
.innerJoin(LOGICAL_FLOW_DECORATOR).on(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID.eq(LOGICAL_FLOW.ID))
.innerJoin(FLOW_CLASSIFICATION).on(flowClassificationRuleJoin)
.innerJoin(FLOW_CLASSIFICATION_RULE).on(flowClassificationRuleJoin)
.innerJoin(ENTITY_HIERARCHY).on(hierarchyJoin)
.innerJoin(APPLICATION).on(appJoin)
.where(condition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private Stream<EntityHierarchyItem> streamSelf(EntityKind kind,
.id(nodeId)
.parentId(nodeId)
.ancestorLevel(level == null ? -1 : level)
.descendantLevel(idToLevel.get(node.getId()))
.descendantLevel(idToLevel.getOrDefault(node.getId(), -1))
.kind(kind)
.build();
return Stream.of(selfAsEntityHierarchyItem);
Expand All @@ -238,7 +238,7 @@ private Stream<EntityHierarchyItem> streamAncestors(EntityKind kind,
.id(node.getId())
.parentId(p.getId())
.ancestorLevel(idToLevel.get(p.getId()))
.descendantLevel(idToLevel.get(node.getId()))
.descendantLevel(idToLevel.getOrDefault(node.getId(), -1))
.kind(kind)
.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,14 @@
@Service
public class PhysicalFlowExtractor extends CustomDataExtractor {

private DSLContext dsl;
private final PhysicalFlowIdSelectorFactory physicalFlowIdSelectorFactory = new PhysicalFlowIdSelectorFactory();

private static List<Field> RECEIVER_NAME_AND_ASSET_CODE_FIELDS;
private static List<Field> SOURCE_NAME_AND_ASSET_CODE_FIELDS;
private static List<Field> SOURCE_AND_TARGET_NAME_AND_ASSET_CODE;
private static List<String> staticHeaders = newArrayList(
"Name",
"External Id",
"Source",
"Source Asset Code",
"Receiver",
"Receiver Asset Code",
"Format",
"Transport",
"Frequency",
"Criticality",
"Freshness Indicator",
"Description");
private static final List<Field<String>> RECEIVER_NAME_AND_ASSET_CODE_FIELDS;
private static final List<Field<String>> SOURCE_NAME_AND_ASSET_CODE_FIELDS;
private static final List<Field<String>> SOURCE_AND_TARGET_NAME_AND_ASSET_CODE;
private static final PhysicalFlowIdSelectorFactory physicalFlowIdSelectorFactory = new PhysicalFlowIdSelectorFactory();


private final DSLContext dsl;


static {
Field<String> SOURCE_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
Expand Down Expand Up @@ -251,11 +240,15 @@ private Tuple3<ExtractFormat, String, byte[]> preparePhysicalFlows(SelectConditi

List<List<Object>> reportRows = prepareReportRows(query, tags);

List<String> headers = ListUtilities.map(
query.getSelect(),
Field::getName);

return formatReport(
format,
reportName,
reportRows,
ListUtilities.append(staticHeaders, "Tags")
ListUtilities.append(headers, "Tags")
);
}

Expand All @@ -266,8 +259,9 @@ private List<List<Object>> prepareReportRows(SelectConditionStep<Record> qry,
return results
.stream()
.map(row -> {
ArrayList<Object> reportRow = new ArrayList<>();
staticHeaders.forEach(h -> reportRow.add(row.get(h)));
List<Object> reportRow = ListUtilities.map(
qry.getSelect(),
row::get);
Long physicalFlowId = row.get(PHYSICAL_FLOW.ID);
List<String> physicalFlowTags = tags.get(physicalFlowId);
reportRow.add(isEmpty(physicalFlowTags)
Expand Down

0 comments on commit e0add81

Please sign in to comment.