DocumentPersonReferencesPageModContentFactoryImpl.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.document.pagemode;

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

  22. import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentData;
  23. import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentData_;
  24. import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentPersonReferenceData;
  25. import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer;
  26. import com.hack23.cia.model.external.riksdagen.dokumentstatus.impl.DocumentStatusContainer_;
  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.menufactory.api.pagecommands.PageCommandDocumentConstants;
  31. import com.hack23.cia.web.impl.ui.application.views.common.pagemode.CardInfoRowUtil;
  32. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
  33. import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
  34. import com.vaadin.ui.Layout;
  35. import com.vaadin.ui.MenuBar;
  36. import com.vaadin.ui.Panel;
  37. import com.vaadin.ui.VerticalLayout;

  38. /**
  39.  * The Class DocumentPersonReferencesPageModContentFactoryImpl.
  40.  */
  41. @Component
  42. public final class DocumentPersonReferencesPageModContentFactoryImpl extends AbstractDocumentPageModContentFactoryImpl {

  43.     /** The Constant COLUMN_ORDER. */
  44.     private static final String[] COLUMN_ORDER = { "personReferenceId", "referenceName", "partyShortCode",
  45.             "orderNumber", "roleDescription" };

  46.     /** The Constant DOCUMENT_PERSON_REFERENCES. */
  47.     private static final String DOCUMENT_PERSON_REFERENCES = "Document person references";

  48.     /** The Constant HIDE_COLUMNS. */
  49.     private static final String[] HIDE_COLUMNS = { "personReferenceId", "hjid" };

  50.     /** The Constant LISTENER. */
  51.     private static final PageItemPropertyClickListener LISTENER = new PageItemPropertyClickListener(
  52.             UserViews.POLITICIAN_VIEW_NAME, "personReferenceId");
  53.     /**
  54.      * Instantiates a new document person references page mod content factory
  55.      * impl.
  56.      */
  57.     public DocumentPersonReferencesPageModContentFactoryImpl() {
  58.         super();
  59.     }

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

  64.         final String pageId = getPageId(parameters);
  65.         getDocumentMenuItemFactory().createDocumentMenuBar(menuBar, pageId);

  66.         final DataContainer<DocumentStatusContainer, String> documentStatusContainerDataContainer = getApplicationManager()
  67.                 .getDataContainer(DocumentStatusContainer.class);

  68.         final DocumentStatusContainer documentStatusContainer = documentStatusContainerDataContainer
  69.                 .findByQueryProperty(DocumentStatusContainer.class, DocumentStatusContainer_.document,
  70.                         DocumentData.class, DocumentData_.id, pageId);

  71.         CardInfoRowUtil.createPageHeader(panel, panelContent,
  72.             DocumentViewConstants.PERSON_REFERENCES_TITLE,
  73.             DocumentViewConstants.PERSON_REFERENCES_SUBTITLE,
  74.             DocumentViewConstants.PERSON_REFERENCES_DESC);

  75.         if (documentStatusContainer != null && documentStatusContainer.getDocumentPersonReferenceContainer() != null
  76.                 && documentStatusContainer.getDocumentPersonReferenceContainer()
  77.                         .getDocumentPersonReferenceList() != null) {

  78.             getGridFactory().createBasicBeanItemGrid(panelContent, DocumentPersonReferenceData.class,
  79.                     documentStatusContainer.getDocumentPersonReferenceContainer().getDocumentPersonReferenceList(),
  80.                     DOCUMENT_PERSON_REFERENCES, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);

  81.         }

  82.         panel.setContent(panelContent);
  83.         getPageActionEventHelper().createPageEvent(ViewAction.VISIT_DOCUMENT_VIEW, ApplicationEventGroup.USER, NAME,
  84.                 parameters, pageId);

  85.         return panelContent;

  86.     }

  87.     @Override
  88.     public boolean matches(final String page, final String parameters) {
  89.         return PageCommandDocumentConstants.COMMAND_DOCUMENT_PERSON_REFERENCES.matches(page, parameters);
  90.     }

  91. }