ConfigurazioneAllarmeHistoryBean.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.monitor.engine.alarm.wrapper;

  21. import java.util.ArrayList;
  22. import java.util.List;

  23. import org.openspcoop2.core.allarmi.AllarmeHistory;
  24. import org.openspcoop2.core.allarmi.constants.StatoAllarme;
  25. import org.openspcoop2.core.allarmi.utils.AllarmiConverterUtils;
  26. import org.openspcoop2.monitor.engine.alarm.utils.AllarmiUtils;
  27. import org.openspcoop2.utils.beans.BeanUtils;
  28. import org.openspcoop2.utils.beans.BlackListElement;

  29. /**
  30.  * ConfigurazioneAllarmeHistoryBean
  31.  *
  32.  * @author Giuliano Pintori (pintori@link.it)
  33.  * @author $Author$
  34.  * @version $Rev$, $Date$
  35.  */
  36. public class ConfigurazioneAllarmeHistoryBean extends AllarmeHistory{

  37.     /**
  38.      *
  39.      */
  40.     private static final long serialVersionUID = 1L;
  41.    
  42.     public ConfigurazioneAllarmeHistoryBean() {
  43.         super();
  44.     }
  45.    
  46.     public ConfigurazioneAllarmeHistoryBean(AllarmeHistory allarmeHistory){
  47.         List<BlackListElement> metodiEsclusi = new ArrayList<BlackListElement>(
  48.                 0);
  49. //      metodiEsclusi.add(new BlackListElement("setLatenzaTotale",
  50. //              Long.class));
  51.        
  52.         BeanUtils.copy(this, allarmeHistory, metodiEsclusi);
  53.     }
  54.    
  55.     private static final int LIMIT = 100;
  56.    
  57.     public String getDettaglioStatoAbbr(){
  58.     String tmp = this.getDettaglioStato();
  59.        
  60.         if(tmp != null){
  61.             if(tmp.length() >= LIMIT)
  62.                 return tmp.substring(0, (LIMIT-3))+"...";
  63.         }
  64.        
  65.         return tmp;
  66.     }
  67.    
  68.     public String getDettaglioStatoHtmlEscaped(){
  69.         String tmp = this.getDettaglioStato();
  70.        
  71.         if(tmp != null){
  72.             while(tmp.contains("\n")) {
  73.                 tmp = tmp.replace("\n", "<BR/>");
  74.             }
  75.         }
  76.        
  77.         return tmp;
  78.     }
  79.    
  80.     public String getLabelStato(){
  81.         StatoAllarme stato = AllarmiConverterUtils.toStatoAllarme(this.getStato());
  82.         return AllarmiUtils.getLabelStato(stato);
  83.     }

  84. }