FiltroRicerca.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.core.registry.driver;

  21. import java.io.Serializable;
  22. import java.util.ArrayList;
  23. import java.util.Date;
  24. import java.util.List;

  25. /**
  26.  * Permette il filtro di ricerca attraverso i driver che implementano l'interfaccia 'get'
  27.  *
  28.  *
  29.  * @author Poli Andrea (apoli@link.it)
  30.  * @author Nardi Lorenzo (nardi@link.it)
  31.  * @author $Author$
  32.  * @version $Rev$, $Date$
  33.  */

  34. public class FiltroRicerca implements Serializable{

  35.    
  36.     /**
  37.      *
  38.      */
  39.     private static final long serialVersionUID = 1L;

  40.     /** Intervallo inferiore */
  41.     private Date minDate;
  42.    
  43.     /** Intervallo superiore */
  44.     private Date maxDate;
  45.    
  46.     /** Nome */
  47.     private String nome;
  48.    
  49.     /** Tipo */
  50.     private String tipo;
  51.    
  52.     /** ProtocolProperty */
  53.     private List<FiltroRicercaProtocolPropertyRegistry> protocolProperties = new ArrayList<FiltroRicercaProtocolPropertyRegistry>();

  54.     public List<FiltroRicercaProtocolPropertyRegistry> getProtocolProperties() {
  55.         return this.protocolProperties;
  56.     }

  57.     public void setProtocolProperties(
  58.             List<FiltroRicercaProtocolPropertyRegistry> list) {
  59.         this.protocolProperties = list;
  60.     }

  61.     public void addProtocolProperty(FiltroRicercaProtocolPropertyRegistry filtro){
  62.         this.protocolProperties.add(filtro);
  63.     }
  64.    
  65.     /**
  66.      * @return the maxDate
  67.      */
  68.     public Date getMaxDate() {
  69.         return this.maxDate;
  70.     }

  71.     /**
  72.      * @param maxDate the maxDate to set
  73.      */
  74.     public void setMaxDate(Date maxDate) {
  75.         this.maxDate = maxDate;
  76.     }

  77.     /**
  78.      * @return the minDate
  79.      */
  80.     public Date getMinDate() {
  81.         return this.minDate;
  82.     }

  83.     /**
  84.      * @param minDate the minDate to set
  85.      */
  86.     public void setMinDate(Date minDate) {
  87.         this.minDate = minDate;
  88.     }

  89.     /**
  90.      * @return the nome
  91.      */
  92.     public String getNome() {
  93.         return this.nome;
  94.     }

  95.     /**
  96.      * @param nome the nome to set
  97.      */
  98.     public void setNome(String nome) {
  99.         this.nome = nome;
  100.     }

  101.     /**
  102.      * @return the tipo
  103.      */
  104.     public String getTipo() {
  105.         return this.tipo;
  106.     }

  107.     /**
  108.      * @param tipo the tipo to set
  109.      */
  110.     public void setTipo(String tipo) {
  111.         this.tipo = tipo;
  112.     }

  113.    
  114.     @Override
  115.     public String toString(){
  116.         return this.toString(true);
  117.     }
  118.     public String toString(boolean checkEmpty){
  119.         StringBuilder bf = new StringBuilder();
  120.         bf.append("Filtro:");
  121.         this.addDetails(bf);
  122.         if(checkEmpty){
  123.             if(bf.length()=="Filtro:".length()){
  124.                 bf.append(" nessun filtro presente");
  125.             }
  126.         }
  127.         return bf.toString();
  128.     }
  129.     public void addDetails(StringBuilder bf){
  130.         if(this.minDate!=null)
  131.             bf.append(" [intervallo-inferiore-data:"+this.minDate+"]");
  132.         if(this.maxDate!=null)
  133.             bf.append(" [intervallo-superiore-data:"+this.maxDate+"]");
  134.         if(this.tipo!=null)
  135.             bf.append(" [tipo:"+this.tipo+"]");
  136.         if(this.nome!=null)
  137.             bf.append(" [nome:"+this.nome+"]");
  138.         if(this.protocolProperties!=null && this.protocolProperties.size()>0){
  139.             bf.append(" [protocol-properties:"+this.protocolProperties.size()+"]");
  140.             for (int i = 0; i < this.protocolProperties.size(); i++) {
  141.                 bf.append(" [protocol-properties["+i+"]:");
  142.                 this.protocolProperties.get(i).addDetails(bf);
  143.                 bf.append("]");
  144.             }
  145.         }
  146.     }
  147. }