Skip to content

Commit

Permalink
Merge pull request #7074 from deutschebank/db-contrib/waltz-7073-dt-d…
Browse files Browse the repository at this point in the history
…ecorator-ro-flag

Respect the DT decorator r/o flag
  • Loading branch information
davidwatkins73 authored May 20, 2024
2 parents 95e29ba + 4f8ca5b commit 430f8a2
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ public List<DataTypeUsageCharacteristics> findDatatypeUsageCharacteristics(Entit
.select(
LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID,
LOGICAL_FLOW_DECORATOR.IS_READONLY,
LOGICAL_FLOW_DECORATOR.LAST_UPDATED_BY,
LOGICAL_FLOW_DECORATOR.PROVENANCE,
numberOfFlowsSharingDatatype)
.from(LOGICAL_FLOW)
.innerJoin(LOGICAL_FLOW_DECORATOR).on(LOGICAL_FLOW.ID.eq(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID)
Expand All @@ -315,22 +317,58 @@ public List<DataTypeUsageCharacteristics> findDatatypeUsageCharacteristics(Entit
.leftJoin(PHYSICAL_SPEC_DATA_TYPE).on(PHYSICAL_FLOW.SPECIFICATION_ID.eq(PHYSICAL_SPEC_DATA_TYPE.SPECIFICATION_ID)
.and(PHYSICAL_SPEC_DATA_TYPE.DATA_TYPE_ID.eq(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID)))
.where(LOGICAL_FLOW.ID.eq(ref.id()))
.groupBy(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID, LOGICAL_FLOW_DECORATOR.IS_READONLY)
.groupBy(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID, LOGICAL_FLOW_DECORATOR.IS_READONLY, LOGICAL_FLOW_DECORATOR.LAST_UPDATED_BY, LOGICAL_FLOW_DECORATOR.PROVENANCE)
.fetch(r -> {
int usageCount = r.get(numberOfFlowsSharingDatatype);
boolean noUsages = usageCount == 0;
boolean isReadOnly = r.get(LOGICAL_FLOW_DECORATOR.IS_READONLY);
String provenance = r.get(LOGICAL_FLOW_DECORATOR.PROVENANCE);
String lastUpdatedBy = r.get(LOGICAL_FLOW_DECORATOR.LAST_UPDATED_BY);
return ImmutableDataTypeUsageCharacteristics.builder()
.dataTypeId(r.get(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID))
.warningMessageForViewers(usageCount == 0
? "Warning: None of the underlying physical flows reference this data type."
: null)
.warningMessageForEditors(usageCount > 0
? format("Cannot be removed as used in %d physical flows. These must be removed first.", usageCount)
: null)
.isRemovable(usageCount == 0)
.warningMessageForViewers(mkViewerWarningMessage(noUsages, isReadOnly, lastUpdatedBy, provenance))
.warningMessageForEditors(mkEditorWarningMessage(usageCount, isReadOnly, lastUpdatedBy, provenance))
.isRemovable(noUsages && !isReadOnly)
.build();
});
}

private String mkEditorWarningMessage(int usageCount,
boolean isReadOnly,
String lastUpdatedBy,
String provenance) {

StringBuilder buff = new StringBuilder();
if (usageCount > 0 || isReadOnly) {
buff.append("Warning:\n");
}
if (usageCount > 0) {
buff.append(format("- Cannot be removed as used in %d physical flows. The data type mappings on these must be removed first\n", usageCount));
}
if (isReadOnly) {
buff.append(format("- Marked as readonly - <span title='last edited by / provenance' class='text-muted'>%s / %s</span>\n", lastUpdatedBy, provenance));
}
return buff.toString();
}


private String mkViewerWarningMessage(boolean noUsages,
boolean isReadOnly,
String lastUpdatedBy,
String provenance) {
StringBuilder buff = new StringBuilder();
if (noUsages || isReadOnly) {
buff.append("Warning:\n");
}
if (noUsages) {
buff.append("- None of the underlying physical flows reference this data type\n");
}
if (isReadOnly) {
buff.append(format("- Marked as readonly - <span title='last edited by / provenance' class='text-muted'>%s / %s</span>\n", lastUpdatedBy, provenance));
}
return buff.toString();
}


public int updateRatingsByCondition(AuthoritativenessRatingValue rating, Condition condition) {
return dsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
style="vertical-align: middle"
size="xl"/>
</span>
{usageCharacteristics.warningMessageForEditors}
<Markdown inline={true} text={usageCharacteristics.warningMessageForEditors}/>
</div>
</div>
{/if}
Expand All @@ -120,7 +120,7 @@
style="vertical-align: middle"
size="xl"/>
</span>
{usageCharacteristics.warningMessageForViewers}
<Markdown inline={true} text={usageCharacteristics.warningMessageForViewers}/>
</div>
</div>
{/if}
11 changes: 8 additions & 3 deletions waltz-ng/client/common/svelte/DataTypeTreeNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@
function calcDisabled(filterFn, n) {
const isUnchecked = filterFn(n);
return isUnchecked // should be allowed to deselect non-concrete
const cannotCheck = isUnchecked // should be allowed to deselect non-concrete
&& ((!nonConcreteSelectable && !n.concrete) || n.unknown);
const cannotUncheck = ! _.get(n, ["usageCharacteristics", "isRemovable"], true);
return cannotCheck || cannotUncheck;
}
function mkTooltipProps(node) {
return node;
return Object.assign({}, node, {isEditMode: multiSelect});
}
</script>
Expand Down Expand Up @@ -82,6 +86,7 @@
{/if}
{#if node.usageCharacteristics}
<UsageCharacteristicsDecorator usageCharacteristics={node.usageCharacteristics}
isEditMode={multiSelect}
isConcrete={node.concrete}/>
{/if}
</span>
Expand Down Expand Up @@ -138,6 +143,7 @@
{/if}
{#if childNode.usageCharacteristics}
<UsageCharacteristicsDecorator usageCharacteristics={childNode.usageCharacteristics}
isEditMode={multiSelect}
isConcrete={childNode.concrete}/>
{/if}
</div>
Expand Down Expand Up @@ -185,5 +191,4 @@
margin-left: 0;
}
</style>
26 changes: 22 additions & 4 deletions waltz-ng/client/common/svelte/UsageCharacteristicsDecorator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,42 @@
export let isConcrete;
export let isEditMode = false;
</script>
$: isEditable = usageCharacteristics?.isRemovable;
$: isReadonly = ! isEditable;
$: hasViewerMessage = !_.isEmpty(usageCharacteristics.warningMessageForViewers);
$: hasEditorMessage = !_.isEmpty(usageCharacteristics.warningMessageForEditors);
$: hasMapping= !_.isEmpty(usageCharacteristics);
</script>

{#if !isConcrete && !_.isEmpty(usageCharacteristics)}
{#if !isConcrete && hasMapping}
<span class="waltz-error-icon" title="This data type is non-concrete so should not be mapped to">
<Icon name="exclamation-triangle"
style="vertical-align: middle"/>
</span>
{/if}
{#if isEditMode && !_.isEmpty(usageCharacteristics.warningMessageForEditors)}
{#if isEditMode && hasEditorMessage}
<span class="waltz-warning-icon" title={usageCharacteristics.warningMessageForEditors}>
<Icon name="exclamation-triangle"
style="vertical-align: middle"/>
</span>
{/if}
{#if !isEditMode && !_.isEmpty(usageCharacteristics.warningMessageForViewers)}
{#if !isEditMode && hasViewerMessage}
<span class="waltz-warning-icon" title={usageCharacteristics.warningMessageForViewers}>
<Icon name="exclamation-triangle"
style="vertical-align: middle"/>
</span>
{/if}
{#if !isEditMode && isReadonly && hasViewerMessage}
<span title="read only" style="color: #777;">
<Icon name="lock"
style="vertical-align: middle"/>
</span>
{/if}
{#if isEditMode && isReadonly}
<span title="read only" style="color: #777;">
<Icon name="lock"
style="vertical-align: middle"/>
</span>
{/if}

0 comments on commit 430f8a2

Please sign in to comment.