@@ -162,8 +162,9 @@ public KpiMaturity calculateKpiMaturityForProject(ProjectInputDTO projectInput)
162162 return calculateKpiMaturity (projectInput , kpiElementList );
163163 }
164164
165- private List <KpiElement > processAllKpiRequests (List <KpiRequest > kpiRequests , ProjectDeliveryMethodology projectDeliveryMethodology ) {
166- if (projectDeliveryMethodology == ProjectDeliveryMethodology .KANBAN ) {
165+ private List <KpiElement > processAllKpiRequests (List <KpiRequest > kpiRequests ,
166+ ProjectDeliveryMethodology projectDeliveryMethodology ) {
167+ if (projectDeliveryMethodology == ProjectDeliveryMethodology .KANBAN ) {
167168 return this .knowHOWClient .getKpiIntegrationValuesKanban (kpiRequests );
168169 }
169170 return this .knowHOWClient .getKpiIntegrationValues (kpiRequests );
@@ -326,39 +327,45 @@ private List<KpiRequest> constructKpiRequests(ProjectInputDTO projectInput) {
326327 List <KpiRequest > kpiRequests = new ArrayList <>();
327328
328329 Map <String , List <KpiMaster >> kpisGroupedBySource = this .kpisEligibleForMaturityCalculation .stream ()
329- .filter (kpiMaster -> kpiMaster .getKanban () == (projectInput .deliveryMethodology () == ProjectDeliveryMethodology .KANBAN ))
330+ .filter (kpiMaster -> kpiMaster
331+ .getKanban () == (projectInput .deliveryMethodology () == ProjectDeliveryMethodology .KANBAN ))
330332 .collect (Collectors .groupingBy (KpiMaster ::getKpiSource ));
331333
332334 for (Map .Entry <String , List <KpiMaster >> entry : kpisGroupedBySource .entrySet ()) {
333335 KpiGranularity kpiGranularity = KpiGranularity .getByKpiXAxisLabel (entry .getValue ().get (0 ).getXAxisLabel ());
334336 switch (kpiGranularity ) {
335- case MONTH , WEEK , DAY -> kpiRequests .add (KpiRequest .builder ()
336- .kpiIdList (new ArrayList <>(entry .getValue ().stream ().map (KpiMaster ::getKpiId ).toList ()))
337- .selectedMap (Map .of (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , List .of (projectInput .nodeId ()),
338- CommonConstant .DATE , List .of (KPI_GRANULARITY_WEEKS )))
339- .ids (new String []{String .valueOf (
340- this .kpiMaturityCalculationConfig .getCalculationConfig ().getDataPoints ().getCount ())})
341- .level (projectInput .hierarchyLevel ())
342- .label (projectInput .hierarchyLevelId ()).build ());
343- case SPRINT , ITERATION , PI -> kpiRequests .add (KpiRequest .builder ()
344- .kpiIdList (new ArrayList <>(entry .getValue ().stream ().map (KpiMaster ::getKpiId ).toList ()))
345- .selectedMap (Map .of (CommonConstant .HIERARCHY_LEVEL_ID_SPRINT ,
346- projectInput .sprints ().stream ().map (SprintInputDTO ::nodeId ).toList (),
347- CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , List .of (projectInput .nodeId ())))
348- .ids (projectInput .sprints ().stream ().map (SprintInputDTO ::nodeId ).toList ()
349- .toArray (String []::new ))
350- .level (projectInput .sprints ().get (0 ).hierarchyLevel ())
351- .label (CommonConstant .HIERARCHY_LEVEL_ID_SPRINT ).build ());
352- case NONE -> {
353- if (projectInput .deliveryMethodology () == ProjectDeliveryMethodology .KANBAN ) {
354- kpiRequests .add (KpiRequest .builder ()
355- .kpiIdList (new ArrayList <>(entry .getValue ().stream ().map (KpiMaster ::getKpiId ).toList ()))
356- .selectedMap (Map .of (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , List .of (projectInput .nodeId ()),
357- CommonConstant .DATE , List .of (KPI_GRANULARITY_WEEKS )))
358- .ids (new String []{String .valueOf (
359- this .kpiMaturityCalculationConfig .getCalculationConfig ().getDataPoints ().getCount ())})
360- .level (projectInput .hierarchyLevel ()).label (projectInput .hierarchyLevelId ()).build ());
361- } else {
337+ case MONTH , WEEK , DAY -> kpiRequests .add (KpiRequest .builder ()
338+ .kpiIdList (new ArrayList <>(entry .getValue ().stream ().map (KpiMaster ::getKpiId ).toList ()))
339+ .selectedMap (Map .of (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , List .of (projectInput .nodeId ()),
340+ CommonConstant .DATE , List .of (KPI_GRANULARITY_WEEKS )))
341+ .ids (new String [] { String .valueOf (
342+ this .kpiMaturityCalculationConfig .getCalculationConfig ().getDataPoints ().getCount ()) })
343+ .level (projectInput .hierarchyLevel ()).label (projectInput .hierarchyLevelId ()).build ());
344+ case SPRINT , ITERATION , PI -> {
345+ if (CollectionUtils .isNotEmpty (projectInput .sprints ())) {
346+ kpiRequests .add (KpiRequest .builder ()
347+ .kpiIdList (new ArrayList <>(entry .getValue ().stream ().map (KpiMaster ::getKpiId ).toList ()))
348+ .selectedMap (Map .of (CommonConstant .HIERARCHY_LEVEL_ID_SPRINT ,
349+ projectInput .sprints ().stream ().map (SprintInputDTO ::nodeId ).toList (),
350+ CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , List .of (projectInput .nodeId ())))
351+ .ids (projectInput .sprints ().stream ().map (SprintInputDTO ::nodeId ).toList ()
352+ .toArray (String []::new ))
353+ .level (projectInput .sprints ().get (0 ).hierarchyLevel ())
354+ .label (CommonConstant .HIERARCHY_LEVEL_ID_SPRINT ).build ());
355+ }
356+ }
357+ case NONE -> {
358+ if (projectInput .deliveryMethodology () == ProjectDeliveryMethodology .KANBAN ) {
359+ kpiRequests .add (KpiRequest .builder ()
360+ .kpiIdList (new ArrayList <>(entry .getValue ().stream ().map (KpiMaster ::getKpiId ).toList ()))
361+ .selectedMap (
362+ Map .of (CommonConstant .HIERARCHY_LEVEL_ID_PROJECT , List .of (projectInput .nodeId ()),
363+ CommonConstant .DATE , List .of (KPI_GRANULARITY_WEEKS )))
364+ .ids (new String [] { String .valueOf (this .kpiMaturityCalculationConfig .getCalculationConfig ()
365+ .getDataPoints ().getCount ()) })
366+ .level (projectInput .hierarchyLevel ()).label (projectInput .hierarchyLevelId ()).build ());
367+ } else {
368+ if (CollectionUtils .isNotEmpty (projectInput .sprints ())) {
362369 kpiRequests .add (KpiRequest .builder ()
363370 .kpiIdList (new ArrayList <>(entry .getValue ().stream ().map (KpiMaster ::getKpiId ).toList ()))
364371 .selectedMap (Map .of (CommonConstant .HIERARCHY_LEVEL_ID_SPRINT ,
@@ -371,6 +378,7 @@ private List<KpiRequest> constructKpiRequests(ProjectInputDTO projectInput) {
371378 }
372379 }
373380 }
381+ }
374382 }
375383 return kpiRequests ;
376384 }
@@ -381,7 +389,8 @@ private List<KpiRequest> constructKpiRequests(ProjectInputDTO projectInput) {
381389 * <p>
382390 * This method performs a multi-step filtering process:
383391 * <ol>
384- * <li>Fetch KPIs supporting maturity calculation for SCRUM and KANBAN methodology</li>
392+ * <li>Fetch KPIs supporting maturity calculation for SCRUM and KANBAN
393+ * methodology</li>
385394 * <li>Map KPI categories from database configuration</li>
386395 * <li>Override categories with values from KpiCategoryMapping if available</li>
387396 * <li>Filter KPIs to include only those with configured category weights</li>
@@ -400,8 +409,7 @@ private List<KpiMaster> loadKpisEligibleForMaturityCalculation() {
400409 }
401410 return KpiMaster .builder ().kpiId (kpiMasterProjection .getKpiId ())
402411 .kpiName (kpiMasterProjection .getKpiName ()).kpiCategory (kpiCategory .toLowerCase ())
403- .kpiSource (kpiMasterProjection .getKpiSource ())
404- .kanban (kpiMasterProjection .isKanban ())
412+ .kpiSource (kpiMasterProjection .getKpiSource ()).kanban (kpiMasterProjection .isKanban ())
405413 .xAxisLabel (kpiMasterProjection .getxAxisLabel ()).build ();
406414 }).toList ();
407415
0 commit comments