@@ -32,6 +32,7 @@ const _graphlib = require("graphlib");
3232// local
3333const fileUtils = require ( "../common/file-utils.js" ) ;
3434const 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