Skip to content

Commit b18626f

Browse files
Merge pull request #7065 from deutschebank/db-contrib/waltz-7058-fcr-admin
Flow Classification Rules admin
2 parents ca13b39 + 42e0a36 commit b18626f

51 files changed

Lines changed: 1412 additions & 414 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

waltz-data/src/main/java/org/finos/waltz/data/application/ApplicationIdSelectorFactory.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
7979
case ALL:
8080
return mkForAll(options);
8181
case ACTOR:
82-
return mkForActor(options);
82+
return mkViaFlows(options);
8383
case APP_GROUP:
8484
return mkForAppGroup(options);
8585
case APPLICATION:
@@ -88,6 +88,8 @@ public Select<Record1<Long>> apply(IdSelectionOptions options) {
8888
return mkForEntityRelationship(options);
8989
case DATA_TYPE:
9090
return mkForDataType(options);
91+
case END_USER_APPLICATION:
92+
return mkViaFlows(options);
9193
case FLOW_DIAGRAM:
9294
return mkForFlowDiagram(options);
9395
case LICENCE:
@@ -327,27 +329,28 @@ private Select<Record1<Long>> mkForServer(IdSelectionOptions options) {
327329
}
328330

329331

330-
public static Select<Record1<Long>> mkForActor(IdSelectionOptions options) {
332+
private static Select<Record1<Long>> mkViaFlows(IdSelectionOptions options) {
331333
SelectorUtilities.ensureScopeIsExact(options);
332-
long actorId = options.entityReference().id();
334+
long entityId = options.entityReference().id();
335+
EntityKind entityKind = options.entityReference().kind();
333336

334337
Condition applicationConditions = SelectorUtilities.mkApplicationConditions(options);
335338

336339
Select<Record1<Long>> sourceAppIds = DSL
337340
.select(logicalFlow.SOURCE_ENTITY_ID)
338341
.from(logicalFlow)
339342
.innerJoin(APPLICATION).on(APPLICATION.ID.eq(logicalFlow.SOURCE_ENTITY_ID))
340-
.where(logicalFlow.TARGET_ENTITY_ID.eq(actorId)
341-
.and(logicalFlow.TARGET_ENTITY_KIND.eq(EntityKind.ACTOR.name()))
343+
.where(logicalFlow.TARGET_ENTITY_ID.eq(entityId)
342344
.and(logicalFlow.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))
345+
.and(logicalFlow.TARGET_ENTITY_KIND.eq(entityKind.name()))
343346
.and(logicalFlow.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name())))
344347
.and(applicationConditions);
345348

346349
Select<Record1<Long>> targetAppIds = DSL.select(logicalFlow.TARGET_ENTITY_ID)
347350
.from(logicalFlow)
348351
.innerJoin(APPLICATION).on(APPLICATION.ID.eq(logicalFlow.TARGET_ENTITY_ID))
349-
.where(logicalFlow.SOURCE_ENTITY_ID.eq(actorId)
350-
.and(logicalFlow.SOURCE_ENTITY_KIND.eq(EntityKind.ACTOR.name()))
352+
.where(logicalFlow.SOURCE_ENTITY_ID.eq(entityId)
353+
.and(logicalFlow.SOURCE_ENTITY_KIND.eq(entityKind.name()))
351354
.and(logicalFlow.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))
352355
.and(logicalFlow.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name())))
353356
.and(applicationConditions);

waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationDao.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
package org.finos.waltz.data.flow_classification_rule;
2020

2121
import org.finos.waltz.model.FlowDirection;
22-
import org.finos.waltz.model.Severity;
23-
import org.finos.waltz.schema.tables.records.FlowClassificationRecord;
22+
import org.finos.waltz.model.MessageSeverity;
2423
import org.finos.waltz.model.flow_classification.FlowClassification;
2524
import org.finos.waltz.model.flow_classification.ImmutableFlowClassification;
25+
import org.finos.waltz.schema.tables.records.FlowClassificationRecord;
2626
import org.jooq.DSLContext;
2727
import org.jooq.Record;
2828
import org.jooq.RecordMapper;
@@ -31,8 +31,8 @@
3131

3232
import java.util.Set;
3333

34-
import static org.finos.waltz.schema.Tables.FLOW_CLASSIFICATION;
3534
import static org.finos.waltz.common.Checks.checkNotNull;
35+
import static org.finos.waltz.schema.Tables.FLOW_CLASSIFICATION;
3636

3737

3838
@Repository
@@ -53,7 +53,7 @@ public class FlowClassificationDao {
5353
.userSelectable(record.getUserSelectable())
5454
.direction(FlowDirection.valueOf(record.getDirection()))
5555
.defaultMessage(record.getDefaultMessage())
56-
.messageSeverity(Severity.valueOf(record.getMessageSeverity()))
56+
.messageSeverity(MessageSeverity.valueOf(record.getMessageSeverity()))
5757
.build();
5858
};
5959

waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationRuleDao.java

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.finos.waltz.model.EntityReference;
2424
import org.finos.waltz.model.FlowDirection;
2525
import org.finos.waltz.model.ImmutableEntityReference;
26-
import org.finos.waltz.model.Severity;
26+
import org.finos.waltz.model.MessageSeverity;
2727
import org.finos.waltz.model.flow_classification_rule.DiscouragedSource;
2828
import org.finos.waltz.model.flow_classification_rule.FlowClassificationRule;
2929
import org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleCreateCommand;
@@ -34,14 +34,14 @@
3434
import org.finos.waltz.model.flow_classification_rule.ImmutableFlowClassificationRuleVantagePoint;
3535
import org.finos.waltz.model.rating.AuthoritativenessRatingValue;
3636
import org.finos.waltz.schema.tables.Application;
37-
import org.finos.waltz.schema.tables.DataType;
3837
import org.finos.waltz.schema.tables.EntityHierarchy;
3938
import org.finos.waltz.schema.tables.records.FlowClassificationRuleRecord;
4039
import org.finos.waltz.schema.tables.records.LogicalFlowDecoratorRecord;
4140
import org.jooq.AggregateFunction;
4241
import org.jooq.Condition;
4342
import org.jooq.DSLContext;
4443
import org.jooq.Field;
44+
import org.jooq.InsertSetMoreStep;
4545
import org.jooq.Record;
4646
import org.jooq.Record1;
4747
import org.jooq.Record11;
@@ -93,6 +93,8 @@ public class FlowClassificationRuleDao {
9393

9494
public final static Application CONSUMER_APP = APPLICATION.as("consumer");
9595
public final static Application SUPPLIER_APP = APPLICATION.as("supplier");
96+
public final static Application SUBJECT_APP = APPLICATION.as("subject_app");
97+
public final static Application SUBJECT_EUDA = APPLICATION.as("subject_euda");
9698
public static final org.finos.waltz.schema.tables.DataType parent_dt = org.finos.waltz.schema.tables.DataType.DATA_TYPE.as("parent_dt");
9799
public static final org.finos.waltz.schema.tables.DataType child_dt = org.finos.waltz.schema.tables.DataType.DATA_TYPE.as("child_dt");
98100
public static final EntityHierarchy eh = ENTITY_HIERARCHY.as("eh");
@@ -108,12 +110,12 @@ public class FlowClassificationRuleDao {
108110
private static final Field<String> PARENT_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
109111
FLOW_CLASSIFICATION_RULE.PARENT_ID,
110112
FLOW_CLASSIFICATION_RULE.PARENT_KIND,
111-
newArrayList(EntityKind.ORG_UNIT, EntityKind.APPLICATION, EntityKind.ACTOR));
113+
newArrayList(EntityKind.ORG_UNIT, EntityKind.APPLICATION, EntityKind.ACTOR, EntityKind.END_USER_APPLICATION));
112114

113115
private static final Field<String> SUBJECT_NAME_FIELD = InlineSelectFieldFactory.mkNameField(
114116
FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID,
115117
FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND,
116-
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR));
118+
newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR, EntityKind.END_USER_APPLICATION));
117119

118120
private static final Condition flowNotRemoved = LOGICAL_FLOW.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name())
119121
.and(LOGICAL_FLOW.IS_REMOVED.isFalse());
@@ -160,7 +162,7 @@ public class FlowClassificationRuleDao {
160162
.externalId(Optional.ofNullable(record.getExternalId()))
161163
.isReadonly(record.getIsReadonly())
162164
.message(record.getMessage())
163-
.messageSeverity(Severity.valueOf(record.getMessageSeverity()))
165+
.messageSeverity(MessageSeverity.valueOf(record.getMessageSeverity()))
164166
.build();
165167
};
166168

@@ -176,7 +178,7 @@ public class FlowClassificationRuleDao {
176178
.dataTypeRank(r.get(dataTypeLevel))
177179
.ruleId(r.get(FLOW_CLASSIFICATION_RULE.ID))
178180
.message(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE))
179-
.messageSeverity(Severity.valueOf(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY)))
181+
.messageSeverity(MessageSeverity.valueOf(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY)))
180182
.build();
181183
};
182184

@@ -240,6 +242,11 @@ public int update(FlowClassificationRuleUpdateCommand command) {
240242
.set(FLOW_CLASSIFICATION_RULE.FLOW_CLASSIFICATION_ID, command.classificationId())
241243
.set(FLOW_CLASSIFICATION_RULE.DESCRIPTION, command.description());
242244

245+
if (command.severity() != null) {
246+
upd.set(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY, command.severity().name());
247+
upd.set(FLOW_CLASSIFICATION_RULE.MESSAGE, command.message());
248+
}
249+
243250
return upd
244251
.where(FLOW_CLASSIFICATION_RULE.ID.eq(command.id().get()))
245252
.execute();
@@ -249,7 +256,7 @@ public int update(FlowClassificationRuleUpdateCommand command) {
249256
public long insert(FlowClassificationRuleCreateCommand command, String username) {
250257
checkNotNull(command, "command cannot be null");
251258

252-
return dsl
259+
InsertSetMoreStep<FlowClassificationRuleRecord> stmt = dsl
253260
.insertInto(FLOW_CLASSIFICATION_RULE)
254261
.set(FLOW_CLASSIFICATION_RULE.PARENT_KIND, command.parentReference().kind().name())
255262
.set(FLOW_CLASSIFICATION_RULE.PARENT_ID, command.parentReference().id())
@@ -260,7 +267,14 @@ public long insert(FlowClassificationRuleCreateCommand command, String username)
260267
.set(FLOW_CLASSIFICATION_RULE.DESCRIPTION, command.description())
261268
.set(FLOW_CLASSIFICATION_RULE.PROVENANCE, "waltz")
262269
.set(FLOW_CLASSIFICATION_RULE.LAST_UPDATED_AT, nowUtcTimestamp())
263-
.set(FLOW_CLASSIFICATION_RULE.LAST_UPDATED_BY, username)
270+
.set(FLOW_CLASSIFICATION_RULE.LAST_UPDATED_BY, username);
271+
272+
if (command.severity() != null) {
273+
stmt.set(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY, command.severity().name());
274+
stmt.set(FLOW_CLASSIFICATION_RULE.MESSAGE, command.message());
275+
}
276+
277+
return stmt
264278
.returning(FLOW_CLASSIFICATION_RULE.ID)
265279
.fetchOne()
266280
.getId();
@@ -318,6 +332,8 @@ public Set<EntityReference> cleanupOrphans() {
318332
}
319333

320334

335+
/* deprecating as we need to work on improving the speed of on-demand recalcs */
336+
@Deprecated
321337
public int clearRatingsForPointToPointFlows(FlowClassificationRule rule) {
322338

323339
// this may wipe any lower level explicit datatype mappings but these will be restored by the nightly job
@@ -526,22 +542,10 @@ public List<DiscouragedSource> findDiscouragedSourcesBySelector(Condition custom
526542

527543
public Set<FlowClassificationRule> findClassificationRules(Condition customSelectionCriteria) {
528544

529-
SelectConditionStep<Record1<Long>> ruleSelectorBasedOnCustomSelectionForTargetApps = DSL
530-
.select(FLOW_CLASSIFICATION_RULE.ID)
531-
.from(FLOW_CLASSIFICATION_RULE)
532-
.innerJoin(LOGICAL_FLOW)
533-
.on(LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID)
534-
.and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND))
535-
.and(LOGICAL_FLOW.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name())
536-
.and(LOGICAL_FLOW.IS_REMOVED.isFalse())))
537-
.innerJoin(CONSUMER_APP).on(LOGICAL_FLOW.TARGET_ENTITY_ID.eq(CONSUMER_APP.ID)
538-
.and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name())))
545+
SelectConditionStep<Record> qry = baseSelect()
539546
.where(customSelectionCriteria);
540547

541-
Condition criteria = FLOW_CLASSIFICATION_RULE.ID.in(ruleSelectorBasedOnCustomSelectionForTargetApps);
542-
543-
return baseSelect()
544-
.where(criteria)
548+
return qry
545549
.fetchSet(TO_DOMAIN_MAPPER);
546550
}
547551

@@ -554,13 +558,16 @@ private SelectOnConditionStep<Record> baseSelect() {
554558
.select(SUBJECT_NAME_FIELD)
555559
.select(ORGANISATIONAL_UNIT.ID, ORGANISATIONAL_UNIT.NAME)
556560
.select(FLOW_CLASSIFICATION_RULE.fields())
557-
.select(SUPPLIER_APP.NAME, SUPPLIER_APP.ID)
558561
.from(FLOW_CLASSIFICATION_RULE)
559-
.leftJoin(SUPPLIER_APP)
560-
.on(SUPPLIER_APP.ID.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID)
562+
.leftJoin(SUBJECT_APP)
563+
.on(SUBJECT_APP.ID.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID)
561564
.and(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND.eq(EntityKind.APPLICATION.name())))
565+
.leftJoin(SUBJECT_EUDA)
566+
.on(SUBJECT_EUDA.ID.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID)
567+
.and(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND.eq(EntityKind.END_USER_APPLICATION.name())))
562568
.leftJoin(ORGANISATIONAL_UNIT)
563-
.on(ORGANISATIONAL_UNIT.ID.eq(SUPPLIER_APP.ORGANISATIONAL_UNIT_ID));
569+
.on(ORGANISATIONAL_UNIT.ID.eq(SUBJECT_APP.ORGANISATIONAL_UNIT_ID)
570+
.or(ORGANISATIONAL_UNIT.ID.eq(SUBJECT_EUDA.ORGANISATIONAL_UNIT_ID)));
564571
}
565572

566573

waltz-jobs/src/main/java/org/finos/waltz/jobs/harness/FlowClassificationRuleHarness.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@
1919
package org.finos.waltz.jobs.harness;
2020

2121
import org.finos.waltz.model.EntityKind;
22-
import org.finos.waltz.model.EntityReference;
23-
import org.finos.waltz.model.datatype.DataTypeDecoratorRatingCharacteristics;
22+
import org.finos.waltz.model.flow_classification_rule.FlowClassificationRule;
2423
import org.finos.waltz.service.DIConfiguration;
25-
import org.finos.waltz.service.data_flow_decorator.LogicalFlowDecoratorRatingsCalculator;
2624
import org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleService;
2725
import org.jooq.DSLContext;
2826
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
2927

30-
import java.util.Optional;
3128
import java.util.Set;
3229

33-
import static org.finos.waltz.common.SetUtilities.asSet;
30+
import static org.finos.waltz.model.EntityReference.mkRef;
31+
import static org.finos.waltz.model.IdSelectionOptions.mkOpts;
3432

3533

3634
public class FlowClassificationRuleHarness {
@@ -39,18 +37,10 @@ public static void main(String[] args) {
3937
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
4038
DSLContext dsl = ctx.getBean(DSLContext.class);
4139

42-
LogicalFlowDecoratorRatingsCalculator calc = ctx.getBean(LogicalFlowDecoratorRatingsCalculator.class);
43-
// AuthSourceRatingCalculator authSourceRatingCalculatorCalculator = ctx.getBean(AuthSourceRatingCalculator.class);
44-
// LogicalFlowDecoratorRatingsCalculator flowCalculator = ctx.getBean(LogicalFlowDecoratorRatingsCalculator.class);
45-
// LogicalFlowDecoratorSummaryDao decoratorDao = ctx.getBean(LogicalFlowDecoratorSummaryDao.class);
46-
// AuthoritativeSourceDao dao = ctx.getBean(AuthoritativeSourceDao.class);
4740

48-
EntityReference waltz = EntityReference.mkRef(EntityKind.APPLICATION, 20506);
49-
EntityReference apptio = EntityReference.mkRef(EntityKind.APPLICATION, 20023);
50-
51-
// Set<DataTypeDecoratorRatingCharacteristics> calculated = calc.calculate(waltz, apptio, Optional.of(asSet(58584L, 66684L)));
52-
Set<DataTypeDecoratorRatingCharacteristics> calculated = calc.calculate(waltz, apptio, Optional.empty());
53-
System.out.printf("Calculated %d\n", calculated.size());
41+
FlowClassificationRuleService svc = ctx.getBean(FlowClassificationRuleService.class);
42+
Set<FlowClassificationRule> r = svc.findClassificationRules(mkOpts(mkRef(EntityKind.ORG_UNIT, 14902L)));
43+
System.out.println(r);
5444

5545
// System.exit(-1);
5646
}

waltz-model/src/main/java/org/finos/waltz/model/IdSelectionOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ protected static HierarchyQueryScope determineDefaultScope(EntityKind kind) {
9191
case APPLICATION:
9292
case APP_GROUP:
9393
case CHANGE_INITIATIVE:
94+
case END_USER_APPLICATION:
9495
case FLOW_DIAGRAM:
9596
case LOGICAL_DATA_ELEMENT:
9697
case LOGICAL_DATA_FLOW:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Waltz - Enterprise Architecture
3+
* Copyright (C) 2016, 2017, 2018, 2019 Waltz open source project
4+
* See README.md for more information
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific
16+
*
17+
*/
18+
19+
package org.finos.waltz.model;
20+
21+
public enum MessageSeverity {
22+
23+
NONE,
24+
INFORMATION,
25+
WARNING,
26+
ERROR
27+
28+
}

waltz-model/src/main/java/org/finos/waltz/model/datatype/DataTypeDecoratorRatingCharacteristics.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
2222
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
2323
import org.finos.waltz.model.EntityReference;
24+
import org.finos.waltz.model.MessageSeverity;
2425
import org.finos.waltz.model.Nullable;
25-
import org.finos.waltz.model.Severity;
2626
import org.finos.waltz.model.rating.AuthoritativenessRatingValue;
2727
import org.immutables.value.Value;
2828

@@ -53,16 +53,16 @@ public AuthoritativenessRatingValue targetInboundRating(){
5353
public abstract String outboundMessage();
5454

5555
@Value.Default
56-
public Severity outboundMessageSeverity() {
57-
return Severity.INFORMATION;
56+
public MessageSeverity outboundMessageSeverity() {
57+
return MessageSeverity.INFORMATION;
5858
}
5959

6060
@Nullable
6161
public abstract String inboundMessage();
6262

6363
@Value.Default
64-
public Severity inboundMessageSeverity() {
65-
return Severity.INFORMATION;
64+
public MessageSeverity inboundMessageSeverity() {
65+
return MessageSeverity.INFORMATION;
6666
}
6767

6868
}

waltz-model/src/main/java/org/finos/waltz/model/flow_classification/FlowClassification.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public FlowDirection direction() {
2626
public abstract String defaultMessage();
2727

2828
@Value.Default
29-
public Severity messageSeverity() {
30-
return Severity.INFORMATION;
29+
public MessageSeverity messageSeverity() {
30+
return MessageSeverity.INFORMATION;
3131
}
3232
@Value.Default
3333
public EntityKind kind() {
34-
return EntityKind.FLOW_CLASSIFICATION_RULE;
34+
return EntityKind.FLOW_CLASSIFICATION;
3535
}
3636

3737
}

waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public boolean isReadonly() {
6666
public abstract String message();
6767

6868
@Value.Default
69-
public Severity messageSeverity() {
70-
return Severity.INFORMATION;
69+
public MessageSeverity messageSeverity() {
70+
return MessageSeverity.INFORMATION;
7171
}
7272

7373

0 commit comments

Comments
 (0)