Skip to content

Commit 0cd6371

Browse files
[WIP] Implementation of hand-coded conditional checks
1 parent de4ae2f commit 0cd6371

23 files changed

Lines changed: 86 additions & 24 deletions

SysML2.NET/TextualNotation/AcceptActionUsageTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static partial class AcceptActionUsageTextualNotationBuilder
3434
/// <returns>The assertion of the condition</returns>
3535
private static bool BuildGroupConditionForTransitionAcceptActionUsage(IAcceptActionUsage poco)
3636
{
37-
return false;
37+
return poco.OwnedRelationship.Count != 0;
3838
}
3939
}
4040
}

SysML2.NET/TextualNotation/ActionUsageTextualNotationBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static partial class ActionUsageTextualNotationBuilder
3434
/// <returns>The assertion of the condition</returns>
3535
private static bool BuildGroupConditionForActionBodyParameter(IActionUsage poco)
3636
{
37-
return false;
37+
return CommonTextualNotationBuilder.DoesDefinesUsageDeclaration(poco);
3838
}
3939

4040
/// <summary>
@@ -44,7 +44,7 @@ private static bool BuildGroupConditionForActionBodyParameter(IActionUsage poco)
4444
/// <returns>The assertion of the condition</returns>
4545
private static bool BuildGroupConditionForAssignmentNodeDeclaration(IActionUsage poco)
4646
{
47-
return false;
47+
return CommonTextualNotationBuilder.DoesDefinesUsageDeclaration(poco);
4848
}
4949
}
5050
}

SysML2.NET/TextualNotation/AssignmentActionUsageTextualNotationBuilder.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
namespace SysML2.NET.TextualNotation
2222
{
23+
using System.Linq;
24+
25+
using SysML2.NET.Core.POCO.Core.Features;
2326
using SysML2.NET.Core.POCO.Systems.Actions;
2427

2528
/// <summary>
@@ -34,7 +37,7 @@ public static partial class AssignmentActionUsageTextualNotationBuilder
3437
/// <returns>The assertion of the condition</returns>
3538
private static bool BuildGroupConditionForTransitionAssignmentActionUsage(IAssignmentActionUsage poco)
3639
{
37-
return false;
40+
return poco.OwnedRelationship.OfType<IFeature>().Any();
3841
}
3942
}
4043
}

SysML2.NET/TextualNotation/BindingConnectorAsUsageTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static partial class BindingConnectorAsUsageTextualNotationBuilder
3434
/// <returns>The assertion of the condition</returns>
3535
private static bool BuildGroupConditionForBindingConnectorAsUsage(IBindingConnectorAsUsage poco)
3636
{
37-
return false;
37+
return CommonTextualNotationBuilder.DoesDefinesUsageDeclaration(poco);
3838
}
3939
}
4040
}

SysML2.NET/TextualNotation/CommentTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static partial class CommentTextualNotationBuilder
3434
/// <returns>The assertion of the condition</returns>
3535
private static bool BuildGroupConditionForComment(IComment poco)
3636
{
37-
return false;
37+
return CommonTextualNotationBuilder.DoesDefinesIdentificationProperties(poco) || poco.ownedAnnotation.Count != 0;
3838
}
3939
}
4040
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// -------------------------------------------------------------------------------------------------
2+
// <copyright file="CommonTextualNotationBuilder.cs" company="Starion Group S.A.">
3+
//
4+
// Copyright 2022-2026 Starion Group S.A.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// </copyright>
19+
// ------------------------------------------------------------------------------------------------
20+
21+
namespace SysML2.NET.TextualNotation
22+
{
23+
using System.Linq;
24+
25+
using SysML2.NET.Core.POCO.Core.Features;
26+
using SysML2.NET.Core.POCO.Root.Elements;
27+
using SysML2.NET.Core.POCO.Systems.DefinitionAndUsage;
28+
29+
/// <summary>
30+
/// Textual Notation Builder that provides common features, usable by others builder
31+
/// </summary>
32+
public static class CommonTextualNotationBuilder
33+
{
34+
/// <summary>
35+
/// Asserts that an <see cref="IElement"/> defines properties used by the Identification rule
36+
/// </summary>
37+
/// <param name="poco">The <see cref="IElement"/></param>
38+
/// <returns>True if the <see cref="IElement.DeclaredName"/> or <see cref="IElement.DeclaredShortName"/> is defined</returns>
39+
public static bool DoesDefinesIdentificationProperties(IElement poco)
40+
{
41+
return !string.IsNullOrWhiteSpace(poco.DeclaredName) || !string.IsNullOrWhiteSpace(poco.DeclaredShortName);
42+
}
43+
44+
/// <summary>
45+
/// Asserts that an <see cref="IUsage"/> defines properties used by the UsageDeclaration rule
46+
/// </summary>
47+
/// <param name="poco">The <see cref="IUsage"/></param>
48+
/// <returns>True if respects the <see cref="DoesDefinesIdentificationProperties"/> or have <see cref="IElement.OwnedRelationship"/> not empty</returns>
49+
public static bool DoesDefinesUsageDeclaration(IElement poco)
50+
{
51+
return DoesDefinesIdentificationProperties(poco) || poco.OwnedRelationship.OfType<IFeature>().Any();
52+
}
53+
}
54+
}

SysML2.NET/TextualNotation/ConjugationTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static partial class ConjugationTextualNotationBuilder
3434
/// <returns>The assertion of the condition</returns>
3535
private static bool BuildGroupConditionForConjugation(IConjugation poco)
3636
{
37-
return false;
37+
return CommonTextualNotationBuilder.DoesDefinesIdentificationProperties(poco);
3838
}
3939
}
4040
}

SysML2.NET/TextualNotation/DependencyTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static partial class DependencyTextualNotationBuilder
3434
/// <returns>The assertion of the condition</returns>
3535
private static bool BuildGroupConditionForDependencyDeclaration(IDependency poco)
3636
{
37-
return false;
37+
return poco.Client.Count != 0 && poco.Supplier.Count != 0;
3838
}
3939
}
4040
}

SysML2.NET/TextualNotation/DisjoiningTextualNotationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static partial class DisjoiningTextualNotationBuilder
3434
/// <returns>The assertion of the condition</returns>
3535
private static bool BuildGroupConditionForDisjoining(IDisjoining poco)
3636
{
37-
return false;
37+
return CommonTextualNotationBuilder.DoesDefinesIdentificationProperties(poco);
3838
}
3939
}
4040
}

SysML2.NET/TextualNotation/FeatureInvertingTextualNotationBuilder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace SysML2.NET.TextualNotation
2222
{
23+
using System.Buffers;
24+
2325
using SysML2.NET.Core.POCO.Core.Features;
2426

2527
/// <summary>
@@ -34,7 +36,7 @@ public static partial class FeatureInvertingTextualNotationBuilder
3436
/// <returns>The assertion of the condition</returns>
3537
private static bool BuildGroupConditionForFeatureInverting(IFeatureInverting poco)
3638
{
37-
return false;
39+
return CommonTextualNotationBuilder.DoesDefinesIdentificationProperties(poco);
3840
}
3941
}
4042
}

0 commit comments

Comments
 (0)