JDBCConfigurazioneFiltroServiceImpl.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.plugins.dao.jdbc;

  21. import java.sql.Connection;

  22. import org.openspcoop2.utils.sql.ISQLQueryObject;

  23. import org.slf4j.Logger;

  24. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceCRUDWithId;
  25. import org.openspcoop2.core.plugins.IdConfigurazioneFiltro;
  26. import org.openspcoop2.generic_project.beans.NonNegativeNumber;
  27. import org.openspcoop2.generic_project.beans.UpdateField;
  28. import org.openspcoop2.generic_project.beans.UpdateModel;

  29. import org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities;
  30. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject;
  31. import org.openspcoop2.generic_project.exception.NotFoundException;
  32. import org.openspcoop2.generic_project.exception.NotImplementedException;
  33. import org.openspcoop2.generic_project.exception.ServiceException;
  34. import org.openspcoop2.generic_project.expression.IExpression;
  35. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  36. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;

  37. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;

  38. import org.openspcoop2.core.plugins.ConfigurazioneFiltro;

  39. /**    
  40.  * JDBCConfigurazioneFiltroServiceImpl
  41.  *
  42.  * @author Poli Andrea (poli@link.it)
  43.  * @author $Author$
  44.  * @version $Rev$, $Date$
  45.  */
  46. public class JDBCConfigurazioneFiltroServiceImpl extends JDBCConfigurazioneFiltroServiceSearchImpl
  47.     implements IJDBCServiceCRUDWithId<ConfigurazioneFiltro, IdConfigurazioneFiltro, JDBCServiceManager> {

  48.     @Override
  49.     public void create(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneFiltro configurazioneFiltro, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException,ServiceException,Exception {

  50.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  51.                 new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  52.        
  53.         ISQLQueryObject sqlQueryObjectInsert = sqlQueryObject.newSQLQueryObject();
  54.                


  55.         // Object configurazioneFiltro
  56.         sqlQueryObjectInsert.addInsertTable(this.getConfigurazioneFiltroFieldConverter().toTable(ConfigurazioneFiltro.model()));
  57.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().NOME,false),"?");
  58.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().DESCRIZIONE,false),"?");
  59.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().TIPO_MITTENTE,false),"?");
  60.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().NOME_MITTENTE,false),"?");
  61.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().IDPORTA_MITTENTE,false),"?");
  62.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().TIPO_DESTINATARIO,false),"?");
  63.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().NOME_DESTINATARIO,false),"?");
  64.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().IDPORTA_DESTINATARIO,false),"?");
  65.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().TIPO_SERVIZIO,false),"?");
  66.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().NOME_SERVIZIO,false),"?");
  67.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().VERSIONE_SERVIZIO,false),"?");
  68.         sqlQueryObjectInsert.addInsertField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().AZIONE,false),"?");

  69.         // Insert configurazioneFiltro
  70.         org.openspcoop2.utils.jdbc.IKeyGeneratorObject keyGenerator = this.getConfigurazioneFiltroFetch().getKeyGeneratorObject(ConfigurazioneFiltro.model());
  71.         long id = jdbcUtilities.insertAndReturnGeneratedKey(sqlQueryObjectInsert, keyGenerator, jdbcProperties.isShowSql(),
  72.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getNome(),ConfigurazioneFiltro.model().NOME.getFieldType()),
  73.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getDescrizione(),ConfigurazioneFiltro.model().DESCRIZIONE.getFieldType()),
  74.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getTipoMittente(),ConfigurazioneFiltro.model().TIPO_MITTENTE.getFieldType()),
  75.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getNomeMittente(),ConfigurazioneFiltro.model().NOME_MITTENTE.getFieldType()),
  76.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getIdportaMittente(),ConfigurazioneFiltro.model().IDPORTA_MITTENTE.getFieldType()),
  77.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getTipoDestinatario(),ConfigurazioneFiltro.model().TIPO_DESTINATARIO.getFieldType()),
  78.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getNomeDestinatario(),ConfigurazioneFiltro.model().NOME_DESTINATARIO.getFieldType()),
  79.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getIdportaDestinatario(),ConfigurazioneFiltro.model().IDPORTA_DESTINATARIO.getFieldType()),
  80.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getTipoServizio(),ConfigurazioneFiltro.model().TIPO_SERVIZIO.getFieldType()),
  81.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getNomeServizio(),ConfigurazioneFiltro.model().NOME_SERVIZIO.getFieldType()),
  82.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getVersioneServizio(),ConfigurazioneFiltro.model().VERSIONE_SERVIZIO.getFieldType()),
  83.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(configurazioneFiltro.getAzione(),ConfigurazioneFiltro.model().AZIONE.getFieldType())
  84.         );
  85.         configurazioneFiltro.setId(id);

  86.        
  87.     }

  88.     @Override
  89.     public void update(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneFiltro oldId, ConfigurazioneFiltro configurazioneFiltro, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  90.         ISQLQueryObject sqlQueryObjectUpdate = sqlQueryObject.newSQLQueryObject();
  91.         Long longIdByLogicId = this.findIdConfigurazioneFiltro(jdbcProperties, log, connection, sqlQueryObjectUpdate.newSQLQueryObject(), oldId, true);
  92.         Long tableId = configurazioneFiltro.getId();
  93.         if(tableId != null && tableId.longValue() > 0) {
  94.             if(tableId.longValue() != longIdByLogicId.longValue()) {
  95.                 throw new Exception("Ambiguous parameter: configurazioneFiltro.id ["+tableId+"] does not match logic id ["+longIdByLogicId+"]");
  96.             }
  97.         } else {
  98.             tableId = longIdByLogicId;
  99.             configurazioneFiltro.setId(tableId);
  100.         }
  101.         if(tableId==null || tableId<=0){
  102.             throw new Exception("Retrieve tableId failed");
  103.         }

  104.         this.update(jdbcProperties, log, connection, sqlQueryObject, tableId, configurazioneFiltro, idMappingResolutionBehaviour);
  105.     }
  106.     @Override
  107.     public void update(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, ConfigurazioneFiltro configurazioneFiltro, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  108.    
  109.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  110.                 new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  111.        
  112.         ISQLQueryObject sqlQueryObjectInsert = sqlQueryObject.newSQLQueryObject();
  113.         ISQLQueryObject sqlQueryObjectDelete = sqlQueryObjectInsert.newSQLQueryObject();
  114.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObjectDelete.newSQLQueryObject();
  115.         ISQLQueryObject sqlQueryObjectUpdate = sqlQueryObjectGet.newSQLQueryObject();
  116.        
  117.         @SuppressWarnings("unused")
  118.         boolean setIdMappingResolutionBehaviour =
  119.             (idMappingResolutionBehaviour==null) ||
  120.             org.openspcoop2.generic_project.beans.IDMappingBehaviour.ENABLED.equals(idMappingResolutionBehaviour) ||
  121.             org.openspcoop2.generic_project.beans.IDMappingBehaviour.USE_TABLE_ID.equals(idMappingResolutionBehaviour);
  122.            


  123.         // Object configurazioneFiltro
  124.         sqlQueryObjectUpdate.setANDLogicOperator(true);
  125.         sqlQueryObjectUpdate.addUpdateTable(this.getConfigurazioneFiltroFieldConverter().toTable(ConfigurazioneFiltro.model()));
  126.         boolean isUpdate_configurazioneFiltro = true;
  127.         java.util.List<JDBCObject> lstObjects_configurazioneFiltro = new java.util.ArrayList<>();
  128.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().NOME,false), "?");
  129.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getNome(), ConfigurazioneFiltro.model().NOME.getFieldType()));
  130.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().DESCRIZIONE,false), "?");
  131.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getDescrizione(), ConfigurazioneFiltro.model().DESCRIZIONE.getFieldType()));
  132.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().TIPO_MITTENTE,false), "?");
  133.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getTipoMittente(), ConfigurazioneFiltro.model().TIPO_MITTENTE.getFieldType()));
  134.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().NOME_MITTENTE,false), "?");
  135.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getNomeMittente(), ConfigurazioneFiltro.model().NOME_MITTENTE.getFieldType()));
  136.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().IDPORTA_MITTENTE,false), "?");
  137.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getIdportaMittente(), ConfigurazioneFiltro.model().IDPORTA_MITTENTE.getFieldType()));
  138.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().TIPO_DESTINATARIO,false), "?");
  139.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getTipoDestinatario(), ConfigurazioneFiltro.model().TIPO_DESTINATARIO.getFieldType()));
  140.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().NOME_DESTINATARIO,false), "?");
  141.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getNomeDestinatario(), ConfigurazioneFiltro.model().NOME_DESTINATARIO.getFieldType()));
  142.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().IDPORTA_DESTINATARIO,false), "?");
  143.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getIdportaDestinatario(), ConfigurazioneFiltro.model().IDPORTA_DESTINATARIO.getFieldType()));
  144.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().TIPO_SERVIZIO,false), "?");
  145.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getTipoServizio(), ConfigurazioneFiltro.model().TIPO_SERVIZIO.getFieldType()));
  146.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().NOME_SERVIZIO,false), "?");
  147.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getNomeServizio(), ConfigurazioneFiltro.model().NOME_SERVIZIO.getFieldType()));
  148.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().VERSIONE_SERVIZIO,false), "?");
  149.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getVersioneServizio(), ConfigurazioneFiltro.model().VERSIONE_SERVIZIO.getFieldType()));
  150.         sqlQueryObjectUpdate.addUpdateField(this.getConfigurazioneFiltroFieldConverter().toColumn(ConfigurazioneFiltro.model().AZIONE,false), "?");
  151.         lstObjects_configurazioneFiltro.add(new JDBCObject(configurazioneFiltro.getAzione(), ConfigurazioneFiltro.model().AZIONE.getFieldType()));
  152.         sqlQueryObjectUpdate.addWhereCondition("id=?");
  153.         lstObjects_configurazioneFiltro.add(new JDBCObject(tableId, Long.class));

  154.         if(isUpdate_configurazioneFiltro) {
  155.             // Update configurazioneFiltro
  156.             jdbcUtilities.executeUpdate(sqlQueryObjectUpdate.createSQLUpdate(), jdbcProperties.isShowSql(),
  157.                 lstObjects_configurazioneFiltro.toArray(new JDBCObject[]{}));
  158.         }


  159.     }
  160.    
  161.     @Override
  162.     public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneFiltro id, UpdateField ... updateFields) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  163.        
  164.         GenericJDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject,
  165.                 this.getConfigurazioneFiltroFieldConverter().toTable(ConfigurazioneFiltro.model()),
  166.                 this.getMapTableToPKColumnEngine(),
  167.                 this.getRootTablePrimaryKeyValuesEngine(jdbcProperties, log, connection, sqlQueryObject, id),
  168.                 this.getConfigurazioneFiltroFieldConverter(), this, null, updateFields);
  169.     }
  170.    
  171.     @Override
  172.     public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneFiltro id, IExpression condition, UpdateField ... updateFields) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  173.        
  174.         GenericJDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject,
  175.                 this.getConfigurazioneFiltroFieldConverter().toTable(ConfigurazioneFiltro.model()),
  176.                 this.getMapTableToPKColumnEngine(),
  177.                 this.getRootTablePrimaryKeyValuesEngine(jdbcProperties, log, connection, sqlQueryObject, id),
  178.                 this.getConfigurazioneFiltroFieldConverter(), this, condition, updateFields);
  179.     }
  180.    
  181.     @Override
  182.     public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneFiltro id, UpdateModel ... updateModels) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  183.        
  184.         GenericJDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject,
  185.                 this.getConfigurazioneFiltroFieldConverter().toTable(ConfigurazioneFiltro.model()),
  186.                 this.getMapTableToPKColumnEngine(),
  187.                 this.getRootTablePrimaryKeyValuesEngine(jdbcProperties, log, connection, sqlQueryObject, id),
  188.                 this.getConfigurazioneFiltroFieldConverter(), this, updateModels);
  189.     }  
  190.    
  191.     @Override
  192.     public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, UpdateField ... updateFields) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  193.         java.util.List<Object> ids = new java.util.ArrayList<>();
  194.         ids.add(tableId);
  195.         GenericJDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject,
  196.                 this.getConfigurazioneFiltroFieldConverter().toTable(ConfigurazioneFiltro.model()),
  197.                 this.getMapTableToPKColumnEngine(),
  198.                 ids,
  199.                 this.getConfigurazioneFiltroFieldConverter(), this, null, updateFields);
  200.     }
  201.    
  202.     @Override
  203.     public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, IExpression condition, UpdateField ... updateFields) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  204.         java.util.List<Object> ids = new java.util.ArrayList<>();
  205.         ids.add(tableId);
  206.         GenericJDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject,
  207.                 this.getConfigurazioneFiltroFieldConverter().toTable(ConfigurazioneFiltro.model()),
  208.                 this.getMapTableToPKColumnEngine(),
  209.                 ids,
  210.                 this.getConfigurazioneFiltroFieldConverter(), this, condition, updateFields);
  211.     }
  212.    
  213.     @Override
  214.     public void updateFields(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, UpdateModel ... updateModels) throws NotFoundException, NotImplementedException, ServiceException, Exception {
  215.         java.util.List<Object> ids = new java.util.ArrayList<>();
  216.         ids.add(tableId);
  217.         GenericJDBCUtilities.updateFields(jdbcProperties, log, connection, sqlQueryObject,
  218.                 this.getConfigurazioneFiltroFieldConverter().toTable(ConfigurazioneFiltro.model()),
  219.                 this.getMapTableToPKColumnEngine(),
  220.                 ids,
  221.                 this.getConfigurazioneFiltroFieldConverter(), this, updateModels);
  222.     }
  223.    
  224.     @Override
  225.     public void updateOrCreate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneFiltro oldId, ConfigurazioneFiltro configurazioneFiltro, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException,ServiceException,Exception {
  226.    
  227.         if(this.exists(jdbcProperties, log, connection, sqlQueryObject, oldId)) {
  228.             this.update(jdbcProperties, log, connection, sqlQueryObject, oldId, configurazioneFiltro,idMappingResolutionBehaviour);
  229.         } else {
  230.             this.create(jdbcProperties, log, connection, sqlQueryObject, configurazioneFiltro,idMappingResolutionBehaviour);
  231.         }
  232.        
  233.     }
  234.    
  235.     @Override
  236.     public void updateOrCreate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, ConfigurazioneFiltro configurazioneFiltro, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException,ServiceException,Exception {
  237.         if(this.exists(jdbcProperties, log, connection, sqlQueryObject, tableId)) {
  238.             this.update(jdbcProperties, log, connection, sqlQueryObject, tableId, configurazioneFiltro,idMappingResolutionBehaviour);
  239.         } else {
  240.             this.create(jdbcProperties, log, connection, sqlQueryObject, configurazioneFiltro,idMappingResolutionBehaviour);
  241.         }
  242.     }
  243.    
  244.     @Override
  245.     public void delete(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneFiltro configurazioneFiltro) throws NotImplementedException,ServiceException,Exception {
  246.        
  247.        
  248.         Long longId = null;
  249.         if( (configurazioneFiltro.getId()!=null) && (configurazioneFiltro.getId()>0) ){
  250.             longId = configurazioneFiltro.getId();
  251.         }
  252.         else{
  253.             IdConfigurazioneFiltro idConfigurazioneFiltro = this.convertToId(jdbcProperties,log,connection,sqlQueryObject,configurazioneFiltro);
  254.             longId = this.findIdConfigurazioneFiltro(jdbcProperties,log,connection,sqlQueryObject,idConfigurazioneFiltro,false);
  255.             if(longId == null){
  256.                 return; // entry not exists
  257.             }
  258.         }      
  259.        
  260.         this.deleteEngine(jdbcProperties, log, connection, sqlQueryObject, longId);
  261.        
  262.     }

  263.     private void deleteEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long id) throws NotImplementedException,ServiceException,Exception {
  264.    
  265.         if(id!=null && id.longValue()<=0){
  266.             throw new ServiceException("Id is less equals 0");
  267.         }
  268.        
  269.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  270.                 new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  271.        
  272.         ISQLQueryObject sqlQueryObjectDelete = sqlQueryObject.newSQLQueryObject();
  273.        

  274.         // Object configurazioneFiltro
  275.         sqlQueryObjectDelete.setANDLogicOperator(true);
  276.         sqlQueryObjectDelete.addDeleteTable(this.getConfigurazioneFiltroFieldConverter().toTable(ConfigurazioneFiltro.model()));
  277.         if(id != null)
  278.             sqlQueryObjectDelete.addWhereCondition("id=?");

  279.         // Delete configurazioneFiltro
  280.         jdbcUtilities.execute(sqlQueryObjectDelete.createSQLDelete(), jdbcProperties.isShowSql(),
  281.             new JDBCObject(id,Long.class));

  282.     }

  283.     @Override
  284.     public void deleteById(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneFiltro idConfigurazioneFiltro) throws NotImplementedException,ServiceException,Exception {

  285.         Long id = null;
  286.         try{
  287.             id = this.findIdConfigurazioneFiltro(jdbcProperties, log, connection, sqlQueryObject, idConfigurazioneFiltro, true);
  288.         }catch(NotFoundException notFound){
  289.             return;
  290.         }
  291.         this.deleteEngine(jdbcProperties, log, connection, sqlQueryObject, id);
  292.        
  293.     }
  294.    
  295.     @Override
  296.     public NonNegativeNumber deleteAll(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject) throws NotImplementedException,ServiceException,Exception {
  297.        
  298.         return this.deleteAll(jdbcProperties, log, connection, sqlQueryObject, new JDBCExpression(this.getConfigurazioneFiltroFieldConverter()));

  299.     }

  300.     @Override
  301.     public NonNegativeNumber deleteAll(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws NotImplementedException, ServiceException,Exception {

  302.         java.util.List<Long> lst = this.findAllTableIds(jdbcProperties, log, connection, sqlQueryObject, new JDBCPaginatedExpression(expression));
  303.        
  304.         for(Long id : lst) {
  305.             this.deleteEngine(jdbcProperties, log, connection, sqlQueryObject, id);
  306.         }
  307.        
  308.         return new NonNegativeNumber(lst.size());
  309.    
  310.     }



  311.     // -- DB
  312.    
  313.     @Override
  314.     public void deleteById(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws ServiceException, NotImplementedException, Exception {
  315.         this.deleteEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  316.     }
  317.    
  318.     @Override
  319.     public int nativeUpdate(JDBCServiceManagerProperties jdbcProperties, Logger log,Connection connection,ISQLQueryObject sqlObject, String sql,Object ... param) throws ServiceException,NotImplementedException, Exception {
  320.    
  321.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.nativeUpdate(jdbcProperties, log, connection, sqlObject,
  322.                                                                                             sql,param);
  323.    
  324.     }
  325. }