DataElementInfo.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.web.lib.mvc;

  21. import java.io.Serializable;
  22. import java.util.List;

  23. import org.apache.commons.lang.StringUtils;

  24. /**
  25.  * DataElementInfo
  26.  *
  27.  * @author Giuliano Pintori (pintori@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class DataElementInfo implements Serializable {

  32.     /**
  33.      *
  34.      */
  35.     private static final long serialVersionUID = 1L;
  36.    
  37.     public DataElementInfo(String headerFinestraModale) {
  38.         this.headerFinestraModale = headerFinestraModale;
  39.         this.buttonIcon = Costanti.INFO_BUTTON_ICON_WHITE;
  40.     }
  41.     private String headerFinestraModale;
  42.    
  43.     private String headerBody;
  44.    
  45.     private List<String> listBody;
  46.    
  47.     private String body;
  48.    
  49.     private String buttonIcon;

  50.     public String getHeaderFinestraModale() {
  51.         return this.headerFinestraModale;
  52.     }

  53.     public String getHeaderBody() {
  54.         return this.headerBody;
  55.     }

  56.     public void setHeaderBody(String headerBody) {
  57.         this.headerBody = headerBody;
  58.     }

  59.     public List<String> getListBody() {
  60.         return this.listBody;
  61.     }
  62.    
  63.     public String getListBodyHtml() {
  64.         StringBuilder sb = new StringBuilder();
  65.        
  66.         if(this.getListBody() != null && !this.getListBody().isEmpty()) {
  67.             sb.append("<ul>");
  68.            
  69.             for (String info : this.getListBody()) {
  70.                 sb.append("<li>").append(info).append("</li>");
  71.             }
  72.                    
  73.             sb.append("</ul>");    
  74.         }
  75.         return sb.toString();
  76.     }

  77.     public void setListBody(List<String> listBody) {
  78.         this.listBody = listBody;
  79.     }

  80.     public String getBody() {
  81.         StringBuilder sb = new StringBuilder();
  82.        
  83.        
  84.         if(StringUtils.isNotEmpty(this.body)) {
  85.             sb.append(this.body);
  86.         } else {
  87.             sb.append("<p>");
  88.            
  89.             boolean addBreak = false;
  90.             if(StringUtils.isNotEmpty(this.getHeaderBody())) {
  91.                 sb.append("<span>").append(this.getHeaderBody()).append("</span>");
  92.                 addBreak = true;
  93.             }
  94.            
  95.             if(StringUtils.isNotEmpty(this.getListBodyHtml())) {
  96.                 if(addBreak)
  97.                     sb.append("<br/>");
  98.                
  99.                 sb.append(this.getListBodyHtml());
  100.             }
  101.            
  102.             sb.append("</p>");
  103.         }
  104.        
  105.         return sb.toString();
  106.     }

  107.     public void setBody(String body) {
  108.         this.body = body;
  109.     }

  110.     public String getButtonIcon() {
  111.         return this.buttonIcon;
  112.     }

  113.     public void setButtonIcon(String buttonIcon) {
  114.         this.buttonIcon = buttonIcon;
  115.     }
  116. }