AliasTableRicerchePersonalizzate.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.transazioni.utils;

  21. import java.util.ArrayList;
  22. import java.util.List;

  23. import org.openspcoop2.generic_project.beans.IAliasTableField;
  24. import org.openspcoop2.generic_project.beans.IField;
  25. import org.openspcoop2.generic_project.exception.ExpressionException;
  26. import org.openspcoop2.generic_project.exception.ExpressionNotImplementedException;
  27. import org.openspcoop2.generic_project.expression.IExpression;
  28. import org.openspcoop2.generic_project.expression.impl.sql.ISQLFieldConverter;
  29. import org.openspcoop2.utils.sql.ISQLQueryObject;
  30. import org.openspcoop2.utils.sql.SQLQueryObjectException;

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

  39.     public static final String ALIAS_PREFIX = "op2T";
  40.    
  41.     public static List<String> addFromTable(IExpression expression, ISQLQueryObject sqlQueryObject,ISQLFieldConverter fieldConverter) throws ExpressionNotImplementedException, ExpressionException, SQLQueryObjectException{
  42.         List<IField> iFields = expression.getFields(true);
  43.         List<String> tabelleAggiunteAlias = new ArrayList<>();
  44.         if(iFields!=null && iFields.size()>0){
  45.             for (IField iField : iFields) {
  46.                 if(iField instanceof IAliasTableField){
  47.                     IAliasTableField af = (IAliasTableField) iField;
  48.                     //System.out.println("CHECK ALIAS ["+af.getAliasTable()+"] ["+af.getFieldName()+"] ...");
  49.                     if(org.openspcoop2.core.transazioni.Transazione.model().DUMP_MESSAGGIO.CONTENUTO.NOME.equals(af.getField())){
  50.                         String aliasTabella = af.getAliasTable();
  51.                         //System.out.println("CHECK ALIAS DENTRO ["+af.getAliasTable()+"] ["+af.getFieldName()+"] ...");
  52.                         if(tabelleAggiunteAlias.contains(aliasTabella)==false){
  53.                             //Lo fa gia in automatico la gestione dell'Expression
  54.                             //sqlQueryObject.addFromTable(fieldConverter.toTable(Transazione.model().DUMP_MESSAGGIO.CONTENUTO), aliasTabella);
  55.                             //System.out.println("CHECK ALIAS ADD ["+af.getAliasTable()+"] ["+af.getFieldName()+"]");
  56.                             tabelleAggiunteAlias.add(aliasTabella);
  57.                         }
  58.                     }
  59.                 }
  60.             }
  61.         }
  62.         return tabelleAggiunteAlias;
  63.     }
  64.    
  65. }