Connettore.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;

  21. import javax.xml.bind.annotation.XmlAccessType;
  22. import javax.xml.bind.annotation.XmlAccessorType;
  23. import javax.xml.bind.annotation.XmlAttribute;
  24. import javax.xml.bind.annotation.XmlElement;
  25. import javax.xml.bind.annotation.XmlRootElement;
  26. import javax.xml.bind.annotation.XmlType;
  27. import java.io.Serializable;
  28. import java.util.ArrayList;
  29. import java.util.HashMap;
  30. import java.util.Iterator;
  31. import java.util.List;
  32. import java.util.Map;
  33. import java.util.Set;


  34. /** <p>Java class for connettore complex type.
  35.  *
  36.  * <p>The following schema fragment specifies the expected content contained within this class.
  37.  *
  38.  * <pre>
  39.  * &lt;complexType name="connettore"&gt;
  40.  *      &lt;sequence&gt;
  41.  *          &lt;element name="property" type="{http://www.openspcoop2.org/core/registry}Property" minOccurs="0" maxOccurs="unbounded"/&gt;
  42.  *      &lt;/sequence&gt;
  43.  *      &lt;attribute name="custom" type="{http://www.w3.org/2001/XMLSchema}string" use="optional" default="false"/&gt;
  44.  *      &lt;attribute name="tipo" type="{http://www.w3.org/2001/XMLSchema}string" use="optional"/&gt;
  45.  *      &lt;attribute name="nome" type="{http://www.w3.org/2001/XMLSchema}string" use="required"/&gt;
  46.  * &lt;/complexType&gt;
  47.  * </pre>
  48.  *
  49.  * @version $Rev$, $Date$
  50.  *
  51.  * @author Poli Andrea (poli@link.it)
  52.  * @author $Author$
  53.  * */

  54. @XmlAccessorType(XmlAccessType.FIELD)
  55. @XmlType(name = "connettore",
  56.   propOrder = {
  57.     "property"
  58.   }
  59. )

  60. @XmlRootElement(name = "connettore")

  61. public class Connettore extends org.openspcoop2.utils.beans.BaseBeanWithId implements Serializable , Cloneable {
  62.   public Connettore() {
  63.     super();
  64.   }

  65.   public void addProperty(Property property) {
  66.     this.property.add(property);
  67.   }

  68.   public Property getProperty(int index) {
  69.     return this.property.get( index );
  70.   }

  71.   public Property removeProperty(int index) {
  72.     return this.property.remove( index );
  73.   }

  74.   public List<Property> getPropertyList() {
  75.     return this.property;
  76.   }

  77.   public void setPropertyList(List<Property> property) {
  78.     this.property=property;
  79.   }

  80.   public int sizePropertyList() {
  81.     return this.property.size();
  82.   }

  83.   public Boolean getCustom() {
  84.     return this.custom;
  85.   }

  86.   public void setCustom(Boolean custom) {
  87.     this.custom = custom;
  88.   }

  89.   public java.lang.String getTipo() {
  90.     return this.tipo;
  91.   }

  92.   public void setTipo(java.lang.String tipo) {
  93.     this.tipo = tipo;
  94.   }

  95.   public java.lang.String getNome() {
  96.     return this.nome;
  97.   }

  98.   public void setNome(java.lang.String nome) {
  99.     this.nome = nome;
  100.   }

  101.   private static final long serialVersionUID = 1L;



  102.   public org.openspcoop2.core.config.Connettore mappingIntoConnettoreConfigurazione(){
  103.     org.openspcoop2.core.config.Connettore connettoreConfig = new org.openspcoop2.core.config.Connettore();
  104.     for(int i=0; i<this.property.size();i++){
  105.         org.openspcoop2.core.config.Property property = new org.openspcoop2.core.config.Property();
  106.         property.setNome(this.property.get(i).getNome());
  107.         property.setValore(this.property.get(i).getValore());
  108.         connettoreConfig.addProperty(property);
  109.     }
  110.     connettoreConfig.setId(this.id);
  111.     connettoreConfig.setNome(this.nome);
  112.     connettoreConfig.setTipo(this.tipo);
  113.     connettoreConfig.setCustom(this.custom);
  114.     return connettoreConfig;
  115.   }

  116.   public Map<String,String> getProperties(){
  117.     Map<String, String> map = new HashMap<>();
  118.     Iterator<Property> it = this.property.iterator();
  119.     while (it!=null && it.hasNext()){
  120.         Property elem = it.next();
  121.         map.put(elem.getNome(), elem.getValore());
  122.     }
  123.     return map;
  124.   }

  125.   public void setProperties(Map<String,String> newmap){
  126.     this.property.clear();
  127.     Set<String> keys = newmap.keySet();
  128.     Iterator<String> it = keys.iterator();
  129.     while(it.hasNext()){
  130.         String key = it.next();
  131.         Property cp = new Property();
  132.         cp.setNome(key);
  133.         cp.setValore(newmap.get(key));
  134.         this.property.add(cp);
  135.     }
  136.   }

  137.   @XmlElement(name="property",required=true,nillable=false)
  138.   private List<Property> property = new ArrayList<>();

  139.   /**
  140.    * Use method getPropertyList
  141.    * @return List&lt;Property&gt;
  142.   */
  143.   public List<Property> getProperty() {
  144.     return this.getPropertyList();
  145.   }

  146.   /**
  147.    * Use method setPropertyList
  148.    * @param property List&lt;Property&gt;
  149.   */
  150.   public void setProperty(List<Property> property) {
  151.     this.setPropertyList(property);
  152.   }

  153.   /**
  154.    * Use method sizePropertyList
  155.    * @return lunghezza della lista
  156.   */
  157.   public int sizeProperty() {
  158.     return this.sizePropertyList();
  159.   }

  160.   @javax.xml.bind.annotation.XmlSchemaType(name="string")
  161.   @XmlAttribute(name="custom",required=false)
  162.   protected Boolean custom = Boolean.valueOf("false");

  163.   @javax.xml.bind.annotation.XmlSchemaType(name="string")
  164.   @XmlAttribute(name="tipo",required=false)
  165.   protected java.lang.String tipo;

  166.   @javax.xml.bind.annotation.XmlSchemaType(name="string")
  167.   @XmlAttribute(name="nome",required=true)
  168.   protected java.lang.String nome;

  169. }