Skip to content

Commit 07733ca

Browse files
author
Alexander van Delft
committed
Make DiagramConvas.LockedBy optional
1 parent 0984d28 commit 07733ca

13 files changed

+112
-69
lines changed

CDP4Common/AutoGenDto/ArchitectureDiagram.cs

+3-22
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public override IDictionary<string, IEnumerable<Guid>> GetReferenceProperties()
112112

113113
if (this.LockedBy != null)
114114
{
115-
dictionary.Add("LockedBy", new [] { this.LockedBy });
115+
dictionary.Add("LockedBy", new [] { this.LockedBy.Value });
116116
}
117117

118118
if (this.Owner != null)
@@ -168,11 +168,7 @@ public override bool TryRemoveReferences(IEnumerable<Guid> ids, out List<string>
168168
break;
169169

170170
case "LockedBy":
171-
if (addModelErrors)
172-
{
173-
errors.Add($"Removed reference '{id}' from LockedBy property results in inconsistent ArchitectureDiagram.");
174-
result = false;
175-
}
171+
this.LockedBy = null;
176172
break;
177173

178174
case "Owner":
@@ -240,8 +236,7 @@ public override bool TryRemoveReferencesNotIn(IEnumerable<Guid> ids, out List<st
240236
case "LockedBy":
241237
if (referencedProperty.Value.Except(ids).Any())
242238
{
243-
errors.Add($"Removed reference '{referencedProperty.Key}' from LockedBy property results in inconsistent ArchitectureDiagram.");
244-
result = false;
239+
this.LockedBy = null;
245240
}
246241
break;
247242

@@ -283,13 +278,6 @@ public override bool HasMandatoryReferenceToAny(IEnumerable<Guid> ids)
283278
{
284279
switch (kvp.Key)
285280
{
286-
case "LockedBy":
287-
if (ids.Intersect(kvp.Value).Any())
288-
{
289-
result = true;
290-
}
291-
break;
292-
293281
case "Owner":
294282
if (ids.Intersect(kvp.Value).Any())
295283
{
@@ -315,13 +303,6 @@ public override bool HasMandatoryReferenceNotIn(HashSet<Guid> ids)
315303
{
316304
switch (kvp.Key)
317305
{
318-
case "LockedBy":
319-
if (kvp.Value.Except(ids).Any())
320-
{
321-
result = true;
322-
}
323-
break;
324-
325306
case "Owner":
326307
if (kvp.Value.Except(ids).Any())
327308
{

CDP4Common/AutoGenDto/DiagramCanvas.cs

+5-22
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ public DiagramCanvas(Guid iid, int rev) : base(iid: iid, rev: rev)
9999
/// Gets or sets the unique identifier of the referenced LockedBy.
100100
/// </summary>
101101
[CDPVersion("1.4.0")]
102-
[UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)]
102+
[UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: true, isPersistent: true)]
103103
[DataMember]
104-
public virtual Guid LockedBy { get; set; }
104+
public virtual Guid? LockedBy { get; set; }
105105

106106
/// <summary>
107107
/// Gets the route for the current <see ref="DiagramCanvas"/>.
@@ -129,7 +129,7 @@ public override IDictionary<string, IEnumerable<Guid>> GetReferenceProperties()
129129

130130
if (this.LockedBy != null)
131131
{
132-
dictionary.Add("LockedBy", new [] { this.LockedBy });
132+
dictionary.Add("LockedBy", new [] { this.LockedBy.Value });
133133
}
134134

135135
return dictionary;
@@ -175,11 +175,7 @@ public override bool TryRemoveReferences(IEnumerable<Guid> ids, out List<string>
175175
break;
176176

177177
case "LockedBy":
178-
if (addModelErrors)
179-
{
180-
errors.Add($"Removed reference '{id}' from LockedBy property results in inconsistent DiagramCanvas.");
181-
result = false;
182-
}
178+
this.LockedBy = null;
183179
break;
184180
}
185181
}
@@ -235,8 +231,7 @@ public override bool TryRemoveReferencesNotIn(IEnumerable<Guid> ids, out List<st
235231
case "LockedBy":
236232
if (referencedProperty.Value.Except(ids).Any())
237233
{
238-
errors.Add($"Removed reference '{referencedProperty.Key}' from LockedBy property results in inconsistent DiagramCanvas.");
239-
result = false;
234+
this.LockedBy = null;
240235
}
241236
break;
242237
}
@@ -263,12 +258,6 @@ public override bool HasMandatoryReferenceToAny(IEnumerable<Guid> ids)
263258
{
264259
switch (kvp.Key)
265260
{
266-
case "LockedBy":
267-
if (ids.Intersect(kvp.Value).Any())
268-
{
269-
result = true;
270-
}
271-
break;
272261
}
273262
}
274263

@@ -288,12 +277,6 @@ public override bool HasMandatoryReferenceNotIn(HashSet<Guid> ids)
288277
{
289278
switch (kvp.Key)
290279
{
291-
case "LockedBy":
292-
if (kvp.Value.Except(ids).Any())
293-
{
294-
result = true;
295-
}
296-
break;
297280
}
298281
}
299282

CDP4Common/AutoGenEquatable/ArchitectureDiagramEquatable.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
| 9 | description | string | 1..1 | 1.4.0 |
4444
| 10 | diagramElement | Guid | 0..* | 1.4.0 |
4545
| 11 | isHidden | bool | 1..1 | 1.4.0 |
46-
| 12 | lockedBy | Guid | 1..1 | 1.4.0 |
46+
| 12 | lockedBy | Guid | 0..1 | 1.4.0 |
4747
| 13 | name | string | 1..1 | 1.4.0 |
4848
| 14 | owner | Guid | 1..1 | 1.4.0 |
4949
| 15 | topArchitectureElement | Guid | 0..1 | 1.4.0 |
@@ -109,6 +109,7 @@ public static bool ArePropertiesEqual(this ArchitectureDiagram me, ArchitectureD
109109

110110
if (!me.IsHidden.Equals(other.IsHidden)) return false;
111111

112+
if (me.LockedBy.HasValue != other.LockedBy.HasValue) return false;
112113
if (!me.LockedBy.Equals(other.LockedBy)) return false;
113114

114115
if (me.Name == null && other.Name != null) return false;

CDP4Common/AutoGenEquatable/DiagramCanvasEquatable.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
| 10 | actor | Guid | 0..1 | 1.3.0 |
4545
| 11 | description | string | 1..1 | 1.4.0 |
4646
| 12 | isHidden | bool | 1..1 | 1.4.0 |
47-
| 13 | lockedBy | Guid | 1..1 | 1.4.0 |
47+
| 13 | lockedBy | Guid | 0..1 | 1.4.0 |
4848
* -------------------------------------------- | ---------------------------- | ----------- | ------- */
4949

5050
namespace CDP4Common.DTO.Equatable
@@ -110,6 +110,7 @@ public static bool ArePropertiesEqual(this DiagramCanvas me, DiagramCanvas other
110110

111111
if (!me.IsHidden.Equals(other.IsHidden)) return false;
112112

113+
if (me.LockedBy.HasValue != other.LockedBy.HasValue) return false;
113114
if (!me.LockedBy.Equals(other.LockedBy)) return false;
114115

115116
return true;

CDP4Common/AutoGenMetaInfo/ArchitectureDiagramMetaInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public IEnumerable<PropertyMetaInfo> Properties
274274
{ "ExcludedPerson", new PropertyMetaInfo("ExcludedPerson", "Person", PropertyKind.List, AggregationKind.None, false, false, true, 0, "*", true) },
275275
{ "Iid", new PropertyMetaInfo("Iid", "Guid", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
276276
{ "IsHidden", new PropertyMetaInfo("IsHidden", "bool", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
277-
{ "LockedBy", new PropertyMetaInfo("LockedBy", "Person", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
277+
{ "LockedBy", new PropertyMetaInfo("LockedBy", "Person", PropertyKind.Scalar, AggregationKind.None, false, false, true, 0, "1", true) },
278278
{ "ModifiedOn", new PropertyMetaInfo("ModifiedOn", "DateTime", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
279279
{ "Name", new PropertyMetaInfo("Name", "string", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
280280
{ "Owner", new PropertyMetaInfo("Owner", "DomainOfExpertise", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
@@ -304,7 +304,7 @@ public IEnumerable<PropertyMetaInfo> Properties
304304
{ "Description", (architectureDiagram, value) => architectureDiagram.Description = value.ToString() },
305305
{ "Iid", (architectureDiagram, value) => architectureDiagram.Iid = (Guid)value },
306306
{ "IsHidden", (architectureDiagram, value) => architectureDiagram.IsHidden = (bool)value },
307-
{ "LockedBy", (architectureDiagram, value) => architectureDiagram.LockedBy = (Guid)value },
307+
{ "LockedBy", (architectureDiagram, value) => architectureDiagram.LockedBy = value == null ? (Guid?)null : (Guid)value },
308308
{ "ModifiedOn", (architectureDiagram, value) => architectureDiagram.ModifiedOn = (DateTime)value },
309309
{ "Name", (architectureDiagram, value) => architectureDiagram.Name = value.ToString() },
310310
{ "Owner", (architectureDiagram, value) => architectureDiagram.Owner = (Guid)value },

CDP4Common/AutoGenMetaInfo/DiagramCanvasMetaInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public IEnumerable<PropertyMetaInfo> Properties
272272
{ "ExcludedPerson", new PropertyMetaInfo("ExcludedPerson", "Person", PropertyKind.List, AggregationKind.None, false, false, true, 0, "*", true) },
273273
{ "Iid", new PropertyMetaInfo("Iid", "Guid", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
274274
{ "IsHidden", new PropertyMetaInfo("IsHidden", "bool", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
275-
{ "LockedBy", new PropertyMetaInfo("LockedBy", "Person", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
275+
{ "LockedBy", new PropertyMetaInfo("LockedBy", "Person", PropertyKind.Scalar, AggregationKind.None, false, false, true, 0, "1", true) },
276276
{ "ModifiedOn", new PropertyMetaInfo("ModifiedOn", "DateTime", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
277277
{ "Name", new PropertyMetaInfo("Name", "string", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
278278
{ "RevisionNumber", new PropertyMetaInfo("RevisionNumber", "int", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) },
@@ -300,7 +300,7 @@ public IEnumerable<PropertyMetaInfo> Properties
300300
{ "Description", (diagramCanvas, value) => diagramCanvas.Description = value.ToString() },
301301
{ "Iid", (diagramCanvas, value) => diagramCanvas.Iid = (Guid)value },
302302
{ "IsHidden", (diagramCanvas, value) => diagramCanvas.IsHidden = (bool)value },
303-
{ "LockedBy", (diagramCanvas, value) => diagramCanvas.LockedBy = (Guid)value },
303+
{ "LockedBy", (diagramCanvas, value) => diagramCanvas.LockedBy = value == null ? (Guid?)null : (Guid)value },
304304
{ "ModifiedOn", (diagramCanvas, value) => diagramCanvas.ModifiedOn = (DateTime)value },
305305
{ "Name", (diagramCanvas, value) => diagramCanvas.Name = value.ToString() },
306306
{ "ThingPreference", (diagramCanvas, value) => diagramCanvas.ThingPreference = value == null ? (string)null : value.ToString() },

CDP4Common/AutoGenPoco/ArchitectureDiagram.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ internal override void ResolveProperties(DTO.Thing dtoThing)
216216
this.ExcludedDomain.ResolveList(dto.ExcludedDomain, dto.IterationContainerId, this.Cache);
217217
this.ExcludedPerson.ResolveList(dto.ExcludedPerson, dto.IterationContainerId, this.Cache);
218218
this.IsHidden = dto.IsHidden;
219-
this.LockedBy = this.Cache.Get<Person>(dto.LockedBy, dto.IterationContainerId) ?? SentinelThingProvider.GetSentinel<Person>();
219+
this.LockedBy = (dto.LockedBy.HasValue) ? this.Cache.Get<Person>(dto.LockedBy.Value, dto.IterationContainerId) : null;
220220
this.ModifiedOn = dto.ModifiedOn;
221221
this.Name = dto.Name;
222222
this.Owner = this.Cache.Get<DomainOfExpertise>(dto.Owner, dto.IterationContainerId) ?? SentinelThingProvider.GetSentinel<DomainOfExpertise>();
@@ -242,7 +242,7 @@ public override DTO.Thing ToDto()
242242
dto.ExcludedDomain.AddRange(this.ExcludedDomain.Select(x => x.Iid));
243243
dto.ExcludedPerson.AddRange(this.ExcludedPerson.Select(x => x.Iid));
244244
dto.IsHidden = this.IsHidden;
245-
dto.LockedBy = this.LockedBy != null ? this.LockedBy.Iid : Guid.Empty;
245+
dto.LockedBy = this.LockedBy != null ? (Guid?)this.LockedBy.Iid : null;
246246
dto.ModifiedOn = this.ModifiedOn;
247247
dto.Name = this.Name;
248248
dto.Owner = this.Owner != null ? this.Owner.Iid : Guid.Empty;

CDP4Common/AutoGenPoco/DiagramCanvas.cs

+2-9
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,6 @@ protected override IEnumerable<string> ValidatePocoCardinality()
202202
errorList.Add("The property Description is null or empty.");
203203
}
204204

205-
if (this.LockedBy == null || this.LockedBy.Iid == Guid.Empty)
206-
{
207-
errorList.Add("The property LockedBy is null.");
208-
this.LockedBy = SentinelThingProvider.GetSentinel<Person>();
209-
this.sentinelResetMap["LockedBy"] = () => this.LockedBy = null;
210-
}
211-
212205
return errorList;
213206
}
214207

@@ -237,7 +230,7 @@ internal override void ResolveProperties(DTO.Thing dtoThing)
237230
this.ExcludedDomain.ResolveList(dto.ExcludedDomain, dto.IterationContainerId, this.Cache);
238231
this.ExcludedPerson.ResolveList(dto.ExcludedPerson, dto.IterationContainerId, this.Cache);
239232
this.IsHidden = dto.IsHidden;
240-
this.LockedBy = this.Cache.Get<Person>(dto.LockedBy, dto.IterationContainerId) ?? SentinelThingProvider.GetSentinel<Person>();
233+
this.LockedBy = (dto.LockedBy.HasValue) ? this.Cache.Get<Person>(dto.LockedBy.Value, dto.IterationContainerId) : null;
241234
this.ModifiedOn = dto.ModifiedOn;
242235
this.Name = dto.Name;
243236
this.RevisionNumber = dto.RevisionNumber;
@@ -261,7 +254,7 @@ public override DTO.Thing ToDto()
261254
dto.ExcludedDomain.AddRange(this.ExcludedDomain.Select(x => x.Iid));
262255
dto.ExcludedPerson.AddRange(this.ExcludedPerson.Select(x => x.Iid));
263256
dto.IsHidden = this.IsHidden;
264-
dto.LockedBy = this.LockedBy != null ? this.LockedBy.Iid : Guid.Empty;
257+
dto.LockedBy = this.LockedBy != null ? (Guid?)this.LockedBy.Iid : null;
265258
dto.ModifiedOn = this.ModifiedOn;
266259
dto.Name = this.Name;
267260
dto.RevisionNumber = this.RevisionNumber;
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright file="PublicationState.cs" company="RHEA System S.A.">
3+
// Copyright (c) 2015-2023 RHEA System S.A.
4+
//
5+
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski,
6+
// Antoine Théate, Omar Elebiary, Jaime Bernar
7+
//
8+
// This file is part of CDP4-COMET SDK Community Edition
9+
// This is an auto-generated class. Any manual changes to this file will be overwritten!
10+
//
11+
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
12+
// modify it under the terms of the GNU Lesser General Public
13+
// License as published by the Free Software Foundation; either
14+
// version 3 of the License, or (at your option) any later version.
15+
//
16+
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
17+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19+
// Lesser General Public License for more details.
20+
//
21+
// You should have received a copy of the GNU Lesser General Public License
22+
// along with this program; if not, write to the Free Software Foundation,
23+
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24+
// --------------------------------------------------------------------------------------------------------------------
25+
26+
// ------------------------------------------------------------------------------------------------
27+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
28+
// ------------------------------------------------------------------------------------------------
29+
30+
namespace CDP4Common.DiagramData
31+
{
32+
/// <summary>
33+
/// Specifies the state of Publication.
34+
/// </summary>
35+
public enum PublicationState
36+
{
37+
/// <summary>
38+
/// State that defines that an object is Hidden to others.
39+
/// </summary>
40+
Hidden,
41+
42+
/// <summary>
43+
/// State that defines that an object is ready for publication.
44+
/// </summary>
45+
ReadyForPublish,
46+
47+
/// <summary>
48+
/// State that defines that an object has been published.
49+
/// </summary>
50+
Published,
51+
}
52+
}
53+
54+
// ------------------------------------------------------------------------------------------------
55+
// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!--------
56+
// ------------------------------------------------------------------------------------------------

CDP4JsonSerializer/AutoGenDtoDeserializer/ArchitectureDiagramResolver.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static CDP4Common.DTO.ArchitectureDiagram FromJsonObject(JObject jObject)
9898

9999
if (!jObject["lockedBy"].IsNullOrEmpty())
100100
{
101-
architectureDiagram.LockedBy = jObject["lockedBy"].ToObject<Guid>();
101+
architectureDiagram.LockedBy = jObject["lockedBy"].ToObject<Guid?>();
102102
}
103103

104104
if (!jObject["modifiedOn"].IsNullOrEmpty())

CDP4JsonSerializer/AutoGenDtoDeserializer/DiagramCanvasResolver.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public static CDP4Common.DTO.DiagramCanvas FromJsonObject(JObject jObject)
9898

9999
if (!jObject["lockedBy"].IsNullOrEmpty())
100100
{
101-
diagramCanvas.LockedBy = jObject["lockedBy"].ToObject<Guid>();
101+
diagramCanvas.LockedBy = jObject["lockedBy"].ToObject<Guid?>();
102102
}
103103

104104
if (!jObject["modifiedOn"].IsNullOrEmpty())

0 commit comments

Comments
 (0)