From b7f86fe6351e4bd0d6f5213db034289dfbb01c3a Mon Sep 17 00:00:00 2001
From: Kimia Kabiri <126855522+K-Kabiri@users.noreply.github.com>
Date: Mon, 9 Sep 2024 12:25:31 +0330
Subject: [PATCH] fix(Graph): edit GetRelationalEdgeBaseNode method and add
NodeHasNotEdgesException. (#117)
---
.../NodeException/NodeHasNotEdgesException.cs | 9 +++++++++
AnalysisData/AnalysisData/Resources.Designer.cs | 9 +++++++++
AnalysisData/AnalysisData/Resources.resx | 4 ++++
.../GraphServices/Relationship/GraphRelationService.cs | 10 ++++++++--
4 files changed, 30 insertions(+), 2 deletions(-)
create mode 100644 AnalysisData/AnalysisData/Exception/GraphException/NodeException/NodeHasNotEdgesException.cs
diff --git a/AnalysisData/AnalysisData/Exception/GraphException/NodeException/NodeHasNotEdgesException.cs b/AnalysisData/AnalysisData/Exception/GraphException/NodeException/NodeHasNotEdgesException.cs
new file mode 100644
index 0000000..19c6833
--- /dev/null
+++ b/AnalysisData/AnalysisData/Exception/GraphException/NodeException/NodeHasNotEdgesException.cs
@@ -0,0 +1,9 @@
+namespace AnalysisData.Exception.GraphException.NodeException;
+
+public class NodeHasNotEdgesException : ServiceException
+{
+ public NodeHasNotEdgesException() : base(Resources.NodeHasNotEdgesException,
+ StatusCodes.Status404NotFound)
+ {
+ }
+}
\ No newline at end of file
diff --git a/AnalysisData/AnalysisData/Resources.Designer.cs b/AnalysisData/AnalysisData/Resources.Designer.cs
index 519cda2..165d1d6 100644
--- a/AnalysisData/AnalysisData/Resources.Designer.cs
+++ b/AnalysisData/AnalysisData/Resources.Designer.cs
@@ -203,6 +203,15 @@ internal static string InvalidPhoneNumberFormatException {
}
}
+ ///
+ /// Looks up a localized string similar to no edges found for this node ! .
+ ///
+ internal static string NodeHasNotEdgesException {
+ get {
+ return ResourceManager.GetString("NodeHasNotEdgesException", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Header(s) Node is not accessible for this user! {0}.
///
diff --git a/AnalysisData/AnalysisData/Resources.resx b/AnalysisData/AnalysisData/Resources.resx
index 52be4ee..0cab730 100644
--- a/AnalysisData/AnalysisData/Resources.resx
+++ b/AnalysisData/AnalysisData/Resources.resx
@@ -102,4 +102,8 @@
failed to processing file !
+
+ no edges found for this node !
+
+
\ No newline at end of file
diff --git a/AnalysisData/AnalysisData/Services/GraphService/GraphServices/Relationship/GraphRelationService.cs b/AnalysisData/AnalysisData/Services/GraphService/GraphServices/Relationship/GraphRelationService.cs
index 3a98ef7..dd992ab 100644
--- a/AnalysisData/AnalysisData/Services/GraphService/GraphServices/Relationship/GraphRelationService.cs
+++ b/AnalysisData/AnalysisData/Services/GraphService/GraphServices/Relationship/GraphRelationService.cs
@@ -48,11 +48,16 @@ public GraphRelationService(IEntityNodeRepository entityNodeRepository, IEntityE
throw new NodeNotAccessibleForUserException();
}
- if (!result.nodes.Any() && !result.edges.Any())
+ if (!result.nodes.Any())
{
throw new NodeNotFoundException();
}
+ if (!result.edges.Any())
+ {
+ throw new NodeHasNotEdgesException();
+ }
+
return result;
}
@@ -72,7 +77,7 @@ public GraphRelationService(IEntityNodeRepository entityNodeRepository, IEntityE
{ From = x.EntityIDSource, To = x.EntityIDTarget, Id = x.Id });
return (nodeDto, edgeDto);
}
-
+
private async Task> GetEntityNodesByIdsAsync(IEnumerable nodeIdes)
{
var entityNodes = new List();
@@ -84,6 +89,7 @@ private async Task> GetEntityNodesByIdsAsync(IEnumerable
entityNodes.Add(node);
}
}
+
return entityNodes;
}
}
\ No newline at end of file