diff --git a/citizen-intelligence-agency/src/main/java/com/hack23/cia/web/impl/ui/application/views/user/politician/pagemode/PoliticianOverviewPageModContentFactoryImpl.java b/citizen-intelligence-agency/src/main/java/com/hack23/cia/web/impl/ui/application/views/user/politician/pagemode/PoliticianOverviewPageModContentFactoryImpl.java index 062779e801..cf54c99a81 100644 --- a/citizen-intelligence-agency/src/main/java/com/hack23/cia/web/impl/ui/application/views/user/politician/pagemode/PoliticianOverviewPageModContentFactoryImpl.java +++ b/citizen-intelligence-agency/src/main/java/com/hack23/cia/web/impl/ui/application/views/user/politician/pagemode/PoliticianOverviewPageModContentFactoryImpl.java @@ -30,7 +30,6 @@ import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician; import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPoliticianBallotSummary; import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPoliticianExperienceSummary; -import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPoliticianExperienceSummary.PoliticalRole; import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup; import com.hack23.cia.web.impl.ui.application.action.ViewAction; import com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio; @@ -92,7 +91,7 @@ public Layout createContent(final String parameters, final MenuBar menuBar, fina final PersonData personData = getApplicationManager().getDataContainer(PersonData.class) .load(viewRiksdagenPolitician.getPersonId()); - createOverviewContent(panelContent, personData, viewRiksdagenPolitician, + createOverviewContent(panelContent, personData, viewRiksdagenPolitician, viewRiksdagenPoliticianBallotSummary, experienceSummary, pageId); getPageActionEventHelper().createPageEvent(ViewAction.VISIT_POLITICIAN_VIEW, ApplicationEventGroup.USER, UserViews.POLITICIAN_VIEW_NAME, parameters, pageId); @@ -116,7 +115,13 @@ protected ViewRiksdagenPoliticianBallotSummary getViewRiksdagenPoliticianBallotS return null; } } - + + /** + * Gets the view riksdagen politician experience summary. + * + * @param parameters the parameters + * @return the view riksdagen politician experience summary + */ protected ViewRiksdagenPoliticianExperienceSummary getViewRiksdagenPoliticianExperienceSummary(final String parameters) { final String pageId = getPageId(parameters); return getApplicationManager().getDataContainer(ViewRiksdagenPoliticianExperienceSummary.class).load(pageId); @@ -131,6 +136,7 @@ protected ViewRiksdagenPoliticianExperienceSummary getViewRiksdagenPoliticianExp * @param viewRiksdagenPolitician the view riksdagen politician * @param viewRiksdagenPoliticianBallotSummary the view riksdagen politician * ballot summary + * @param experienceSummary the experience summary * @param pageId the page id */ private void createOverviewContent(final VerticalLayout panelContent, final PersonData personData, @@ -138,7 +144,7 @@ private void createOverviewContent(final VerticalLayout panelContent, final Pers final ViewRiksdagenPoliticianBallotSummary viewRiksdagenPoliticianBallotSummary, final ViewRiksdagenPoliticianExperienceSummary experienceSummary, final String pageId) { - + // Link to politician detail page final Link createPoliticianPageLink = getPageLinkFactory().createPoliticianPageLink(personData); createPoliticianPageLink.addStyleName("card-subtitle"); @@ -200,7 +206,7 @@ private void createOverviewContent(final VerticalLayout panelContent, final Pers addPoliticalRoleMetrics(politicalRoleLayout, viewRiksdagenPolitician, viewRiksdagenPoliticianBallotSummary,experienceSummary); sectionsGrid.addComponent(politicalRoleLayout); sectionsGrid.setExpandRatio(politicalRoleLayout, 1.0f); - + final VerticalLayout experienceLayout = createSectionLayout("Experience & Expertise"); addExperienceMetrics(experienceLayout, experienceSummary); sectionsGrid.addComponent(experienceLayout); @@ -237,50 +243,51 @@ private void createOverviewContent(final VerticalLayout panelContent, final Pers getPoliticianMenuItemFactory().createOverviewPage(overviewLayout, pageId); } - + + /** + * Adds the experience metrics. + * + * @param layout the layout + * @param experienceSummary the experience summary + */ private void addExperienceMetrics(VerticalLayout layout, ViewRiksdagenPoliticianExperienceSummary experienceSummary) { if (experienceSummary != null) { // Career Overview - layout.addComponent(createInfoRow("Career Phase:", - experienceSummary.getCareerPhase().toString().replace("_", " "), - VaadinIcons.CALENDAR_CLOCK, + layout.addComponent(createInfoRow("Career Phase:", + experienceSummary.getCareerPhase().toString().replace("_", " "), + VaadinIcons.CALENDAR_CLOCK, "Current career stage")); // Experience Level - layout.addComponent(createInfoRow("Experience Level:", - experienceSummary.getExperienceLevel().toString().replace("_", " "), - VaadinIcons.CHART_TIMELINE, + layout.addComponent(createInfoRow("Experience Level:", + experienceSummary.getExperienceLevel().toString().replace("_", " "), + VaadinIcons.CHART_TIMELINE, "Overall political experience classification")); // Leadership Profile - layout.addComponent(createInfoRow("Leadership Role:", - experienceSummary.getLeadershipProfile().toString().replace("_", " "), - VaadinIcons.USER_STAR, + layout.addComponent(createInfoRow("Leadership Role:", + experienceSummary.getLeadershipProfile().toString().replace("_", " "), + VaadinIcons.USER_STAR, "Leadership experience level")); // Specialization - layout.addComponent(createInfoRow("Expertise:", - experienceSummary.getSpecializationLevel().toString().replace("_", " "), - VaadinIcons.SPECIALIST, + layout.addComponent(createInfoRow("Expertise:", + experienceSummary.getSpecializationLevel().toString().replace("_", " "), + VaadinIcons.SPECIALIST, "Area of specialization")); - - // Political Analysis Comment - if (StringUtils.isNotBlank(experienceSummary.getPoliticalAnalysisComment())) { - layout.addComponent(createInfoRow("Analysis:", - experienceSummary.getPoliticalAnalysisComment(), - VaadinIcons.COMMENT, - "Political career analysis")); - } - } + + + } } - - + + /** * Adds the political role metrics. * * @param layout the layout * @param politician the politician * @param ballotSummary the ballot summary + * @param experienceSummary the experience summary */ private void addPoliticalRoleMetrics(VerticalLayout layout, ViewRiksdagenPolitician politician, ViewRiksdagenPoliticianBallotSummary ballotSummary, ViewRiksdagenPoliticianExperienceSummary experienceSummary) { @@ -292,41 +299,59 @@ private void addPoliticalRoleMetrics(VerticalLayout layout, ViewRiksdagenPolitic layout.addComponent(createInfoRow("Career Length:", calculateServiceYears(politician.getFirstAssignmentDate(), politician.getLastAssignmentDate()), VaadinIcons.TIMER, "Years in parliament")); - + + // Top Roles + if (experienceSummary.getRoles() != null && !experienceSummary.getRoles().isEmpty()) { + final String topRoles = experienceSummary.getRoles().stream() + .filter(role -> role.getRole() != null && !role.getRole().equals("Other")) + .sorted((r1, r2) -> r2.getWeightedExp().compareTo(r1.getWeightedExp())) + .limit(3) + .map(role -> String.format(Locale.ENGLISH,"%s", + role.getRole())) + .collect(Collectors.joining(", ")); + + if (!topRoles.isEmpty()) { + layout.addComponent(createInfoRow("Key Political Roles:", + topRoles, + VaadinIcons.USERS, + "Most significant positions with weighted importance")); + } + } + // Top Knowledge Areas if (experienceSummary.getKnowledgeAreas() != null && !experienceSummary.getKnowledgeAreas().isEmpty()) { - String topAreas = experienceSummary.getKnowledgeAreas().stream() + final String topAreas = experienceSummary.getKnowledgeAreas().stream() .filter(ka -> ka.getArea() != null && !ka.getArea().equals("Other")) .sorted((ka1, ka2) -> ka2.getWeightedExp().compareTo(ka1.getWeightedExp())) .limit(3) - .map(ka -> String.format(Locale.ENGLISH,"%s ", + .map(ka -> String.format(Locale.ENGLISH,"%s ", ka.getArea())) .collect(Collectors.joining(", ")); if (!topAreas.isEmpty()) { - layout.addComponent(createInfoRow("Key Policy Areas:", - topAreas, - VaadinIcons.CLIPBOARD_TEXT, + layout.addComponent(createInfoRow("Key Policy Areas:", + topAreas, + VaadinIcons.CLIPBOARD_TEXT, "Main areas of expertise with weighted importance")); } } - // Top Roles - if (experienceSummary.getRoles() != null && !experienceSummary.getRoles().isEmpty()) { - String topRoles = experienceSummary.getRoles().stream() - .filter(role -> role.getRole() != null && !role.getRole().equals("Other")) - .sorted((r1, r2) -> r2.getWeightedExp().compareTo(r1.getWeightedExp())) - .limit(3) - .map(role -> String.format(Locale.ENGLISH,"%s", - role.getRole())) - .collect(Collectors.joining(", ")); - if (!topRoles.isEmpty()) { - layout.addComponent(createInfoRow("Key Political Roles:", - topRoles, - VaadinIcons.USERS, - "Most significant positions with weighted importance")); + // Split the analysis points and create a bullet list + final String[] analysisPoints = experienceSummary.getPoliticalAnalysisComment().split("\\s*\\|\\|\\s*"); + StringBuilder analys=new StringBuilder(); + for (final String point : analysisPoints) { + if (StringUtils.isNotBlank(point)) { + analys.append(" • ").append(point); } + } + + // Political Analysis Comment + if (StringUtils.isNotBlank(experienceSummary.getPoliticalAnalysisComment())) { + layout.addComponent(createInfoRow("Analysis:", + analys.toString(), + VaadinIcons.COMMENT, + "Political career analysis")); } } @@ -362,9 +387,9 @@ private void addLegislativeMetrics(VerticalLayout layout, ViewRiksdagenPoliticia VaadinIcons.FILE_TEXT, "Average documents per year")); layout.addComponent(createInfoRow("Individual Motions:", String.valueOf(politician.getIndividualMotions()), VaadinIcons.USER, "Personal motions submitted")); - + layout.addComponent(createInfoRow("Party Motions:", String.valueOf(politician.getPartyMotions()), - VaadinIcons.USER, "Party motions signed")); + VaadinIcons.USER, "Party motions signed")); layout.addComponent(createInfoRow("Committee Motions:", String.valueOf(politician.getCommitteeMotions()), VaadinIcons.GROUP, "Committee-based motions"));