use of com.github.markash.ui.component.card.CounterStatisticModel in project cia by Hack23.
the class ParliamentRiskPageModContentFactoryImpl 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();
getParliamentMenuItemFactory().createParliamentTopicMenu(menuBar);
final String pageId = getPageId(parameters);
final ComplianceCheckRequest serviceRequest = new ComplianceCheckRequest();
serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
final ComplianceCheckResponse serviceResponse = (ComplianceCheckResponse) getApplicationManager().service(serviceRequest);
final HorizontalLayout horizontalLayout = new HorizontalLayout();
for (final Entry<Status, List<RuleViolation>> statusEntry : serviceResponse.getStatusMap().entrySet()) {
horizontalLayout.addComponent(new CounterStatisticsCard(VaadinIcons.WARNING, new CounterStatisticModel("ALL:" + statusEntry.getKey(), statusEntry.getValue().size()).withShow(StatisticShow.Sum).withIconHidden().withShowOnlyStatistic(true), "ALL:" + statusEntry.getKey()));
}
for (final Entry<ResourceType, List<RuleViolation>> statusEntry : serviceResponse.getResourceTypeMap().entrySet()) {
horizontalLayout.addComponent(new CounterStatisticsCard(VaadinIcons.WARNING, new CounterStatisticModel("ALL:" + statusEntry.getKey(), statusEntry.getValue().size()).withShow(StatisticShow.Sum).withIconHidden().withShowOnlyStatistic(true), "ALL:" + statusEntry.getKey()));
}
panelContent.addComponent(horizontalLayout);
getGridFactory().createBasicBeanItemGrid(panelContent, ComplianceCheck.class, serviceResponse.getList(), "Risk", new String[] { "name", "resourceType", "numberRuleViolations", "ruleSummary" }, new String[] { "id", "ruleViolations" }, CLICK_LISTENER, null, null);
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARLIAMENT_RANKING_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
panel.setCaption(new StringBuilder().append(NAME).append("::").append(PARLIAMENT_RISK_SUMMARY).toString());
return panelContent;
}
use of com.github.markash.ui.component.card.CounterStatisticModel in project cia by Hack23.
the class ParliamentRuleViolationsPageModContentFactoryImpl 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();
getParliamentMenuItemFactory().createParliamentTopicMenu(menuBar);
final ComplianceCheckRequest serviceRequest = new ComplianceCheckRequest();
serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
final ComplianceCheckResponse serviceResponse = (ComplianceCheckResponse) getApplicationManager().service(serviceRequest);
final HorizontalLayout horizontalLayout = new HorizontalLayout();
for (final Entry<Status, List<RuleViolation>> statusEntry : serviceResponse.getStatusMap().entrySet()) {
horizontalLayout.addComponent(new CounterStatisticsCard(VaadinIcons.WARNING, new CounterStatisticModel("ALL:" + statusEntry.getKey(), statusEntry.getValue().size()).withShow(StatisticShow.Sum).withIconHidden().withShowOnlyStatistic(true), "ALL:" + statusEntry.getKey()));
}
final List<RuleViolation> ruleViolations = new ArrayList<>();
for (final Entry<ResourceType, List<RuleViolation>> statusEntry : serviceResponse.getResourceTypeMap().entrySet()) {
horizontalLayout.addComponent(new CounterStatisticsCard(VaadinIcons.WARNING, new CounterStatisticModel("ALL:" + statusEntry.getKey(), statusEntry.getValue().size()).withShow(StatisticShow.Sum).withIconHidden().withShowOnlyStatistic(true), "ALL:" + statusEntry.getKey()));
ruleViolations.addAll(statusEntry.getValue());
}
panelContent.addComponent(horizontalLayout);
Collections.sort(ruleViolations, new Comparator<RuleViolation>() {
@Override
public int compare(final RuleViolation o1, final RuleViolation o2) {
return o2.getStatus().compareTo(o1.getStatus());
}
});
getGridFactory().createBasicBeanItemGrid(panelContent, RuleViolation.class, ruleViolations, "Risk", new String[] { "name", "status", "resourceType", "ruleName", "ruleGroup", "ruleDescription", "positive" }, new String[] { "id" }, CLICK_LISTENER, null, null);
final String pageId = getPageId(parameters);
getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARLIAMENT_RANKING_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
panel.setCaption(new StringBuilder().append(NAME).append("::").append(PARLIAMENT_RULE_VIOLATIONS).toString());
return panelContent;
}
Aggregations