Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit b6df3e27 authored by Harald Martini's avatar Harald Martini
Browse files

added IXMLComponentInputReader to multistage dependencies, updated loading airdrag data

parent f473607a
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ namespace VECTO3GUI2020.Ninject
IDialogHelper DialogHelper { get; }
IDeclarationInjectFactory InjectFactory { get; }
IComponentViewModelFactory ComponentViewModelFactory { get; }
IXMLComponentInputReader ComponentInputReader { get; }
IXMLWriterFactory XMLWriterFactory { get; }
}
}
\ No newline at end of file
......@@ -16,11 +16,13 @@ namespace VECTO3GUI2020.Ninject
private readonly Lazy<IComponentViewModelFactory> _componentViewModelFactory;
private readonly Lazy<IMultiStageViewModelFactory> _multistageViewModelFactory;
private readonly Lazy<IDialogHelper> _dialogHelper;
private readonly Lazy<IXMLComponentInputReader> _componentInputReader;
public Lazy<IMultiStageViewModelFactory> MultistageViewModelFactory => _multistageViewModelFactory;
public Lazy<IDialogHelper> DialogHelperLazy => _dialogHelper;
public IDialogHelper DialogHelper => _dialogHelper.Value;
public IDeclarationInjectFactory InjectFactory => _injectFactory.Value;
public IComponentViewModelFactory ComponentViewModelFactory => _componentViewModelFactory.Value;
public IXMLComponentInputReader ComponentInputReader => _componentInputReader.Value;
public IXMLWriterFactory XMLWriterFactory => _xmlWriterFactory.Value;
public MultistageLazyDependencies(
......@@ -28,13 +30,15 @@ namespace VECTO3GUI2020.Ninject
Lazy<IDeclarationInjectFactory> injectFactory,
Lazy<IComponentViewModelFactory> componentViewModelFactory,
Lazy<IXMLWriterFactory> xmlWriterFactory,
Lazy<IMultiStageViewModelFactory> viewModelFactory)
Lazy<IMultiStageViewModelFactory> viewModelFactory,
Lazy<IXMLComponentInputReader> componentInputReader)
{
_dialogHelper = dialogHelper;
_componentViewModelFactory = componentViewModelFactory;
_injectFactory = injectFactory;
_xmlWriterFactory = xmlWriterFactory;
_multistageViewModelFactory = viewModelFactory;
_componentInputReader = componentInputReader;
}
}
}
\ No newline at end of file
......@@ -153,7 +153,9 @@ namespace VECTO3GUI2020.ViewModel.Implementation.JobEdit.Vehicle.Components
public override void SetProperties()
{
throw new NotImplementedException();
_airDragArea = _inputData.AirDragArea;
_airDragArea = _inputData.AirDragArea_0;
_transferredAirDragArea = _inputData.TransferredAirDragArea;
}
}
......
......@@ -150,38 +150,47 @@ namespace VECTO3GUI2020.ViewModel.MultiStage.Implementation
var success = true;
var errorStringBuilder = new StringBuilder();
try {
var xDoc = XDocument.Load(fileName);
var doc = new XmlDocument();
doc.Load(fileName);
var airdragElements = xDoc.Descendants().Where(e => e.Name.LocalName == XMLNames.Component_AirDrag);
if (airdragElements.Count() == 1) {
//GET FROM FILE
var dataProviderVersion = XMLDeclarationAirdragDataProviderV20.QUALIFIED_XSD_TYPE;
var validator = new XMLValidator(doc);
var valid = validator.ValidateXML(TUGraz.VectoCore.Utils.XmlDocumentType
.DeclarationComponentData);
if (!valid) {
throw new VectoException("Invalid input file");
}
//dataProviderVersion = XMLHelper.GetVersion(doc.Node);
XElement airdragElement = airdragElements.First();
XmlNode airdragNode = airdragElement.ToXmlNode();
var airDragInputData =
_dependencies.InjectFactory.CreateAirdragData(dataProviderVersion, null, airdragNode, fileName);
AirDragViewModel =
_dependencies.ComponentViewModelFactory.CreateComponentViewModel(airDragInputData) as IAirDragViewModel;
AirDragViewModel.IsReadOnly = true;
AirDragViewModel.LabelVisible = false;
success = true;
} else {
success = false;
}
var airDragInputData = _dependencies.ComponentInputReader.CreateAirdrag(fileName);
AirDragViewModel =
_dependencies.ComponentViewModelFactory.CreateComponentViewModel(airDragInputData) as IAirDragViewModel;
AirDragViewModel.IsReadOnly = true;
AirDragViewModel.LabelVisible = false;
success = true;
// // ---- old implementation
// var xDoc = XDocument.Load(fileName);
//var doc = new XmlDocument();
//doc.Load(fileName);
//var airdragElements = xDoc.Descendants().Where(e => e.Name.LocalName == XMLNames.Component_AirDrag);
//if (airdragElements.Count() == 1) {
// //GET FROM FILE
// var dataProviderVersion = XMLDeclarationAirdragDataProviderV20.QUALIFIED_XSD_TYPE;
// var validator = new XMLValidator(doc);
// var valid = validator.ValidateXML(TUGraz.VectoCore.Utils.XmlDocumentType
// .DeclarationComponentData);
// if (!valid) {
// throw new VectoException("Invalid input file");
// }
// //dataProviderVersion = XMLHelper.GetVersion(doc.Node);
// XElement airdragElement = airdragElements.First();
// XmlNode airdragNode = airdragElement.ToXmlNode();
// var airDragInputData =
// _dependencies.InjectFactory.CreateAirdragData(dataProviderVersion, null, airdragNode, fileName);
// AirDragViewModel =
// _dependencies.ComponentViewModelFactory.CreateComponentViewModel(airDragInputData) as IAirDragViewModel;
// AirDragViewModel.IsReadOnly = true;
// AirDragViewModel.LabelVisible = false;
// success = true;
//} else {
// success = false;
//}
} catch (Exception e) {
_dependencies.DialogHelper.ShowMessageBox(e.Message,
"Invalid File",
......
......@@ -85,7 +85,7 @@ namespace Vecto3GUI2020Test.ViewModelTests
var multistageJobViewModel = vm.MultiStageJobViewModel as MultiStageJobViewModel_v0_1;
var outputName = "AidragLoadedInFirstStage";
multistageJobViewModel.SaveVif(Path.GetFullPath($"{outputName}.xml"));
_mockDialogHelper.AssertNoErrorDialogs();
var resultFile = $"{outputName}.VIF_Report_2.xml";
AssertHelper.FileExists(resultFile);
var secondstageVm = LoadFileFromPath(resultFile);
......
......@@ -6,6 +6,7 @@ using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Hashing;
using TUGraz.VectoCommon.InputData;
using TUGraz.VectoCommon.Resources;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider;
using TUGraz.VectoCore.Utils;
......@@ -65,6 +66,14 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF
return retVal;
}
protected XElement GetAirdragElement(IAirdragDeclarationInputData inputData, string version)
{
var retVal = new XElement(v24 + XMLNames.Component_AirDrag);
var tmp = XElement.Load(inputData.XMLSource.CreateNavigator().ReadSubtree());
retVal.Add(tmp.Elements());
return retVal;
}
protected XElement GetAirdragElement(IAirdragDeclarationInputData airdrag)
{
switch (airdrag) {
......@@ -75,6 +84,16 @@ namespace TUGraz.VectoCore.OutputData.XML.DeclarationReports.VehicleInformationF
case XMLDeclarationAirdragDataProviderV10 av10:
return GetAirdragElement(av10);
}
var sourceVersion = airdrag.DataSource.SourceVersion;
if (sourceVersion.IsOneOf(v10.GetVersionFromNamespaceUri(), v20.GetVersionFromNamespaceUri(),
v24.GetVersionFromNamespaceUri())) {
return GetAirdragElement(airdrag, "");
}
throw new VectoException(
$"Specific implementation for Airdrag Data (Interim Stage) missing {airdrag.GetType().Name}");
......
{
"Header": {
"CreatedBy": "Harry",
"Date": "2021-08-25T00:00:00+02:00",
"CreatedBy": "haraldmartini",
"Date": "2023-03-23T00:00:00+01:00",
"AppVersion": "Vecto3GUI2020",
"FileVersion": 10
},
......
......@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net6.0-windows</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
......@@ -31,9 +31,10 @@
</ItemGroup>
<ItemGroup>
<Content Include="..\..\VectoCore\VectoCoreTest\TestData\**\*.*">
<Link>TestData\%(RecursiveDir)%(FileName).%(Extension)</Link>
<Content Include="..\..\VectoCore\VectoCoreTest\TestData\**\*.*" Exclude="..\..\VectoCore\VectoCoreTest\TestData\Integration\DeclarationMode\2nd_AmendmDeclMode\JSON\**\*.*">
<Link>TestData\%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
......@@ -42,6 +43,7 @@
<ItemGroup>
<Content Remove="..\..\VectoCore\VectoCoreTest\TestData\Components\**" />
<Content Remove="..\..\VectoCore\VectoCoreTest\TestData\Integration\DeclarationMode\2nd_AmendmDeclMode\JSON\**\*.*" />
</ItemGroup>
<ItemGroup>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment