From 4cfa369354bbc6f809ef6822bdd4f2ae84c91b8f Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 22 Oct 2026 17:54:53 -0400 Subject: [PATCH] refactor(adminui): delete the dead LoadTagsForEquipmentAsync surface (R04 S4) v3 retired the equipment-Tag binding; IUnsTreeService.LoadTagsForEquipmentAsync always returned empty, had no production caller, and EquipmentTagRow plus the always-zero tagCounts / EquipmentRow.TagCount plumbing existed only to feed it. All removed; the equipment badge count (virtual tags) is unchanged. Refs #745 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT --- .../Uns/EquipmentChildRows.cs | 5 ----- .../Uns/IUnsTreeService.cs | 11 ----------- .../ZB.MOM.WW.OtOpcUa.AdminUI/Uns/UnsNode.cs | 6 +++--- .../Uns/UnsTreeService.cs | 14 -------------- .../Uns/UnsTreeAssemblyTests.cs | 12 ++++++------ .../Uns/UnsTreeServiceEquipmentChildRowsTests.cs | 16 ++-------------- .../Uns/UnsTreeServiceTagTests.cs | 12 +----------- 7 files changed, 12 insertions(+), 64 deletions(-) diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/EquipmentChildRows.cs b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/EquipmentChildRows.cs index ec313790..7886285c 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/EquipmentChildRows.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/EquipmentChildRows.cs @@ -2,11 +2,6 @@ using ZB.MOM.WW.OtOpcUa.Configuration.Enums; namespace ZB.MOM.WW.OtOpcUa.AdminUI.Uns; -/// A tag row for the equipment page's Tags tab table — display columns plus the id used to -/// open the edit modal. RowVersion is re-read fresh on delete (matching the tree's delete path). -public sealed record EquipmentTagRow( - string TagId, string Name, string DriverInstanceId, string DataType, TagAccessLevel AccessLevel); - /// A virtual-tag row for the equipment page's Virtual Tags tab table. public sealed record EquipmentVirtualTagRow(string VirtualTagId, string Name, string DataType, string ScriptId, bool Enabled); diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/IUnsTreeService.cs b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/IUnsTreeService.cs index b2dd3f01..fe2b478e 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/IUnsTreeService.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/IUnsTreeService.cs @@ -117,17 +117,6 @@ public interface IUnsTreeService /// The enterprise root nodes, each populated down to equipment. Task> LoadStructureAsync(CancellationToken ct = default); - /// - /// Loads the driver tags bound to a single equipment as flat row projections for the equipment - /// page's Tags tab table, ordered by Name. Each row carries the display columns plus the - /// TagId the table uses to open the edit modal. Reads untracked. Returns an empty list when - /// the equipment has no tags. - /// - /// The equipment whose tags to load. - /// A token to cancel the load. - /// The equipment's tag rows ordered by Name; empty if it has none. - Task> LoadTagsForEquipmentAsync(string equipmentId, CancellationToken ct = default); - /// /// Loads the virtual tags scoped to a single equipment as flat row projections for the equipment /// page's Virtual Tags tab table, ordered by Name. Each row carries the display columns plus the diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/UnsNode.cs b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/UnsNode.cs index fc5893b4..8bc8a127 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/UnsNode.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/UnsNode.cs @@ -75,13 +75,13 @@ public readonly record struct AreaRow(string UnsAreaId, string ClusterId, string /// Flat structural row describing a UNS line and its owning area. public readonly record struct LineRow(string UnsLineId, string UnsAreaId, string Name); -/// Flat structural row describing an equipment node, its owning line and its tag/virtual-tag counts. +/// Flat structural row describing an equipment node, its owning line and its virtual-tag count. +/// (The driver-tag count was retired with the v3 equipment↔Tag binding; it was always zero.) public readonly record struct EquipmentRow( string EquipmentId, string UnsLineId, string MachineCode, string Name, - int TagCount, int VirtualTagCount); /// @@ -237,7 +237,7 @@ public static class UnsTreeAssembly private static UnsNode BuildEquipment(EquipmentRow equipment, string clusterId) { - var childCount = equipment.TagCount + equipment.VirtualTagCount; + var childCount = equipment.VirtualTagCount; return new UnsNode { Kind = UnsNodeKind.Equipment, diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/UnsTreeService.cs b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/UnsTreeService.cs index 6f2823cd..b27583e3 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/UnsTreeService.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.AdminUI/Uns/UnsTreeService.cs @@ -61,11 +61,6 @@ public sealed class UnsTreeService( }) .ToListAsync(ct); - // Per-equipment driver-tag counts: the equipment↔Tag binding was retired in v3 - // (Tag is now Raw-only; authoring moved to the Raw tree in Batch 2/3). No binding - // exists to count against, so every equipment reports zero driver tags. - var tagCounts = new Dictionary(StringComparer.Ordinal); - // Per-equipment virtual-tag counts (virtual tags with no equipment are excluded). var vtagCounts = (await db.VirtualTags .AsNoTracking() @@ -81,21 +76,12 @@ public sealed class UnsTreeService( e.UnsLineId, e.MachineCode, e.Name, - tagCounts.GetValueOrDefault(e.EquipmentId), vtagCounts.GetValueOrDefault(e.EquipmentId))) .ToList(); return UnsTreeAssembly.Build(clusters, areas, lines, equipment); } - /// - public Task> LoadTagsForEquipmentAsync(string equipmentId, CancellationToken ct = default) - { - // The equipment↔Tag binding was retired in v3 (Tag is now Raw-only; authoring moved to - // the Raw tree in Batch 2/3). No equipment-bound tags exist to list. - return Task.FromResult>(Array.Empty()); - } - /// public async Task> LoadVirtualTagsForEquipmentAsync(string equipmentId, CancellationToken ct = default) { diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeAssemblyTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeAssemblyTests.cs index cce549d2..d65815ff 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeAssemblyTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeAssemblyTests.cs @@ -37,7 +37,7 @@ public sealed class UnsTreeAssemblyTests var clusters = new[] { new ClusterRow("c1", "zb", "SiteA", "Alpha") }; var areas = new[] { new AreaRow("a1", "c1", "AreaOne") }; var lines = new[] { new LineRow("l1", "a1", "LineOne") }; - var equipment = new[] { new EquipmentRow("e1", "l1", "MC-1", "EquipOne", 0, 0) }; + var equipment = new[] { new EquipmentRow("e1", "l1", "MC-1", "EquipOne", 0) }; var tree = UnsTreeAssembly.Build(clusters, areas, lines, equipment); @@ -75,8 +75,8 @@ public sealed class UnsTreeAssemblyTests var lines = new[] { new LineRow("l1", "a1", "LineOne") }; var equipment = new[] { - new EquipmentRow("e1", "l1", "MC-1", "WithChildren", 2, 1), - new EquipmentRow("e2", "l1", "MC-2", "Empty", 0, 0), + new EquipmentRow("e1", "l1", "MC-1", "WithChildren", 3), + new EquipmentRow("e2", "l1", "MC-2", "Empty", 0), }; var tree = UnsTreeAssembly.Build(clusters, areas, lines, equipment); @@ -84,7 +84,7 @@ public sealed class UnsTreeAssemblyTests // Equipment is a tree leaf that links to its own detail page, so it never carries an // expander — HasLazyChildren is always false regardless of its tag/virtual-tag count. - // The ChildCount badge still reflects tags + virtual tags. + // The ChildCount badge reflects its virtual tags. var withChildren = line.Children.Single(e => e.Key == "eq:e1"); withChildren.ChildCount.ShouldBe(3); withChildren.HasLazyChildren.ShouldBeFalse(); @@ -145,8 +145,8 @@ public sealed class UnsTreeAssemblyTests }; var equipment = new[] { - new EquipmentRow("e2", "l1", "MC-2", "EquipB", 0, 0), - new EquipmentRow("e1", "l1", "MC-1", "EquipA", 0, 0), + new EquipmentRow("e2", "l1", "MC-2", "EquipB", 0), + new EquipmentRow("e1", "l1", "MC-1", "EquipA", 0), }; var tree = UnsTreeAssembly.Build(clusters, areas, lines, equipment); diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeServiceEquipmentChildRowsTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeServiceEquipmentChildRowsTests.cs index 8d5f53a6..108c9ff8 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeServiceEquipmentChildRowsTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeServiceEquipmentChildRowsTests.cs @@ -14,16 +14,8 @@ public sealed class UnsTreeServiceEquipmentChildRowsTests return new UnsTreeService(UnsTreeTestDb.Factory(dbName)); } - // v3 Batch-1: the equipment↔Tag binding was retired (Tag is Raw-only; authoring moved to the Raw - // tree in Batch 2). LoadTagsForEquipmentAsync is a stub that always returns empty — no equipment - // has bound driver tags to list. The former in-name-order / EquipmentId-scoping assertions moved - // with the authoring surface to the Batch-2 Raw-tree tests. - [Fact] - public async Task LoadTagsForEquipment_returns_empty_stub() - { - var rows = await SeededService().LoadTagsForEquipmentAsync(UnsTreeTestDb.SeededEquipmentId); - rows.ShouldBeEmpty(); - } + // v3 Batch-1 retired the equipment↔Tag binding; the always-empty LoadTagsForEquipmentAsync stub and + // its EquipmentTagRow were deleted (R04 S4). Equipment tags are UnsTagReference rows now. [Fact] public async Task LoadVirtualTagsForEquipment_returns_vtags_in_name_order() @@ -34,8 +26,4 @@ public sealed class UnsTreeServiceEquipmentChildRowsTests rows[0].Name.ShouldBe("computed"); rows[0].DataType.ShouldBe("Double"); } - - [Fact] - public async Task LoadTagsForEquipment_empty_for_unknown_equipment() - => (await SeededService().LoadTagsForEquipmentAsync("EQ-NONE")).ShouldBeEmpty(); } diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeServiceTagTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeServiceTagTests.cs index e2caffe7..26728673 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeServiceTagTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.AdminUI.Tests/Uns/UnsTreeServiceTagTests.cs @@ -12,7 +12,7 @@ namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Uns; /// FolderPath), the Namespace/NamespaceKind entities were deleted, and tag /// authoring moved to the Raw tree (/raw) in Batch 2. So 's /// CreateTagAsync / UpdateTagAsync now return a uniform Batch-1 refusal, and -/// LoadTagsForEquipmentAsync / LoadTagDriversForEquipmentAsync return empty. The tests +/// LoadTagDriversForEquipmentAsync returns empty. The tests /// below assert that stub contract (preserving the intent of the old CRUD-guard / driver-loader /// tests) plus the still-live DeleteTagAsync path (which continues to remove a raw Tag row). /// @@ -153,16 +153,6 @@ public sealed class UnsTreeServiceTagTests // ----- Per-equipment loaders: retired → empty ----- - /// The per-equipment tag list is retired (Tag is Raw-only) → always empty. - [Fact] - public async Task LoadTagsForEquipment_returns_empty() - { - var (service, dbName) = Fresh(); - SeedHierarchy(dbName); - - (await service.LoadTagsForEquipmentAsync("EQ-1")).ShouldBeEmpty(); - } - /// The per-equipment candidate-driver loader is retired (equipment↔driver binding gone) → always empty. [Fact] public async Task LoadTagDriversForEquipment_returns_empty()