Skip to content

Commit

Permalink
Merge pull request #7139 from deutschebank/db-contrib/waltz-6595-bulk…
Browse files Browse the repository at this point in the history
…-taxonomy

Db contrib/waltz 6595 bulk taxonomy
  • Loading branch information
davidwatkins73 authored Sep 16, 2024
2 parents 559fba4 + 0fbc7c2 commit f908776
Show file tree
Hide file tree
Showing 50 changed files with 2,955 additions and 124 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-csv</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ public static <K, R, V> Map<K, R> indexBy(Collection<V> xs,

public static <K, V> Map<K, Long> countBy(Function<V, K> keyFn,
Collection<V> xs) {
return countBy(xs, keyFn);
}

public static <K, V> Map<K, Long> countBy(Collection<V> xs,
Function<V, K> keyFn) {
if (xs == null) {
return emptyMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,8 @@ public static <T> Set<T> add(Set<T> orig, T... ts) {
public static <T> Set<T> remove(Set<T> orig, T... ts) {
return minus(orig, asSet(ts));
}

public static <T> Set<T> compact(T... ts) {
return remove(asSet(ts), (T) null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public static <T> Stream<T> concat(Stream<T>... streams) {
}


public static Stream<String> lines(String multiLineStr) {
String[] lines = multiLineStr.split("(\n|\r|\r\n)");
return Stream.of(lines);
}


public static class Siphon<T> implements Predicate<T> {
private final Predicate<T> pred;
private final List<T> results = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,5 +327,37 @@ public static Optional<String> firstNonNull(String... xs) {
.findFirst();
}


public static boolean safeEq(String expected, String actual) {
if(actual == null && expected == null) {
return true;
} else if(actual == null || expected == null) {
return false;
} else {
return actual.equals(expected);
}
}


public static boolean safeEqIgnoreCase(String expected, String actual) {
if(actual == null && expected == null) {
return true;
} else if(actual == null || expected == null) {
return false;
} else {
return actual.equalsIgnoreCase(expected);
}
}


public static String mkExternalId(String str) {
return sanitizeCharacters(mkSafe(str))
.toUpperCase()
.replaceAll("&", " AND ")
.replaceAll("[\\s\\-(){}/\\\\,.*;]", "_")
.replaceAll("_+", "_");
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.finos.waltz.common;

import org.junit.jupiter.api.Test;

import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class StreamUtilities_linesTest {

@Test
public void simpleCase(){
Stream<String> emptyLine = StreamUtilities
.lines("");

assertEquals("", emptyLine.collect(Collectors.joining("")));

}


@Test
public void multiLines(){
Stream<String> output = StreamUtilities
.lines("a\nb\nc");

assertEquals("a#b#c", output.collect(Collectors.joining("#")));

}


@Test
public void onlyOneLine(){
Stream<String> output = StreamUtilities
.lines("ddd");

assertEquals("<ddd>", output.collect(Collectors.joining("#", "<", ">")));

}


@Test
public void emptyLines(){
Stream<String> output = StreamUtilities
.lines("hello\n\nworld");

assertEquals("<hello##world>", output.collect(Collectors.joining("#", "<", ">")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ public List<Measurable> findByCategoryId(Long categoryId) {
}


public List<Measurable> findByCategoryId(Long categoryId, Set<EntityLifecycleStatus> statuses) {
return dsl
.select(MEASURABLE.fields())
.from(MEASURABLE)
.where(MEASURABLE.MEASURABLE_CATEGORY_ID.eq(categoryId))
.and(MEASURABLE.ENTITY_LIFECYCLE_STATUS.in(statuses))
.fetch(TO_DOMAIN_MAPPER);
}


public List<Measurable> findByParentId(Long parentId) {
return dsl
.select(MEASURABLE.fields())
Expand Down
Loading

0 comments on commit f908776

Please sign in to comment.