SPCoopArchiveExportUtils.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.spcoop.archive;

  21. import org.openspcoop2.core.id.IDAccordo;
  22. import org.openspcoop2.core.id.IDServizio;
  23. import org.openspcoop2.core.id.IDSoggetto;
  24. import org.openspcoop2.core.registry.AccordoCooperazionePartecipanti;
  25. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  26. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  27. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  28. import org.openspcoop2.protocol.sdk.registry.IRegistryReader;
  29. import org.openspcoop2.protocol.spcoop.sica.SICAtoOpenSPCoopContext;

  30. /**
  31.  * SPCoopArchiveExportUtils
  32.  *
  33.  * @author Poli Andrea (apoli@link.it)
  34.  * @author $Author$
  35.  * @version $Rev$, $Date$
  36.  */
  37. public class SPCoopArchiveExportUtils {


  38.     /* ------------ SetCodiceIPA -------------------------- */
  39.    
  40.     public static void setCodiceIPA(AccordoServizioParteComune aspc,SICAtoOpenSPCoopContext contextSICA,IRegistryReader registryReader) throws Exception{
  41.         // Imposto CodiceIPA memorizzato per Referente
  42.         if(aspc.getSoggettoReferente()!=null){
  43.                 IDSoggetto soggettoReferente = new IDSoggetto(aspc.getSoggettoReferente().getTipo(),aspc.getSoggettoReferente().getNome());
  44.                 String codiceIPAReferente = registryReader.getCodiceIPA(soggettoReferente);
  45.                 contextSICA.addMappingSoggettoSPCoopToCodiceIPA(soggettoReferente, codiceIPAReferente);
  46.         }
  47.         // Imposto CodiceIPA memorizzato per erogatori servizi componenti
  48.         if(aspc.getServizioComposto()!=null){
  49.                 for(int i=0;i<aspc.getServizioComposto().sizeServizioComponenteList();i++){
  50.                         IDSoggetto soggettoErogatoreServizioComponente =
  51.                                 new IDSoggetto(aspc.getServizioComposto().getServizioComponente(i).getTipoSoggetto(),
  52.                                         aspc.getServizioComposto().getServizioComponente(i).getNomeSoggetto());
  53.                         String codiceIPASoggettoErogatoreServizioComponente = registryReader.getCodiceIPA(soggettoErogatoreServizioComponente);
  54.                         contextSICA.addMappingSoggettoSPCoopToCodiceIPA(soggettoErogatoreServizioComponente, codiceIPASoggettoErogatoreServizioComponente);
  55.                 }
  56.         }
  57.     }
  58.    
  59.     public static void setCodiceIPA(org.openspcoop2.core.registry.AccordoCooperazione ac,SICAtoOpenSPCoopContext contextSICA,IRegistryReader registryReader) throws Exception{
  60.         // Imposto CodiceIPA memorizzato per Coordinatore
  61.         if(ac.getSoggettoReferente()!=null){
  62.                 IDSoggetto soggettoCoordinatore = new IDSoggetto(ac.getSoggettoReferente().getTipo(),ac.getSoggettoReferente().getNome());
  63.                 String codiceIPACoordinatore = registryReader.getCodiceIPA(soggettoCoordinatore);
  64.                 contextSICA.addMappingSoggettoSPCoopToCodiceIPA(soggettoCoordinatore, codiceIPACoordinatore);
  65.         }
  66.         // Imposto CodiceIPA per Partecipanti
  67.         if(ac.getElencoPartecipanti()!=null){
  68.                 AccordoCooperazionePartecipanti partecipanti = ac.getElencoPartecipanti();
  69.                 for(int i=0; i<partecipanti.sizeSoggettoPartecipanteList();i++){
  70.                         IDSoggetto soggettoPartecipante = new IDSoggetto(partecipanti.getSoggettoPartecipante(i).getTipo(),partecipanti.getSoggettoPartecipante(i).getNome());
  71.                         String codiceIPAPartecipante = registryReader.getCodiceIPA(soggettoPartecipante);
  72.                         contextSICA.addMappingSoggettoSPCoopToCodiceIPA(soggettoPartecipante, codiceIPAPartecipante);
  73.                 }
  74.         }
  75.         // Imposto CodiceIPA per erogatori servizi composti
  76.         for(int i=0; i<ac.sizeUriServiziCompostiList(); i++){
  77.                 String uriServizioComposto =  ac.getUriServiziComposti(i);
  78.                 IDAccordo idAccordoServizioComposto = IDAccordoFactory.getInstance().getIDAccordoFromUri(uriServizioComposto);
  79.                 if(idAccordoServizioComposto.getSoggettoReferente()!=null){
  80.                         String codiceIPASoggettoErogatoreServizioComposto = registryReader.getCodiceIPA(idAccordoServizioComposto.getSoggettoReferente());
  81.                         contextSICA.addMappingSoggettoSPCoopToCodiceIPA(idAccordoServizioComposto.getSoggettoReferente(), codiceIPASoggettoErogatoreServizioComposto);
  82.                 }
  83.         }
  84.     }

  85.     public static void setCodiceIPA(IDServizio idS,IDAccordo idAccordoServizioParteComune,SICAtoOpenSPCoopContext contextSICA,IRegistryReader registryReader) throws Exception{
  86.         // Imposto CodiceIPA memorizzato per Erogatore
  87.         String codiceIPASoggettoErogatore = registryReader.getCodiceIPA(idS.getSoggettoErogatore());
  88.         contextSICA.addMappingSoggettoSPCoopToCodiceIPA(idS.getSoggettoErogatore(), codiceIPASoggettoErogatore);
  89.         // Imposto CodiceIPA memorizzato per referente Accordo di Servizio Parte Comune
  90.         if(idAccordoServizioParteComune.getSoggettoReferente()!=null){
  91.                 IDSoggetto referenteParteComune = new IDSoggetto(idAccordoServizioParteComune.getSoggettoReferente().getTipo(),idAccordoServizioParteComune.getSoggettoReferente().getNome());
  92.                 String codiceIPAReferenteParteComune = registryReader.getCodiceIPA(referenteParteComune);
  93.                 contextSICA.addMappingSoggettoSPCoopToCodiceIPA(referenteParteComune, codiceIPAReferenteParteComune);
  94.         }
  95.     }
  96.    
  97.    
  98.    
  99.     /* ------------ SetURIAccordiServizioParteSpecifica -------------------------- */
  100.    
  101.     public static void setURI_APS(AccordoServizioParteComune as,SICAtoOpenSPCoopContext contextSICA,IRegistryReader registryReader) throws Exception{
  102.             // Imposto uriAPS per servizi componenti
  103.             if(as.getServizioComposto()!=null){
  104.                     for(int i=0;i<as.getServizioComposto().sizeServizioComponenteList();i++){
  105.                             IDSoggetto soggettoErogatoreServizioComponente =
  106.                                     new IDSoggetto(as.getServizioComposto().getServizioComponente(i).getTipoSoggetto(),as.getServizioComposto().getServizioComponente(i).getNomeSoggetto());
  107.                             IDServizio idServizioComponente = IDServizioFactory.getInstance().getIDServizioFromValues(as.getServizioComposto().getServizioComponente(i).getTipo(),
  108.                                     as.getServizioComposto().getServizioComponente(i).getNome(),
  109.                                     soggettoErogatoreServizioComponente,
  110.                                     as.getServizioComposto().getServizioComponente(i).getVersione());
  111.                             contextSICA.addMappingServizioToUriAPS(registryReader, idServizioComponente);
  112.                     }
  113.             }
  114.     }
  115.    
  116.    
  117. }