SearchDocumentResponseHandlerImpl.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.pageclicklisteners.handlers.impl;

  20. import com.hack23.cia.model.external.riksdagen.dokumentlista.impl.DocumentElement;
  21. import com.hack23.cia.service.api.action.user.SearchDocumentResponse;
  22. import com.hack23.cia.web.impl.ui.application.views.common.gridfactory.api.GridFactory;
  23. import com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio;
  24. import com.hack23.cia.web.impl.ui.application.views.common.viewnames.UserViews;
  25. import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.PageItemPropertyClickListener;
  26. import com.hack23.cia.web.impl.ui.application.views.pageclicklisteners.handlers.api.SearchDocumentResponseHandler;
  27. import com.vaadin.ui.Panel;
  28. import com.vaadin.ui.VerticalLayout;


  29. /**
  30.  * The Class SearchDocumentResponseHandlerImpl.
  31.  */
  32. public final class SearchDocumentResponseHandlerImpl implements SearchDocumentResponseHandler {

  33.     /** The Constant DOCUMENT. */
  34.     private static final String DOCUMENT = "Document";

  35.     /** The Constant DOCUMENT_GRID_COLUMN_ORDER. */
  36.     private static final String[] DOCUMENT_GRID_COLUMN_ORDER = { "rm", "createdDate", "documentName", "subType", "title", "subTitle", "status" };

  37.     /** The Constant DOCUMENT_GRID_HIDE_COLUMNS. */
  38.     private static final String[] DOCUMENT_GRID_HIDE_COLUMNS = { "rm", "lang", "noteTitle", "origin", "subType","note", "subTitle", "status", "label", "id", "hit", "madePublicDate", "databaseSource", "domainOrg", "relatedId",
  39.             "org", "documentType","docType", "debateName", "tempLabel", "numberValue", "systemDate", "kallId",
  40.             "documentFormat", "documentUrlText", "documentUrlHtml", "documentStatusUrlXml",
  41.             "committeeReportUrlXml" };

  42.     /** The Constant DOCUMENT_LISTENER. */
  43.     private static final PageItemPropertyClickListener DOCUMENT_LISTENER = new PageItemPropertyClickListener(UserViews.DOCUMENT_VIEW_NAME, "id");

  44.     /** The Constant serialVersionUID. */
  45.     private static final long serialVersionUID = 1L;

  46.     /** The form panel. */
  47.     private final Panel formPanel;

  48.     /** The grid factory. */
  49.     private final GridFactory gridFactory;

  50.     /** The searchresult layout. */
  51.     private final VerticalLayout searchresultLayout;

  52.     /**
  53.      * Instantiates a new search document response handler impl.
  54.      *
  55.      * @param gridFactory
  56.      *            the grid factory
  57.      * @param formPanel
  58.      *            the form panel
  59.      * @param searchresultLayout
  60.      *            the searchresult layout
  61.      */
  62.     public SearchDocumentResponseHandlerImpl(final GridFactory gridFactory, final Panel formPanel, final VerticalLayout searchresultLayout) {
  63.         this.formPanel = formPanel;
  64.         this.searchresultLayout = searchresultLayout;
  65.         this.gridFactory = gridFactory;
  66.     }

  67.     @Override
  68.     public void handle(final SearchDocumentResponse response) {
  69.         searchresultLayout.removeAllComponents();

  70.         searchresultLayout.addComponent(formPanel);
  71.         searchresultLayout.setExpandRatio(formPanel, ContentRatio.SMALL3);

  72.         gridFactory.createBasicBeanItemGrid(searchresultLayout, DocumentElement.class, response.getResultElement(), DOCUMENT,
  73.                 DOCUMENT_GRID_COLUMN_ORDER,
  74.                 DOCUMENT_GRID_HIDE_COLUMNS,
  75.                 DOCUMENT_LISTENER, null, null);

  76.     }
  77. }