Created
August 11, 2019 09:39
-
-
Save dfch/59a3f94ea132a8a217a058f1134ac945 to your computer and use it in GitHub Desktop.
Handling Sparx Enterprise Architect Baseline Information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2018 d-fens GmbH | |
* | |
* 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. | |
*/ | |
using System; | |
using System.Collections.Generic; | |
using System.ServiceModel; | |
using System.Xml.Serialization; | |
namespace biz.dfch.CS.EA.ProductModeler.Public.Ea.Conversion.Baseline | |
{ | |
[XmlSerializerFormat] | |
[XmlRoot("EA.CompareLog")] | |
public class BaselineComparison : XmlSerialiserBase | |
{ | |
[XmlElement(nameof(ComparePackage))] | |
public ComparePackageElement ComparePackage { get; set; } = new ComparePackageElement(); | |
[XmlSerializerFormat] | |
public class ComparePackageElement | |
{ | |
[XmlAttribute("name")] | |
public string Name { get; set; } | |
[XmlAttribute("guid")] | |
public string EaId { get; set; } | |
[XmlAttribute("packageID")] | |
public int PackageId { get; set; } | |
[XmlAttribute("comparedBy")] | |
public string ComparedBy { get; set; } | |
[XmlAttribute("comparedOn")] | |
public string ComparedOnString { get; set; } | |
public DateTime ComparedOn => DateTime.Parse(ComparedOnString); | |
[XmlElement(nameof(CompareResults))] | |
public CompareResultsElement CompareResults = new CompareResultsElement(); | |
} | |
public class CompareResultsElement | |
{ | |
[XmlAttribute("hasChanges")] | |
public bool HasChanges { get; set; } | |
[XmlElement("CompareItem")] | |
public List<CompareItemElement> CompareItems { get; set; } = new List<CompareItemElement>(); | |
} | |
public class CompareItemElement | |
{ | |
[XmlAttribute("name")] | |
public string Name { get; set; } | |
[XmlAttribute("type")] | |
public string Type { get; set; } | |
[XmlAttribute("guid")] | |
public string Id { get; set; } | |
[XmlAttribute("status")] | |
public string Status { get; set; } | |
[XmlElement(nameof(Properties))] | |
public PropertiesElement Properties { get; set; } = new PropertiesElement(); | |
[XmlElement("CompareItem")] | |
public List<CompareItemElement> CompareItems { get; set; } = new List<CompareItemElement>(); | |
} | |
public class PropertiesElement | |
{ | |
[XmlElement("Property")] | |
public List<PropertyElement> Properties { get; set; } = new List<PropertyElement>(); | |
} | |
public class PropertyElement | |
{ | |
[XmlAttribute("name")] | |
public string Name { get; set; } | |
[XmlAttribute("model")] | |
public string Model { get; set; } | |
[XmlAttribute("baseline")] | |
public string Baseline { get; set; } | |
[XmlAttribute("status")] | |
public string Status { get; set; } | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2018 d-fens GmbH | |
* | |
* 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. | |
*/ | |
using System.Collections.Generic; | |
using System.Diagnostics.Contracts; | |
namespace biz.dfch.CS.EA.ProductModeler.Public.Ea.Conversion.Baseline | |
{ | |
public abstract class BaselineComparisonVisitor : IBaselineComparisonVisitor | |
{ | |
public void Visit(BaselineComparison baselineComparison) | |
{ | |
Visit(baselineComparison, BaselineComparisonStatus.Any); | |
} | |
public void Visit(BaselineComparison baselineComparison, string status) | |
{ | |
Contract.Requires(null != baselineComparison); | |
VisitPackage(baselineComparison.ComparePackage); | |
VisitResults(baselineComparison.ComparePackage.CompareResults); | |
RecursiveVisitElements(baselineComparison.ComparePackage.CompareResults.CompareItems, null, status); | |
} | |
private void RecursiveVisitElements(List<BaselineComparison.CompareItemElement> elements, BaselineComparison.CompareItemElement parent, string status) | |
{ | |
VisitElements(elements); | |
VisitElements(elements, parent); | |
foreach (var element in elements) | |
{ | |
if (!string.IsNullOrWhiteSpace(status) && element.Status != status) | |
{ | |
RecursiveVisitElements(element.CompareItems, element, status); | |
continue; | |
} | |
VisitElement(element); | |
VisitElement(element, parent); | |
VisitProperties(element.Properties.Properties); | |
VisitProperties(element.Properties.Properties, element); | |
foreach (var property in element.Properties.Properties) | |
{ | |
if (!string.IsNullOrWhiteSpace(status) && property.Status != status) continue; | |
VisitProperty(property); | |
VisitProperty(property, element); | |
} | |
RecursiveVisitElements(element.CompareItems, element, status); | |
} | |
} | |
public virtual void VisitPackage(BaselineComparison.ComparePackageElement element) { } | |
public virtual void VisitResults(BaselineComparison.CompareResultsElement element) { } | |
public virtual void VisitElements(List<BaselineComparison.CompareItemElement> elements) { } | |
public virtual void VisitElements(List<BaselineComparison.CompareItemElement> elements, BaselineComparison.CompareItemElement parent) { } | |
public virtual void VisitElement(BaselineComparison.CompareItemElement element, BaselineComparison.CompareItemElement parent) { } | |
public virtual void VisitElement(BaselineComparison.CompareItemElement element) { } | |
public virtual void VisitProperties(List<BaselineComparison.PropertyElement> elements, BaselineComparison.CompareItemElement parent) { } | |
public virtual void VisitProperties(List<BaselineComparison.PropertyElement> elements) { } | |
public virtual void VisitProperty(BaselineComparison.PropertyElement element, BaselineComparison.CompareItemElement parent) { } | |
public virtual void VisitProperty(BaselineComparison.PropertyElement element) { } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2018 d-fens GmbH | |
* | |
* 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. | |
*/ | |
using System; | |
using System.Collections.Generic; | |
using System.ServiceModel; | |
using System.Xml.Serialization; | |
namespace biz.dfch.CS.EA.ProductModeler.Public.Ea.Conversion.Baseline | |
{ | |
[XmlSerializerFormat] | |
[XmlRoot("EA.BaseLines")] | |
public class BaselineSummary : XmlSerialiserBase | |
{ | |
[XmlAttribute("package")] | |
public Guid PackageId { get; set; } | |
[XmlElement("Baseline")] | |
public List<BaselineElement> Baselines { get; set; } = new List<BaselineElement>(); | |
public class BaselineElement | |
{ | |
[XmlAttribute("name")] | |
public string Name { get; set; } | |
[XmlAttribute("version")] | |
public string Version { get; set; } | |
[XmlAttribute("notes")] | |
public string Description { get; set; } | |
[XmlAttribute("guid")] | |
public Guid Id { get; set; } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment