diff --git a/SysML2.NET.Serializer.Json.Tests/ApiSerializerTestFixture.cs b/SysML2.NET.Serializer.Json.Tests/ApiSerializerTestFixture.cs index da6673267..e8a6bd10e 100644 --- a/SysML2.NET.Serializer.Json.Tests/ApiSerializerTestFixture.cs +++ b/SysML2.NET.Serializer.Json.Tests/ApiSerializerTestFixture.cs @@ -1,20 +1,20 @@ // ------------------------------------------------------------------------------------------------- // -// +// // Copyright 2022-2025 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. -// +// // // ------------------------------------------------------------------------------------------------ @@ -73,7 +73,7 @@ private void CreateTestData() Created = new DateTime(1976, 8, 20, 0, 0, 0, DateTimeKind.Utc), Description = "", OwningProject = Guid.Parse("9b0e1914-3241-461e-b9ee-a3ff5120de4e"), - PreviousCommit = Guid.Empty, + PreviousCommits = [Guid.Parse("8d3c3f31-2b2f-4f4b-8f35-6b2e0f4a4a11")], ResourceIdentifier = "http://www.stariongroup.eu/commit", }; diff --git a/SysML2.NET.Serializer.Json.Tests/DeSerializerTestFixture.cs b/SysML2.NET.Serializer.Json.Tests/DeSerializerTestFixture.cs index ffe351f42..57ba1154f 100644 --- a/SysML2.NET.Serializer.Json.Tests/DeSerializerTestFixture.cs +++ b/SysML2.NET.Serializer.Json.Tests/DeSerializerTestFixture.cs @@ -64,6 +64,20 @@ public class DeSerializerTestFixture /// private const int LargePayloadElementCount = 4000; + /// + /// A merge commit json object that names two immediately preceding commits + /// + private const string MergeCommit = """[{"@id":"6d7ad9fd-6520-4ff2-885b-8c5c129e6c27","@type":"Commit","created":"2023-03-13T17:53:59.111354-04:00","description":null,"owningProject":{"@id":"000e9890-6935-43e6-a5d7-5d7cac601f4c"},"previousCommit":[{"@id":"1e4c2a06-0f2f-4a3c-9d64-0f4b2f6d9a11"},{"@id":"2b7d5e18-6a4f-4d1e-8c32-7d5a1c8e4b22"}]}]"""; + + /// + /// The identifiers that the payload names as preceding commits + /// + private static readonly Guid[] MergeCommitPredecessors = + [ + Guid.Parse("1e4c2a06-0f2f-4a3c-9d64-0f4b2f6d9a11"), + Guid.Parse("2b7d5e18-6a4f-4d1e-8c32-7d5a1c8e4b22") + ]; + private DeSerializer deSerializer; [SetUp] @@ -209,7 +223,7 @@ public void Verify_that_particular_project_and_commits_from_restapi_json_can_be_ using (Assert.EnterMultipleScope()) { Assert.That(firstCommit.OwningProject, Is.EqualTo(Guid.Parse("000e9890-6935-43e6-a5d7-5d7cac601f4c"))); - Assert.That(firstCommit.PreviousCommit, Is.EqualTo(Guid.Empty)); + Assert.That(firstCommit.PreviousCommits, Has.Count.EqualTo(0)); Assert.That(firstCommit.Description, Is.Null); Assert.That(firstCommit.Created, Is.EqualTo(DateTime.Parse("2023-03-13T17:53:59.111354-04:00", CultureInfo.InvariantCulture))); } @@ -232,12 +246,30 @@ public void Verify_that_particular_project_and_particular_commit_from_restapi_js using (Assert.EnterMultipleScope()) { Assert.That(firstCommit.OwningProject, Is.EqualTo(Guid.Parse("000e9890-6935-43e6-a5d7-5d7cac601f4c"))); - Assert.That(firstCommit.PreviousCommit, Is.EqualTo(Guid.Empty)); + Assert.That(firstCommit.PreviousCommits, Has.Count.EqualTo(0)); Assert.That(firstCommit.Description, Is.Null); Assert.That(firstCommit.Created, Is.EqualTo(DateTime.Parse("2023-03-13T17:53:59.111354-04:00", CultureInfo.InvariantCulture))); } } + [Test] + [TestCase(false)] + [TestCase(true)] + public void Verify_that_a_merge_commit_from_restapi_json_can_be_deserialized(bool shouldDeserializeDerivedProperties) + { + using var stream = new MemoryStream(Encoding.UTF8.GetBytes(MergeCommit)); + + var data = this.deSerializer.DeSerialize(stream, SerializationModeKind.JSON, SerializationTargetKind.PSM, shouldDeserializeDerivedProperties); + + var mergeCommit = data.OfType().Single(); + + using (Assert.EnterMultipleScope()) + { + Assert.That(mergeCommit.PreviousCommits, Is.EqualTo(MergeCommitPredecessors)); + Assert.That(mergeCommit.OwningProject, Is.EqualTo(Guid.Parse("000e9890-6935-43e6-a5d7-5d7cac601f4c"))); + } + } + [Test] [TestCase(false)] [TestCase(true)] diff --git a/SysML2.NET.Serializer.Json/PIM/CommitDeSerializer.cs b/SysML2.NET.Serializer.Json/PIM/CommitDeSerializer.cs index 62d99b6ba..d0b3f9d7e 100644 --- a/SysML2.NET.Serializer.Json/PIM/CommitDeSerializer.cs +++ b/SysML2.NET.Serializer.Json/PIM/CommitDeSerializer.cs @@ -145,18 +145,17 @@ internal static Commit DeSerialize(JsonElement jsonElement, SerializationModeKin if (jsonElement.TryGetProperty("previousCommit"u8, out JsonElement previousCommitProperty)) { - if (previousCommitProperty.ValueKind == JsonValueKind.Null) + if (previousCommitProperty.ValueKind == JsonValueKind.Array) { - dtoInstance.PreviousCommit = Guid.Empty; - } - else - { - if (previousCommitProperty.TryGetProperty("@id"u8, out JsonElement previousCommitPropertyIdProperty)) + foreach (var previousCommitItem in previousCommitProperty.EnumerateArray()) { - var propertyValue = previousCommitPropertyIdProperty.GetString(); - if (propertyValue != null) + if (previousCommitItem.TryGetProperty("@id"u8, out JsonElement previousCommitItemIdProperty)) { - dtoInstance.PreviousCommit = Guid.Parse(propertyValue); + var propertyValue = previousCommitItemIdProperty.GetString(); + if (propertyValue != null) + { + dtoInstance.PreviousCommits.Add(Guid.Parse(propertyValue)); + } } } } @@ -165,7 +164,7 @@ internal static Commit DeSerialize(JsonElement jsonElement, SerializationModeKin { if (logger.IsEnabled(LogLevel.Debug)) { - logger.LogDebug("the owningProject Json property was not found in the Commit: {Id}", dtoInstance.Id); + logger.LogDebug("the previousCommit Json property was not found in the Commit: {Id}", dtoInstance.Id); } } diff --git a/SysML2.NET.Serializer.Json/PIM/CommitSerializer.cs b/SysML2.NET.Serializer.Json/PIM/CommitSerializer.cs index 53405053c..8b6528f9c 100644 --- a/SysML2.NET.Serializer.Json/PIM/CommitSerializer.cs +++ b/SysML2.NET.Serializer.Json/PIM/CommitSerializer.cs @@ -75,9 +75,17 @@ internal static void Serialize(object obj, Utf8JsonWriter writer, SerializationM writer.WriteString("@id"u8, commit.OwningProject); writer.WriteEndObject(); writer.WriteString("resourceIdentifier"u8, commit.ResourceIdentifier); - writer.WriteStartObject("previousCommit"u8); - writer.WriteString("@id"u8, commit.PreviousCommit); - writer.WriteEndObject(); + writer.WriteStartArray("previousCommit"u8); + if (commit.PreviousCommits != null) + { + foreach (var item in commit.PreviousCommits) + { + writer.WriteStartObject(); + writer.WriteString("@id"u8, item); + writer.WriteEndObject(); + } + } + writer.WriteEndArray(); writer.WriteEndObject(); break; diff --git a/SysML2.NET/PIM/DTO/Branch.cs b/SysML2.NET/PIM/DTO/Branch.cs index ca048e762..244d3ec92 100644 --- a/SysML2.NET/PIM/DTO/Branch.cs +++ b/SysML2.NET/PIM/DTO/Branch.cs @@ -22,10 +22,12 @@ namespace SysML2.NET.PIM.DTO { using System; + using SysML2.NET.Decorators; + /// /// A is a type of CommitReference. A is a pointer to a (Branch.head). /// The history of a on a given branch can be computed by recursively navigating - /// , starting from the head of the (Branch.head) + /// , starting from the head of the (Branch.head) /// public class Branch : CommitReference { @@ -33,6 +35,7 @@ public class Branch : CommitReference /// Gets or sets the commit to which the branch is currently pointing. It represents the latest state of the /// on the given branch /// + [Property(lowerValue: 1, upperValue: 1)] public Guid Head { get; set; } } } diff --git a/SysML2.NET/PIM/DTO/Commit.cs b/SysML2.NET/PIM/DTO/Commit.cs index cc4cd9f25..5e0f144bc 100644 --- a/SysML2.NET/PIM/DTO/Commit.cs +++ b/SysML2.NET/PIM/DTO/Commit.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.DTO using System; using System.Collections.Generic; + using SysML2.NET.Decorators; using SysML2.NET.PIM; /// @@ -31,9 +32,9 @@ namespace SysML2.NET.PIM.DTO /// a . A has 0 or more s /// /// - /// s are immutable. For a given record, the value of change + /// s are immutable. For a given record, the value of /// cannot be modified after a has been created. If a modification is required, a new - /// record can be created with a different value of change. + /// record can be created with a different value of . /// s are not destructible1. A record cannot be deleted during normal /// end-user operation. s represent the history and evolution of a . /// Deleting and mutating records must be disabled for the normal end-user operations @@ -44,16 +45,39 @@ public class Commit : Record /// /// Gets or sets the timestamp at which the was created /// + [Property(lowerValue: 1, upperValue: 1)] public DateTime Created { get; set; } /// /// Gets or sets the that owns the . /// + [Property(lowerValue: 1, upperValue: 1)] public Guid OwningProject { get; set; } /// - /// Gets or sets the immediately preceding s + /// Gets or sets the set of immediately preceding s /// - public Guid PreviousCommit { get; set; } + [Property(lowerValue: 0, upperValue: int.MaxValue)] + public List PreviousCommits { get; set; } = []; + + /// + /// Gets or sets the set of records representing data that is created, updated, + /// or deleted in the + /// + /// + /// A deletion is recorded by a whose payload is null. + /// + [Property(lowerValue: 1, upperValue: int.MaxValue)] + public List Change { get; set; } = []; + + /// + /// Gets or sets the set of cumulative records in a at the + /// + /// + /// Derived by Systems Modeling API and Services, Clause 7.1.2 from and the + /// versioned data of . + /// + [Property(lowerValue: 0, upperValue: int.MaxValue, isDerived: true)] + public List VersionedData { get; set; } = []; } } diff --git a/SysML2.NET/PIM/DTO/CommitReference.cs b/SysML2.NET/PIM/DTO/CommitReference.cs index a12e5bba5..5e4b80ad4 100644 --- a/SysML2.NET/PIM/DTO/CommitReference.cs +++ b/SysML2.NET/PIM/DTO/CommitReference.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.DTO using System; using SysML2.NET.Common; + using SysML2.NET.Decorators; /// /// An abstract subclass of that references a specific (Commit Reference.referencedCommit). Project.commit is the set of all the Commit records for a given Project. @@ -34,21 +35,26 @@ public abstract class CommitReference : Record /// /// Gets or sets the timestamp at which the was created. /// + [Property(lowerValue: 1, upperValue: 1)] public DateTime Created { get; set; } /// /// Gets or sets the timestamp at which the was deleted /// + [Property(lowerValue: 1, upperValue: 1)] public DateTime Deleted { get; set; } /// /// Gets or sets the Project that owns the given /// + [Property(lowerValue: 1, upperValue: 1)] public Guid OwningProject { get; set; } /// /// Gets or sets the name of the /// + [Property(lowerValue: 1, upperValue: 1)] + [RedefinedProperty(propertyName: "Record.Name")] public new string Name { get; set; } } } diff --git a/SysML2.NET/PIM/DTO/CompositeConstraint.cs b/SysML2.NET/PIM/DTO/CompositeConstraint.cs index 7f01a7a11..c1398dbe2 100644 --- a/SysML2.NET/PIM/DTO/CompositeConstraint.cs +++ b/SysML2.NET/PIM/DTO/CompositeConstraint.cs @@ -22,8 +22,10 @@ namespace SysML2.NET.PIM.DTO { using System.Collections.Generic; + using SysML2.NET.Decorators; + /// - /// a subtype of that represents complex conditions composed of two or more + /// a concrete subtype of that represents complex conditions composed of two or more /// s or s using logical AND or OR operators /// public class CompositeConstraint : Constraint @@ -34,11 +36,13 @@ public class CompositeConstraint : Constraint /// /// There must be at least 2 /// + [Property(lowerValue: 2, upperValue: int.MaxValue)] public List Constraint { get; set; } = []; /// /// Gets or sets the logical operator for composing the s /// + [Property(lowerValue: 1, upperValue: 1)] public JoinOperator Operator { get; set; } } } diff --git a/SysML2.NET/PIM/DTO/DataDifference.cs b/SysML2.NET/PIM/DTO/DataDifference.cs index a766e11c4..6edaf8ea8 100644 --- a/SysML2.NET/PIM/DTO/DataDifference.cs +++ b/SysML2.NET/PIM/DTO/DataDifference.cs @@ -22,6 +22,8 @@ namespace SysML2.NET.PIM.DTO { using System; + using SysML2.NET.Decorators; + /// /// Represents a single difference between two compared versions of the same /// @@ -30,11 +32,13 @@ public class DataDifference /// /// Gets or sets the taken as the baseline of the comparison, or null when the data was added /// + [Property(lowerValue: 0, upperValue: 1)] public Guid? BaseData { get; set; } /// /// Gets or sets the compared against the baseline, or null when the data was deleted /// + [Property(lowerValue: 0, upperValue: 1)] public Guid? CompareData { get; set; } } } diff --git a/SysML2.NET/PIM/DTO/DataVersion.cs b/SysML2.NET/PIM/DTO/DataVersion.cs index a8f2250e1..7b1c3e169 100644 --- a/SysML2.NET/PIM/DTO/DataVersion.cs +++ b/SysML2.NET/PIM/DTO/DataVersion.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.DTO using System; using SysML2.NET.Common; + using SysML2.NET.Decorators; /// /// A subclass of that represents at a specific version in its lifecycle. @@ -32,18 +33,33 @@ namespace SysML2.NET.PIM.DTO public class DataVersion : Record { /// - /// Gets or sets the at which the wrapped data (payload) was created, modified, or deleted. + /// Gets or sets the at which the wrapped data (payload) was created, modified, or deleted. /// + [Property(lowerValue: 1, upperValue: 1)] public Guid Commit { get; set; } + /// + /// Gets or sets the that owns the + /// + /// + /// Derived by Systems Modeling API and Services, Clause 7.1.2 from the owning project of . + /// + [Property(lowerValue: 1, upperValue: 1, isDerived: true)] + public Guid Project { get; set; } + /// /// Gets or sets the contained /// + [Property(lowerValue: 1, upperValue: 1)] public DataIdentity Identity { get; set; } /// /// Gets or sets the that is the payload /// + /// + /// null when no data with the given identity is present at the . + /// + [Property(lowerValue: 0, upperValue: 1)] public IData Payload { get; set; } } } diff --git a/SysML2.NET/PIM/DTO/ExternalData.cs b/SysML2.NET/PIM/DTO/ExternalData.cs index bfeea1909..cbbe69ba5 100644 --- a/SysML2.NET/PIM/DTO/ExternalData.cs +++ b/SysML2.NET/PIM/DTO/ExternalData.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.DTO using System; using SysML2.NET.Common; + using SysML2.NET.Decorators; /// /// ExternalData is a realization of Data, and represents a resource external to a given tool or @@ -33,11 +34,13 @@ public class ExternalData : IData /// /// Gets or sets the unique identifier /// + [Property(lowerValue: 1, upperValue: 1, isReadOnly: true)] public Guid Id { get; set; } /// /// Gets or sets the string representation of the IRI of the resource represented by the ExternalData /// + [Property(lowerValue: 1, upperValue: 1)] public string ResourceIdentifier { get; set; } } } diff --git a/SysML2.NET/PIM/DTO/ExternalRelationship.cs b/SysML2.NET/PIM/DTO/ExternalRelationship.cs index 959cf816e..413bb2734 100644 --- a/SysML2.NET/PIM/DTO/ExternalRelationship.cs +++ b/SysML2.NET/PIM/DTO/ExternalRelationship.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.DTO using System; using SysML2.NET.Common; + using SysML2.NET.Decorators; /// /// ExternalRelationship is a realization of Data, and represents the relationship between a @@ -35,6 +36,7 @@ public class ExternalRelationship : IData /// /// Gets or sets the unique identifier /// + [Property(lowerValue: 1, upperValue: 1)] public Guid Id { get; set; } /// @@ -44,21 +46,25 @@ public class ExternalRelationship : IData /// would contain mathematical expressions, such as equations, representing the mapping.This is an optional /// attribute. /// + [Property(lowerValue: 0, upperValue: 1)] public string Specification { get; set; } /// /// Gets or sets the name of the expression language used for the specification. This is an optional attribute. /// + [Property(lowerValue: 0, upperValue: 1)] public string Language { get; set; } /// /// Gets or sets the /// + [Property(lowerValue: 1, upperValue: 1)] public Guid ElementEnd { get; set; } /// /// Gets or sets the /// + [Property(lowerValue: 1, upperValue: 1)] public Guid ExternalDataEnd { get; set; } } } diff --git a/SysML2.NET/PIM/DTO/MergeResult.cs b/SysML2.NET/PIM/DTO/MergeResult.cs index 4ccde2c02..3550aba8a 100644 --- a/SysML2.NET/PIM/DTO/MergeResult.cs +++ b/SysML2.NET/PIM/DTO/MergeResult.cs @@ -23,6 +23,8 @@ namespace SysML2.NET.PIM.DTO using System; using System.Collections.Generic; + using SysML2.NET.Decorators; + /// /// Represents the outcome of merging one into another /// @@ -31,11 +33,13 @@ public class MergeResult /// /// Gets or sets the records that could not be merged automatically /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] public List Conflict { get; set; } = []; /// /// Gets or sets the that records the merge /// + [Property(lowerValue: 0, upperValue: 1)] public Guid MergeCommit { get; set; } } } \ No newline at end of file diff --git a/SysML2.NET/PIM/DTO/PrimitiveConstraint.cs b/SysML2.NET/PIM/DTO/PrimitiveConstraint.cs index f1de4a81a..8c0978d3b 100644 --- a/SysML2.NET/PIM/DTO/PrimitiveConstraint.cs +++ b/SysML2.NET/PIM/DTO/PrimitiveConstraint.cs @@ -22,30 +22,36 @@ namespace SysML2.NET.PIM.DTO { using System.Collections.Generic; + using SysML2.NET.Decorators; + /// - /// a subtype of Constraint that represents simple conditions that be modeled using the + /// a concrete subtype of that represents simple conditions that be modeled using the /// property-operator -value tuple. e.g. mass <= 4 kg, or type instanceOf Generalization /// - public class PrimitiveConstraint + public class PrimitiveConstraint : Constraint { /// /// Gets or sets the name of a property of Element or its subtypes that is being constrained /// + [Property(lowerValue: 1, upperValue: 1)] public string Property { get; set; } /// /// Gets or sets the mathematical operators /// + [Property(lowerValue: 1, upperValue: 1)] public Operator Operator { get; set; } /// /// Gets or sets list of primitive objects, such as String, Boolean, Integer, Double, and UUID /// + [Property(lowerValue: 1, upperValue: int.MaxValue)] public List Value { get; set;} = []; /// /// Gets or sets a value indicating a logical NOT operator is applied to the /// + [Property(lowerValue: 1, upperValue: 1)] public bool Inverse { get; set; } } } diff --git a/SysML2.NET/PIM/DTO/Project.cs b/SysML2.NET/PIM/DTO/Project.cs index f85036624..5c5484b5b 100644 --- a/SysML2.NET/PIM/DTO/Project.cs +++ b/SysML2.NET/PIM/DTO/Project.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.DTO using System; using System.Collections.Generic; + using SysML2.NET.Decorators; using SysML2.NET.PIM; /// @@ -34,26 +35,56 @@ public class Project : Record /// /// Gets or sets the collection of /// - public List Commits { get; set; } = new List(); + [Property(lowerValue: 0, upperValue: int.MaxValue)] + public List Commits { get; set; } = []; + + /// + /// Gets or sets the set of all s in the + /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] + public List CommitReferences { get; set; } = []; + + /// + /// Gets or sets the set of all es in the + /// + /// + /// A has one or more branches; a default branch is created with the . + /// + [Property(lowerValue: 1, upperValue: int.MaxValue)] + [SubsettedProperty(propertyName: "Project.CommitReferences")] + public List Branches { get; set; } = []; + + /// + /// Gets or sets the set of all s in the + /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] + [SubsettedProperty(propertyName: "Project.CommitReferences")] + public List Tags { get; set; } = []; /// /// Gets or sets the when the project was created /// + [Property(lowerValue: 1, upperValue: 1)] public DateTime Created { get; set; } /// /// Gets or sets the human readable name /// + [Property(lowerValue: 1, upperValue: 1)] + [RedefinedProperty(propertyName: "Record.Name")] public new string Name { get; set; } /// /// Gets or sets the default in the which is a subset of /// + [Property(lowerValue: 1, upperValue: 1)] + [SubsettedProperty(propertyName: "Project.Branches")] public Guid DefaultBranch { get; set; } /// /// Gets or sets the collection of /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] public List Queries { get; set; } = []; } } diff --git a/SysML2.NET/PIM/DTO/ProjectUsage.cs b/SysML2.NET/PIM/DTO/ProjectUsage.cs index 03ce74367..0b4c05dc8 100644 --- a/SysML2.NET/PIM/DTO/ProjectUsage.cs +++ b/SysML2.NET/PIM/DTO/ProjectUsage.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.DTO using System; using SysML2.NET.Common; + using SysML2.NET.Decorators; /// /// a realization of that represents the use of a in the context of another @@ -33,16 +34,19 @@ public class ProjectUsage : IData /// /// Gets or sets the unique identifier /// + [Property(lowerValue: 1, upperValue: 1, isReadOnly: true)] public Guid Id { get; set; } /// /// Gets or sets the reference to the of the being used. /// + [Property(lowerValue: 1, upperValue: 1)] public Guid UsedCommit { get; set; } /// /// Gets or sets the reference to the of the being used. /// + [Property(lowerValue: 1, upperValue: 1)] public Guid UsedProject { get; set; } } } diff --git a/SysML2.NET/PIM/DTO/Query.cs b/SysML2.NET/PIM/DTO/Query.cs index e178a3d1d..22df598c4 100644 --- a/SysML2.NET/PIM/DTO/Query.cs +++ b/SysML2.NET/PIM/DTO/Query.cs @@ -23,6 +23,8 @@ namespace SysML2.NET.PIM.DTO using System; using System.Collections.Generic; + using SysML2.NET.Decorators; + /// /// is a subclass of that represents a precise and language-independent /// request for information retrieval using the Systems Modeling API and Services. @@ -33,24 +35,44 @@ public class Query : Record /// /// Gets or sets the name of the Query /// + [Property(lowerValue: 1, upperValue: 1)] + [RedefinedProperty(propertyName: "Record.Name")] public new string Name { get; set; } + /// + /// Gets or sets the that owns the + /// + [Property(lowerValue: 1, upperValue: 1)] + public Guid Project { get; set; } + /// /// list of properties of Element or its subtypes that will be included for each Element object in the /// query response. Element is the root-metaclass in KerML. If no properties are specified, then all the /// properties will be included for each Element in the query response /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] public List Select { get; set; } = []; /// /// represents the conditions that Elements in the query response must satisfy /// + [Property(lowerValue: 1, upperValue: 1)] public Constraint Where { get; set; } /// /// list of Data objects that define the scope context for query execution. The default scope of a /// Query is the owning Project /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] public List Scope { get; set; } = []; + + /// + /// Gets or sets the list of properties used for sorting the data objects in the query response + /// + /// + /// The order of the properties in the list governs the sorting order. + /// + [Property(lowerValue: 0, upperValue: int.MaxValue, isOrdered: true)] + public List OrderBy { get; set; } = []; } } diff --git a/SysML2.NET/PIM/DTO/Tag.cs b/SysML2.NET/PIM/DTO/Tag.cs index e0e50414e..1e073e48e 100644 --- a/SysML2.NET/PIM/DTO/Tag.cs +++ b/SysML2.NET/PIM/DTO/Tag.cs @@ -22,6 +22,8 @@ namespace SysML2.NET.PIM.DTO { using System; + using SysML2.NET.Decorators; + /// /// a is used for annotating specific commits-of-interest during development, /// such as for representing milestones, releases, baselines, or snapshots. A @@ -32,6 +34,7 @@ public class Tag : CommitReference /// /// Gets or sets a reference to the tagged /// + [Property(lowerValue: 1, upperValue: 1)] public Guid TaggedCommit { get; set; } } } diff --git a/SysML2.NET/PIM/POCO/Branch.cs b/SysML2.NET/PIM/POCO/Branch.cs index 9f549c9ff..864c006ff 100644 --- a/SysML2.NET/PIM/POCO/Branch.cs +++ b/SysML2.NET/PIM/POCO/Branch.cs @@ -20,10 +20,12 @@ namespace SysML2.NET.PIM.POCO { + using SysML2.NET.Decorators; + /// /// A is a type of . A is a pointer to a (Branch.head). /// The history of a on a given can be computed by recursively navigating - /// , starting from the head of the (Branch.head) + /// , starting from the head of the (Branch.head) /// public class Branch : CommitReference { @@ -31,6 +33,7 @@ public class Branch : CommitReference /// Gets or sets the commit to which the branch is currently pointing. It represents the latest state of the /// on the given branch /// + [Property(lowerValue: 1, upperValue: 1)] public Commit Head { get; set; } } } \ No newline at end of file diff --git a/SysML2.NET/PIM/POCO/Commit.cs b/SysML2.NET/PIM/POCO/Commit.cs index 3b5c23993..7e9a8b818 100644 --- a/SysML2.NET/PIM/POCO/Commit.cs +++ b/SysML2.NET/PIM/POCO/Commit.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.POCO using System; using System.Collections.Generic; + using SysML2.NET.Decorators; using SysML2.NET.PIM; /// @@ -44,27 +45,35 @@ public class Commit : Record /// /// Gets or sets the timestamp at which the was created /// + [Property(lowerValue: 1, upperValue: 1)] public DateTime Created { get; set; } /// /// Gets or sets the that owns the . /// + [Property(lowerValue: 1, upperValue: 1)] public Project OwningProject { get; set; } /// /// Gets or sets the set of immediately preceding s /// - public List PreviousCommit { get; set; } = new List(); + [Property(lowerValue: 0, upperValue: int.MaxValue)] + public List PreviousCommits { get; set; } = []; /// /// Gets or sets the the set of records representing that is /// created, updated, or deleted in the /// - public List Change { get; set; } = new List(); + [Property(lowerValue: 1, upperValue: int.MaxValue)] + public List Change { get; set; } = []; /// /// Queries the derived property VersionedData /// + /// The set of cumulative records at the . + /// Thrown until the derivation is supported. + [Property(lowerValue: 0, upperValue: int.MaxValue, isDerived: true)] + [DerivedProperty(name: "VersionedData")] public List QueryVersionedData() { throw new NotImplementedException("Derived property VersionedData not yet supported"); diff --git a/SysML2.NET/PIM/POCO/CommitReference.cs b/SysML2.NET/PIM/POCO/CommitReference.cs index 9a8c1053b..a296c0465 100644 --- a/SysML2.NET/PIM/POCO/CommitReference.cs +++ b/SysML2.NET/PIM/POCO/CommitReference.cs @@ -22,9 +22,11 @@ namespace SysML2.NET.PIM.POCO { using System; + using SysML2.NET.Decorators; + /// /// An abstract subclass of that references a specific (Commit Reference.referencedCommit). Project.commit is the set of all the Commit records for a given Project. - /// identifies specific records in a that provide the context for navigating the + /// identifies specific records in a that provide the context for navigating the /// in a Project. Two special types of are and /// public abstract class CommitReference : Record @@ -32,21 +34,26 @@ public abstract class CommitReference : Record /// /// Gets or sets the timestamp at which the was created. /// + [Property(lowerValue: 1, upperValue: 1)] public DateTime Created { get; set; } /// /// Gets or sets the timestamp at which the was deleted /// + [Property(lowerValue: 1, upperValue: 1)] public DateTime Deleted { get; set; } /// /// Gets or sets the name of the /// + [Property(lowerValue: 1, upperValue: 1)] + [RedefinedProperty(propertyName: "Record.Name")] public new string Name { get; set; } /// /// Gets or sets the Project that owns the given /// + [Property(lowerValue: 1, upperValue: 1)] public Project OwningProject { get; set; } } } diff --git a/SysML2.NET/PIM/POCO/CompositeConstraint.cs b/SysML2.NET/PIM/POCO/CompositeConstraint.cs index 7a49f2845..08172eea0 100644 --- a/SysML2.NET/PIM/POCO/CompositeConstraint.cs +++ b/SysML2.NET/PIM/POCO/CompositeConstraint.cs @@ -22,8 +22,10 @@ namespace SysML2.NET.PIM.POCO { using System.Collections.Generic; + using SysML2.NET.Decorators; + /// - /// a subtype of that represents complex conditions composed of two or more + /// a concrete subtype of that represents complex conditions composed of two or more /// s or s using logical AND or OR operators /// public class CompositeConstraint : Constraint @@ -34,11 +36,13 @@ public class CompositeConstraint : Constraint /// /// There must be at least 2 /// + [Property(lowerValue: 2, upperValue: int.MaxValue)] public List Constraint { get; set; } = []; /// /// Gets or sets the logical operator for composing the s /// + [Property(lowerValue: 1, upperValue: 1)] public JoinOperator Operator { get; set; } } } diff --git a/SysML2.NET/PIM/POCO/DataDifference.cs b/SysML2.NET/PIM/POCO/DataDifference.cs index 67fb80d7d..fe3accbff 100644 --- a/SysML2.NET/PIM/POCO/DataDifference.cs +++ b/SysML2.NET/PIM/POCO/DataDifference.cs @@ -20,6 +20,7 @@ namespace SysML2.NET.PIM.POCO { + using SysML2.NET.Decorators; /// /// Represents a single difference between two compared versions of the same @@ -29,11 +30,13 @@ public class DataDifference /// /// Gets or sets the taken as the baseline of the comparison, or null when the data was added /// + [Property(lowerValue: 0, upperValue: 1)] public DataVersion BaseData { get; set; } /// /// Gets or sets the compared against the baseline, or null when the data was deleted /// + [Property(lowerValue: 0, upperValue: 1)] public DataVersion CompareData { get; set; } } } \ No newline at end of file diff --git a/SysML2.NET/PIM/POCO/DataIdentity.cs b/SysML2.NET/PIM/POCO/DataIdentity.cs index 5f95d8d3e..05f0b052f 100644 --- a/SysML2.NET/PIM/POCO/DataIdentity.cs +++ b/SysML2.NET/PIM/POCO/DataIdentity.cs @@ -22,6 +22,8 @@ namespace SysML2.NET.PIM.POCO { using System.Collections.Generic; + using SysML2.NET.Decorators; + /// /// A subclass of that represents a unique, version-independent representation of /// through its lifecycle. A is associated with 1 or more Version @@ -32,6 +34,7 @@ public class DataIdentity : Record /// /// Gets or sets the the set of records representing all versions of the given /// - public List Version = new List(); + [Property(lowerValue: 1, upperValue: int.MaxValue)] + public List Version { get; set; } = []; } } diff --git a/SysML2.NET/PIM/POCO/DataVersion.cs b/SysML2.NET/PIM/POCO/DataVersion.cs index 8aad1d49d..710bbc6f5 100644 --- a/SysML2.NET/PIM/POCO/DataVersion.cs +++ b/SysML2.NET/PIM/POCO/DataVersion.cs @@ -23,7 +23,8 @@ namespace SysML2.NET.PIM.POCO using System; using SysML2.NET.Common; - + using SysML2.NET.Decorators; + /// /// A subclass of that represents at a specific version in its lifecycle. /// A record is associated with only one (1) record. @@ -34,23 +35,31 @@ public class DataVersion : Record /// /// Gets or sets the at which the wrapped data (payload) was created, modified, or deleted. /// + [Property(lowerValue: 1, upperValue: 1)] public Commit Commit { get; set; } /// /// Gets or sets a reference to corresponding the /// + [Property(lowerValue: 1, upperValue: 1)] public DataIdentity Identity { get; set; } /// /// Gets or sets the payload /// + /// + /// null when no data with the given identity is present at the . + /// + [Property(lowerValue: 0, upperValue: 1)] public IData Payload { get; set; } /// /// Queries the derived property /// - /// - /// + /// The that owns the . + /// Thrown until the derivation is supported. + [Property(lowerValue: 1, upperValue: 1, isDerived: true)] + [DerivedProperty(name: "Project")] public Project QueryProject() { throw new NotImplementedException("Derived property Project not yet supported"); diff --git a/SysML2.NET/PIM/POCO/ExternalData.cs b/SysML2.NET/PIM/POCO/ExternalData.cs index 868a29a7d..45ee9a646 100644 --- a/SysML2.NET/PIM/POCO/ExternalData.cs +++ b/SysML2.NET/PIM/POCO/ExternalData.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.POCO using System; using SysML2.NET.Common; + using SysML2.NET.Decorators; /// /// ExternalData is a realization of Data, and represents a resource external to a given tool or @@ -33,11 +34,13 @@ public class ExternalData : IData /// /// Gets or sets the unique identifier /// + [Property(lowerValue: 1, upperValue: 1, isReadOnly: true)] public Guid Id { get; set; } /// /// Gets or sets the string representation of the IRI of the resource represented by the ExternalData /// + [Property(lowerValue: 1, upperValue: 1)] public string ResourceIdentifier { get; set; } } } diff --git a/SysML2.NET/PIM/POCO/ExternalRelationship.cs b/SysML2.NET/PIM/POCO/ExternalRelationship.cs index 6fbb1af54..4f6b36867 100644 --- a/SysML2.NET/PIM/POCO/ExternalRelationship.cs +++ b/SysML2.NET/PIM/POCO/ExternalRelationship.cs @@ -25,6 +25,7 @@ namespace SysML2.NET.PIM.POCO using SysML2.NET.Common; using SysML2.NET.Core.POCO; using SysML2.NET.Core.POCO.Root.Elements; + using SysML2.NET.Decorators; /// /// ExternalRelationship is a realization of Data, and represents the relationship between a @@ -37,6 +38,7 @@ public class ExternalRelationship : IData /// /// Gets or sets the unique identifier /// + [Property(lowerValue: 1, upperValue: 1)] public Guid Id { get; set; } /// @@ -46,21 +48,25 @@ public class ExternalRelationship : IData /// would contain mathematical expressions, such as equations, representing the mapping.This is an optional /// attribute. /// + [Property(lowerValue: 0, upperValue: 1)] public string Specification { get; set; } /// /// Gets or sets the name of the expression language used for the specification. This is an optional attribute. /// + [Property(lowerValue: 0, upperValue: 1)] public string Language { get; set; } /// /// Gets or sets the /// + [Property(lowerValue: 1, upperValue: 1)] public IElement ElementEnd { get; set; } /// /// Gets or sets the /// + [Property(lowerValue: 1, upperValue: 1)] public ExternalData ExternalDataEnd { get; set; } } } diff --git a/SysML2.NET/PIM/POCO/MergeResult.cs b/SysML2.NET/PIM/POCO/MergeResult.cs index ed377a44e..17c44ecd0 100644 --- a/SysML2.NET/PIM/POCO/MergeResult.cs +++ b/SysML2.NET/PIM/POCO/MergeResult.cs @@ -22,6 +22,8 @@ namespace SysML2.NET.PIM.POCO { using System.Collections.Generic; + using SysML2.NET.Decorators; + /// /// Represents the outcome of merging one into another /// @@ -30,11 +32,13 @@ public class MergeResult /// /// Gets or sets the records that could not be merged automatically /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] public List Conflict { get; set; } = []; /// /// Gets or sets the that records the merge /// + [Property(lowerValue: 0, upperValue: 1)] public Commit MergeCommit { get; set; } } } \ No newline at end of file diff --git a/SysML2.NET/PIM/POCO/PrimitiveConstraint.cs b/SysML2.NET/PIM/POCO/PrimitiveConstraint.cs index 5a106a9ad..1b1ed9196 100644 --- a/SysML2.NET/PIM/POCO/PrimitiveConstraint.cs +++ b/SysML2.NET/PIM/POCO/PrimitiveConstraint.cs @@ -22,8 +22,10 @@ namespace SysML2.NET.PIM.POCO { using System.Collections.Generic; + using SysML2.NET.Decorators; + /// - /// a subtype of Constraint that represents simple conditions that be modeled using the + /// a concrete subtype of that represents simple conditions that be modeled using the /// property-operator -value tuple. e.g. mass <= 4 kg, or type instanceOf Generalization /// public class PrimitiveConstraint : Constraint @@ -31,21 +33,25 @@ public class PrimitiveConstraint : Constraint /// /// Gets or sets the name of a property of Element or its subtypes that is being constrained /// + [Property(lowerValue: 1, upperValue: 1)] public string Property { get; set; } /// /// Gets or sets the mathematical operatores /// + [Property(lowerValue: 1, upperValue: 1)] public Operator Operator { get; set; } /// /// Gets or sets list of primitive objects, such as String, Boolean, Integer, Double, and UUID /// - public List Value { get; set; } = new List(); + [Property(lowerValue: 1, upperValue: int.MaxValue)] + public List Value { get; set; } = []; /// /// Gets or sets a value indicating a logical NOT operator is applied to the /// + [Property(lowerValue: 1, upperValue: 1)] public bool Inverse { get; set; } } } \ No newline at end of file diff --git a/SysML2.NET/PIM/POCO/Project.cs b/SysML2.NET/PIM/POCO/Project.cs index added9758..07626e172 100644 --- a/SysML2.NET/PIM/POCO/Project.cs +++ b/SysML2.NET/PIM/POCO/Project.cs @@ -25,6 +25,7 @@ namespace SysML2.NET.PIM.POCO using System.Linq; using SysML2.NET.Common; + using SysML2.NET.Decorators; using SysML2.NET.PIM; /// @@ -36,11 +37,14 @@ public class Project : Record /// /// Gets or sets a human-friendly identifier for a Project /// + [Property(lowerValue: 1, upperValue: 1)] + [RedefinedProperty(propertyName: "Record.Name")] public new string Name { get; set; } /// /// Gets or sets the timestamp at which the was created /// + [Property(lowerValue: 1, upperValue: 1)] public DateTime Created { get; set; } /// @@ -50,37 +54,47 @@ public class Project : Record /// /// this is a derived attribute /// + [Property(lowerValue: 0, upperValue: int.MaxValue, isDerived: true)] public IEnumerable IdentifiedData => throw new NotImplementedException(); /// /// Gets all the s in the /// - public List Commits { get; set; } = new List(); + [Property(lowerValue: 0, upperValue: int.MaxValue)] + public List Commits { get; set; } = []; /// /// Gets or sets all s in the /// - public List CommitReference { get; set; } = new List(); + [Property(lowerValue: 0, upperValue: int.MaxValue)] + public List CommitReferences { get; set; } = []; /// - /// Gets or sets all the branches in the Project which is a subset of + /// Gets all the branches in the which is a subset of /// - public IEnumerable Branches => this.CommitReference.OfType(); + [Property(lowerValue: 1, upperValue: int.MaxValue, isDerived: true)] + [SubsettedProperty(propertyName: "Project.CommitReferences")] + public IEnumerable Branches => this.CommitReferences.OfType(); /// /// Gets or sets the default in the which is a subset of /// + [Property(lowerValue: 1, upperValue: 1)] + [SubsettedProperty(propertyName: "Project.Branches")] public Branch DefaultBranch { get; set; } /// - /// Gets all the s in the which is a subset of + /// Gets all the s in the which is a subset of /// - public IEnumerable Tags => this.CommitReference.OfType(); + [Property(lowerValue: 0, upperValue: int.MaxValue, isDerived: true)] + [SubsettedProperty(propertyName: "Project.CommitReferences")] + public IEnumerable Tags => this.CommitReferences.OfType(); /// /// Gets or sets the records owned by the . Each record represents a /// saved for the given . /// - public List Queries { get; set; } = new List(); + [Property(lowerValue: 0, upperValue: int.MaxValue)] + public List Queries { get; set; } = []; } } diff --git a/SysML2.NET/PIM/POCO/ProjectUsage.cs b/SysML2.NET/PIM/POCO/ProjectUsage.cs index 29e1a375c..d5e91c605 100644 --- a/SysML2.NET/PIM/POCO/ProjectUsage.cs +++ b/SysML2.NET/PIM/POCO/ProjectUsage.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.POCO using System; using SysML2.NET.Common; + using SysML2.NET.Decorators; /// /// a realization of that represents the use of a in the context of another @@ -33,16 +34,19 @@ public class ProjectUsage : IData /// /// Gets or sets the unique identifier /// + [Property(lowerValue: 1, upperValue: 1, isReadOnly: true)] public Guid Id { get; set; } /// /// Gets or sets the reference to the of the being used. /// + [Property(lowerValue: 1, upperValue: 1)] public Commit UsedCommit { get; set; } /// /// Gets or sets the reference to the being used. /// + [Property(lowerValue: 1, upperValue: 1)] public Project UsedProject { get; set; } } } diff --git a/SysML2.NET/PIM/POCO/Query.cs b/SysML2.NET/PIM/POCO/Query.cs index 1e64da087..a31388a2a 100644 --- a/SysML2.NET/PIM/POCO/Query.cs +++ b/SysML2.NET/PIM/POCO/Query.cs @@ -23,6 +23,7 @@ namespace SysML2.NET.PIM.POCO using System.Collections.Generic; using SysML2.NET.Common; + using SysML2.NET.Decorators; /// /// is a subclass of that represents a precise and language-independent @@ -34,30 +35,42 @@ public class Query : Record /// /// Gets or sets the name of the Query /// + [Property(lowerValue: 1, upperValue: 1)] + [RedefinedProperty(propertyName: "Record.Name")] public new string Name { get; set; } + /// + /// Gets or sets the that owns the + /// + [Property(lowerValue: 1, upperValue: 1)] + public Project Project { get; set; } + /// /// list of properties of Element or its subtypes that will be included for each Element object in the /// query response. Element is the root-metaclass in KerML. If no properties are specified, then all the /// properties will be included for each Element in the query response /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] public List Select { get; set; } = []; /// /// Gets or sets the list of Element objects that define the scope for query execution. The default scope of a is - /// the owning + /// the owning /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] public List Scope { get; set; } = []; /// /// represents the conditions that Elements in the query response must satisfy /// + [Property(lowerValue: 1, upperValue: 1)] public Constraint Where { get; set; } /// /// Gets or sets a list of properties of Data (or its realizations) that are used for sorting the Data objects in the /// query response.The order of properties in the list governs the sorting order /// + [Property(lowerValue: 0, upperValue: int.MaxValue, isOrdered: true)] public List OrderBy { get; set; } = []; } } diff --git a/SysML2.NET/PIM/POCO/Tag.cs b/SysML2.NET/PIM/POCO/Tag.cs index 746f35548..47940d448 100644 --- a/SysML2.NET/PIM/POCO/Tag.cs +++ b/SysML2.NET/PIM/POCO/Tag.cs @@ -22,6 +22,8 @@ namespace SysML2.NET.PIM.POCO { using System; + using SysML2.NET.Decorators; + /// /// a is used for annotating specific commits-of-interest during development, /// such as for representing milestones, releases, baselines, or snapshots. A @@ -33,6 +35,7 @@ public class Tag : CommitReference /// Gets or sets a reference to the which the Tag is pointing. It represents a /// -of-interest in the owning . /// + [Property(lowerValue: 1, upperValue: 1)] public Commit TaggedCommit { get; set; } } } diff --git a/SysML2.NET/PIM/Record.cs b/SysML2.NET/PIM/Record.cs index 295e4a6a2..caf6522a4 100644 --- a/SysML2.NET/PIM/Record.cs +++ b/SysML2.NET/PIM/Record.cs @@ -1,20 +1,20 @@ // ------------------------------------------------------------------------------------------------- // -// +// // Copyright 2022-2025 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. -// +// // // ------------------------------------------------------------------------------------------------ @@ -24,6 +24,7 @@ namespace SysML2.NET.PIM using System.Collections.Generic; using SysML2.NET.Common; + using SysML2.NET.Decorators; /// /// A Record represents any data that is consumed (input) or produced (output) by the Systems Modeling API @@ -42,28 +43,34 @@ protected Record() /// /// Gets or sets the unique identifier of the /// + [Property(lowerValue: 1, upperValue: 1)] public Guid Id { get; set; } /// /// Gets or sets string representation of the IRI for the /// + [Property(lowerValue: 0, upperValue: 1)] public string ResourceIdentifier { get; set; } /// /// Gets or sets a collection of other identifiers for this record, especially if the record was created or represented /// in other software applications and systems /// + [Property(lowerValue: 0, upperValue: int.MaxValue)] public List Alias { get; set; } /// /// Gets or sets a statement that provides details about the . /// + [Property(lowerValue: 1, upperValue: 1)] public string Description { get; set; } /// /// Gets or sets an optional human-friendly identifier for a record. The value assigned to the name for a given /// record must be in the set of values assigned to alias for that record /// + [Property(lowerValue: 0, upperValue: 1)] + [SubsettedProperty(propertyName: "Record.Alias")] public string Name { get; set; } } }