Skip to content

Improve ValueSetConverter.ToValueSetString #240

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

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions CDP4Common.Tests/Helpers/ValueSetConverterTestFixture.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ValueSetConverterTestFixture.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2020 RHEA System S.A.
// <copyright file="ActionItem.cs" company="RHEA System S.A.">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect class name?

// 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.
//
// 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.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace CDP4Common.Tests.Helpers
Expand Down Expand Up @@ -112,24 +111,37 @@ 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, "-", "-", 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()},
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()},
};
}
}
4 changes: 2 additions & 2 deletions CDP4Common/CDP4Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4Common Community Edition</Title>
<VersionPrefix>8.2.0</VersionPrefix>
<VersionPrefix>8.2.1</VersionPrefix>
<Description>CDP4 Common Class Library that contains DTOs, POCOs</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed</Authors>
Expand All @@ -19,7 +19,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[FIX] Beautify code based on SonarCube advice
[IMPROVE] TextParameterType implementationin ValueSetConverter

</PackageReleaseNotes>
</PropertyGroup>
Expand Down
16 changes: 10 additions & 6 deletions CDP4Common/Helpers/ValueSetConverter.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ValueSetConverter.cs" company="RHEA System S.A.">
// 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.
//
// 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.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace CDP4Common.Helpers
Expand Down Expand Up @@ -61,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);
Expand Down
4 changes: 2 additions & 2 deletions CDP4Dal/CDP4Dal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4Dal Community Edition</Title>
<VersionPrefix>8.1.0</VersionPrefix>
<VersionPrefix>8.1.1</VersionPrefix>
<Description>CDP4 Data Access Layer library, a consumer of an ECSS-E-TM-10-25 Annex C API</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael, Ahmed</Authors>
Expand All @@ -19,7 +19,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[Update] to CDP4Common 8.1.0
[Update] to CDP4Common 8.2.1
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions CDP4JsonFileDal/CDP4JsonFileDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4JsonFileDal Community Edition</Title>
<VersionPrefix>8.1.0</VersionPrefix>
<VersionPrefix>8.1.1</VersionPrefix>
<Description>CDP4 Json File Dal Plugin</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -19,7 +19,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[FIX] Beautify code based on SonarCube advice
[Update] to CDP4Common 8.2.1
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
7 changes: 2 additions & 5 deletions CDP4JsonSerializer/CDP4JsonSerializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4JsonSerializer Community Edition</Title>
<VersionPrefix>8.1.0</VersionPrefix>
<VersionPrefix>8.1.1</VersionPrefix>
<Description>CDP4 JSON Serialization Library</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -19,10 +19,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25 JSON</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
Model version checks for
- Category.PermissibleClass
- PersonPermission
- ParticipantPermission
[Update] to CDP4Common 8.2.1

</PackageReleaseNotes>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4RequirementsVerification Community Edition</Title>
<VersionPrefix>1.13.0</VersionPrefix>
<VersionPrefix>1.13.1</VersionPrefix>
<Description>CDP4 Class Library that provides requirement verification</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -19,7 +19,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[fix] Option dependent Requirement Verification on ElementUsage level
[Update] to CDP4Common 8.2.1
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions CDP4Rules/CDP4Rules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4Rules Community Edition</Title>
<VersionPrefix>8.1.0</VersionPrefix>
<VersionPrefix>8.1.1</VersionPrefix>
<Description>CDP4 Class Library that provides Model Analysis and Rule Checking</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Alex, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -19,7 +19,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[FIX] Beautify code based on SonarCube advice
[Update] to CDP4Common 8.2.1
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions CDP4ServicesDal/CDP4ServicesDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4ServicesDal Community Edition</Title>
<VersionPrefix>8.2.0</VersionPrefix>
<VersionPrefix>8.2.1</VersionPrefix>
<Description>CDP4ServicesDal Dal Plugin</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -19,7 +19,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[Update] to CDP4Common 8.1.0
[Update] to CDP4Common 8.2.1
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions CDP4WspDal/CDP4WspDal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netstandard2.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<Company>RHEA System S.A.</Company>
<Title>CDP4WspDal Community Edition</Title>
<VersionPrefix>8.1.0</VersionPrefix>
<VersionPrefix>8.1.1</VersionPrefix>
<Description>CDP4 WSP Dal Plugin</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander, Yevhen, Nathanael</Authors>
Expand All @@ -19,7 +19,7 @@
<PackageTags>CDP COMET ECSS-E-TM-10-25</PackageTags>
<PackageLicenseExpression>LGPL-3.0-only</PackageLicenseExpression>
<PackageReleaseNotes>
[Update] to CDP4Common 8.1.0
[Update] to CDP4Common 8.2.1
</PackageReleaseNotes>
</PropertyGroup>

Expand Down