Skip to content

Commit 286444c

Browse files
committed
[#68] Integrate Model Orphans Reporting
Added Model Orphan Support
1 parent 7a96cb4 commit 286444c

File tree

5 files changed

+77
-6
lines changed

5 files changed

+77
-6
lines changed

.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

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

+41
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,47 @@ internal static Issue CheckTableSize(string model)
453453
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
454454

455455

456+
#endregion
457+
458+
return result;
459+
}
460+
461+
internal static Issue CheckModelOrphans(string model)
462+
{
463+
#region get result table
464+
465+
const string statisticSql = @"SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, t_object.* FROM t_object WHERE t_object.Object_Type <> 'Package' AND t_object.Object_ID NOT IN (SELECT t_diagramobjects.Object_ID FROM t_diagramobjects) AND t_object.Object_ID NOT IN (SELECT t_object.Classifier FROM t_object WHERE t_object.Classifier <> 0) 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) 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 <> '') 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 <> '') 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 <> '') AND t_object.Object_ID NOT IN (SELECT t_connector.Start_Object_ID FROM t_connector) AND t_object.Object_ID NOT IN (SELECT t_connector.End_Object_ID FROM t_connector) AND t_object.Object_ID NOT IN (SELECT t_object.ParentID FROM t_object) 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' ) AND t_object.ea_guid NOT IN ( SELECT t_operation.Behaviour FROM t_operation WHERE t_operation.Behaviour <> '' ) 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' );";
466+
467+
var resultTable = ModelAccess.RunSql(statisticSql);
468+
469+
Console.WriteLine(ToMD(resultTable, header: true));
470+
471+
#endregion
472+
473+
474+
#region process result table and calculate Issue number
475+
476+
477+
#endregion
478+
479+
#region set Issue Level
480+
481+
Issue result = new Issue();
482+
483+
result.Level = IssueLevel.Information;
484+
result.Title = "Model Orphans Statistics (all >32)";
485+
486+
487+
if (resultTable.Rows.Count > 0)
488+
{
489+
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
490+
}
491+
else
492+
{
493+
result.Detail = "No Orphans found in Model!";
494+
}
495+
496+
456497
#endregion
457498

458499
return result;

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 Model Orphans will be reported!")]
24+
public bool Orphans { get; set; }
2225
}
2326
}

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

+21-5
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private static int RunModelCheck(ModelCheckOptions opts)
7070
}
7171

7272

73-
// issues.WriteOutPut(Checks.Checks.CheckProjectStatitics(opts.Model));
73+
// issues.WriteOutPut(Checks.Checks.CheckProjectStatitics(opts.Model));
7474

7575

7676
Console.WriteLine(issues.ToString());
@@ -84,23 +84,39 @@ private static int RunModelCheck(ModelCheckOptions opts)
8484
{
8585
if (ModelAccess.IsSqlLite())
8686
{
87-
sb.AppendLine(Checks.Checks.CheckTableSize(opts.Model).Detail);
87+
var result = Checks.Checks.CheckTableSize(opts.Model);
88+
sb.AppendLine(result.Detail);
89+
issues.AddIfNotNull(result);
8890
}
8991
else
9092
{
9193
Console.WriteLine("Talbesize reporting only supported for SqlLite!");
9294
}
9395
}
9496

95-
97+
if (opts.Orphans == true)
98+
{
99+
if (ModelAccess.IsSqlLite())
100+
{
101+
var result = Checks.Checks.CheckModelOrphans(opts.Model);
102+
sb.AppendLine(result.Detail);
103+
issues.AddIfNotNull(result);
104+
}
105+
else
106+
{
107+
Console.WriteLine("Orphans reporting only supported for SqlLite!");
108+
}
109+
}
110+
111+
96112

97113

98114
if (opts.Out != null)
99115
{
100-
File.WriteAllText(opts.Out, sb.ToString());
116+
File.WriteAllText(opts.Out, sb.ToString());
101117
}
102118

103-
119+
104120

105121
if (opts.FailOnErrors == true)
106122
{

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)