FilterTransactionRepositoryImpl.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.monitor.engine.condition;

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

  23. import org.openspcoop2.core.transazioni.Transazione;
  24. import org.openspcoop2.core.transazioni.dao.jdbc.converter.TransazioneFieldConverter;
  25. import org.openspcoop2.generic_project.beans.AliasTableComplexField;
  26. import org.openspcoop2.generic_project.beans.ComplexField;
  27. import org.openspcoop2.generic_project.beans.IAliasTableField;
  28. import org.openspcoop2.generic_project.beans.IField;
  29. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  30. import org.openspcoop2.generic_project.expression.IExpression;
  31. import org.openspcoop2.generic_project.expression.impl.sql.ISQLFieldConverter;
  32. import org.openspcoop2.core.plugins.utils.FilterUtils;
  33. import org.openspcoop2.monitor.sdk.condition.IStatisticFilter;
  34. import org.openspcoop2.monitor.sdk.exceptions.SearchException;
  35. import org.openspcoop2.monitor.sdk.statistic.StatisticFilterName;
  36. import org.openspcoop2.utils.TipiDatabase;

  37. /**
  38.  * FilterTransactionRepositoryImpl
  39.  *
  40.  * @author Poli Andrea (apoli@link.it)
  41.  * @author $Author$
  42.  * @version $Rev$, $Date$
  43.  */
  44. public class FilterTransactionRepositoryImpl extends FilterImpl {  

  45.     public FilterTransactionRepositoryImpl(TipiDatabase databaseType) throws SearchException {
  46.         super(newExpression(databaseType),databaseType,newFieldConverter(databaseType));
  47.     }
  48.    
  49.    
  50.    
  51.    
  52.     private static IExpression newExpression(TipiDatabase databaseType) throws SearchException{
  53.         try{
  54.             return new JDBCExpression(newFieldConverter(databaseType));
  55.         }catch(Exception e){
  56.             throw new SearchException(e.getMessage(),e);
  57.         }
  58.     }
  59.     private static ISQLFieldConverter newFieldConverter(TipiDatabase databaseType){
  60.         return new TransazioneFieldConverter(databaseType);
  61.     }

  62.    
  63.     @Override
  64.     protected IStatisticFilter newIFilter() throws SearchException{
  65.         try{
  66.             return new FilterTransactionRepositoryImpl(this.databaseType);
  67.         }catch(Exception e){
  68.             throw new SearchException(e.getMessage(),e);
  69.         }
  70.     }
  71.    
  72.     @Override
  73.     protected IExpression newIExpression() throws SearchException{
  74.         try{
  75.             return newExpression(this.databaseType);
  76.         }catch(Exception e){
  77.             throw new SearchException(e.getMessage(),e);
  78.         }
  79.     }
  80.    
  81.     @Override
  82.     protected IField getIFieldForMessageType() throws SearchException{
  83.         return Transazione.model().DUMP_MESSAGGIO.TIPO_MESSAGGIO;
  84.     }
  85.    
  86.     @Override
  87.     protected List<IField> getIFieldForResourceName(StatisticFilterName statisticFilter) throws SearchException{
  88.         try{
  89.             List<IField> l = new ArrayList<IField>();
  90.             l.add(new AliasTableComplexField((ComplexField)Transazione.model().DUMP_MESSAGGIO.CONTENUTO.NOME, FilterUtils.getNextAliasTransactionTable()));
  91.             return l;
  92.         }catch(Exception e){
  93.             throw new SearchException(e.getMessage(),e);
  94.         }
  95.     }
  96.    
  97.     @Override
  98.     protected IField getIFieldForResourceValue(IField fieldResourceName) throws SearchException{
  99.         try{
  100.             if( !(fieldResourceName instanceof IAliasTableField)){
  101.                 throw new Exception("Unknown parameter type: "+fieldResourceName.getClass().getName());
  102.             }
  103.             IAliasTableField af = (IAliasTableField) fieldResourceName;
  104.             String aliasTable = af.getAliasTable();
  105.             return new AliasTableComplexField((ComplexField)Transazione.model().DUMP_MESSAGGIO.CONTENUTO.VALORE, aliasTable);
  106.         }catch(Exception e){
  107.             throw new SearchException(e.getMessage(),e);
  108.         }
  109.     }
  110.    
  111.    
  112. }