Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] Instance version checks for Annex.C3 file export; fixes #281 #282

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
139 changes: 134 additions & 5 deletions CDP4Common/AutoGenDto/ActionItem.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ActionItem.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2022 RHEA System S.A.
// Copyright (c) 2015-2023 RHEA System S.A.
//
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski,
// Antoine Théate, Omar Elebiary, Jaime Bernar
//
// This file is part of COMET-SDK Community Edition
// This file is part of CDP4-COMET SDK Community Edition
// This is an auto-generated class. Any manual changes to this file will be overwritten!
//
// The COMET-SDK Community Edition is free software; you can redistribute it and/or
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The COMET-SDK Community Edition is distributed in the hope that it will be useful,
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
Expand Down Expand Up @@ -107,6 +108,134 @@ public override string Route
get { return this.ComputedRoute(); }
}

/// <summary>
/// Get all Reference Properties by their Name and id's of instance values
/// </summary>
/// <returns>A dictionary of string (Name) and a collections of Guid's (id's of instance values)</returns>
public override IDictionary<string, IEnumerable<Guid>> GetReferenceProperties()
{
var dictionary = new Dictionary<string, IEnumerable<Guid>>();

if (this.Actionee != default)
{
dictionary.Add("Actionee", new [] { this.Actionee });
}

dictionary.Add("ApprovedBy", this.ApprovedBy);

if (this.Author != default)
{
dictionary.Add("Author", new [] { this.Author });
}

dictionary.Add("Category", this.Category);

dictionary.Add("Discussion", this.Discussion);

dictionary.Add("ExcludedDomain", this.ExcludedDomain);

dictionary.Add("ExcludedPerson", this.ExcludedPerson);

if (this.Owner != default)
{
dictionary.Add("Owner", new [] { this.Owner });
}

if (this.PrimaryAnnotatedThing != default)
{
dictionary.Add("PrimaryAnnotatedThing", new [] { this.PrimaryAnnotatedThing.Value });
}

dictionary.Add("RelatedThing", this.RelatedThing);

dictionary.Add("SourceAnnotation", this.SourceAnnotation);

return dictionary;
}

/// <summary>
/// Tries to remove references to id's if they exist in a collection of id's (Guid's)
/// </summary>
/// <param name="ids">The collection of Guids to remove references for.</param>
/// <param name="errors">The errors collected while trying to remove references</param>
/// <returns>True if no errors were found while trying to remove references</returns>
public override bool TryRemoveReferences(IEnumerable<Guid> ids, out List<string> errors)
{
errors = new List<string>();
var referencedProperties = this.GetReferenceProperties();
var addModelErrors = !ids.Contains(this.Iid);
var result = true;

foreach (var id in ids)
{
var foundProperty = referencedProperties.Where(x => x.Value.Contains(id)).ToList();

if (foundProperty.Any())
{
foreach (var kvp in foundProperty)
{
switch (kvp.Key)
{
case "Actionee":
if (addModelErrors)
{
errors.Add($"Remove reference '{id}' from Actionee property is not allowed.");
}
break;

case "ApprovedBy":
this.ApprovedBy.Remove(id);
break;

case "Author":
if (addModelErrors)
{
errors.Add($"Remove reference '{id}' from Author property is not allowed.");
}
break;

case "Category":
this.Category.Remove(id);
break;

case "Discussion":
this.Discussion.Remove(id);
break;

case "ExcludedDomain":
this.ExcludedDomain.Remove(id);
break;

case "ExcludedPerson":
this.ExcludedPerson.Remove(id);
break;

case "Owner":
if (addModelErrors)
{
errors.Add($"Remove reference '{id}' from Owner property is not allowed.");
}
break;

case "PrimaryAnnotatedThing":
this.PrimaryAnnotatedThing = null;
break;

case "RelatedThing":
this.RelatedThing.Remove(id);
break;

case "SourceAnnotation":
this.SourceAnnotation.Remove(id);
break;
}
}
}
}

return result;
}

/// <summary>
/// Instantiate a <see cref="CDP4Common.ReportingData.ActionItem"/> from a <see cref="ActionItem"/>
/// </summary>
Expand Down
74 changes: 69 additions & 5 deletions CDP4Common/AutoGenDto/ActualFiniteState.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ActualFiniteState.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2022 RHEA System S.A.
// Copyright (c) 2015-2023 RHEA System S.A.
//
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski,
// Antoine Théate, Omar Elebiary, Jaime Bernar
//
// This file is part of COMET-SDK Community Edition
// This file is part of CDP4-COMET SDK Community Edition
// This is an auto-generated class. Any manual changes to this file will be overwritten!
//
// The COMET-SDK Community Edition is free software; you can redistribute it and/or
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The COMET-SDK Community Edition is distributed in the hope that it will be useful,
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
Expand Down Expand Up @@ -136,6 +137,69 @@ public override string Route
get { return this.ComputedRoute(); }
}

/// <summary>
/// Get all Reference Properties by their Name and id's of instance values
/// </summary>
/// <returns>A dictionary of string (Name) and a collections of Guid's (id's of instance values)</returns>
public override IDictionary<string, IEnumerable<Guid>> GetReferenceProperties()
{
var dictionary = new Dictionary<string, IEnumerable<Guid>>();

dictionary.Add("ExcludedDomain", this.ExcludedDomain);

dictionary.Add("ExcludedPerson", this.ExcludedPerson);

dictionary.Add("PossibleState", this.PossibleState);

return dictionary;
}

/// <summary>
/// Tries to remove references to id's if they exist in a collection of id's (Guid's)
/// </summary>
/// <param name="ids">The collection of Guids to remove references for.</param>
/// <param name="errors">The errors collected while trying to remove references</param>
/// <returns>True if no errors were found while trying to remove references</returns>
public override bool TryRemoveReferences(IEnumerable<Guid> ids, out List<string> errors)
{
errors = new List<string>();
var referencedProperties = this.GetReferenceProperties();
var addModelErrors = !ids.Contains(this.Iid);
var result = true;

foreach (var id in ids)
{
var foundProperty = referencedProperties.Where(x => x.Value.Contains(id)).ToList();

if (foundProperty.Any())
{
foreach (var kvp in foundProperty)
{
switch (kvp.Key)
{
case "ExcludedDomain":
this.ExcludedDomain.Remove(id);
break;

case "ExcludedPerson":
this.ExcludedPerson.Remove(id);
break;

case "PossibleState":
if (addModelErrors && this.PossibleState.Count == 1)
{
errors.Add($"Remove reference '{id}' from PossibleState property is not allowed.");
}
this.PossibleState.Remove(id);
break;
}
}
}
}

return result;
}

/// <summary>
/// Instantiate a <see cref="CDP4Common.EngineeringModelData.ActualFiniteState"/> from a <see cref="ActualFiniteState"/>
/// </summary>
Expand Down
88 changes: 83 additions & 5 deletions CDP4Common/AutoGenDto/ActualFiniteStateList.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ActualFiniteStateList.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2022 RHEA System S.A.
// Copyright (c) 2015-2023 RHEA System S.A.
//
// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft, Nathanael Smiechowski
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski,
// Antoine Théate, Omar Elebiary, Jaime Bernar
//
// This file is part of COMET-SDK Community Edition
// This file is part of CDP4-COMET SDK Community Edition
// This is an auto-generated class. Any manual changes to this file will be overwritten!
//
// The COMET-SDK Community Edition is free software; you can redistribute it and/or
// The CDP4-COMET SDK Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The COMET-SDK Community Edition is distributed in the hope that it will be useful,
// The CDP4-COMET SDK Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
Expand Down Expand Up @@ -153,6 +154,83 @@ public override IEnumerable<IEnumerable> ContainerLists
}
}

/// <summary>
/// Get all Reference Properties by their Name and id's of instance values
/// </summary>
/// <returns>A dictionary of string (Name) and a collections of Guid's (id's of instance values)</returns>
public override IDictionary<string, IEnumerable<Guid>> GetReferenceProperties()
{
var dictionary = new Dictionary<string, IEnumerable<Guid>>();

dictionary.Add("ActualState", this.ActualState);

dictionary.Add("ExcludedDomain", this.ExcludedDomain);

dictionary.Add("ExcludedPerson", this.ExcludedPerson);

dictionary.Add("ExcludeOption", this.ExcludeOption);

if (this.Owner != default)
{
dictionary.Add("Owner", new [] { this.Owner });
}

return dictionary;
}

/// <summary>
/// Tries to remove references to id's if they exist in a collection of id's (Guid's)
/// </summary>
/// <param name="ids">The collection of Guids to remove references for.</param>
/// <param name="errors">The errors collected while trying to remove references</param>
/// <returns>True if no errors were found while trying to remove references</returns>
public override bool TryRemoveReferences(IEnumerable<Guid> ids, out List<string> errors)
{
errors = new List<string>();
var referencedProperties = this.GetReferenceProperties();
var addModelErrors = !ids.Contains(this.Iid);
var result = true;

foreach (var id in ids)
{
var foundProperty = referencedProperties.Where(x => x.Value.Contains(id)).ToList();

if (foundProperty.Any())
{
foreach (var kvp in foundProperty)
{
switch (kvp.Key)
{
case "ActualState":
this.ActualState.Remove(id);
break;

case "ExcludedDomain":
this.ExcludedDomain.Remove(id);
break;

case "ExcludedPerson":
this.ExcludedPerson.Remove(id);
break;

case "ExcludeOption":
this.ExcludeOption.Remove(id);
break;

case "Owner":
if (addModelErrors)
{
errors.Add($"Remove reference '{id}' from Owner property is not allowed.");
}
break;
}
}
}
}

return result;
}

/// <summary>
/// Instantiate a <see cref="CDP4Common.EngineeringModelData.ActualFiniteStateList"/> from a <see cref="ActualFiniteStateList"/>
/// </summary>
Expand Down
Loading
Loading