CommitteeRankingDataGridPageModContentFactoryImpl.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.committeeranking.pagemode;

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

  22. import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee;
  23. import com.hack23.cia.model.internal.application.data.committee.impl.ViewRiksdagenCommittee_;
  24. import com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup;
  25. import com.hack23.cia.service.api.DataContainer;
  26. import com.hack23.cia.web.impl.ui.application.action.ViewAction;
  27. import com.hack23.cia.web.impl.ui.application.views.common.menufactory.api.pagecommands.PageCommandCommitteeRankingConstants;
  28. import com.hack23.cia.web.impl.ui.application.views.common.pagemode.CardInfoRowUtil;
  29. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
  30. import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
  31. import com.hack23.cia.web.impl.ui.application.views.user.committee.pagemode.CommitteeViewConstants;
  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 CommitteeRankingDataGridPageModContentFactoryImpl.
  38.  */
  39. @Service
  40. public final class CommitteeRankingDataGridPageModContentFactoryImpl extends AbstractCommitteeRankingPageModContentFactoryImpl {

  41.     /** The Constant COLUMN_ORDER. */
  42.     private static final String[] COLUMN_ORDER = {
  43.             "embeddedId.detail",
  44.             "embeddedId",
  45.             "currentMemberSize",
  46.             "currentLeadershipPositions",
  47.             "currentSubstitutePositions",
  48.             "currentRegularMembers",
  49.             "activityLevel",
  50.             "totalCommitteeMotions",
  51.             "avgDocumentsPerMember",
  52.             "documentsLastYear",
  53.             "totalDocuments",
  54.             "totalAssignments",
  55.             "firstAssignmentDate",
  56.             "lastAssignmentDate",
  57.             "totalDaysServed",
  58.             "totalLeadershipPositions",
  59.             "totalSubstitutePositions"
  60.         };

  61.     /** The Constant HIDE_COLUMNS. */
  62.     private static final String[] HIDE_COLUMNS = {
  63.             "active",
  64.             "embeddedId",
  65.             "totalFollowUpMotions"
  66.         };

  67.     /** The Constant COMMITTEES. */
  68.     private static final String COMMITTEES = "Committees";

  69.     /** The Constant LISTENER. */
  70.     private static final PageItemPropertyClickListener LISTENER = new PageItemPropertyClickListener(UserViews.COMMITTEE_VIEW_NAME, "embeddedId.orgCode");

  71.     /** The Constant NAME. */
  72.     public static final String NAME = UserViews.COMMITTEE_RANKING_VIEW_NAME;

  73.     /** The Constant NESTED_PROPERTIES. */
  74.     private static final String[] NESTED_PROPERTIES = {"embeddedId.detail"};


  75.     /**
  76.      * Instantiates a new committee ranking data grid page mod content factory
  77.      * impl.
  78.      */
  79.     public CommitteeRankingDataGridPageModContentFactoryImpl() {
  80.         super();
  81.     }

  82.     @Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
  83.     @Override
  84.     public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
  85.         final VerticalLayout panelContent = createPanelContent();

  86.         getCommitteeRankingMenuItemFactory().createCommitteeeRankingMenuBar(menuBar);
  87.         CardInfoRowUtil.createPageHeader(panel, panelContent,
  88.             CommitteeViewConstants.CR_GRID_TITLE_HEADER,
  89.             CommitteeViewConstants.CR_GRID_TITLE,
  90.             CommitteeViewConstants.CR_GRID_DESCRIPTION);

  91.         final String pageId = getPageId(parameters);

  92.         final DataContainer<ViewRiksdagenCommittee, String> dataContainer = getApplicationManager()
  93.                 .getDataContainer(ViewRiksdagenCommittee.class);


  94.         getGridFactory().createBasicBeanItemNestedPropertiesGrid(panelContent, ViewRiksdagenCommittee.class, dataContainer.getAllOrderBy(ViewRiksdagenCommittee_.currentMemberSize),
  95.                 COMMITTEES, NESTED_PROPERTIES,
  96.                 COLUMN_ORDER, HIDE_COLUMNS,
  97.                 LISTENER, null, null);

  98.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_COMMITTEE_RANKING_VIEW, ApplicationEventGroup.USER, NAME,
  99.                 parameters, pageId);

  100.         return panelContent;

  101.     }

  102.     @Override
  103.     public boolean matches(final String page, final String parameters) {
  104.         return PageCommandCommitteeRankingConstants.COMMAND_COMMITTEE_RANKING_DATAGRID.matches(page, parameters);
  105.     }

  106. }