use of com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician in project cia by Hack23.
the class DataViewerITest method viewRiksdagenPartySummary.
/**
* View riksdagen party summary.
*
* @throws Exception
* the exception
*/
@Test
public void viewRiksdagenPartySummary() throws Exception {
final List<ViewRiksdagenPartySummary> committees = dataViewer.getAll(ViewRiksdagenPartySummary.class);
assertNotNull(EXPECT_VALUE_IN_DATABASE, committees);
if (committees.size() > 0) {
final ViewRiksdagenPartySummary viewRiksdagenPartySummary = committees.get(4);
final ViewRiksdagenPartySummary viewRiksdagenPartySummaryLoaded = dataViewer.load(ViewRiksdagenPartySummary.class, viewRiksdagenPartySummary.getParty());
assertNotNull(EXPECT_VALUE_IN_DATABASE, viewRiksdagenPartySummaryLoaded);
final ViewRiksdagenPartySummary viewRiksdagenPartySummaryFound = dataViewer.findFirstByProperty(ViewRiksdagenPartySummary.class, ViewRiksdagenPartySummary_.party, viewRiksdagenPartySummaryLoaded.getParty());
assertEquals(EXPECT_SAME_OBJECT_LOADED, viewRiksdagenPartySummaryLoaded, viewRiksdagenPartySummaryFound);
}
long parliamentSum = 0;
long euSum = 0;
long governmentSum = 0;
for (final ViewRiksdagenPartySummary viewRiksdagenPartySummary : committees) {
if (viewRiksdagenPartySummary != null) {
parliamentSum = parliamentSum + viewRiksdagenPartySummary.getTotalActiveParliament();
euSum = euSum + viewRiksdagenPartySummary.getTotalActiveEu();
governmentSum = governmentSum + viewRiksdagenPartySummary.getTotalActiveGovernment();
}
}
final List<ViewRiksdagenPolitician> activeWithNoParty = dataViewer.findListByProperty(ViewRiksdagenPolitician.class, new Object[] { true, null }, ViewRiksdagenPolitician_.activeParliament, ViewRiksdagenPolitician_.party);
assertEquals(SHOULD_ALWAYS_BE_349_IN_PARLIAMENT, 349, parliamentSum + activeWithNoParty.size());
assertEquals("Should always be 20 in eu, but riksdagen data contains only 15", 15, euSum);
assertEquals("Should always be 23 in current government", 23, governmentSum);
}
use of com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician in project cia by Hack23.
the class RulesEngineImpl method insertPoliticians.
/**
* Insert politicians.
*
* @param ksession
* the ksession
* @param list
* the list
*/
private void insertPoliticians(final KieSession ksession, final List<ViewRiksdagenPolitician> list) {
final Map<String, List<ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual>> politicanBallotSummaryAnnualMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getIntressentId()));
final Map<String, List<ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly>> politicanBallotSummaryMontlyMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getIntressentId()));
final Map<String, List<ViewRiksdagenVoteDataBallotPoliticianSummaryDaily>> politicanBallotSummaryDailyMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPoliticianSummaryDaily.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getIntressentId()));
for (final ViewRiksdagenPolitician politicianData : list) {
if (politicianData != null) {
final List<ViewRiksdagenVoteDataBallotPoliticianSummaryDaily> dailyList = politicanBallotSummaryDailyMap.get(politicianData.getPersonId());
final List<ViewRiksdagenVoteDataBallotPoliticianSummaryMonthly> monthlyList = politicanBallotSummaryMontlyMap.get(politicianData.getPersonId());
final List<ViewRiksdagenVoteDataBallotPoliticianSummaryAnnual> annualList = politicanBallotSummaryAnnualMap.get(politicianData.getPersonId());
if (politicianData.isActiveParliament() && dailyList != null && monthlyList != null && annualList != null) {
Collections.sort(dailyList, (e1, e2) -> e1.getEmbeddedId().getVoteDate().compareTo(e2.getEmbeddedId().getVoteDate()));
Collections.sort(monthlyList, (e1, e2) -> e1.getEmbeddedId().getVoteDate().compareTo(e2.getEmbeddedId().getVoteDate()));
Collections.sort(annualList, (e1, e2) -> e1.getEmbeddedId().getVoteDate().compareTo(e2.getEmbeddedId().getVoteDate()));
final PoliticianComplianceCheckImpl politicianComplianceCheckImpl = new PoliticianComplianceCheckImpl(politicianData, Iterables.getFirst(dailyList, null), Iterables.getFirst(monthlyList, null), Iterables.getFirst(annualList, null));
ksession.insert(politicianComplianceCheckImpl);
} else {
final PoliticianComplianceCheckImpl politicianComplianceCheckImpl = new PoliticianComplianceCheckImpl(politicianData, null, null, null);
ksession.insert(politicianComplianceCheckImpl);
}
}
}
}
use of com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician in project cia by Hack23.
the class PartyMemberHistoryPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
final DataContainer<ViewRiksdagenParty, String> dataContainer = getApplicationManager().getDataContainer(ViewRiksdagenParty.class);
final ViewRiksdagenParty viewRiksdagenParty = dataContainer.load(pageId);
if (viewRiksdagenParty != null) {
getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, MEMBER_HISTORY);
final DataContainer<ViewRiksdagenPolitician, String> politicianDataContainer = getApplicationManager().getDataContainer(ViewRiksdagenPolitician.class);
getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenPolitician.class, politicianDataContainer.getAllBy(ViewRiksdagenPolitician_.party, viewRiksdagenParty.getPartyId()), POLITICIANS, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
pageCompleted(parameters, panel, pageId, viewRiksdagenParty);
}
return panelContent;
}
use of com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician in project cia by Hack23.
the class PoliticianRoleListPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
final DataContainer<PersonData, String> dataContainer = getApplicationManager().getDataContainer(PersonData.class);
final PersonData personData = dataContainer.load(pageId);
if (personData != null) {
final DataContainer<ViewRiksdagenPolitician, String> politicianDataContainer = getApplicationManager().getDataContainer(ViewRiksdagenPolitician.class);
final ViewRiksdagenPolitician viewRiksdagenPolitician = politicianDataContainer.load(personData.getId());
getPoliticianMenuItemFactory().createPoliticianMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, PoliticianPageMode.ROLELIST.toString());
final List<AssignmentData> assignmentList = personData.getPersonAssignmentData().getAssignmentList();
createRoleList(panelContent, assignmentList);
pageCompleted(parameters, panel, pageId, viewRiksdagenPolitician);
}
return panelContent;
}
use of com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician in project cia by Hack23.
the class PoliticianRoleSummaryPageModContentFactoryImpl method createContent.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
final VerticalLayout panelContent = createPanelContent();
final String pageId = getPageId(parameters);
final DataContainer<PersonData, String> dataContainer = getApplicationManager().getDataContainer(PersonData.class);
final PersonData personData = dataContainer.load(pageId);
if (personData != null) {
final DataContainer<ViewRiksdagenPolitician, String> politicianDataContainer = getApplicationManager().getDataContainer(ViewRiksdagenPolitician.class);
final ViewRiksdagenPolitician viewRiksdagenPolitician = politicianDataContainer.load(personData.getId());
getPoliticianMenuItemFactory().createPoliticianMenuBar(menuBar, pageId);
LabelFactory.createHeader2Label(panelContent, PoliticianPageMode.ROLESUMMARY.toString());
final List<AssignmentData> assignmentList = personData.getPersonAssignmentData().getAssignmentList();
createRoleSummary(panelContent, assignmentList, viewRiksdagenPolitician);
pageCompleted(parameters, panel, pageId, viewRiksdagenPolitician);
}
return panelContent;
}
Aggregations