From faec0219fb0c90bf6167cfd942fde1e0e4b2150b Mon Sep 17 00:00:00 2001 From: james-strauss-uwa Date: Mon, 15 Jan 2024 15:47:13 +0800 Subject: [PATCH] Add checkGraph rule to update nodes with the the legacy 'Component' category --- src/Edge.ts | 2 +- src/Node.ts | 10 ++++++++++ src/Utils.ts | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Edge.ts b/src/Edge.ts index a1670cc9e..f27e45161 100644 --- a/src/Edge.ts +++ b/src/Edge.ts @@ -345,7 +345,7 @@ export class Edge { // this is not supported. How would a BashShellApp read data from another process? if ((sourceNode.getCategory() === Category.Memory && destinationNode.getCategory() === Category.BashShellApp) || (sourceNode.getCategory() === Category.Memory && destinationNode.isGroup() && destinationNode.getInputApplication() !== undefined && destinationNode.hasInputApplication() && destinationNode.getInputApplication().getCategory() === Category.BashShellApp)){ - const issue: Errors.Issue = Errors.ShowFix("output from Memory Node cannot be input into a BashShellApp or input into a Group Node with a BashShellApp inputApplicationType", function(){Utils.showNode(eagle, Eagle.FileType.Graph, sourceNode.getId())}, function(){Utils.fixNodeCategory(eagle, sourceNode, Category.File)}, "Change data component type to File"); + const issue: Errors.Issue = Errors.ShowFix("output from Memory Node cannot be input into a BashShellApp or input into a Group Node with a BashShellApp inputApplicationType", function(){Utils.showNode(eagle, Eagle.FileType.Graph, sourceNode.getId())}, function(){Utils.fixNodeCategory(eagle, sourceNode, Category.File, Category.Type.Data)}, "Change data component type to File"); Edge.isValidLog(edgeId, Eagle.LinkValid.Invalid, issue, showNotification, showConsole, errorsWarnings); } diff --git a/src/Node.ts b/src/Node.ts index ec0029cae..10be51584 100644 --- a/src/Node.ts +++ b/src/Node.ts @@ -591,6 +591,10 @@ export class Node { return this.categoryType(); } + setCategoryType = (categoryType: Category.Type) : void => { + this.categoryType(categoryType); + } + setRepositoryUrl = (url: string) : void => { this.repositoryUrl(url); } @@ -2048,6 +2052,12 @@ export class Node { } static isValid = (eagle: Eagle, node: Node, selectedLocation: Eagle.FileType, showNotification : boolean, showConsole : boolean, errorsWarnings: Errors.ErrorsWarnings) : Eagle.LinkValid => { + // check that node has modern (not legacy) category + if (node.getCategory() === Category.Component){ + const issue: Errors.Issue = Errors.ShowFix("Node " + node.getKey() + " (" + node.getName() + ") has legacy category (" + node.getCategory() + ")", function(){Utils.showNode(eagle, selectedLocation, node.getId());}, function(){Utils.fixNodeCategory(eagle, node, Category.PythonApp, Category.Type.Application)}, ""); + errorsWarnings.warnings.push(issue); + } + // check that all port dataTypes have been defined for (const port of node.getInputPorts()){ if (port.isType(Daliuge.DataType.Unknown)){ diff --git a/src/Utils.ts b/src/Utils.ts index 07e7b0f16..c82087d3b 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -1741,8 +1741,9 @@ export class Utils { } } - static fixNodeCategory(eagle: Eagle, node: Node, category: Category){ + static fixNodeCategory(eagle: Eagle, node: Node, category: Category, categoryType: Category.Type){ node.setCategory(category); + node.setCategoryType(categoryType); } // NOTE: merges field1 into field0