PartyMemberHistoryPageModContentFactoryImpl.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.ViewRiksdagenPartyMember;
  24. import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartyMember_;
  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 MemberHistoryPageModContentFactoryImpl.
  38.  */
  39. @Component
  40. public final class PartyMemberHistoryPageModContentFactoryImpl extends AbstractPartyPageModContentFactoryImpl {

  41.     /** The Constant COLUMN_ORDER. */
  42.     private static final String[] COLUMN_ORDER = { "id", "firstName", "lastName", "activityLevel", "activityProfile", "collaborationPercentage", "individualMotions", "partyMotions",
  43.             "committeeMotions", "multiPartyMotions", "documentsLastYear", "totalDocuments", "status"
  44.              };

  45.     /** The Constant HIDE_COLUMNS. */
  46.     private static final String[] HIDE_COLUMNS = { "id","partyId", "phoneNumber", "postCode", "registeredDate", "shortCode", "website",
  47.             "gender", "hangarGuid", "imageUrl192", "imageUrl80", "imageUrlMax","coAddress","city","hjid",
  48.             "personUrlXml", "place", "personAssignmentData", "personDetailData","party", "partyName","email","faxNumber","address","bornYear" };

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

  52.     /** The Constant POLITICIANS. */
  53.     private static final String POLITICIANS = "Politicians";

  54.     /**
  55.      * Instantiates a new party member history page mod content factory impl.
  56.      */
  57.     public PartyMemberHistoryPageModContentFactoryImpl() {
  58.         super();
  59.     }

  60.     /**
  61.      * Creates the content.
  62.      *
  63.      * @param parameters the parameters
  64.      * @param menuBar the menu bar
  65.      * @param panel the panel
  66.      * @return the layout
  67.      */
  68.     @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
  69.     @Override
  70.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  71.         final VerticalLayout panelContent = createPanelContent();

  72.         final String pageId = getPageId(parameters);

  73.         final ViewRiksdagenParty viewRiksdagenParty = getItem(parameters);
  74.         getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);

  75.         CardInfoRowUtil.createPageHeader(panel, panelContent,
  76.             PartyViewConstants.MEMBER_HISTORY_HEADER + " " + viewRiksdagenParty.getPartyName(),
  77.             PartyViewConstants.MEMBER_HISTORY_TITLE,
  78.             PartyViewConstants.MEMBER_HISTORY_DESC);

  79.         final DataContainer<ViewRiksdagenPartyMember, String> partyMembernDataContainer = getApplicationManager()
  80.                 .getDataContainer(ViewRiksdagenPartyMember.class);

  81.         getGridFactory().createBasicBeanItemGrid(panelContent, ViewRiksdagenPartyMember.class,
  82.                 partyMembernDataContainer.getAllBy(ViewRiksdagenPartyMember_.party, viewRiksdagenParty.getPartyId()),
  83.                 POLITICIANS, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

  84.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARTY_VIEW, ApplicationEventGroup.USER, NAME, parameters,
  85.         pageId);
  86.         return panelContent;

  87.     }

  88.     /**
  89.      * Matches.
  90.      *
  91.      * @param page the page
  92.      * @param parameters the parameters
  93.      * @return true, if successful
  94.      */
  95.     @Override
  96.     public boolean matches(final String page, final String parameters) {
  97.         return PageCommandPartyConstants.COMMAND_PARTY_MEMBER_HISTORY.matches(page, parameters);
  98.     }

  99. }