DumpUtils.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.List;

  22. import org.openspcoop2.core.transazioni.DumpMessaggio;
  23. import org.openspcoop2.core.transazioni.dao.jdbc.converter.DumpMessaggioFieldConverter;
  24. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject;
  25. import org.openspcoop2.generic_project.exception.ExpressionException;
  26. import org.openspcoop2.utils.sql.Case;
  27. import org.openspcoop2.utils.sql.CastColumnType;
  28. import org.openspcoop2.utils.sql.ISQLQueryObject;
  29. import org.openspcoop2.utils.sql.SQLQueryObjectException;

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

  38.     private static int threshold_readInMemory = -1;

  39.     public static int getThreshold_readInMemory() {
  40.         return threshold_readInMemory;
  41.     }

  42.     public static void setThreshold_readInMemory(int threshold_readInMemory) {
  43.         DumpUtils.threshold_readInMemory = threshold_readInMemory;
  44.     }
  45.    
  46.     public static final String ALIAS_BODY = "msgContentBody";
  47.    
  48.     public static void selectContentByThreshold(ISQLQueryObject sqlQueryObjectGet_dumpMessaggio, DumpMessaggioFieldConverter dumpMessaggioFieldConverter,
  49.             List<JDBCObject> listJDBCObject) throws SQLQueryObjectException, ExpressionException {
  50.        
  51.         String columnBody = dumpMessaggioFieldConverter.toColumn(DumpMessaggio.model().BODY,true);
  52.        
  53.         if(threshold_readInMemory>0) {
  54.             String columnLength = dumpMessaggioFieldConverter.toColumn(DumpMessaggio.model().CONTENT_LENGTH,true);
  55.             ISQLQueryObject sqlQueryObjectGet_condizione = sqlQueryObjectGet_dumpMessaggio.newSQLQueryObject();
  56.             sqlQueryObjectGet_condizione.setANDLogicOperator(true);
  57.             sqlQueryObjectGet_condizione.addWhereIsNotNullCondition(columnLength);
  58.             sqlQueryObjectGet_condizione.addWhereCondition(columnLength+"<?");
  59.            
  60.             Case caseValue = new Case(CastColumnType.NONE,"null");
  61.             caseValue.addCase(sqlQueryObjectGet_condizione.createSQLConditions(), columnBody);
  62.             sqlQueryObjectGet_dumpMessaggio.addSelectCaseField(caseValue, ALIAS_BODY);
  63.            
  64.             listJDBCObject.add(new JDBCObject(Long.valueOf(threshold_readInMemory),Long.class));
  65.         }
  66.         else {
  67.             sqlQueryObjectGet_dumpMessaggio.addSelectAliasField(columnBody, ALIAS_BODY);
  68.         }
  69.     }
  70.    
  71. }