diff --git a/uml4net.xmi.Tests/DecisionModelNotationReaderTestFixture.cs b/uml4net.xmi.Tests/DecisionModelNotationReaderTestFixture.cs new file mode 100644 index 00000000..ef0cfaf0 --- /dev/null +++ b/uml4net.xmi.Tests/DecisionModelNotationReaderTestFixture.cs @@ -0,0 +1,78 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Tests +{ + using System.IO; + using System.Linq; + + using Microsoft.Extensions.Logging; + + using NUnit.Framework; + + using Serilog; + + using uml4net.Values; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StructuredClassifiers; + using uml4net.xmi; + + [TestFixture] + public class DecisionModelNotationReaderTestFixture + { + private ILoggerFactory loggerFactory; + + [OneTimeSetUp] + public void OneTimeSetUp() + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.Console() + .CreateLogger(); + + this.loggerFactory = LoggerFactory.Create(builder => + { + builder.AddSerilog(); + }); + } + + [Test] + public void Verify_that_DMN_XMI_can_be_read() + { + var rootPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData"); + + var reader = XmiReaderBuilder.Create() + .UsingSettings(x => x.LocalReferenceBasePath = rootPath) + .WithLogger(this.loggerFactory) + .Build(); + + var xmiReaderResult = reader.Read(Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "dtc-23-02-13.xmi.xml")); + + Assert.That(xmiReaderResult.Packages.Count, Is.EqualTo(2)); + + var model = xmiReaderResult.Root as IModel; + + Assert.That(model.Name, Is.EqualTo("Data")); + + Assert.That(model.NestedPackage.Count, Is.EqualTo(4)); + } + } +} \ No newline at end of file diff --git a/uml4net.xmi.Tests/uml4net.xmi.Tests.csproj b/uml4net.xmi.Tests/uml4net.xmi.Tests.csproj index eeaaac48..9b45d6c0 100644 --- a/uml4net.xmi.Tests/uml4net.xmi.Tests.csproj +++ b/uml4net.xmi.Tests/uml4net.xmi.Tests.csproj @@ -39,6 +39,9 @@ + + Always + Always diff --git a/uml4net.xmi/Readers/StructuredClassifiers/AssociationReader.cs b/uml4net.xmi/AutoGenXmiReaders/AssociationReader.cs similarity index 100% rename from uml4net.xmi/Readers/StructuredClassifiers/AssociationReader.cs rename to uml4net.xmi/AutoGenXmiReaders/AssociationReader.cs diff --git a/uml4net.xmi/Readers/StructuredClassifiers/ClassReader.cs b/uml4net.xmi/AutoGenXmiReaders/ClassReader.cs similarity index 99% rename from uml4net.xmi/Readers/StructuredClassifiers/ClassReader.cs rename to uml4net.xmi/AutoGenXmiReaders/ClassReader.cs index 15bbb983..3253b0d1 100644 --- a/uml4net.xmi/Readers/StructuredClassifiers/ClassReader.cs +++ b/uml4net.xmi/AutoGenXmiReaders/ClassReader.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // // // Copyright (C) 2019-2024 Starion Group S.A. diff --git a/uml4net.xmi/Readers/StructuredClassifiers/CollaborationUseReader.cs b/uml4net.xmi/AutoGenXmiReaders/CollaborationUseReader.cs similarity index 51% rename from uml4net.xmi/Readers/StructuredClassifiers/CollaborationUseReader.cs rename to uml4net.xmi/AutoGenXmiReaders/CollaborationUseReader.cs index db4e6356..d9b3ee83 100644 --- a/uml4net.xmi/Readers/StructuredClassifiers/CollaborationUseReader.cs +++ b/uml4net.xmi/AutoGenXmiReaders/CollaborationUseReader.cs @@ -32,24 +32,25 @@ namespace uml4net.xmi.Readers.StructuredClassifiers using Microsoft.Extensions.Logging; using uml4net; + using uml4net.Actions; + using uml4net.Activities; using uml4net.Classification; using uml4net.CommonBehavior; using uml4net.CommonStructure; using uml4net.Deployments; + using uml4net.Interactions; using uml4net.Packages; using uml4net.SimpleClassifiers; + using uml4net.StateMachines; using uml4net.StructuredClassifiers; using uml4net.UseCases; using uml4net.Utils; using uml4net.Values; using uml4net.xmi.Cache; using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; /// - /// The purpose of the is to read an instance of + /// The purpose of the is to read an instance of /// from the XMI document /// public class CollaborationUseReader : XmiElementReader, IXmiElementReader @@ -72,13 +73,13 @@ public CollaborationUseReader(IXmiReaderCache cache, ILoggerFactory loggerFactor } /// - /// Reads the object from its XML representation + /// Reads the object from its XML representation /// /// /// an instance of /// /// - /// an instance of + /// an instance of /// public override ICollaborationUse Read(XmlReader xmlReader) { @@ -107,9 +108,68 @@ public override ICollaborationUse Read(XmlReader xmlReader) poco.XmiId = xmlReader.GetAttribute("xmi:id"); this.Cache.Add(poco.XmiId, poco); + + poco.Name = xmlReader.GetAttribute("name"); + + var typeXmlAttribute = xmlReader.GetAttribute("type"); + if (!string.IsNullOrEmpty(typeXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("type", typeXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "roleBinding": + var roleBindingValue = (IDependency)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Dependency"); + poco.RoleBinding.Add(roleBindingValue); + break; + case "type": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "type"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"CollaborationUseReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + } return poco; } } } + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/UseCases/UseCaseReader.cs b/uml4net.xmi/AutoGenXmiReaders/CommentReader.cs similarity index 54% rename from uml4net.xmi/Readers/UseCases/UseCaseReader.cs rename to uml4net.xmi/AutoGenXmiReaders/CommentReader.cs index bba534b6..fcf3d222 100644 --- a/uml4net.xmi/Readers/UseCases/UseCaseReader.cs +++ b/uml4net.xmi/AutoGenXmiReaders/CommentReader.cs @@ -1,5 +1,5 @@ // ------------------------------------------------------------------------------------------------- -// +// // // Copyright (C) 2019-2024 Starion Group S.A. // @@ -22,7 +22,7 @@ // --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- // ------------------------------------------------------------------------------------------------ -namespace uml4net.xmi.Readers.UseCases +namespace uml4net.xmi.Readers.CommonStructure { using System; using System.Collections.Generic; @@ -32,32 +32,33 @@ namespace uml4net.xmi.Readers.UseCases using Microsoft.Extensions.Logging; using uml4net; + using uml4net.Actions; + using uml4net.Activities; using uml4net.Classification; using uml4net.CommonBehavior; using uml4net.CommonStructure; using uml4net.Deployments; + using uml4net.Interactions; using uml4net.Packages; using uml4net.SimpleClassifiers; + using uml4net.StateMachines; using uml4net.StructuredClassifiers; using uml4net.UseCases; using uml4net.Utils; using uml4net.Values; using uml4net.xmi.Cache; using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; /// - /// The purpose of the is to read an instance of + /// The purpose of the is to read an instance of /// from the XMI document /// - public class UseCaseReader : XmiElementReader, IXmiElementReader + public class CommentReader : XmiElementReader, IXmiElementReader { private readonly IXmiElementReaderFacade xmiElementReaderFacade; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The cache in which each > is stored @@ -65,41 +66,41 @@ public class UseCaseReader : XmiElementReader, IXmiElementReader /// The (injected) used to set up logging /// - public UseCaseReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + public CommentReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) : base(cache, loggerFactory) { this.xmiElementReaderFacade = new XmiElementReaderFacade(); } /// - /// Reads the object from its XML representation + /// Reads the object from its XML representation /// /// /// an instance of /// /// - /// an instance of + /// an instance of /// - public override IUseCase Read(XmlReader xmlReader) + public override IComment Read(XmlReader xmlReader) { if (xmlReader == null) { throw new ArgumentNullException(nameof(xmlReader)); } - IUseCase poco = new UseCase(); + IComment poco = new Comment(); if (xmlReader.MoveToContent() == XmlNodeType.Element) { var xmiType = xmlReader.GetAttribute("xmi:type"); - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:UseCase") + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Comment") { - throw new XmlException($"The XmiType should be 'uml:UseCase' while it is {xmiType}"); + throw new XmlException($"The XmiType should be 'uml:Comment' while it is {xmiType}"); } else { - xmiType = "uml:UseCase"; + xmiType = "uml:Comment"; } poco.XmiType = xmiType; @@ -107,6 +108,47 @@ public override IUseCase Read(XmlReader xmlReader) poco.XmiId = xmlReader.GetAttribute("xmi:id"); this.Cache.Add(poco.XmiId, poco); + + var annotatedElementXmlAttribute = xmlReader.GetAttribute("annotatedElement"); + if (!string.IsNullOrEmpty(annotatedElementXmlAttribute)) + { + var annotatedElementXmlAttributeValues = annotatedElementXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("annotatedElement", annotatedElementXmlAttributeValues); + } + + poco.Body = xmlReader.GetAttribute("body"); + + + var annotatedElementValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "annotatedElement": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, annotatedElementValues, "annotatedElement"); + break; + case "body": + poco.Body = xmlReader.ReadElementContentAsString(); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"CommentReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (annotatedElementValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("annotatedElement", annotatedElementValues); + } + } return poco; diff --git a/uml4net.xmi/Readers/StructuredClassifiers/ConnectorReader.cs b/uml4net.xmi/AutoGenXmiReaders/ConnectorReader.cs similarity index 100% rename from uml4net.xmi/Readers/StructuredClassifiers/ConnectorReader.cs rename to uml4net.xmi/AutoGenXmiReaders/ConnectorReader.cs diff --git a/uml4net.xmi/AutoGenXmiReaders/ConstraintReader.cs b/uml4net.xmi/AutoGenXmiReaders/ConstraintReader.cs new file mode 100644 index 00000000..ba1e8d41 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/ConstraintReader.cs @@ -0,0 +1,209 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.CommonStructure +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class ConstraintReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public ConstraintReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IConstraint Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IConstraint poco = new Constraint(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Constraint") + { + throw new XmlException($"The XmiType should be 'uml:Constraint' while it is {xmiType}"); + } + else + { + xmiType = "uml:Constraint"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var constrainedElementXmlAttribute = xmlReader.GetAttribute("constrainedElement"); + if (!string.IsNullOrEmpty(constrainedElementXmlAttribute)) + { + var constrainedElementXmlAttributeValues = constrainedElementXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("constrainedElement", constrainedElementXmlAttributeValues); + } + + var contextXmlAttribute = xmlReader.GetAttribute("context"); + if (!string.IsNullOrEmpty(contextXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("context", contextXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var constrainedElementValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "constrainedElement": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, constrainedElementValues, "constrainedElement"); + break; + case "context": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "context"); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "specification": + var specificationValue = (IValueSpecification)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.Specification.Add(specificationValue); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"ConstraintReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (constrainedElementValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("constrainedElement", constrainedElementValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/CommonStructure/ElementImportReader.cs b/uml4net.xmi/AutoGenXmiReaders/ElementImportReader.cs similarity index 54% rename from uml4net.xmi/Readers/CommonStructure/ElementImportReader.cs rename to uml4net.xmi/AutoGenXmiReaders/ElementImportReader.cs index 48e4a6e8..0ef50581 100644 --- a/uml4net.xmi/Readers/CommonStructure/ElementImportReader.cs +++ b/uml4net.xmi/AutoGenXmiReaders/ElementImportReader.cs @@ -32,21 +32,22 @@ namespace uml4net.xmi.Readers.CommonStructure using Microsoft.Extensions.Logging; using uml4net; + using uml4net.Actions; + using uml4net.Activities; using uml4net.Classification; using uml4net.CommonBehavior; using uml4net.CommonStructure; using uml4net.Deployments; + using uml4net.Interactions; using uml4net.Packages; using uml4net.SimpleClassifiers; + using uml4net.StateMachines; using uml4net.StructuredClassifiers; using uml4net.UseCases; using uml4net.Utils; using uml4net.Values; using uml4net.xmi.Cache; using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; /// /// The purpose of the is to read an instance of @@ -107,9 +108,69 @@ public override IElementImport Read(XmlReader xmlReader) poco.XmiId = xmlReader.GetAttribute("xmi:id"); this.Cache.Add(poco.XmiId, poco); + + poco.Alias = xmlReader.GetAttribute("alias"); + + var importedElementXmlAttribute = xmlReader.GetAttribute("importedElement"); + if (!string.IsNullOrEmpty(importedElementXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("importedElement", importedElementXmlAttribute); + } + + var importingNamespaceXmlAttribute = xmlReader.GetAttribute("importingNamespace"); + if (!string.IsNullOrEmpty(importingNamespaceXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("importingNamespace", importingNamespaceXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "alias": + poco.Alias = xmlReader.ReadElementContentAsString(); + break; + case "importedElement": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "importedElement"); + break; + case "importingNamespace": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "importingNamespace"); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"ElementImportReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + } return poco; } } } + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/EnumerationLiteralReader.cs b/uml4net.xmi/AutoGenXmiReaders/EnumerationLiteralReader.cs new file mode 100644 index 00000000..b648e75a --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/EnumerationLiteralReader.cs @@ -0,0 +1,207 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.SimpleClassifiers +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class EnumerationLiteralReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public EnumerationLiteralReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IEnumerationLiteral Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IEnumerationLiteral poco = new EnumerationLiteral(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:EnumerationLiteral") + { + throw new XmlException($"The XmiType should be 'uml:EnumerationLiteral' while it is {xmiType}"); + } + else + { + xmiType = "uml:EnumerationLiteral"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var enumerationXmlAttribute = xmlReader.GetAttribute("enumeration"); + if (!string.IsNullOrEmpty(enumerationXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("enumeration", enumerationXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var classifierValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "deployment": + var deploymentValue = (IDeployment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Deployment"); + poco.Deployment.Add(deploymentValue); + break; + case "enumeration": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "enumeration"); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "slot": + var slotValue = (ISlot)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Slot"); + poco.Slot.Add(slotValue); + break; + case "specification": + var specificationValue = (IValueSpecification)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.Specification.Add(specificationValue); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"EnumerationLiteralReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (classifierValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("classifier", classifierValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/EnumerationReader.cs b/uml4net.xmi/AutoGenXmiReaders/EnumerationReader.cs new file mode 100644 index 00000000..26efde3b --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/EnumerationReader.cs @@ -0,0 +1,333 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.SimpleClassifiers +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class EnumerationReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public EnumerationReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IEnumeration Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IEnumeration poco = new Enumeration(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Enumeration") + { + throw new XmlException($"The XmiType should be 'uml:Enumeration' while it is {xmiType}"); + } + else + { + xmiType = "uml:Enumeration"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var isAbstractXmlAttribute = xmlReader.GetAttribute("isAbstract"); + if (!string.IsNullOrEmpty(isAbstractXmlAttribute)) + { + poco.IsAbstract = bool.Parse(isAbstractXmlAttribute); + } + + var isFinalSpecializationXmlAttribute = xmlReader.GetAttribute("isFinalSpecialization"); + if (!string.IsNullOrEmpty(isFinalSpecializationXmlAttribute)) + { + poco.IsFinalSpecialization = bool.Parse(isFinalSpecializationXmlAttribute); + } + + var isLeafXmlAttribute = xmlReader.GetAttribute("isLeaf"); + if (!string.IsNullOrEmpty(isLeafXmlAttribute)) + { + poco.IsLeaf = bool.Parse(isLeafXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var packageXmlAttribute = xmlReader.GetAttribute("package"); + if (!string.IsNullOrEmpty(packageXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("package", packageXmlAttribute); + } + + var powertypeExtentXmlAttribute = xmlReader.GetAttribute("powertypeExtent"); + if (!string.IsNullOrEmpty(powertypeExtentXmlAttribute)) + { + var powertypeExtentXmlAttributeValues = powertypeExtentXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("powertypeExtent", powertypeExtentXmlAttributeValues); + } + + var redefinedClassifierXmlAttribute = xmlReader.GetAttribute("redefinedClassifier"); + if (!string.IsNullOrEmpty(redefinedClassifierXmlAttribute)) + { + var redefinedClassifierXmlAttributeValues = redefinedClassifierXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedClassifier", redefinedClassifierXmlAttributeValues); + } + + var representationXmlAttribute = xmlReader.GetAttribute("representation"); + if (!string.IsNullOrEmpty(representationXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("representation", representationXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var useCasesXmlAttribute = xmlReader.GetAttribute("useCases"); + if (!string.IsNullOrEmpty(useCasesXmlAttribute)) + { + var useCasesXmlAttributeValues = useCasesXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("useCases", useCasesXmlAttributeValues); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var powertypeExtentValues = new List(); + var redefinedClassifierValues = new List(); + var useCasesValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "collaborationUse": + var collaborationUseValue = (ICollaborationUse)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:CollaborationUse"); + poco.CollaborationUse.Add(collaborationUseValue); + break; + case "elementImport": + var elementImportValue = (IElementImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ElementImport"); + poco.ElementImport.Add(elementImportValue); + break; + case "generalization": + var generalizationValue = (IGeneralization)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Generalization"); + poco.Generalization.Add(generalizationValue); + break; + case "isAbstract": + var isAbstractValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isAbstractValue)) + { + poco.IsAbstract = bool.Parse(isAbstractValue); + } + break; + case "isFinalSpecialization": + var isFinalSpecializationValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isFinalSpecializationValue)) + { + poco.IsFinalSpecialization = bool.Parse(isFinalSpecializationValue); + } + break; + case "isLeaf": + var isLeafValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isLeafValue)) + { + poco.IsLeaf = bool.Parse(isLeafValue); + } + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedAttribute": + var ownedAttributeValue = (IProperty)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Property"); + poco.OwnedAttribute.Add(ownedAttributeValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "ownedLiteral": + var ownedLiteralValue = (IEnumerationLiteral)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:EnumerationLiteral"); + poco.OwnedLiteral.Add(ownedLiteralValue); + break; + case "ownedOperation": + var ownedOperationValue = (IOperation)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Operation"); + poco.OwnedOperation.Add(ownedOperationValue); + break; + case "ownedRule": + var ownedRuleValue = (IConstraint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Constraint"); + poco.OwnedRule.Add(ownedRuleValue); + break; + case "ownedTemplateSignature": + var ownedTemplateSignatureValue = (IRedefinableTemplateSignature)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:RedefinableTemplateSignature"); + poco.OwnedTemplateSignature.Add(ownedTemplateSignatureValue); + break; + case "ownedUseCase": + var ownedUseCaseValue = (IUseCase)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:UseCase"); + poco.OwnedUseCase.Add(ownedUseCaseValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "package": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "package"); + break; + case "packageImport": + var packageImportValue = (IPackageImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:PackageImport"); + poco.PackageImport.Add(packageImportValue); + break; + case "powertypeExtent": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, powertypeExtentValues, "powertypeExtent"); + break; + case "redefinedClassifier": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, redefinedClassifierValues, "redefinedClassifier"); + break; + case "representation": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "representation"); + break; + case "substitution": + var substitutionValue = (ISubstitution)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Substitution"); + poco.Substitution.Add(substitutionValue); + break; + case "templateBinding": + var templateBindingValue = (ITemplateBinding)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateBinding"); + poco.TemplateBinding.Add(templateBindingValue); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "useCases": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, useCasesValues, "useCases"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"EnumerationReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (powertypeExtentValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("powertypeExtent", powertypeExtentValues); + } + + if (redefinedClassifierValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedClassifier", redefinedClassifierValues); + } + + if (useCasesValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("useCases", useCasesValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/Classification/GeneralizationReader.cs b/uml4net.xmi/AutoGenXmiReaders/GeneralizationReader.cs similarity index 100% rename from uml4net.xmi/Readers/Classification/GeneralizationReader.cs rename to uml4net.xmi/AutoGenXmiReaders/GeneralizationReader.cs diff --git a/uml4net.xmi/AutoGenXmiReaders/InstanceValueReader.cs b/uml4net.xmi/AutoGenXmiReaders/InstanceValueReader.cs new file mode 100644 index 00000000..76b8b180 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/InstanceValueReader.cs @@ -0,0 +1,198 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.Classification +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class InstanceValueReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public InstanceValueReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IInstanceValue Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IInstanceValue poco = new InstanceValue(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:InstanceValue") + { + throw new XmlException($"The XmiType should be 'uml:InstanceValue' while it is {xmiType}"); + } + else + { + xmiType = "uml:InstanceValue"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var instanceXmlAttribute = xmlReader.GetAttribute("instance"); + if (!string.IsNullOrEmpty(instanceXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("instance", instanceXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var typeXmlAttribute = xmlReader.GetAttribute("type"); + if (!string.IsNullOrEmpty(typeXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("type", typeXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "instance": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "instance"); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "type": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "type"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"InstanceValueReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/InterfaceReader.cs b/uml4net.xmi/AutoGenXmiReaders/InterfaceReader.cs new file mode 100644 index 00000000..cf9e5e30 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/InterfaceReader.cs @@ -0,0 +1,357 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.SimpleClassifiers +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class InterfaceReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public InterfaceReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IInterface Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IInterface poco = new Interface(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Interface") + { + throw new XmlException($"The XmiType should be 'uml:Interface' while it is {xmiType}"); + } + else + { + xmiType = "uml:Interface"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var isAbstractXmlAttribute = xmlReader.GetAttribute("isAbstract"); + if (!string.IsNullOrEmpty(isAbstractXmlAttribute)) + { + poco.IsAbstract = bool.Parse(isAbstractXmlAttribute); + } + + var isFinalSpecializationXmlAttribute = xmlReader.GetAttribute("isFinalSpecialization"); + if (!string.IsNullOrEmpty(isFinalSpecializationXmlAttribute)) + { + poco.IsFinalSpecialization = bool.Parse(isFinalSpecializationXmlAttribute); + } + + var isLeafXmlAttribute = xmlReader.GetAttribute("isLeaf"); + if (!string.IsNullOrEmpty(isLeafXmlAttribute)) + { + poco.IsLeaf = bool.Parse(isLeafXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var packageXmlAttribute = xmlReader.GetAttribute("package"); + if (!string.IsNullOrEmpty(packageXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("package", packageXmlAttribute); + } + + var powertypeExtentXmlAttribute = xmlReader.GetAttribute("powertypeExtent"); + if (!string.IsNullOrEmpty(powertypeExtentXmlAttribute)) + { + var powertypeExtentXmlAttributeValues = powertypeExtentXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("powertypeExtent", powertypeExtentXmlAttributeValues); + } + + var redefinedClassifierXmlAttribute = xmlReader.GetAttribute("redefinedClassifier"); + if (!string.IsNullOrEmpty(redefinedClassifierXmlAttribute)) + { + var redefinedClassifierXmlAttributeValues = redefinedClassifierXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedClassifier", redefinedClassifierXmlAttributeValues); + } + + var redefinedInterfaceXmlAttribute = xmlReader.GetAttribute("redefinedInterface"); + if (!string.IsNullOrEmpty(redefinedInterfaceXmlAttribute)) + { + var redefinedInterfaceXmlAttributeValues = redefinedInterfaceXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedInterface", redefinedInterfaceXmlAttributeValues); + } + + var representationXmlAttribute = xmlReader.GetAttribute("representation"); + if (!string.IsNullOrEmpty(representationXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("representation", representationXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var useCasesXmlAttribute = xmlReader.GetAttribute("useCases"); + if (!string.IsNullOrEmpty(useCasesXmlAttribute)) + { + var useCasesXmlAttributeValues = useCasesXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("useCases", useCasesXmlAttributeValues); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var powertypeExtentValues = new List(); + var redefinedClassifierValues = new List(); + var redefinedInterfaceValues = new List(); + var useCasesValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "collaborationUse": + var collaborationUseValue = (ICollaborationUse)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:CollaborationUse"); + poco.CollaborationUse.Add(collaborationUseValue); + break; + case "elementImport": + var elementImportValue = (IElementImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ElementImport"); + poco.ElementImport.Add(elementImportValue); + break; + case "generalization": + var generalizationValue = (IGeneralization)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Generalization"); + poco.Generalization.Add(generalizationValue); + break; + case "isAbstract": + var isAbstractValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isAbstractValue)) + { + poco.IsAbstract = bool.Parse(isAbstractValue); + } + break; + case "isFinalSpecialization": + var isFinalSpecializationValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isFinalSpecializationValue)) + { + poco.IsFinalSpecialization = bool.Parse(isFinalSpecializationValue); + } + break; + case "isLeaf": + var isLeafValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isLeafValue)) + { + poco.IsLeaf = bool.Parse(isLeafValue); + } + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "nestedClassifier": + var nestedClassifierValue = (IClassifier)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.NestedClassifier.Add(nestedClassifierValue); + break; + case "ownedAttribute": + var ownedAttributeValue = (IProperty)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Property"); + poco.OwnedAttribute.Add(ownedAttributeValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "ownedOperation": + var ownedOperationValue = (IOperation)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Operation"); + poco.OwnedOperation.Add(ownedOperationValue); + break; + case "ownedReception": + var ownedReceptionValue = (IReception)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Reception"); + poco.OwnedReception.Add(ownedReceptionValue); + break; + case "ownedRule": + var ownedRuleValue = (IConstraint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Constraint"); + poco.OwnedRule.Add(ownedRuleValue); + break; + case "ownedTemplateSignature": + var ownedTemplateSignatureValue = (IRedefinableTemplateSignature)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:RedefinableTemplateSignature"); + poco.OwnedTemplateSignature.Add(ownedTemplateSignatureValue); + break; + case "ownedUseCase": + var ownedUseCaseValue = (IUseCase)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:UseCase"); + poco.OwnedUseCase.Add(ownedUseCaseValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "package": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "package"); + break; + case "packageImport": + var packageImportValue = (IPackageImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:PackageImport"); + poco.PackageImport.Add(packageImportValue); + break; + case "powertypeExtent": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, powertypeExtentValues, "powertypeExtent"); + break; + case "protocol": + var protocolValue = (IProtocolStateMachine)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ProtocolStateMachine"); + poco.Protocol.Add(protocolValue); + break; + case "redefinedClassifier": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, redefinedClassifierValues, "redefinedClassifier"); + break; + case "redefinedInterface": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, redefinedInterfaceValues, "redefinedInterface"); + break; + case "representation": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "representation"); + break; + case "substitution": + var substitutionValue = (ISubstitution)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Substitution"); + poco.Substitution.Add(substitutionValue); + break; + case "templateBinding": + var templateBindingValue = (ITemplateBinding)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateBinding"); + poco.TemplateBinding.Add(templateBindingValue); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "useCases": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, useCasesValues, "useCases"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"InterfaceReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (powertypeExtentValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("powertypeExtent", powertypeExtentValues); + } + + if (redefinedClassifierValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedClassifier", redefinedClassifierValues); + } + + if (redefinedInterfaceValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedInterface", redefinedInterfaceValues); + } + + if (useCasesValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("useCases", useCasesValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/InterfaceRealizationReader.cs b/uml4net.xmi/AutoGenXmiReaders/InterfaceRealizationReader.cs new file mode 100644 index 00000000..4ce9d354 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/InterfaceRealizationReader.cs @@ -0,0 +1,234 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.SimpleClassifiers +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class InterfaceRealizationReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public InterfaceRealizationReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IInterfaceRealization Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IInterfaceRealization poco = new InterfaceRealization(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:InterfaceRealization") + { + throw new XmlException($"The XmiType should be 'uml:InterfaceRealization' while it is {xmiType}"); + } + else + { + xmiType = "uml:InterfaceRealization"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var clientXmlAttribute = xmlReader.GetAttribute("client"); + if (!string.IsNullOrEmpty(clientXmlAttribute)) + { + var clientXmlAttributeValues = clientXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("client", clientXmlAttributeValues); + } + + var contractXmlAttribute = xmlReader.GetAttribute("contract"); + if (!string.IsNullOrEmpty(contractXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("contract", contractXmlAttribute); + } + + var implementingClassifierXmlAttribute = xmlReader.GetAttribute("implementingClassifier"); + if (!string.IsNullOrEmpty(implementingClassifierXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("implementingClassifier", implementingClassifierXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var supplierXmlAttribute = xmlReader.GetAttribute("supplier"); + if (!string.IsNullOrEmpty(supplierXmlAttribute)) + { + var supplierXmlAttributeValues = supplierXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("supplier", supplierXmlAttributeValues); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var clientValues = new List(); + var supplierValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "client": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, clientValues, "client"); + break; + case "contract": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "contract"); + break; + case "implementingClassifier": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "implementingClassifier"); + break; + case "mapping": + var mappingValue = (IOpaqueExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:OpaqueExpression"); + poco.Mapping.Add(mappingValue); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "supplier": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, supplierValues, "supplier"); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"InterfaceRealizationReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (clientValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("client", clientValues); + } + + if (supplierValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("supplier", supplierValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/LiteralBooleanReader.cs b/uml4net.xmi/AutoGenXmiReaders/LiteralBooleanReader.cs new file mode 100644 index 00000000..0bb80a84 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/LiteralBooleanReader.cs @@ -0,0 +1,202 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.Values +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class LiteralBooleanReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public LiteralBooleanReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override ILiteralBoolean Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + ILiteralBoolean poco = new LiteralBoolean(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:LiteralBoolean") + { + throw new XmlException($"The XmiType should be 'uml:LiteralBoolean' while it is {xmiType}"); + } + else + { + xmiType = "uml:LiteralBoolean"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var typeXmlAttribute = xmlReader.GetAttribute("type"); + if (!string.IsNullOrEmpty(typeXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("type", typeXmlAttribute); + } + + var valueXmlAttribute = xmlReader.GetAttribute("value"); + if (!string.IsNullOrEmpty(valueXmlAttribute)) + { + poco.Value = bool.Parse(valueXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "type": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "type"); + break; + case "value": + var valueValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(valueValue)) + { + poco.Value = bool.Parse(valueValue); + } + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"LiteralBooleanReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/Values/LiteralIntegerReader.cs b/uml4net.xmi/AutoGenXmiReaders/LiteralIntegerReader.cs similarity index 100% rename from uml4net.xmi/Readers/Values/LiteralIntegerReader.cs rename to uml4net.xmi/AutoGenXmiReaders/LiteralIntegerReader.cs diff --git a/uml4net.xmi/AutoGenXmiReaders/LiteralStringReader.cs b/uml4net.xmi/AutoGenXmiReaders/LiteralStringReader.cs new file mode 100644 index 00000000..c06477b2 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/LiteralStringReader.cs @@ -0,0 +1,194 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.Values +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class LiteralStringReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public LiteralStringReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override ILiteralString Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + ILiteralString poco = new LiteralString(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:LiteralString") + { + throw new XmlException($"The XmiType should be 'uml:LiteralString' while it is {xmiType}"); + } + else + { + xmiType = "uml:LiteralString"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var typeXmlAttribute = xmlReader.GetAttribute("type"); + if (!string.IsNullOrEmpty(typeXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("type", typeXmlAttribute); + } + + poco.Value = xmlReader.GetAttribute("value"); + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "type": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "type"); + break; + case "value": + poco.Value = xmlReader.ReadElementContentAsString(); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"LiteralStringReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/Values/OpaqueExpressionReader.cs b/uml4net.xmi/AutoGenXmiReaders/OpaqueExpressionReader.cs similarity index 100% rename from uml4net.xmi/Readers/Values/OpaqueExpressionReader.cs rename to uml4net.xmi/AutoGenXmiReaders/OpaqueExpressionReader.cs diff --git a/uml4net.xmi/AutoGenXmiReaders/PackageImportReader.cs b/uml4net.xmi/AutoGenXmiReaders/PackageImportReader.cs new file mode 100644 index 00000000..5fa531c3 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/PackageImportReader.cs @@ -0,0 +1,171 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.CommonStructure +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class PackageImportReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public PackageImportReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IPackageImport Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IPackageImport poco = new PackageImport(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:PackageImport") + { + throw new XmlException($"The XmiType should be 'uml:PackageImport' while it is {xmiType}"); + } + else + { + xmiType = "uml:PackageImport"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var importedPackageXmlAttribute = xmlReader.GetAttribute("importedPackage"); + if (!string.IsNullOrEmpty(importedPackageXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("importedPackage", importedPackageXmlAttribute); + } + + var importingNamespaceXmlAttribute = xmlReader.GetAttribute("importingNamespace"); + if (!string.IsNullOrEmpty(importingNamespaceXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("importingNamespace", importingNamespaceXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "importedPackage": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "importedPackage"); + break; + case "importingNamespace": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "importingNamespace"); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"PackageImportReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/ParameterReader.cs b/uml4net.xmi/AutoGenXmiReaders/ParameterReader.cs new file mode 100644 index 00000000..0d570d43 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/ParameterReader.cs @@ -0,0 +1,304 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.Classification +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class ParameterReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public ParameterReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IParameter Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IParameter poco = new Parameter(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Parameter") + { + throw new XmlException($"The XmiType should be 'uml:Parameter' while it is {xmiType}"); + } + else + { + xmiType = "uml:Parameter"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var directionXmlAttribute = xmlReader.GetAttribute("direction"); + if (!string.IsNullOrEmpty(directionXmlAttribute)) + { + poco.Direction = (ParameterDirectionKind)Enum.Parse(typeof(ParameterDirectionKind), directionXmlAttribute, true); + } + + var effectXmlAttribute = xmlReader.GetAttribute("effect"); + if (!string.IsNullOrEmpty(effectXmlAttribute)) + { + poco.Effect = (ParameterEffectKind)Enum.Parse(typeof(ParameterEffectKind), effectXmlAttribute, true); + } + + var isExceptionXmlAttribute = xmlReader.GetAttribute("isException"); + if (!string.IsNullOrEmpty(isExceptionXmlAttribute)) + { + poco.IsException = bool.Parse(isExceptionXmlAttribute); + } + + var isOrderedXmlAttribute = xmlReader.GetAttribute("isOrdered"); + if (!string.IsNullOrEmpty(isOrderedXmlAttribute)) + { + poco.IsOrdered = bool.Parse(isOrderedXmlAttribute); + } + + var isStreamXmlAttribute = xmlReader.GetAttribute("isStream"); + if (!string.IsNullOrEmpty(isStreamXmlAttribute)) + { + poco.IsStream = bool.Parse(isStreamXmlAttribute); + } + + var isUniqueXmlAttribute = xmlReader.GetAttribute("isUnique"); + if (!string.IsNullOrEmpty(isUniqueXmlAttribute)) + { + poco.IsUnique = bool.Parse(isUniqueXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var operationXmlAttribute = xmlReader.GetAttribute("operation"); + if (!string.IsNullOrEmpty(operationXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("operation", operationXmlAttribute); + } + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var parameterSetXmlAttribute = xmlReader.GetAttribute("parameterSet"); + if (!string.IsNullOrEmpty(parameterSetXmlAttribute)) + { + var parameterSetXmlAttributeValues = parameterSetXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("parameterSet", parameterSetXmlAttributeValues); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var typeXmlAttribute = xmlReader.GetAttribute("type"); + if (!string.IsNullOrEmpty(typeXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("type", typeXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var parameterSetValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "defaultValue": + var defaultValueValue = (IValueSpecification)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.DefaultValue.Add(defaultValueValue); + break; + case "direction": + var directionValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(directionValue)) + { + poco.Direction = (ParameterDirectionKind)Enum.Parse(typeof(ParameterDirectionKind), directionValue, true); ; + } + break; + case "effect": + var effectValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(effectValue)) + { + poco.Effect = (ParameterEffectKind)Enum.Parse(typeof(ParameterEffectKind), effectValue, true); ; + } + break; + case "isException": + var isExceptionValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isExceptionValue)) + { + poco.IsException = bool.Parse(isExceptionValue); + } + break; + case "isOrdered": + var isOrderedValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isOrderedValue)) + { + poco.IsOrdered = bool.Parse(isOrderedValue); + } + break; + case "isStream": + var isStreamValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isStreamValue)) + { + poco.IsStream = bool.Parse(isStreamValue); + } + break; + case "isUnique": + var isUniqueValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isUniqueValue)) + { + poco.IsUnique = bool.Parse(isUniqueValue); + } + break; + case "lowerValue": + var lowerValueValue = (IValueSpecification)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.LowerValue.Add(lowerValueValue); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "operation": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "operation"); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "parameterSet": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, parameterSetValues, "parameterSet"); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "type": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "type"); + break; + case "upperValue": + var upperValueValue = (IValueSpecification)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.UpperValue.Add(upperValueValue); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"ParameterReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (parameterSetValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("parameterSet", parameterSetValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/PrimitiveTypeReader.cs b/uml4net.xmi/AutoGenXmiReaders/PrimitiveTypeReader.cs new file mode 100644 index 00000000..919d4922 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/PrimitiveTypeReader.cs @@ -0,0 +1,329 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.SimpleClassifiers +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class PrimitiveTypeReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public PrimitiveTypeReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IPrimitiveType Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IPrimitiveType poco = new PrimitiveType(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:PrimitiveType") + { + throw new XmlException($"The XmiType should be 'uml:PrimitiveType' while it is {xmiType}"); + } + else + { + xmiType = "uml:PrimitiveType"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var isAbstractXmlAttribute = xmlReader.GetAttribute("isAbstract"); + if (!string.IsNullOrEmpty(isAbstractXmlAttribute)) + { + poco.IsAbstract = bool.Parse(isAbstractXmlAttribute); + } + + var isFinalSpecializationXmlAttribute = xmlReader.GetAttribute("isFinalSpecialization"); + if (!string.IsNullOrEmpty(isFinalSpecializationXmlAttribute)) + { + poco.IsFinalSpecialization = bool.Parse(isFinalSpecializationXmlAttribute); + } + + var isLeafXmlAttribute = xmlReader.GetAttribute("isLeaf"); + if (!string.IsNullOrEmpty(isLeafXmlAttribute)) + { + poco.IsLeaf = bool.Parse(isLeafXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var packageXmlAttribute = xmlReader.GetAttribute("package"); + if (!string.IsNullOrEmpty(packageXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("package", packageXmlAttribute); + } + + var powertypeExtentXmlAttribute = xmlReader.GetAttribute("powertypeExtent"); + if (!string.IsNullOrEmpty(powertypeExtentXmlAttribute)) + { + var powertypeExtentXmlAttributeValues = powertypeExtentXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("powertypeExtent", powertypeExtentXmlAttributeValues); + } + + var redefinedClassifierXmlAttribute = xmlReader.GetAttribute("redefinedClassifier"); + if (!string.IsNullOrEmpty(redefinedClassifierXmlAttribute)) + { + var redefinedClassifierXmlAttributeValues = redefinedClassifierXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedClassifier", redefinedClassifierXmlAttributeValues); + } + + var representationXmlAttribute = xmlReader.GetAttribute("representation"); + if (!string.IsNullOrEmpty(representationXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("representation", representationXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var useCasesXmlAttribute = xmlReader.GetAttribute("useCases"); + if (!string.IsNullOrEmpty(useCasesXmlAttribute)) + { + var useCasesXmlAttributeValues = useCasesXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("useCases", useCasesXmlAttributeValues); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var powertypeExtentValues = new List(); + var redefinedClassifierValues = new List(); + var useCasesValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "collaborationUse": + var collaborationUseValue = (ICollaborationUse)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:CollaborationUse"); + poco.CollaborationUse.Add(collaborationUseValue); + break; + case "elementImport": + var elementImportValue = (IElementImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ElementImport"); + poco.ElementImport.Add(elementImportValue); + break; + case "generalization": + var generalizationValue = (IGeneralization)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Generalization"); + poco.Generalization.Add(generalizationValue); + break; + case "isAbstract": + var isAbstractValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isAbstractValue)) + { + poco.IsAbstract = bool.Parse(isAbstractValue); + } + break; + case "isFinalSpecialization": + var isFinalSpecializationValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isFinalSpecializationValue)) + { + poco.IsFinalSpecialization = bool.Parse(isFinalSpecializationValue); + } + break; + case "isLeaf": + var isLeafValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isLeafValue)) + { + poco.IsLeaf = bool.Parse(isLeafValue); + } + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedAttribute": + var ownedAttributeValue = (IProperty)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Property"); + poco.OwnedAttribute.Add(ownedAttributeValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "ownedOperation": + var ownedOperationValue = (IOperation)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Operation"); + poco.OwnedOperation.Add(ownedOperationValue); + break; + case "ownedRule": + var ownedRuleValue = (IConstraint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Constraint"); + poco.OwnedRule.Add(ownedRuleValue); + break; + case "ownedTemplateSignature": + var ownedTemplateSignatureValue = (IRedefinableTemplateSignature)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:RedefinableTemplateSignature"); + poco.OwnedTemplateSignature.Add(ownedTemplateSignatureValue); + break; + case "ownedUseCase": + var ownedUseCaseValue = (IUseCase)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:UseCase"); + poco.OwnedUseCase.Add(ownedUseCaseValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "package": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "package"); + break; + case "packageImport": + var packageImportValue = (IPackageImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:PackageImport"); + poco.PackageImport.Add(packageImportValue); + break; + case "powertypeExtent": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, powertypeExtentValues, "powertypeExtent"); + break; + case "redefinedClassifier": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, redefinedClassifierValues, "redefinedClassifier"); + break; + case "representation": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "representation"); + break; + case "substitution": + var substitutionValue = (ISubstitution)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Substitution"); + poco.Substitution.Add(substitutionValue); + break; + case "templateBinding": + var templateBindingValue = (ITemplateBinding)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateBinding"); + poco.TemplateBinding.Add(templateBindingValue); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "useCases": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, useCasesValues, "useCases"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"PrimitiveTypeReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (powertypeExtentValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("powertypeExtent", powertypeExtentValues); + } + + if (redefinedClassifierValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedClassifier", redefinedClassifierValues); + } + + if (useCasesValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("useCases", useCasesValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/Classification/PropertyReader.cs b/uml4net.xmi/AutoGenXmiReaders/PropertyReader.cs similarity index 100% rename from uml4net.xmi/Readers/Classification/PropertyReader.cs rename to uml4net.xmi/AutoGenXmiReaders/PropertyReader.cs diff --git a/uml4net.xmi/AutoGenXmiReaders/RealizationReader.cs b/uml4net.xmi/AutoGenXmiReaders/RealizationReader.cs new file mode 100644 index 00000000..d5e9d96c --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/RealizationReader.cs @@ -0,0 +1,216 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.CommonStructure +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class RealizationReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public RealizationReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IRealization Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IRealization poco = new Realization(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Realization") + { + throw new XmlException($"The XmiType should be 'uml:Realization' while it is {xmiType}"); + } + else + { + xmiType = "uml:Realization"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var clientXmlAttribute = xmlReader.GetAttribute("client"); + if (!string.IsNullOrEmpty(clientXmlAttribute)) + { + var clientXmlAttributeValues = clientXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("client", clientXmlAttributeValues); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var supplierXmlAttribute = xmlReader.GetAttribute("supplier"); + if (!string.IsNullOrEmpty(supplierXmlAttribute)) + { + var supplierXmlAttributeValues = supplierXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("supplier", supplierXmlAttributeValues); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var clientValues = new List(); + var supplierValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "client": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, clientValues, "client"); + break; + case "mapping": + var mappingValue = (IOpaqueExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:OpaqueExpression"); + poco.Mapping.Add(mappingValue); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "supplier": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, supplierValues, "supplier"); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"RealizationReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (clientValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("client", clientValues); + } + + if (supplierValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("supplier", supplierValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/ReceptionReader.cs b/uml4net.xmi/AutoGenXmiReaders/ReceptionReader.cs new file mode 100644 index 00000000..ba14734a --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/ReceptionReader.cs @@ -0,0 +1,275 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.SimpleClassifiers +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class ReceptionReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public ReceptionReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IReception Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IReception poco = new Reception(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Reception") + { + throw new XmlException($"The XmiType should be 'uml:Reception' while it is {xmiType}"); + } + else + { + xmiType = "uml:Reception"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var concurrencyXmlAttribute = xmlReader.GetAttribute("concurrency"); + if (!string.IsNullOrEmpty(concurrencyXmlAttribute)) + { + poco.Concurrency = (CallConcurrencyKind)Enum.Parse(typeof(CallConcurrencyKind), concurrencyXmlAttribute, true); + } + + var isAbstractXmlAttribute = xmlReader.GetAttribute("isAbstract"); + if (!string.IsNullOrEmpty(isAbstractXmlAttribute)) + { + poco.IsAbstract = bool.Parse(isAbstractXmlAttribute); + } + + var isLeafXmlAttribute = xmlReader.GetAttribute("isLeaf"); + if (!string.IsNullOrEmpty(isLeafXmlAttribute)) + { + poco.IsLeaf = bool.Parse(isLeafXmlAttribute); + } + + var isStaticXmlAttribute = xmlReader.GetAttribute("isStatic"); + if (!string.IsNullOrEmpty(isStaticXmlAttribute)) + { + poco.IsStatic = bool.Parse(isStaticXmlAttribute); + } + + var methodXmlAttribute = xmlReader.GetAttribute("method"); + if (!string.IsNullOrEmpty(methodXmlAttribute)) + { + var methodXmlAttributeValues = methodXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("method", methodXmlAttributeValues); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var raisedExceptionXmlAttribute = xmlReader.GetAttribute("raisedException"); + if (!string.IsNullOrEmpty(raisedExceptionXmlAttribute)) + { + var raisedExceptionXmlAttributeValues = raisedExceptionXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("raisedException", raisedExceptionXmlAttributeValues); + } + + var signalXmlAttribute = xmlReader.GetAttribute("signal"); + if (!string.IsNullOrEmpty(signalXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("signal", signalXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var methodValues = new List(); + var raisedExceptionValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "concurrency": + var concurrencyValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(concurrencyValue)) + { + poco.Concurrency = (CallConcurrencyKind)Enum.Parse(typeof(CallConcurrencyKind), concurrencyValue, true); ; + } + break; + case "elementImport": + var elementImportValue = (IElementImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ElementImport"); + poco.ElementImport.Add(elementImportValue); + break; + case "isAbstract": + var isAbstractValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isAbstractValue)) + { + poco.IsAbstract = bool.Parse(isAbstractValue); + } + break; + case "isLeaf": + var isLeafValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isLeafValue)) + { + poco.IsLeaf = bool.Parse(isLeafValue); + } + break; + case "isStatic": + var isStaticValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isStaticValue)) + { + poco.IsStatic = bool.Parse(isStaticValue); + } + break; + case "method": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, methodValues, "method"); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "ownedParameter": + var ownedParameterValue = (IParameter)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Parameter"); + poco.OwnedParameter.Add(ownedParameterValue); + break; + case "ownedParameterSet": + var ownedParameterSetValue = (IParameterSet)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ParameterSet"); + poco.OwnedParameterSet.Add(ownedParameterSetValue); + break; + case "ownedRule": + var ownedRuleValue = (IConstraint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Constraint"); + poco.OwnedRule.Add(ownedRuleValue); + break; + case "packageImport": + var packageImportValue = (IPackageImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:PackageImport"); + poco.PackageImport.Add(packageImportValue); + break; + case "raisedException": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, raisedExceptionValues, "raisedException"); + break; + case "signal": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "signal"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"ReceptionReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (methodValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("method", methodValues); + } + + if (raisedExceptionValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("raisedException", raisedExceptionValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/RedefinableTemplateSignatureReader.cs b/uml4net.xmi/AutoGenXmiReaders/RedefinableTemplateSignatureReader.cs new file mode 100644 index 00000000..31b04b07 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/RedefinableTemplateSignatureReader.cs @@ -0,0 +1,220 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.Classification +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class RedefinableTemplateSignatureReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public RedefinableTemplateSignatureReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IRedefinableTemplateSignature Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IRedefinableTemplateSignature poco = new RedefinableTemplateSignature(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:RedefinableTemplateSignature") + { + throw new XmlException($"The XmiType should be 'uml:RedefinableTemplateSignature' while it is {xmiType}"); + } + else + { + xmiType = "uml:RedefinableTemplateSignature"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var classifierXmlAttribute = xmlReader.GetAttribute("classifier"); + if (!string.IsNullOrEmpty(classifierXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("classifier", classifierXmlAttribute); + } + + var extendedSignatureXmlAttribute = xmlReader.GetAttribute("extendedSignature"); + if (!string.IsNullOrEmpty(extendedSignatureXmlAttribute)) + { + var extendedSignatureXmlAttributeValues = extendedSignatureXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("extendedSignature", extendedSignatureXmlAttributeValues); + } + + var isLeafXmlAttribute = xmlReader.GetAttribute("isLeaf"); + if (!string.IsNullOrEmpty(isLeafXmlAttribute)) + { + poco.IsLeaf = bool.Parse(isLeafXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var parameterXmlAttribute = xmlReader.GetAttribute("parameter"); + if (!string.IsNullOrEmpty(parameterXmlAttribute)) + { + var parameterXmlAttributeValues = parameterXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("parameter", parameterXmlAttributeValues); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var extendedSignatureValues = new List(); + var parameterValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "classifier": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "classifier"); + break; + case "extendedSignature": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, extendedSignatureValues, "extendedSignature"); + break; + case "isLeaf": + var isLeafValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isLeafValue)) + { + poco.IsLeaf = bool.Parse(isLeafValue); + } + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "ownedParameter": + var ownedParameterValue = (ITemplateParameter)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateParameter"); + poco.OwnedParameter.Add(ownedParameterValue); + break; + case "parameter": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, parameterValues, "parameter"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"RedefinableTemplateSignatureReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (extendedSignatureValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("extendedSignature", extendedSignatureValues); + } + + if (parameterValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("parameter", parameterValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/StringExpressionReader.cs b/uml4net.xmi/AutoGenXmiReaders/StringExpressionReader.cs new file mode 100644 index 00000000..85e29d18 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/StringExpressionReader.cs @@ -0,0 +1,219 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.Values +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class StringExpressionReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public StringExpressionReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IStringExpression Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IStringExpression poco = new StringExpression(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:StringExpression") + { + throw new XmlException($"The XmiType should be 'uml:StringExpression' while it is {xmiType}"); + } + else + { + xmiType = "uml:StringExpression"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + poco.Name = xmlReader.GetAttribute("name"); + + var owningExpressionXmlAttribute = xmlReader.GetAttribute("owningExpression"); + if (!string.IsNullOrEmpty(owningExpressionXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningExpression", owningExpressionXmlAttribute); + } + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + poco.Symbol = xmlReader.GetAttribute("symbol"); + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var typeXmlAttribute = xmlReader.GetAttribute("type"); + if (!string.IsNullOrEmpty(typeXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("type", typeXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "operand": + var operandValue = (IValueSpecification)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.Operand.Add(operandValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "ownedTemplateSignature": + var ownedTemplateSignatureValue = (ITemplateSignature)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateSignature"); + poco.OwnedTemplateSignature.Add(ownedTemplateSignatureValue); + break; + case "owningExpression": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningExpression"); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "subExpression": + var subExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.SubExpression.Add(subExpressionValue); + break; + case "symbol": + poco.Symbol = xmlReader.ReadElementContentAsString(); + break; + case "templateBinding": + var templateBindingValue = (ITemplateBinding)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateBinding"); + poco.TemplateBinding.Add(templateBindingValue); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "type": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "type"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"StringExpressionReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/AutoGenXmiReaders/SubstitutionReader.cs b/uml4net.xmi/AutoGenXmiReaders/SubstitutionReader.cs new file mode 100644 index 00000000..3c57d013 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/SubstitutionReader.cs @@ -0,0 +1,234 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.Classification +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class SubstitutionReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public SubstitutionReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override ISubstitution Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + ISubstitution poco = new Substitution(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Substitution") + { + throw new XmlException($"The XmiType should be 'uml:Substitution' while it is {xmiType}"); + } + else + { + xmiType = "uml:Substitution"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var clientXmlAttribute = xmlReader.GetAttribute("client"); + if (!string.IsNullOrEmpty(clientXmlAttribute)) + { + var clientXmlAttributeValues = clientXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("client", clientXmlAttributeValues); + } + + var contractXmlAttribute = xmlReader.GetAttribute("contract"); + if (!string.IsNullOrEmpty(contractXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("contract", contractXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var substitutingClassifierXmlAttribute = xmlReader.GetAttribute("substitutingClassifier"); + if (!string.IsNullOrEmpty(substitutingClassifierXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("substitutingClassifier", substitutingClassifierXmlAttribute); + } + + var supplierXmlAttribute = xmlReader.GetAttribute("supplier"); + if (!string.IsNullOrEmpty(supplierXmlAttribute)) + { + var supplierXmlAttributeValues = supplierXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("supplier", supplierXmlAttributeValues); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var clientValues = new List(); + var supplierValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "client": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, clientValues, "client"); + break; + case "contract": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "contract"); + break; + case "mapping": + var mappingValue = (IOpaqueExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:OpaqueExpression"); + poco.Mapping.Add(mappingValue); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "substitutingClassifier": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "substitutingClassifier"); + break; + case "supplier": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, supplierValues, "supplier"); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"SubstitutionReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (clientValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("client", clientValues); + } + + if (supplierValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("supplier", supplierValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/CommonStructure/TemplateBindingReader.cs b/uml4net.xmi/AutoGenXmiReaders/TemplateBindingReader.cs similarity index 64% rename from uml4net.xmi/Readers/CommonStructure/TemplateBindingReader.cs rename to uml4net.xmi/AutoGenXmiReaders/TemplateBindingReader.cs index a1ee2c33..99d4a6a7 100644 --- a/uml4net.xmi/Readers/CommonStructure/TemplateBindingReader.cs +++ b/uml4net.xmi/AutoGenXmiReaders/TemplateBindingReader.cs @@ -32,21 +32,22 @@ namespace uml4net.xmi.Readers.CommonStructure using Microsoft.Extensions.Logging; using uml4net; + using uml4net.Actions; + using uml4net.Activities; using uml4net.Classification; using uml4net.CommonBehavior; using uml4net.CommonStructure; using uml4net.Deployments; + using uml4net.Interactions; using uml4net.Packages; using uml4net.SimpleClassifiers; + using uml4net.StateMachines; using uml4net.StructuredClassifiers; using uml4net.UseCases; using uml4net.Utils; using uml4net.Values; using uml4net.xmi.Cache; using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; /// /// The purpose of the is to read an instance of @@ -107,6 +108,48 @@ public override ITemplateBinding Read(XmlReader xmlReader) poco.XmiId = xmlReader.GetAttribute("xmi:id"); this.Cache.Add(poco.XmiId, poco); + + var boundElementXmlAttribute = xmlReader.GetAttribute("boundElement"); + if (!string.IsNullOrEmpty(boundElementXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("boundElement", boundElementXmlAttribute); + } + + var signatureXmlAttribute = xmlReader.GetAttribute("signature"); + if (!string.IsNullOrEmpty(signatureXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("signature", signatureXmlAttribute); + } + + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "boundElement": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "boundElement"); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "parameterSubstitution": + var parameterSubstitutionValue = (ITemplateParameterSubstitution)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateParameterSubstitution"); + poco.ParameterSubstitution.Add(parameterSubstitutionValue); + break; + case "signature": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "signature"); + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"TemplateBindingReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + } return poco; diff --git a/uml4net.xmi/AutoGenXmiReaders/UseCaseReader.cs b/uml4net.xmi/AutoGenXmiReaders/UseCaseReader.cs new file mode 100644 index 00000000..148d6635 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/UseCaseReader.cs @@ -0,0 +1,366 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 Starion Group S.A. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// ------------------------------------------------------------------------------------------------ + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + +namespace uml4net.xmi.Readers.UseCases +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + using uml4net.xmi.Readers; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class UseCaseReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public UseCaseReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override IUseCase Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + IUseCase poco = new UseCase(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:UseCase") + { + throw new XmlException($"The XmiType should be 'uml:UseCase' while it is {xmiType}"); + } + else + { + xmiType = "uml:UseCase"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + var classifierBehaviorXmlAttribute = xmlReader.GetAttribute("classifierBehavior"); + if (!string.IsNullOrEmpty(classifierBehaviorXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("classifierBehavior", classifierBehaviorXmlAttribute); + } + + var isAbstractXmlAttribute = xmlReader.GetAttribute("isAbstract"); + if (!string.IsNullOrEmpty(isAbstractXmlAttribute)) + { + poco.IsAbstract = bool.Parse(isAbstractXmlAttribute); + } + + var isFinalSpecializationXmlAttribute = xmlReader.GetAttribute("isFinalSpecialization"); + if (!string.IsNullOrEmpty(isFinalSpecializationXmlAttribute)) + { + poco.IsFinalSpecialization = bool.Parse(isFinalSpecializationXmlAttribute); + } + + var isLeafXmlAttribute = xmlReader.GetAttribute("isLeaf"); + if (!string.IsNullOrEmpty(isLeafXmlAttribute)) + { + poco.IsLeaf = bool.Parse(isLeafXmlAttribute); + } + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var packageXmlAttribute = xmlReader.GetAttribute("package"); + if (!string.IsNullOrEmpty(packageXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("package", packageXmlAttribute); + } + + var powertypeExtentXmlAttribute = xmlReader.GetAttribute("powertypeExtent"); + if (!string.IsNullOrEmpty(powertypeExtentXmlAttribute)) + { + var powertypeExtentXmlAttributeValues = powertypeExtentXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("powertypeExtent", powertypeExtentXmlAttributeValues); + } + + var redefinedClassifierXmlAttribute = xmlReader.GetAttribute("redefinedClassifier"); + if (!string.IsNullOrEmpty(redefinedClassifierXmlAttribute)) + { + var redefinedClassifierXmlAttributeValues = redefinedClassifierXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedClassifier", redefinedClassifierXmlAttributeValues); + } + + var representationXmlAttribute = xmlReader.GetAttribute("representation"); + if (!string.IsNullOrEmpty(representationXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("representation", representationXmlAttribute); + } + + var subjectXmlAttribute = xmlReader.GetAttribute("subject"); + if (!string.IsNullOrEmpty(subjectXmlAttribute)) + { + var subjectXmlAttributeValues = subjectXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("subject", subjectXmlAttributeValues); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var useCasesXmlAttribute = xmlReader.GetAttribute("useCases"); + if (!string.IsNullOrEmpty(useCasesXmlAttribute)) + { + var useCasesXmlAttributeValues = useCasesXmlAttribute.Split(SplitMultiReference, StringSplitOptions.RemoveEmptyEntries).ToList(); + poco.MultiValueReferencePropertyIdentifiers.Add("useCases", useCasesXmlAttributeValues); + } + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + var powertypeExtentValues = new List(); + var redefinedClassifierValues = new List(); + var subjectValues = new List(); + var useCasesValues = new List(); + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "classifierBehavior": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "classifierBehavior"); + break; + case "collaborationUse": + var collaborationUseValue = (ICollaborationUse)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:CollaborationUse"); + poco.CollaborationUse.Add(collaborationUseValue); + break; + case "elementImport": + var elementImportValue = (IElementImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ElementImport"); + poco.ElementImport.Add(elementImportValue); + break; + case "extend": + var extendValue = (IExtend)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Extend"); + poco.Extend.Add(extendValue); + break; + case "extensionPoint": + var extensionPointValue = (IExtensionPoint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ExtensionPoint"); + poco.ExtensionPoint.Add(extensionPointValue); + break; + case "generalization": + var generalizationValue = (IGeneralization)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Generalization"); + poco.Generalization.Add(generalizationValue); + break; + case "include": + var includeValue = (IInclude)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Include"); + poco.Include.Add(includeValue); + break; + case "interfaceRealization": + var interfaceRealizationValue = (IInterfaceRealization)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:InterfaceRealization"); + poco.InterfaceRealization.Add(interfaceRealizationValue); + break; + case "isAbstract": + var isAbstractValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isAbstractValue)) + { + poco.IsAbstract = bool.Parse(isAbstractValue); + } + break; + case "isFinalSpecialization": + var isFinalSpecializationValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isFinalSpecializationValue)) + { + poco.IsFinalSpecialization = bool.Parse(isFinalSpecializationValue); + } + break; + case "isLeaf": + var isLeafValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(isLeafValue)) + { + poco.IsLeaf = bool.Parse(isLeafValue); + } + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedBehavior": + var ownedBehaviorValue = (IBehavior)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.OwnedBehavior.Add(ownedBehaviorValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "ownedRule": + var ownedRuleValue = (IConstraint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Constraint"); + poco.OwnedRule.Add(ownedRuleValue); + break; + case "ownedTemplateSignature": + var ownedTemplateSignatureValue = (IRedefinableTemplateSignature)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:RedefinableTemplateSignature"); + poco.OwnedTemplateSignature.Add(ownedTemplateSignatureValue); + break; + case "ownedUseCase": + var ownedUseCaseValue = (IUseCase)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:UseCase"); + poco.OwnedUseCase.Add(ownedUseCaseValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "package": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "package"); + break; + case "packageImport": + var packageImportValue = (IPackageImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:PackageImport"); + poco.PackageImport.Add(packageImportValue); + break; + case "powertypeExtent": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, powertypeExtentValues, "powertypeExtent"); + break; + case "redefinedClassifier": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, redefinedClassifierValues, "redefinedClassifier"); + break; + case "representation": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "representation"); + break; + case "subject": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, subjectValues, "subject"); + break; + case "substitution": + var substitutionValue = (ISubstitution)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Substitution"); + poco.Substitution.Add(substitutionValue); + break; + case "templateBinding": + var templateBindingValue = (ITemplateBinding)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateBinding"); + poco.TemplateBinding.Add(templateBindingValue); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "useCases": + this.CollectMultiValueReferencePropertyIdentifiers(xmlReader, useCasesValues, "useCases"); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + var defaultLineInfo = xmlReader as IXmlLineInfo; + throw new NotSupportedException($"UseCaseReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + + if (powertypeExtentValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("powertypeExtent", powertypeExtentValues); + } + + if (redefinedClassifierValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("redefinedClassifier", redefinedClassifierValues); + } + + if (subjectValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("subject", subjectValues); + } + + if (useCasesValues.Count > 0) + { + poco.MultiValueReferencePropertyIdentifiers.Add("useCases", useCasesValues); + } + + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/Classification/InstanceValueReader.cs b/uml4net.xmi/Readers/Classification/InstanceValueReader.cs deleted file mode 100644 index eea04d94..00000000 --- a/uml4net.xmi/Readers/Classification/InstanceValueReader.cs +++ /dev/null @@ -1,145 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.Classification -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class InstanceValueReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public InstanceValueReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IInstanceValue Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - IInstanceValue poco = new InstanceValue(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:InstanceValue") - { - throw new XmlException($"The XmiType should be 'uml:InstanceValue' while it is {xmiType}"); - } - else - { - xmiType = "uml:InstanceValue"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - poco.Name = xmlReader.GetAttribute("name"); - - var visibility = xmlReader.GetAttribute("visibility"); - if (!string.IsNullOrEmpty(visibility)) - { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibility, true); - } - - var type = xmlReader.GetAttribute("type"); - if (!string.IsNullOrEmpty(type)) - { - poco.SingleValueReferencePropertyIdentifiers.Add("type", type); - } - - var instance = xmlReader.GetAttribute("instance"); - if (!string.IsNullOrEmpty(instance)) - { - poco.SingleValueReferencePropertyIdentifiers.Add("instance", instance); - } - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"InstanceValueReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - } - - return poco; - } - } -} diff --git a/uml4net.xmi/Readers/Classification/ParameterReader.cs b/uml4net.xmi/Readers/Classification/ParameterReader.cs deleted file mode 100644 index e908e6df..00000000 --- a/uml4net.xmi/Readers/Classification/ParameterReader.cs +++ /dev/null @@ -1,230 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.Classification -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class ParameterReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public ParameterReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IParameter Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - IParameter poco = new Parameter(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Parameter") - { - throw new XmlException($"The XmiType should be 'uml:Parameter' while it is {xmiType}"); - } - else - { - xmiType = "uml:Parameter"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - poco.Name = xmlReader.GetAttribute("name"); - - var direction = xmlReader.GetAttribute("direction"); - if (!string.IsNullOrEmpty(direction)) - { - poco.Direction = (ParameterDirectionKind)Enum.Parse(typeof(ParameterDirectionKind), direction, true); - } - - var visibility = xmlReader.GetAttribute("visibility"); - if (!string.IsNullOrEmpty(visibility)) - { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibility, true); - } - - var type = xmlReader.GetAttribute("type"); - if (!string.IsNullOrEmpty(type)) - { - poco.SingleValueReferencePropertyIdentifiers.Add("type", type); - } - - var isOrdered = xmlReader.GetAttribute("isOrdered"); - if (!string.IsNullOrEmpty(isOrdered)) - { - poco.IsOrdered = bool.Parse(isOrdered); - } - - var isUnique = xmlReader.GetAttribute("isUnique"); - if (!string.IsNullOrEmpty(isUnique)) - { - poco.IsUnique = bool.Parse(isUnique); - } - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - case "type": - using (var typeXmlReader = xmlReader.ReadSubtree()) - { - if (typeXmlReader.MoveToContent() == XmlNodeType.Element) - { - var href = typeXmlReader.GetAttribute("href"); - if (!string.IsNullOrEmpty(href)) - { - poco.SingleValueReferencePropertyIdentifiers.Add("type", href); - } - else if (typeXmlReader.GetAttribute("xmi:idref") is { Length: > 0 } idRef) - { - poco.SingleValueReferencePropertyIdentifiers.Add("type", idRef); - } - else - { - throw new InvalidOperationException("type xml-attribute reference could not be read"); - } - } - } - break; - case "lowerValue": - using (var lowerValueXmlReader = xmlReader.ReadSubtree()) - { - if (lowerValueXmlReader.MoveToContent() == XmlNodeType.Element) - { - var reference = lowerValueXmlReader.GetAttribute("xmi:type"); - - switch (reference) - { - case "uml:LiteralInteger": - var literalIntegerReader = new LiteralIntegerReader(this.Cache, this.LoggerFactory); - var literalInteger = literalIntegerReader.Read(lowerValueXmlReader); - poco.LowerValue.Add(literalInteger); - break; - case "uml:LiteralUnlimitedNatural": - var literalUnlimitedNaturalReader = new LiteralUnlimitedNaturalReader(this.Cache, this.LoggerFactory); - var literalUnlimitedNatural = literalUnlimitedNaturalReader.Read(lowerValueXmlReader); - poco.LowerValue.Add(literalUnlimitedNatural); - break; - default: - throw new InvalidOperationException($"lowerValueXmlReader: type {reference} is unsupported."); - } - } - } - break; - case "upperValue": - using (var upperValueXmlReader = xmlReader.ReadSubtree()) - { - if (upperValueXmlReader.MoveToContent() == XmlNodeType.Element) - { - var reference = upperValueXmlReader.GetAttribute("xmi:type"); - if (!string.IsNullOrEmpty(reference)) - { - switch (reference) - { - case "uml:LiteralInteger": - var literalIntegerReader = new LiteralIntegerReader(this.Cache, this.LoggerFactory); - var literalInteger = literalIntegerReader.Read(upperValueXmlReader); - poco.UpperValue.Add(literalInteger); - break; - case "uml:LiteralUnlimitedNatural": - var literalUnlimitedNaturalReader = new LiteralUnlimitedNaturalReader(this.Cache, this.LoggerFactory); - var literalUnlimitedNatural = literalUnlimitedNaturalReader.Read(upperValueXmlReader); - poco.UpperValue.Add(literalUnlimitedNatural); - break; - default: - throw new InvalidOperationException($"upperValueXmlReader: type {reference} is unsupported."); - } - } - } - } - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"ParameterReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - } - - return poco; - } - } -} diff --git a/uml4net.xmi/Readers/Classification/RedefinableTemplateSignatureReader.cs b/uml4net.xmi/Readers/Classification/RedefinableTemplateSignatureReader.cs deleted file mode 100644 index 2484b45a..00000000 --- a/uml4net.xmi/Readers/Classification/RedefinableTemplateSignatureReader.cs +++ /dev/null @@ -1,119 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright (C) 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.Classification -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class RedefinableTemplateSignatureReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to set up logging - /// - public RedefinableTemplateSignatureReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IRedefinableTemplateSignature Read(XmlReader xmlReader) - { - if (xmlReader == null) - { - throw new ArgumentNullException(nameof(xmlReader)); - } - - IRedefinableTemplateSignature poco = new RedefinableTemplateSignature(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:RedefinableTemplateSignature") - { - throw new XmlException($"The XmiType should be 'uml:RedefinableTemplateSignature' while it is {xmiType}"); - } - else - { - xmiType = "uml:RedefinableTemplateSignature"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - } - - return poco; - } - } -} - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/Classification/SubstitutionReader.cs b/uml4net.xmi/Readers/Classification/SubstitutionReader.cs deleted file mode 100644 index 3b204116..00000000 --- a/uml4net.xmi/Readers/Classification/SubstitutionReader.cs +++ /dev/null @@ -1,119 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright (C) 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.Classification -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class SubstitutionReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to set up logging - /// - public SubstitutionReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override ISubstitution Read(XmlReader xmlReader) - { - if (xmlReader == null) - { - throw new ArgumentNullException(nameof(xmlReader)); - } - - ISubstitution poco = new Substitution(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Substitution") - { - throw new XmlException($"The XmiType should be 'uml:Substitution' while it is {xmiType}"); - } - else - { - xmiType = "uml:Substitution"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - } - - return poco; - } - } -} - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/CommonStructure/CommentReader.cs b/uml4net.xmi/Readers/CommonStructure/CommentReader.cs deleted file mode 100644 index 3f0b760a..00000000 --- a/uml4net.xmi/Readers/CommonStructure/CommentReader.cs +++ /dev/null @@ -1,160 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.CommonStructure -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class CommentReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public CommentReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IComment Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - IComment comment = new Comment(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Comment") - { - throw new XmlException($"The XmiType should be 'uml:Comment' while it is {xmiType}"); - } - else - { - xmiType = "uml:Comment"; - } - - comment.XmiType = xmiType; - - comment.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(comment.XmiId, comment); - - comment.Body = xmlReader.GetAttribute("body"); - - var annotatedElementXmlAttribute = xmlReader.GetAttribute("annotatedElement"); - if (!string.IsNullOrEmpty(annotatedElementXmlAttribute)) - { - comment.MultiValueReferencePropertyIdentifiers.Add("annotatedElement", annotatedElementXmlAttribute.Split([' '], StringSplitOptions.RemoveEmptyEntries).ToList()); - } - - var annotatedElement = new List(); - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "annotatedElement": - using (var annotatedElementXmlReader = xmlReader.ReadSubtree()) - { - if (annotatedElementXmlReader.MoveToContent() == XmlNodeType.Element) - { - var href = annotatedElementXmlReader.GetAttribute("href"); - if (!string.IsNullOrEmpty(href)) - { - annotatedElement.Add(href); - } - else if (annotatedElementXmlReader.GetAttribute("xmi:idref") is { Length: > 0 } idRef) - { - annotatedElement.Add(idRef); - } - else - { - throw new InvalidOperationException("annotatedElement xml-attribute reference could not be read"); - } - } - } - break; - case "body": - comment.Body = xmlReader.ReadElementContentAsString(); - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"CommentReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - - if (annotatedElement.Count > 0) - { - comment.MultiValueReferencePropertyIdentifiers.Add("annotatedElement", annotatedElement); - } - } - - return comment; - } - } -} diff --git a/uml4net.xmi/Readers/CommonStructure/ConstraintReader.cs b/uml4net.xmi/Readers/CommonStructure/ConstraintReader.cs deleted file mode 100644 index d3824f63..00000000 --- a/uml4net.xmi/Readers/CommonStructure/ConstraintReader.cs +++ /dev/null @@ -1,186 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.CommonStructure -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class ConstraintReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > are stored - /// - /// - /// The - /// - public ConstraintReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IConstraint Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - IConstraint poco = new Constraint(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Constraint") - { - throw new XmlException($"The XmiType should be 'uml:Constraint' while it is {xmiType}"); - } - else - { - xmiType = "uml:Constraint"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - var constrainedElement = new List(); - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "constrainedElement": - - using (var constrainedElementXmlReader = xmlReader.ReadSubtree()) - { - if (constrainedElementXmlReader.MoveToContent() == XmlNodeType.Element) - { - var href = constrainedElementXmlReader.GetAttribute("href"); - if (!string.IsNullOrEmpty(href)) - { - constrainedElement.Add(href); - } - else if (constrainedElementXmlReader.GetAttribute("xmi:idref") is { Length: > 0 } idRef) - { - constrainedElement.Add(idRef); - } - else - { - throw new InvalidOperationException("constrainedElement xml-attribute reference could not be read"); - } - } - } - - break; - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - case "specification": - this.ReadValueSpecification(poco, xmlReader); - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"ConstraintReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - - if (constrainedElement.Count > 0) - { - poco.MultiValueReferencePropertyIdentifiers.Add("ConstrainedElement", constrainedElement); - } - } - - return poco; - } - - /// - /// Read the packaged elements - /// - /// - /// The that the nested > elements are added to - /// - /// - /// an instance of - /// - private void ReadValueSpecification(IConstraint constraint, XmlReader xmlReader) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - switch (xmiType) - { - case "uml:OpaqueExpression": - using (var opaqueExpressionXmlReader = xmlReader.ReadSubtree()) - { - var opaqueExpressionReader = new OpaqueExpressionReader(this.Cache, this.LoggerFactory); - var opaqueExpression = opaqueExpressionReader.Read(opaqueExpressionXmlReader); - constraint.Specification.Add(opaqueExpression); - } - break; - default: - throw new NotSupportedException(xmiType); - } - } - } -} diff --git a/uml4net.xmi/Readers/CommonStructure/PackageImportReader.cs b/uml4net.xmi/Readers/CommonStructure/PackageImportReader.cs deleted file mode 100644 index f67c6c27..00000000 --- a/uml4net.xmi/Readers/CommonStructure/PackageImportReader.cs +++ /dev/null @@ -1,122 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright (C) 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.CommonStructure -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class PackageImportReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The - /// - public PackageImportReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the - /// - /// - /// the active > - /// - /// - /// an instance of - /// - public override IPackageImport Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - var packageImport = new PackageImport(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:PackageImport") - { - throw new XmlException($"The XmiType should be 'uml:PackageImport' while it is {xmiType}"); - } - else - { - xmiType = "uml:PackageImport"; - } - - packageImport.XmiId = xmlReader.GetAttribute("xmi:id"); - - var importedPackage = xmlReader.GetAttribute("importedPackage"); - if (!string.IsNullOrEmpty(importedPackage)) - { - packageImport.SingleValueReferencePropertyIdentifiers.Add("ImportedPackage", importedPackage); - } - - var importingNamespace = xmlReader.GetAttribute("importingNamespace"); - if (!string.IsNullOrEmpty(importingNamespace)) - { - packageImport.SingleValueReferencePropertyIdentifiers.Add("ImportingNamespace", importingNamespace); - } - - string visibility = xmlReader.GetAttribute("visibility"); - if (visibility != null) - { - packageImport.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibility, true); - } - } - - return packageImport; - } - } -} diff --git a/uml4net.xmi/Readers/CommonStructure/RealizationReader.cs b/uml4net.xmi/Readers/CommonStructure/RealizationReader.cs deleted file mode 100644 index 800db6fa..00000000 --- a/uml4net.xmi/Readers/CommonStructure/RealizationReader.cs +++ /dev/null @@ -1,120 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.CommonStructure -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class RealizationReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public RealizationReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IRealization Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - IRealization realization = new Realization(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Realization") - { - throw new XmlException($"The XmiType should be 'uml:Realization' while it is {xmiType}"); - } - else - { - xmiType = "uml:Realization"; - } - - realization.XmiType = xmiType; - - realization.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(realization.XmiId, realization); - - var clientIds = xmlReader.GetAttribute("client"); - if (!string.IsNullOrEmpty(clientIds)) - { - realization.MultiValueReferencePropertyIdentifiers.Add("Client", clientIds.Split([' '], StringSplitOptions.RemoveEmptyEntries).ToList()); - } - - var supplierIds = xmlReader.GetAttribute("supplier"); - if (!string.IsNullOrEmpty(supplierIds)) - { - realization.MultiValueReferencePropertyIdentifiers.Add("Supplier", supplierIds.Split([' '], StringSplitOptions.RemoveEmptyEntries).ToList()); - } - } - - return realization; - } - } -} diff --git a/uml4net.xmi/Readers/Packages/ModelReader.cs b/uml4net.xmi/Readers/Packages/ModelReader.cs index 74a56bfb..798a2ccd 100644 --- a/uml4net.xmi/Readers/Packages/ModelReader.cs +++ b/uml4net.xmi/Readers/Packages/ModelReader.cs @@ -9,7 +9,7 @@ // // http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, softwareUseCases +// Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and @@ -18,6 +18,10 @@ // // ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + namespace uml4net.xmi.Readers.Packages { using System; @@ -26,24 +30,24 @@ namespace uml4net.xmi.Readers.Packages using System.Xml; using Microsoft.Extensions.Logging; - using SimpleClassifiers; - using StructuredClassifiers; + using uml4net; + using uml4net.Actions; + using uml4net.Activities; using uml4net.Classification; using uml4net.CommonBehavior; using uml4net.CommonStructure; using uml4net.Deployments; + using uml4net.Interactions; using uml4net.Packages; using uml4net.SimpleClassifiers; + using uml4net.StateMachines; using uml4net.StructuredClassifiers; using uml4net.UseCases; using uml4net.Utils; using uml4net.Values; using uml4net.xmi.Cache; using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; /// /// The purpose of the is to read an instance of @@ -54,13 +58,13 @@ public class ModelReader : XmiElementReader, IXmiElementReader private readonly IXmiElementReaderFacade xmiElementReaderFacade; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// /// The cache in which each > is stored /// - /// - /// The (injected) used to setup logging + /// + /// The (injected) used to set up logging /// public ModelReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) : base(cache, loggerFactory) @@ -69,19 +73,22 @@ public ModelReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) } /// - /// Reads the object from its XML representation + /// Reads the object from its XML representation /// /// - /// an instance of + /// an instance of /// /// - /// an instance of + /// an instance of /// public override IModel Read(XmlReader xmlReader) { - Guard.ThrowIfNull(xmlReader); + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } - IModel model = new Model(); + IModel poco = new Model(); if (xmlReader.MoveToContent() == XmlNodeType.Element) { @@ -89,22 +96,50 @@ public override IModel Read(XmlReader xmlReader) if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Model") { - throw new XmlException($"The XmiType should be: uml:Model while it is {xmiType}"); + throw new XmlException($"The XmiType should be 'uml:Model' while it is {xmiType}"); } else { xmiType = "uml:Model"; } - model.XmiType = xmiType; + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + poco.Name = xmlReader.GetAttribute("name"); + + var nestingPackageXmlAttribute = xmlReader.GetAttribute("nestingPackage"); + if (!string.IsNullOrEmpty(nestingPackageXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("nestingPackage", nestingPackageXmlAttribute); + } + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + poco.URI = xmlReader.GetAttribute("URI"); - model.Name = xmlReader.GetAttribute("name"); + poco.Viewpoint = xmlReader.GetAttribute("viewpoint"); - model.URI = xmlReader.GetAttribute("URI"); + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } - model.XmiId = xmlReader.GetAttribute("xmi:id") ?? model.Name; - this.Cache.Add(model.XmiId, model); while (xmlReader.Read()) { @@ -112,102 +147,85 @@ public override IModel Read(XmlReader xmlReader) { switch (xmlReader.LocalName) { + case "elementImport": + var elementImportValue = (IElementImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ElementImport"); + poco.ElementImport.Add(elementImportValue); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "nestingPackage": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "nestingPackage"); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "ownedRule": + var ownedRuleValue = (IConstraint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Constraint"); + poco.OwnedRule.Add(ownedRuleValue); + break; + case "ownedTemplateSignature": + var ownedTemplateSignatureValue = (ITemplateSignature)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateSignature"); + poco.OwnedTemplateSignature.Add(ownedTemplateSignatureValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "packagedElement": + var packagedElementValue = (IPackageableElement)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.PackagedElement.Add(packagedElementValue); + break; case "packageImport": - using (var packageImportXmlReader = xmlReader.ReadSubtree()) + var packageImportValue = (IPackageImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:PackageImport"); + poco.PackageImport.Add(packageImportValue); + break; + case "packageMerge": + var packageMergeValue = (IPackageMerge)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:PackageMerge"); + poco.PackageMerge.Add(packageMergeValue); + break; + case "profileApplication": + var profileApplicationValue = (IProfileApplication)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ProfileApplication"); + poco.ProfileApplication.Add(profileApplicationValue); + break; + case "templateBinding": + var templateBindingValue = (ITemplateBinding)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateBinding"); + poco.TemplateBinding.Add(templateBindingValue); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "URI": + poco.URI = xmlReader.ReadElementContentAsString(); + break; + case "viewpoint": + poco.Viewpoint = xmlReader.ReadElementContentAsString(); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) { - var packageImportReader = new PackageImportReader(this.Cache, this.LoggerFactory); - var packageImport = packageImportReader.Read(packageImportXmlReader); - model.PackageImport.Add(packageImport); + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; } break; - case "packagedElement": - this.ReadPackagedElements(model, xmlReader); - break; default: var defaultLineInfo = xmlReader as IXmlLineInfo; throw new NotSupportedException($"ModelReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); } } } - } - - return model; - } - - /// - /// Reads the packaged elements - /// - /// - /// The that the nested packaged elements are added to - /// - /// - /// an instance of - /// - private void ReadPackagedElements(IModel model, XmlReader xmlReader) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - switch (xmiType) - { - case "uml:Association": - using (var associationXmlReader = xmlReader.ReadSubtree()) - { - var associationReader = new AssociationReader(this.Cache, this.LoggerFactory); - var association = associationReader.Read(associationXmlReader); - model.PackagedElement.Add(association); - } - break; - case "uml:Class": - using (var classXmlReader = xmlReader.ReadSubtree()) - { - var classReader = new ClassReader(this.Cache, this.LoggerFactory); - var packagedElement = classReader.Read(classXmlReader); - model.PackagedElement.Add(packagedElement); - } - break; - case "uml:Enumeration": - using (var enumerationXmlReader = xmlReader.ReadSubtree()) - { - var enumerationReader = new EnumerationReader(this.Cache, this.LoggerFactory); - var enumeration = enumerationReader.Read(enumerationXmlReader); - model.PackagedElement.Add(enumeration); - } - break; - case "uml:Package": - using (var packageXmlReader = xmlReader.ReadSubtree()) - { - var packagedElement = this.Read(packageXmlReader); - model.PackagedElement.Add(packagedElement); - } - break; - case "uml:PrimitiveType": - using (var primitiveTypeXmlReader = xmlReader.ReadSubtree()) - { - var primitiveTypeReader = new PrimitiveTypeReader(this.Cache, this.LoggerFactory); - var primitive = primitiveTypeReader.Read(primitiveTypeXmlReader); - model.PackagedElement.Add(primitive); - } - break; - case "uml:Interface": - using (var interfaceXmlReader = xmlReader.ReadSubtree()) - { - var interfaceReader = new InterfaceReader(this.Cache, this.LoggerFactory); - var @interface = interfaceReader.Read(interfaceXmlReader); - model.PackagedElement.Add(@interface); - } - break; - case "uml:Realization": - using (var realizationXmlReader = xmlReader.ReadSubtree()) - { - var realizationReader = new RealizationReader(this.Cache, this.LoggerFactory); - var realization = realizationReader.Read(realizationXmlReader); - model.PackagedElement.Add(realization); - } - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"ModelReader.ReadPackagedElements: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); } + + return poco; } } } + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/Packages/PackageReader.cs b/uml4net.xmi/Readers/Packages/PackageReader.cs index b841f697..4eeaecee 100644 --- a/uml4net.xmi/Readers/Packages/PackageReader.cs +++ b/uml4net.xmi/Readers/Packages/PackageReader.cs @@ -9,7 +9,7 @@ // // http://www.apache.org/licenses/LICENSE-2.0 // -// Unless required by applicable law or agreed to in writing, softwareUseCases +// Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and @@ -18,6 +18,10 @@ // // ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ + namespace uml4net.xmi.Readers.Packages { using System; @@ -26,24 +30,24 @@ namespace uml4net.xmi.Readers.Packages using System.Xml; using Microsoft.Extensions.Logging; - using SimpleClassifiers; + using uml4net; + using uml4net.Actions; + using uml4net.Activities; using uml4net.Classification; using uml4net.CommonBehavior; using uml4net.CommonStructure; using uml4net.Deployments; + using uml4net.Interactions; using uml4net.Packages; using uml4net.SimpleClassifiers; + using uml4net.StateMachines; using uml4net.StructuredClassifiers; using uml4net.UseCases; using uml4net.Utils; using uml4net.Values; using uml4net.xmi.Cache; using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.StructuredClassifiers; - using uml4net.xmi.Readers.Values; /// /// The purpose of the is to read an instance of @@ -59,8 +63,8 @@ public class PackageReader : XmiElementReader, IXmiElementReader /// The cache in which each > is stored /// - /// - /// The (injected) used to setup logging + /// + /// The (injected) used to set up logging /// public PackageReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) : base(cache, loggerFactory) @@ -79,7 +83,10 @@ public PackageReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) /// public override IPackage Read(XmlReader xmlReader) { - Guard.ThrowIfNull(xmlReader); + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } IPackage poco = new Package(); @@ -104,136 +111,116 @@ public override IPackage Read(XmlReader xmlReader) poco.Name = xmlReader.GetAttribute("name"); + var nestingPackageXmlAttribute = xmlReader.GetAttribute("nestingPackage"); + if (!string.IsNullOrEmpty(nestingPackageXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("nestingPackage", nestingPackageXmlAttribute); + } + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + poco.URI = xmlReader.GetAttribute("URI"); - var visibility = xmlReader.GetAttribute("visibility"); - if (!string.IsNullOrEmpty(visibility)) + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibility, true); + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); } + + while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { switch (xmlReader.LocalName) { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; case "elementImport": - using (var elementImportXmlReader = xmlReader.ReadSubtree()) - { - this.Logger.LogInformation("PackageReader.elementImport not yet implemented"); - } + var elementImportValue = (IElementImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ElementImport"); + poco.ElementImport.Add(elementImportValue); + break; + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "nestingPackage": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "nestingPackage"); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); break; case "ownedRule": - var ownedRule = (IConstraint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Constraint"); - poco.OwnedRule.Add(ownedRule); + var ownedRuleValue = (IConstraint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Constraint"); + poco.OwnedRule.Add(ownedRuleValue); + break; + case "ownedTemplateSignature": + var ownedTemplateSignatureValue = (ITemplateSignature)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateSignature"); + poco.OwnedTemplateSignature.Add(ownedTemplateSignatureValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "packagedElement": + var packagedElementValue = (IPackageableElement)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory); + poco.PackagedElement.Add(packagedElementValue); break; case "packageImport": - using (var packageImportXmlReader = xmlReader.ReadSubtree()) - { - var packageImportReader = new PackageImportReader(this.Cache, this.LoggerFactory); - var packageImport = packageImportReader.Read(packageImportXmlReader); - poco.PackageImport.Add(packageImport); - } + var packageImportValue = (IPackageImport)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:PackageImport"); + poco.PackageImport.Add(packageImportValue); + break; + case "packageMerge": + var packageMergeValue = (IPackageMerge)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:PackageMerge"); + poco.PackageMerge.Add(packageMergeValue); + break; + case "profileApplication": + var profileApplicationValue = (IProfileApplication)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:ProfileApplication"); + poco.ProfileApplication.Add(profileApplicationValue); break; case "templateBinding": - using (var templateBindingXmlReader = xmlReader.ReadSubtree()) + var templateBindingValue = (ITemplateBinding)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:TemplateBinding"); + poco.TemplateBinding.Add(templateBindingValue); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "URI": + poco.URI = xmlReader.ReadElementContentAsString(); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) { - this.Logger.LogInformation("PackageReader.TemplateBinding not yet implemented"); + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; } break; - case "packagedElement": - this.ReadPackagedElements(poco, xmlReader); - break; default: var defaultLineInfo = xmlReader as IXmlLineInfo; throw new NotSupportedException($"PackageReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); } } } + } return poco; } - - /// - /// Reads the packaged elements - /// - /// - /// The that the nested packaged elements are added to - /// - /// - /// an instance of - /// - private void ReadPackagedElements(IPackage package, XmlReader xmlReader) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - switch (xmiType) - { - case "uml:Association": - using (var associationXmlReader = xmlReader.ReadSubtree()) - { - var associationReader = new AssociationReader(this.Cache, this.LoggerFactory); - var association = associationReader.Read(associationXmlReader); - package.PackagedElement.Add(association); - } - break; - case "uml:Class": - using (var classXmlReader = xmlReader.ReadSubtree()) - { - var classReader = new ClassReader(this.Cache, this.LoggerFactory); - var packagedElement = classReader.Read(classXmlReader); - package.PackagedElement.Add(packagedElement); - } - break; - case "uml:Enumeration": - using (var enumerationXmlReader = xmlReader.ReadSubtree()) - { - var enumerationReader = new EnumerationReader(this.Cache, this.LoggerFactory); - var enumeration = enumerationReader.Read(enumerationXmlReader); - package.PackagedElement.Add(enumeration); - } - break; - case "uml:Package": - using (var packageXmlReader = xmlReader.ReadSubtree()) - { - var packagedElement = this.Read(packageXmlReader); - package.PackagedElement.Add(packagedElement); - } - break; - case "uml:PrimitiveType": - using (var primitiveTypeXmlReader = xmlReader.ReadSubtree()) - { - var primitiveTypeReader = new PrimitiveTypeReader(this.Cache, this.LoggerFactory); - var primitive = primitiveTypeReader.Read(primitiveTypeXmlReader); - package.PackagedElement.Add(primitive); - } - break; - case "uml:Interface": - using (var interfaceXmlReader = xmlReader.ReadSubtree()) - { - var interfaceReader = new InterfaceReader(this.Cache, this.LoggerFactory); - var @interface = interfaceReader.Read(interfaceXmlReader); - package.PackagedElement.Add(@interface); - } - break; - case "uml:Realization": - using (var realizationXmlReader = xmlReader.ReadSubtree()) - { - var realizationReader = new RealizationReader(this.Cache, this.LoggerFactory); - var realization = realizationReader.Read(realizationXmlReader); - package.PackagedElement.Add(realization); - } - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"PackageReader.ReadPackagedElements: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } } } + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/SimpleClassifiers/EnumerationLiteralReader.cs b/uml4net.xmi/Readers/SimpleClassifiers/EnumerationLiteralReader.cs deleted file mode 100644 index f2cacb98..00000000 --- a/uml4net.xmi/Readers/SimpleClassifiers/EnumerationLiteralReader.cs +++ /dev/null @@ -1,127 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.SimpleClassifiers -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class EnumerationLiteralReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public EnumerationLiteralReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IEnumerationLiteral Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - IEnumerationLiteral poco = new EnumerationLiteral(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:EnumerationLiteral") - { - throw new XmlException($"The XmiType should be 'uml:EnumerationLiteral' while it is {xmiType}"); - } - else - { - xmiType = "uml:EnumerationLiteral"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - poco.Name = xmlReader.GetAttribute("name"); - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"EnumerationLiteralReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - } - - return poco; - } - } -} diff --git a/uml4net.xmi/Readers/SimpleClassifiers/EnumerationReader.cs b/uml4net.xmi/Readers/SimpleClassifiers/EnumerationReader.cs deleted file mode 100644 index e57d8c9d..00000000 --- a/uml4net.xmi/Readers/SimpleClassifiers/EnumerationReader.cs +++ /dev/null @@ -1,135 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.SimpleClassifiers -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class EnumerationReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public EnumerationReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IEnumeration Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - IEnumeration poco = new Enumeration(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Enumeration") - { - throw new XmlException($"The XmiType should be 'uml:Enumeration' while it is {xmiType}"); - } - else - { - xmiType = "uml:Enumeration"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - poco.Name = xmlReader.GetAttribute("name"); - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - case "ownedLiteral": - using (var ownedLiteralXmlReader = xmlReader.ReadSubtree()) - { - var enumerationLiteralReader = new EnumerationLiteralReader(this.Cache, this.LoggerFactory); - var ownedLiteral = enumerationLiteralReader.Read(ownedLiteralXmlReader); - poco.OwnedLiteral.Add(ownedLiteral); - } - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"EnumerationReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - } - - return poco; - } - } -} diff --git a/uml4net.xmi/Readers/SimpleClassifiers/InterfaceReader.cs b/uml4net.xmi/Readers/SimpleClassifiers/InterfaceReader.cs deleted file mode 100644 index 26c385ce..00000000 --- a/uml4net.xmi/Readers/SimpleClassifiers/InterfaceReader.cs +++ /dev/null @@ -1,165 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.SimpleClassifiers -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class InterfaceReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to set up logging - /// - public InterfaceReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IInterface Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - IInterface poco = new Interface(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Interface") - { - throw new XmlException($"The XmiType should be 'uml:Interface' while it is {xmiType}"); - } - else - { - xmiType = "uml:Interface"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - poco.Name = xmlReader.GetAttribute("name"); - - var isAbstract = xmlReader.GetAttribute("isAbstract"); - if (!string.IsNullOrEmpty(isAbstract)) - { - poco.IsAbstract = bool.Parse(isAbstract); - } - - var visibility = xmlReader.GetAttribute("visibility"); - if (!string.IsNullOrEmpty(visibility)) - { - poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibility, true); - } - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - case "ownedRule": - var ownedRule = (IConstraint)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Constraint"); - poco.OwnedRule.Add(ownedRule); - break; - case "ownedAttribute": - using (var ownedAttributeXmlReader = xmlReader.ReadSubtree()) - { - var propertyReader = new PropertyReader(this.Cache, this.LoggerFactory); - var property = propertyReader.Read(ownedAttributeXmlReader); - poco.Attribute.Add(property); - } - break; - case "ownedOperation": - using (var ownedOperationXmlReader = xmlReader.ReadSubtree()) - { - this.Logger.LogInformation("InterfaceReader.ownedOperation not yet implemented"); - } - break; - case "generalization": - using (var generalizationXmlReader = xmlReader.ReadSubtree()) - { - var generalizationReader = new GeneralizationReader(this.Cache, this.LoggerFactory); - var generalization = generalizationReader.Read(generalizationXmlReader); - poco.Generalization.Add(generalization); - } - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"InterfaceReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - } - - return poco; - } - } -} diff --git a/uml4net.xmi/Readers/SimpleClassifiers/InterfaceRealizationReader.cs b/uml4net.xmi/Readers/SimpleClassifiers/InterfaceRealizationReader.cs deleted file mode 100644 index 7dba9deb..00000000 --- a/uml4net.xmi/Readers/SimpleClassifiers/InterfaceRealizationReader.cs +++ /dev/null @@ -1,119 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright (C) 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.SimpleClassifiers -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class InterfaceRealizationReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to set up logging - /// - public InterfaceRealizationReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IInterfaceRealization Read(XmlReader xmlReader) - { - if (xmlReader == null) - { - throw new ArgumentNullException(nameof(xmlReader)); - } - - IInterfaceRealization poco = new InterfaceRealization(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:InterfaceRealization") - { - throw new XmlException($"The XmiType should be 'uml:InterfaceRealization' while it is {xmiType}"); - } - else - { - xmiType = "uml:InterfaceRealization"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - } - - return poco; - } - } -} - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/SimpleClassifiers/PrimitiveTypeReader.cs b/uml4net.xmi/Readers/SimpleClassifiers/PrimitiveTypeReader.cs deleted file mode 100644 index d2b12021..00000000 --- a/uml4net.xmi/Readers/SimpleClassifiers/PrimitiveTypeReader.cs +++ /dev/null @@ -1,127 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.SimpleClassifiers -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class PrimitiveTypeReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public PrimitiveTypeReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IPrimitiveType Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - IPrimitiveType poco = new PrimitiveType(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:PrimitiveType") - { - throw new XmlException($"The XmiType should be 'uml:PrimitiveType' while it is {xmiType}"); - } - else - { - xmiType = "uml:PrimitiveType"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - poco.Name = xmlReader.GetAttribute("name"); - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"PrimitiveTypeReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - } - - return poco; - } - } -} diff --git a/uml4net.xmi/Readers/SimpleClassifiers/ReceptionReader.cs b/uml4net.xmi/Readers/SimpleClassifiers/ReceptionReader.cs deleted file mode 100644 index b906425e..00000000 --- a/uml4net.xmi/Readers/SimpleClassifiers/ReceptionReader.cs +++ /dev/null @@ -1,119 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright (C) 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.SimpleClassifiers -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class ReceptionReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to set up logging - /// - public ReceptionReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IReception Read(XmlReader xmlReader) - { - if (xmlReader == null) - { - throw new ArgumentNullException(nameof(xmlReader)); - } - - IReception poco = new Reception(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:Reception") - { - throw new XmlException($"The XmiType should be 'uml:Reception' while it is {xmiType}"); - } - else - { - xmiType = "uml:Reception"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - } - - return poco; - } - } -} - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/Values/LiteralBooleanReader.cs b/uml4net.xmi/Readers/Values/LiteralBooleanReader.cs deleted file mode 100644 index 3adc2986..00000000 --- a/uml4net.xmi/Readers/Values/LiteralBooleanReader.cs +++ /dev/null @@ -1,131 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.Values -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class LiteralBooleanReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public LiteralBooleanReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override ILiteralBoolean Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - ILiteralBoolean poco = new LiteralBoolean(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:LiteralBoolean") - { - throw new XmlException($"The XmiType should be 'uml:LiteralBoolean' while it is {xmiType}"); - } - else - { - xmiType = "uml:LiteralBoolean"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - var value = xmlReader.GetAttribute("value"); - if (!string.IsNullOrEmpty(value)) - { - poco.Value = bool.Parse(value); - } - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"LiteralBooleanReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - } - - return poco; - } - } -} diff --git a/uml4net.xmi/Readers/Values/LiteralStringReader.cs b/uml4net.xmi/Readers/Values/LiteralStringReader.cs deleted file mode 100644 index 5360f423..00000000 --- a/uml4net.xmi/Readers/Values/LiteralStringReader.cs +++ /dev/null @@ -1,127 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.Values -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class LiteralStringReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public LiteralStringReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override ILiteralString Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - ILiteralString poco = new LiteralString(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:LiteralString") - { - throw new XmlException($"The XmiType should be 'uml:LiteralString' while it is {xmiType}"); - } - else - { - xmiType = "uml:LiteralString"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - poco.Value = xmlReader.GetAttribute("value"); - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"LiteralStringReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - } - - return poco; - } - } -} diff --git a/uml4net.xmi/Readers/Values/StringExpressionReader.cs b/uml4net.xmi/Readers/Values/StringExpressionReader.cs deleted file mode 100644 index 2a59d98e..00000000 --- a/uml4net.xmi/Readers/Values/StringExpressionReader.cs +++ /dev/null @@ -1,119 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright (C) 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.xmi.Readers.Values -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - using uml4net.xmi.Readers.Classification; - using uml4net.xmi.Readers.CommonStructure; - using uml4net.xmi.Readers.Values; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class StringExpressionReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to set up logging - /// - public StringExpressionReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override IStringExpression Read(XmlReader xmlReader) - { - if (xmlReader == null) - { - throw new ArgumentNullException(nameof(xmlReader)); - } - - IStringExpression poco = new StringExpression(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:StringExpression") - { - throw new XmlException($"The XmiType should be 'uml:StringExpression' while it is {xmiType}"); - } - else - { - xmiType = "uml:StringExpression"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - } - - return poco; - } - } -} - -// ------------------------------------------------------------------------------------------------ -// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- -// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/uml4net.xmi.csproj b/uml4net.xmi/uml4net.xmi.csproj index f8fceeba..5bfb7402 100644 --- a/uml4net.xmi/uml4net.xmi.csproj +++ b/uml4net.xmi/uml4net.xmi.csproj @@ -47,8 +47,4 @@ - - - -