|
| 1 | +// -------------------------------------------------------------------------------------------------------------------- |
| 2 | +// <copyright file="ArchitectureDiagram.cs" company="RHEA System S.A."> |
| 3 | +// Copyright (c) 2015-2021 RHEA System S.A. |
| 4 | +// |
| 5 | +// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski |
| 6 | +// |
| 7 | +// This file is part of COMET-SDK Community Edition |
| 8 | +// This is an auto-generated class. Any manual changes to this file will be overwritten! |
| 9 | +// |
| 10 | +// The COMET-SDK Community Edition is free software; you can redistribute it and/or |
| 11 | +// modify it under the terms of the GNU Lesser General Public |
| 12 | +// License as published by the Free Software Foundation; either |
| 13 | +// version 3 of the License, or (at your option) any later version. |
| 14 | +// |
| 15 | +// The COMET-SDK Community Edition is distributed in the hope that it will be useful, |
| 16 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | +// Lesser General Public License for more details. |
| 19 | +// |
| 20 | +// You should have received a copy of the GNU Lesser General Public License |
| 21 | +// along with this program; if not, write to the Free Software Foundation, |
| 22 | +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 23 | +// -------------------------------------------------------------------------------------------------------------------- |
| 24 | + |
| 25 | +namespace CDP4Common.DTO |
| 26 | +{ |
| 27 | + using System; |
| 28 | + using System.Collections; |
| 29 | + using System.Collections.Concurrent; |
| 30 | + using System.Collections.Generic; |
| 31 | + using System.Linq; |
| 32 | + using System.Runtime.Serialization; |
| 33 | + using System.Xml.Serialization; |
| 34 | + using CDP4Common.CommonData; |
| 35 | + using CDP4Common.DiagramData; |
| 36 | + using CDP4Common.EngineeringModelData; |
| 37 | + using CDP4Common.ReportingData; |
| 38 | + using CDP4Common.SiteDirectoryData; |
| 39 | + using CDP4Common.Types; |
| 40 | + |
| 41 | + /// <summary> |
| 42 | + /// A Data Transfer Object representation of the <see cref="ArchitectureDiagram"/> class. |
| 43 | + /// </summary> |
| 44 | + [DataContract] |
| 45 | + [CDPVersion("1.3.0")] |
| 46 | + [Container(typeof(Iteration), "DiagramCanvas")] |
| 47 | + public sealed partial class ArchitectureDiagram : DiagramCanvas, IOwnedThing |
| 48 | + { |
| 49 | + /// <summary> |
| 50 | + /// Initializes a new instance of the <see cref="ArchitectureDiagram"/> class. |
| 51 | + /// </summary> |
| 52 | + public ArchitectureDiagram() |
| 53 | + { |
| 54 | + } |
| 55 | + |
| 56 | + /// <summary> |
| 57 | + /// Initializes a new instance of the <see cref="ArchitectureDiagram"/> class. |
| 58 | + /// </summary> |
| 59 | + /// <param name="iid"> |
| 60 | + /// The unique identifier. |
| 61 | + /// </param> |
| 62 | + /// <param name="rev"> |
| 63 | + /// The revision number. |
| 64 | + /// </param> |
| 65 | + public ArchitectureDiagram(Guid iid, int rev) : base(iid: iid, rev: rev) |
| 66 | + { |
| 67 | + } |
| 68 | + |
| 69 | + /// <summary> |
| 70 | + /// Gets or sets the unique identifier of the referenced Owner. |
| 71 | + /// </summary> |
| 72 | + [UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)] |
| 73 | + [DataMember] |
| 74 | + public Guid Owner { get; set; } |
| 75 | + |
| 76 | + /// <summary> |
| 77 | + /// Gets or sets the unique identifier of the referenced TopArchitectureElement. |
| 78 | + /// </summary> |
| 79 | + [UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: true, isPersistent: true)] |
| 80 | + [DataMember] |
| 81 | + public Guid? TopArchitectureElement { get; set; } |
| 82 | + |
| 83 | + /// <summary> |
| 84 | + /// Gets the route for the current <see ref="ArchitectureDiagram"/>. |
| 85 | + /// </summary> |
| 86 | + public override string Route |
| 87 | + { |
| 88 | + get { return this.ComputedRoute(); } |
| 89 | + } |
| 90 | + |
| 91 | + /// <summary> |
| 92 | + /// Instantiate a <see cref="CDP4Common.DiagramData.ArchitectureDiagram"/> from a <see cref="ArchitectureDiagram"/> |
| 93 | + /// </summary> |
| 94 | + /// <param name="cache">The cache that stores all the <see cref="CommonData.Thing"/>s</param>. |
| 95 | + /// <param name="uri">The <see cref="Uri"/> of the <see cref="CDP4Common.DiagramData.ArchitectureDiagram"/></param>. |
| 96 | + /// <returns>A new <see cref="CommonData.Thing"/></returns> |
| 97 | + public override CommonData.Thing InstantiatePoco(ConcurrentDictionary<CacheKey, Lazy<CommonData.Thing>> cache, Uri uri) |
| 98 | + { |
| 99 | + return new CDP4Common.DiagramData.ArchitectureDiagram(this.Iid, cache, uri); |
| 100 | + } |
| 101 | + |
| 102 | + /// <summary> |
| 103 | + /// Resolves the properties of a copied <see cref="Thing"/> based on the original and a collection of copied <see cref="Thing"/>. |
| 104 | + /// </summary> |
| 105 | + /// <param name="originalThing">The original <see cref="Thing"/></param>. |
| 106 | + /// <param name="originalCopyMap">The map containig all instance of copied <see cref="Thing"/>s with their original</param>. |
| 107 | + public override void ResolveCopy(Thing originalThing, IReadOnlyDictionary<Thing, Thing> originalCopyMap) |
| 108 | + { |
| 109 | + var original = originalThing as ArchitectureDiagram; |
| 110 | + if (original == null) |
| 111 | + { |
| 112 | + throw new InvalidOperationException("The originalThing cannot be null or is of the incorrect type"); |
| 113 | + } |
| 114 | + |
| 115 | + foreach (var guid in original.Bounds) |
| 116 | + { |
| 117 | + var copy = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == guid); |
| 118 | + if (Equals(copy, default(KeyValuePair<Thing, Thing>))) |
| 119 | + { |
| 120 | + throw new InvalidOperationException(string.Format("The copy could not be found for {0}", guid)); |
| 121 | + } |
| 122 | + |
| 123 | + this.Bounds.Add(copy.Value.Iid); |
| 124 | + } |
| 125 | + |
| 126 | + this.CreatedOn = original.CreatedOn; |
| 127 | + |
| 128 | + this.Description = original.Description; |
| 129 | + |
| 130 | + foreach (var guid in original.DiagramElement) |
| 131 | + { |
| 132 | + var copy = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == guid); |
| 133 | + if (Equals(copy, default(KeyValuePair<Thing, Thing>))) |
| 134 | + { |
| 135 | + throw new InvalidOperationException(string.Format("The copy could not be found for {0}", guid)); |
| 136 | + } |
| 137 | + |
| 138 | + this.DiagramElement.Add(copy.Value.Iid); |
| 139 | + } |
| 140 | + |
| 141 | + foreach (var guid in original.ExcludedDomain) |
| 142 | + { |
| 143 | + var copy = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == guid); |
| 144 | + this.ExcludedDomain.Add(copy.Value == null ? guid : copy.Value.Iid); |
| 145 | + } |
| 146 | + |
| 147 | + foreach (var guid in original.ExcludedPerson) |
| 148 | + { |
| 149 | + var copy = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == guid); |
| 150 | + this.ExcludedPerson.Add(copy.Value == null ? guid : copy.Value.Iid); |
| 151 | + } |
| 152 | + |
| 153 | + this.ModifiedOn = original.ModifiedOn; |
| 154 | + |
| 155 | + this.Name = original.Name; |
| 156 | + |
| 157 | + var copyOwner = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == original.Owner); |
| 158 | + this.Owner = copyOwner.Value == null ? original.Owner : copyOwner.Value.Iid; |
| 159 | + |
| 160 | + this.PublicationState = original.PublicationState; |
| 161 | + |
| 162 | + this.ThingPreference = original.ThingPreference; |
| 163 | + |
| 164 | + var copyTopArchitectureElement = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == original.TopArchitectureElement); |
| 165 | + this.TopArchitectureElement = copyTopArchitectureElement.Value == null ? original.TopArchitectureElement : copyTopArchitectureElement.Value.Iid; |
| 166 | + } |
| 167 | + |
| 168 | + /// <summary> |
| 169 | + /// Resolves the references of a copied <see cref="Thing"/> based on a original to copy map. |
| 170 | + /// </summary> |
| 171 | + /// <param name="originalCopyMap">The map containig all instance of copied <see cref="Thing"/>s with their original</param>. |
| 172 | + /// <returns>True if a modification was done in the process of this method</returns>. |
| 173 | + public override bool ResolveCopyReference(IReadOnlyDictionary<Thing, Thing> originalCopyMap) |
| 174 | + { |
| 175 | + var hasChanges = false; |
| 176 | + |
| 177 | + return hasChanges; |
| 178 | + } |
| 179 | + } |
| 180 | +} |
0 commit comments