Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flow-translator/flow-translator-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.codice.keip</groupId>
<artifactId>flow-translator-webapp</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>

<packaging>jar</packaging>

Expand Down Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>org.codice.keip.xsd</groupId>
<artifactId>eip-schema-definitions</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/palette/EipComponentPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EipId } from "../../api/generated/eipFlow"
import { EIP_SCHEMA } from "../../singletons/eipDefinitions"
import getIconUrl from "../../singletons/eipIconCatalog"
import { useNodeCount } from "../../singletons/store/getterHooks"
import { toTitleCase } from "../../utils/titleTransform"
import { getNamespaceAlias, toTitleCase } from "../../utils/titleTransform"
import { DragTypes } from "./dragTypes"

interface Namespace {
Expand Down Expand Up @@ -67,7 +67,7 @@ const EipNamespaceCollection = ({

return (
<AccordionItem
title={toTitleCase(namespace.name)}
title={toTitleCase(getNamespaceAlias(namespace.name))}
open={allExpanded || expandedNamespace === namespace.name}
onHeadingClick={({ isOpen }) => handleExpand(isOpen)}
>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/json/springIntegrationEipComponents.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ui/src/singletons/eipDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const contentBasedRouterTargets: ReadonlyMap<string, RouterTarget> = new Map([
{ name: "header-name", type: "attribute" },
],
["integration.router", { name: "expression", type: "attribute" }],
["xml.xpath-router", { name: "xpath-expression", type: "child" }],
["int-xml.xpath-router", { name: "xpath-expression", type: "child" }],
])

export const lookupContentBasedRouterKeys = (
Expand Down
166 changes: 142 additions & 24 deletions ui/src/singletons/store/__snapshots__/appActions.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports[`import flow from an exported JSON file > 'import a deprecated flow part
"eipIds": [
{
"name": "inbound-gateway",
"namespace": "web-services",
"namespace": "ws",
},
{
"name": "transformer",
Expand Down Expand Up @@ -99,48 +99,46 @@ exports[`import flow from an exported JSON file > 'import a deprecated flow part
}
`;

exports[`import flow from an exported JSON file > 'import a valid flow success' 1`] = `
exports[`import flow from an exported JSON file > 'import a flow with deprecated namespa…' 1`] = `
{
"children": [
{
"81HAL73ElW": [],
"EhSdB7aSPh": [],
},
{
"Hz22QyhCpj": [],
"e5ZObyhckj": [],
},
{
"THgI9WvsJh": [
"mbL_mB1wGOY",
],
"PFC0tD2Jjq": [],
},
],
"edges": [
{
"id": "reactflow__edge-81HAL73ElWoutput-Hz22QyhCpjinput",
"source": "81HAL73ElW",
"id": "xy-edge__EhSdB7aSPhoutput-e5ZObyhckjinput",
"source": "EhSdB7aSPh",
"sourceHandle": "output",
"target": "Hz22QyhCpj",
"target": "e5ZObyhckj",
"targetHandle": "input",
},
{
"id": "reactflow__edge-Hz22QyhCpjoutput-THgI9WvsJhinput",
"source": "Hz22QyhCpj",
"id": "xy-edge__PFC0tD2Jjqoutput-EhSdB7aSPhinput",
"source": "PFC0tD2Jjq",
"sourceHandle": "output",
"target": "THgI9WvsJh",
"target": "EhSdB7aSPh",
"targetHandle": "input",
},
],
"eipIds": [
{
"name": "inbound-gateway",
"namespace": "web-services",
"name": "xpath-transformer",
"namespace": "int-xml",
},
{
"name": "transformer",
"namespace": "integration",
"name": "outbound-gateway",
"namespace": "ws",
},
{
"name": "outbound-gateway",
"name": "inbound-channel-adapter",
"namespace": "http",
},
],
Expand All @@ -151,11 +149,51 @@ exports[`import flow from an exported JSON file > 'import a valid flow success'
"nodes": [
{
"data": {
"label": "ws-in",
"label": "transform",
},
"dragging": false,
"height": 124,
"id": "81HAL73ElW",
"id": "EhSdB7aSPh",
"measured": {
"height": 90,
"width": 104,
},
"position": {
"x": 203,
"y": 22.5,
},
"selected": false,
"sourcePosition": "right",
"targetPosition": "left",
"type": "eipNode",
},
{
"data": {
"label": "out1",
},
"dragging": false,
"id": "e5ZObyhckj",
"measured": {
"height": 127,
"width": 128,
},
"position": {
"x": 382,
"y": 4,
},
"selected": false,
"sourcePosition": "right",
"targetPosition": "left",
"type": "eipNode",
},
{
"data": {
"label": "in1",
},
"id": "PFC0tD2Jjq",
"measured": {
"height": 135,
"width": 128,
},
"position": {
"x": 0,
"y": 0,
Expand All @@ -164,16 +202,73 @@ exports[`import flow from an exported JSON file > 'import a valid flow success'
"sourcePosition": "right",
"targetPosition": "left",
"type": "eipNode",
"width": 128,
},
],
}
`;

exports[`import flow from an exported JSON file > 'import a valid flow success' 1`] = `
{
"children": [
{
"Hz22QyhCpj": [],
},
{
"THgI9WvsJh": [
"mbL_mB1wGOY",
],
},
{
"OuC9d1xC5e": [],
},
],
"edges": [
{
"id": "reactflow__edge-Hz22QyhCpjoutput-THgI9WvsJhinput",
"source": "Hz22QyhCpj",
"sourceHandle": "output",
"target": "THgI9WvsJh",
"targetHandle": "input",
},
{
"id": "xy-edge__OuC9d1xC5eoutput-Hz22QyhCpjinput",
"source": "OuC9d1xC5e",
"sourceHandle": "output",
"target": "Hz22QyhCpj",
"targetHandle": "input",
},
],
"eipIds": [
{
"name": "transformer",
"namespace": "integration",
},
{
"name": "outbound-gateway",
"namespace": "http",
},
{
"name": "message-driven-channel-adapter",
"namespace": "jms",
},
],
"layout": {
"density": "comfortable",
"orientation": "horizontal",
},
"nodes": [
{
"data": {},
"dragging": false,
"height": 87,
"id": "Hz22QyhCpj",
"measured": {
"height": 87,
"width": 99,
},
"position": {
"x": 203,
"y": 18.5,
"y": 24,
},
"selected": false,
"sourcePosition": "right",
Expand All @@ -186,16 +281,39 @@ exports[`import flow from an exported JSON file > 'import a valid flow success'
"dragging": false,
"height": 121,
"id": "THgI9WvsJh",
"measured": {
"height": 121,
"width": 109,
},
"position": {
"x": 377,
"y": 5.5,
"y": 7,
},
"selected": false,
"sourcePosition": "right",
"targetPosition": "left",
"type": "eipNode",
"width": 109,
},
{
"data": {
"label": "jms-in",
},
"dragging": false,
"id": "OuC9d1xC5e",
"measured": {
"height": 135,
"width": 128,
},
"position": {
"x": 0,
"y": 0,
},
"selected": false,
"sourcePosition": "right",
"targetPosition": "left",
"type": "eipNode",
},
],
}
`;
5 changes: 5 additions & 0 deletions ui/src/singletons/store/appActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
getNodesView,
} from "./storeViews"
import deprecatedExportedFlow from "./testdata/exported-diagrams/deprecatedFlow.json?raw"
import deprecatedNamespacesFlow from "./testdata/exported-diagrams/deprecatedNamespaces.json?raw"
import validExportedFlow from "./testdata/exported-diagrams/validFlow.json?raw"

vi.mock("zustand")
Expand Down Expand Up @@ -594,6 +595,10 @@ describe("import flow from an exported JSON file", () => {
msg: "import a deprecated flow partial success",
flow: deprecatedExportedFlow,
},
{
msg: "import a flow with deprecated namespaces success",
flow: deprecatedNamespacesFlow,
},
])("$msg", ({ flow }) => {
const initNodes = getNodesView()

Expand Down
45 changes: 41 additions & 4 deletions ui/src/singletons/store/appActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,16 @@ export const importFlowFromObject = (flow: SerializedFlow) => {
throw new Error("Failed to import an EIP flow JSON. Malformed input")
}

// Maintain backwards compatibility with older exported formats
if (!flow.eipConfigs && !flow.version) {
return importDeprecatedFlow(flow)
}

const eipConfigs = convertDeprecatedNamespaces(flow.eipConfigs)

return {
nodes: flow.nodes,
edges: flow.edges,
eipConfigs: flow.eipConfigs,
eipConfigs,
customEntities: flow.customEntities ?? {},
}
})
Expand Down Expand Up @@ -418,15 +419,15 @@ const isStoreType = (state: unknown): state is AppStore => {
)
}

// Maintains compatibility with older exported formats
// Maintain backwards compatibility with older exported formats
const importDeprecatedFlow = (flow: SerializedFlow): Partial<AppStore> => {
const eipConfigs = {} as AppStore["eipConfigs"]
const nodes = flow.nodes.map((node) => {
const { eipId: oldEipId, ...rest } = node.data as { eipId: EipId }
eipConfigs[node.id] = {
attributes: {},
children: [],
eipId: oldEipId,
eipId: fixDeprecatedEipId(oldEipId),
}
return {
...node,
Expand All @@ -441,6 +442,42 @@ const importDeprecatedFlow = (flow: SerializedFlow): Partial<AppStore> => {
}
}

const DEPRECATED_EIP_NAMESPACES: Record<string, string> = {
xml: "int-xml",
"web-services": "ws",
}

// Maintain backwards compatibility with older exported namespaces
const convertDeprecatedNamespaces = (
eipConfigs: SerializedFlow["eipConfigs"]
) =>
Object.fromEntries(
Object.entries(eipConfigs).map(([id, config]) => {
const eipId = config.eipId
if (eipId.namespace in DEPRECATED_EIP_NAMESPACES) {
const convertedEipId = fixDeprecatedEipId(eipId)

console.warn(
`Imported flow has a deprecated namespace '${eipId.namespace}'. Converting the namespace to '${convertedEipId.namespace}'.`
)

return [
id,
{
...config,
eipId: convertedEipId,
},
]
}
return [id, config]
})
)

const fixDeprecatedEipId = (eipId: EipId): EipId => ({
...eipId,
namespace: DEPRECATED_EIP_NAMESPACES[eipId.namespace] ?? eipId.namespace,
})

const isWellFormedXML = (content: string) => {
if (!content) {
return false
Expand Down
Loading