Skip to content

Commit

Permalink
Pull request #365: CTCTOWALTZ-3094 make fcr visible in data type editor
Browse files Browse the repository at this point in the history
Merge in WALTZ/waltz from WALTZ/waltz-jws:CTCTOWALTZ-3094-make-fcr-visible-in-data-type-editor to db-feature/waltz-7053-visualise-inbound-ratings-datatype-selector

* commit '84891c7aa8257c93503ac3a4162dd3b59a96a387':
  Return rating classifications for source and target
  Return rating classifications for source and target
  Return rating classifications for source and target
  Enhance data type selector panel for flows
  Return rating classifications for source and target
  • Loading branch information
jessica-woodland-scott-db authored and db-waltz committed Apr 15, 2024
2 parents 293dda5 + 84891c7 commit 8e73fb9
Show file tree
Hide file tree
Showing 19 changed files with 534 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.finos.waltz.model.datatype.ImmutableDataTypeDecorator;
import org.finos.waltz.model.datatype.ImmutableDataTypeUsageCharacteristics;
import org.finos.waltz.model.datatype.ImmutableFlowDataType;
import org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint;
import org.finos.waltz.model.rating.AuthoritativenessRatingValue;
import org.finos.waltz.schema.Tables;
import org.finos.waltz.schema.tables.Application;
Expand All @@ -45,10 +44,7 @@
import org.jooq.Record1;
import org.jooq.RecordMapper;
import org.jooq.Select;
import org.jooq.SelectConditionStep;
import org.jooq.Update;
import org.jooq.impl.DSL;
import org.jooq.lambda.function.Function2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

Expand All @@ -69,16 +65,13 @@
import static org.finos.waltz.model.EntityKind.LOGICAL_DATA_FLOW;
import static org.finos.waltz.model.EntityReference.mkRef;
import static org.finos.waltz.schema.Tables.PHYSICAL_FLOW;
import static org.finos.waltz.schema.tables.Application.APPLICATION;
import static org.finos.waltz.schema.tables.EntityHierarchy.ENTITY_HIERARCHY;
import static org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW;
import static org.finos.waltz.schema.tables.LogicalFlowDecorator.LOGICAL_FLOW_DECORATOR;
import static org.finos.waltz.schema.tables.PhysicalSpecDataType.PHYSICAL_SPEC_DATA_TYPE;


@Repository
public class LogicalFlowDecoratorDao extends DataTypeDecoratorDao {

private static final LogicalFlow lf = Tables.LOGICAL_FLOW;
private static final LogicalFlowDecorator lfd = Tables.LOGICAL_FLOW_DECORATOR;
private static final Application srcApp = Tables.APPLICATION.as("srcApp");
Expand Down Expand Up @@ -107,6 +100,7 @@ public class LogicalFlowDecoratorDao extends DataTypeDecoratorDao {
.lastUpdatedBy(record.getLastUpdatedBy())
.isReadonly(record.getIsReadonly())
.flowClassificationRuleId(Optional.ofNullable(record.getFlowClassificationRuleId()))
.inboundFlowClassificationRuleId(Optional.ofNullable(record.getInboundFlowClassificationRuleId()))
.build();
};

Expand Down Expand Up @@ -294,61 +288,6 @@ public int[] updateDecorators(Set<DataTypeDecorator> decorators) {
}


public int updateDecoratorsForFlowClassificationRule(FlowClassificationRuleVantagePoint flowClassificationRuleVantagePoint) {
LogicalFlowDecorator lfd = LOGICAL_FLOW_DECORATOR.as("lfd");

EntityReference vantagePoint = flowClassificationRuleVantagePoint.vantagePoint();
EntityReference subjectReference = flowClassificationRuleVantagePoint.subjectReference();
EntityReference dataType = flowClassificationRuleVantagePoint.dataType();
String classificationCode = flowClassificationRuleVantagePoint.classificationCode();

SelectConditionStep<Record1<Long>> orgUnitSubselect = DSL
.select(ENTITY_HIERARCHY.ID)
.from(ENTITY_HIERARCHY)
.where(ENTITY_HIERARCHY.KIND.eq(vantagePoint.kind().name()))
.and(ENTITY_HIERARCHY.ANCESTOR_ID.eq(vantagePoint.id()));

SelectConditionStep<Record1<Long>> dataTypeSubselect = DSL
.select(ENTITY_HIERARCHY.ID)
.from(ENTITY_HIERARCHY)
.where(ENTITY_HIERARCHY.KIND.eq(DATA_TYPE.name()))
.and(ENTITY_HIERARCHY.ANCESTOR_ID.eq(dataType.id()));

Condition usingFlowClassificationRule = LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(subjectReference.id()).and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(subjectReference.kind().name()));
Condition notUsingFlowClassificationRule = LOGICAL_FLOW.SOURCE_ENTITY_ID.ne(subjectReference.id()).or(LOGICAL_FLOW.SOURCE_ENTITY_KIND.ne(subjectReference.kind().name()));

Function2<Condition, String, Update<LogicalFlowDecoratorRecord>> mkQuery = (subjectScopingCondition, ratingName) -> dsl
.update(LOGICAL_FLOW_DECORATOR)
.set(LOGICAL_FLOW_DECORATOR.RATING, ratingName)
.set(LOGICAL_FLOW_DECORATOR.FLOW_CLASSIFICATION_RULE_ID, flowClassificationRuleVantagePoint.ruleId())
.where(LOGICAL_FLOW_DECORATOR.ID.in(
DSL.select(lfd.ID)
.from(lfd)
.innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(lfd.LOGICAL_FLOW_ID))
.innerJoin(APPLICATION)
.on(APPLICATION.ID.eq(LOGICAL_FLOW.TARGET_ENTITY_ID)
.and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name())))
.where(subjectScopingCondition
.and(APPLICATION.ORGANISATIONAL_UNIT_ID.in(orgUnitSubselect))
.and(lfd.DECORATOR_ENTITY_KIND.eq(DATA_TYPE.name()))
.and(lfd.DECORATOR_ENTITY_ID.in(dataTypeSubselect))
.and(lfd.RATING.in(
AuthoritativenessRatingValue.NO_OPINION.value(),
AuthoritativenessRatingValue.DISCOURAGED.value())))));

Update<LogicalFlowDecoratorRecord> updateAuthSources = mkQuery.apply(
usingFlowClassificationRule,
classificationCode);

Update<LogicalFlowDecoratorRecord> updateNonAuthSources = mkQuery.apply(
notUsingFlowClassificationRule,
AuthoritativenessRatingValue.DISCOURAGED.value());

int authSourceUpdateCount = updateAuthSources.execute();
int nonAuthSourceUpdateCount = updateNonAuthSources.execute();
return authSourceUpdateCount + nonAuthSourceUpdateCount;
}


@Override
public List<DataTypeUsageCharacteristics> findDatatypeUsageCharacteristics(EntityReference ref) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ public List<FlowClassificationRuleVantagePoint> findExpandedFlowClassificationRu
ehOrgUnit.ID,
ehDataType.ID);

System.out.println(select);
return select
.fetch(TO_VANTAGE_MAPPER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,41 @@

package org.finos.waltz.jobs.harness;

import org.finos.waltz.model.EntityKind;
import org.finos.waltz.model.EntityReference;
import org.finos.waltz.model.datatype.DataTypeDecoratorRatingCharacteristics;
import org.finos.waltz.service.DIConfiguration;
import org.finos.waltz.service.data_flow_decorator.LogicalFlowDecoratorRatingsCalculator;
import org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleService;
import org.jooq.DSLContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Optional;
import java.util.Set;

import static org.finos.waltz.common.SetUtilities.asSet;


public class FlowClassificationRuleHarness {

public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);

FlowClassificationRuleService svc = ctx.getBean(FlowClassificationRuleService.class);
LogicalFlowDecoratorRatingsCalculator calc = ctx.getBean(LogicalFlowDecoratorRatingsCalculator.class);
// AuthSourceRatingCalculator authSourceRatingCalculatorCalculator = ctx.getBean(AuthSourceRatingCalculator.class);
// LogicalFlowDecoratorRatingsCalculator flowCalculator = ctx.getBean(LogicalFlowDecoratorRatingsCalculator.class);
// LogicalFlowDecoratorSummaryDao decoratorDao = ctx.getBean(LogicalFlowDecoratorSummaryDao.class);
// AuthoritativeSourceDao dao = ctx.getBean(AuthoritativeSourceDao.class);

int updCount = svc.fastRecalculateAllFlowRatingsOld();
System.out.printf("Updated %d\n", updCount);
EntityReference waltz = EntityReference.mkRef(EntityKind.APPLICATION, 20506);
EntityReference apptio = EntityReference.mkRef(EntityKind.APPLICATION, 20023);

// Set<DataTypeDecoratorRatingCharacteristics> calculated = calc.calculate(waltz, apptio, Optional.of(asSet(58584L, 66684L)));
Set<DataTypeDecoratorRatingCharacteristics> calculated = calc.calculate(waltz, apptio, Optional.empty());
System.out.printf("Calculated %d\n", calculated.size());

System.out.println(calculated);
// System.exit(-1);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Waltz - Enterprise Architecture
* Copyright (C) 2016, 2017, 2018, 2019 Waltz open source project
* See README.md for more information
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific
*
*/

package org.finos.waltz.model.datatype;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.finos.waltz.model.EntityReference;
import org.finos.waltz.model.Nullable;
import org.finos.waltz.model.rating.AuthoritativenessRatingValue;
import org.immutables.value.Value;

/**
* Data Type decorator usage stats
*/
@Value.Immutable
@JsonSerialize(as = ImmutableDataTypeDecoratorRatingCharacteristics.class)
@JsonDeserialize(as = ImmutableDataTypeDecoratorRatingCharacteristics.class)
public abstract class DataTypeDecoratorRatingCharacteristics {

public abstract EntityReference source();
public abstract EntityReference target();

public abstract long dataTypeId();

@Value.Default
public AuthoritativenessRatingValue sourceOutboundRating(){
return AuthoritativenessRatingValue.NO_OPINION;
}

@Value.Default
public AuthoritativenessRatingValue targetInboundRating(){
return AuthoritativenessRatingValue.NO_OPINION;
};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Waltz - Enterprise Architecture
* Copyright (C) 2016, 2017, 2018, 2019 Waltz open source project
* See README.md for more information
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific
*
*/

package org.finos.waltz.model.datatype;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.finos.waltz.model.EntityReference;
import org.immutables.value.Value;

/**
* Data Type decorator usage stats
*/
@Value.Immutable
@JsonSerialize(as = ImmutableDataTypeDecoratorRatingCharacteristicsRequest.class)
@JsonDeserialize(as = ImmutableDataTypeDecoratorRatingCharacteristicsRequest.class)
public abstract class DataTypeDecoratorRatingCharacteristicsRequest {
public abstract EntityReference source();
public abstract EntityReference target();

}
92 changes: 92 additions & 0 deletions waltz-ng/client/common/svelte/DataTypeNodeTooltipContent.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<script>
import Icon from "./Icon.svelte";
import RatingIndicatorCell from "../../ratings/components/rating-indicator-cell/RatingIndicatorCell.svelte";
import _ from "lodash";
export let name;
export let description;
export let concrete;
export let ratingCharacteristics;
export let usageCharacteristics;
export let isEditMode = false;
</script>


<div class="row">
<div class="col-sm-12">
<h4>{name}</h4>
</div>
</div>
<div class="row">
<div class="col-sm-12">
{description}
</div>
</div>
{#if !_.isEmpty(ratingCharacteristics)}
<hr>
{/if}
{#if ratingCharacteristics}
<div class="row">
<div class="col-sm-4">Source Outbound Rating:</div>
<div class="col-sm-8">
<RatingIndicatorCell {...ratingCharacteristics.sourceOutboundClassification} showName={true}/>
</div>
</div>
<div class="row">
<div class="col-sm-12 help-block small">
This describes the rating of the data flow looking at outbound flow classification rules from the upstream entity.
</div>
</div>
<div class="row">
<div class="col-sm-4">Target Inbound Rating:</div>
<div class="col-sm-8">
<RatingIndicatorCell {...ratingCharacteristics.targetInboundClassification} showName={true}/>
</div>
</div>
<div class="row">
<div class="col-sm-12 help-block small">
This describes the rating of the data flow looking at inbound flow classification rules for the downstream target entity.
</div>
</div>
{/if}
{#if !_.isEmpty(usageCharacteristics)}
<hr>
{/if}
{#if !concrete && !_.isEmpty(usageCharacteristics)}
<div class="row">
<div class="col-sm-12">
<span class="waltz-error-icon">
<Icon name="exclamation-triangle"
style="vertical-align: middle"
size="xl"/>
</span>
This data type is non-concrete so should not be mapped to
</div>
</div>
{/if}
{#if isEditMode && !_.isEmpty(usageCharacteristics?.warningMessageForEditors)}
<div class="row">
<div class="col-sm-12">
<span class="waltz-warning-icon">
<Icon name="exclamation-triangle"
style="vertical-align: middle"
size="xl"/>
</span>
{usageCharacteristics.warningMessageForEditors}
</div>
</div>
{/if}
{#if !isEditMode && !_.isEmpty(usageCharacteristics?.warningMessageForViewers)}
<div class="row">
<div class="col-sm-12">
<span class="waltz-warning-icon">
<Icon name="exclamation-triangle"
style="vertical-align: middle"
size="xl"/>
</span>
{usageCharacteristics.warningMessageForViewers}
</div>
</div>
{/if}
Loading

0 comments on commit 8e73fb9

Please sign in to comment.