Skip to content

Commit b0eee07

Browse files
authored
[#68] Integrate Model Orphans Reporting (#69)
* [#68] Integrate Model Orphans Reporting
1 parent 7a96cb4 commit b0eee07

File tree

11 files changed

+132
-26
lines changed

11 files changed

+132
-26
lines changed

.github/workflows/TestModelCheck.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
./LemonTree.Pipeline.Tools.ModelCheck --model "${{inputs.model-path}}" --tablesize --out "./output.md"
5050
}
5151
elseif ('${{runner.os}}' -eq 'Windows') {
52-
./LemonTree.Pipeline.Tools.ModelCheck.exe --model "${{inputs.model-path}}" --tablesize --out "./output.md"
52+
./LemonTree.Pipeline.Tools.ModelCheck.exe --model "${{inputs.model-path}}" --tablesize --orphans --out "./output.md"
5353
}
5454
else {
5555
Write-Output "${{runner.os}} is not supported"

.github/workflows/release.yml

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ on:
44
release:
55
types: [created]
66

7+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
deployments: write
13+
714
jobs:
815
prepareVersion:
916
runs-on: windows-latest

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,6 @@ src/Models/GPUCache/data_2
354354
src/Models/GPUCache/data_3
355355
src/Models/GPUCache/index
356356
*.ldb
357+
/.obsidian/appearance.json
358+
/.obsidian/core-plugins.json
359+
/.obsidian/workspace.json

.obsidian/app.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ https://nexus.lieberlieber.com/#browse/browse:lemontree-pipeline-tools
77
Used to check Models for LemonTree Readiness.
88
https://nexus.lieberlieber.com/repository/lemontree-pipeline-tools/LemonTree.Pipeline.Tools.ModelCheck.exe
99

10+
### Commandline Reference
11+
12+
```
13+
--Out File to output .md e.g.: 'out.md'
14+
15+
--NoCompact If set the Checks that compact the Model are not run!
16+
17+
--FailOnErrors If set the Exitcode will be 2 if there is at least on Check of Status Error!
18+
19+
--FailOnWarnings If set the Exitcode will be 1 if there is at least on Check of Status Warning!
20+
21+
--TableSize If set the size of the tables in the database will be reported!
22+
23+
--Orphans If set Model Orphans will be reported!
24+
25+
--Model Required. The 'Model' used for the operation.
26+
27+
--help Display this help screen.
28+
29+
--version Display version information.
30+
```
1031

1132
### Powershell Example:
1233
```

src/LemonTree.Pipeline.Tools.ModelCheck/Checks/Checks.cs

+58-6
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ select count(t_object.Object_Type) as ['Count'], t_object.Object_Type as ['Measu
410410

411411
result.Level = IssueLevel.Information;
412412
result.Title = "Project Statistics";
413+
result.Detail = "Executed Project Statistics on Model";
413414

414415

415-
416-
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
416+
result.Markdown = ToMD(resultTable.DefaultView.ToTable(), header: true);
417417

418418

419419
#endregion
@@ -431,11 +431,8 @@ internal static Issue CheckTableSize(string model)
431431
//resultTable.DefaultView.Sort = "table_size";
432432
resultTable.Columns[1].ColumnName = "table_size (bytes)";
433433

434-
Console.WriteLine(ToMD(resultTable, header: true));
435-
436434
#endregion
437435

438-
439436
#region process result table and calculate Issue number
440437

441438

@@ -447,10 +444,65 @@ internal static Issue CheckTableSize(string model)
447444

448445
result.Level = IssueLevel.Information;
449446
result.Title = "Table Statistics (all >32)";
447+
result.Detail = $"Found {resultTable.Rows.Count} Tables bigger 32";
448+
449+
450+
result.Markdown = ToMD(resultTable.DefaultView.ToTable(), header: true);
451+
452+
453+
#endregion
454+
455+
return result;
456+
}
457+
458+
internal static Issue CheckModelOrphans(string model)
459+
{
460+
#region get result table
461+
462+
const string statisticSql = @"
463+
SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, t_object.*
464+
FROM t_object
465+
WHERE t_object.Object_Type <> 'Package'
466+
AND t_object.Object_ID NOT IN (SELECT t_diagramobjects.Object_ID FROM t_diagramobjects)
467+
AND t_object.Object_ID NOT IN (SELECT t_object.Classifier FROM t_object WHERE t_object.Classifier <> 0)
468+
AND t_object.Object_ID NOT IN (SELECT a.Object_ID FROM t_object AS a JOIN t_object AS b ON b.PDATA1 = a.ea_guid)
469+
AND t_object.Object_ID NOT IN (SELECT CAST(t_attribute.Classifier AS INTEGER) FROM t_attribute WHERE t_attribute.Classifier <> '0' AND t_attribute.Classifier <> '')
470+
AND t_object.Object_ID NOT IN (SELECT CAST(t_operation.Classifier AS INTEGER) FROM t_operation WHERE t_operation.Classifier <> '0' AND t_operation.Classifier <> '')
471+
AND t_object.Object_ID NOT IN (SELECT CAST(t_operationparams.Classifier AS INTEGER) FROM t_operationparams WHERE t_operationparams.Classifier <> '0' AND t_operationparams.Classifier <> '')
472+
AND t_object.Object_ID NOT IN (SELECT t_connector.Start_Object_ID FROM t_connector)
473+
AND t_object.Object_ID NOT IN (SELECT t_connector.End_Object_ID FROM t_connector)
474+
AND t_object.Object_ID NOT IN (SELECT t_object.ParentID FROM t_object)
475+
AND t_object.Object_ID NOT IN (SELECT t_object.Object_ID FROM t_xref JOIN t_object ON t_xref.Description LIKE '%' || t_object.ea_guid || '%' WHERE t_xref.Name = 'MOFProps')
476+
AND t_object.ea_guid NOT IN (SELECT t_operation.Behaviour FROM t_operation WHERE t_operation.Behaviour <> '')
477+
AND t_object.Object_ID NOT IN (SELECT CAST(t_connector.PDATA1 AS INTEGER) FROM t_connector WHERE t_connector.Connector_Type = 'Association' AND t_connector.SubType = 'Class');
478+
";
479+
480+
var resultTable = ModelAccess.RunSql(statisticSql);
450481

482+
#endregion
483+
484+
#region process result table and calculate Issue number
451485

452486

453-
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
487+
#endregion
488+
489+
#region set Issue Level
490+
491+
Issue result = new Issue();
492+
493+
result.Level = IssueLevel.Information;
494+
result.Title = "Model Orphans Statistics";
495+
496+
497+
if (resultTable.Rows.Count > 0)
498+
{
499+
result.Markdown = ToMD(resultTable.DefaultView.ToTable(), header: true);
500+
result.Detail = $"Found {resultTable.Rows.Count} Orphans in Model";
501+
}
502+
else
503+
{
504+
result.Detail = "No Orphans found in Model!";
505+
}
454506

455507

456508
#endregion

src/LemonTree.Pipeline.Tools.ModelCheck/Checks/Issue.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ internal class Issue
66
internal string Detail { get; set; }
77
internal string Title { get; set; }
88

9+
internal string Markdown { get; set; }
10+
911
internal string Symbol
1012
{
1113
get

src/LemonTree.Pipeline.Tools.ModelCheck/Checks/Issues.cs

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ internal string ToMd()
1717
var mySortedList = this.OrderBy(x => x.Level);
1818
foreach (Issue issue in mySortedList)
1919
{
20-
21-
2220
sb.AppendLine($"|{issue.Symbol}|{issue.Level}|{issue.Title}|{issue.Detail}|");
2321
}
2422
return sb.ToString();

src/LemonTree.Pipeline.Tools.ModelCheck/CommandLineOptions/ModelCheckOptions.cs

+3
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ internal class ModelCheckOptions:BaseOptions
1919

2020
[Option("TableSize", Required = false, HelpText = "If set the size of the tables in the database will be reported!")]
2121
public bool TableSize { get; set; }
22+
23+
[Option("Orphans", Required = false, HelpText = "If set Model Orphans will be reported!")]
24+
public bool Orphans { get; set; }
2225
}
2326
}

src/LemonTree.Pipeline.Tools.ModelCheck/Program.cs

+31-16
Original file line numberDiff line numberDiff line change
@@ -69,39 +69,54 @@ private static int RunModelCheck(ModelCheckOptions opts)
6969
issues.AddIfNotNull(Checks.Checks.CheckStrippedCompact(opts.Model));
7070
}
7171

72-
73-
// issues.WriteOutPut(Checks.Checks.CheckProjectStatitics(opts.Model));
74-
75-
76-
Console.WriteLine(issues.ToString());
77-
78-
StringBuilder sb = new StringBuilder();
79-
sb.AppendLine(issues.ToMd());
80-
sb.AppendLine("# Project Statistics");
81-
sb.AppendLine(Checks.Checks.CheckProjectStatitics(opts.Model).Detail);
82-
72+
Issue resultTableSize = null;
8373
if (opts.TableSize == true)
8474
{
8575
if (ModelAccess.IsSqlLite())
8676
{
87-
sb.AppendLine(Checks.Checks.CheckTableSize(opts.Model).Detail);
77+
resultTableSize = Checks.Checks.CheckTableSize(opts.Model);
78+
79+
issues.AddIfNotNull(resultTableSize);
8880
}
8981
else
9082
{
9183
Console.WriteLine("Talbesize reporting only supported for SqlLite!");
9284
}
9385
}
9486

95-
87+
Issue resultOrphans = null;
88+
if (opts.Orphans == true)
89+
{
90+
if (ModelAccess.IsSqlLite())
91+
{
92+
resultOrphans = Checks.Checks.CheckModelOrphans(opts.Model);
93+
issues.AddIfNotNull(resultOrphans);
94+
}
95+
else
96+
{
97+
Console.WriteLine("Orphans reporting only supported for SqlLite!");
98+
}
99+
}
96100

101+
Console.WriteLine(issues.ToString());
102+
StringBuilder sb = new StringBuilder();
103+
sb.AppendLine(issues.ToMd());
104+
sb.AppendLine("# Project Statistics");
105+
sb.AppendLine(Checks.Checks.CheckProjectStatitics(opts.Model).Markdown);
106+
if (resultTableSize != null)
107+
{
108+
sb.AppendLine(resultTableSize.Markdown);
109+
}
110+
if (resultOrphans != null)
111+
{
112+
sb.AppendLine(resultOrphans.Markdown);
113+
}
97114

98115
if (opts.Out != null)
99116
{
100-
File.WriteAllText(opts.Out, sb.ToString());
117+
File.WriteAllText(opts.Out, sb.ToString());
101118
}
102119

103-
104-
105120
if (opts.FailOnErrors == true)
106121
{
107122
if (issues.HasErrors())

src/LemonTree.Pipeline.Tools.ModelCheck/Properties/launchSettings.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"profiles": {
33
"LemonTree.Pipeline.Tools.ModelCheck": {
44
"commandName": "Project",
5-
"commandLineArgs": "--model models\\model.qeax --tablesize"
5+
"commandLineArgs": "--model models\\model.qeax --tablesize --orphans"
6+
},
7+
"ExampleModel": {
8+
"commandName": "Project",
9+
"commandLineArgs": "--model \"C:\\repos\\SixthForth\\lemontree_demo\\EAExample.qeax\" --tablesize --orphans"
610
}
711
}
812
}

0 commit comments

Comments
 (0)