Skip to content

Commit

Permalink
Add support for EngineeringModelSetup.AutoPublish
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander van Delft committed Mar 4, 2024
1 parent d35418e commit 6c89429
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 1 deletion.
10 changes: 10 additions & 0 deletions CDP4Common/AutoGenDto/EngineeringModelSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ public EngineeringModelSetup(Guid iid, int rev) : base(iid: iid, rev: rev)
[DataMember]
public List<Guid> ActiveDomain { get; set; }

/// <summary>
/// Gets or sets a value indicating whether AutoPublish.
/// </summary>
[CDPVersion("1.4.0")]
[UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)]
[DataMember]
public bool AutoPublish { get; set; }

/// <summary>
/// Gets or sets the unique identifier of the referenced DefaultOrganizationalParticipant.
/// </summary>
Expand Down Expand Up @@ -565,6 +573,8 @@ public override void ResolveCopy(Thing originalThing, IReadOnlyDictionary<Thing,
this.Attachment.Add(copy.Value.Iid);
}

this.AutoPublish = original.AutoPublish;

var copyDefaultOrganizationalParticipant = originalCopyMap.SingleOrDefault(kvp => kvp.Key.Iid == original.DefaultOrganizationalParticipant);
this.DefaultOrganizationalParticipant = copyDefaultOrganizationalParticipant.Value == null ? original.DefaultOrganizationalParticipant : copyDefaultOrganizationalParticipant.Value.Iid;

Expand Down
3 changes: 3 additions & 0 deletions CDP4Common/AutoGenEquatable/EngineeringModelSetupEquatable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down
4 changes: 4 additions & 0 deletions CDP4Common/AutoGenMetaInfo/EngineeringModelSetupMetaInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public IEnumerable<OrderedItem> 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" },
Expand Down Expand Up @@ -262,6 +263,7 @@ public IEnumerable<PropertyMetaInfo> 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 },
Expand Down Expand Up @@ -294,6 +296,7 @@ public IEnumerable<PropertyMetaInfo> 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) },
Expand Down Expand Up @@ -334,6 +337,7 @@ public IEnumerable<PropertyMetaInfo> Properties
private readonly Dictionary<string, Action<CDP4Common.DTO.EngineeringModelSetup, object>> propertyValueAssignmentMap = new Dictionary<string, Action<CDP4Common.DTO.EngineeringModelSetup, object>>
{
{ "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 },
Expand Down
12 changes: 12 additions & 0 deletions CDP4Common/AutoGenPoco/EngineeringModelSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ public EngineeringModelSetup(Guid iid, ConcurrentDictionary<CacheKey, Lazy<Commo
[UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)]
public List<DomainOfExpertise> ActiveDomain { get; set; }

/// <summary>
/// Gets or sets a value indicating whether AutoPublish.
/// </summary>
/// <remarks>
/// When set to true and the value of a Parameter is updated, it is immediately available as published value without creating a new Publication
/// </remarks>
[CDPVersion("1.4.0")]
[UmlInformation(aggregation: AggregationKind.None, isDerived: false, isOrdered: false, isNullable: false, isPersistent: true)]
public bool AutoPublish { get; set; }

/// <summary>
/// Gets or sets the DefaultOrganizationalParticipant.
/// </summary>
Expand Down Expand Up @@ -358,6 +368,7 @@ internal override void ResolveProperties(DTO.Thing dtoThing)
this.Actor = (dto.Actor.HasValue) ? this.Cache.Get<Person>(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<OrganizationalParticipant>(dto.DefaultOrganizationalParticipant.Value, dto.IterationContainerId) : null;
this.Definition.ResolveList(dto.Definition, dto.IterationContainerId, this.Cache);
this.EngineeringModelIid = dto.EngineeringModelIid;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -583,6 +586,9 @@ internal object QuerySentinelValue(string path, bool isCallerEmunerable)
return pd.Next == null ? (object) new List<Alias>() : new Alias(Guid.Empty, null, null).QuerySentinelValue(pd.Next.Input, true);
case "attachment":
return pd.Next == null ? (object) new List<Attachment>() : new Attachment(Guid.Empty, null, null).QuerySentinelValue(pd.Next.Input, true);
case "autopublish":
pd.VerifyPropertyDescriptorForValueProperty();
return isCallerEmunerable ? (object) new List<bool>() : null;
case "defaultorganizationalparticipant":
pd.VerifyPropertyDescriptorForReferenceProperty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public static CDP4Common.DTO.EngineeringModelSetup FromJsonObject(JObject jObjec
engineeringModelSetup.Attachment.AddRange(jObject["attachment"].ToObject<IEnumerable<Guid>>());
}

if (!jObject["autoPublish"].IsNullOrEmpty())
{
engineeringModelSetup.AutoPublish = jObject["autoPublish"].ToObject<bool>();
}

if (!jObject["defaultOrganizationalParticipant"].IsNullOrEmpty())
{
engineeringModelSetup.DefaultOrganizationalParticipant = jObject["defaultOrganizationalParticipant"].ToObject<Guid?>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down Expand Up @@ -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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -197,6 +198,7 @@ public void Serialize(ref MessagePackWriter writer, EngineeringModelSetup engine
{
writer.Write(identifier.ToByteArray());
}
writer.Write(engineeringModelSetup.AutoPublish);

writer.Flush();
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6c89429

Please sign in to comment.