Skip to content

Commit dbfaebc

Browse files
Zachary_KniebelZachary_Kniebel
authored andcommitted
Merge branch 'version/1.1' into release
2 parents cdcb581 + 9469f3f commit dbfaebc

File tree

2 files changed

+263
-2
lines changed

2 files changed

+263
-2
lines changed

app/generator/generation-metadata.js

Lines changed: 172 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,169 @@
2222
* TYPES
2323
*/
2424

25+
/**
26+
* @summary Holds statistics for a helix module of the solution
27+
* @param {string} moduleID ID of the module
28+
* @param {number} totalTemplates the total number of templates in the module
29+
* @param {number} totalDependencies the total number of dependencies on other modules
30+
* @param {number} totalDependents the total number of dependents from other modules
31+
*/
32+
function HelixModuleStatistics(moduleID, totalTemplates, totalDependencies, totalDependents) {
33+
/**
34+
* @property the ID of the module
35+
*/
36+
this.ModuleID = moduleID;
37+
/**
38+
* @property the total number of templates in the layer
39+
*/
40+
this.TotalTemplates = totalTemplates;
41+
/**
42+
* @property the total number of dependencies in the layer
43+
*/
44+
this.TotalDependencies = totalDependencies;
45+
/**
46+
* @property the total number of dependents in the layer
47+
*/
48+
this.TotalDependents = totalDependents;
49+
};
50+
51+
/**
52+
* @summary Holds statistics for a helix layer of the solution
53+
* @param {string} layerID the ID of the layer
54+
* @param {Array<HelixModuleStatistics>} helixModuleStatistics array of HelixModuleStatistics objects representing the modules that belong to the layer
55+
*/
56+
function HelixLayerStatistics(layerID, helixModuleStatistics) {
57+
/**
58+
* @property the reference ID of the layer root
59+
*/
60+
this.LayerID = layerID;
61+
/**
62+
* @property array of HelixModuleStatistics objects representing the modules that belong to the layer
63+
*/
64+
this.HelixModuleStatistics = helixModuleStatistics;
65+
};
66+
/**
67+
* @summary gets the total number of templates in the layer
68+
*/
69+
HelixLayerStatistics.prototype.getTotalTemplates = function() {
70+
return this.HelixModuleStatistics.reduce(function(accumulator, moduleStatistics) {
71+
return accumulator + moduleStatistics.TotalTemplates;
72+
}, 0);
73+
};
74+
/**
75+
* @summary gets the total number of modules in the layer
76+
*/
77+
HelixLayerStatistics.prototype.getTotalModules = function() {
78+
return this.HelixModuleStatistics.length;
79+
};
80+
/**
81+
* @summary gets the total number of dependencies in the layer
82+
*/
83+
HelixLayerStatistics.prototype.getTotalModuleDependencies = function() {
84+
return this.HelixModuleStatistics.reduce(function(accumulator, moduleStatistics) {
85+
return accumulator + moduleStatistics.TotalDependencies;
86+
}, 0);
87+
};
88+
/**
89+
* @summary gets the total number of dependents in the layer
90+
*/
91+
HelixLayerStatistics.prototype.getTotalModuleDependents = function() {
92+
return this.HelixModuleStatistics.reduce(function(accumulator, moduleStatistics) {
93+
return accumulator + moduleStatistics.TotalDependents;
94+
}, 0);
95+
};
96+
97+
/**
98+
* @summary Holds statistics about the helix elements of the solution
99+
* @param {HelixLayerStatistics} foundationLayerStatistics the statistics object for the foundation layer
100+
* @param {HelixLayerStatistics} featureLayerStatistics the statistics object for the feature layer
101+
* @param {HelixLayerStatistics} projectLayerStatistics the statistics object for the project layer
102+
*/
103+
function HelixStatistics(foundationLayerStatistics, featureLayerStatistics, projectLayerStatistics) {
104+
/**
105+
* @property foundation-layer statistics
106+
*/
107+
this.FoundationLayer = foundationLayerStatistics;
108+
/**
109+
* @property feature-layer statistics
110+
*/
111+
this.FeatureLayer = featureLayerStatistics;
112+
/**
113+
* @property project-layer statistics
114+
*/
115+
this.ProjectLayer = projectLayerStatistics;
116+
117+
var layersArray = [ foundationLayerStatistics, featureLayerStatistics, projectLayerStatistics ];
118+
119+
/**
120+
* @property hashmap of IDs to layer statistics
121+
*/
122+
this.IDsToLayersMap = layersArray.reduce(function(map, layerStats) {
123+
map[layerStats.LayerID] = layerStats;
124+
return map;
125+
}, {});
126+
/**
127+
* @property hashmap of IDs to module statistics
128+
*/
129+
this.IDsToModulesMap = layersArray
130+
.reduce(function(arr, layerStats) { return arr.concat(layerStats.HelixModuleStatistics); }, [])
131+
.reduce(function(map, moduleStats) {
132+
map[moduleStats.ModuleID] = moduleStats;
133+
return map;
134+
}, {});
135+
};
136+
/**
137+
* @summary gets the total number of modules in the solution
138+
*/
139+
HelixStatistics.prototype.getTotalModules = function() {
140+
return this.FoundationLayer.getTotalModules() + this.FeatureLayer.getTotalModules() + this.ProjectLayer.getTotalModules();
141+
};
142+
/**
143+
* @summary gets the total number of helix templates in the solution
144+
*/
145+
HelixStatistics.prototype.getTotalTemplates = function() {
146+
return this.FoundationLayer.getTotalTemplates() + this.FeatureLayer.getTotalTemplates() + this.ProjectLayer.getTotalTemplates();
147+
};
148+
/**
149+
* @summary gets the total number of module dependencies in the solution
150+
*/
151+
HelixStatistics.prototype.getTotalModuleDependencies = function() {
152+
return this.FoundationLayer.getTotalModuleDependencies() + this.FeatureLayer.getTotalModuleDependencies() + this.ProjectLayer.getTotalModuleDependencies();
153+
};
154+
/**
155+
* @summary gets the total number of module dependents in the solution
156+
*/
157+
HelixStatistics.prototype.getTotalModuleDependents = function() {
158+
return this.FoundationLayer.getTotalModuleDependents() + this.FeatureLayer.getTotalModuleDependents() + this.ProjectLayer.getTotalModuleDependents();
159+
};
160+
161+
/**
162+
* @summary Holds statistics about the solution
163+
* @param {HelixStatistics} helixStatistics the optional HelixStatistics object representing the helix statistics of the solution
164+
*/
165+
function SolutionStatistics(helixStatistics = undefined) {
166+
/**
167+
* @property total number of templates in the solution
168+
*/
169+
this.TotalTemplates = 0;
170+
/**
171+
* @property total number of template folders in the solution
172+
*/
173+
this.TotalTemplateFolders = 0;
174+
/**
175+
* @property total number of template fields in the solution
176+
*/
177+
this.TotalTemplateFields = 0;
178+
/**
179+
* @property total number of template inheritance relationships in the solution
180+
*/
181+
this.TotalTemplateInheritance = 0;
182+
/**
183+
* @property Helix statistics for the solution
184+
*/
185+
this.HelixStatistics = helixStatistics;
186+
};
187+
25188
/**
26189
* @summary Holds the metadata for the generation
27190
*/
@@ -70,7 +233,15 @@ function Metaball() {
70233
* @property generation end time
71234
*/
72235
this.EndTime = -1;
236+
/**
237+
* @property Solution Statistics
238+
*/
239+
this.SolutionStatistics = undefined;
73240
};
74241

75242

76-
exports.Metaball = Metaball;
243+
exports.Metaball = Metaball;
244+
exports.SolutionStatistics = SolutionStatistics;
245+
exports.HelixStatistics = HelixStatistics;
246+
exports.HelixLayerStatistics = HelixLayerStatistics;
247+
exports.HelixModuleStatistics = HelixModuleStatistics;

app/generator/mdj-reverseengineer.js

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const _graphlib = require("graphlib");
3232
// local
3333
const fileUtils = require("../common/file-utils.js");
3434
const logger = require("../common/logging.js").logger;
35+
const { SolutionStatistics, HelixStatistics, HelixLayerStatistics, HelixModuleStatistics } = require("./generation-metadata.js");
3536

3637
/*
3738
* GLOBALS
@@ -1338,6 +1339,63 @@ function _generateHelixDiagrams(documentationConfiguration, metaball, canvas, cr
13381339
__createDiagramsForLayer(helixArchitecture.FoundationLayer);
13391340
__createDiagramsForLayer(helixArchitecture.FeatureLayer);
13401341
__createDiagramsForLayer(helixArchitecture.ProjectLayer);
1342+
1343+
// create solution statistics
1344+
var __createLayerStatistics = function(layer) {
1345+
return new HelixLayerStatistics(
1346+
layer.ReferenceID,
1347+
layer.Modules.map(function(helixModule) {
1348+
return new HelixModuleStatistics(
1349+
helixModule.RootJsonItem.ReferenceID,
1350+
helixModule.JsonTemplates.length,
1351+
helixModule.JsonTemplates.reduce(function(accumulator, jsonTemplate) {
1352+
// get dependencies excluding those within the same module
1353+
var dependencies = templateDependenciesCache[jsonTemplate.ReferenceID]
1354+
.filter(function(dependency) { return dependency.SourceHierarchyModel.ModuleID != dependency.TargetHierarchyModel.ModuleID });
1355+
return accumulator + dependencies.length;
1356+
}, 0),
1357+
helixModule.JsonTemplates.reduce(function(accumulator, jsonTemplate) {
1358+
// get dependents excluding those within the same module
1359+
var dependents = templateDependentsCache[jsonTemplate.ReferenceID]
1360+
.filter(function(dependent) { return dependent.SourceHierarchyModel.ModuleID != dependent.TargetHierarchyModel.ModuleID });
1361+
return accumulator + dependents.length;
1362+
}, 0)
1363+
);
1364+
})
1365+
);
1366+
};
1367+
1368+
metaball.SolutionStatistics = new SolutionStatistics(new HelixStatistics(
1369+
__createLayerStatistics(helixArchitecture.FoundationLayer),
1370+
__createLayerStatistics(helixArchitecture.FeatureLayer),
1371+
__createLayerStatistics(helixArchitecture.ProjectLayer)
1372+
));
1373+
1374+
1375+
// update the documentation for the layer and module models to include the layer and module statistics
1376+
var __updateStatisticsDocumentationForLayer = function(layer) {
1377+
var layerModelDocumentation = layer.RootModel.documentation;
1378+
if (layerModelDocumentation) {
1379+
layerModelDocumentation += " \n \n";
1380+
}
1381+
var layerStats = metaball.SolutionStatistics.HelixStatistics.IDsToLayersMap[layer.ReferenceID];
1382+
layerModelDocumentation += `**Total Templates:** ${layerStats.getTotalTemplates()} \n**Total Modules:** ${layerStats.getTotalModules()} \n**Total Module Dependencies:** ${layerStats.getTotalModuleDependencies()} \n**Total Module Dependents:** ${layerStats.getTotalModuleDependents()}`;
1383+
layer.RootModel.documentation = layerModelDocumentation;
1384+
1385+
layer.Modules.forEach(function(helixModule) {
1386+
var moduleModelDocumentation = helixModule.RootModel.documentation;
1387+
if (moduleModelDocumentation) {
1388+
moduleModelDocumentation += " \n \n";
1389+
}
1390+
var moduleStats = metaball.SolutionStatistics.HelixStatistics.IDsToModulesMap[helixModule.RootJsonItem.ReferenceID];
1391+
moduleModelDocumentation += `**Total Templates:** ${moduleStats.TotalTemplates} \n**Total Dependencies:** ${moduleStats.TotalDependencies} \n**Total Dependents:** ${moduleStats.TotalDependents}`;
1392+
helixModule.RootModel.documentation = moduleModelDocumentation;
1393+
});
1394+
};
1395+
1396+
__updateStatisticsDocumentationForLayer(helixArchitecture.FoundationLayer);
1397+
__updateStatisticsDocumentationForLayer(helixArchitecture.FeatureLayer);
1398+
__updateStatisticsDocumentationForLayer(helixArchitecture.ProjectLayer);
13411399
};
13421400

13431401
/*
@@ -1454,6 +1512,11 @@ var reverseEngineerMetaDataJsonFile = (architecture, outputFilePath, metaball, l
14541512

14551513
/* 3) CREATE ALL OF THE ITEM RELATIONSHIP MODELS AND VIEWS */
14561514

1515+
var totalTemplates = 0;
1516+
var totalTemplateFolders = 0;
1517+
var totalTemplateFields = 0;
1518+
var totalTemplateInheritance = 0;
1519+
14571520
// get all the json items in a flat array and then create the relationships for the items
14581521
// *** this needs to run in a separate loop to ensure all items have already been created
14591522
architecture.Items
@@ -1466,6 +1529,10 @@ var reverseEngineerMetaDataJsonFile = (architecture, outputFilePath, metaball, l
14661529

14671530
// create the base template relationship models and views
14681531
if (jsonItem.IsTemplate) {
1532+
totalTemplates++;
1533+
totalTemplateFields += jsonItem.Fields.length;
1534+
totalTemplateInheritance += jsonItem.BaseTemplates.length;
1535+
14691536
jsonItem.BaseTemplates.forEach(function (jsonBaseTemplateId) {
14701537
var baseTemplateView = createdItemViewsCache[jsonBaseTemplateId];
14711538

@@ -1478,6 +1545,8 @@ var reverseEngineerMetaDataJsonFile = (architecture, outputFilePath, metaball, l
14781545
});
14791546
// create the parent-child relationship views
14801547
} else {
1548+
totalTemplateFolders++;
1549+
14811550
var parentModel = view.model._parent;
14821551
var parentView = createdItemViewsCache[parentModel._id];
14831552

@@ -1504,7 +1573,28 @@ var reverseEngineerMetaDataJsonFile = (architecture, outputFilePath, metaball, l
15041573
jsonItemIDsCache,
15051574
createdInheritanceModelsCache,
15061575
layoutOptions);
1507-
1576+
1577+
// update the solution statistics
1578+
if (!metaball.SolutionStatistics) {
1579+
metaball.SolutionStatistics = new SolutionStatistics();
1580+
}
1581+
1582+
metaball.SolutionStatistics.TotalTemplates = totalTemplates;
1583+
metaball.SolutionStatistics.TotalTemplateFields = totalTemplateFields;
1584+
metaball.SolutionStatistics.TotalTemplateInheritance = totalTemplateInheritance;
1585+
metaball.SolutionStatistics.TotalTemplateFolders = totalTemplateFolders;
1586+
1587+
// add the solution statistics to the project model
1588+
var documentation = project.documentation;
1589+
if (documentation) {
1590+
documentation += " \n \n";
1591+
}
1592+
documentation += `**Total Templates:** ${totalTemplates} \n**Total Template Fields:** ${totalTemplateFields} \n**Total Template Inheritance Relationships:** ${totalTemplateInheritance} \n**Total Template Folders:** ${totalTemplateFolders}`;
1593+
var helixStats = metaball.SolutionStatistics.HelixStatistics;
1594+
documentation = helixStats
1595+
? documentation + ` \n \n**Total Helix Templates:** ${helixStats.getTotalTemplates()} \n**Total Helix Modules:** ${helixStats.getTotalModules()} \n**Total Helix Module Dependencies:** ${helixStats.getTotalModuleDependencies()} \n \n**Foundation Layer Templates:** ${helixStats.FoundationLayer.getTotalTemplates()} \n**Foundation Layer Modules:** ${helixStats.FoundationLayer.getTotalModules()} \n**Foundation Layer Module Dependencies:** ${helixStats.FoundationLayer.getTotalModuleDependencies()} \n**Foundation Layer Module Dependents:** ${helixStats.FoundationLayer.getTotalModuleDependents()} \n \n**Feature Layer Templates:** ${helixStats.FeatureLayer.getTotalTemplates()} \n**Feature Layer Modules:** ${helixStats.FeatureLayer.getTotalModules()} \n**Feature Layer Module Dependencies:** ${helixStats.FeatureLayer.getTotalModuleDependencies()} \n**Feature Layer Module Dependents:** ${helixStats.FeatureLayer.getTotalModuleDependents()} \n \n**Project Layer Templates:** ${helixStats.ProjectLayer.getTotalTemplates()} \n**Project Layer Modules:** ${helixStats.ProjectLayer.getTotalModules()} \n**Project Layer Module Dependencies:** ${helixStats.ProjectLayer.getTotalModuleDependencies()} \n**Project Layer Module Dependents:** ${helixStats.ProjectLayer.getTotalModuleDependents()}`
1596+
: documentation;
1597+
project.documentation = documentation;
15081598

15091599
// serialize the project to JSON
15101600
var mdjcontent = mdjson.Repository.writeObject(project);

0 commit comments

Comments
 (0)