public TechStatsMatrix getTechStatsMap(ProjectModel appBeingSummarized)
    {

        Map<String, Map<String, Map<Long, Map<String, TechUsageStatSum>>>> map = new HashMap<>();

        final Iterable<TechnologyUsageStatisticsModel> statModels = graphContext.service(TechnologyUsageStatisticsModel.class).findAll();
        for (TechnologyUsageStatisticsModel stat : statModels)
        {
            //If a stat doesn't apply to this project we move on to the next stat without further processing
            if (appBeingSummarized != null)
            {
                boolean appIsContainedInStatProject = stat.getProjectModel().getApplications().contains(appBeingSummarized);
                boolean appIsASharedLibrary = appBeingSummarized.getName().toLowerCase().contains("shared");
                boolean statAppliesToSeveralApps = stat.getProjectModel().getApplications().size() > 1;
                if(!appIsContainedInStatProject || (statAppliesToSeveralApps && !appIsASharedLibrary))
                {
                    LOG.fine("\t\tThis stat is not for this project, skipping.");
                    continue;
                }
            }

            final Set<String> placementTags = TechReportService.getPlacementTags(graphContext, stat.getTags());
            TechReportService.TechReportPlacement placement = TechReportService.processPlaceLabels(graphContext, placementTags);
            if (placement.box == null || placement.row == null)
            {
                LOG.severe(String.format("\tPlacement labels not recognized, placement incomplete: %s; stat: %s", placement, stat));
                continue;
            }

            placement = TechReportService.normalizePlacement(graphContext, placement);

            if (placement.box == null || placement.row == null)
            {
                LOG.severe(String.format("\tPlacement labels not recognized, placement incomplete: %s; stat: %s", placement, stat));
                continue;
            }

            // For boxes report - show each tech in sector, row, box. A sum for all projects.
            mergeToTheRightCell(map, placement.row.getName(), placement.box.getName(), 0L, stat.getName(), stat, false);
            // For the punch card report - maximum count for each box.
            mergeToTheRightCell(map, "", placement.box.getName(), 0L, "", stat, true);

            List<Long> appsToCountTowards;
            if (appBeingSummarized == null)
            {
                appsToCountTowards = StreamSupport.stream(stat.getProjectModel().getApplications().spliterator(), false)
                            .map(ProjectModel::getElement)
                            .map(Vertex::id)
                            .map(Long.class::cast)
                            .collect(toList());
            }
            else
            {
                appsToCountTowards = Collections.singletonList(appBeingSummarized.getId());
            }

            boolean isSharedApp = appsToCountTowards.size() > 1;
            List<ProjectModel> apps = stat.getProjectModel().getApplications();
            List<ProjectModel>sharedApps = apps.stream().filter(app -> app.getName().toLowerCase().contains("shared")).collect(toList());


            for (Long appToCountTowards : appsToCountTowards)
            {
                if(isSharedApp)
                {
                    if(!sharedApps.stream().anyMatch(app -> app.getElement().id().equals(appToCountTowards)))
                    {
                        continue;
                    }
                }

                // For boxes report - show each tech in sector, row, box. For individual projects.
                mergeToTheRightCell(map, placement.row.getName(), placement.box.getName(), appToCountTowards, stat.getName(), stat, false);

                // For the punch card report - roll up rows and individual techs.
                mergeToTheRightCell(map, "", placement.box.getName(), appToCountTowards, "", stat, false);
            }
        }

        return new TechStatsMatrix(map);
    }
public TechStatsMatrix getTechStatsMap ( ProjectModel appBeingSummarized ) { Map < String , Map < String , Map < Long , Map < String , TechUsageStatSum > > > > map = new HashMap < > ( ) ; final Iterable < TechnologyUsageStatisticsModel > statModels = graphContext . service ( TechnologyUsageStatisticsModel . class ) . findAll ( ) ; for ( TechnologyUsageStatisticsModel stat : statModels ) { if ( appBeingSummarized != null ) { boolean appIsContainedInStatProject = stat . getProjectModel ( ) . getApplications ( ) . contains ( appBeingSummarized ) ; boolean appIsASharedLibrary = appBeingSummarized . getName ( ) . toLowerCase ( ) . contains ( "shared" ) ; boolean statAppliesToSeveralApps = stat . getProjectModel ( ) . getApplications ( ) . size ( ) > 1 ; if ( ! appIsContainedInStatProject || ( statAppliesToSeveralApps && ! appIsASharedLibrary ) ) { LOG . fine ( "\t\tThis stat is not for this project, skipping." ) ; continue ; } } final Set < String > placementTags = TechReportService . getPlacementTags ( graphContext , stat . getTags ( ) ) ; TechReportService . TechReportPlacement placement = TechReportService . processPlaceLabels ( graphContext , placementTags ) ; if ( placement . box == null || placement . row == null ) { LOG . severe ( String . format ( "\tPlacement labels not recognized, placement incomplete: %s; stat: %s" , placement , stat ) ) ; continue ; } placement = TechReportService . normalizePlacement ( graphContext , placement ) ; if ( placement . box == null || placement . row == null ) { LOG . severe ( String . format ( "\tPlacement labels not recognized, placement incomplete: %s; stat: %s" , placement , stat ) ) ; continue ; } mergeToTheRightCell ( map , placement . row . getName ( ) , placement . box . getName ( ) , 0L , stat . getName ( ) , stat , false ) ; mergeToTheRightCell ( map , "" , placement . box . getName ( ) , 0L , "" , stat , true ) ; List < Long > appsToCountTowards ; if ( appBeingSummarized == null ) { appsToCountTowards = StreamSupport . stream ( stat . getProjectModel ( ) . getApplications ( ) . spliterator ( ) , false ) . map ( ProjectModel :: getElement ) . map ( Vertex :: id ) . map ( Long . class :: cast ) . collect ( toList ( ) ) ; } else { appsToCountTowards = Collections . singletonList ( appBeingSummarized . getId ( ) ) ; } boolean isSharedApp = appsToCountTowards . size ( ) > 1 ; List < ProjectModel > apps = stat . getProjectModel ( ) . getApplications ( ) ; List < ProjectModel > sharedApps = apps . stream ( ) . filter ( app -> app . getName ( ) . toLowerCase ( ) . contains ( "shared" ) ) . collect ( toList ( ) ) ; for ( Long appToCountTowards : appsToCountTowards ) { if ( isSharedApp ) { if ( ! sharedApps . stream ( ) . anyMatch ( app -> app . getElement ( ) . id ( ) . equals ( appToCountTowards ) ) ) { continue ; } } mergeToTheRightCell ( map , placement . row . getName ( ) , placement . box . getName ( ) , appToCountTowards , stat . getName ( ) , stat , false ) ; mergeToTheRightCell ( map , "" , placement . box . getName ( ) , appToCountTowards , "" , stat , false ) ; } } return new TechStatsMatrix ( map ) ; }
Prepares a precomputed matrix - map of maps of maps: rowTag -> boxTag -> project -> placement label -> TechUsageStatSum.

@param appBeingSummarized Sum the statistics only for this project.