CommitteeCurrentMembersHistoryPageModContentFactoryImpl.java

  1. /*
  2.  * Copyright 2010-2025 James Pether Sörling
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  *  $Id$
  17.  *  $HeadURL$
  18. */
  19. package com.hack23.cia.web.impl.ui.application.views.user.committee.pagemode;

  20. import org.springframework.security.access.annotation.Secured;
  21. import org.springframework.stereotype.Component;

  22. import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee;
  23. import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeRoleMember;
  24. import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommitteeRoleMember_;
  25. import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
  26. import com.hack23.cia.service.api.DataContainer;
  27. import com.hack23.cia.web.impl.ui.application.action.ViewAction;
  28. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandCommitteeConstants;
  29. import com.hack23.cia.web.impl.ui.application.views.common.pagemode.CardInfoRowUtil;
  30. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
  31. import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
  32. import com.vaadin.ui.Layout;
  33. import com.vaadin.ui.MenuBar;
  34. import com.vaadin.ui.Panel;
  35. import com.vaadin.ui.VerticalLayout;

  36. /**
  37.  * The Class CommitteeCurrentMembersHistoryPageModContentFactoryImpl.
  38.  */
  39. @Component
  40. public final class CommitteeCurrentMembersHistoryPageModContentFactoryImpl
  41.         extends AbstractCommitteePageModContentFactoryImpl {

  42.     /** The Constant LISTENER. */
  43.     private static final PageItemPropertyClickListener LISTENER = new PageItemPropertyClickListener(
  44.             UserViews.POLITICIAN_VIEW_NAME, "personId");

  45.     /**
  46.      * Instantiates a new committee current members history page mod content
  47.      * factory impl.
  48.      */
  49.     public CommitteeCurrentMembersHistoryPageModContentFactoryImpl() {
  50.         super();
  51.     }

  52.     @SuppressWarnings("unchecked")
  53.     @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
  54.     @Override
  55.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  56.         final VerticalLayout panelContent = createPanelContent();

  57.         final String pageId = getPageId(parameters);

  58.         final ViewRiksdagenCommittee viewRiksdagenCommittee = getItem(parameters);
  59.         getCommitteeMenuItemFactory().createCommitteeeMenuBar(menuBar, pageId);

  60.         CardInfoRowUtil.createPageHeader(panel, panelContent,
  61.             CommitteeViewConstants.CM_TITLE_HEADER + viewRiksdagenCommittee.getEmbeddedId().getDetail(),
  62.             CommitteeViewConstants.CM_TITLE,
  63.             CommitteeViewConstants.CM_DESCRIPTION);

  64.         final DataContainer<ViewRiksdagenCommitteeRoleMember, String> committeeRoleMemberDataContainer = getApplicationManager()
  65.                 .getDataContainer(ViewRiksdagenCommitteeRoleMember.class);

  66.         getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenCommitteeRoleMember.class,
  67.                 committeeRoleMemberDataContainer.findListByProperty(
  68.                         new Object[] { viewRiksdagenCommittee.getEmbeddedId().getDetail(), Boolean.TRUE },
  69.                         ViewRiksdagenCommitteeRoleMember_.detail, ViewRiksdagenCommitteeRoleMember_.active),
  70.                 CommitteeGridConstants.CURRENT_MEMBERS_GRID_NAME,
  71.                 CommitteeGridConstants.MEMBER_HISTORY_COLUMN_ORDER,
  72.                 CommitteeGridConstants.CURRENT_MEMBERS_HIDDEN_COLUMNS,
  73.                 LISTENER, null, null);

  74.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_VIEW, ApplicationEventGroup.USER, NAME,
  75.                 parameters, pageId);
  76.         return panelContent;

  77.     }

  78.     @Override
  79.     public boolean matches(final String page, final String parameters) {
  80.         return PageCommandCommitteeConstants.COMMAND_COMMITTEE_CURRENT_MEMBERS.matches(page, parameters);
  81.     }

  82. }