Skip to content

Commit

Permalink
Add checkGraph rule to update nodes with the the legacy 'Component' c…
Browse files Browse the repository at this point in the history
…ategory
  • Loading branch information
james-strauss-uwa committed Jan 15, 2024
1 parent 0c9e041 commit faec021
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 10 additions & 0 deletions src/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)){
Expand Down
3 changes: 2 additions & 1 deletion src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit faec021

Please sign in to comment.