ArchiveAllarme.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.protocol.sdk.archive;

  21. import org.openspcoop2.core.allarmi.constants.RuoloPorta;
  22. import org.openspcoop2.protocol.sdk.ProtocolException;

  23. /**
  24.  * ArchiveAllarme
  25.  *
  26.  * @author Poli Andrea (apoli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public class ArchiveAllarme implements IArchiveObject {

  31.     public static String buildKey(RuoloPorta ruoloPorta, String nomePorta, String alias) throws ProtocolException{
  32.        
  33.         if(alias==null){
  34.             throw new ProtocolException("alias non fornito");
  35.         }
  36.        
  37.         StringBuilder bf = new StringBuilder();
  38.         bf.append("Allarme_");
  39.         bf.append(alias);
  40.         if(ruoloPorta!=null && nomePorta!=null) {
  41.             bf.append("#");
  42.             bf.append(ruoloPorta.toString());
  43.             bf.append("_");
  44.             bf.append(nomePorta);
  45.         }
  46.         return bf.toString();
  47.     }
  48.    
  49.     @Override
  50.     public String key() throws ProtocolException {
  51.         return ArchiveAllarme.buildKey(this.ruoloPorta, this.nomePorta, this.alias);
  52.     }
  53.    
  54.    
  55.    
  56.     private RuoloPorta ruoloPorta;
  57.     private String nomePorta;
  58.     private String alias;
  59.     private org.openspcoop2.core.allarmi.Allarme allarme;
  60.     private boolean allarmeGlobale;
  61.    
  62.     private ArchiveIdCorrelazione idCorrelazione; // permette di correlare più oggetti tra di loro

  63.     public ArchiveAllarme(org.openspcoop2.core.allarmi.Allarme allarme, ArchiveIdCorrelazione idCorrelazione) throws ProtocolException{
  64.        
  65.         if(allarme==null){
  66.             throw new ProtocolException("Allarme non fornito");
  67.         }
  68.         if(allarme.getAlias()==null){
  69.             throw new ProtocolException("Allarme.alias non definito");
  70.         }
  71.         this.alias = allarme.getAlias();
  72.         if(allarme!=null && allarme.getFiltro()!=null) {
  73.             this.ruoloPorta = allarme.getFiltro().getRuoloPorta();
  74.             this.nomePorta = allarme.getFiltro().getNomePorta();
  75.         }
  76.         this.allarme = allarme;
  77.        
  78.         this.allarmeGlobale = allarme.getFiltro()==null || allarme.getFiltro().getNomePorta()==null || "".equals(allarme.getFiltro().getNomePorta());
  79.                
  80.         this.idCorrelazione = idCorrelazione;
  81.        
  82.     }
  83.    
  84.    
  85.     public String getAlias() {
  86.         return this.alias;
  87.     }
  88.     public RuoloPorta getRuoloPorta() {
  89.         return this.ruoloPorta;
  90.     }
  91.     public String getNomePorta() {
  92.         return this.nomePorta;
  93.     }
  94.     public org.openspcoop2.core.allarmi.Allarme getAllarme() {
  95.         return this.allarme;
  96.     }
  97.    
  98.     public boolean isAllarmeGlobale() {
  99.         return this.allarmeGlobale;
  100.     }
  101.    
  102.     public ArchiveIdCorrelazione getIdCorrelazione() {
  103.         return this.idCorrelazione;
  104.     }

  105. }