PartyRoleGhantPageModContentFactoryImpl.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 java.util.List;

  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.security.access.annotation.Secured;
  23. import org.springframework.stereotype.Component;

  24. import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenParty;
  25. import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartyRoleMember;
  26. import com.hack23.cia.model.internal.application.data.party.impl.ViewRiksdagenPartyRoleMember_;
  27. import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
  28. import com.hack23.cia.service.api.DataContainer;
  29. import com.hack23.cia.web.impl.ui.application.action.ViewAction;
  30. import com.hack23.cia.web.impl.ui.application.views.common.chartfactory.api.PartyGhantChartManager;
  31. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandPartyConstants;
  32. import com.hack23.cia.web.impl.ui.application.views.common.pagemode.CardInfoRowUtil;
  33. import com.vaadin.ui.Layout;
  34. import com.vaadin.ui.MenuBar;
  35. import com.vaadin.ui.Panel;
  36. import com.vaadin.ui.VerticalLayout;

  37. /**
  38.  * The Class PartyRoleGhantPageModContentFactoryImpl.
  39.  */
  40. @Component
  41. public final class PartyRoleGhantPageModContentFactoryImpl extends AbstractPartyPageModContentFactoryImpl {

  42.     /** The party ghant chart manager. */
  43.     @Autowired
  44.     private PartyGhantChartManager partyGhantChartManager;

  45.     /**
  46.      * Instantiates a new party role ghant page mod content factory impl.
  47.      */
  48.     public PartyRoleGhantPageModContentFactoryImpl() {
  49.         super();
  50.     }

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

  55.         final String pageId = getPageId(parameters);

  56.         final ViewRiksdagenParty viewRiksdagenParty = getItem(parameters);
  57.         getPartyMenuItemFactory().createPartyMenuBar(menuBar, pageId);

  58.         CardInfoRowUtil.createPageHeader(panel, panelContent,
  59.             PartyViewConstants.ROLE_GHANT_HEADER  + viewRiksdagenParty.getPartyName(),
  60.             PartyViewConstants.ROLE_GHANT_TITLE,
  61.             PartyViewConstants.ROLE_GHANT_DESC);

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

  64.         final List<ViewRiksdagenPartyRoleMember> allMembers = partyRoleMemberDataContainer
  65.                 .getAllBy(ViewRiksdagenPartyRoleMember_.party, viewRiksdagenParty.getPartyId());

  66.         partyGhantChartManager.createRoleGhant(panelContent, allMembers);

  67.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARTY_VIEW, ApplicationEventGroup.USER, NAME, parameters,
  68.         pageId);
  69.         return panelContent;

  70.     }

  71.     @Override
  72.     public boolean matches(final String page, final String parameters) {
  73.         return PageCommandPartyConstants.COMMAND_PARTY_ROLE_GHANT.matches(page, parameters);
  74.     }

  75. }