add charts to dashboard
package com.hack23.cia.web.impl.ui.application.views.common.pagemode;
import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import com.hack23.cia.service.external.esv.api.EsvApi;
import com.hack23.cia.service.external.esv.api.GovernmentBodyAnnualSummary;
import com.hack23.cia.web.impl.ui.application.action.ViewAction;
+import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.GovernmentBodyChartDataManager;
import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
import com.hack23.cia.web.impl.ui.application.views.common.rows.RowUtil;
import com.hack23.cia.web.impl.ui.application.views.common.viewnames.CommonsViews;
@Autowired
private EsvApi esvApi;
+ /** The government body chart data manager. */
+ @Autowired
+ private GovernmentBodyChartDataManager governmentBodyChartDataManager;
+
+
/**
* Instantiates a new dashboard view overview page mod content factory impl.
*/
@@ -424,9 +432,13 @@ private void createDashboardParliament(final ResponsiveRow row) {
layout.addComponent(horizontalLayout);
-
addParliamentIncomeSpending(layout);
+ VerticalLayout layoutPanel = createPanelContent();
+
+ createHeadCountChart(layoutPanel,"202100-2627");
+ layout.addComponent(layoutPanel);
+
row.addColumn().withDisplayRules(DISPLAY_SIZE_XS_DEVICE, DISPLAYS_SIZE_XM_DEVICE, DISPLAY_SIZE_MD_DEVICE,
DISPLAY_SIZE_LG_DEVICE).withComponent(layout);
}
@@ -503,6 +515,22 @@ private void createDashboardPartRiskBySeverity(final ResponsiveRow row) {
DISPLAY_SIZE_LG_DEVICE).withComponent(layout);
}
+
+ private void createHeadCountChart(final VerticalLayout panelContent, final String orgId) {
+ final Map<String, List<GovernmentBodyAnnualSummary>> map = esvApi.getData().get(2022).stream().collect(Collectors.groupingBy(GovernmentBodyAnnualSummary::getOrgNumber));
+ final List<GovernmentBodyAnnualSummary> list = map.get(getPageId(orgId));
+
+ if (list != null && !list.isEmpty()) {
+ final Optional<GovernmentBodyAnnualSummary> governmentBodyAnnualSummary = list.stream().findFirst();
+
+ if (governmentBodyAnnualSummary.isPresent()) {
+ governmentBodyChartDataManager.createGovernmentBodyHeadcountSummaryChart(panelContent, governmentBodyAnnualSummary.get().getName());
+ }
+ }
+ }
+
+
+
@Override
public boolean matches(final String page, final String parameters) {
return NAME.equals(page)
