From 278a184c8b245bed99d8c2d6e7f9e3a281ce70e4 Mon Sep 17 00:00:00 2001 From: lxatrhea Date: Tue, 5 Jul 2022 15:29:38 +0200 Subject: [PATCH 1/3] Improve ValueSetConverter.ToValueSetString --- .../Helpers/ValueSetConverterTestFixture.cs | 31 +++++++++++++------ CDP4Common/Helpers/ValueSetConverter.cs | 29 +++++++++++------ 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/CDP4Common.Tests/Helpers/ValueSetConverterTestFixture.cs b/CDP4Common.Tests/Helpers/ValueSetConverterTestFixture.cs index 01c203900..f2cb0ee25 100644 --- a/CDP4Common.Tests/Helpers/ValueSetConverterTestFixture.cs +++ b/CDP4Common.Tests/Helpers/ValueSetConverterTestFixture.cs @@ -1,17 +1,17 @@ // -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2015-2020 RHEA System S.A. +// +// Copyright (c) 2015-2022 RHEA System S.A. // -// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft +// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary // -// This file is part of CDP4-SDK Community Edition +// This file is part of COMET-SDK Community Edition // -// The CDP4-SDK Community Edition is free software; you can redistribute it and/or +// The 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 CDP4-SDK Community Edition is distributed in the hope that it will be useful, +// The 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. @@ -19,7 +19,6 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// // -------------------------------------------------------------------------------------------------------------------- namespace CDP4Common.Tests.Helpers @@ -112,20 +111,32 @@ public void VerifyThatValueSetValuesAreCalculatedCorrectly(object value, string new object[] { " ", "-", "-", new SimpleQuantityKind()}, new object[] { true, "true", "true", new BooleanParameterType()}, new object[] { false, "false", "false", new BooleanParameterType()}, + new object[] { "True", "true", "true", new BooleanParameterType()}, + new object[] { "False", "false", "false", new BooleanParameterType()}, + new object[] { "True", "True", "True", new TextParameterType()}, + new object[] { "False", "False", "False", new TextParameterType()}, + new object[] { null, string.Empty, string.Empty, new TextParameterType()}, new object[] { "true", "true", "true", new TextParameterType()}, new object[] { "false", "false", "false", new TextParameterType()}, - new object[] { "True", "true", "true", new TextParameterType()}, - new object[] { "False", "false", "false", new TextParameterType()}, + new object[] { "0000001", "0000001", "0000001", new TextParameterType()}, + new object[] { "000.000,000", "000.000,000", "000.000,000", new TextParameterType()}, new object[] { 11.11F, "11.11", "11.11", new SimpleQuantityKind()}, new object[] { 11.11D, "11.11", "11.11", new SimpleQuantityKind()}, + new object[] { 11.11F, "11,11", "11.11", new TextParameterType()}, + new object[] { 11.11D, "11,11", "11.11", new TextParameterType()}, + new object[] { true, "True", "True", new TextParameterType()}, + new object[] { false, "False", "False", new TextParameterType()}, + new object[] { new EnumerationValueDefinition() {ShortName = "enumValue"}, "enumValue", "enumValue", new EnumerationParameterType()}, + new object[] { "SomeValue", "SomeValue", "SomeValue", new EnumerationParameterType()}, new object[] { new [] { new EnumerationValueDefinition {ShortName = "enumValue1"}, new EnumerationValueDefinition {ShortName = "enumValue2"} - }, $"enumValue1{Constants.PaddedMultiEnumSeparator}enumValue2", $"enumValue1{Constants.PaddedMultiEnumSeparator}enumValue2", new EnumerationParameterType() + }, + $"enumValue1{Constants.PaddedMultiEnumSeparator}enumValue2", $"enumValue1{Constants.PaddedMultiEnumSeparator}enumValue2", new EnumerationParameterType() }, new object[] { DateTime.ParseExact("2020-09-23T12:11:30", "yyyy-MM-ddTHH:mm:ss", null), "2020-09-23T12:11:30", "2020-09-23T12:11:30", new DateTimeParameterType()}, new object[] { DateTime.ParseExact("2020-09-23T12:11:30", "yyyy-MM-ddTHH:mm:ss", null), "2020-09-23", "2020-09-23", new DateParameterType()}, diff --git a/CDP4Common/Helpers/ValueSetConverter.cs b/CDP4Common/Helpers/ValueSetConverter.cs index f4f5fa4b1..23bbbe197 100644 --- a/CDP4Common/Helpers/ValueSetConverter.cs +++ b/CDP4Common/Helpers/ValueSetConverter.cs @@ -1,17 +1,17 @@ // -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) 2015-2020 RHEA System S.A. +// Copyright (c) 2015-2022 RHEA System S.A. // -// Author: Sam Gerené, Merlin Bieze, Alex Vorobiev, Naron Phou, Alexander van Delft +// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate, Omar Elebiary // -// This file is part of CDP4-SDK Community Edition +// This file is part of COMET-SDK Community Edition // -// The CDP4-SDK Community Edition is free software; you can redistribute it and/or +// The 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 CDP4-SDK Community Edition is distributed in the hope that it will be useful, +// The 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. @@ -19,7 +19,6 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program; if not, write to the Free Software Foundation, // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -// // -------------------------------------------------------------------------------------------------------------------- namespace CDP4Common.Helpers @@ -51,6 +50,16 @@ public static string ToValueSetString(this object value, ParameterType parameter throw new ArgumentNullException(nameof(parameterType)); } + if (parameterType.ClassKind == ClassKind.TextParameterType) + { + if (value == null) + { + return string.Empty; + } + + return value.ToString(); + } + if (value == null) { return "-"; @@ -82,18 +91,18 @@ public static string ToValueSetString(this object value, ParameterType parameter var stringValue = value.ToString(); // try parse double in any culture - allow the user to still use "." as separator - if (double.TryParse(stringValue, NumberStyles.Float, CultureInfo.InvariantCulture, out var doubleValue)) + if (parameterType is QuantityKind && double.TryParse(stringValue, NumberStyles.Float, CultureInfo.InvariantCulture, out var doubleValue)) { return doubleValue.ToString(CultureInfo.InvariantCulture); } // convert the comma separator to dot - if (double.TryParse(stringValue, NumberStyles.Float, CultureInfo.CurrentCulture, out doubleValue)) + if (parameterType is QuantityKind && double.TryParse(stringValue, NumberStyles.Float, CultureInfo.CurrentCulture, out doubleValue)) { return doubleValue.ToString(CultureInfo.InvariantCulture); } - if (bool.TryParse(stringValue, out var booleanValue)) + if (parameterType.ClassKind == ClassKind.BooleanParameterType && bool.TryParse(stringValue, out var booleanValue)) { return booleanValue ? "true" : "false"; } @@ -102,7 +111,7 @@ public static string ToValueSetString(this object value, ParameterType parameter } // single enum - if (value is EnumerationValueDefinition enumValueDef) + if (parameterType.ClassKind == ClassKind.EnumerationParameterType && value is EnumerationValueDefinition enumValueDef) { return enumValueDef.ShortName; } From c9efc251760b3b33f158e12dc0bc5eaf17252f8c Mon Sep 17 00:00:00 2001 From: lxatrhea Date: Tue, 5 Jul 2022 16:57:07 +0200 Subject: [PATCH 2/3] Improve a bit more --- .../Helpers/ValueSetConverterTestFixture.cs | 5 ++-- CDP4Common/Helpers/ValueSetConverter.cs | 23 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/CDP4Common.Tests/Helpers/ValueSetConverterTestFixture.cs b/CDP4Common.Tests/Helpers/ValueSetConverterTestFixture.cs index f2cb0ee25..e422693f5 100644 --- a/CDP4Common.Tests/Helpers/ValueSetConverterTestFixture.cs +++ b/CDP4Common.Tests/Helpers/ValueSetConverterTestFixture.cs @@ -115,7 +115,7 @@ public void VerifyThatValueSetValuesAreCalculatedCorrectly(object value, string new object[] { "False", "false", "false", new BooleanParameterType()}, new object[] { "True", "True", "True", new TextParameterType()}, new object[] { "False", "False", "False", new TextParameterType()}, - new object[] { null, string.Empty, string.Empty, new TextParameterType()}, + new object[] { null, "-", "-", new TextParameterType()}, new object[] { "true", "true", "true", new TextParameterType()}, new object[] { "false", "false", "false", new TextParameterType()}, new object[] { "0000001", "0000001", "0000001", new TextParameterType()}, @@ -135,12 +135,13 @@ public void VerifyThatValueSetValuesAreCalculatedCorrectly(object value, string { new EnumerationValueDefinition {ShortName = "enumValue1"}, new EnumerationValueDefinition {ShortName = "enumValue2"} - }, + }, $"enumValue1{Constants.PaddedMultiEnumSeparator}enumValue2", $"enumValue1{Constants.PaddedMultiEnumSeparator}enumValue2", new EnumerationParameterType() }, new object[] { DateTime.ParseExact("2020-09-23T12:11:30", "yyyy-MM-ddTHH:mm:ss", null), "2020-09-23T12:11:30", "2020-09-23T12:11:30", new DateTimeParameterType()}, new object[] { DateTime.ParseExact("2020-09-23T12:11:30", "yyyy-MM-ddTHH:mm:ss", null), "2020-09-23", "2020-09-23", new DateParameterType()}, new object[] { DateTime.ParseExact("2020-09-23T12:11:30", "yyyy-MM-ddTHH:mm:ss", null), "12:11:30", "12:11:30", new TimeOfDayParameterType()}, + new object[] { "2020-09-23T12:11:30", "2020-09-23T12:11:30", "2020-09-23T12:11:30", new DateTimeParameterType()}, }; } } diff --git a/CDP4Common/Helpers/ValueSetConverter.cs b/CDP4Common/Helpers/ValueSetConverter.cs index 23bbbe197..b55a0c23b 100644 --- a/CDP4Common/Helpers/ValueSetConverter.cs +++ b/CDP4Common/Helpers/ValueSetConverter.cs @@ -50,16 +50,6 @@ public static string ToValueSetString(this object value, ParameterType parameter throw new ArgumentNullException(nameof(parameterType)); } - if (parameterType.ClassKind == ClassKind.TextParameterType) - { - if (value == null) - { - return string.Empty; - } - - return value.ToString(); - } - if (value == null) { return "-"; @@ -70,6 +60,11 @@ public static string ToValueSetString(this object value, ParameterType parameter return "-"; } + if (parameterType.ClassKind == ClassKind.TextParameterType) + { + return value.ToString(); + } + if (value is bool) { var booleanValue = Convert.ToBoolean(value); @@ -91,18 +86,18 @@ public static string ToValueSetString(this object value, ParameterType parameter var stringValue = value.ToString(); // try parse double in any culture - allow the user to still use "." as separator - if (parameterType is QuantityKind && double.TryParse(stringValue, NumberStyles.Float, CultureInfo.InvariantCulture, out var doubleValue)) + if (double.TryParse(stringValue, NumberStyles.Float, CultureInfo.InvariantCulture, out var doubleValue)) { return doubleValue.ToString(CultureInfo.InvariantCulture); } // convert the comma separator to dot - if (parameterType is QuantityKind && double.TryParse(stringValue, NumberStyles.Float, CultureInfo.CurrentCulture, out doubleValue)) + if (double.TryParse(stringValue, NumberStyles.Float, CultureInfo.CurrentCulture, out doubleValue)) { return doubleValue.ToString(CultureInfo.InvariantCulture); } - if (parameterType.ClassKind == ClassKind.BooleanParameterType && bool.TryParse(stringValue, out var booleanValue)) + if (bool.TryParse(stringValue, out var booleanValue)) { return booleanValue ? "true" : "false"; } @@ -111,7 +106,7 @@ public static string ToValueSetString(this object value, ParameterType parameter } // single enum - if (parameterType.ClassKind == ClassKind.EnumerationParameterType && value is EnumerationValueDefinition enumValueDef) + if (value is EnumerationValueDefinition enumValueDef) { return enumValueDef.ShortName; } From e35da643fbc15cdfbf433beda9f75102b86c07bf Mon Sep 17 00:00:00 2001 From: lxatrhea Date: Wed, 6 Jul 2022 12:39:44 +0200 Subject: [PATCH 3/3] Bump version numbers --- CDP4Common/CDP4Common.csproj | 4 ++-- CDP4Dal/CDP4Dal.csproj | 4 ++-- CDP4JsonFileDal/CDP4JsonFileDal.csproj | 4 ++-- CDP4JsonSerializer/CDP4JsonSerializer.csproj | 7 ++----- .../CDP4RequirementsVerification.csproj | 4 ++-- CDP4Rules/CDP4Rules.csproj | 4 ++-- CDP4ServicesDal/CDP4ServicesDal.csproj | 4 ++-- CDP4WspDal/CDP4WspDal.csproj | 4 ++-- 8 files changed, 16 insertions(+), 19 deletions(-) diff --git a/CDP4Common/CDP4Common.csproj b/CDP4Common/CDP4Common.csproj index 42ae9ab72..fd868e2d0 100644 --- a/CDP4Common/CDP4Common.csproj +++ b/CDP4Common/CDP4Common.csproj @@ -4,7 +4,7 @@ net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1 RHEA System S.A. CDP4Common Community Edition - 8.2.0 + 8.2.1 CDP4 Common Class Library that contains DTOs, POCOs Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed @@ -19,7 +19,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [FIX] Beautify code based on SonarCube advice + [IMPROVE] TextParameterType implementationin ValueSetConverter diff --git a/CDP4Dal/CDP4Dal.csproj b/CDP4Dal/CDP4Dal.csproj index 8a4536176..73c7d9be9 100644 --- a/CDP4Dal/CDP4Dal.csproj +++ b/CDP4Dal/CDP4Dal.csproj @@ -4,7 +4,7 @@ net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1 RHEA System S.A. CDP4Dal Community Edition - 8.1.0 + 8.1.1 CDP4 Data Access Layer library, a consumer of an ECSS-E-TM-10-25 Annex C API Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed @@ -19,7 +19,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [Update] to CDP4Common 8.1.0 + [Update] to CDP4Common 8.2.1 diff --git a/CDP4JsonFileDal/CDP4JsonFileDal.csproj b/CDP4JsonFileDal/CDP4JsonFileDal.csproj index e08f70c47..8d65214c1 100644 --- a/CDP4JsonFileDal/CDP4JsonFileDal.csproj +++ b/CDP4JsonFileDal/CDP4JsonFileDal.csproj @@ -4,7 +4,7 @@ net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1 RHEA System S.A. CDP4JsonFileDal Community Edition - 8.1.0 + 8.1.1 CDP4 Json File Dal Plugin Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael @@ -19,7 +19,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [FIX] Beautify code based on SonarCube advice + [Update] to CDP4Common 8.2.1 diff --git a/CDP4JsonSerializer/CDP4JsonSerializer.csproj b/CDP4JsonSerializer/CDP4JsonSerializer.csproj index 4e73d986f..9e1442798 100644 --- a/CDP4JsonSerializer/CDP4JsonSerializer.csproj +++ b/CDP4JsonSerializer/CDP4JsonSerializer.csproj @@ -4,7 +4,7 @@ net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1 RHEA System S.A. CDP4JsonSerializer Community Edition - 8.1.0 + 8.1.1 CDP4 JSON Serialization Library Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael @@ -19,10 +19,7 @@ CDP COMET ECSS-E-TM-10-25 JSON LGPL-3.0-only - Model version checks for - - Category.PermissibleClass - - PersonPermission - - ParticipantPermission + [Update] to CDP4Common 8.2.1 diff --git a/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj b/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj index 185fa788a..73375a379 100644 --- a/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj +++ b/CDP4RequirementsVerification/CDP4RequirementsVerification.csproj @@ -4,7 +4,7 @@ net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1 RHEA System S.A. CDP4RequirementsVerification Community Edition - 1.13.0 + 1.13.1 CDP4 Class Library that provides requirement verification Copyright © RHEA System S.A. Sam, Alex, Alexander, Yevhen, Nathanael @@ -19,7 +19,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [fix] Option dependent Requirement Verification on ElementUsage level + [Update] to CDP4Common 8.2.1 diff --git a/CDP4Rules/CDP4Rules.csproj b/CDP4Rules/CDP4Rules.csproj index a9ce7f3af..8612e44d7 100644 --- a/CDP4Rules/CDP4Rules.csproj +++ b/CDP4Rules/CDP4Rules.csproj @@ -4,7 +4,7 @@ net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1 RHEA System S.A. CDP4Rules Community Edition - 8.1.0 + 8.1.1 CDP4 Class Library that provides Model Analysis and Rule Checking Copyright © RHEA System S.A. Sam, Alex, Alexander, Yevhen, Nathanael @@ -19,7 +19,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [FIX] Beautify code based on SonarCube advice + [Update] to CDP4Common 8.2.1 diff --git a/CDP4ServicesDal/CDP4ServicesDal.csproj b/CDP4ServicesDal/CDP4ServicesDal.csproj index afe37e01b..78d78392d 100644 --- a/CDP4ServicesDal/CDP4ServicesDal.csproj +++ b/CDP4ServicesDal/CDP4ServicesDal.csproj @@ -4,7 +4,7 @@ net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1 RHEA System S.A. CDP4ServicesDal Community Edition - 8.2.0 + 8.2.1 CDP4ServicesDal Dal Plugin Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael @@ -19,7 +19,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [Update] to CDP4Common 8.1.0 + [Update] to CDP4Common 8.2.1 diff --git a/CDP4WspDal/CDP4WspDal.csproj b/CDP4WspDal/CDP4WspDal.csproj index 6a2d89844..ac783b67b 100644 --- a/CDP4WspDal/CDP4WspDal.csproj +++ b/CDP4WspDal/CDP4WspDal.csproj @@ -4,7 +4,7 @@ net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1 RHEA System S.A. CDP4WspDal Community Edition - 8.1.0 + 8.1.1 CDP4 WSP Dal Plugin Copyright © RHEA System S.A. Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael @@ -19,7 +19,7 @@ CDP COMET ECSS-E-TM-10-25 LGPL-3.0-only - [Update] to CDP4Common 8.1.0 + [Update] to CDP4Common 8.2.1