EventiUtilities.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.pdd.core.eventi;

  21. import java.text.SimpleDateFormat;

  22. import org.openspcoop2.core.eventi.Evento;
  23. import org.openspcoop2.core.eventi.utils.SeveritaConverter;
  24. import org.openspcoop2.utils.date.DateUtils;

  25. /**    
  26.  * EventiUtilities
  27.  *
  28.  * @author Poli Andrea (poli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */
  32. public class EventiUtilities {

  33.     public static String toString(Evento evento){
  34.         StringBuilder bf = new StringBuilder();

  35.         SimpleDateFormat sdf = DateUtils.getSimpleDateFormatMs();
  36.         if(evento.getOraRegistrazione()!=null){
  37.             bf.append("<").append(sdf.format(evento.getOraRegistrazione())).append(">");
  38.         }

  39.         if(evento.getTipo()!=null){
  40.             if(bf.length()>0){
  41.                 bf.append(" ");
  42.             }
  43.             bf.append("Tipo:").append(evento.getTipo());
  44.         }

  45.         if(evento.getCodice()!=null){
  46.             if(bf.length()>0){
  47.                 bf.append(" ");
  48.             }
  49.             bf.append("Codice:").append(evento.getCodice());
  50.         }

  51.         if(evento.getSeverita()>=0){
  52.             if(bf.length()>0){
  53.                 bf.append(" ");
  54.             }
  55.             bf.append("Severita:");
  56.             try{
  57.                 bf.append(SeveritaConverter.toSeverita(evento.getSeverita()).name());
  58.             }catch(Exception e){
  59.                 bf.append("[ERRORE:"+e.getMessage()+"]");
  60.             }
  61.         }

  62.         if(evento.getDescrizione()!=null){
  63.             if(bf.length()>0){
  64.                 bf.append(" ");
  65.             }
  66.             bf.append("Descrizione:").append(evento.getDescrizione());
  67.         }

  68.         if(evento.getIdTransazione()!=null){
  69.             if(bf.length()>0){
  70.                 bf.append(" ");
  71.             }
  72.             bf.append("IdTransazione:").append(evento.getIdTransazione());
  73.         }

  74.         if(evento.getClusterId()!=null){
  75.             if(bf.length()>0){
  76.                 bf.append(" ");
  77.             }
  78.             bf.append("IdCluster:").append(evento.getClusterId());
  79.         }

  80.         return bf.toString();
  81.     }

  82. }