diff --git a/waltz-data/src/main/java/org/finos/waltz/data/application/ApplicationIdSelectorFactory.java b/waltz-data/src/main/java/org/finos/waltz/data/application/ApplicationIdSelectorFactory.java index 353ade81fe..7388f44ad8 100644 --- a/waltz-data/src/main/java/org/finos/waltz/data/application/ApplicationIdSelectorFactory.java +++ b/waltz-data/src/main/java/org/finos/waltz/data/application/ApplicationIdSelectorFactory.java @@ -79,7 +79,7 @@ public Select> apply(IdSelectionOptions options) { case ALL: return mkForAll(options); case ACTOR: - return mkForActor(options); + return mkViaFlows(options); case APP_GROUP: return mkForAppGroup(options); case APPLICATION: @@ -88,6 +88,8 @@ public Select> apply(IdSelectionOptions options) { return mkForEntityRelationship(options); case DATA_TYPE: return mkForDataType(options); + case END_USER_APPLICATION: + return mkViaFlows(options); case FLOW_DIAGRAM: return mkForFlowDiagram(options); case LICENCE: @@ -327,9 +329,10 @@ private Select> mkForServer(IdSelectionOptions options) { } - public static Select> mkForActor(IdSelectionOptions options) { + private static Select> mkViaFlows(IdSelectionOptions options) { SelectorUtilities.ensureScopeIsExact(options); - long actorId = options.entityReference().id(); + long entityId = options.entityReference().id(); + EntityKind entityKind = options.entityReference().kind(); Condition applicationConditions = SelectorUtilities.mkApplicationConditions(options); @@ -337,17 +340,17 @@ public static Select> mkForActor(IdSelectionOptions options) { .select(logicalFlow.SOURCE_ENTITY_ID) .from(logicalFlow) .innerJoin(APPLICATION).on(APPLICATION.ID.eq(logicalFlow.SOURCE_ENTITY_ID)) - .where(logicalFlow.TARGET_ENTITY_ID.eq(actorId) - .and(logicalFlow.TARGET_ENTITY_KIND.eq(EntityKind.ACTOR.name())) + .where(logicalFlow.TARGET_ENTITY_ID.eq(entityId) .and(logicalFlow.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name())) + .and(logicalFlow.TARGET_ENTITY_KIND.eq(entityKind.name())) .and(logicalFlow.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name()))) .and(applicationConditions); Select> targetAppIds = DSL.select(logicalFlow.TARGET_ENTITY_ID) .from(logicalFlow) .innerJoin(APPLICATION).on(APPLICATION.ID.eq(logicalFlow.TARGET_ENTITY_ID)) - .where(logicalFlow.SOURCE_ENTITY_ID.eq(actorId) - .and(logicalFlow.SOURCE_ENTITY_KIND.eq(EntityKind.ACTOR.name())) + .where(logicalFlow.SOURCE_ENTITY_ID.eq(entityId) + .and(logicalFlow.SOURCE_ENTITY_KIND.eq(entityKind.name())) .and(logicalFlow.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name())) .and(logicalFlow.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name()))) .and(applicationConditions); diff --git a/waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationDao.java b/waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationDao.java index d30a973577..c225876810 100644 --- a/waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationDao.java +++ b/waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationDao.java @@ -19,10 +19,10 @@ package org.finos.waltz.data.flow_classification_rule; import org.finos.waltz.model.FlowDirection; -import org.finos.waltz.model.Severity; -import org.finos.waltz.schema.tables.records.FlowClassificationRecord; +import org.finos.waltz.model.MessageSeverity; import org.finos.waltz.model.flow_classification.FlowClassification; import org.finos.waltz.model.flow_classification.ImmutableFlowClassification; +import org.finos.waltz.schema.tables.records.FlowClassificationRecord; import org.jooq.DSLContext; import org.jooq.Record; import org.jooq.RecordMapper; @@ -31,8 +31,8 @@ import java.util.Set; -import static org.finos.waltz.schema.Tables.FLOW_CLASSIFICATION; import static org.finos.waltz.common.Checks.checkNotNull; +import static org.finos.waltz.schema.Tables.FLOW_CLASSIFICATION; @Repository @@ -53,7 +53,7 @@ public class FlowClassificationDao { .userSelectable(record.getUserSelectable()) .direction(FlowDirection.valueOf(record.getDirection())) .defaultMessage(record.getDefaultMessage()) - .messageSeverity(Severity.valueOf(record.getMessageSeverity())) + .messageSeverity(MessageSeverity.valueOf(record.getMessageSeverity())) .build(); }; diff --git a/waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationRuleDao.java b/waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationRuleDao.java index a6801ebdc1..17f9eddd75 100644 --- a/waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationRuleDao.java +++ b/waltz-data/src/main/java/org/finos/waltz/data/flow_classification_rule/FlowClassificationRuleDao.java @@ -23,7 +23,7 @@ import org.finos.waltz.model.EntityReference; import org.finos.waltz.model.FlowDirection; import org.finos.waltz.model.ImmutableEntityReference; -import org.finos.waltz.model.Severity; +import org.finos.waltz.model.MessageSeverity; import org.finos.waltz.model.flow_classification_rule.DiscouragedSource; import org.finos.waltz.model.flow_classification_rule.FlowClassificationRule; import org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleCreateCommand; @@ -34,7 +34,6 @@ import org.finos.waltz.model.flow_classification_rule.ImmutableFlowClassificationRuleVantagePoint; import org.finos.waltz.model.rating.AuthoritativenessRatingValue; import org.finos.waltz.schema.tables.Application; -import org.finos.waltz.schema.tables.DataType; import org.finos.waltz.schema.tables.EntityHierarchy; import org.finos.waltz.schema.tables.records.FlowClassificationRuleRecord; import org.finos.waltz.schema.tables.records.LogicalFlowDecoratorRecord; @@ -42,6 +41,7 @@ import org.jooq.Condition; import org.jooq.DSLContext; import org.jooq.Field; +import org.jooq.InsertSetMoreStep; import org.jooq.Record; import org.jooq.Record1; import org.jooq.Record11; @@ -93,6 +93,8 @@ public class FlowClassificationRuleDao { public final static Application CONSUMER_APP = APPLICATION.as("consumer"); public final static Application SUPPLIER_APP = APPLICATION.as("supplier"); + public final static Application SUBJECT_APP = APPLICATION.as("subject_app"); + public final static Application SUBJECT_EUDA = APPLICATION.as("subject_euda"); public static final org.finos.waltz.schema.tables.DataType parent_dt = org.finos.waltz.schema.tables.DataType.DATA_TYPE.as("parent_dt"); public static final org.finos.waltz.schema.tables.DataType child_dt = org.finos.waltz.schema.tables.DataType.DATA_TYPE.as("child_dt"); public static final EntityHierarchy eh = ENTITY_HIERARCHY.as("eh"); @@ -108,12 +110,12 @@ public class FlowClassificationRuleDao { private static final Field PARENT_NAME_FIELD = InlineSelectFieldFactory.mkNameField( FLOW_CLASSIFICATION_RULE.PARENT_ID, FLOW_CLASSIFICATION_RULE.PARENT_KIND, - newArrayList(EntityKind.ORG_UNIT, EntityKind.APPLICATION, EntityKind.ACTOR)); + newArrayList(EntityKind.ORG_UNIT, EntityKind.APPLICATION, EntityKind.ACTOR, EntityKind.END_USER_APPLICATION)); private static final Field SUBJECT_NAME_FIELD = InlineSelectFieldFactory.mkNameField( FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID, FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND, - newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR)); + newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR, EntityKind.END_USER_APPLICATION)); private static final Condition flowNotRemoved = LOGICAL_FLOW.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name()) .and(LOGICAL_FLOW.IS_REMOVED.isFalse()); @@ -160,7 +162,7 @@ public class FlowClassificationRuleDao { .externalId(Optional.ofNullable(record.getExternalId())) .isReadonly(record.getIsReadonly()) .message(record.getMessage()) - .messageSeverity(Severity.valueOf(record.getMessageSeverity())) + .messageSeverity(MessageSeverity.valueOf(record.getMessageSeverity())) .build(); }; @@ -176,7 +178,7 @@ public class FlowClassificationRuleDao { .dataTypeRank(r.get(dataTypeLevel)) .ruleId(r.get(FLOW_CLASSIFICATION_RULE.ID)) .message(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE)) - .messageSeverity(Severity.valueOf(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY))) + .messageSeverity(MessageSeverity.valueOf(r.get(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY))) .build(); }; @@ -240,6 +242,11 @@ public int update(FlowClassificationRuleUpdateCommand command) { .set(FLOW_CLASSIFICATION_RULE.FLOW_CLASSIFICATION_ID, command.classificationId()) .set(FLOW_CLASSIFICATION_RULE.DESCRIPTION, command.description()); + if (command.severity() != null) { + upd.set(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY, command.severity().name()); + upd.set(FLOW_CLASSIFICATION_RULE.MESSAGE, command.message()); + } + return upd .where(FLOW_CLASSIFICATION_RULE.ID.eq(command.id().get())) .execute(); @@ -249,7 +256,7 @@ public int update(FlowClassificationRuleUpdateCommand command) { public long insert(FlowClassificationRuleCreateCommand command, String username) { checkNotNull(command, "command cannot be null"); - return dsl + InsertSetMoreStep stmt = dsl .insertInto(FLOW_CLASSIFICATION_RULE) .set(FLOW_CLASSIFICATION_RULE.PARENT_KIND, command.parentReference().kind().name()) .set(FLOW_CLASSIFICATION_RULE.PARENT_ID, command.parentReference().id()) @@ -260,7 +267,14 @@ public long insert(FlowClassificationRuleCreateCommand command, String username) .set(FLOW_CLASSIFICATION_RULE.DESCRIPTION, command.description()) .set(FLOW_CLASSIFICATION_RULE.PROVENANCE, "waltz") .set(FLOW_CLASSIFICATION_RULE.LAST_UPDATED_AT, nowUtcTimestamp()) - .set(FLOW_CLASSIFICATION_RULE.LAST_UPDATED_BY, username) + .set(FLOW_CLASSIFICATION_RULE.LAST_UPDATED_BY, username); + + if (command.severity() != null) { + stmt.set(FLOW_CLASSIFICATION_RULE.MESSAGE_SEVERITY, command.severity().name()); + stmt.set(FLOW_CLASSIFICATION_RULE.MESSAGE, command.message()); + } + + return stmt .returning(FLOW_CLASSIFICATION_RULE.ID) .fetchOne() .getId(); @@ -318,6 +332,8 @@ public Set cleanupOrphans() { } + /* deprecating as we need to work on improving the speed of on-demand recalcs */ + @Deprecated public int clearRatingsForPointToPointFlows(FlowClassificationRule rule) { // this may wipe any lower level explicit datatype mappings but these will be restored by the nightly job @@ -526,22 +542,10 @@ public List findDiscouragedSourcesBySelector(Condition custom public Set findClassificationRules(Condition customSelectionCriteria) { - SelectConditionStep> ruleSelectorBasedOnCustomSelectionForTargetApps = DSL - .select(FLOW_CLASSIFICATION_RULE.ID) - .from(FLOW_CLASSIFICATION_RULE) - .innerJoin(LOGICAL_FLOW) - .on(LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID) - .and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND)) - .and(LOGICAL_FLOW.ENTITY_LIFECYCLE_STATUS.ne(REMOVED.name()) - .and(LOGICAL_FLOW.IS_REMOVED.isFalse()))) - .innerJoin(CONSUMER_APP).on(LOGICAL_FLOW.TARGET_ENTITY_ID.eq(CONSUMER_APP.ID) - .and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))) + SelectConditionStep qry = baseSelect() .where(customSelectionCriteria); - Condition criteria = FLOW_CLASSIFICATION_RULE.ID.in(ruleSelectorBasedOnCustomSelectionForTargetApps); - - return baseSelect() - .where(criteria) + return qry .fetchSet(TO_DOMAIN_MAPPER); } @@ -554,13 +558,16 @@ private SelectOnConditionStep baseSelect() { .select(SUBJECT_NAME_FIELD) .select(ORGANISATIONAL_UNIT.ID, ORGANISATIONAL_UNIT.NAME) .select(FLOW_CLASSIFICATION_RULE.fields()) - .select(SUPPLIER_APP.NAME, SUPPLIER_APP.ID) .from(FLOW_CLASSIFICATION_RULE) - .leftJoin(SUPPLIER_APP) - .on(SUPPLIER_APP.ID.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID) + .leftJoin(SUBJECT_APP) + .on(SUBJECT_APP.ID.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID) .and(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))) + .leftJoin(SUBJECT_EUDA) + .on(SUBJECT_EUDA.ID.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID) + .and(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND.eq(EntityKind.END_USER_APPLICATION.name()))) .leftJoin(ORGANISATIONAL_UNIT) - .on(ORGANISATIONAL_UNIT.ID.eq(SUPPLIER_APP.ORGANISATIONAL_UNIT_ID)); + .on(ORGANISATIONAL_UNIT.ID.eq(SUBJECT_APP.ORGANISATIONAL_UNIT_ID) + .or(ORGANISATIONAL_UNIT.ID.eq(SUBJECT_EUDA.ORGANISATIONAL_UNIT_ID))); } diff --git a/waltz-jobs/src/main/java/org/finos/waltz/jobs/harness/FlowClassificationRuleHarness.java b/waltz-jobs/src/main/java/org/finos/waltz/jobs/harness/FlowClassificationRuleHarness.java index 74d869907d..5922f03041 100644 --- a/waltz-jobs/src/main/java/org/finos/waltz/jobs/harness/FlowClassificationRuleHarness.java +++ b/waltz-jobs/src/main/java/org/finos/waltz/jobs/harness/FlowClassificationRuleHarness.java @@ -19,18 +19,16 @@ 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.model.flow_classification_rule.FlowClassificationRule; 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; +import static org.finos.waltz.model.EntityReference.mkRef; +import static org.finos.waltz.model.IdSelectionOptions.mkOpts; public class FlowClassificationRuleHarness { @@ -39,18 +37,10 @@ public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DSLContext dsl = ctx.getBean(DSLContext.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); - EntityReference waltz = EntityReference.mkRef(EntityKind.APPLICATION, 20506); - EntityReference apptio = EntityReference.mkRef(EntityKind.APPLICATION, 20023); - -// Set calculated = calc.calculate(waltz, apptio, Optional.of(asSet(58584L, 66684L))); - Set calculated = calc.calculate(waltz, apptio, Optional.empty()); - System.out.printf("Calculated %d\n", calculated.size()); + FlowClassificationRuleService svc = ctx.getBean(FlowClassificationRuleService.class); + Set r = svc.findClassificationRules(mkOpts(mkRef(EntityKind.ORG_UNIT, 14902L))); + System.out.println(r); // System.exit(-1); } diff --git a/waltz-model/src/main/java/org/finos/waltz/model/IdSelectionOptions.java b/waltz-model/src/main/java/org/finos/waltz/model/IdSelectionOptions.java index 559cae1250..dddff27166 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/IdSelectionOptions.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/IdSelectionOptions.java @@ -91,6 +91,7 @@ protected static HierarchyQueryScope determineDefaultScope(EntityKind kind) { case APPLICATION: case APP_GROUP: case CHANGE_INITIATIVE: + case END_USER_APPLICATION: case FLOW_DIAGRAM: case LOGICAL_DATA_ELEMENT: case LOGICAL_DATA_FLOW: diff --git a/waltz-model/src/main/java/org/finos/waltz/model/MessageSeverity.java b/waltz-model/src/main/java/org/finos/waltz/model/MessageSeverity.java new file mode 100644 index 0000000000..6a26750832 --- /dev/null +++ b/waltz-model/src/main/java/org/finos/waltz/model/MessageSeverity.java @@ -0,0 +1,28 @@ +/* + * 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; + +public enum MessageSeverity { + + NONE, + INFORMATION, + WARNING, + ERROR + +} diff --git a/waltz-model/src/main/java/org/finos/waltz/model/datatype/DataTypeDecoratorRatingCharacteristics.java b/waltz-model/src/main/java/org/finos/waltz/model/datatype/DataTypeDecoratorRatingCharacteristics.java index f44116281a..8963d10a03 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/datatype/DataTypeDecoratorRatingCharacteristics.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/datatype/DataTypeDecoratorRatingCharacteristics.java @@ -21,8 +21,8 @@ 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.MessageSeverity; import org.finos.waltz.model.Nullable; -import org.finos.waltz.model.Severity; import org.finos.waltz.model.rating.AuthoritativenessRatingValue; import org.immutables.value.Value; @@ -53,16 +53,16 @@ public AuthoritativenessRatingValue targetInboundRating(){ public abstract String outboundMessage(); @Value.Default - public Severity outboundMessageSeverity() { - return Severity.INFORMATION; + public MessageSeverity outboundMessageSeverity() { + return MessageSeverity.INFORMATION; } @Nullable public abstract String inboundMessage(); @Value.Default - public Severity inboundMessageSeverity() { - return Severity.INFORMATION; + public MessageSeverity inboundMessageSeverity() { + return MessageSeverity.INFORMATION; } } diff --git a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification/FlowClassification.java b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification/FlowClassification.java index 2eeaaea543..e5a0c2b91b 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification/FlowClassification.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification/FlowClassification.java @@ -26,12 +26,12 @@ public FlowDirection direction() { public abstract String defaultMessage(); @Value.Default - public Severity messageSeverity() { - return Severity.INFORMATION; + public MessageSeverity messageSeverity() { + return MessageSeverity.INFORMATION; } @Value.Default public EntityKind kind() { - return EntityKind.FLOW_CLASSIFICATION_RULE; + return EntityKind.FLOW_CLASSIFICATION; } } diff --git a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRule.java b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRule.java index fa2a6a9c75..ff88e29241 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRule.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRule.java @@ -66,8 +66,8 @@ public boolean isReadonly() { public abstract String message(); @Value.Default - public Severity messageSeverity() { - return Severity.INFORMATION; + public MessageSeverity messageSeverity() { + return MessageSeverity.INFORMATION; } diff --git a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleCreateCommand.java b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleCreateCommand.java index d440db8291..9a2337da9f 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleCreateCommand.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleCreateCommand.java @@ -23,6 +23,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.finos.waltz.model.DescriptionProvider; import org.finos.waltz.model.EntityReference; +import org.finos.waltz.model.MessageSeverity; +import org.finos.waltz.model.Nullable; import org.finos.waltz.model.command.Command; import org.immutables.value.Value; @@ -31,9 +33,17 @@ @JsonDeserialize(as = ImmutableFlowClassificationRuleCreateCommand.class) public abstract class FlowClassificationRuleCreateCommand implements Command, DescriptionProvider { public abstract long classificationId(); - public abstract long dataTypeId(); + + @Nullable + public abstract Long dataTypeId(); public abstract EntityReference subjectReference(); public abstract EntityReference parentReference(); + + @Nullable + public abstract MessageSeverity severity(); + + @Nullable + public abstract String message(); } diff --git a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleUpdateCommand.java b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleUpdateCommand.java index e7d1eb6f8a..9a5f93ab12 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleUpdateCommand.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleUpdateCommand.java @@ -23,6 +23,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.finos.waltz.model.DescriptionProvider; import org.finos.waltz.model.IdProvider; +import org.finos.waltz.model.MessageSeverity; +import org.finos.waltz.model.Nullable; import org.finos.waltz.model.command.Command; import org.immutables.value.Value; @@ -35,4 +37,10 @@ public abstract class FlowClassificationRuleUpdateCommand implements IdProvider { public abstract long classificationId(); + + @Nullable + public abstract MessageSeverity severity(); + + @Nullable + public abstract String message(); } diff --git a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleVantagePoint.java b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleVantagePoint.java index aa1ebb1f30..2ab87ff531 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleVantagePoint.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleVantagePoint.java @@ -21,8 +21,8 @@ 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.MessageSeverity; import org.finos.waltz.model.Nullable; -import org.finos.waltz.model.Severity; import org.immutables.value.Value; @@ -45,8 +45,8 @@ public abstract class FlowClassificationRuleVantagePoint { public abstract String message(); @Value.Default - public Severity messageSeverity() { - return Severity.INFORMATION; - }; + public MessageSeverity messageSeverity() { + return MessageSeverity.INFORMATION; + } } \ No newline at end of file diff --git a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleView.java b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleView.java index c836fb722a..363700514d 100644 --- a/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleView.java +++ b/waltz-model/src/main/java/org/finos/waltz/model/flow_classification_rule/FlowClassificationRuleView.java @@ -3,6 +3,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import org.finos.waltz.model.assessment_definition.AssessmentDefinition; import org.finos.waltz.model.assessment_rating.AssessmentRating; +import org.finos.waltz.model.datatype.DataType; +import org.finos.waltz.model.flow_classification.FlowClassification; import org.finos.waltz.model.rating.RatingSchemeItem; import org.immutables.value.Value; @@ -20,4 +22,8 @@ public abstract class FlowClassificationRuleView { public abstract Set ratingSchemeItems(); + public abstract Set dataTypes(); + + public abstract Set flowClassifications(); + } diff --git a/waltz-model/src/test/java/org/finos/waltz/model/survey/SurveyInstanceStateMachineTest.java b/waltz-model/src/test/java/org/finos/waltz/model/survey/SurveyInstanceStateMachineTest.java index 0de720a6a4..48b9701895 100644 --- a/waltz-model/src/test/java/org/finos/waltz/model/survey/SurveyInstanceStateMachineTest.java +++ b/waltz-model/src/test/java/org/finos/waltz/model/survey/SurveyInstanceStateMachineTest.java @@ -74,12 +74,4 @@ public void permissionCheckPasses() { assertEquals(COMPLETED, state.process(SUBMITTING, participant, survey)); } - @Test - public void permissionCheckRejects() { - SurveyInstanceStateMachine state = SurveyInstanceStateMachineFactory.simple("APPROVED"); - assertEquals(IN_PROGRESS, state.process(REOPENING, participant, survey)); - assertThrows(IllegalArgumentException.class, - () -> state.process(WITHDRAWING, participant, survey)); // fails as only admin - } - } \ No newline at end of file diff --git a/waltz-ng/client/common/checks.js b/waltz-ng/client/common/checks.js index 3bc7411c2c..f85b6ba925 100644 --- a/waltz-ng/client/common/checks.js +++ b/waltz-ng/client/common/checks.js @@ -106,7 +106,7 @@ const flowClassificationRuleCreateCommand = { description: apiCheck.string.optional, classificationId: apiCheck.number, subjectReference: apiCheck.shape(entityRefShape), - dataTypeId: apiCheck.number, + dataTypeId: apiCheck.number.optional, parentReference: apiCheck.shape(entityRefShape) }; diff --git a/waltz-ng/client/common/selector-utils.js b/waltz-ng/client/common/selector-utils.js index 0a7adda7f1..4f04a2d49e 100644 --- a/waltz-ng/client/common/selector-utils.js +++ b/waltz-ng/client/common/selector-utils.js @@ -89,7 +89,7 @@ export function determineUpwardsScopeForKind(kind) { * @returns {{entityLifecycleStatuses: string[], entityReference: {kind: *, id: *}, scope: (*|string), filters}} */ export function mkSelectionOptions(entityReference, - scope, + scope = null, entityLifecycleStatuses = ["ACTIVE"], filters = {}) { checkIsEntityRef(entityReference); diff --git a/waltz-ng/client/common/services/enums/index.js b/waltz-ng/client/common/services/enums/index.js index bac6c0f24a..ac7ec743a7 100644 --- a/waltz-ng/client/common/services/enums/index.js +++ b/waltz-ng/client/common/services/enums/index.js @@ -39,6 +39,7 @@ import { investmentRating } from "./investment-rating"; import { issuance } from "./issuance"; import { lifecyclePhase } from "./lifecycle-phase"; import { lifecycleStatus } from "./lifecycle-status"; +import { messageSeverity } from "./message-severity"; import { usageKind } from "./usage-kind"; import { orgUnitKind } from "./org-unit-kind"; import { participantKind } from "./participation-kind"; @@ -74,6 +75,7 @@ export const enums = { lifecyclePhase, orgUnitKind, severity, + messageSeverity, entity, changeInitiative, entityStatistic, diff --git a/waltz-ng/client/common/services/enums/message-severity.js b/waltz-ng/client/common/services/enums/message-severity.js new file mode 100644 index 0000000000..d8406cfefb --- /dev/null +++ b/waltz-ng/client/common/services/enums/message-severity.js @@ -0,0 +1,48 @@ +/* + * 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 + * + */ + +export const messageSeverity = { + NONE: { + key: "NONE", + name: "None", + icon: "fw", + description: null, + position: 0 + }, + INFORMATION: { + key: "INFORMATION", + name: "Info", + icon: "sitemap", + description: null, + position: 10 + }, + ERROR: { + key: "ERROR", + name: "Error", + icon: "sitemap", + description: null, + position: 20 + }, + WARNING: { + key: "WARNING", + name: "Warning", + icon: "sitemap", + description: null, + position: 30 + } +}; \ No newline at end of file diff --git a/waltz-ng/client/common/slick-grid-utils.js b/waltz-ng/client/common/slick-grid-utils.js index e0d86a6f7f..ca5a3eb776 100644 --- a/waltz-ng/client/common/slick-grid-utils.js +++ b/waltz-ng/client/common/slick-grid-utils.js @@ -4,6 +4,7 @@ import {applicationKind} from "./services/enums/application-kind"; import {lifecyclePhase} from "./services/enums/lifecycle-phase"; import _ from "lodash"; import {toLocalDate} from "./date-utils"; +import EntityLabel from "./svelte/EntityLabel.svelte"; export function mkSortFn(sortCol, sortAsc = true) { @@ -32,6 +33,26 @@ export function mkEntityLinkFormatter(valueProvider, showIcon = true) { } +export function mkEntityLabelFormatter(valueProvider, showIcon = true, nullText = '') { + return (row, cell, value, colDef, dataCtx) => { + + const ref = valueProvider + ? valueProvider(value, dataCtx) + : value; + + if (_.isNil(ref)) { + return nullText; + } else { + const me = document.createElement("span"); + const component = new EntityLabel({target: me}); + + component.$set({ref, showIcon}); + return me; + } + } +} + + export function mkExternalIdFormatter(valueProvider = d => d.externalId) { return (row, cell, value, colDef, dataCtx) => { const extId = valueProvider(value, dataCtx); diff --git a/waltz-ng/client/common/sort-utils.js b/waltz-ng/client/common/sort-utils.js index e067ffefd0..98e7f2fec7 100644 --- a/waltz-ng/client/common/sort-utils.js +++ b/waltz-ng/client/common/sort-utils.js @@ -12,6 +12,12 @@ export function refCmp(a, b) { return cmp(a.name, b.name); } + +export function propCmp(a, b, path) { + return cmp(_.get(a, path), _.get(b, path)); +} + + export function compareDates(date1, date2) { if(!_.isEmpty(date1) && _.isEmpty(date2)){ return 1; diff --git a/waltz-ng/client/common/svelte/DataTypeNodeTooltipContent.svelte b/waltz-ng/client/common/svelte/DataTypeNodeTooltipContent.svelte index 6113ed873f..b72059d80b 100644 --- a/waltz-ng/client/common/svelte/DataTypeNodeTooltipContent.svelte +++ b/waltz-ng/client/common/svelte/DataTypeNodeTooltipContent.svelte @@ -5,7 +5,8 @@ import _ from "lodash"; import DescriptionFade from "./DescriptionFade.svelte"; import NoData from "./NoData.svelte"; - import {severity} from "../services/enums/severity"; + import {messageSeverity} from "../services/enums/message-severity"; + import Markdown from "./Markdown.svelte"; export let name; export let description; @@ -14,19 +15,19 @@ export let usageCharacteristics; export let isEditMode = false; - $: inboundMessage = ratingCharacteristics.inboundMessage - || ratingCharacteristics.targetInboundClassification.defaultMessage + $: inboundMessage = ratingCharacteristics?.inboundMessage + || ratingCharacteristics?.targetInboundClassification.defaultMessage - $: outboundMessage = ratingCharacteristics.outboundMessage - || ratingCharacteristics.sourceOutboundClassification.defaultMessage + $: outboundMessage = ratingCharacteristics?.outboundMessage + || ratingCharacteristics?.sourceOutboundClassification.defaultMessage - $: inboundSeverity = ratingCharacteristics.inboundMessage - ? ratingCharacteristics.inboundMessageSeverity - : ratingCharacteristics.targetInboundClassification.messageSeverity; + $: inboundSeverity = ratingCharacteristics?.inboundMessage + ? ratingCharacteristics?.inboundMessageSeverity + : ratingCharacteristics?.targetInboundClassification.messageSeverity; - $: outboundSeverity = ratingCharacteristics.outboundMessage - ? ratingCharacteristics.outboundMessageSeverity - : ratingCharacteristics.sourceOutboundClassification.messageSeverity + $: outboundSeverity = ratingCharacteristics?.outboundMessage + ? ratingCharacteristics?.outboundMessageSeverity + : ratingCharacteristics?.sourceOutboundClassification.messageSeverity @@ -52,14 +53,14 @@
-
+
This indicates the rating of the flow according whether this source entity is authorised to distribute this data type
{#if !_.isEmpty(outboundMessage)}
- {outboundMessage} + {outboundMessage}
{/if} @@ -70,14 +71,16 @@
-
- This rating expresses whether the target entity has a preference for or against this type of data being sent to it +
+ This rating expresses whether the target entity has a preference for or against this type of data being documented against it
{#if !_.isEmpty(inboundMessage)}
- {inboundMessage} + + +
{/if} diff --git a/waltz-ng/client/common/svelte/EntitySearchSelector.svelte b/waltz-ng/client/common/svelte/EntitySearchSelector.svelte index ac7b4ec5c1..db4b986b19 100644 --- a/waltz-ng/client/common/svelte/EntitySearchSelector.svelte +++ b/waltz-ng/client/common/svelte/EntitySearchSelector.svelte @@ -3,10 +3,12 @@ import AutoComplete from "simple-svelte-autocomplete"; import {createEventDispatcher} from "svelte"; import _ from "lodash"; + import EntityLabel from "./EntityLabel.svelte"; export let entityKinds; export let placeholder = "Search..."; export let showClear = true; + export let showIcon = true; export let selectionFilter = () => true; const dispatch = createEventDispatcher(); @@ -32,4 +34,11 @@ {placeholder} {showClear} className="waltz-search-input" - bind:selectedItem={selectedItem} /> + bind:selectedItem={selectedItem}> +
+ +
+ diff --git a/waltz-ng/client/common/svelte/TextEditableField.svelte b/waltz-ng/client/common/svelte/TextEditableField.svelte index 61c4f0f93f..3ca4425005 100644 --- a/waltz-ng/client/common/svelte/TextEditableField.svelte +++ b/waltz-ng/client/common/svelte/TextEditableField.svelte @@ -54,7 +54,8 @@ {/if} {/if} -
+
1000}>
{#if mandatory} diff --git a/waltz-ng/client/common/svelte/ViewLink.svelte b/waltz-ng/client/common/svelte/ViewLink.svelte index 2c4f59e8c8..6c0c404479 100644 --- a/waltz-ng/client/common/svelte/ViewLink.svelte +++ b/waltz-ng/client/common/svelte/ViewLink.svelte @@ -41,6 +41,10 @@ path: ctx => `change-initiative/${ctx.id}`, title: "Change Initiative View" }, + "main.data-type.list" : { + path: ctx => `data-types`, + title: "DataTypes" + }, "main.data-type.view": { path: ctx => `data-types/${ctx.id}`, title: "DataType View" diff --git a/waltz-ng/client/data-flow/components/application-flow-summary-pane/application-flow-summary-pane.js b/waltz-ng/client/data-flow/components/application-flow-summary-pane/application-flow-summary-pane.js index 827559e750..30cf8c3900 100644 --- a/waltz-ng/client/data-flow/components/application-flow-summary-pane/application-flow-summary-pane.js +++ b/waltz-ng/client/data-flow/components/application-flow-summary-pane/application-flow-summary-pane.js @@ -128,7 +128,7 @@ function controller($q, serviceBroker) { const loadUnknownDataTypeId = () => { return serviceBroker .loadAppData(CORE_API.DataTypeStore.findAll) - .then(r => console.log(r.data) || findUnknownDataTypeId(r.data)); + .then(r => findUnknownDataTypeId(r.data)); }; vm.$onChanges = () => { @@ -136,8 +136,7 @@ function controller($q, serviceBroker) { .then(dtId => reload(dtId)); loadFlowClassificationRatings(serviceBroker) - .then(xs => vm.flowClassificationCols = console.log({xs, rd: vm.ratingDirection}) - || _.filter(xs, d => d.direction === vm.ratingDirection)); + .then(xs => vm.flowClassificationCols = _.filter(xs, d => d.direction === vm.ratingDirection)); } } diff --git a/waltz-ng/client/data-flow/components/data-flow-section/data-flow-section.html b/waltz-ng/client/data-flow/components/data-flow-section/data-flow-section.html index 8eda6a3fcf..2fe3d20123 100644 --- a/waltz-ng/client/data-flow/components/data-flow-section/data-flow-section.html +++ b/waltz-ng/client/data-flow/components/data-flow-section/data-flow-section.html @@ -299,8 +299,9 @@

Bulk Insert Logical Data Flows

- - + +
-
- - -
- - - - - None defined - - - + +
diff --git a/waltz-ng/client/flow-classification-rule/components/section/flow-classification-rules-section.js b/waltz-ng/client/flow-classification-rule/components/section/flow-classification-rules-section.js index 4ef6ec9268..8348ab3990 100644 --- a/waltz-ng/client/flow-classification-rule/components/section/flow-classification-rules-section.js +++ b/waltz-ng/client/flow-classification-rule/components/section/flow-classification-rules-section.js @@ -25,6 +25,7 @@ import {hierarchyQueryScope} from "../../../common/services/enums/hierarchy-quer import {entityLifecycleStatus} from "../../../common/services/enums/entity-lifecycle-status"; import template from "./flow-classification-rules-section.html"; +import FlowClassificationRulesPanel from "../summary-list/FlowClassificationRulesPanel.svelte"; const bindings = { filters: "<", @@ -41,7 +42,7 @@ const allTabDefinitions = [ name: "Flow Classification Scorecard", template: "wass-scorecard-tab-content" }, { - name: "Rated Sources", + name: "Rules", template: "wass-sources-tab-content" }, { name: "Discouraged Sources", @@ -51,7 +52,7 @@ const allTabDefinitions = [ const initialState = { - classificationRules: [], + FlowClassificationRulesPanel, visibility: { sourceDataRatingsOverlay: false, }, @@ -91,21 +92,9 @@ function controller(serviceBroker) { .then(r => vm.discouragedSources = r.data); }; - const loadFlowClassificationRules = () => { - vm.selectionOptions = mkSelector(); - serviceBroker - .loadViewData( - CORE_API.FlowClassificationRuleStore.view, - [vm.selectionOptions]) - .then(r => { - vm.classificationRules = r.data; - }); - }; - vm.$onInit = () => { vm.tabDefinitions = mkTabDefinitionsForKind(vm.parentEntityRef.kind); vm.selectedTabName = _.first(vm.tabDefinitions).name; - loadFlowClassificationRules(); loadDiscouragedSources(); }; diff --git a/waltz-ng/client/flow-classification-rule/components/summary-list/FlowClassificationRuleEditor2.svelte b/waltz-ng/client/flow-classification-rule/components/summary-list/FlowClassificationRuleEditor2.svelte new file mode 100644 index 0000000000..5c3e655919 --- /dev/null +++ b/waltz-ng/client/flow-classification-rule/components/summary-list/FlowClassificationRuleEditor2.svelte @@ -0,0 +1,210 @@ + + +{#if !_.isNil(formData)} +
+ + + + + {#if isNew} + +
+ + +
+

Start typing to select the subject application, actor or end user application

+ + +
+ + +
+

Start typing to select the selector for which this flow classification rule will apply to. This could be an organisational unit, application, edn user application or actor.

+ + +
+ {#if formData.dataType} + {formData.dataType.name} + +

Datatype for which this application / actor determines flow + classifications

+ {:else} + +

Select the datatype which this rule will be valid for. All child data types are included.

+
+ By not selecting a data type this rule will apply to all types +
+ {/if} +
+ + {/if} + + + +