Skip to content

Commit

Permalink
Merge pull request #6666 from deutschebank/db-contrib/waltz-6665-fixes
Browse files Browse the repository at this point in the history
Db contrib/waltz 6665 fixes
  • Loading branch information
davidwatkins73 authored Jun 29, 2023
2 parents b25d544 + bfa3757 commit 6e4614d
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ private void mkRatings(EntityReference appRef, long... measurableIds) {
.provenance(PROVENANCE)
.lastUpdate(UserTimestamp.mkForUser(LAST_UPDATE_USER))
.description("test")
.isPrimary(false)
.build(), false);
}
}
Expand Down
50 changes: 50 additions & 0 deletions waltz-ng/client/common/hierarchy-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,54 @@ export function determineExpandedNodes(hierarchy, maxDepth = 100) {
.concat()
.flatten()
.value();
}



/**
* Given a list of flat nodes and a starting node id will return a 'sliver' of the
* tree with all parents and children of the starting node populated. All other
* nodes are omitted.
*
* @param flatNodes starting list of nodes
* @param nodeId starting node id
* @param idFn optional accessor for getting the node id (defaults to n=>n.id)
* @param parentIdFn optional accessor for getting the parent node id (defaults to n=>n.parentId)
* @returns {*} node at the top of the sliver, each node may have parent and children attributes populated
*/
export function directLineage(flatNodes,
nodeId,
idFn = n => n.id,
parentIdFn = n => n.parentId) {
const byId = _.keyBy(flatNodes, idFn);
const byParentId = _.groupBy(flatNodes, parentIdFn);

const start = byId[nodeId];

// parents
let parent = byId[parentIdFn(start)];
let ptr = start;
while(parent != null) {
ptr.parent = parent;
parent.children = [ptr];
ptr = parent;
parent = byId[parentIdFn(parent)];
}

// recursively populate children
const recurse = (node) => {
const kids = byParentId[idFn(node)];
if (kids) {
node.children = kids;
_.each(kids, recurse);
}
}
recurse(start);

// find head
let head = start;
while (head.parent != null) {
head = head.parent;
}
return head;
}
2 changes: 1 addition & 1 deletion waltz-ng/client/common/services/service-broker.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function loadData($injector,
})).catch(error => {
//evict the cache entry because it's in error
cache.delete(cacheKey);
console.warn(`ServiceBroker::loadData - ${serviceName}.${serviceFnName}: ${error.statusText} - ${error.data.message}`, targetParams);
console.warn(`ServiceBroker::loadData - ${serviceName}.${serviceFnName}: ${error.statusText} - ${error.data?.message}`, targetParams);
throw error;
});
return resultPromise;
Expand Down
6 changes: 3 additions & 3 deletions waltz-ng/client/data-flow/components/svelte/Categories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
parentCategory,
startingCategory
} from "./flow-decorator-store";
import {colors, dimensions} from "./flow-decorator-utils"
import {dimensions, getNodeColors} from "./flow-decorator-utils"
import {truncateMiddle} from "../../../common/string-utils";
import {symbol, symbolCircle, symbolTriangle} from "d3-shape";
import {createEventDispatcher} from "svelte";
Expand Down Expand Up @@ -58,8 +58,8 @@
</script>

<rect fill={colors[kind].fill}
stroke={colors[kind].stroke}
<rect fill={getNodeColors(kind).fill}
stroke={getNodeColors(kind).stroke}
x={20}
width={dimensions.category.width - 40}
height={dimensions.diagram.height}>
Expand Down
6 changes: 3 additions & 3 deletions waltz-ng/client/data-flow/components/svelte/Clients.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Modes,
selectedClient
} from "./flow-decorator-store";
import {colors, dimensions} from "./flow-decorator-utils"
import {dimensions, getNodeColors} from "./flow-decorator-utils"
import {truncateMiddle} from "../../../common/string-utils";
import _ from "lodash";
Expand Down Expand Up @@ -44,8 +44,8 @@
class={mkClasses(client)}
on:click|stopPropagation={() => selectClient(client)}
on:keydown|stopPropagation={() => selectClient(client)}>
<rect stroke={colors[client.kind].stroke}
fill={colors[client.kind].fill}
<rect stroke={getNodeColors(client.kind).stroke}
fill={getNodeColors(client.kind).fill}
on:mouseenter={() => onMouseEnter(client)}
on:mouseleave={() => onMouseLeave()}
rx={dimensions.client.height / 2}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from "lodash";

export const colors = {
const colors = {
APPLICATION: {
fill: "#eef8ff",
stroke: "#6fbdff"
Expand All @@ -12,6 +12,13 @@ export const colors = {
};


export function getNodeColors(kind) {
const c = colors[kind];

return c || { fill: "#ccc", stroke: "#999" };
}


export const dimensions = {
client: {
height: 25,
Expand Down
32 changes: 24 additions & 8 deletions waltz-web/src/main/java/org/finos/waltz/web/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@
package org.finos.waltz.web;

import org.eclipse.jetty.http.HttpStatus;
import org.finos.waltz.service.DIConfiguration;
import org.finos.waltz.service.settings.SettingsService;
import org.finos.waltz.web.endpoints.Endpoint;
import org.finos.waltz.web.endpoints.api.StaticResourcesEndpoint;
import org.finos.waltz.web.endpoints.extracts.DataExtractor;
import org.finos.waltz.common.LoggingUtilities;
import org.finos.waltz.common.exception.DuplicateKeyException;
import org.finos.waltz.common.exception.InsufficientPrivelegeException;
import org.finos.waltz.common.exception.NotFoundException;
import org.finos.waltz.common.exception.UpdateFailedException;
import org.finos.waltz.service.DIConfiguration;
import org.finos.waltz.service.settings.SettingsService;
import org.finos.waltz.web.endpoints.Endpoint;
import org.finos.waltz.web.endpoints.EndpointUtilities;
import org.finos.waltz.web.endpoints.api.StaticResourcesEndpoint;
import org.finos.waltz.web.endpoints.extracts.DataExtractor;
import org.jooq.exception.DataAccessException;
import org.jooq.exception.NoDataFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
Expand All @@ -42,9 +43,13 @@
import java.util.Map;
import java.util.TimeZone;

import static org.finos.waltz.web.WebUtilities.reportException;
import static java.lang.String.format;
import static org.finos.waltz.common.DateTimeUtilities.UTC;
import static spark.Spark.*;
import static org.finos.waltz.web.WebUtilities.reportException;
import static spark.Spark.after;
import static spark.Spark.before;
import static spark.Spark.options;
import static spark.Spark.port;

public class Main {

Expand Down Expand Up @@ -144,6 +149,17 @@ private void registerExceptionHandlers() {
LOG);
});

EndpointUtilities.addExceptionHandler(NoDataFoundException.class, (e, req, res) -> {
String message = "Not found exception" + e.getMessage();
LOG.error(message, e);
reportException(
HttpStatus.NOT_FOUND_404,
"NO_DATA",
message,
res,
LOG);
});

EndpointUtilities.addExceptionHandler(UpdateFailedException.class, (e, req, res) -> {
String message = "Update failed exception:" + e.getMessage();
LOG.error(message, e);
Expand Down Expand Up @@ -178,7 +194,7 @@ private void registerExceptionHandlers() {
});

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

0 comments on commit 6e4614d

Please sign in to comment.