Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup #6937

Merged
merged 1 commit into from
Jan 5, 2025
Merged

cleanup #6937

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -131,14 +136,15 @@ 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,
final ViewRiksdagenPolitician viewRiksdagenPolitician,
final ViewRiksdagenPoliticianBallotSummary viewRiksdagenPoliticianBallotSummary,
final ViewRiksdagenPoliticianExperienceSummary experienceSummary,
final String pageId) {

// Link to politician detail page
final Link createPoliticianPageLink = getPageLinkFactory().createPoliticianPageLink(personData);
createPoliticianPageLink.addStyleName("card-subtitle");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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"));
}

}
Expand Down Expand Up @@ -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"));
Expand Down
Loading