Skip to content

Commit

Permalink
Merge pull request #7042 from deutschebank/db-contrib/waltz-7032-flow…
Browse files Browse the repository at this point in the history
…-classifications-add-directionality

Db contrib/waltz 7032 flow classifications add directionality
  • Loading branch information
davidwatkins73 committed Apr 4, 2024
2 parents 639af46 + 76333de commit ca36aa7
Show file tree
Hide file tree
Showing 8 changed files with 327 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@

package org.finos.waltz.common;

import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static org.finos.waltz.common.Checks.checkNotEmpty;


public class CollectionUtilities {

Expand Down Expand Up @@ -242,5 +245,4 @@ public static Long sumInts(Collection<Integer> values) {
return acc;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.toList;
import static org.finos.waltz.common.Checks.checkNotNull;
Expand Down Expand Up @@ -205,6 +206,17 @@ public static <T> T getOrDefault(List<T> xs, int idx, T defaultValue) {
}


public static <X> List<X> take(Collection<X> xs,
int amount) {
return ListUtilities
.ensureNotNull(xs)
.stream()
.limit(amount)
.collect(Collectors.toList());
}



/**
* Returns a list of distinct values from a given list
* @param ts a list of T's with possible duplicates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.finos.waltz.data.InlineSelectFieldFactory;
import org.finos.waltz.model.EntityKind;
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.flow_classification_rule.DiscouragedSource;
Expand Down Expand Up @@ -372,7 +373,12 @@ public List<FlowClassificationRuleVantagePoint> findExpandedFlowClassificationRu
}


public List<FlowClassificationRuleVantagePoint> findFlowClassificationRuleVantagePoints() {
public List<FlowClassificationRuleVantagePoint> findFlowClassificationRuleVantagePoints(FlowDirection direction) {
return findFlowClassificationRuleVantagePoints(FLOW_CLASSIFICATION.DIRECTION.eq(direction.name()));
}


private List<FlowClassificationRuleVantagePoint> findFlowClassificationRuleVantagePoints(Condition condition) {
SelectSeekStep4<Record8<Long, Integer, Long, Integer, Long, String, String, Long>, Integer, Integer, Long, Long> select = dsl
.select(targetOrgUnitId,
declaredOrgUnitLevel,
Expand All @@ -394,6 +400,7 @@ public List<FlowClassificationRuleVantagePoint> findFlowClassificationRuleVantag
.and(ehDataType.KIND.eq(EntityKind.DATA_TYPE.name()))
.and(ehDataType.ID.eq(ehDataType.ANCESTOR_ID)))
.innerJoin(FLOW_CLASSIFICATION).on(FLOW_CLASSIFICATION_RULE.FLOW_CLASSIFICATION_ID.eq(FLOW_CLASSIFICATION.ID))
.where(condition)
.orderBy(
ehOrgUnit.LEVEL.desc(),
ehDataType.LEVEL.desc(),
Expand Down Expand Up @@ -533,7 +540,7 @@ private SelectOnConditionStep<Record> baseSelect() {
}


public int updatePointToPointFlowClassificationRules() {
public int updatePointToPointFlowClassificationRules(FlowDirection direction) {

Condition logicalFlowTargetIsAuthSourceParent = FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_ID.eq(LOGICAL_FLOW.SOURCE_ENTITY_ID)
.and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(FLOW_CLASSIFICATION_RULE.SUBJECT_ENTITY_KIND)
Expand All @@ -558,7 +565,7 @@ public int updatePointToPointFlowClassificationRules() {
.and(level.ID.eq(level.ANCESTOR_ID)
.and(level.KIND.eq(EntityKind.DATA_TYPE.name()))))
.innerJoin(FLOW_CLASSIFICATION).on(FLOW_CLASSIFICATION_RULE.FLOW_CLASSIFICATION_ID.eq(FLOW_CLASSIFICATION.ID))
.where(FLOW_CLASSIFICATION.CODE.ne(LOGICAL_FLOW_DECORATOR.RATING))
.where(FLOW_CLASSIFICATION.CODE.ne(LOGICAL_FLOW_DECORATOR.RATING).and(FLOW_CLASSIFICATION.DIRECTION.eq(direction.name())))
.orderBy(level.LEVEL)
.fetch()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

import org.finos.waltz.common.ListUtilities;
import org.finos.waltz.data.SearchDao;
import org.finos.waltz.data.legal_entity.LegalEntityDao;
import org.finos.waltz.data.licence.LicenceDao;
import org.finos.waltz.model.entity_search.EntitySearchOptions;
import org.finos.waltz.model.legal_entity.LegalEntity;
import org.finos.waltz.model.licence.Licence;
import org.jooq.Condition;
import org.jooq.DSLContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;

import static java.util.Collections.emptyList;
import static org.finos.waltz.common.ListUtilities.concat;
Expand All @@ -23,7 +19,7 @@
import static org.finos.waltz.data.SearchUtilities.mkTerms;
import static org.finos.waltz.schema.Tables.LICENCE;

@Service
@Repository
public class LicenceSearchDao implements SearchDao<Licence> {

private final DSLContext dsl;
Expand Down
Loading

0 comments on commit ca36aa7

Please sign in to comment.