From 6c89429340116b3e3b95b22a126e0875d0436785 Mon Sep 17 00:00:00 2001 From: Alexander van Delft Date: Fri, 1 Mar 2024 12:07:24 +0100 Subject: [PATCH] Add support for EngineeringModelSetup.AutoPublish --- CDP4Common/AutoGenDto/EngineeringModelSetup.cs | 10 ++++++++++ .../EngineeringModelSetupEquatable.cs | 3 +++ .../AutoGenMetaInfo/EngineeringModelSetupMetaInfo.cs | 4 ++++ CDP4Common/AutoGenPoco/EngineeringModelSetup.cs | 12 ++++++++++++ .../EngineeringModelSetupPropertyAccessor.cs | 6 ++++++ .../EngineeringModelSetupResolver.cs | 5 +++++ .../EngineeringModelSetupSerializer.cs | 2 ++ .../EngineeringModelSetupMessagePackFormatter.cs | 7 ++++++- 8 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CDP4Common/AutoGenDto/EngineeringModelSetup.cs b/CDP4Common/AutoGenDto/EngineeringModelSetup.cs index e80590e6..24d7fd71 100644 --- a/CDP4Common/AutoGenDto/EngineeringModelSetup.cs +++ b/CDP4Common/AutoGenDto/EngineeringModelSetup.cs @@ -88,6 +88,14 @@ public EngineeringModelSetup(Guid iid, int rev) : base(iid: iid, rev: rev) [DataMember] public List ActiveDomain { get; set; } + /// + /// Gets or sets a value indicating whether AutoPublish. + /// + [CDPVersion("1.4.0")] + [UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)] + [DataMember] + public bool AutoPublish { get; set; } + /// /// Gets or sets the unique identifier of the referenced DefaultOrganizationalParticipant. /// @@ -565,6 +573,8 @@ public override void ResolveCopy(Thing originalThing, IReadOnlyDictionary kvp.Key.Iid == original.DefaultOrganizationalParticipant); this.DefaultOrganizationalParticipant = copyDefaultOrganizationalParticipant.Value == null ? original.DefaultOrganizationalParticipant : copyDefaultOrganizationalParticipant.Value.Iid; diff --git a/CDP4Common/AutoGenEquatable/EngineeringModelSetupEquatable.cs b/CDP4Common/AutoGenEquatable/EngineeringModelSetupEquatable.cs index fc29f45e..77dc39ee 100644 --- a/CDP4Common/AutoGenEquatable/EngineeringModelSetupEquatable.cs +++ b/CDP4Common/AutoGenEquatable/EngineeringModelSetupEquatable.cs @@ -54,6 +54,7 @@ | 20 | thingPreference | string | 0..1 | 1.2.0 | | 21 | actor | Guid | 0..1 | 1.3.0 | | 22 | attachment | Guid | 0..* | 1.4.0 | + | 23 | autoPublish | bool | 1..1 | 1.4.0 | * -------------------------------------------- | ---------------------------- | ----------- | ------- */ namespace CDP4Common.DTO.Equatable @@ -141,6 +142,8 @@ public static bool ArePropertiesEqual(this EngineeringModelSetup me, Engineering if (!me.Attachment.OrderBy(x => x).SequenceEqual(other.Attachment.OrderBy(x => x))) return false; + if (!me.AutoPublish.Equals(other.AutoPublish)) return false; + return true; } } diff --git a/CDP4Common/AutoGenMetaInfo/EngineeringModelSetupMetaInfo.cs b/CDP4Common/AutoGenMetaInfo/EngineeringModelSetupMetaInfo.cs index ee3acbc8..e5be8266 100644 --- a/CDP4Common/AutoGenMetaInfo/EngineeringModelSetupMetaInfo.cs +++ b/CDP4Common/AutoGenMetaInfo/EngineeringModelSetupMetaInfo.cs @@ -211,6 +211,7 @@ public IEnumerable GetOrderedContainmentIds(CDP4Common.DTO.Thing en { { "Actor", "1.3.0" }, { "Attachment", "1.4.0" }, + { "AutoPublish", "1.4.0" }, { "DefaultOrganizationalParticipant", "1.2.0" }, { "ExcludedDomain", "1.1.0" }, { "ExcludedPerson", "1.1.0" }, @@ -262,6 +263,7 @@ public IEnumerable Properties { "Actor", thing => thing.Actor }, { "Alias", thing => thing.Alias }, { "Attachment", thing => thing.Attachment }, + { "AutoPublish", thing => thing.AutoPublish }, { "ClassKind", thing => thing.ClassKind }, { "DefaultOrganizationalParticipant", thing => thing.DefaultOrganizationalParticipant }, { "Definition", thing => thing.Definition }, @@ -294,6 +296,7 @@ public IEnumerable Properties { { "ActiveDomain", new PropertyMetaInfo("ActiveDomain", "DomainOfExpertise", PropertyKind.List, AggregationKind.None, false, false, true, 1, "*", true) }, { "Actor", new PropertyMetaInfo("Actor", "Person", PropertyKind.Scalar, AggregationKind.None, false, false, false, 0, "1", false) }, + { "AutoPublish", new PropertyMetaInfo("AutoPublish", "bool", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) }, { "ClassKind", new PropertyMetaInfo("ClassKind", "CDP4Common.CommonData.ClassKind", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) }, { "DefaultOrganizationalParticipant", new PropertyMetaInfo("DefaultOrganizationalParticipant", "OrganizationalParticipant", PropertyKind.Scalar, AggregationKind.None, false, false, true, 0, "1", true) }, { "EngineeringModelIid", new PropertyMetaInfo("EngineeringModelIid", "Guid", PropertyKind.Scalar, AggregationKind.None, false, false, true, 1, "1", true) }, @@ -334,6 +337,7 @@ public IEnumerable Properties private readonly Dictionary> propertyValueAssignmentMap = new Dictionary> { { "Actor", (engineeringModelSetup, value) => engineeringModelSetup.Actor = value == null ? (Guid?)null : (Guid)value }, + { "AutoPublish", (engineeringModelSetup, value) => engineeringModelSetup.AutoPublish = (bool)value }, { "DefaultOrganizationalParticipant", (engineeringModelSetup, value) => engineeringModelSetup.DefaultOrganizationalParticipant = value == null ? (Guid?)null : (Guid)value }, { "EngineeringModelIid", (engineeringModelSetup, value) => engineeringModelSetup.EngineeringModelIid = (Guid)value }, { "Iid", (engineeringModelSetup, value) => engineeringModelSetup.Iid = (Guid)value }, diff --git a/CDP4Common/AutoGenPoco/EngineeringModelSetup.cs b/CDP4Common/AutoGenPoco/EngineeringModelSetup.cs index 272db9e4..702ffaa5 100644 --- a/CDP4Common/AutoGenPoco/EngineeringModelSetup.cs +++ b/CDP4Common/AutoGenPoco/EngineeringModelSetup.cs @@ -105,6 +105,16 @@ public EngineeringModelSetup(Guid iid, ConcurrentDictionary ActiveDomain { get; set; } + /// + /// Gets or sets a value indicating whether AutoPublish. + /// + /// + /// When set to true and the value of a Parameter is updated, it is immediately available as published value without creating a new Publication + /// + [CDPVersion("1.4.0")] + [UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)] + public bool AutoPublish { get; set; } + /// /// Gets or sets the DefaultOrganizationalParticipant. /// @@ -358,6 +368,7 @@ internal override void ResolveProperties(DTO.Thing dtoThing) this.Actor = (dto.Actor.HasValue) ? this.Cache.Get(dto.Actor.Value, dto.IterationContainerId) : null; this.Alias.ResolveList(dto.Alias, dto.IterationContainerId, this.Cache); this.Attachment.ResolveList(dto.Attachment, dto.IterationContainerId, this.Cache); + this.AutoPublish = dto.AutoPublish; this.DefaultOrganizationalParticipant = (dto.DefaultOrganizationalParticipant.HasValue) ? this.Cache.Get(dto.DefaultOrganizationalParticipant.Value, dto.IterationContainerId) : null; this.Definition.ResolveList(dto.Definition, dto.IterationContainerId, this.Cache); this.EngineeringModelIid = dto.EngineeringModelIid; @@ -391,6 +402,7 @@ public override DTO.Thing ToDto() dto.Actor = this.Actor != null ? (Guid?)this.Actor.Iid : null; dto.Alias.AddRange(this.Alias.Select(x => x.Iid)); dto.Attachment.AddRange(this.Attachment.Select(x => x.Iid)); + dto.AutoPublish = this.AutoPublish; dto.DefaultOrganizationalParticipant = this.DefaultOrganizationalParticipant != null ? (Guid?)this.DefaultOrganizationalParticipant.Iid : null; dto.Definition.AddRange(this.Definition.Select(x => x.Iid)); dto.EngineeringModelIid = this.EngineeringModelIid; diff --git a/CDP4Common/AutoGenThingPropertyAccessor/EngineeringModelSetupPropertyAccessor.cs b/CDP4Common/AutoGenThingPropertyAccessor/EngineeringModelSetupPropertyAccessor.cs index e6933887..dbe36a6f 100644 --- a/CDP4Common/AutoGenThingPropertyAccessor/EngineeringModelSetupPropertyAccessor.cs +++ b/CDP4Common/AutoGenThingPropertyAccessor/EngineeringModelSetupPropertyAccessor.cs @@ -166,6 +166,9 @@ public override object QueryValue(string path) return base.QueryValue(pd.Input); case "attachment": return base.QueryValue(pd.Input); + case "autopublish": + pd.VerifyPropertyDescriptorForValueProperty(); + return this.AutoPublish; case "defaultorganizationalparticipant": pd.VerifyPropertyDescriptorForReferenceProperty(); @@ -583,6 +586,9 @@ internal object QuerySentinelValue(string path, bool isCallerEmunerable) return pd.Next == null ? (object) new List() : new Alias(Guid.Empty, null, null).QuerySentinelValue(pd.Next.Input, true); case "attachment": return pd.Next == null ? (object) new List() : new Attachment(Guid.Empty, null, null).QuerySentinelValue(pd.Next.Input, true); + case "autopublish": + pd.VerifyPropertyDescriptorForValueProperty(); + return isCallerEmunerable ? (object) new List() : null; case "defaultorganizationalparticipant": pd.VerifyPropertyDescriptorForReferenceProperty(); diff --git a/CDP4JsonSerializer/AutoGenDtoDeserializer/EngineeringModelSetupResolver.cs b/CDP4JsonSerializer/AutoGenDtoDeserializer/EngineeringModelSetupResolver.cs index 2c2f8a62..21d4b8e8 100644 --- a/CDP4JsonSerializer/AutoGenDtoDeserializer/EngineeringModelSetupResolver.cs +++ b/CDP4JsonSerializer/AutoGenDtoDeserializer/EngineeringModelSetupResolver.cs @@ -76,6 +76,11 @@ public static CDP4Common.DTO.EngineeringModelSetup FromJsonObject(JObject jObjec engineeringModelSetup.Attachment.AddRange(jObject["attachment"].ToObject>()); } + if (!jObject["autoPublish"].IsNullOrEmpty()) + { + engineeringModelSetup.AutoPublish = jObject["autoPublish"].ToObject(); + } + if (!jObject["defaultOrganizationalParticipant"].IsNullOrEmpty()) { engineeringModelSetup.DefaultOrganizationalParticipant = jObject["defaultOrganizationalParticipant"].ToObject(); diff --git a/CDP4JsonSerializer/AutoGenDtoSerializer/EngineeringModelSetupSerializer.cs b/CDP4JsonSerializer/AutoGenDtoSerializer/EngineeringModelSetupSerializer.cs index f9d42ab4..1123a74c 100644 --- a/CDP4JsonSerializer/AutoGenDtoSerializer/EngineeringModelSetupSerializer.cs +++ b/CDP4JsonSerializer/AutoGenDtoSerializer/EngineeringModelSetupSerializer.cs @@ -53,6 +53,7 @@ public class EngineeringModelSetupSerializer : BaseThingSerializer, IThingSerial { "actor", actor => new JValue(actor) }, { "alias", alias => new JArray(alias) }, { "attachment", attachment => new JArray(attachment) }, + { "autoPublish", autoPublish => new JValue(autoPublish) }, { "classKind", classKind => new JValue(classKind.ToString()) }, { "defaultOrganizationalParticipant", defaultOrganizationalParticipant => new JValue(defaultOrganizationalParticipant) }, { "definition", definition => new JArray(definition) }, @@ -86,6 +87,7 @@ private JObject Serialize(EngineeringModelSetup engineeringModelSetup) jsonObject.Add("activeDomain", this.PropertySerializerMap["activeDomain"](engineeringModelSetup.ActiveDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("alias", this.PropertySerializerMap["alias"](engineeringModelSetup.Alias.OrderBy(x => x, this.guidComparer))); jsonObject.Add("attachment", this.PropertySerializerMap["attachment"](engineeringModelSetup.Attachment.OrderBy(x => x, this.guidComparer))); + jsonObject.Add("autoPublish", this.PropertySerializerMap["autoPublish"](engineeringModelSetup.AutoPublish)); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), engineeringModelSetup.ClassKind))); jsonObject.Add("defaultOrganizationalParticipant", this.PropertySerializerMap["defaultOrganizationalParticipant"](engineeringModelSetup.DefaultOrganizationalParticipant)); jsonObject.Add("definition", this.PropertySerializerMap["definition"](engineeringModelSetup.Definition.OrderBy(x => x, this.guidComparer))); diff --git a/CDP4MessagePackSerializer/AutoGenMessagePackFormatter/EngineeringModelSetupMessagePackFormatter.cs b/CDP4MessagePackSerializer/AutoGenMessagePackFormatter/EngineeringModelSetupMessagePackFormatter.cs index ceea54b0..6981d4d0 100644 --- a/CDP4MessagePackSerializer/AutoGenMessagePackFormatter/EngineeringModelSetupMessagePackFormatter.cs +++ b/CDP4MessagePackSerializer/AutoGenMessagePackFormatter/EngineeringModelSetupMessagePackFormatter.cs @@ -54,6 +54,7 @@ | 20 | thingPreference | string | 0..1 | 1.2.0 | | 21 | actor | Guid | 0..1 | 1.3.0 | | 22 | attachment | Guid | 0..* | 1.4.0 | + | 23 | autoPublish | bool | 1..1 | 1.4.0 | * -------------------------------------------- | ---------------------------- | ----------- | ------- */ namespace CDP4MessagePackSerializer @@ -106,7 +107,7 @@ public void Serialize(ref MessagePackWriter writer, EngineeringModelSetup engine throw new ArgumentNullException(nameof(engineeringModelSetup), "The EngineeringModelSetup may not be null"); } - writer.WriteArrayHeader(23); + writer.WriteArrayHeader(24); writer.Write(engineeringModelSetup.Iid.ToByteArray()); writer.Write(engineeringModelSetup.RevisionNumber); @@ -197,6 +198,7 @@ public void Serialize(ref MessagePackWriter writer, EngineeringModelSetup engine { writer.Write(identifier.ToByteArray()); } + writer.Write(engineeringModelSetup.AutoPublish); writer.Flush(); } @@ -368,6 +370,9 @@ public EngineeringModelSetup Deserialize(ref MessagePackReader reader, MessagePa engineeringModelSetup.Attachment.Add(reader.ReadBytes().ToGuid()); } break; + case 23: + engineeringModelSetup.AutoPublish = reader.ReadBoolean(); + break; default: reader.Skip(); break;