JDBCConfigurazioneTransazioneServiceSearchImpl.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.config.transazioni.dao.jdbc;

  21. import java.util.List;
  22. import java.util.ArrayList;
  23. import java.util.HashMap;
  24. import java.util.Map;

  25. import java.sql.Connection;

  26. import org.slf4j.Logger;

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

  28. import org.openspcoop2.core.plugins.IdConfigurazioneServizioAzione;
  29. import org.openspcoop2.core.plugins.Plugin;
  30. import org.openspcoop2.core.plugins.dao.jdbc.JDBCConfigurazioneServizioAzioneBaseLib;
  31. import org.openspcoop2.core.plugins.dao.jdbc.JDBCPluginsBaseLib;

  32. import org.openspcoop2.generic_project.expression.impl.sql.ISQLFieldConverter;
  33. import org.openspcoop2.generic_project.dao.jdbc.utils.IJDBCFetch;
  34. import org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject;
  35. import org.openspcoop2.generic_project.dao.jdbc.IJDBCServiceSearchWithId;
  36. import org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneTransazione;
  37. import org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneTransazioneStato;
  38. import org.openspcoop2.generic_project.utils.UtilsTemplate;
  39. import org.openspcoop2.generic_project.beans.CustomField;
  40. import org.openspcoop2.generic_project.beans.InUse;
  41. import org.openspcoop2.generic_project.beans.IField;
  42. import org.openspcoop2.generic_project.beans.NonNegativeNumber;
  43. import org.openspcoop2.generic_project.beans.UnionExpression;
  44. import org.openspcoop2.generic_project.beans.Union;
  45. import org.openspcoop2.generic_project.beans.FunctionField;
  46. import org.openspcoop2.generic_project.exception.MultipleResultException;
  47. import org.openspcoop2.generic_project.exception.NotFoundException;
  48. import org.openspcoop2.generic_project.exception.NotImplementedException;
  49. import org.openspcoop2.generic_project.exception.ServiceException;
  50. import org.openspcoop2.generic_project.expression.IExpression;
  51. import org.openspcoop2.generic_project.dao.jdbc.JDBCExpression;
  52. import org.openspcoop2.generic_project.dao.jdbc.JDBCPaginatedExpression;

  53. import org.openspcoop2.generic_project.dao.jdbc.JDBCServiceManagerProperties;
  54. import org.openspcoop2.monitor.engine.config.transazioni.dao.jdbc.converter.ConfigurazioneTransazioneFieldConverter;
  55. import org.openspcoop2.monitor.engine.config.transazioni.dao.jdbc.fetch.ConfigurazioneTransazioneFetch;
  56. import org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazione;
  57. import org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazionePlugin;
  58. import org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneStato;
  59. import org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneRisorsaContenuto;

  60. /**    
  61.  * JDBCConfigurazioneTransazioneServiceSearchImpl
  62.  *
  63.  * @author Poli Andrea (poli@link.it)
  64.  * @author $Author$
  65.  * @version $Rev$, $Date$
  66.  */
  67. public class JDBCConfigurazioneTransazioneServiceSearchImpl implements IJDBCServiceSearchWithId<ConfigurazioneTransazione, IdConfigurazioneTransazione, JDBCServiceManager> {

  68.     private ConfigurazioneTransazioneFieldConverter _configurazioneTransazioneFieldConverter = null;
  69.     public ConfigurazioneTransazioneFieldConverter getConfigurazioneTransazioneFieldConverter() {
  70.         if(this._configurazioneTransazioneFieldConverter==null){
  71.             this._configurazioneTransazioneFieldConverter = new ConfigurazioneTransazioneFieldConverter(this.jdbcServiceManager.getJdbcProperties().getDatabaseType());
  72.         }      
  73.         return this._configurazioneTransazioneFieldConverter;
  74.     }
  75.     @Override
  76.     public ISQLFieldConverter getFieldConverter() {
  77.         return this.getConfigurazioneTransazioneFieldConverter();
  78.     }
  79.    
  80.     private ConfigurazioneTransazioneFetch configurazioneTransazioneFetch = new ConfigurazioneTransazioneFetch();
  81.     public ConfigurazioneTransazioneFetch getConfigurazioneTransazioneFetch() {
  82.         return this.configurazioneTransazioneFetch;
  83.     }
  84.     @Override
  85.     public IJDBCFetch getFetch() {
  86.         return getConfigurazioneTransazioneFetch();
  87.     }
  88.    
  89.    
  90.     private JDBCServiceManager jdbcServiceManager = null;

  91.     @Override
  92.     public void setServiceManager(JDBCServiceManager serviceManager) throws ServiceException{
  93.         this.jdbcServiceManager = serviceManager;
  94.     }
  95.    
  96.     @Override
  97.     public JDBCServiceManager getServiceManager() throws ServiceException{
  98.         return this.jdbcServiceManager;
  99.     }
  100.    

  101.     @Override
  102.     public IdConfigurazioneTransazione convertToId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneTransazione configurazioneTransazione) throws NotImplementedException, ServiceException, Exception{
  103.    
  104.         IdConfigurazioneTransazione idTransazione = new IdConfigurazioneTransazione();
  105.         idTransazione.setIdConfigurazioneServizioAzione(configurazioneTransazione.getIdConfigurazioneServizioAzione());
  106.         return idTransazione;
  107.     }
  108.    
  109.     @Override
  110.     public ConfigurazioneTransazione get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneTransazione id, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {
  111.         Long id_configurazioneTransazione = ( (id!=null && id.getId()!=null && id.getId()>0) ? id.getId() : this.findIdConfigurazioneTransazione(jdbcProperties, log, connection, sqlQueryObject, id, true));
  112.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, id_configurazioneTransazione,idMappingResolutionBehaviour);
  113.        
  114.        
  115.     }
  116.    
  117.     @Override
  118.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneTransazione id) throws MultipleResultException, NotImplementedException, ServiceException,Exception {

  119.         Long id_configurazioneTransazione = this.findIdConfigurazioneTransazione(jdbcProperties, log, connection, sqlQueryObject, id, false);
  120.         return id_configurazioneTransazione != null && id_configurazioneTransazione > 0;
  121.        
  122.     }
  123.    
  124.     @Override
  125.     public List<IdConfigurazioneTransazione> findAllIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException, ServiceException,Exception {

  126.         List<IdConfigurazioneTransazione> list = new ArrayList<IdConfigurazioneTransazione>();

  127.         // TODO: implementazione non efficiente.
  128.         // Per ottenere una implementazione efficiente:
  129.         // 1. Usare metodo select di questa classe indirizzando esattamente i field necessari a create l'ID logico
  130.         // 2. Usare metodo getConfigurazioneTransazioneFetch() sul risultato della select per ottenere un oggetto ConfigurazioneTransazione
  131.         //    La fetch con la map inserirĂ  nell'oggetto solo i valori estratti
  132.         // 3. Usare metodo convertToId per ottenere l'id

  133.         List<Long> ids = this.findAllTableIds(jdbcProperties, log, connection, sqlQueryObject, expression);
  134.        
  135.         for(Long id: ids) {
  136.             ConfigurazioneTransazione configurazioneTransazione = this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour);
  137.             IdConfigurazioneTransazione idConfigurazioneTransazione = this.convertToId(jdbcProperties,log,connection,sqlQueryObject,configurazioneTransazione);
  138.             list.add(idConfigurazioneTransazione);
  139.         }

  140.         return list;
  141.        
  142.     }
  143.    
  144.     @Override
  145.     public List<ConfigurazioneTransazione> findAll(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotImplementedException, ServiceException,Exception {

  146.         List<ConfigurazioneTransazione> list = new ArrayList<ConfigurazioneTransazione>();
  147.        
  148.         // TODO: implementazione non efficiente.
  149.         // Per ottenere una implementazione efficiente:
  150.         // 1. Usare metodo select di questa classe indirizzando esattamente i field necessari
  151.         // 2. Usare metodo getConfigurazioneTransazioneFetch() sul risultato della select per ottenere un oggetto ConfigurazioneTransazione
  152.         //    La fetch con la map inserirĂ  nell'oggetto solo i valori estratti

  153.         List<Long> ids = this.findAllTableIds(jdbcProperties, log, connection, sqlQueryObject, expression);
  154.        
  155.         for(Long id: ids) {
  156.             list.add(this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour));
  157.         }

  158.         return list;      
  159.        
  160.     }
  161.    
  162.     @Override
  163.     public ConfigurazioneTransazione find(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour)
  164.         throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException,Exception {

  165.         long id = this.findTableId(jdbcProperties, log, connection, sqlQueryObject, expression);
  166.         if(id>0){
  167.             return this.get(jdbcProperties, log, connection, sqlQueryObject, id, idMappingResolutionBehaviour);
  168.         }else{
  169.             throw new NotFoundException("Entry with id["+id+"] not found");
  170.         }
  171.        
  172.     }
  173.    
  174.     @Override
  175.     public NonNegativeNumber count(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws NotImplementedException, ServiceException,Exception {
  176.        
  177.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareCount(jdbcProperties, log, connection, sqlQueryObject, expression,
  178.                                                 this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model());
  179.        
  180.         sqlQueryObject.addSelectCountField(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model())+".id","tot",true);
  181.        
  182.         joinEngine(expression,sqlQueryObject);
  183.        
  184.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.count(jdbcProperties, log, connection, sqlQueryObject, expression,
  185.                                                                             this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model(),listaQuery);
  186.     }

  187.     @Override
  188.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneTransazione id) throws NotFoundException, NotImplementedException, ServiceException,Exception {
  189.        
  190.         Long id_configurazioneTransazione = this.findIdConfigurazioneTransazione(jdbcProperties, log, connection, sqlQueryObject, id, true);
  191.         return this.inUseEngine(jdbcProperties, log, connection, sqlQueryObject, id_configurazioneTransazione);
  192.        
  193.     }

  194.     @Override
  195.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  196.                                                     JDBCPaginatedExpression paginatedExpression, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  197.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  198.                                 paginatedExpression, false, field);
  199.     }
  200.    
  201.     @Override
  202.     public List<Object> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  203.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  204.         List<Map<String,Object>> map =
  205.             this.select(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, distinct, new IField[]{field});
  206.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.selectSingleObject(map);
  207.     }
  208.    
  209.     @Override
  210.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  211.                                                     JDBCPaginatedExpression paginatedExpression, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  212.         return this.select(jdbcProperties, log, connection, sqlQueryObject,
  213.                                 paginatedExpression, false, field);
  214.     }
  215.    
  216.     @Override
  217.     public List<Map<String,Object>> select(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  218.                                                     JDBCPaginatedExpression paginatedExpression, boolean distinct, IField ... field) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  219.        
  220.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,paginatedExpression,field);
  221.         try{
  222.        
  223.             ISQLQueryObject sqlQueryObjectDistinct =
  224.                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(distinct,sqlQueryObject, paginatedExpression, log,
  225.                                                 this.getConfigurazioneTransazioneFieldConverter(), field);

  226.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression, sqlQueryObjectDistinct);
  227.            
  228.         }finally{
  229.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,field);
  230.         }
  231.     }

  232.     @Override
  233.     public Object aggregate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  234.                                                     JDBCExpression expression, FunctionField functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  235.         Map<String,Object> map =
  236.             this.aggregate(jdbcProperties, log, connection, sqlQueryObject, expression, new FunctionField[]{functionField});
  237.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.selectAggregateObject(map,functionField);
  238.     }
  239.    
  240.     @Override
  241.     public Map<String,Object> aggregate(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  242.                                                     JDBCExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {                                                  
  243.        
  244.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,expression,functionField);
  245.         try{
  246.             List<Map<String,Object>> list = selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression);
  247.             return list.get(0);
  248.         }finally{
  249.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,expression,functionField);
  250.         }
  251.     }

  252.     @Override
  253.     public List<Map<String,Object>> groupBy(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  254.                                                     JDBCExpression expression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  255.        
  256.         if(expression.getGroupByFields().isEmpty()){
  257.             throw new ServiceException("GroupBy conditions not found in expression");
  258.         }
  259.        
  260.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,expression,functionField);
  261.         try{
  262.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression);
  263.         }finally{
  264.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,expression,functionField);
  265.         }
  266.     }
  267.    

  268.     @Override
  269.     public List<Map<String,Object>> groupBy(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  270.                                                     JDBCPaginatedExpression paginatedExpression, FunctionField ... functionField) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  271.        
  272.         if(paginatedExpression.getGroupByFields().isEmpty()){
  273.             throw new ServiceException("GroupBy conditions not found in expression");
  274.         }
  275.        
  276.         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.setFields(sqlQueryObject,paginatedExpression,functionField);
  277.         try{
  278.             return selectEngine(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression);
  279.         }finally{
  280.             org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.removeFields(sqlQueryObject,paginatedExpression,functionField);
  281.         }
  282.     }
  283.    
  284.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  285.                                                 IExpression expression) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  286.         return selectEngine(jdbcProperties, log, connection, sqlQueryObject, expression, null);
  287.     }
  288.     protected List<Map<String,Object>> selectEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  289.                                                 IExpression expression, ISQLQueryObject sqlQueryObjectDistinct) throws ServiceException,NotFoundException,NotImplementedException,Exception {
  290.        
  291.         List<Object> listaQuery = new ArrayList<>();
  292.         List<JDBCObject> listaParams = new ArrayList<>();
  293.         List<Object> returnField = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSelect(jdbcProperties, log, connection, sqlQueryObject,
  294.                                 expression, this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model(),
  295.                                 listaQuery,listaParams);
  296.        
  297.         joinEngine(expression,sqlQueryObject);
  298.        
  299.         List<Map<String,Object>> list = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.select(jdbcProperties, log, connection,
  300.                                         org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareSqlQueryObjectForSelectDistinct(sqlQueryObject,sqlQueryObjectDistinct),
  301.                                         expression, this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model(),
  302.                                         listaQuery,listaParams,returnField);
  303.         if(list!=null && !list.isEmpty()){
  304.             return list;
  305.         }
  306.         else{
  307.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  308.         }
  309.     }
  310.    
  311.     @Override
  312.     public List<Map<String,Object>> union(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  313.                                                 Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException,Exception {    
  314.        
  315.         List<ISQLQueryObject> sqlQueryObjectInnerList = new ArrayList<>();
  316.         List<JDBCObject> jdbcObjects = new ArrayList<>();
  317.         List<Class<?>> returnClassTypes = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareUnion(jdbcProperties, log, connection, sqlQueryObject,
  318.                                 this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model(),
  319.                                 sqlQueryObjectInnerList, jdbcObjects, union, unionExpression);
  320.        
  321.         if(unionExpression!=null){
  322.             for (int i = 0; i < unionExpression.length; i++) {
  323.                 UnionExpression ue = unionExpression[i];
  324.                 IExpression expression = ue.getExpression();
  325.                 joinEngine(expression,sqlQueryObjectInnerList.get(i));
  326.             }
  327.         }
  328.        
  329.         List<Map<String,Object>> list = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.union(jdbcProperties, log, connection, sqlQueryObject,
  330.                                         this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model(),
  331.                                         sqlQueryObjectInnerList, jdbcObjects, returnClassTypes, union, unionExpression);
  332.         if(list!=null && !list.isEmpty()){
  333.             return list;
  334.         }
  335.         else{
  336.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  337.         }                              
  338.     }
  339.    
  340.     @Override
  341.     public NonNegativeNumber unionCount(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  342.                                                 Union union, UnionExpression ... unionExpression) throws ServiceException,NotFoundException,NotImplementedException,Exception {    
  343.        
  344.         List<ISQLQueryObject> sqlQueryObjectInnerList = new ArrayList<>();
  345.         List<JDBCObject> jdbcObjects = new ArrayList<>();
  346.         List<Class<?>> returnClassTypes = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareUnionCount(jdbcProperties, log, connection, sqlQueryObject,
  347.                                 this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model(),
  348.                                 sqlQueryObjectInnerList, jdbcObjects, union, unionExpression);
  349.        
  350.         if(unionExpression!=null){
  351.             for (int i = 0; i < unionExpression.length; i++) {
  352.                 UnionExpression ue = unionExpression[i];
  353.                 IExpression expression = ue.getExpression();
  354.                 joinEngine(expression,sqlQueryObjectInnerList.get(i));
  355.             }
  356.         }
  357.        
  358.         NonNegativeNumber number = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.unionCount(jdbcProperties, log, connection, sqlQueryObject,
  359.                                         this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model(),
  360.                                         sqlQueryObjectInnerList, jdbcObjects, returnClassTypes, union, unionExpression);
  361.         if(number!=null && number.longValue()>=0){
  362.             return number;
  363.         }
  364.         else{
  365.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  366.         }
  367.     }



  368.     // -- ConstructorExpression

  369.     @Override
  370.     public JDBCExpression newExpression(Logger log) throws NotImplementedException, ServiceException {
  371.         try{
  372.             return new JDBCExpression(this.getConfigurazioneTransazioneFieldConverter());
  373.         }catch(Exception e){
  374.             throw new ServiceException(e);
  375.         }
  376.     }


  377.     @Override
  378.     public JDBCPaginatedExpression newPaginatedExpression(Logger log) throws NotImplementedException, ServiceException {
  379.         try{
  380.             return new JDBCPaginatedExpression(this.getConfigurazioneTransazioneFieldConverter());
  381.         }catch(Exception e){
  382.             throw new ServiceException(e);
  383.         }
  384.     }
  385.    
  386.     @Override
  387.     public JDBCExpression toExpression(JDBCPaginatedExpression paginatedExpression, Logger log) throws NotImplementedException, ServiceException {
  388.         try{
  389.             return new JDBCExpression(paginatedExpression);
  390.         }catch(Exception e){
  391.             throw new ServiceException(e);
  392.         }
  393.     }

  394.     @Override
  395.     public JDBCPaginatedExpression toPaginatedExpression(JDBCExpression expression, Logger log) throws NotImplementedException, ServiceException {
  396.         try{
  397.             return new JDBCPaginatedExpression(expression);
  398.         }catch(Exception e){
  399.             throw new ServiceException(e);
  400.         }
  401.     }
  402.    
  403.    
  404.    
  405.     // -- DB

  406.     @Override
  407.     public void mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneTransazione id, ConfigurazioneTransazione obj) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  408.         _mappingTableIds(jdbcProperties,log,connection,sqlQueryObject,obj,
  409.                 this.get(jdbcProperties,log,connection,sqlQueryObject,id,null));
  410.     }
  411.    
  412.     @Override
  413.     public void mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, ConfigurazioneTransazione obj) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  414.         _mappingTableIds(jdbcProperties,log,connection,sqlQueryObject,obj,
  415.                 this.get(jdbcProperties,log,connection,sqlQueryObject,tableId,null));
  416.     }
  417.     private void _mappingTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, ConfigurazioneTransazione obj, ConfigurazioneTransazione imgSaved) throws NotFoundException,NotImplementedException,ServiceException,Exception{
  418.         if(imgSaved==null){
  419.             return;
  420.         }
  421.         obj.setId(imgSaved.getId());
  422.         if(obj.getIdConfigurazioneServizioAzione()!=null &&
  423.                 imgSaved.getIdConfigurazioneServizioAzione()!=null){
  424.             obj.getIdConfigurazioneServizioAzione().setId(imgSaved.getIdConfigurazioneServizioAzione().getId());
  425.             if(obj.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio()!=null &&
  426.                     imgSaved.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio()!=null){
  427.                 obj.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio().setId(imgSaved.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio().getId());
  428.             }
  429.         }
  430.         if(obj.getConfigurazioneTransazionePluginList()!=null){
  431.             List<org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazionePlugin> listObj_ = obj.getConfigurazioneTransazionePluginList();
  432.             for(org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazionePlugin itemObj_ : listObj_){
  433.                 org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazionePlugin itemAlreadySaved_ = null;
  434.                 if(imgSaved.getConfigurazioneTransazionePluginList()!=null){
  435.                     List<org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazionePlugin> listImgSaved_ = imgSaved.getConfigurazioneTransazionePluginList();
  436.                     for(org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazionePlugin itemImgSaved_ : listImgSaved_){
  437.                         boolean objEqualsToImgSaved_ = false;
  438.                         objEqualsToImgSaved_ = org.openspcoop2.generic_project.utils.Utilities.equals(itemObj_.getIdConfigurazioneTransazionePlugin(),itemImgSaved_.getIdConfigurazioneTransazionePlugin());
  439.                         if(objEqualsToImgSaved_){
  440.                             itemAlreadySaved_=itemImgSaved_;
  441.                             break;
  442.                         }
  443.                     }
  444.                 }
  445.                 if(itemAlreadySaved_!=null){
  446.                     itemObj_.setId(itemAlreadySaved_.getId());
  447.                     if(itemObj_.getPlugin()!=null &&
  448.                             itemAlreadySaved_.getPlugin()!=null){
  449.                         itemObj_.getPlugin().setId(itemAlreadySaved_.getPlugin().getId());
  450.                     }
  451.                 }
  452.             }
  453.         }
  454.         if(obj.getConfigurazioneTransazioneStatoList()!=null){
  455.             List<org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneStato> listObj_ = obj.getConfigurazioneTransazioneStatoList();
  456.             for(org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneStato itemObj_ : listObj_){
  457.                 org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneStato itemAlreadySaved_ = null;
  458.                 if(imgSaved.getConfigurazioneTransazioneStatoList()!=null){
  459.                     List<org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneStato> listImgSaved_ = imgSaved.getConfigurazioneTransazioneStatoList();
  460.                     for(org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneStato itemImgSaved_ : listImgSaved_){
  461.                         boolean objEqualsToImgSaved_ = false;
  462.                         objEqualsToImgSaved_ = org.openspcoop2.generic_project.utils.Utilities.equals(itemObj_.getNome(),itemImgSaved_.getNome()) &&
  463.                                 org.openspcoop2.generic_project.utils.Utilities.equals(itemObj_.getTipoMessaggio(),itemImgSaved_.getTipoMessaggio());
  464.                         if(objEqualsToImgSaved_){
  465.                             itemAlreadySaved_=itemImgSaved_;
  466.                             break;
  467.                         }
  468.                     }
  469.                 }
  470.                 if(itemAlreadySaved_!=null){
  471.                     itemObj_.setId(itemAlreadySaved_.getId());
  472.                 }
  473.             }
  474.         }
  475.         if(obj.getConfigurazioneTransazioneRisorsaContenutoList()!=null){
  476.             List<org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneRisorsaContenuto> listObj_ = obj.getConfigurazioneTransazioneRisorsaContenutoList();
  477.             for(org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneRisorsaContenuto itemObj_ : listObj_){
  478.                 org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneRisorsaContenuto itemAlreadySaved_ = null;
  479.                 if(imgSaved.getConfigurazioneTransazioneRisorsaContenutoList()!=null){
  480.                     List<org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneRisorsaContenuto> listImgSaved_ = imgSaved.getConfigurazioneTransazioneRisorsaContenutoList();
  481.                     for(org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazioneRisorsaContenuto itemImgSaved_ : listImgSaved_){
  482.                         boolean objEqualsToImgSaved_ = false;
  483.                         objEqualsToImgSaved_ = org.openspcoop2.generic_project.utils.Utilities.equals(itemObj_.getNome(),itemImgSaved_.getNome()) &&
  484.                                     org.openspcoop2.generic_project.utils.Utilities.equals(itemObj_.getTipoMessaggio(),itemImgSaved_.getTipoMessaggio());
  485.                         if(objEqualsToImgSaved_){
  486.                             itemAlreadySaved_=itemImgSaved_;
  487.                             break;
  488.                         }
  489.                     }
  490.                 }
  491.                 if(itemAlreadySaved_!=null){
  492.                     itemObj_.setId(itemAlreadySaved_.getId());
  493.                     if(itemObj_.getIdConfigurazioneTransazioneStato()!=null &&
  494.                             itemAlreadySaved_.getIdConfigurazioneTransazioneStato()!=null){
  495.                         itemObj_.getIdConfigurazioneTransazioneStato().setId(itemAlreadySaved_.getIdConfigurazioneTransazioneStato().getId());
  496.                     }
  497.                 }
  498.             }
  499.         }          
  500.     }
  501.    
  502.     @Override
  503.     public ConfigurazioneTransazione get(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  504.         return this.getEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId), idMappingResolutionBehaviour);
  505.     }
  506.    
  507.     private ConfigurazioneTransazione getEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId, org.openspcoop2.generic_project.beans.IDMappingBehaviour idMappingResolutionBehaviour) throws NotFoundException, MultipleResultException, NotImplementedException, ServiceException, Exception {
  508.    
  509.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  510.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  511.        
  512.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();
  513.                
  514.         ConfigurazioneTransazione configurazioneTransazione = new ConfigurazioneTransazione();
  515.        

  516.         // Object configurazioneTransazione
  517.         ISQLQueryObject sqlQueryObjectGet_configurazioneTransazione = sqlQueryObjectGet.newSQLQueryObject();
  518.         sqlQueryObjectGet_configurazioneTransazione.setANDLogicOperator(true);
  519.         sqlQueryObjectGet_configurazioneTransazione.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model()));
  520.         sqlQueryObjectGet_configurazioneTransazione.addSelectField("id");
  521.         sqlQueryObjectGet_configurazioneTransazione.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().ENABLED,true));
  522.         sqlQueryObjectGet_configurazioneTransazione.addWhereCondition("id=?");

  523.         // Get configurazioneTransazione
  524.         configurazioneTransazione = (ConfigurazioneTransazione) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_configurazioneTransazione.createSQLQuery(), jdbcProperties.isShowSql(), ConfigurazioneTransazione.model(), this.getConfigurazioneTransazioneFetch(),
  525.             new JDBCObject(tableId,Long.class));


  526.         if(idMappingResolutionBehaviour==null ||
  527.             (org.openspcoop2.generic_project.beans.IDMappingBehaviour.ENABLED.equals(idMappingResolutionBehaviour) || org.openspcoop2.generic_project.beans.IDMappingBehaviour.USE_TABLE_ID.equals(idMappingResolutionBehaviour))
  528.         ){
  529.             // Recupero idConfigurazioneServizioAzione
  530.                
  531.             ISQLQueryObject sqlQueryObjectGet_configurazioneTransazione_idConfigurazioneServizioAzione = sqlQueryObjectGet.newSQLQueryObject();
  532.             sqlQueryObjectGet_configurazioneTransazione_idConfigurazioneServizioAzione.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model()));
  533.             sqlQueryObjectGet_configurazioneTransazione_idConfigurazioneServizioAzione.addSelectField("id_conf_servizio_azione");
  534.             sqlQueryObjectGet_configurazioneTransazione_idConfigurazioneServizioAzione.addWhereCondition("id=?");
  535.             sqlQueryObjectGet_configurazioneTransazione_idConfigurazioneServizioAzione.setANDLogicOperator(true);
  536.             Long id_configurazioneTransazione_idConfigurazioneServizioAzione = (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_configurazioneTransazione_idConfigurazioneServizioAzione.createSQLQuery(), jdbcProperties.isShowSql(),Long.class,
  537.                     new JDBCObject(configurazioneTransazione.getId(),Long.class));
  538.        
  539.             IdConfigurazioneServizioAzione _tmpIdConfigurazioneServizioAzione =
  540.                     JDBCConfigurazioneServizioAzioneBaseLib.getIdConfigurazioneServizioAzione(connection, jdbcProperties, log, id_configurazioneTransazione_idConfigurazioneServizioAzione);
  541.             org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneServizioAzione idConfigurazioneServizioAzione = new org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneServizioAzione();
  542.             idConfigurazioneServizioAzione.setAzione(_tmpIdConfigurazioneServizioAzione.getAzione());
  543.             org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneServizio idConfigurazioneServizio = new org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneServizio();
  544.             idConfigurazioneServizio.setAccordo(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getAccordo());
  545.             idConfigurazioneServizio.setTipoSoggettoReferente(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getTipoSoggettoReferente());
  546.             idConfigurazioneServizio.setNomeSoggettoReferente(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getNomeSoggettoReferente());
  547.             idConfigurazioneServizio.setVersione(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getVersione());
  548.             idConfigurazioneServizio.setServizio(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getServizio());
  549.             idConfigurazioneServizioAzione.setIdConfigurazioneServizio(idConfigurazioneServizio);
  550.             configurazioneTransazione.setIdConfigurazioneServizioAzione(idConfigurazioneServizioAzione);
  551.         }


  552.         // Object configurazioneTransazione_configurazioneTransazionePlugin
  553.         ISQLQueryObject sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin = sqlQueryObjectGet.newSQLQueryObject();
  554.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.setANDLogicOperator(true);
  555.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN));
  556.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.PLUGIN));
  557.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN)+".id");
  558.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.ID_CONFIGURAZIONE_TRANSAZIONE_PLUGIN,true));
  559.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.ENABLED,true));
  560.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.addWhereCondition("id_configurazione_transazione=?");
  561.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.addWhereCondition(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN)+".id_plugin="+
  562.                 this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.PLUGIN)+".id");
  563.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.addOrderBy(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN.PLUGIN.LABEL,true));
  564.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.setSortType(true);
  565.        
  566.        
  567.        
  568.         // Get configurazioneTransazione_configurazioneTransazionePlugin
  569.         java.util.List<Object> configurazioneTransazione_configurazioneTransazionePlugin_list = jdbcUtilities.executeQuery(sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin.createSQLQuery(), jdbcProperties.isShowSql(), ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN, this.getConfigurazioneTransazioneFetch(),
  570.             new JDBCObject(configurazioneTransazione.getId(),Long.class));

  571.         if(configurazioneTransazione_configurazioneTransazionePlugin_list != null) {
  572.             for (Object configurazioneTransazione_configurazioneTransazionePlugin_object: configurazioneTransazione_configurazioneTransazionePlugin_list) {
  573.                 ConfigurazioneTransazionePlugin configurazioneTransazione_configurazioneTransazionePlugin = (ConfigurazioneTransazionePlugin) configurazioneTransazione_configurazioneTransazionePlugin_object;


  574.                 if(idMappingResolutionBehaviour==null ||
  575.                     (org.openspcoop2.generic_project.beans.IDMappingBehaviour.ENABLED.equals(idMappingResolutionBehaviour) || org.openspcoop2.generic_project.beans.IDMappingBehaviour.USE_TABLE_ID.equals(idMappingResolutionBehaviour))
  576.                 ){
  577.                     // Object _configurazioneTransazione_configurazioneTransazionePlugin_plugin (recupero id)
  578.                     ISQLQueryObject sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin_plugin_readFkId = sqlQueryObjectGet.newSQLQueryObject();
  579.                     sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin_plugin_readFkId.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(org.openspcoop2.monitor.engine.config.transazioni.ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_PLUGIN));
  580.                     sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin_plugin_readFkId.addSelectField("id_plugin");
  581.                     sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin_plugin_readFkId.addWhereCondition("id=?");
  582.                     sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin_plugin_readFkId.setANDLogicOperator(true);
  583.                     Long idFK_configurazioneTransazione_configurazioneTransazionePlugin_plugin = (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazionePlugin_plugin_readFkId.createSQLQuery(), jdbcProperties.isShowSql(),Long.class,
  584.                             new JDBCObject(configurazioneTransazione_configurazioneTransazionePlugin.getId(),Long.class));
  585.                
  586.                     Plugin plugin = JDBCPluginsBaseLib.getPlugin(connection, jdbcProperties, log, idFK_configurazioneTransazione_configurazioneTransazionePlugin_plugin);
  587.                     org.openspcoop2.monitor.engine.config.transazioni.InfoPlugin info = new org.openspcoop2.monitor.engine.config.transazioni.InfoPlugin();
  588.                     info.setTipoPlugin(plugin.getTipoPlugin());
  589.                     info.setTipo(plugin.getTipo());
  590.                     info.setClassName(plugin.getClassName());
  591.                     info.setDescrizione(plugin.getDescrizione());
  592.                     info.setLabel(plugin.getLabel());
  593.                     configurazioneTransazione_configurazioneTransazionePlugin.setPlugin(info);
  594.                
  595.                     configurazioneTransazione.addConfigurazioneTransazionePlugin(configurazioneTransazione_configurazioneTransazionePlugin);
  596.                 }

  597.                 configurazioneTransazione.addConfigurazioneTransazionePlugin(configurazioneTransazione_configurazioneTransazionePlugin);
  598.             }
  599.         }

  600.         // Object configurazioneTransazione_configurazioneTransazioneStato
  601.         ISQLQueryObject sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato = sqlQueryObjectGet.newSQLQueryObject();
  602.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.setANDLogicOperator(true);
  603.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO));
  604.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addSelectField("id");
  605.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.ENABLED,true));
  606.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.NOME,true));
  607.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.TIPO_CONTROLLO,true));
  608.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.TIPO_MESSAGGIO,true));
  609.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.VALORE,true));
  610.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.XPATH,true));
  611.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addWhereCondition("id_configurazione_transazione=?");
  612.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.addOrderBy(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO.NOME,true));
  613.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.setSortType(true);
  614.        
  615.        
  616.        
  617.         // Get configurazioneTransazione_configurazioneTransazioneStato
  618.         java.util.List<Object> configurazioneTransazione_configurazioneTransazioneStato_list = jdbcUtilities.executeQuery(sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneStato.createSQLQuery(), jdbcProperties.isShowSql(), ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO, this.getConfigurazioneTransazioneFetch(),
  619.             new JDBCObject(configurazioneTransazione.getId(),Long.class));

  620.         HashMap<Long, String> mapIdTransazioneStatoToName = new HashMap<Long, String>();
  621.        
  622.         if(configurazioneTransazione_configurazioneTransazioneStato_list != null) {
  623.             for (Object configurazioneTransazione_configurazioneTransazioneStato_object: configurazioneTransazione_configurazioneTransazioneStato_list) {
  624.                 ConfigurazioneTransazioneStato configurazioneTransazione_configurazioneTransazioneStato = (ConfigurazioneTransazioneStato) configurazioneTransazione_configurazioneTransazioneStato_object;
  625.                 configurazioneTransazione.addConfigurazioneTransazioneStato(configurazioneTransazione_configurazioneTransazioneStato);
  626.                 mapIdTransazioneStatoToName.put(configurazioneTransazione_configurazioneTransazioneStato.getId(), configurazioneTransazione_configurazioneTransazioneStato.getNome());
  627.             }
  628.         }

  629.         // Object configurazioneTransazione_configurazioneTransazioneRisorsaContenuto
  630.         ISQLQueryObject sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto = sqlQueryObjectGet.newSQLQueryObject();
  631.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.setANDLogicOperator(true);
  632.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO));
  633.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField("id");
  634.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ABILITA_ANONIMIZZAZIONE,true));
  635.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ABILITA_COMPRESSIONE,true));
  636.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.TIPO_COMPRESSIONE,true));
  637.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.CARATTERE_MASCHERA,true));
  638.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.NUMERO_CARATTERI_MASCHERA,true));
  639.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.POSIZIONAMENTO_MASCHERA,true));
  640.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.TIPO_MASCHERAMENTO,true));
  641.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ENABLED,true));
  642.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.NOME,true));
  643.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.TIPO_MESSAGGIO,true));
  644.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.XPATH,true));
  645.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.STAT_ENABLED,true));
  646.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addWhereCondition("id_conf_transazione=?");
  647.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.addOrderBy(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.NOME,true));
  648.         sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.setSortType(true);
  649.                
  650.        
  651.         // Get configurazioneTransazione_configurazioneTransazioneRisorsaContenuto
  652.         java.util.List<Object> configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_list = jdbcUtilities.executeQuery(sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.createSQLQuery(), jdbcProperties.isShowSql(), ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO, this.getConfigurazioneTransazioneFetch(),
  653.             new JDBCObject(configurazioneTransazione.getId(),Long.class));

  654.         if(configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_list != null) {
  655.             for (Object configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_object: configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_list) {
  656.                 ConfigurazioneTransazioneRisorsaContenuto configurazioneTransazione_configurazioneTransazioneRisorsaContenuto = (ConfigurazioneTransazioneRisorsaContenuto) configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_object;


  657.                 if(idMappingResolutionBehaviour==null ||
  658.                     (org.openspcoop2.generic_project.beans.IDMappingBehaviour.ENABLED.equals(idMappingResolutionBehaviour) || org.openspcoop2.generic_project.beans.IDMappingBehaviour.USE_TABLE_ID.equals(idMappingResolutionBehaviour))
  659.                 ){
  660.                     // Recupero idConfigurazioneTransazioneStato
  661.                     ISQLQueryObject sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato =
  662.                             sqlQueryObjectGet.newSQLQueryObject();
  663.                     sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO));
  664.                     sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato.addSelectField("id_configurazione_stato");
  665.                     sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato.addWhereCondition("id=?");
  666.                     sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato.setANDLogicOperator(true);
  667.                     Long id_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato = null;
  668.                     try{
  669.                         id_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato = (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato.createSQLQuery(), jdbcProperties.isShowSql(),Long.class,
  670.                             new JDBCObject(configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.getId(),Long.class));
  671.                     }catch(NotFoundException  e){
  672.                         id_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato = null;
  673.                     }
  674.                
  675.                     IdConfigurazioneTransazioneStato idConfigurazioneTransazioneStato = new IdConfigurazioneTransazioneStato();
  676.                     if(id_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato != null)
  677.                         idConfigurazioneTransazioneStato.setStato(mapIdTransazioneStatoToName.get(id_configurazioneTransazione_configurazioneTransazioneRisorsaContenuto_idConfigurazioneTransazioneStato));
  678.                     configurazioneTransazione_configurazioneTransazioneRisorsaContenuto.setIdConfigurazioneTransazioneStato(idConfigurazioneTransazioneStato);
  679.                
  680.                 }

  681.                 configurazioneTransazione.addConfigurazioneTransazioneRisorsaContenuto(configurazioneTransazione_configurazioneTransazioneRisorsaContenuto);
  682.             }
  683.         }
  684.              
  685.         return configurazioneTransazione;  
  686.    
  687.     }
  688.    
  689.     @Override
  690.     public boolean exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  691.         return this._exists(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  692.     }
  693.    
  694.     private boolean _exists(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId) throws MultipleResultException, NotImplementedException, ServiceException, Exception {
  695.    
  696.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  697.                     new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);
  698.                
  699.         boolean existsConfigurazioneTransazione = false;

  700.         sqlQueryObject = sqlQueryObject.newSQLQueryObject();
  701.         sqlQueryObject.setANDLogicOperator(true);

  702.         sqlQueryObject.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model()));
  703.         sqlQueryObject.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toColumn(ConfigurazioneTransazione.model().ENABLED,true));
  704.         sqlQueryObject.addWhereCondition("id=?");


  705.         // Exists configurazioneTransazione
  706.         existsConfigurazioneTransazione = jdbcUtilities.exists(sqlQueryObject.createSQLQuery(), jdbcProperties.isShowSql(),
  707.             new JDBCObject(tableId,Long.class));

  708.        
  709.         return existsConfigurazioneTransazione;
  710.    
  711.     }
  712.    
  713.     private void joinEngine(IExpression expression, ISQLQueryObject sqlQueryObject) throws NotImplementedException, ServiceException, Exception{
  714.    
  715.         if(expression.inUseModel(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE,false)){
  716.             String tableName1 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model());
  717.             String tableName2 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE);
  718.             sqlQueryObject.addWhereCondition(tableName1+".id_conf_servizio_azione="+tableName2+".id");
  719.         }
  720.         if(expression.inUseModel(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE.ID_CONFIGURAZIONE_SERVIZIO,false)){
  721.             String tableName1 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE);
  722.             String tableName2 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE.ID_CONFIGURAZIONE_SERVIZIO);
  723.             sqlQueryObject.addWhereCondition(tableName1+".id_config_servizio="+tableName2+".id");
  724.         }
  725.         if(expression.inUseModel(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO,false)){
  726.             String tableName1 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO);
  727.             String tableName2 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model());
  728.             sqlQueryObject.addWhereCondition(tableName1+".id_configurazione_transazione="+tableName2+".id");
  729.         }
  730.         if(expression.inUseModel(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO,false)){
  731.             String tableName1 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO);
  732.             String tableName2 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model());
  733.             sqlQueryObject.addWhereCondition(tableName1+".id_conf_transazione="+tableName2+".id");
  734.         }
  735.         if(expression.inUseModel(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ID_CONFIGURAZIONE_TRANSAZIONE_STATO,false)){
  736.             String tableName1 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO);
  737.             String tableName2 = this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ID_CONFIGURAZIONE_TRANSAZIONE_STATO);
  738.             sqlQueryObject.addWhereCondition(tableName1+".id_configurazione_stato="+tableName2+".id");
  739.         }
  740.        
  741.         // Check FROM Table necessarie per le join di oggetti annidati dal secondo livello in poi dove pero' non viene poi utilizzato l'oggetto del livello precedente nella espressione
  742.         if(expression.inUseModel(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE.ID_CONFIGURAZIONE_SERVIZIO,false)){
  743.             if(expression.inUseModel(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE,false)==false){
  744.                 sqlQueryObject.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE));
  745.             }
  746.         }
  747.         if(expression.inUseModel(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ID_CONFIGURAZIONE_TRANSAZIONE_STATO,false)){
  748.             if(expression.inUseModel(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO,false)==false){
  749.                 sqlQueryObject.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO));
  750.             }
  751.         }
  752.        
  753.     }
  754.    
  755.     protected java.util.List<Object> getRootTablePrimaryKeyValuesEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneTransazione id) throws NotFoundException, ServiceException, NotImplementedException, Exception{
  756.         // Identificativi
  757.         java.util.List<Object> rootTableIdValues = new java.util.ArrayList<>();
  758.         // TODO: Define the column values used to identify the primary key
  759.         Long longId = this.findIdConfigurazioneTransazione(jdbcProperties, log, connection, sqlQueryObject.newSQLQueryObject(), id, true);
  760.         rootTableIdValues.add(longId);
  761.        
  762.         // Delete this line when you have verified the method
  763.         int throwNotImplemented = 1;
  764.         if(throwNotImplemented==1){
  765.                 throw new NotImplementedException("NotImplemented");
  766.         }
  767.         // Delete this line when you have verified the method
  768.        
  769.         return rootTableIdValues;
  770.     }
  771.    
  772.     protected Map<String, List<IField>> getMapTableToPKColumnEngine() throws NotImplementedException, Exception{
  773.    
  774.         ConfigurazioneTransazioneFieldConverter converter = this.getConfigurazioneTransazioneFieldConverter();
  775.         Map<String, List<IField>> mapTableToPKColumn = new java.util.HashMap<>();
  776.         UtilsTemplate<IField> utilities = new UtilsTemplate<>();

  777.         // ConfigurazioneTransazione.model()
  778.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneTransazione.model()),
  779.             utilities.newList(
  780.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneTransazione.model()))
  781.             ));

  782.         // ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE
  783.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE),
  784.             utilities.newList(
  785.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE))
  786.             ));

  787.         // ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE.ID_CONFIGURAZIONE_SERVIZIO
  788.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE.ID_CONFIGURAZIONE_SERVIZIO),
  789.             utilities.newList(
  790.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneTransazione.model().ID_CONFIGURAZIONE_SERVIZIO_AZIONE.ID_CONFIGURAZIONE_SERVIZIO))
  791.             ));

  792.         // ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO
  793.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO),
  794.             utilities.newList(
  795.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_STATO))
  796.             ));

  797.         // ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO
  798.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO),
  799.             utilities.newList(
  800.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO))
  801.             ));

  802.         // ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ID_CONFIGURAZIONE_TRANSAZIONE_STATO
  803.         mapTableToPKColumn.put(converter.toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ID_CONFIGURAZIONE_TRANSAZIONE_STATO),
  804.             utilities.newList(
  805.                 new CustomField("id", Long.class, "id", converter.toTable(ConfigurazioneTransazione.model().CONFIGURAZIONE_TRANSAZIONE_RISORSA_CONTENUTO.ID_CONFIGURAZIONE_TRANSAZIONE_STATO))
  806.             ));
  807.        
  808.         return mapTableToPKColumn;      
  809.     }
  810.    
  811.     @Override
  812.     public List<Long> findAllTableIds(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCPaginatedExpression paginatedExpression) throws ServiceException, NotImplementedException, Exception {
  813.        
  814.         List<Long> list = new ArrayList<Long>();

  815.         sqlQueryObject.setSelectDistinct(true);
  816.         sqlQueryObject.setANDLogicOperator(true);
  817.         sqlQueryObject.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model())+".id");
  818.         Class<?> objectIdClass = Long.class;
  819.        
  820.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFindAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  821.                                                 this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model());
  822.        
  823.         joinEngine(paginatedExpression,sqlQueryObject);
  824.        
  825.         List<Object> listObjects = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.findAll(jdbcProperties, log, connection, sqlQueryObject, paginatedExpression,
  826.                                                                             this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model(), objectIdClass, listaQuery);
  827.         for(Object object: listObjects) {
  828.             list.add((Long)object);
  829.         }

  830.         return list;
  831.        
  832.     }
  833.    
  834.     @Override
  835.     public long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, JDBCExpression expression) throws ServiceException, NotFoundException, MultipleResultException, NotImplementedException, Exception {
  836.    
  837.         sqlQueryObject.setSelectDistinct(true);
  838.         sqlQueryObject.setANDLogicOperator(true);
  839.         sqlQueryObject.addSelectField(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model())+".id");
  840.         Class<?> objectIdClass = Long.class;
  841.        
  842.         List<Object> listaQuery = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.prepareFind(jdbcProperties, log, connection, sqlQueryObject, expression,
  843.                                                 this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model());
  844.        
  845.         joinEngine(expression,sqlQueryObject);

  846.         Object res = org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.find(jdbcProperties, log, connection, sqlQueryObject, expression,
  847.                                                         this.getConfigurazioneTransazioneFieldConverter(), ConfigurazioneTransazione.model(), objectIdClass, listaQuery);
  848.         if(res!=null && (((Long) res).longValue()>0) ){
  849.             return ((Long) res).longValue();
  850.         }
  851.         else{
  852.             throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  853.         }
  854.        
  855.     }

  856.     @Override
  857.     public InUse inUse(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId) throws ServiceException, NotFoundException, NotImplementedException, Exception {
  858.         return this.inUseEngine(jdbcProperties, log, connection, sqlQueryObject, Long.valueOf(tableId));
  859.     }

  860.     private InUse inUseEngine(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, Long tableId) throws ServiceException, NotFoundException, NotImplementedException, Exception {

  861.         InUse inUse = new InUse();
  862.         inUse.setInUse(false);
  863.        
  864.         /*
  865.          * TODO: implement code that checks whether the object identified by the id parameter is used by other objects
  866.         */
  867.        
  868.         // Delete this line when you have implemented the method
  869.         int throwNotImplemented = 1;
  870.         if(throwNotImplemented==1){
  871.                 throw new NotImplementedException("NotImplemented");
  872.         }
  873.         // Delete this line when you have implemented the method

  874.         return inUse;

  875.     }
  876.    
  877.     @Override
  878.     public IdConfigurazioneTransazione findId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, long tableId, boolean throwNotFound)
  879.             throws NotFoundException, ServiceException, NotImplementedException, Exception {
  880.        
  881.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  882.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);

  883.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();            

  884.         // Object _configurazioneTransazione
  885.         sqlQueryObjectGet.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model()));
  886.         sqlQueryObjectGet.addSelectField("id_conf_servizio_azione");
  887.         sqlQueryObjectGet.setANDLogicOperator(true);
  888.         sqlQueryObjectGet.addWhereCondition("id=?");

  889.         // Recupero _configurazioneTransazione
  890.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_configurazioneTransazione = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  891.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject(tableId,Long.class)
  892.         };
  893.         List<Class<?>> listaFieldIdReturnType_configurazioneTransazione = new ArrayList<Class<?>>();
  894.         listaFieldIdReturnType_configurazioneTransazione.add(Long.class);
  895.         org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneTransazione id_configurazioneTransazione = null;
  896.         List<Object> listaFieldId_configurazioneTransazione = jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  897.                 listaFieldIdReturnType_configurazioneTransazione, searchParams_configurazioneTransazione);
  898.         if(listaFieldId_configurazioneTransazione==null || listaFieldId_configurazioneTransazione.size()<=0){
  899.             if(throwNotFound){
  900.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  901.             }
  902.         }
  903.         else{
  904.             // set _configurazioneTransazione
  905.             id_configurazioneTransazione = new org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneTransazione();
  906.             Long idFK_configurazioneTransazione_configurazioneServizioAzione = (Long) listaFieldId_configurazioneTransazione.get(1);
  907.             IdConfigurazioneServizioAzione _tmpIdConfigurazioneServizioAzione =
  908.                     JDBCConfigurazioneServizioAzioneBaseLib.getIdConfigurazioneServizioAzione(connection, jdbcProperties, log, idFK_configurazioneTransazione_configurazioneServizioAzione);
  909.            
  910.             org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneServizioAzione idConfigurazioneServizioAzione = new org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneServizioAzione();
  911.             idConfigurazioneServizioAzione.setAzione(_tmpIdConfigurazioneServizioAzione.getAzione());
  912.             org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneServizio idConfigurazioneServizio = new org.openspcoop2.monitor.engine.config.transazioni.IdConfigurazioneServizio();
  913.             idConfigurazioneServizio.setAccordo(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getAccordo());
  914.             idConfigurazioneServizio.setTipoSoggettoReferente(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getTipoSoggettoReferente());
  915.             idConfigurazioneServizio.setNomeSoggettoReferente(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getNomeSoggettoReferente());
  916.             idConfigurazioneServizio.setVersione(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getVersione());
  917.             idConfigurazioneServizio.setServizio(_tmpIdConfigurazioneServizioAzione.getIdConfigurazioneServizio().getServizio());
  918.             idConfigurazioneServizioAzione.setIdConfigurazioneServizio(idConfigurazioneServizio);
  919.             id_configurazioneTransazione.setIdConfigurazioneServizioAzione(idConfigurazioneServizioAzione);
  920.         }
  921.        
  922.         return id_configurazioneTransazione;
  923.        
  924.     }

  925.     @Override
  926.     public Long findTableId(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneTransazione id, boolean throwNotFound)
  927.             throws NotFoundException, ServiceException, NotImplementedException, Exception {
  928.    
  929.         return this.findIdConfigurazioneTransazione(jdbcProperties,log,connection,sqlQueryObject,id,throwNotFound);
  930.            
  931.     }
  932.    
  933.     @Override
  934.     public List<List<Object>> nativeQuery(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject,
  935.                                             String sql,List<Class<?>> returnClassTypes,Object ... param) throws ServiceException,NotFoundException,NotImplementedException,Exception{
  936.        
  937.         return org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.nativeQuery(jdbcProperties, log, connection, sqlQueryObject,
  938.                                                                                             sql,returnClassTypes,param);
  939.                                                        
  940.     }
  941.    
  942.     protected Long findIdConfigurazioneTransazione(JDBCServiceManagerProperties jdbcProperties, Logger log, Connection connection, ISQLQueryObject sqlQueryObject, IdConfigurazioneTransazione id, boolean throwNotFound) throws NotFoundException, ServiceException, NotImplementedException, Exception {

  943.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities jdbcUtilities =
  944.             new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCPreparedStatementUtilities(sqlQueryObject.getTipoDatabaseOpenSPCoop2(), log, connection);

  945.         ISQLQueryObject sqlQueryObjectGet = sqlQueryObject.newSQLQueryObject();

  946.        
  947.         // Object _configurazioneServizioAzione
  948.        
  949.         if(id==null){
  950.             throw new ServiceException("Id is null");
  951.         }
  952.         if(id.getIdConfigurazioneServizioAzione()==null){
  953.             throw new ServiceException("IdConfigurazioneServizioAzione is null");
  954.         }
  955.         if(id.getIdConfigurazioneServizioAzione().getAzione()==null){
  956.             throw new ServiceException("IdConfigurazioneServizioAzione.azione is null");
  957.         }
  958.         if(id.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio()==null){
  959.             throw new ServiceException("IdConfigurazioneServizioAzione.idConfigurazioneServizio is null");
  960.         }
  961.                
  962.         Long id_configurazioneServizioAzione =
  963.                 JDBCConfigurazioneServizioAzioneBaseLib.getIdConfigurazioneServizioAzione(connection, jdbcProperties, log,
  964.                         id.getIdConfigurazioneServizioAzione().getAzione(),
  965.                         id.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio().getAccordo(),
  966.                         id.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio().getTipoSoggettoReferente(),
  967.                         id.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio().getNomeSoggettoReferente(),
  968.                         id.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio().getVersione(),
  969.                         id.getIdConfigurazioneServizioAzione().getIdConfigurazioneServizio().getServizio(),
  970.                         throwNotFound);
  971.         if(id_configurazioneServizioAzione==null){
  972.             return null; // permesso se throwNotFound==false
  973.         }
  974.        
  975.        
  976.         // Object _configurazioneTransazione
  977.         sqlQueryObjectGet.addFromTable(this.getConfigurazioneTransazioneFieldConverter().toTable(ConfigurazioneTransazione.model()));
  978.         sqlQueryObjectGet.addSelectField("id");
  979.         sqlQueryObjectGet.setANDLogicOperator(true);
  980.         sqlQueryObjectGet.setSelectDistinct(true);
  981.         sqlQueryObjectGet.addWhereCondition("id_conf_servizio_azione=?");

  982.         // Recupero _configurazioneTransazione
  983.         org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] searchParams_configurazioneTransazione = new org.openspcoop2.generic_project.dao.jdbc.utils.JDBCObject [] {
  984.                 new JDBCObject( id_configurazioneServizioAzione, Long.class )
  985.         };
  986.         Long id_configurazioneTransazione = null;
  987.         try{
  988.             id_configurazioneTransazione = (Long) jdbcUtilities.executeQuerySingleResult(sqlQueryObjectGet.createSQLQuery(), jdbcProperties.isShowSql(),
  989.                         Long.class, searchParams_configurazioneTransazione);
  990.         }catch(NotFoundException notFound){
  991.             if(throwNotFound){
  992.                 throw new NotFoundException(notFound);
  993.             }
  994.         }
  995.         if(id_configurazioneTransazione==null || id_configurazioneTransazione<=0){
  996.             if(throwNotFound){
  997.                 throw org.openspcoop2.generic_project.dao.jdbc.utils.GenericJDBCUtilities.newNotFoundException();
  998.             }
  999.         }
  1000.        
  1001.         return id_configurazioneTransazione;
  1002.     }
  1003. }