Skip to content

Commit 6ae859b

Browse files
committed
Small fixes for 1.51
#CTCTOWALTZ-2780 #6665
1 parent 905d62e commit 6ae859b

7 files changed

Lines changed: 90 additions & 16 deletions

File tree

waltz-integration-test/src/test/java/org/finos/waltz/integration_test/inmem/dao/MeasurableRatingDaoTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ private void mkRatings(EntityReference appRef, long... measurableIds) {
198198
.provenance(PROVENANCE)
199199
.lastUpdate(UserTimestamp.mkForUser(LAST_UPDATE_USER))
200200
.description("test")
201+
.isPrimary(false)
201202
.build(), false);
202203
}
203204
}

waltz-ng/client/common/hierarchy-utils.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,54 @@ export function determineExpandedNodes(hierarchy, maxDepth = 100) {
289289
.concat()
290290
.flatten()
291291
.value();
292+
}
293+
294+
295+
296+
/**
297+
* Given a list of flat nodes and a starting node id will return a 'sliver' of the
298+
* tree with all parents and children of the starting node populated. All other
299+
* nodes are omitted.
300+
*
301+
* @param flatNodes starting list of nodes
302+
* @param nodeId starting node id
303+
* @param idFn optional accessor for getting the node id (defaults to n=>n.id)
304+
* @param parentIdFn optional accessor for getting the parent node id (defaults to n=>n.parentId)
305+
* @returns {*} node at the top of the sliver, each node may have parent and children attributes populated
306+
*/
307+
export function directLineage(flatNodes,
308+
nodeId,
309+
idFn = n => n.id,
310+
parentIdFn = n => n.parentId) {
311+
const byId = _.keyBy(flatNodes, idFn);
312+
const byParentId = _.groupBy(flatNodes, parentIdFn);
313+
314+
const start = byId[nodeId];
315+
316+
// parents
317+
let parent = byId[parentIdFn(start)];
318+
let ptr = start;
319+
while(parent != null) {
320+
ptr.parent = parent;
321+
parent.children = [ptr];
322+
ptr = parent;
323+
parent = byId[parentIdFn(parent)];
324+
}
325+
326+
// recursively populate children
327+
const recurse = (node) => {
328+
const kids = byParentId[idFn(node)];
329+
if (kids) {
330+
node.children = kids;
331+
_.each(kids, recurse);
332+
}
333+
}
334+
recurse(start);
335+
336+
// find head
337+
let head = start;
338+
while (head.parent != null) {
339+
head = head.parent;
340+
}
341+
return head;
292342
}

waltz-ng/client/common/services/service-broker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function loadData($injector,
132132
})).catch(error => {
133133
//evict the cache entry because it's in error
134134
cache.delete(cacheKey);
135-
console.warn(`ServiceBroker::loadData - ${serviceName}.${serviceFnName}: ${error.statusText} - ${error.data.message}`, targetParams);
135+
console.warn(`ServiceBroker::loadData - ${serviceName}.${serviceFnName}: ${error.statusText} - ${error.data?.message}`, targetParams);
136136
throw error;
137137
});
138138
return resultPromise;

waltz-ng/client/data-flow/components/svelte/Categories.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
parentCategory,
99
startingCategory
1010
} from "./flow-decorator-store";
11-
import {colors, dimensions} from "./flow-decorator-utils"
11+
import {dimensions, getNodeColors} from "./flow-decorator-utils"
1212
import {truncateMiddle} from "../../../common/string-utils";
1313
import {symbol, symbolCircle, symbolTriangle} from "d3-shape";
1414
import {createEventDispatcher} from "svelte";
@@ -58,8 +58,8 @@
5858
5959
</script>
6060

61-
<rect fill={colors[kind].fill}
62-
stroke={colors[kind].stroke}
61+
<rect fill={getNodeColors(kind).fill}
62+
stroke={getNodeColors(kind).stroke}
6363
x={20}
6464
width={dimensions.category.width - 40}
6565
height={dimensions.diagram.height}>

waltz-ng/client/data-flow/components/svelte/Clients.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Modes,
1212
selectedClient
1313
} from "./flow-decorator-store";
14-
import {colors, dimensions} from "./flow-decorator-utils"
14+
import {dimensions, getNodeColors} from "./flow-decorator-utils"
1515
import {truncateMiddle} from "../../../common/string-utils";
1616
1717
import _ from "lodash";
@@ -44,8 +44,8 @@
4444
class={mkClasses(client)}
4545
on:click|stopPropagation={() => selectClient(client)}
4646
on:keydown|stopPropagation={() => selectClient(client)}>
47-
<rect stroke={colors[client.kind].stroke}
48-
fill={colors[client.kind].fill}
47+
<rect stroke={getNodeColors(client.kind).stroke}
48+
fill={getNodeColors(client.kind).fill}
4949
on:mouseenter={() => onMouseEnter(client)}
5050
on:mouseleave={() => onMouseLeave()}
5151
rx={dimensions.client.height / 2}

waltz-ng/client/data-flow/components/svelte/flow-decorator-utils.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from "lodash";
22

3-
export const colors = {
3+
const colors = {
44
APPLICATION: {
55
fill: "#eef8ff",
66
stroke: "#6fbdff"
@@ -12,6 +12,13 @@ export const colors = {
1212
};
1313

1414

15+
export function getNodeColors(kind) {
16+
const c = colors[kind];
17+
18+
return c || { fill: "#ccc", stroke: "#999" };
19+
}
20+
21+
1522
export const dimensions = {
1623
client: {
1724
height: 25,

waltz-web/src/main/java/org/finos/waltz/web/Main.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@
1919
package org.finos.waltz.web;
2020

2121
import org.eclipse.jetty.http.HttpStatus;
22-
import org.finos.waltz.service.DIConfiguration;
23-
import org.finos.waltz.service.settings.SettingsService;
24-
import org.finos.waltz.web.endpoints.Endpoint;
25-
import org.finos.waltz.web.endpoints.api.StaticResourcesEndpoint;
26-
import org.finos.waltz.web.endpoints.extracts.DataExtractor;
2722
import org.finos.waltz.common.LoggingUtilities;
2823
import org.finos.waltz.common.exception.DuplicateKeyException;
2924
import org.finos.waltz.common.exception.InsufficientPrivelegeException;
3025
import org.finos.waltz.common.exception.NotFoundException;
3126
import org.finos.waltz.common.exception.UpdateFailedException;
27+
import org.finos.waltz.service.DIConfiguration;
28+
import org.finos.waltz.service.settings.SettingsService;
29+
import org.finos.waltz.web.endpoints.Endpoint;
3230
import org.finos.waltz.web.endpoints.EndpointUtilities;
31+
import org.finos.waltz.web.endpoints.api.StaticResourcesEndpoint;
32+
import org.finos.waltz.web.endpoints.extracts.DataExtractor;
3333
import org.jooq.exception.DataAccessException;
34+
import org.jooq.exception.NoDataFoundException;
3435
import org.slf4j.Logger;
3536
import org.slf4j.LoggerFactory;
3637
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -42,9 +43,13 @@
4243
import java.util.Map;
4344
import java.util.TimeZone;
4445

45-
import static org.finos.waltz.web.WebUtilities.reportException;
46+
import static java.lang.String.format;
4647
import static org.finos.waltz.common.DateTimeUtilities.UTC;
47-
import static spark.Spark.*;
48+
import static org.finos.waltz.web.WebUtilities.reportException;
49+
import static spark.Spark.after;
50+
import static spark.Spark.before;
51+
import static spark.Spark.options;
52+
import static spark.Spark.port;
4853

4954
public class Main {
5055

@@ -144,6 +149,17 @@ private void registerExceptionHandlers() {
144149
LOG);
145150
});
146151

152+
EndpointUtilities.addExceptionHandler(NoDataFoundException.class, (e, req, res) -> {
153+
String message = "Not found exception" + e.getMessage();
154+
LOG.error(message, e);
155+
reportException(
156+
HttpStatus.NOT_FOUND_404,
157+
"NO_DATA",
158+
message,
159+
res,
160+
LOG);
161+
});
162+
147163
EndpointUtilities.addExceptionHandler(UpdateFailedException.class, (e, req, res) -> {
148164
String message = "Update failed exception:" + e.getMessage();
149165
LOG.error(message, e);
@@ -178,7 +194,7 @@ private void registerExceptionHandlers() {
178194
});
179195

180196
EndpointUtilities.addExceptionHandler(DataAccessException.class, (e, req, resp) -> {
181-
String message = "Exception: " + e.getCause().getMessage();
197+
String message = format("Data Access Exception: %s [%s]", e.getCause(), e.getClass().getName());
182198
LOG.error(message, e);
183199
reportException(
184200
HttpStatus.BAD_REQUEST_400,

0 commit comments

Comments
 (0)