diff --git a/COMETwebapp.Tests/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTableTestFixture.cs b/COMETwebapp.Tests/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTableTestFixture.cs
new file mode 100644
index 00000000..6668a640
--- /dev/null
+++ b/COMETwebapp.Tests/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTableTestFixture.cs
@@ -0,0 +1,127 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Tests.Components.ReferenceData.MeasurementScales
+{
+ using Bunit;
+
+ using CDP4Common.SiteDirectoryData;
+
+ using COMET.Web.Common.Test.Helpers;
+
+ using COMETwebapp.Components.ReferenceData.MeasurementScales;
+
+ using DevExpress.Blazor;
+
+ using NUnit.Framework;
+
+ using TestContext = Bunit.TestContext;
+
+ [TestFixture]
+ public class MappingToReferenceScalesTableTestFixture
+ {
+ private TestContext context;
+ private IRenderedComponent renderer;
+
+ [SetUp]
+ public void SetUp()
+ {
+ this.context = new TestContext();
+ this.context.ConfigureDevExpressBlazor();
+
+ var mappingToReferenceScale = new MappingToReferenceScale
+ {
+ ReferenceScaleValue = new ScaleValueDefinition(),
+ DependentScaleValue = new ScaleValueDefinition()
+ };
+
+ this.renderer = this.context.RenderComponent(parameters =>
+ {
+ parameters.Add(p => p.MappingToReferenceScales, [mappingToReferenceScale]);
+ parameters.Add(p => p.DependentScaleValueDefinitions, [new ScaleValueDefinition()]);
+ parameters.Add(p => p.ReferenceScaleValueDefinitions, [new ScaleValueDefinition()]);
+ });
+ }
+
+ [TearDown]
+ public void Teardown()
+ {
+ this.context.CleanContext();
+ this.context.Dispose();
+ }
+
+ [Test]
+ public void VerifyOnInitialized()
+ {
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.renderer.Instance, Is.Not.Null);
+ Assert.That(this.renderer.Instance.DependentScaleValueDefinitions, Is.Not.Null);
+ Assert.That(this.renderer.Instance.DependentScaleValueDefinitions, Is.Not.Null);
+ Assert.That(this.renderer.Instance.ShouldCreate, Is.EqualTo(false));
+ });
+ }
+
+ [Test]
+ public async Task VerifyUnitFactorsTable()
+ {
+ var timesMappingToReferenceScalesChanged = 0;
+
+ this.renderer.SetParametersAndRender(p => { p.Add(parameters => parameters.MappingToReferenceScalesChanged, () => { timesMappingToReferenceScalesChanged++; }); });
+
+ var editMappingToReferenceScaleButton = this.renderer.FindComponents().First(x => x.Instance.Id == "editMappingToReferenceScaleButton");
+ await this.renderer.InvokeAsync(editMappingToReferenceScaleButton.Instance.Click.InvokeAsync);
+
+ var form = this.renderer.FindComponent();
+ await this.renderer.InvokeAsync(form.Instance.EditModelSaving.InvokeAsync);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.renderer.Instance.ShouldCreate, Is.EqualTo(false));
+ Assert.That(this.renderer.Instance.MappingToReferenceScales, Has.Count.EqualTo(1));
+ Assert.That(timesMappingToReferenceScalesChanged, Is.EqualTo(1));
+ });
+
+ var addMappingToReferenceScaleButton = this.renderer.FindComponents().First(x => x.Instance.Id == "addMappingToReferenceScaleButton");
+ await this.renderer.InvokeAsync(addMappingToReferenceScaleButton.Instance.Click.InvokeAsync);
+ await this.renderer.InvokeAsync(form.Instance.EditModelSaving.InvokeAsync);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.renderer.Instance.ShouldCreate, Is.EqualTo(true));
+ Assert.That(this.renderer.Instance.MappingToReferenceScales, Has.Count.EqualTo(2));
+ Assert.That(timesMappingToReferenceScalesChanged, Is.EqualTo(2));
+ });
+
+ var removeMappingToReferenceScaleButton = this.renderer.FindComponents().First(x => x.Instance.Id == "removeMappingToReferenceScaleButton");
+ await this.renderer.InvokeAsync(removeMappingToReferenceScaleButton.Instance.Click.InvokeAsync);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.renderer.Instance.MappingToReferenceScales, Has.Count.EqualTo(1));
+ Assert.That(timesMappingToReferenceScalesChanged, Is.EqualTo(3));
+ });
+ }
+ }
+}
diff --git a/COMETwebapp.Tests/Components/ReferenceData/MeasurementScalesTableTestFixture.cs b/COMETwebapp.Tests/Components/ReferenceData/MeasurementScales/MeasurementScalesTableTestFixture.cs
similarity index 62%
rename from COMETwebapp.Tests/Components/ReferenceData/MeasurementScalesTableTestFixture.cs
rename to COMETwebapp.Tests/Components/ReferenceData/MeasurementScales/MeasurementScalesTableTestFixture.cs
index f170ca0a..1bf9c995 100644
--- a/COMETwebapp.Tests/Components/ReferenceData/MeasurementScalesTableTestFixture.cs
+++ b/COMETwebapp.Tests/Components/ReferenceData/MeasurementScales/MeasurementScalesTableTestFixture.cs
@@ -1,47 +1,47 @@
// --------------------------------------------------------------------------------------------------------------------
-//
-// Copyright (c) 2023-2024 RHEA System S.A.
-//
-// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
-//
-// This file is part of CDP4-COMET WEB Community Edition
-// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
-//
-// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Affero 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-COMET WEB 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
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
// Affero General Public License for more details.
-//
+//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
-// --------------------------------------------------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------------------------------------------------
-namespace COMETwebapp.Tests.Components.ReferenceData
+namespace COMETwebapp.Tests.Components.ReferenceData.MeasurementScales
{
- using System.Linq;
- using System.Threading.Tasks;
-
using Bunit;
+ using CDP4Common.CommonData;
using CDP4Common.SiteDirectoryData;
using COMET.Web.Common.Test.Helpers;
- using COMETwebapp.Components.ReferenceData;
+ using COMETwebapp.Components.ReferenceData.MeasurementScales;
using COMETwebapp.Services.ShowHideDeprecatedThingsService;
using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales;
using COMETwebapp.ViewModels.Components.ReferenceData.Rows;
+ using COMETwebapp.Wrappers;
using DevExpress.Blazor;
using DynamicData;
+ using Microsoft.AspNetCore.Components.Forms;
using Microsoft.Extensions.DependencyInjection;
using Moq;
@@ -68,22 +68,22 @@ public void SetUp()
this.showHideService = new Mock();
this.showHideService.Setup(x => x.ShowDeprecatedThings).Returns(true);
- this.measurementScale1 = new OrdinalScale()
+ this.measurementScale1 = new LogarithmicScale
{
Name = "A name",
ShortName = "AName",
- Container = new SiteReferenceDataLibrary(){ ShortName = "rdl" },
- Unit = new SimpleUnit() { ShortName = "unit1" },
+ Container = new SiteReferenceDataLibrary { ShortName = "rdl" },
+ Unit = new SimpleUnit { ShortName = "unit1" },
NumberSet = NumberSetKind.NATURAL_NUMBER_SET,
IsDeprecated = false
};
- this.measurementScale2 = new OrdinalScale()
+ this.measurementScale2 = new OrdinalScale
{
Name = "B name",
ShortName = "BName",
- Container = new SiteReferenceDataLibrary() { ShortName = "rdl" },
- Unit = new SimpleUnit(){ ShortName = "unit2" },
+ Container = new SiteReferenceDataLibrary { ShortName = "rdl" },
+ Unit = new SimpleUnit { ShortName = "unit2" },
NumberSet = NumberSetKind.INTEGER_NUMBER_SET,
IsDeprecated = true
};
@@ -92,13 +92,16 @@ public void SetUp()
rows.Add(new MeasurementScaleRowViewModel(this.measurementScale1));
rows.Add(new MeasurementScaleRowViewModel(this.measurementScale2));
+ var availableMeasurementScaleTypes = new List { ClassKind.CyclicRatioScale, ClassKind.IntervalScale, ClassKind.LogarithmicScale, ClassKind.OrdinalScale, ClassKind.RatioScale };
+
this.viewModel.Setup(x => x.Rows).Returns(rows);
this.viewModel.Setup(x => x.MeasurementUnits).Returns([]);
this.viewModel.Setup(x => x.NumberSetKinds).Returns([]);
this.viewModel.Setup(x => x.ReferenceDataLibraries).Returns([]);
this.viewModel.Setup(x => x.ShowHideDeprecatedThingsService).Returns(this.showHideService.Object);
this.viewModel.Setup(x => x.IsOnDeprecationMode).Returns(true);
- this.viewModel.Setup(x => x.Thing).Returns(new OrdinalScale());
+ this.viewModel.Setup(x => x.MeasurementScaleTypes).Returns(availableMeasurementScaleTypes.Select(x => new ClassKindWrapper(x)));
+ this.viewModel.Setup(x => x.Thing).Returns(new LogarithmicScale());
this.context.Services.AddSingleton(this.viewModel.Object);
this.context.ConfigureDevExpressBlazor();
@@ -112,18 +115,36 @@ public void Teardown()
}
[Test]
- public void VerifyOnInitialized()
+ public async Task VerifyAddingOrEditingMeasurementScale()
{
var renderer = this.context.RenderComponent();
+ var addMeasurementScaleButton = renderer.FindComponents().First(x => x.Instance.Id == "addMeasurementScaleButton");
+ await renderer.InvokeAsync(addMeasurementScaleButton.Instance.Click.InvokeAsync);
+
Assert.Multiple(() =>
{
- Assert.That(renderer.Instance.ShouldCreateThing, Is.EqualTo(false));
- Assert.That(renderer.Instance.ViewModel, Is.Not.Null);
- Assert.That(renderer.Markup, Does.Contain(this.measurementScale1.Name));
- Assert.That(renderer.Markup, Does.Contain(this.measurementScale2.Name));
- this.viewModel.Verify(x => x.InitializeViewModel(), Times.Once);
+ Assert.That(renderer.Instance.ShouldCreateThing, Is.EqualTo(true));
+ Assert.That(this.viewModel.Object.Thing, Is.InstanceOf(typeof(MeasurementScale)));
+ });
+
+ var measurementScalesGrid = renderer.FindComponent();
+ await renderer.InvokeAsync(() => measurementScalesGrid.Instance.SelectedDataItemChanged.InvokeAsync(new MeasurementScaleRowViewModel(this.measurementScale1)));
+ Assert.That(renderer.Instance.IsOnEditMode, Is.EqualTo(true));
+
+ var measurementScalesForm = renderer.FindComponents()[1];
+ var measurementScalesEditForm = measurementScalesForm.FindComponent();
+ await measurementScalesForm.InvokeAsync(measurementScalesEditForm.Instance.OnValidSubmit.InvokeAsync);
+
+ Assert.Multiple(() =>
+ {
+ this.viewModel.Verify(x => x.CreateOrEditMeasurementScale(false), Times.Once);
+ Assert.That(this.viewModel.Object.Thing, Is.InstanceOf(typeof(LogarithmicScale)));
});
+
+ var form = renderer.FindComponent();
+ await renderer.InvokeAsync(form.Instance.EditModelSaving.InvokeAsync);
+ this.viewModel.Verify(x => x.CreateOrEditMeasurementScale(false), Times.Once);
}
[Test]
@@ -141,26 +162,17 @@ public async Task VerifyDeprecatingAndUndeprecatingMeasurementScale()
}
[Test]
- public async Task VerifyAddingOrEditingMeasurementScale()
+ public void VerifyOnInitialized()
{
var renderer = this.context.RenderComponent();
- var addMeasurementScaleButton = renderer.FindComponents().First(x => x.Instance.Id == "addMeasurementScaleButton");
- await renderer.InvokeAsync(addMeasurementScaleButton.Instance.Click.InvokeAsync);
-
- Assert.Multiple(() =>
- {
- Assert.That(renderer.Instance.ShouldCreateThing, Is.EqualTo(true));
- Assert.That(this.viewModel.Object.Thing, Is.InstanceOf(typeof(MeasurementScale)));
- });
-
- var editMeasurementScaleButton = renderer.FindComponents().First(x => x.Instance.Id == "editScaleButton");
- await renderer.InvokeAsync(editMeasurementScaleButton.Instance.Click.InvokeAsync);
-
Assert.Multiple(() =>
{
Assert.That(renderer.Instance.ShouldCreateThing, Is.EqualTo(false));
- Assert.That(this.viewModel.Object.Thing, Is.InstanceOf(typeof(MeasurementScale)));
+ Assert.That(renderer.Instance.ViewModel, Is.Not.Null);
+ Assert.That(renderer.Markup, Does.Contain(this.measurementScale1.Name));
+ Assert.That(renderer.Markup, Does.Contain(this.measurementScale2.Name));
+ this.viewModel.Verify(x => x.InitializeViewModel(), Times.Once);
});
}
}
diff --git a/COMETwebapp.Tests/Components/ReferenceData/MeasurementScales/ScaleValueDefinitionsTableTestFixture.cs b/COMETwebapp.Tests/Components/ReferenceData/MeasurementScales/ScaleValueDefinitionsTableTestFixture.cs
new file mode 100644
index 00000000..0212125d
--- /dev/null
+++ b/COMETwebapp.Tests/Components/ReferenceData/MeasurementScales/ScaleValueDefinitionsTableTestFixture.cs
@@ -0,0 +1,114 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Tests.Components.ReferenceData.MeasurementScales
+{
+ using Bunit;
+
+ using CDP4Common.SiteDirectoryData;
+
+ using COMET.Web.Common.Test.Helpers;
+
+ using COMETwebapp.Components.ReferenceData.MeasurementScales;
+
+ using DevExpress.Blazor;
+
+ using NUnit.Framework;
+
+ using TestContext = Bunit.TestContext;
+
+ [TestFixture]
+ public class ScaleValueDefinitionsTableTestFixture
+ {
+ private TestContext context;
+ private IRenderedComponent renderer;
+
+ [SetUp]
+ public void SetUp()
+ {
+ this.context = new TestContext();
+ this.context.ConfigureDevExpressBlazor();
+
+ this.renderer = this.context.RenderComponent(parameters => { parameters.Add(p => p.ScaleValueDefinitions, [new ScaleValueDefinition()]); });
+ }
+
+ [TearDown]
+ public void Teardown()
+ {
+ this.context.CleanContext();
+ this.context.Dispose();
+ }
+
+ [Test]
+ public void VerifyOnInitialized()
+ {
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.renderer.Instance, Is.Not.Null);
+ Assert.That(this.renderer.Instance.ShouldCreate, Is.EqualTo(false));
+ });
+ }
+
+ [Test]
+ public async Task VerifyUnitFactorsTable()
+ {
+ var timesScaleValueDefinitionsChanged = 0;
+
+ this.renderer.SetParametersAndRender(p => { p.Add(parameters => parameters.ScaleValueDefinitionsChanged, () => { timesScaleValueDefinitionsChanged++; }); });
+
+ var editScaleValueDefinitionButton = this.renderer.FindComponents().First(x => x.Instance.Id == "editScaleValueDefinitionButton");
+ await this.renderer.InvokeAsync(editScaleValueDefinitionButton.Instance.Click.InvokeAsync);
+
+ var form = this.renderer.FindComponent();
+ await this.renderer.InvokeAsync(form.Instance.EditModelSaving.InvokeAsync);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.renderer.Instance.ShouldCreate, Is.EqualTo(false));
+ Assert.That(this.renderer.Instance.ScaleValueDefinitions, Has.Count.EqualTo(1));
+ Assert.That(timesScaleValueDefinitionsChanged, Is.EqualTo(1));
+ });
+
+ var addScaleValueDefinitionButton = this.renderer.FindComponents().First(x => x.Instance.Id == "addScaleValueDefinitionButton");
+ await this.renderer.InvokeAsync(addScaleValueDefinitionButton.Instance.Click.InvokeAsync);
+ await this.renderer.InvokeAsync(form.Instance.EditModelSaving.InvokeAsync);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.renderer.Instance.ShouldCreate, Is.EqualTo(true));
+ Assert.That(this.renderer.Instance.ScaleValueDefinitions, Has.Count.EqualTo(2));
+ Assert.That(timesScaleValueDefinitionsChanged, Is.EqualTo(2));
+ });
+
+ var removeScaleValueDefinitionButton = this.renderer.FindComponents().First(x => x.Instance.Id == "removeScaleValueDefinitionButton");
+ await this.renderer.InvokeAsync(removeScaleValueDefinitionButton.Instance.Click.InvokeAsync);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.renderer.Instance.ScaleValueDefinitions, Has.Count.EqualTo(1));
+ Assert.That(timesScaleValueDefinitionsChanged, Is.EqualTo(3));
+ });
+ }
+ }
+}
diff --git a/COMETwebapp.Tests/Validators/ReferenceData/MeasurementScaleValidatorsTestFixture.cs b/COMETwebapp.Tests/Validators/ReferenceData/MeasurementScaleValidatorsTestFixture.cs
new file mode 100644
index 00000000..6029485f
--- /dev/null
+++ b/COMETwebapp.Tests/Validators/ReferenceData/MeasurementScaleValidatorsTestFixture.cs
@@ -0,0 +1,128 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Tests.Validators.ReferenceData
+{
+ using CDP4Common.SiteDirectoryData;
+ using CDP4Common.Validation;
+
+ using COMETwebapp.Validators.ReferenceData.MeasurementScales;
+
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class MeasurementScaleValidatorsTestFixture
+ {
+ private MeasurementScaleValidator measurementScaleValidator;
+ private CyclicRatioScaleValidator cyclicRatioScaleValidator;
+ private LogarithmicScaleValidator logarithmicScaleValidator;
+ private OrdinalScaleValidator ordinalScaleValidator;
+
+ [SetUp]
+ public void SetUp()
+ {
+ var validationService = new ValidationService();
+ this.measurementScaleValidator = new MeasurementScaleValidator(validationService);
+ this.cyclicRatioScaleValidator = new CyclicRatioScaleValidator(validationService);
+ this.logarithmicScaleValidator = new LogarithmicScaleValidator(validationService);
+ this.ordinalScaleValidator = new OrdinalScaleValidator(validationService);
+ }
+
+ [Test]
+ public void VerifyCyclicRatioScaleValidation()
+ {
+ var cyclicRatio = new CyclicRatioScale();
+ Assert.That(this.cyclicRatioScaleValidator.Validate(cyclicRatio).IsValid, Is.EqualTo(false));
+
+ cyclicRatio = new CyclicRatioScale
+ {
+ Name = "updated scale",
+ ShortName = "updated scale"
+ };
+
+ Assert.That(this.cyclicRatioScaleValidator.Validate(cyclicRatio).IsValid, Is.EqualTo(false));
+ cyclicRatio.ShortName = "updatedScale";
+ Assert.That(this.cyclicRatioScaleValidator.Validate(cyclicRatio).IsValid, Is.EqualTo(false));
+ cyclicRatio.Modulus = "modulus";
+ Assert.That(this.cyclicRatioScaleValidator.Validate(cyclicRatio).IsValid, Is.EqualTo(true));
+ }
+
+ [Test]
+ public void VerifyLogarithmicScaleValidation()
+ {
+ var logarithmicScale = new LogarithmicScale();
+ Assert.That(this.logarithmicScaleValidator.Validate(logarithmicScale).IsValid, Is.EqualTo(false));
+
+ logarithmicScale = new LogarithmicScale
+ {
+ Name = "updated scale",
+ ShortName = "updated scale"
+ };
+
+ Assert.That(this.logarithmicScaleValidator.Validate(logarithmicScale).IsValid, Is.EqualTo(false));
+ logarithmicScale.ShortName = "updatedScale";
+ Assert.That(this.logarithmicScaleValidator.Validate(logarithmicScale).IsValid, Is.EqualTo(false));
+ logarithmicScale.LogarithmBase = LogarithmBaseKind.NATURAL;
+ logarithmicScale.Exponent = "2";
+ logarithmicScale.Factor = "3";
+ Assert.That(this.logarithmicScaleValidator.Validate(logarithmicScale).IsValid, Is.EqualTo(true));
+ }
+
+ [Test]
+ public void VerifyMeasurementScaleValidation()
+ {
+ var intervalScale = new IntervalScale();
+ Assert.That(this.measurementScaleValidator.Validate(intervalScale).IsValid, Is.EqualTo(false));
+
+ intervalScale = new IntervalScale
+ {
+ Name = "updated scale",
+ ShortName = "updated scale"
+ };
+
+ Assert.That(this.measurementScaleValidator.Validate(intervalScale).IsValid, Is.EqualTo(false));
+ intervalScale.ShortName = "updatedScale";
+ Assert.That(this.measurementScaleValidator.Validate(intervalScale).IsValid, Is.EqualTo(true));
+ }
+
+ [Test]
+ public void VerifyOrdinalScaleValidation()
+ {
+ var ordinalScale = new OrdinalScale();
+ Assert.That(this.ordinalScaleValidator.Validate(ordinalScale).IsValid, Is.EqualTo(false));
+
+ ordinalScale = new OrdinalScale
+ {
+ Name = "updated scale",
+ ShortName = "updated scale"
+ };
+
+ Assert.That(this.ordinalScaleValidator.Validate(ordinalScale).IsValid, Is.EqualTo(false));
+ ordinalScale.ShortName = "updatedScale";
+ Assert.That(this.ordinalScaleValidator.Validate(ordinalScale).IsValid, Is.EqualTo(false));
+ ordinalScale.UseShortNameValues = true;
+ Assert.That(this.ordinalScaleValidator.Validate(ordinalScale).IsValid, Is.EqualTo(true));
+ }
+ }
+}
diff --git a/COMETwebapp.Tests/ViewModels/Components/ReferenceData/MeasurementScalesTableViewModelTestFixture.cs b/COMETwebapp.Tests/ViewModels/Components/ReferenceData/MeasurementScalesTableViewModelTestFixture.cs
index 12db79f3..db03eb05 100644
--- a/COMETwebapp.Tests/ViewModels/Components/ReferenceData/MeasurementScalesTableViewModelTestFixture.cs
+++ b/COMETwebapp.Tests/ViewModels/Components/ReferenceData/MeasurementScalesTableViewModelTestFixture.cs
@@ -1,18 +1,18 @@
// --------------------------------------------------------------------------------------------------------------------
-//
-// Copyright (c) 2023-2024 RHEA System S.A.
+//
+// Copyright (c) 2024 Starion Group S.A.
//
-// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
//
-// This file is part of CDP4-COMET WEB Community Edition
-// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
-// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero 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-COMET WEB Community Edition is distributed in the hope that it will be useful,
+// The COMET WEB 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
// Affero General Public License for more details.
@@ -34,11 +34,11 @@ namespace COMETwebapp.Tests.ViewModels.Components.ReferenceData
using CDP4Web.Enumerations;
- using COMET.Web.Common.Enumerations;
using COMET.Web.Common.Services.SessionManagement;
using COMETwebapp.Services.ShowHideDeprecatedThingsService;
using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales;
+ using COMETwebapp.Wrappers;
using Microsoft.Extensions.Logging;
@@ -57,6 +57,7 @@ public class MeasurementScalesTableViewModelTestFixture
private CDPMessageBus messageBus;
private Mock showHideService;
private MeasurementScale measurementScale;
+ private SiteDirectory siteDirectory;
[SetUp]
public void Setup()
@@ -67,26 +68,35 @@ public void Setup()
this.messageBus = new CDPMessageBus();
this.loggerMock = new Mock>();
- this.measurementScale = new OrdinalScale()
+ this.measurementScale = new OrdinalScale
{
ShortName = "scale",
Name = "scale",
- Unit = new SimpleUnit(){ ShortName = "simpleUnit" },
+ Unit = new SimpleUnit { ShortName = "simpleUnit" },
NumberSet = NumberSetKind.INTEGER_NUMBER_SET
};
- var siteReferenceDataLibrary = new SiteReferenceDataLibrary()
+ var siteReferenceDataLibrary = new SiteReferenceDataLibrary
{
ShortName = "rdl",
+ Unit = { new SimpleUnit() },
+ ParameterType = { new SimpleQuantityKind() },
+ Scale =
+ {
+ new OrdinalScale
+ {
+ ValueDefinition = { new ScaleValueDefinition { Iid = Guid.NewGuid() } }
+ }
+ }
};
- var siteDirectory = new SiteDirectory()
+ this.siteDirectory = new SiteDirectory
{
ShortName = "siteDirectory"
};
siteReferenceDataLibrary.Scale.Add(this.measurementScale);
- siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary);
+ this.siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary);
this.assembler = new Assembler(new Uri("http://localhost:5000/"), this.messageBus);
var lazyMeasurementScale = new Lazy(this.measurementScale);
@@ -96,9 +106,9 @@ public void Setup()
var session = new Mock();
session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
session.Setup(x => x.Assembler).Returns(this.assembler);
- session.Setup(x => x.RetrieveSiteDirectory()).Returns(siteDirectory);
+ session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDirectory);
this.sessionService.Setup(x => x.Session).Returns(session.Object);
- this.sessionService.Setup(x => x.GetSiteDirectory()).Returns(siteDirectory);
+ this.sessionService.Setup(x => x.GetSiteDirectory()).Returns(this.siteDirectory);
this.viewModel = new MeasurementScalesTableViewModel(this.sessionService.Object, this.showHideService.Object, this.messageBus, this.loggerMock.Object);
}
@@ -114,11 +124,74 @@ public void Teardown()
public void VerifyInitializeViewModel()
{
this.viewModel.InitializeViewModel();
+ this.viewModel.SelectedScaleValueDefinitions = [new ScaleValueDefinition()];
Assert.Multiple(() =>
{
Assert.That(this.viewModel.Rows.Count, Is.EqualTo(1));
Assert.That(this.viewModel.Rows.Items.First().Thing, Is.EqualTo(this.measurementScale));
+ Assert.That(this.viewModel.ReferenceDataLibraries, Is.EqualTo(this.siteDirectory.SiteReferenceDataLibrary));
+ Assert.That(this.viewModel.ReferenceQuantityKinds.Count(), Is.EqualTo(1));
+ Assert.That(this.viewModel.ReferenceScaleValueDefinitions.Count(), Is.EqualTo(1));
+ Assert.That(this.viewModel.MeasurementScales.Count(), Is.EqualTo(2));
+ Assert.That(this.viewModel.MeasurementUnits.Count(), Is.EqualTo(1));
+ Assert.That(this.viewModel.NumberSetKinds.Count(), Is.EqualTo(Enum.GetValues().Length));
+ Assert.That(this.viewModel.LogarithmBaseKinds.Count(), Is.EqualTo(Enum.GetValues().Length));
+ });
+ }
+
+ [Test]
+ public async Task VerifyMeasurementScaleAddOrEdit()
+ {
+ this.viewModel.InitializeViewModel();
+ this.viewModel.SelectedMeasurementScaleType = new ClassKindWrapper(ClassKind.LogarithmicScale);
+
+ var scaleValueDefinition = new ScaleValueDefinition
+ {
+ ShortName = "valueDefinition",
+ Value = "val"
+ };
+
+ var mappingToReferenceScale = new MappingToReferenceScale
+ {
+ DependentScaleValue = scaleValueDefinition,
+ ReferenceScaleValue = new ScaleValueDefinition()
+ };
+
+ this.viewModel.Thing.ValueDefinition.Add(scaleValueDefinition);
+ this.viewModel.Thing.MappingToReferenceScale.Add(mappingToReferenceScale);
+ this.viewModel.SelectedReferenceQuantityValue.Value = "value";
+ this.viewModel.SelectedReferenceQuantityValue.Scale = new OrdinalScale();
+ this.viewModel.SelectedScaleValueDefinitions = [new ScaleValueDefinition()];
+ this.viewModel.SelectedMappingToReferenceScale = [new MappingToReferenceScale()];
+ Assert.That(((LogarithmicScale)this.viewModel.Thing).ReferenceQuantityValue, Has.Count.EqualTo(0));
+
+ await this.viewModel.CreateOrEditMeasurementScale(true);
+
+ Assert.Multiple(() =>
+ {
+ this.sessionService.Verify(x => x.CreateOrUpdateThings(It.IsAny(), It.IsAny>()), Times.Once);
+ Assert.That(((LogarithmicScale)this.viewModel.Thing).ReferenceQuantityValue, Has.Count.EqualTo(1));
+ });
+
+ this.viewModel.SelectedReferenceQuantityValue.Value = string.Empty;
+ await this.viewModel.CreateOrEditMeasurementScale(true);
+
+ Assert.Multiple(() =>
+ {
+ this.sessionService.Verify(x => x.CreateOrUpdateThings(It.IsAny(), It.IsAny>()), Times.Exactly(2));
+ Assert.That(((LogarithmicScale)this.viewModel.Thing).ReferenceQuantityValue, Has.Count.EqualTo(0));
+ });
+
+ ((LogarithmicScale)this.viewModel.Thing).ReferenceQuantityValue.Add(new ScaleReferenceQuantityValue { Value = "val" });
+ this.viewModel.SelectedReferenceQuantityValue.Value = "value";
+ this.viewModel.SelectedReferenceQuantityValue.Scale = new OrdinalScale();
+ await this.viewModel.CreateOrEditMeasurementScale(true);
+
+ Assert.Multiple(() =>
+ {
+ this.sessionService.Verify(x => x.CreateOrUpdateThings(It.IsAny(), It.IsAny>()), Times.Exactly(3));
+ Assert.That(((LogarithmicScale)this.viewModel.Thing).ReferenceQuantityValue, Has.Count.EqualTo(1));
});
}
@@ -139,6 +212,76 @@ public void VerifyMeasurementScaleRowProperties()
});
}
+ [Test]
+ public void VerifyMeasurementScaleSelection()
+ {
+ this.viewModel.InitializeViewModel();
+ this.viewModel.SelectedMeasurementScaleType = new ClassKindWrapper(ClassKind.OrdinalScale);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.viewModel.Thing, Is.TypeOf());
+ Assert.That(this.viewModel.SelectedMeasurementScaleType.ClassKind, Is.EqualTo(ClassKind.OrdinalScale));
+ });
+
+ this.viewModel.SelectedMeasurementScaleType = new ClassKindWrapper(ClassKind.CyclicRatioScale);
+ Assert.That(this.viewModel.Thing, Is.TypeOf());
+
+ this.viewModel.SelectedMeasurementScaleType = new ClassKindWrapper(ClassKind.IntervalScale);
+ Assert.That(this.viewModel.Thing, Is.TypeOf());
+
+ this.viewModel.SelectedMeasurementScaleType = new ClassKindWrapper(ClassKind.RatioScale);
+ Assert.That(this.viewModel.Thing, Is.TypeOf());
+
+ this.viewModel.SelectedMeasurementScaleType = new ClassKindWrapper(ClassKind.LogarithmicScale);
+ Assert.That(this.viewModel.Thing, Is.TypeOf());
+
+ this.viewModel.SelectedMeasurementScaleType = new ClassKindWrapper(ClassKind.SimpleUnit);
+ Assert.That(this.viewModel.Thing, Is.TypeOf());
+
+ var measurementScaleToSet = new LogarithmicScale();
+ this.viewModel.SelectMeasurementScale(measurementScaleToSet);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.viewModel.Thing, Is.EqualTo(measurementScaleToSet));
+ Assert.That(this.viewModel.SelectedScaleValueDefinitions, Is.EqualTo(measurementScaleToSet.ValueDefinition));
+ Assert.That(this.viewModel.SelectedMappingToReferenceScale, Is.EqualTo(measurementScaleToSet.MappingToReferenceScale));
+ });
+ }
+
+ [Test]
+ public async Task VerifyRowOperations()
+ {
+ this.viewModel.InitializeViewModel();
+ var measurementScaleRow = this.viewModel.Rows.Items.First();
+ measurementScaleRow.IsDeprecated = false;
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(measurementScaleRow, Is.Not.Null);
+ Assert.That(this.viewModel.IsOnDeprecationMode, Is.EqualTo(false));
+ });
+
+ this.viewModel.OnDeprecateUnDeprecateButtonClick(measurementScaleRow);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(this.viewModel.IsOnDeprecationMode, Is.EqualTo(true));
+ Assert.That(this.viewModel.Thing, Is.EqualTo(measurementScaleRow.Thing));
+ });
+
+ this.viewModel.OnCancelPopupButtonClick();
+ Assert.That(this.viewModel.IsOnDeprecationMode, Is.EqualTo(false));
+
+ await this.viewModel.OnConfirmPopupButtonClick();
+ this.sessionService.Verify(x => x.CreateOrUpdateThings(It.IsAny(), It.Is>(c => ((IDeprecatableThing)c.First()).IsDeprecated == true)));
+
+ this.viewModel.Thing.IsDeprecated = true;
+ await this.viewModel.OnConfirmPopupButtonClick();
+ this.sessionService.Verify(x => x.CreateOrUpdateThings(It.IsAny(), It.Is>(c => ((IDeprecatableThing)c.First()).IsDeprecated == false)));
+ }
+
[Test]
public void VerifySessionRefresh()
{
@@ -147,16 +290,16 @@ public void VerifySessionRefresh()
this.messageBus.SendMessage(SessionServiceEvent.SessionRefreshed, this.sessionService.Object.Session);
Assert.That(this.viewModel.Rows, Has.Count.EqualTo(1));
- var siteReferenceDataLibrary = new SiteReferenceDataLibrary()
+ var siteReferenceDataLibrary = new SiteReferenceDataLibrary
{
ShortName = "newShortname"
};
- var scaleTest = new OrdinalScale()
+ var scaleTest = new OrdinalScale
{
Iid = Guid.NewGuid(),
Container = siteReferenceDataLibrary,
- Unit = new SimpleUnit() { ShortName = "newSimpleUnit" },
+ Unit = new SimpleUnit { ShortName = "newSimpleUnit" },
NumberSet = NumberSetKind.INTEGER_NUMBER_SET
};
@@ -181,37 +324,5 @@ public void VerifySessionRefresh()
this.permissionService.Verify(x => x.CanWrite(scaleTest.ClassKind, It.IsAny()), Times.AtLeast(this.viewModel.Rows.Count));
});
}
-
- [Test]
- public async Task VerifyRowOperations()
- {
- this.viewModel.InitializeViewModel();
- var measurementScaleRow = this.viewModel.Rows.Items.First();
- measurementScaleRow.IsDeprecated = false;
-
- Assert.Multiple(() =>
- {
- Assert.That(measurementScaleRow, Is.Not.Null);
- Assert.That(this.viewModel.IsOnDeprecationMode, Is.EqualTo(false));
- });
-
- this.viewModel.OnDeprecateUnDeprecateButtonClick(measurementScaleRow);
-
- Assert.Multiple(() =>
- {
- Assert.That(this.viewModel.IsOnDeprecationMode, Is.EqualTo(true));
- Assert.That(this.viewModel.Thing, Is.EqualTo(measurementScaleRow.Thing));
- });
-
- this.viewModel.OnCancelPopupButtonClick();
- Assert.That(this.viewModel.IsOnDeprecationMode, Is.EqualTo(false));
-
- await this.viewModel.OnConfirmPopupButtonClick();
- this.sessionService.Verify(x => x.CreateOrUpdateThings(It.IsAny(), It.Is>(c => ((IDeprecatableThing)c.First()).IsDeprecated == true)));
-
- this.viewModel.Thing.IsDeprecated = true;
- await this.viewModel.OnConfirmPopupButtonClick();
- this.sessionService.Verify(x => x.CreateOrUpdateThings(It.IsAny(), It.Is>(c => ((IDeprecatableThing)c.First()).IsDeprecated == false)));
- }
}
}
diff --git a/COMETwebapp.Tests/ViewModels/Components/ReferenceData/MeasurementUnitsTableViewModelTestFixture.cs b/COMETwebapp.Tests/ViewModels/Components/ReferenceData/MeasurementUnitsTableViewModelTestFixture.cs
index 057ee0c6..8745a281 100644
--- a/COMETwebapp.Tests/ViewModels/Components/ReferenceData/MeasurementUnitsTableViewModelTestFixture.cs
+++ b/COMETwebapp.Tests/ViewModels/Components/ReferenceData/MeasurementUnitsTableViewModelTestFixture.cs
@@ -34,7 +34,6 @@ namespace COMETwebapp.Tests.ViewModels.Components.ReferenceData
using CDP4Web.Enumerations;
- using COMET.Web.Common.Enumerations;
using COMET.Web.Common.Services.SessionManagement;
using COMETwebapp.Services.ShowHideDeprecatedThingsService;
diff --git a/COMETwebapp/Components/Common/SelectedDataItemBase.razor.cs b/COMETwebapp/Components/Common/SelectedDataItemBase.razor.cs
index c714da11..d27accd2 100644
--- a/COMETwebapp/Components/Common/SelectedDataItemBase.razor.cs
+++ b/COMETwebapp/Components/Common/SelectedDataItemBase.razor.cs
@@ -31,9 +31,7 @@ namespace COMETwebapp.Components.Common
using COMETwebapp.ViewModels.Components.Common.BaseDataItemTable;
using COMETwebapp.ViewModels.Components.Common.Rows;
-
using DevExpress.Blazor;
-
using DynamicData;
using ReactiveUI;
@@ -92,5 +90,14 @@ protected virtual Task OnEditThingSaving()
{
return Task.CompletedTask;
}
+
+ ///
+ /// Method invoked every time a row is selected
+ ///
+ /// The selected row
+ protected virtual void OnSelectedDataItemChanged(TRow row)
+ {
+ this.IsOnEditMode = true;
+ }
}
}
diff --git a/COMETwebapp/Components/EngineeringModel/CommonFileStoresTable.razor.cs b/COMETwebapp/Components/EngineeringModel/CommonFileStoresTable.razor.cs
index b486fe27..c796b3d1 100644
--- a/COMETwebapp/Components/EngineeringModel/CommonFileStoresTable.razor.cs
+++ b/COMETwebapp/Components/EngineeringModel/CommonFileStoresTable.razor.cs
@@ -80,10 +80,10 @@ protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
/// Method invoked every time a row is selected
///
/// The selected row
- private void OnSelectedDataItemChanged(CommonFileStoreRowViewModel row)
+ protected override void OnSelectedDataItemChanged(CommonFileStoreRowViewModel row)
{
+ base.OnSelectedDataItemChanged(row);
this.ViewModel.Thing = row.Thing.Clone(true);
- this.IsOnEditMode = true;
}
///
diff --git a/COMETwebapp/Components/EngineeringModel/OptionsTable.razor.cs b/COMETwebapp/Components/EngineeringModel/OptionsTable.razor.cs
index 9692bbe2..a9777b53 100644
--- a/COMETwebapp/Components/EngineeringModel/OptionsTable.razor.cs
+++ b/COMETwebapp/Components/EngineeringModel/OptionsTable.razor.cs
@@ -75,10 +75,10 @@ protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
/// Method invoked every time a row is selected
///
/// The selected row
- private void OnSelectedDataItemChanged(OptionRowViewModel row)
+ protected override void OnSelectedDataItemChanged(OptionRowViewModel row)
{
+ base.OnSelectedDataItemChanged(row);
this.ViewModel.SetCurrentOption(row.Thing);
- this.IsOnEditMode = true;
}
///
diff --git a/COMETwebapp/Components/EngineeringModel/PublicationsTable.razor.cs b/COMETwebapp/Components/EngineeringModel/PublicationsTable.razor.cs
index 6cf91a71..6631a7f3 100644
--- a/COMETwebapp/Components/EngineeringModel/PublicationsTable.razor.cs
+++ b/COMETwebapp/Components/EngineeringModel/PublicationsTable.razor.cs
@@ -70,10 +70,10 @@ protected override void OnInitialized()
/// Method invoked every time a row is selected
///
/// The selected row
- private void OnSelectedDataItemChanged(PublicationRowViewModel row)
+ protected override void OnSelectedDataItemChanged(PublicationRowViewModel row)
{
+ base.OnSelectedDataItemChanged(row);
this.SelectedRow = row;
- this.IsOnEditMode = true;
}
///
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTable.razor b/COMETwebapp/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTable.razor
new file mode 100644
index 00000000..e955bbec
--- /dev/null
+++ b/COMETwebapp/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTable.razor
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @{
+ var row = (MappingToReferenceScaleRowViewModel)context.DataItem;
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTable.razor.cs b/COMETwebapp/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTable.razor.cs
new file mode 100644
index 00000000..325862a5
--- /dev/null
+++ b/COMETwebapp/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTable.razor.cs
@@ -0,0 +1,138 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Components.ReferenceData.MeasurementScales
+{
+ using CDP4Common.SiteDirectoryData;
+
+ using COMETwebapp.ViewModels.Components.ReferenceData.Rows;
+
+ using DevExpress.Blazor;
+
+ using Microsoft.AspNetCore.Components;
+
+ ///
+ /// Support class for the
+ ///
+ public partial class MappingToReferenceScalesTable
+ {
+ ///
+ /// A collection of mapping to reference scale to display for selection
+ ///
+ [Parameter]
+ public IEnumerable MappingToReferenceScales { get; set; }
+
+ ///
+ /// The method that is executed when the mapping to reference scales change
+ ///
+ [Parameter]
+ public EventCallback> MappingToReferenceScalesChanged { get; set; }
+
+ ///
+ /// A collection of dependent scale value definitions to display for selection
+ ///
+ [Parameter]
+ public IEnumerable DependentScaleValueDefinitions { get; set; }
+
+ ///
+ /// A collection of reference scale value definitions to display for selection
+ ///
+ [Parameter]
+ public IEnumerable ReferenceScaleValueDefinitions { get; set; }
+
+ ///
+ /// Gets or sets the condition to check if a mapping to reference scale should be created
+ ///
+ public bool ShouldCreate { get; private set; }
+
+ ///
+ /// The mapping to reference scale that will be handled for both edit and add forms
+ ///
+ private MappingToReferenceScale MappingToReferenceScale { get; set; } = new();
+
+ ///
+ /// Gets or sets the grid control that is being customized.
+ ///
+ private IGrid Grid { get; set; }
+
+ ///
+ /// Method that is invoked when the edit/add mapping to reference scale form is being saved
+ ///
+ private void OnEditMappingToReferenceScaleSaving()
+ {
+ var mappingToReferenceScalesList = this.MappingToReferenceScales.ToList();
+
+ if (this.ShouldCreate)
+ {
+ mappingToReferenceScalesList.Add(this.MappingToReferenceScale);
+ this.MappingToReferenceScales = mappingToReferenceScalesList;
+ }
+ else
+ {
+ var indexToUpdate = mappingToReferenceScalesList.FindIndex(x => x.Iid == this.MappingToReferenceScale.Iid);
+ mappingToReferenceScalesList[indexToUpdate] = this.MappingToReferenceScale;
+ }
+
+ this.MappingToReferenceScales = mappingToReferenceScalesList;
+ this.MappingToReferenceScalesChanged.InvokeAsync(this.MappingToReferenceScales);
+ }
+
+ ///
+ /// Method that is invoked when a mapping to reference scale row is being removed
+ ///
+ private void RemoveMappingToReferenceScale(MappingToReferenceScaleRowViewModel row)
+ {
+ var mappingToReferenceScalesList = this.MappingToReferenceScales.ToList();
+ mappingToReferenceScalesList.Remove(row.MappingToReferenceScale);
+
+ this.MappingToReferenceScales = mappingToReferenceScalesList;
+ this.MappingToReferenceScalesChanged.InvokeAsync(this.MappingToReferenceScales);
+ }
+
+ ///
+ /// Method invoked when creating a new Mapping To Reference Scale
+ ///
+ /// A
+ private void CustomizeEditMappingToReferenceScale(GridCustomizeEditModelEventArgs e)
+ {
+ var dataItem = (MappingToReferenceScaleRowViewModel)e.DataItem;
+ this.ShouldCreate = e.IsNew;
+
+ this.MappingToReferenceScale = dataItem == null
+ ? new MappingToReferenceScale { Iid = Guid.NewGuid() }
+ : dataItem.MappingToReferenceScale.Clone(true);
+
+ e.EditModel = this.MappingToReferenceScale;
+ }
+
+ ///
+ /// Method used to retrieve the available rows, given the
+ ///
+ /// A collection of s to display
+ private List GetRows()
+ {
+ return this.MappingToReferenceScales?.Select(x => new MappingToReferenceScaleRowViewModel(x)).ToList();
+ }
+ }
+}
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesForm.razor b/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesForm.razor
new file mode 100644
index 00000000..b6aa4d6a
--- /dev/null
+++ b/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesForm.razor
@@ -0,0 +1,165 @@
+
+
+@using COMETwebapp.Wrappers
+@inherits SelectedDataItemForm
+
+
+
+
+
+
+ @if (this.ShouldCreate)
+ {
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @if (this.ViewModel.Thing is CyclicRatioScale ciclicRatioScale)
+ {
+
+
+
+ }
+
+ @if (this.ViewModel.Thing is OrdinalScale ordinalScale)
+ {
+
+
+
+ }
+
+
+
+
+
+
+ @if (this.ViewModel.Thing is LogarithmicScale logarithmicScale)
+ {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Clear
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Save
+
+
+
+ Cancel
+
+
+
\ No newline at end of file
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesForm.razor.cs b/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesForm.razor.cs
new file mode 100644
index 00000000..aa260165
--- /dev/null
+++ b/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesForm.razor.cs
@@ -0,0 +1,66 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Components.ReferenceData.MeasurementScales
+{
+ using System.ComponentModel.DataAnnotations;
+
+ using CDP4Common.SiteDirectoryData;
+
+ using COMETwebapp.Components.Common;
+ using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales;
+
+ using Microsoft.AspNetCore.Components;
+
+ ///
+ /// Support class for the
+ ///
+ public partial class MeasurementScalesForm : SelectedDataItemForm
+ {
+ ///
+ /// The for this component
+ ///
+ [Parameter]
+ [Required]
+ public IMeasurementScalesTableViewModel ViewModel { get; set; }
+
+ ///
+ /// Method that is executed when there is a valid submit
+ ///
+ /// A
+ protected override async Task OnValidSubmit()
+ {
+ await this.ViewModel.CreateOrEditMeasurementScale(this.ShouldCreate);
+ await base.OnValidSubmit();
+ }
+
+ ///
+ /// Clear the selected reference quantity value
+ ///
+ private void ClearReferenceQuantityValue()
+ {
+ this.ViewModel.SelectedReferenceQuantityValue = new ScaleReferenceQuantityValue();
+ }
+ }
+}
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesTable.razor b/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesTable.razor
new file mode 100644
index 00000000..ac23655a
--- /dev/null
+++ b/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesTable.razor
@@ -0,0 +1,93 @@
+
+
+@inherits SelectedDeprecatableDataItemBase
+
+
+
+
\ No newline at end of file
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesTable.razor.cs b/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesTable.razor.cs
new file mode 100644
index 00000000..e0fbc494
--- /dev/null
+++ b/COMETwebapp/Components/ReferenceData/MeasurementScales/MeasurementScalesTable.razor.cs
@@ -0,0 +1,96 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Components.ReferenceData.MeasurementScales
+{
+ using CDP4Common.CommonData;
+ using CDP4Common.SiteDirectoryData;
+
+ using COMETwebapp.Components.Common;
+ using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales;
+ using COMETwebapp.ViewModels.Components.ReferenceData.Rows;
+
+ using DevExpress.Blazor;
+
+ using Microsoft.AspNetCore.Components;
+
+ ///
+ /// Support class for the
+ ///
+ public partial class MeasurementScalesTable : SelectedDeprecatableDataItemBase
+ {
+ ///
+ /// The for this component
+ ///
+ [Inject]
+ public IMeasurementScalesTableViewModel ViewModel { get; set; }
+
+ ///
+ /// Method invoked when the component is ready to start, having received its
+ /// initial parameters from its parent in the render tree.
+ ///
+ protected override void OnInitialized()
+ {
+ base.OnInitialized();
+ this.Initialize(this.ViewModel);
+ }
+
+ ///
+ /// Method that is invoked when the edit/add thing form is being saved
+ ///
+ /// A
+ protected override async Task OnEditThingSaving()
+ {
+ await this.ViewModel.CreateOrEditMeasurementScale(this.ShouldCreateThing);
+ }
+
+ ///
+ /// Method invoked when creating a new thing
+ ///
+ /// A
+ protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
+ {
+ var dataItem = (MeasurementScaleRowViewModel)e.DataItem;
+ this.ShouldCreateThing = e.IsNew;
+
+ if (this.ShouldCreateThing)
+ {
+ this.ViewModel.SelectedMeasurementScaleType = this.ViewModel.MeasurementScaleTypes.First(x => x.ClassKind == ClassKind.CyclicRatioScale);
+ }
+
+ this.ViewModel.SelectMeasurementScale(dataItem == null ? new CyclicRatioScale() : dataItem.Thing.Clone(true));
+ e.EditModel = this.ViewModel.Thing;
+ }
+
+ ///
+ /// Method invoked every time a row is selected
+ ///
+ /// The selected row
+ protected override void OnSelectedDataItemChanged(MeasurementScaleRowViewModel row)
+ {
+ base.OnSelectedDataItemChanged(row);
+ this.ViewModel.SelectMeasurementScale(row.Thing.Clone(true));
+ }
+ }
+}
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScales/ScaleValueDefinitionsTable.razor b/COMETwebapp/Components/ReferenceData/MeasurementScales/ScaleValueDefinitionsTable.razor
new file mode 100644
index 00000000..4a35ea38
--- /dev/null
+++ b/COMETwebapp/Components/ReferenceData/MeasurementScales/ScaleValueDefinitionsTable.razor
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ @{
+ var row = (ScaleValueDefinitionRowViewModel)context.DataItem;
+
+
+
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScales/ScaleValueDefinitionsTable.razor.cs b/COMETwebapp/Components/ReferenceData/MeasurementScales/ScaleValueDefinitionsTable.razor.cs
new file mode 100644
index 00000000..311cc33d
--- /dev/null
+++ b/COMETwebapp/Components/ReferenceData/MeasurementScales/ScaleValueDefinitionsTable.razor.cs
@@ -0,0 +1,126 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Components.ReferenceData.MeasurementScales
+{
+ using CDP4Common.SiteDirectoryData;
+
+ using COMETwebapp.ViewModels.Components.ReferenceData.Rows;
+
+ using DevExpress.Blazor;
+
+ using Microsoft.AspNetCore.Components;
+
+ ///
+ /// Support class for the
+ ///
+ public partial class ScaleValueDefinitionsTable
+ {
+ ///
+ /// A collection of scale value definitions to display for selection
+ ///
+ [Parameter]
+ public IEnumerable ScaleValueDefinitions { get; set; }
+
+ ///
+ /// The method that is executed when the scale value definitions change
+ ///
+ [Parameter]
+ public EventCallback> ScaleValueDefinitionsChanged { get; set; }
+
+ ///
+ /// Gets or sets the condition to check if a scale value definition should be created
+ ///
+ public bool ShouldCreate { get; private set; }
+
+ ///
+ /// The scale value definition that will be handled for both edit and add forms
+ ///
+ public ScaleValueDefinition ScaleValueDefinition { get; private set; } = new();
+
+ ///
+ /// Gets or sets the grid control that is being customized.
+ ///
+ private IGrid Grid { get; set; }
+
+ ///
+ /// Method that is invoked when the edit/add scale value definition form is being saved
+ ///
+ private void OnEditScaleValueDefinitionSaving()
+ {
+ var valueDefinitionsList = this.ScaleValueDefinitions.ToList();
+
+ if (this.ShouldCreate)
+ {
+ valueDefinitionsList.Add(this.ScaleValueDefinition);
+ this.ScaleValueDefinitions = valueDefinitionsList;
+ }
+ else
+ {
+ var indexToUpdate = valueDefinitionsList.FindIndex(x => x.Iid == this.ScaleValueDefinition.Iid);
+ valueDefinitionsList[indexToUpdate] = this.ScaleValueDefinition;
+ }
+
+ this.ScaleValueDefinitions = valueDefinitionsList;
+ this.ScaleValueDefinitionsChanged.InvokeAsync(this.ScaleValueDefinitions);
+ }
+
+ ///
+ /// Method that is invoked when a scale value definition row is being removed
+ ///
+ private void RemoveScaleValueDefinition(ScaleValueDefinitionRowViewModel row)
+ {
+ var valueDefinitionsList = this.ScaleValueDefinitions.ToList();
+ valueDefinitionsList.Remove(row.Thing);
+
+ this.ScaleValueDefinitions = valueDefinitionsList;
+ this.ScaleValueDefinitionsChanged.InvokeAsync(this.ScaleValueDefinitions);
+ }
+
+ ///
+ /// Method invoked when creating a new scale value definition
+ ///
+ /// A
+ private void CustomizeEditScaleValueDefinition(GridCustomizeEditModelEventArgs e)
+ {
+ var dataItem = (ScaleValueDefinitionRowViewModel)e.DataItem;
+ this.ShouldCreate = e.IsNew;
+
+ this.ScaleValueDefinition = dataItem == null
+ ? new ScaleValueDefinition { Iid = Guid.NewGuid() }
+ : dataItem.Thing.Clone(true);
+
+ e.EditModel = this.ScaleValueDefinition;
+ }
+
+ ///
+ /// Method used to retrieve the available rows, given the
+ ///
+ /// A collection of s to display
+ private List GetRows()
+ {
+ return this.ScaleValueDefinitions?.Select(x => new ScaleValueDefinitionRowViewModel(x)).ToList();
+ }
+ }
+}
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScalesTable.razor b/COMETwebapp/Components/ReferenceData/MeasurementScalesTable.razor
deleted file mode 100644
index 20e18865..00000000
--- a/COMETwebapp/Components/ReferenceData/MeasurementScalesTable.razor
+++ /dev/null
@@ -1,118 +0,0 @@
-
-@using COMETwebapp.ViewModels.Components.ReferenceData.Rows
-@using CDP4Common.SiteDirectoryData
-@inherits COMETwebapp.Components.Common.SelectedDeprecatableDataItemBase
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @{
- var row = (MeasurementScaleRowViewModel)context.DataItem;
-
-
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @this.ViewModel.PopupDialog
-
-
-
-
-
\ No newline at end of file
diff --git a/COMETwebapp/Components/ReferenceData/MeasurementScalesTable.razor.cs b/COMETwebapp/Components/ReferenceData/MeasurementScalesTable.razor.cs
deleted file mode 100644
index 7fb378c7..00000000
--- a/COMETwebapp/Components/ReferenceData/MeasurementScalesTable.razor.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-//
-// Copyright (c) 2023-2024 RHEA System S.A.
-//
-// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
-//
-// This file is part of CDP4-COMET WEB Community Edition
-// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
-//
-// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Affero 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-COMET WEB 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
-// Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see .
-//
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace COMETwebapp.Components.ReferenceData
-{
- using System.Threading.Tasks;
-
- using CDP4Common.SiteDirectoryData;
-
- using COMETwebapp.Components.Common;
- using COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales;
- using COMETwebapp.ViewModels.Components.ReferenceData.Rows;
-
- using DevExpress.Blazor;
-
- using Microsoft.AspNetCore.Components;
-
- ///
- /// Support class for the
- ///
- public partial class MeasurementScalesTable : SelectedDeprecatableDataItemBase
- {
- ///
- /// The for this component
- ///
- [Inject]
- public IMeasurementScalesTableViewModel ViewModel { get; set; }
-
- ///
- /// Method invoked when the component is ready to start, having received its
- /// initial parameters from its parent in the render tree.
- ///
- protected override void OnInitialized()
- {
- base.OnInitialized();
- this.Initialize(this.ViewModel);
- }
-
- ///
- /// Method that is invoked when the edit/add thing form is being saved
- ///
- /// A
- protected override Task OnEditThingSaving()
- {
- if (!this.ShouldCreateThing)
- {
- // update measurement scale
- }
-
- // create measurement scale
- return Task.CompletedTask;
- }
-
- ///
- /// Method invoked when creating a new thing
- ///
- /// A
- protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
- {
- var dataItem = (MeasurementScaleRowViewModel)e.DataItem;
- this.ShouldCreateThing = e.IsNew;
-
- if (dataItem == null)
- {
- e.EditModel = new OrdinalScale();
- this.ViewModel.Thing = new OrdinalScale();
- return;
- }
-
- e.EditModel = dataItem;
- this.ViewModel.Thing = dataItem.Thing.Clone(true);
- }
- }
-}
diff --git a/COMETwebapp/Components/SiteDirectory/DomainsOfExpertiseTable.razor b/COMETwebapp/Components/SiteDirectory/DomainsOfExpertiseTable.razor
index 661b78b1..9e47a441 100644
--- a/COMETwebapp/Components/SiteDirectory/DomainsOfExpertiseTable.razor
+++ b/COMETwebapp/Components/SiteDirectory/DomainsOfExpertiseTable.razor
@@ -14,7 +14,6 @@ Copyright (c) 2023-2024 RHEA System S.A.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
------------------------------------------------------------------------------->
-@using COMETwebapp.ViewModels.Components.SiteDirectory.Rows
@inherits COMETwebapp.Components.Common.SelectedDeprecatableDataItemBase
diff --git a/COMETwebapp/Components/SiteDirectory/DomainsOfExpertiseTable.razor.cs b/COMETwebapp/Components/SiteDirectory/DomainsOfExpertiseTable.razor.cs
index c050b2fd..c0b7a19a 100644
--- a/COMETwebapp/Components/SiteDirectory/DomainsOfExpertiseTable.razor.cs
+++ b/COMETwebapp/Components/SiteDirectory/DomainsOfExpertiseTable.razor.cs
@@ -82,7 +82,7 @@ protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
/// Method invoked every time a row is selected
///
/// The selected row
- private void OnSelectedDataItemChanged(DomainOfExpertiseRowViewModel row)
+ protected override void OnSelectedDataItemChanged(DomainOfExpertiseRowViewModel row)
{
this.ViewModel.Thing = row.Thing.Clone(true);
this.IsOnEditMode = true;
diff --git a/COMETwebapp/Components/SiteDirectory/EngineeringModel/EngineeringModelsTable.razor.cs b/COMETwebapp/Components/SiteDirectory/EngineeringModel/EngineeringModelsTable.razor.cs
index 2a1ea2b8..01b6b189 100644
--- a/COMETwebapp/Components/SiteDirectory/EngineeringModel/EngineeringModelsTable.razor.cs
+++ b/COMETwebapp/Components/SiteDirectory/EngineeringModel/EngineeringModelsTable.razor.cs
@@ -108,10 +108,10 @@ protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
/// Metgid invoked everytime a row is selected
///
/// The selected row
- private void OnSelectedDataItemChanged(EngineeringModelRowViewModel row)
+ protected override void OnSelectedDataItemChanged(EngineeringModelRowViewModel row)
{
+ base.OnSelectedDataItemChanged(row);
this.ViewModel.Thing = row.Thing;
- this.IsOnEditMode = true;
this.parameters[nameof(EngineeringModelSetup)] = row.Thing;
}
diff --git a/COMETwebapp/Components/SiteDirectory/OrganizationsTable.razor.cs b/COMETwebapp/Components/SiteDirectory/OrganizationsTable.razor.cs
index 0486aada..f1aa8e8f 100644
--- a/COMETwebapp/Components/SiteDirectory/OrganizationsTable.razor.cs
+++ b/COMETwebapp/Components/SiteDirectory/OrganizationsTable.razor.cs
@@ -73,10 +73,10 @@ protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
/// Method invoked every time a row is selected
///
/// The selected row
- private void OnSelectedDataItemChanged(OrganizationRowViewModel row)
+ protected override void OnSelectedDataItemChanged(OrganizationRowViewModel row)
{
+ base.OnSelectedDataItemChanged(row);
this.ViewModel.Thing = row.Thing.Clone(true);
- this.IsOnEditMode = true;
}
}
}
diff --git a/COMETwebapp/Components/SiteDirectory/Roles/ParticipantRolesTable.razor.cs b/COMETwebapp/Components/SiteDirectory/Roles/ParticipantRolesTable.razor.cs
index 55cd555b..4b13c8d2 100644
--- a/COMETwebapp/Components/SiteDirectory/Roles/ParticipantRolesTable.razor.cs
+++ b/COMETwebapp/Components/SiteDirectory/Roles/ParticipantRolesTable.razor.cs
@@ -80,10 +80,10 @@ protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
/// Method invoked everytime a row is selected
///
/// The selected row
- private void OnSelectedDataItemChanged(ParticipantRoleRowViewModel row)
+ protected override void OnSelectedDataItemChanged(ParticipantRoleRowViewModel row)
{
+ base.OnSelectedDataItemChanged(row);
this.ViewModel.Thing = row.Thing.Clone(true);
- this.IsOnEditMode = true;
}
}
}
diff --git a/COMETwebapp/Components/SiteDirectory/Roles/PersonRolesTable.razor.cs b/COMETwebapp/Components/SiteDirectory/Roles/PersonRolesTable.razor.cs
index fbe664d1..e3370673 100644
--- a/COMETwebapp/Components/SiteDirectory/Roles/PersonRolesTable.razor.cs
+++ b/COMETwebapp/Components/SiteDirectory/Roles/PersonRolesTable.razor.cs
@@ -80,10 +80,10 @@ protected override void CustomizeEditThing(GridCustomizeEditModelEventArgs e)
/// Method invoked everytime a row is selected
///
/// The selected row
- private void OnSelectedDataItemChanged(PersonRoleRowViewModel row)
+ protected override void OnSelectedDataItemChanged(PersonRoleRowViewModel row)
{
+ base.OnSelectedDataItemChanged(row);
this.ViewModel.Thing = row.Thing.Clone(true);
- this.IsOnEditMode = true;
}
}
}
diff --git a/COMETwebapp/Pages/ReferenceData/ReferenceDataPage.razor.cs b/COMETwebapp/Pages/ReferenceData/ReferenceDataPage.razor.cs
index 47a1059e..20521d60 100644
--- a/COMETwebapp/Pages/ReferenceData/ReferenceDataPage.razor.cs
+++ b/COMETwebapp/Pages/ReferenceData/ReferenceDataPage.razor.cs
@@ -25,6 +25,7 @@
namespace COMETwebapp.Pages.ReferenceData
{
using COMETwebapp.Components.ReferenceData;
+ using COMETwebapp.Components.ReferenceData.MeasurementScales;
using DevExpress.Blazor;
diff --git a/COMETwebapp/Validators/ReferenceData/MeasurementScales/CyclicRatioScaleValidator.cs b/COMETwebapp/Validators/ReferenceData/MeasurementScales/CyclicRatioScaleValidator.cs
new file mode 100644
index 00000000..c812476d
--- /dev/null
+++ b/COMETwebapp/Validators/ReferenceData/MeasurementScales/CyclicRatioScaleValidator.cs
@@ -0,0 +1,48 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Validators.ReferenceData.MeasurementScales
+{
+ using CDP4Common.SiteDirectoryData;
+ using CDP4Common.Validation;
+
+ using COMET.Web.Common.Extensions;
+
+ using FluentValidation;
+
+ ///
+ /// A class to validate the
+ ///
+ public class CyclicRatioScaleValidator : AbstractValidator
+ {
+ ///
+ /// Instantiates a new
+ ///
+ public CyclicRatioScaleValidator(IValidationService validationService)
+ {
+ this.Include(new MeasurementScaleValidator(validationService));
+ this.RuleFor(x => x.Modulus).NotEmpty().Validate(validationService, nameof(CyclicRatioScale.Modulus));
+ }
+ }
+}
diff --git a/COMETwebapp/Validators/ReferenceData/MeasurementScales/LogarithmicScaleValidator.cs b/COMETwebapp/Validators/ReferenceData/MeasurementScales/LogarithmicScaleValidator.cs
new file mode 100644
index 00000000..d50b2912
--- /dev/null
+++ b/COMETwebapp/Validators/ReferenceData/MeasurementScales/LogarithmicScaleValidator.cs
@@ -0,0 +1,51 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Validators.ReferenceData.MeasurementScales
+{
+ using CDP4Common.SiteDirectoryData;
+ using CDP4Common.Validation;
+
+ using COMET.Web.Common.Extensions;
+
+ using FluentValidation;
+
+ ///
+ /// A class to validate the
+ ///
+ public class LogarithmicScaleValidator : AbstractValidator
+ {
+ ///
+ /// Instantiates a new
+ ///
+ public LogarithmicScaleValidator(IValidationService validationService)
+ {
+ this.Include(new MeasurementScaleValidator(validationService));
+ this.RuleFor(x => x.LogarithmBase).Validate(validationService, nameof(LogarithmicScale.LogarithmBase));
+ this.RuleFor(x => x.Factor).Validate(validationService, nameof(LogarithmicScale.Factor));
+ this.RuleFor(x => x.Exponent).Validate(validationService, nameof(LogarithmicScale.Exponent));
+ this.RuleFor(x => x.ReferenceQuantityKind).Validate(validationService, nameof(LogarithmicScale.ReferenceQuantityKind));
+ }
+ }
+}
diff --git a/COMETwebapp/Validators/ReferenceData/MeasurementScales/MeasurementScaleValidator.cs b/COMETwebapp/Validators/ReferenceData/MeasurementScales/MeasurementScaleValidator.cs
new file mode 100644
index 00000000..ee74a6bd
--- /dev/null
+++ b/COMETwebapp/Validators/ReferenceData/MeasurementScales/MeasurementScaleValidator.cs
@@ -0,0 +1,56 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Validators.ReferenceData.MeasurementScales
+{
+ using CDP4Common.SiteDirectoryData;
+ using CDP4Common.Validation;
+
+ using COMET.Web.Common.Extensions;
+
+ using FluentValidation;
+
+ ///
+ /// A class to validate the
+ ///
+ public class MeasurementScaleValidator : AbstractValidator
+ {
+ ///
+ /// Instantiates a new
+ ///
+ public MeasurementScaleValidator(IValidationService validationService)
+ {
+ this.RuleFor(x => x.ShortName).Validate(validationService, nameof(MeasurementScale.ShortName));
+ this.RuleFor(x => x.Name).Validate(validationService, nameof(MeasurementScale.Name));
+ this.RuleFor(x => x.Unit).Validate(validationService, nameof(MeasurementScale.Unit));
+ this.RuleFor(x => x.NumberSet).Validate(validationService, nameof(MeasurementScale.NumberSet));
+ this.RuleFor(x => x.MaximumPermissibleValue).Validate(validationService, nameof(MeasurementScale.MaximumPermissibleValue));
+ this.RuleFor(x => x.MinimumPermissibleValue).Validate(validationService, nameof(MeasurementScale.MinimumPermissibleValue));
+ this.RuleFor(x => x.PositiveValueConnotation).Validate(validationService, nameof(MeasurementScale.PositiveValueConnotation));
+ this.RuleFor(x => x.NegativeValueConnotation).Validate(validationService, nameof(MeasurementScale.NegativeValueConnotation));
+ this.RuleFor(x => x.IsMaximumInclusive).Validate(validationService, nameof(MeasurementScale.IsMaximumInclusive));
+ this.RuleFor(x => x.IsMinimumInclusive).Validate(validationService, nameof(MeasurementScale.IsMinimumInclusive));
+ }
+ }
+}
diff --git a/COMETwebapp/Validators/ReferenceData/MeasurementScales/OrdinalScaleValidator.cs b/COMETwebapp/Validators/ReferenceData/MeasurementScales/OrdinalScaleValidator.cs
new file mode 100644
index 00000000..e6450c14
--- /dev/null
+++ b/COMETwebapp/Validators/ReferenceData/MeasurementScales/OrdinalScaleValidator.cs
@@ -0,0 +1,48 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.Validators.ReferenceData.MeasurementScales
+{
+ using CDP4Common.SiteDirectoryData;
+ using CDP4Common.Validation;
+
+ using COMET.Web.Common.Extensions;
+
+ using FluentValidation;
+
+ ///
+ /// A class to validate the
+ ///
+ public class OrdinalScaleValidator : AbstractValidator
+ {
+ ///
+ /// Instantiates a new
+ ///
+ public OrdinalScaleValidator(IValidationService validationService)
+ {
+ this.Include(new MeasurementScaleValidator(validationService));
+ this.RuleFor(x => x.UseShortNameValues).NotEmpty().Validate(validationService, nameof(OrdinalScale.UseShortNameValues));
+ }
+ }
+}
diff --git a/COMETwebapp/ViewModels/Components/Common/Rows/BaseDataItemRowViewModel.cs b/COMETwebapp/ViewModels/Components/Common/Rows/BaseDataItemRowViewModel.cs
index d255f865..a2362197 100644
--- a/COMETwebapp/ViewModels/Components/Common/Rows/BaseDataItemRowViewModel.cs
+++ b/COMETwebapp/ViewModels/Components/Common/Rows/BaseDataItemRowViewModel.cs
@@ -57,7 +57,7 @@ protected BaseDataItemRowViewModel(T thing)
this.Thing = thing;
this.ShortName = thing is IShortNamedThing shortNamedThing ? shortNamedThing.ShortName : thing.UserFriendlyShortName;
this.Name = thing is INamedThing namedThing ? namedThing.Name : thing.UserFriendlyName;
- this.ContainerName = thing.Container is IShortNamedThing shortNamedContainer ? shortNamedContainer.ShortName : thing.Container.UserFriendlyShortName;
+ this.ContainerName = thing.Container is IShortNamedThing shortNamedContainer ? shortNamedContainer.ShortName : thing.Container?.UserFriendlyShortName;
}
///
diff --git a/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementScales/IMeasurementScalesTableViewModel.cs b/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementScales/IMeasurementScalesTableViewModel.cs
index c29ac99d..e2895ce5 100644
--- a/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementScales/IMeasurementScalesTableViewModel.cs
+++ b/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementScales/IMeasurementScalesTableViewModel.cs
@@ -1,26 +1,26 @@
// --------------------------------------------------------------------------------------------------------------------
-//
-// Copyright (c) 2023-2024 RHEA System S.A.
-//
-// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
-//
-// This file is part of CDP4-COMET WEB Community Edition
-// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
-//
-// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Affero 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-COMET WEB 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
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
// Affero General Public License for more details.
-//
+//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
-// --------------------------------------------------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------------------------------------------------
namespace COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales
{
@@ -28,6 +28,7 @@ namespace COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales
using COMETwebapp.ViewModels.Components.Common.DeprecatableDataItemTable;
using COMETwebapp.ViewModels.Components.ReferenceData.Rows;
+ using COMETwebapp.Wrappers;
///
/// View model used to manage s
@@ -48,5 +49,68 @@ public interface IMeasurementScalesTableViewModel : IDeprecatableDataItemTableVi
/// Gets the available s
///
IEnumerable NumberSetKinds { get; }
+
+ ///
+ /// Gets the available measurement scale types s
+ ///
+ IEnumerable MeasurementScaleTypes { get; }
+
+ ///
+ /// Gets or sets the selected measurement scale type
+ ///
+ ClassKindWrapper SelectedMeasurementScaleType { get; set; }
+
+ ///
+ /// Gets the selected s
+ ///
+ IEnumerable SelectedScaleValueDefinitions { get; set; }
+
+ ///
+ /// Gets or sets the selected reference data library
+ ///
+ ReferenceDataLibrary SelectedReferenceDataLibrary { get; set; }
+
+ ///
+ /// Gets the selected s
+ ///
+ IEnumerable SelectedMappingToReferenceScale { get; set; }
+
+ ///
+ /// Gets the available s for reference scale value selection
+ ///
+ IEnumerable ReferenceScaleValueDefinitions { get; }
+
+ ///
+ /// Gets the available s
+ ///
+ IEnumerable LogarithmBaseKinds { get; }
+
+ ///
+ /// Gets the available reference s
+ ///
+ IEnumerable ReferenceQuantityKinds { get; }
+
+ ///
+ /// Gets the available s
+ ///
+ IEnumerable MeasurementScales { get; }
+
+ ///
+ /// Gets or sets the selected reference quantity value
+ ///
+ ScaleReferenceQuantityValue SelectedReferenceQuantityValue { get; set; }
+
+ ///
+ /// Selects the current
+ ///
+ /// The measurement scale to be set
+ void SelectMeasurementScale(MeasurementScale measurementScale);
+
+ ///
+ /// Creates or edits a
+ ///
+ /// The value to check if a new should be created
+ /// A
+ Task CreateOrEditMeasurementScale(bool shouldCreate);
}
}
diff --git a/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementScales/MeasurementScalesTableViewModel.cs b/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementScales/MeasurementScalesTableViewModel.cs
index 5ed8089c..96bff8d9 100644
--- a/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementScales/MeasurementScalesTableViewModel.cs
+++ b/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementScales/MeasurementScalesTableViewModel.cs
@@ -1,29 +1,30 @@
// --------------------------------------------------------------------------------------------------------------------
-//
-// Copyright (c) 2023-2024 RHEA System S.A.
-//
-// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
-//
-// This file is part of CDP4-COMET WEB Community Edition
-// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
-//
-// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Affero 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-COMET WEB 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
+//
+// Copyright (c) 2024 Starion Group S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
+//
+// This file is part of COMET WEB Community Edition
+// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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 WEB 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
// Affero General Public License for more details.
-//
+//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-//
-// --------------------------------------------------------------------------------------------------------------------
+//
+// --------------------------------------------------------------------------------------------------------------------
namespace COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales
{
+ using CDP4Common.CommonData;
using CDP4Common.SiteDirectoryData;
using CDP4Dal;
@@ -33,6 +34,11 @@ namespace COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales
using COMETwebapp.Services.ShowHideDeprecatedThingsService;
using COMETwebapp.ViewModels.Components.Common.DeprecatableDataItemTable;
using COMETwebapp.ViewModels.Components.ReferenceData.Rows;
+ using COMETwebapp.Wrappers;
+
+ using DynamicData;
+
+ using ReactiveUI;
using MeasurementScale = CDP4Common.SiteDirectoryData.MeasurementScale;
@@ -41,16 +47,31 @@ namespace COMETwebapp.ViewModels.Components.ReferenceData.MeasurementScales
///
public class MeasurementScalesTableViewModel : DeprecatableDataItemTableViewModel, IMeasurementScalesTableViewModel
{
+ ///
+ /// Gets the available s
+ ///
+ private static readonly IEnumerable AvailableMeasurementScaleTypes =
+ [
+ ClassKind.CyclicRatioScale, ClassKind.IntervalScale, ClassKind.LogarithmicScale, ClassKind.OrdinalScale, ClassKind.RatioScale
+ ];
+
+ ///
+ /// The backing field for
+ ///
+ private ClassKindWrapper selectedMeasurementScaleType;
+
///
/// Initializes a new instance of the class.
///
/// The
/// The
- /// The
- /// The
+ /// The
+ /// The
public MeasurementScalesTableViewModel(ISessionService sessionService, IShowHideDeprecatedThingsService showHideDeprecatedThingsService, ICDPMessageBus messageBus,
ILogger logger) : base(sessionService, messageBus, showHideDeprecatedThingsService, logger)
{
+ this.Thing = new OrdinalScale();
+ this.SelectedReferenceQuantityValue = new ScaleReferenceQuantityValue();
}
///
@@ -58,10 +79,32 @@ public MeasurementScalesTableViewModel(ISessionService sessionService, IShowHide
///
public IEnumerable ReferenceDataLibraries { get; private set; }
+ ///
+ /// Gets the available reference s
+ ///
+ public IEnumerable ReferenceQuantityKinds { get; private set; }
+
+ ///
+ /// Gets the available s for reference scale value selection
+ ///
+ public IEnumerable ReferenceScaleValueDefinitions => this.SelectedReferenceDataLibrary?.Scale
+ .SelectMany(x => x.ValueDefinition)
+ .Where(x => this.SelectedScaleValueDefinitions.All(selected => selected.Iid != x.Iid));
+
///
/// Gets the available s
///
- public IEnumerable MeasurementUnits { get; private set; }
+ public IEnumerable MeasurementUnits => this.SelectedReferenceDataLibrary?.QueryMeasurementUnitsFromChainOfRdls();
+
+ ///
+ /// Gets the available s
+ ///
+ public IEnumerable MeasurementScales => this.SelectedReferenceDataLibrary?.QueryMeasurementScalesFromChainOfRdls();
+
+ ///
+ /// Gets the available measurement scale types s
+ ///
+ public IEnumerable MeasurementScaleTypes { get; private set; } = AvailableMeasurementScaleTypes.Select(x => new ClassKindWrapper(x));
///
/// Gets the available s
@@ -69,12 +112,158 @@ public MeasurementScalesTableViewModel(ISessionService sessionService, IShowHide
public IEnumerable NumberSetKinds { get; private set; } = Enum.GetValues();
///
- /// Initializes the
+ /// Gets the available s
+ ///
+ public IEnumerable LogarithmBaseKinds { get; private set; } = Enum.GetValues();
+
+ ///
+ /// Gets or sets the selected reference data library
+ ///
+ public ReferenceDataLibrary SelectedReferenceDataLibrary { get; set; }
+
+ ///
+ /// Gets or sets the selected reference quantity value
+ ///
+ public ScaleReferenceQuantityValue SelectedReferenceQuantityValue { get; set; }
+
+ ///
+ /// Gets the selected s
+ ///
+ public IEnumerable SelectedScaleValueDefinitions { get; set; } = Enumerable.Empty();
+
+ ///
+ /// Gets the selected s
+ ///
+ public IEnumerable SelectedMappingToReferenceScale { get; set; } = Enumerable.Empty();
+
+ ///
+ /// Gets or sets the selected measurement scale type
+ ///
+ public ClassKindWrapper SelectedMeasurementScaleType
+ {
+ get => this.selectedMeasurementScaleType;
+ set
+ {
+ this.SelectMeasurementScaleType(value);
+ this.RaiseAndSetIfChanged(ref this.selectedMeasurementScaleType, value);
+ }
+ }
+
+ ///
+ /// Selects the current
+ ///
+ /// The measurement scale to be set
+ public void SelectMeasurementScale(MeasurementScale measurementScale)
+ {
+ this.Thing = measurementScale;
+
+ this.SelectedScaleValueDefinitions = measurementScale.ValueDefinition;
+ this.SelectedMappingToReferenceScale = measurementScale.MappingToReferenceScale;
+ this.SelectedReferenceDataLibrary = (ReferenceDataLibrary)measurementScale.Container ?? this.ReferenceDataLibraries.FirstOrDefault();
+
+ if (measurementScale is LogarithmicScale logarithmicScale)
+ {
+ this.SelectedReferenceQuantityValue = logarithmicScale.ReferenceQuantityValue.FirstOrDefault() ?? new ScaleReferenceQuantityValue();
+ }
+ }
+
+ ///
+ /// Initializes the
///
public override void InitializeViewModel()
{
base.InitializeViewModel();
- this.ReferenceDataLibraries = this.SessionService.Session.RetrieveSiteDirectory().AvailableReferenceDataLibraries();
+
+ var siteDirectory = this.SessionService.GetSiteDirectory();
+
+ this.ReferenceDataLibraries = siteDirectory.AvailableReferenceDataLibraries().Where(x => x.Unit.Count > 0);
+ this.ReferenceQuantityKinds = siteDirectory.SiteReferenceDataLibrary.SelectMany(x => x.ParameterType).OfType().DistinctBy(x => x.Iid);
+
+ this.SelectedReferenceDataLibrary = this.ReferenceDataLibraries.FirstOrDefault();
+ this.SelectedMeasurementScaleType = this.MeasurementScaleTypes.First();
+ }
+
+ ///
+ /// Creates or edits a
+ ///
+ /// The value to check if a new should be created
+ /// A
+ public async Task CreateOrEditMeasurementScale(bool shouldCreate)
+ {
+ this.IsLoading = true;
+
+ var hasRdlChanged = this.SelectedReferenceDataLibrary != this.Thing.Container;
+ var rdlClone = this.SelectedReferenceDataLibrary.Clone(false);
+ var thingsToCreate = new List();
+
+ if (shouldCreate || hasRdlChanged)
+ {
+ rdlClone.Scale.Add(this.Thing);
+ thingsToCreate.Add(rdlClone);
+ }
+
+ if (this.Thing is LogarithmicScale logarithmicScale)
+ {
+ switch (logarithmicScale.ReferenceQuantityValue.Count)
+ {
+ case 0 when !string.IsNullOrWhiteSpace(this.SelectedReferenceQuantityValue.Value):
+ logarithmicScale.ReferenceQuantityValue.Add(this.SelectedReferenceQuantityValue);
+ thingsToCreate.Add(this.SelectedReferenceQuantityValue);
+ break;
+ case > 0 when string.IsNullOrWhiteSpace(this.SelectedReferenceQuantityValue.Value):
+ logarithmicScale.ReferenceQuantityValue.Clear();
+ break;
+ case > 0 when !string.IsNullOrWhiteSpace(this.SelectedReferenceQuantityValue.Value):
+ logarithmicScale.ReferenceQuantityValue[0] = this.SelectedReferenceQuantityValue;
+ thingsToCreate.Add(this.SelectedReferenceQuantityValue);
+ break;
+ }
+ }
+
+ var scaleValueDefinitionsToCreate = this.SelectedScaleValueDefinitions.Where(x => !this.Thing.ValueDefinition.Contains(x)).ToList();
+ this.Thing.ValueDefinition.AddRange(scaleValueDefinitionsToCreate);
+ thingsToCreate.AddRange(scaleValueDefinitionsToCreate);
+
+ var scaleValueDefinitionsToRemove = this.Thing.ValueDefinition.Where(x => !this.SelectedScaleValueDefinitions.Contains(x)).ToList();
+ this.Thing.ValueDefinition.RemoveMany(scaleValueDefinitionsToRemove);
+ thingsToCreate.AddRange(scaleValueDefinitionsToRemove);
+
+ var mappingToReferenceScalesToCreate = this.SelectedMappingToReferenceScale.Where(x => !this.Thing.MappingToReferenceScale.Contains(x)).ToList();
+ this.Thing.MappingToReferenceScale.AddRange(mappingToReferenceScalesToCreate);
+ thingsToCreate.AddRange(mappingToReferenceScalesToCreate);
+
+ var mappingToReferenceScalesToRemove = this.Thing.MappingToReferenceScale.Where(x => !this.SelectedMappingToReferenceScale.Contains(x)).ToList();
+ this.Thing.MappingToReferenceScale.RemoveMany(mappingToReferenceScalesToRemove);
+ thingsToCreate.AddRange(mappingToReferenceScalesToRemove);
+
+ thingsToCreate.Add(this.Thing);
+
+ await this.SessionService.CreateOrUpdateThings(rdlClone, thingsToCreate);
+ await this.SessionService.RefreshSession();
+
+ this.IsLoading = false;
+ }
+
+ ///
+ /// Selects a new measurement scale type for the attribute
+ ///
+ /// The new kind to which the will be set
+ private void SelectMeasurementScaleType(ClassKindWrapper newKind)
+ {
+ this.Thing = newKind.ClassKind switch
+ {
+ ClassKind.CyclicRatioScale => new CyclicRatioScale(),
+ ClassKind.IntervalScale => new IntervalScale(),
+ ClassKind.LogarithmicScale => new LogarithmicScale(),
+ ClassKind.OrdinalScale => new OrdinalScale(),
+ ClassKind.RatioScale => new RatioScale(),
+ _ => this.Thing
+ };
+
+ if (newKind.ClassKind == ClassKind.LogarithmicScale)
+ {
+ this.SelectedReferenceQuantityValue = new ScaleReferenceQuantityValue();
+ }
}
}
}
diff --git a/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementUnits/MeasurementUnitsTableViewModel.cs b/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementUnits/MeasurementUnitsTableViewModel.cs
index 78bd7dbe..30525aa6 100644
--- a/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementUnits/MeasurementUnitsTableViewModel.cs
+++ b/COMETwebapp/ViewModels/Components/ReferenceData/MeasurementUnits/MeasurementUnitsTableViewModel.cs
@@ -51,7 +51,7 @@ public class MeasurementUnitsTableViewModel : DeprecatableDataItemTableViewModel
private ClassKindWrapper selectedMeasurementUnitType;
///
- /// FGets the available s
+ /// Gets the available s
///
private static readonly IEnumerable AvailableMeasurementUnitTypes = [ClassKind.SimpleUnit, ClassKind.DerivedUnit, ClassKind.LinearConversionUnit, ClassKind.PrefixedUnit];
diff --git a/COMETwebapp/ViewModels/Components/ReferenceData/Rows/MappingToReferenceScaleRowViewModel.cs b/COMETwebapp/ViewModels/Components/ReferenceData/Rows/MappingToReferenceScaleRowViewModel.cs
new file mode 100644
index 00000000..e4d8cc61
--- /dev/null
+++ b/COMETwebapp/ViewModels/Components/ReferenceData/Rows/MappingToReferenceScaleRowViewModel.cs
@@ -0,0 +1,110 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2023-2024 RHEA System S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
+//
+// This file is part of CDP4-COMET WEB Community Edition
+// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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-COMET WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.ViewModels.Components.ReferenceData.Rows
+{
+ using CDP4Common.SiteDirectoryData;
+
+ using ReactiveUI;
+
+ ///
+ /// Row View Model for s
+ ///
+ public class MappingToReferenceScaleRowViewModel : ReactiveObject
+ {
+ ///
+ /// Backing field for
+ ///
+ private string reference;
+
+ ///
+ /// Backing field for
+ ///
+ private string referenceValue;
+
+ ///
+ /// Backing field for
+ ///
+ private string dependent;
+
+ ///
+ /// Backing field for
+ ///
+ private string dependentValue;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The associated
+ public MappingToReferenceScaleRowViewModel(MappingToReferenceScale mappingToReferenceScale)
+ {
+ this.MappingToReferenceScale = mappingToReferenceScale;
+ this.Reference = mappingToReferenceScale.ReferenceScaleValue.ShortName;
+ this.ReferenceValue = mappingToReferenceScale.ReferenceScaleValue.Value;
+ this.Dependent = mappingToReferenceScale.DependentScaleValue.ShortName;
+ this.DependentValue = mappingToReferenceScale.DependentScaleValue.Value;
+ }
+
+ ///
+ /// Gets or sets the row's
+ ///
+ public MappingToReferenceScale MappingToReferenceScale { get; set; }
+
+ ///
+ /// The reference of the
+ ///
+ public string Reference
+ {
+ get => this.reference;
+ set => this.RaiseAndSetIfChanged(ref this.reference, value);
+ }
+
+ ///
+ /// The reference value of the
+ ///
+ public string ReferenceValue
+ {
+ get => this.referenceValue;
+ set => this.RaiseAndSetIfChanged(ref this.referenceValue, value);
+ }
+
+ ///
+ /// The dependent of the
+ ///
+ public string Dependent
+ {
+ get => this.dependent;
+ set => this.RaiseAndSetIfChanged(ref this.dependent, value);
+ }
+
+ ///
+ /// The dependent value of the
+ ///
+ public string DependentValue
+ {
+ get => this.dependentValue;
+ set => this.RaiseAndSetIfChanged(ref this.dependentValue, value);
+ }
+ }
+}
diff --git a/COMETwebapp/ViewModels/Components/ReferenceData/Rows/ScaleValueDefinitionRowViewModel.cs b/COMETwebapp/ViewModels/Components/ReferenceData/Rows/ScaleValueDefinitionRowViewModel.cs
new file mode 100644
index 00000000..164e7356
--- /dev/null
+++ b/COMETwebapp/ViewModels/Components/ReferenceData/Rows/ScaleValueDefinitionRowViewModel.cs
@@ -0,0 +1,61 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// Copyright (c) 2023-2024 RHEA System S.A.
+//
+// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua
+//
+// This file is part of CDP4-COMET WEB Community Edition
+// The CDP4-COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+//
+// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Affero 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-COMET WEB 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
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace COMETwebapp.ViewModels.Components.ReferenceData.Rows
+{
+ using CDP4Common.SiteDirectoryData;
+
+ using COMETwebapp.ViewModels.Components.Common.Rows;
+
+ using ReactiveUI;
+
+ ///
+ /// Row View Model for s
+ ///
+ public class ScaleValueDefinitionRowViewModel : BaseDataItemRowViewModel
+ {
+ ///
+ /// Backing field for
+ ///
+ private string value;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The associated
+ public ScaleValueDefinitionRowViewModel(ScaleValueDefinition scaleValueDefinition) : base(scaleValueDefinition)
+ {
+ this.Value = scaleValueDefinition.Value;
+ }
+
+ ///
+ /// The value of the
+ ///
+ public string Value
+ {
+ get => this.value;
+ set => this.RaiseAndSetIfChanged(ref this.value, value);
+ }
+ }
+}
diff --git a/COMETwebapp/_Imports.razor b/COMETwebapp/_Imports.razor
index f39e2a67..4231c982 100644
--- a/COMETwebapp/_Imports.razor
+++ b/COMETwebapp/_Imports.razor
@@ -31,6 +31,7 @@
@using COMETwebapp.Components.SystemRepresentation
@using COMETwebapp.Components.Viewer.PropertiesPanel
@using COMETwebapp.ViewModels.Components.SiteDirectory.Rows
+@using COMETwebapp.ViewModels.Components.ReferenceData.Rows
@using COMETwebapp.ViewModels.Components.EngineeringModel.Rows
@using BlazorStrap
@using DevExpress.Blazor
diff --git a/WebAppHeader.DotSettings b/WebAppHeader.DotSettings
index 42fe9f29..47090e6d 100644
--- a/WebAppHeader.DotSettings
+++ b/WebAppHeader.DotSettings
@@ -1,12 +1,12 @@
--------------------------------------------------------------------------------------------------------------------
- <copyright file="${File.FileName}" company="RHEA System S.A.">
- Copyright (c) ${CurrentDate.Year} RHEA System S.A.
+ <copyright file="${File.FileName}" company="Starion Group S.A.">
+ Copyright (c) ${CurrentDate.Year} Starion Group S.A.
Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
This file is part of COMET WEB Community Edition
- The COMET WEB Community Edition is the RHEA Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
+ The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
The COMET WEB Community Edition is free software; you can redistribute it and/or
modify it under the terms of the GNU Affero General Public