RuoloTransazione.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.logger.record;

  21. import java.io.Serializable;


  22. /**    
  23.  * RuoloTransazione
  24.  *
  25.  * @author Poli Andrea (poli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public enum RuoloTransazione implements Serializable{

  30.     INVOCAZIONE_ONEWAY ("1"),
  31.     INVOCAZIONE_SINCRONA ("2"),
  32.     INVOCAZIONE_ASINCRONA_SIMMETRICA ("3"),
  33.     RISPOSTA_ASINCRONA_SIMMETRICA ("4"),
  34.     INVOCAZIONE_ASINCRONA_ASIMMETRICA ("5"),
  35.     RICHIESTA_STATO_ASINCRONA_ASIMMETRICA ("6"),
  36.     INTEGRATION_MANAGER ("7");

  37.     private final String valore;

  38.     RuoloTransazione(String valore)
  39.     {
  40.         this.valore = valore;
  41.     }

  42.     public String getValore()
  43.     {
  44.         return this.valore;
  45.     }

  46.     public int getValoreAsInt()
  47.     {
  48.         return Integer.parseInt(this.valore);
  49.     }

  50.     public static String[] toStringArray(){
  51.         String[] res = new String[values().length];
  52.         int i=0;
  53.         for (RuoloTransazione tmp : values()) {
  54.             res[i]=tmp.getValore();
  55.             i++;
  56.         }
  57.         return res;
  58.     }
  59.     public static int[] toIntArray(){
  60.         int[] res = new int[values().length];
  61.         int i=0;
  62.         for (RuoloTransazione tmp : values()) {
  63.             res[i]=tmp.getValoreAsInt();
  64.             i++;
  65.         }
  66.         return res;
  67.     }
  68.     public static String[] toEnumNameArray(){
  69.         String[] res = new String[values().length];
  70.         int i=0;
  71.         for (RuoloTransazione tmp : values()) {
  72.             res[i]=tmp.name();
  73.             i++;
  74.         }
  75.         return res;
  76.     }


  77.     public static RuoloTransazione toEnumConstant(int val){
  78.         return toEnumConstant(""+val);
  79.     }
  80.     public static RuoloTransazione toEnumConstant(String val){

  81.         RuoloTransazione res = null;

  82.         if(RuoloTransazione.INVOCAZIONE_ONEWAY.toString().equals(val)){
  83.             res = RuoloTransazione.INVOCAZIONE_ONEWAY;
  84.         }else if(RuoloTransazione.INVOCAZIONE_SINCRONA.toString().equals(val)){
  85.             res = RuoloTransazione.INVOCAZIONE_SINCRONA;
  86.         } else if(RuoloTransazione.INVOCAZIONE_ASINCRONA_SIMMETRICA.toString().equals(val)){
  87.             res = RuoloTransazione.INVOCAZIONE_ASINCRONA_SIMMETRICA;
  88.         }  else if(RuoloTransazione.RISPOSTA_ASINCRONA_SIMMETRICA.toString().equals(val)){
  89.             res = RuoloTransazione.RISPOSTA_ASINCRONA_SIMMETRICA;
  90.         }  else if(RuoloTransazione.INVOCAZIONE_ASINCRONA_ASIMMETRICA.toString().equals(val)){
  91.             res = RuoloTransazione.INVOCAZIONE_ASINCRONA_ASIMMETRICA;
  92.         }  else if(RuoloTransazione.RICHIESTA_STATO_ASINCRONA_ASIMMETRICA.toString().equals(val)){
  93.             res = RuoloTransazione.RICHIESTA_STATO_ASINCRONA_ASIMMETRICA;
  94.         } else if(RuoloTransazione.INTEGRATION_MANAGER.toString().equals(val)){
  95.             res = RuoloTransazione.INTEGRATION_MANAGER;
  96.         }
  97.         return res;
  98.     }

  99.    
  100.     @Override
  101.     public String toString(){
  102.         return this.valore;
  103.     }
  104.     public boolean equals(String esito){
  105.         return this.toString().equals(esito);
  106.     }


  107.     public static RuoloTransazione getEnumConstantFromOpenSPCoopValue(String val){
  108.        
  109.         /**System.out.println("VALORE DA CONVERTIRE ["+val+"]");*/
  110.        
  111.         if(org.openspcoop2.protocol.engine.constants.Costanti.SCENARIO_ONEWAY_INVOCAZIONE_SERVIZIO.equals(val)){
  112.             /**System.out.println("RITORNO ["+RuoloTransazione.INVOCAZIONE_ONEWAY+"]");*/
  113.             return RuoloTransazione.INVOCAZIONE_ONEWAY;
  114.         }
  115.         else if(org.openspcoop2.protocol.engine.constants.Costanti.SCENARIO_SINCRONO_INVOCAZIONE_SERVIZIO.equals(val)){
  116.             /**System.out.println("RITORNO ["+RuoloTransazione.INVOCAZIONE_SINCRONA+"]");*/
  117.             return RuoloTransazione.INVOCAZIONE_SINCRONA;
  118.         }
  119.         else if(org.openspcoop2.protocol.engine.constants.Costanti.SCENARIO_ASINCRONO_SIMMETRICO_INVOCAZIONE_SERVIZIO.equals(val)){
  120.             /**System.out.println("RITORNO ["+RuoloTransazione.INVOCAZIONE_ASINCRONA_SIMMETRICA+"]");*/
  121.             return RuoloTransazione.INVOCAZIONE_ASINCRONA_SIMMETRICA;
  122.         }
  123.         else if(org.openspcoop2.protocol.engine.constants.Costanti.SCENARIO_ASINCRONO_SIMMETRICO_CONSEGNA_RISPOSTA.equals(val)){
  124.             /**System.out.println("RITORNO ["+RuoloTransazione.RISPOSTA_ASINCRONA_SIMMETRICA+"]");*/
  125.             return RuoloTransazione.RISPOSTA_ASINCRONA_SIMMETRICA;
  126.         }
  127.         else if(org.openspcoop2.protocol.engine.constants.Costanti.SCENARIO_ASINCRONO_ASIMMETRICO_INVOCAZIONE_SERVIZIO.equals(val)){
  128.             /**System.out.println("RITORNO ["+RuoloTransazione.INVOCAZIONE_ASINCRONA_ASIMMETRICA+"]");*/
  129.             return RuoloTransazione.INVOCAZIONE_ASINCRONA_ASIMMETRICA;
  130.         }
  131.         else if(org.openspcoop2.protocol.engine.constants.Costanti.SCENARIO_ASINCRONO_ASIMMETRICO_POLLING.equals(val)){
  132.             /**System.out.println("RITORNO ["+RuoloTransazione.RICHIESTA_STATO_ASINCRONA_ASIMMETRICA+"]");*/
  133.             return RuoloTransazione.RICHIESTA_STATO_ASINCRONA_ASIMMETRICA;
  134.         }
  135.         else {
  136.             /**System.out.println("RITORNO NULL");*/
  137.             return null;
  138.         }
  139.     }


  140. }