use of com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary in project cia by Hack23.
the class PartyDataSeriesFactoryImpl method createChartTimeSeriesCurrentCommitteeByParty.
@Override
public DataSeries createChartTimeSeriesCurrentCommitteeByParty() {
DataSeries dataSeries = new DataSeries();
final DataContainer<ViewRiksdagenParty, String> dataContainer = applicationManager.getDataContainer(ViewRiksdagenParty.class);
final DataContainer<ViewRiksdagenPartySummary, String> partySummarydataContainer = applicationManager.getDataContainer(ViewRiksdagenPartySummary.class);
partySummarydataContainer.getAll();
for (final ViewRiksdagenParty data : dataContainer.getAll()) {
final ViewRiksdagenPartySummary summary = partySummarydataContainer.load(data.getPartyId());
if (summary != null && summary.isActive()) {
dataSeries = dataSeries.newSeries().add(data.getPartyName(), summary.getTotalActiveCommittee());
}
}
return dataSeries;
}
use of com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary 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.party.impl.ViewRiksdagenPartySummary in project cia by Hack23.
the class RulesEngineImpl method insertParties.
/**
* Insert parties.
*
* @param ksession
* the ksession
* @param list
* the list
*/
private void insertParties(final KieSession ksession, final List<ViewRiksdagenPartySummary> list) {
final Map<String, List<ViewRiksdagenVoteDataBallotPartySummaryDaily>> politicanBallotSummaryAnnualMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPartySummaryDaily.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getParty()));
final Map<String, List<ViewRiksdagenVoteDataBallotPartySummaryMonthly>> politicanBallotSummaryMontlyMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPartySummaryMonthly.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getParty()));
final Map<String, List<ViewRiksdagenVoteDataBallotPartySummaryAnnual>> politicanBallotSummaryDailyMap = dataViewer.getAll(ViewRiksdagenVoteDataBallotPartySummaryAnnual.class).stream().collect(Collectors.groupingBy(p -> p.getEmbeddedId().getParty()));
for (final ViewRiksdagenPartySummary partyData : list) {
if (partyData != null) {
final List<ViewRiksdagenVoteDataBallotPartySummaryAnnual> dailyList = politicanBallotSummaryDailyMap.get(partyData.getParty());
final List<ViewRiksdagenVoteDataBallotPartySummaryMonthly> monthlyList = politicanBallotSummaryMontlyMap.get(partyData.getParty());
final List<ViewRiksdagenVoteDataBallotPartySummaryDaily> annualList = politicanBallotSummaryAnnualMap.get(partyData.getParty());
if (partyData.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 PartyComplianceCheckImpl politicianComplianceCheckImpl = new PartyComplianceCheckImpl(partyData, Iterables.getFirst(dailyList, null), Iterables.getFirst(monthlyList, null), Iterables.getFirst(annualList, null));
ksession.insert(politicianComplianceCheckImpl);
} else {
final PartyComplianceCheckImpl politicianComplianceCheckImpl = new PartyComplianceCheckImpl(partyData, null, null, null);
ksession.insert(politicianComplianceCheckImpl);
}
}
}
}
use of com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartySummary in project cia by Hack23.
the class PartyRankingDataGridPageModContentFactoryImpl 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();
getPartyRankingMenuItemFactory().createPartyRankingMenuBar(menuBar);
final String pageId = getPageId(parameters);
final DataContainer<ViewRiksdagenPartySummary, String> dataContainer = getApplicationManager().getDataContainer(ViewRiksdagenPartySummary.class);
getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenPartySummary.class, dataContainer.getAllOrderBy(ViewRiksdagenPartySummary_.currentAssignments), PARTIES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
panel.setCaption(NAME + "::" + DATAGRID);
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARTY_RANKING_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
return panelContent;
}
Aggregations