PartyLeaderHistoryPageModContentFactoryImpl.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.party.pagemode;

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

  22. import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty;
  23. import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartyRoleMember;
  24. import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartyRoleMember_;
  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.PageCommandPartyConstants;
  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 LeaderHistoryPageModContentFactoryImpl.
  38.  */
  39. @Component
  40. public final class PartyLeaderHistoryPageModContentFactoryImpl extends AbstractPartyPageModContentFactoryImpl {

  41.     /** The Constant COLUMN_ORDER. */
  42.     private static final String[] COLUMN_ORDER = { "roleId", "roleCode", "personId", "firstName",
  43.             "lastName", "party", "totalDaysServed", "active", "detail", "fromDate", "toDate" };

  44.     /** The Constant HIDE_COLUMNS. */
  45.     private static final String[] HIDE_COLUMNS = { "roleId", "personId", "party", "detail" };

  46.     /** The Constant LEADER_HISTORY2. */
  47.     private static final String LEADER_HISTORY2 = "Leader History";

  48.     /** The Constant LISTENER. */
  49.     private static final PageItemPropertyClickListener LISTENER = new PageItemPropertyClickListener(
  50.             UserViews.POLITICIAN_VIEW_NAME, "personId");

  51.     /**
  52.      * Instantiates a new party leader history page mod content factory impl.
  53.      */
  54.     public PartyLeaderHistoryPageModContentFactoryImpl() {
  55.         super();
  56.     }

  57.     @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
  58.     @Override
  59.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  60.         final VerticalLayout panelContent = createPanelContent();

  61.         final String pageId = getPageId(parameters);
  62.         final ViewRiksdagenParty viewRiksdagenParty = getItem(parameters);
  63.         getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);

  64.         CardInfoRowUtil.createPageHeader(panel, panelContent, PartyViewConstants.LEADER_HISTORY_HEADER + viewRiksdagenParty.getPartyName(), PartyViewConstants.LEADER_HISTORY_TITLE , PartyViewConstants.LEADER_HISTORY_DESC);

  65.         final DataContainer<ViewRiksdagenPartyRoleMember, String> partyRoleMemberDataContainer = getApplicationManager()
  66.                 .getDataContainer(ViewRiksdagenPartyRoleMember.class);

  67.         getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenPartyRoleMember.class,
  68.                 partyRoleMemberDataContainer.getAllBy(ViewRiksdagenPartyRoleMember_.party,
  69.                         viewRiksdagenParty.getPartyId()),
  70.                 LEADER_HISTORY2, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

  71.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARTY_VIEW, ApplicationEventGroup.USER, NAME, parameters,
  72.         pageId);
  73.         return panelContent;

  74.     }

  75.     @Override
  76.     public boolean matches(final String page, final String parameters) {
  77.         return PageCommandPartyConstants.COMMAND_PARTY_LEADER_HISTORY.matches(page, parameters);
  78.     }

  79. }