DumpMessaggioFieldConverter.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.core.transazioni.dao.jdbc.converter;

  21. import org.openspcoop2.generic_project.beans.IField;
  22. import org.openspcoop2.generic_project.beans.IModel;
  23. import org.openspcoop2.generic_project.exception.ExpressionException;
  24. import org.openspcoop2.generic_project.expression.impl.sql.AbstractSQLFieldConverter;
  25. import org.openspcoop2.utils.TipiDatabase;
  26. import org.openspcoop2.core.constants.CostantiDB;
  27. import org.openspcoop2.core.transazioni.DumpMessaggio;


  28. /**    
  29.  * DumpMessaggioFieldConverter
  30.  *
  31.  * @author Poli Andrea (poli@link.it)
  32.  * @author $Author$
  33.  * @version $Rev$, $Date$
  34.  */
  35. public class DumpMessaggioFieldConverter extends AbstractSQLFieldConverter {

  36.     private TipiDatabase databaseType;
  37.    
  38.     public DumpMessaggioFieldConverter(String databaseType){
  39.         this.databaseType = TipiDatabase.toEnumConstant(databaseType);
  40.     }
  41.     public DumpMessaggioFieldConverter(TipiDatabase databaseType){
  42.         this.databaseType = databaseType;
  43.     }


  44.     @Override
  45.     public IModel<?> getRootModel() throws ExpressionException {
  46.         return DumpMessaggio.model();
  47.     }
  48.    
  49.     @Override
  50.     public TipiDatabase getDatabaseType() throws ExpressionException {
  51.         return this.databaseType;
  52.     }
  53.    


  54.     @Override
  55.     public String toColumn(IField field,boolean returnAlias,boolean appendTablePrefix) throws ExpressionException {
  56.        
  57.         // In the case of columns with alias, using parameter returnAlias​​,
  58.         // it is possible to drive the choice whether to return only the alias or
  59.         // the full definition of the column containing the alias
  60.        
  61.         if(field.equals(DumpMessaggio.model().ID_TRANSAZIONE)){
  62.             if(appendTablePrefix){
  63.                 return this.toAliasTable(field)+".id_transazione";
  64.             }else{
  65.                 return "id_transazione";
  66.             }
  67.         }
  68.         if(field.equals(DumpMessaggio.model().PROTOCOLLO)){
  69.             if(appendTablePrefix){
  70.                 return this.toAliasTable(field)+".protocollo";
  71.             }else{
  72.                 return "protocollo";
  73.             }
  74.         }
  75.         if(field.equals(DumpMessaggio.model().SERVIZIO_APPLICATIVO_EROGATORE)){
  76.             if(appendTablePrefix){
  77.                 return this.toAliasTable(field)+".servizio_applicativo_erogatore";
  78.             }else{
  79.                 return "servizio_applicativo_erogatore";
  80.             }
  81.         }
  82.         if(field.equals(DumpMessaggio.model().DATA_CONSEGNA_EROGATORE)){
  83.             if(appendTablePrefix){
  84.                 return this.toAliasTable(field)+".data_consegna_erogatore";
  85.             }else{
  86.                 return "data_consegna_erogatore";
  87.             }
  88.         }
  89.         if(field.equals(DumpMessaggio.model().TIPO_MESSAGGIO)){
  90.             if(appendTablePrefix){
  91.                 return this.toAliasTable(field)+".tipo_messaggio";
  92.             }else{
  93.                 return "tipo_messaggio";
  94.             }
  95.         }
  96.         if(field.equals(DumpMessaggio.model().FORMATO_MESSAGGIO)){
  97.             if(appendTablePrefix){
  98.                 return this.toAliasTable(field)+".formato_messaggio";
  99.             }else{
  100.                 return "formato_messaggio";
  101.             }
  102.         }
  103.         if(field.equals(DumpMessaggio.model().CONTENT_TYPE)){
  104.             if(appendTablePrefix){
  105.                 return this.toAliasTable(field)+".content_type";
  106.             }else{
  107.                 return "content_type";
  108.             }
  109.         }
  110.         if(field.equals(DumpMessaggio.model().CONTENT_LENGTH)){
  111.             if(appendTablePrefix){
  112.                 return this.toAliasTable(field)+".content_length";
  113.             }else{
  114.                 return "content_length";
  115.             }
  116.         }
  117.         if(field.equals(DumpMessaggio.model().MULTIPART_CONTENT_TYPE)){
  118.             if(appendTablePrefix){
  119.                 return this.toAliasTable(field)+".multipart_content_type";
  120.             }else{
  121.                 return "multipart_content_type";
  122.             }
  123.         }
  124.         if(field.equals(DumpMessaggio.model().MULTIPART_CONTENT_ID)){
  125.             if(appendTablePrefix){
  126.                 return this.toAliasTable(field)+".multipart_content_id";
  127.             }else{
  128.                 return "multipart_content_id";
  129.             }
  130.         }
  131.         if(field.equals(DumpMessaggio.model().MULTIPART_CONTENT_LOCATION)){
  132.             if(appendTablePrefix){
  133.                 return this.toAliasTable(field)+".multipart_content_location";
  134.             }else{
  135.                 return "multipart_content_location";
  136.             }
  137.         }
  138.         if(field.equals(DumpMessaggio.model().MULTIPART_HEADER.NOME)){
  139.             if(appendTablePrefix){
  140.                 return this.toAliasTable(field)+".nome";
  141.             }else{
  142.                 return "nome";
  143.             }
  144.         }
  145.         if(field.equals(DumpMessaggio.model().MULTIPART_HEADER.VALORE)){
  146.             if(appendTablePrefix){
  147.                 return this.toAliasTable(field)+".valore";
  148.             }else{
  149.                 return "valore";
  150.             }
  151.         }
  152.         if(field.equals(DumpMessaggio.model().MULTIPART_HEADER.DUMP_TIMESTAMP)){
  153.             if(appendTablePrefix){
  154.                 return this.toAliasTable(field)+".dump_timestamp";
  155.             }else{
  156.                 return "dump_timestamp";
  157.             }
  158.         }
  159.         if(field.equals(DumpMessaggio.model().BODY)){
  160.             if(appendTablePrefix){
  161.                 return this.toAliasTable(field)+".body";
  162.             }else{
  163.                 return "body";
  164.             }
  165.         }
  166.         if(field.equals(DumpMessaggio.model().HEADER_TRASPORTO.NOME)){
  167.             if(appendTablePrefix){
  168.                 return this.toAliasTable(field)+".nome";
  169.             }else{
  170.                 return "nome";
  171.             }
  172.         }
  173.         if(field.equals(DumpMessaggio.model().HEADER_TRASPORTO.VALORE)){
  174.             if(appendTablePrefix){
  175.                 return this.toAliasTable(field)+".valore";
  176.             }else{
  177.                 return "valore";
  178.             }
  179.         }
  180.         if(field.equals(DumpMessaggio.model().HEADER_TRASPORTO.DUMP_TIMESTAMP)){
  181.             if(appendTablePrefix){
  182.                 return this.toAliasTable(field)+".dump_timestamp";
  183.             }else{
  184.                 return "dump_timestamp";
  185.             }
  186.         }
  187.         if(field.equals(DumpMessaggio.model().ALLEGATO.CONTENT_TYPE)){
  188.             if(appendTablePrefix){
  189.                 return this.toAliasTable(field)+".content_type";
  190.             }else{
  191.                 return "content_type";
  192.             }
  193.         }
  194.         if(field.equals(DumpMessaggio.model().ALLEGATO.CONTENT_ID)){
  195.             if(appendTablePrefix){
  196.                 return this.toAliasTable(field)+".content_id";
  197.             }else{
  198.                 return "content_id";
  199.             }
  200.         }
  201.         if(field.equals(DumpMessaggio.model().ALLEGATO.CONTENT_LOCATION)){
  202.             if(appendTablePrefix){
  203.                 return this.toAliasTable(field)+".content_location";
  204.             }else{
  205.                 return "content_location";
  206.             }
  207.         }
  208.         if(field.equals(DumpMessaggio.model().ALLEGATO.ALLEGATO)){
  209.             if(appendTablePrefix){
  210.                 return this.toAliasTable(field)+".allegato";
  211.             }else{
  212.                 return "allegato";
  213.             }
  214.         }
  215.         if(field.equals(DumpMessaggio.model().ALLEGATO.HEADER.NOME)){
  216.             if(appendTablePrefix){
  217.                 return this.toAliasTable(field)+".nome";
  218.             }else{
  219.                 return "nome";
  220.             }
  221.         }
  222.         if(field.equals(DumpMessaggio.model().ALLEGATO.HEADER.VALORE)){
  223.             if(appendTablePrefix){
  224.                 return this.toAliasTable(field)+".valore";
  225.             }else{
  226.                 return "valore";
  227.             }
  228.         }
  229.         if(field.equals(DumpMessaggio.model().ALLEGATO.HEADER.DUMP_TIMESTAMP)){
  230.             if(appendTablePrefix){
  231.                 return this.toAliasTable(field)+".dump_timestamp";
  232.             }else{
  233.                 return "dump_timestamp";
  234.             }
  235.         }
  236.         if(field.equals(DumpMessaggio.model().ALLEGATO.DUMP_TIMESTAMP)){
  237.             if(appendTablePrefix){
  238.                 return this.toAliasTable(field)+".dump_timestamp";
  239.             }else{
  240.                 return "dump_timestamp";
  241.             }
  242.         }
  243.         if(field.equals(DumpMessaggio.model().ALLEGATO.HEADER_EXT)){
  244.             if(appendTablePrefix){
  245.                 return this.toAliasTable(field)+".header_ext";
  246.             }else{
  247.                 return "header_ext";
  248.             }
  249.         }
  250.         if(field.equals(DumpMessaggio.model().CONTENUTO.NOME)){
  251.             if(appendTablePrefix){
  252.                 return this.toAliasTable(field)+".nome";
  253.             }else{
  254.                 return "nome";
  255.             }
  256.         }
  257.         if(field.equals(DumpMessaggio.model().CONTENUTO.VALORE)){
  258.             if(appendTablePrefix){
  259.                 return this.toAliasTable(field)+".valore";
  260.             }else{
  261.                 return "valore";
  262.             }
  263.         }
  264.         if(field.equals(DumpMessaggio.model().CONTENUTO.VALORE_AS_BYTES)){
  265.             if(appendTablePrefix){
  266.                 return this.toAliasTable(field)+".valore_as_bytes";
  267.             }else{
  268.                 return "valore_as_bytes";
  269.             }
  270.         }
  271.         if(field.equals(DumpMessaggio.model().CONTENUTO.DUMP_TIMESTAMP)){
  272.             if(appendTablePrefix){
  273.                 return this.toAliasTable(field)+".dump_timestamp";
  274.             }else{
  275.                 return "dump_timestamp";
  276.             }
  277.         }
  278.         if(field.equals(DumpMessaggio.model().DUMP_TIMESTAMP)){
  279.             if(appendTablePrefix){
  280.                 return this.toAliasTable(field)+".dump_timestamp";
  281.             }else{
  282.                 return "dump_timestamp";
  283.             }
  284.         }
  285.         if(field.equals(DumpMessaggio.model().POST_PROCESS_HEADER)){
  286.             if(appendTablePrefix){
  287.                 return this.toAliasTable(field)+".post_process_header";
  288.             }else{
  289.                 return "post_process_header";
  290.             }
  291.         }
  292.         if(field.equals(DumpMessaggio.model().POST_PROCESS_FILENAME)){
  293.             if(appendTablePrefix){
  294.                 return this.toAliasTable(field)+".post_process_filename";
  295.             }else{
  296.                 return "post_process_filename";
  297.             }
  298.         }
  299.         if(field.equals(DumpMessaggio.model().POST_PROCESS_CONTENT)){
  300.             if(appendTablePrefix){
  301.                 return this.toAliasTable(field)+".post_process_content";
  302.             }else{
  303.                 return "post_process_content";
  304.             }
  305.         }
  306.         if(field.equals(DumpMessaggio.model().POST_PROCESS_CONFIG_ID)){
  307.             if(appendTablePrefix){
  308.                 return this.toAliasTable(field)+".post_process_config_id";
  309.             }else{
  310.                 return "post_process_config_id";
  311.             }
  312.         }
  313.         if(field.equals(DumpMessaggio.model().POST_PROCESS_TIMESTAMP)){
  314.             if(appendTablePrefix){
  315.                 return this.toAliasTable(field)+".post_process_timestamp";
  316.             }else{
  317.                 return "post_process_timestamp";
  318.             }
  319.         }
  320.         if(field.equals(DumpMessaggio.model().POST_PROCESSED)){
  321.             if(appendTablePrefix){
  322.                 return this.toAliasTable(field)+".post_processed";
  323.             }else{
  324.                 return "post_processed";
  325.             }
  326.         }
  327.         if(field.equals(DumpMessaggio.model().MULTIPART_HEADER_EXT)){
  328.             if(appendTablePrefix){
  329.                 return this.toAliasTable(field)+".multipart_header_ext";
  330.             }else{
  331.                 return "multipart_header_ext";
  332.             }
  333.         }
  334.         if(field.equals(DumpMessaggio.model().HEADER_EXT)){
  335.             if(appendTablePrefix){
  336.                 return this.toAliasTable(field)+".header_ext";
  337.             }else{
  338.                 return "header_ext";
  339.             }
  340.         }


  341.         return super.toColumn(field,returnAlias,appendTablePrefix);
  342.        
  343.     }
  344.    
  345.     @Override
  346.     public String toTable(IField field,boolean returnAlias) throws ExpressionException {
  347.        
  348.         // In the case of table with alias, using parameter returnAlias​​,
  349.         // it is possible to drive the choice whether to return only the alias or
  350.         // the full definition of the table containing the alias
  351.        
  352.         if(field.equals(DumpMessaggio.model().ID_TRANSAZIONE)){
  353.             return this.toTable(DumpMessaggio.model(), returnAlias);
  354.         }
  355.         if(field.equals(DumpMessaggio.model().PROTOCOLLO)){
  356.             return this.toTable(DumpMessaggio.model(), returnAlias);
  357.         }
  358.         if(field.equals(DumpMessaggio.model().SERVIZIO_APPLICATIVO_EROGATORE)){
  359.             return this.toTable(DumpMessaggio.model(), returnAlias);
  360.         }
  361.         if(field.equals(DumpMessaggio.model().DATA_CONSEGNA_EROGATORE)){
  362.             return this.toTable(DumpMessaggio.model(), returnAlias);
  363.         }
  364.         if(field.equals(DumpMessaggio.model().TIPO_MESSAGGIO)){
  365.             return this.toTable(DumpMessaggio.model(), returnAlias);
  366.         }
  367.         if(field.equals(DumpMessaggio.model().FORMATO_MESSAGGIO)){
  368.             return this.toTable(DumpMessaggio.model(), returnAlias);
  369.         }
  370.         if(field.equals(DumpMessaggio.model().CONTENT_TYPE)){
  371.             return this.toTable(DumpMessaggio.model(), returnAlias);
  372.         }
  373.         if(field.equals(DumpMessaggio.model().CONTENT_LENGTH)){
  374.             return this.toTable(DumpMessaggio.model(), returnAlias);
  375.         }
  376.         if(field.equals(DumpMessaggio.model().MULTIPART_CONTENT_TYPE)){
  377.             return this.toTable(DumpMessaggio.model(), returnAlias);
  378.         }
  379.         if(field.equals(DumpMessaggio.model().MULTIPART_CONTENT_ID)){
  380.             return this.toTable(DumpMessaggio.model(), returnAlias);
  381.         }
  382.         if(field.equals(DumpMessaggio.model().MULTIPART_CONTENT_LOCATION)){
  383.             return this.toTable(DumpMessaggio.model(), returnAlias);
  384.         }
  385.         if(field.equals(DumpMessaggio.model().MULTIPART_HEADER.NOME)){
  386.             return this.toTable(DumpMessaggio.model().MULTIPART_HEADER, returnAlias);
  387.         }
  388.         if(field.equals(DumpMessaggio.model().MULTIPART_HEADER.VALORE)){
  389.             return this.toTable(DumpMessaggio.model().MULTIPART_HEADER, returnAlias);
  390.         }
  391.         if(field.equals(DumpMessaggio.model().MULTIPART_HEADER.DUMP_TIMESTAMP)){
  392.             return this.toTable(DumpMessaggio.model().MULTIPART_HEADER, returnAlias);
  393.         }
  394.         if(field.equals(DumpMessaggio.model().BODY)){
  395.             return this.toTable(DumpMessaggio.model(), returnAlias);
  396.         }
  397.         if(field.equals(DumpMessaggio.model().HEADER_TRASPORTO.NOME)){
  398.             return this.toTable(DumpMessaggio.model().HEADER_TRASPORTO, returnAlias);
  399.         }
  400.         if(field.equals(DumpMessaggio.model().HEADER_TRASPORTO.VALORE)){
  401.             return this.toTable(DumpMessaggio.model().HEADER_TRASPORTO, returnAlias);
  402.         }
  403.         if(field.equals(DumpMessaggio.model().HEADER_TRASPORTO.DUMP_TIMESTAMP)){
  404.             return this.toTable(DumpMessaggio.model().HEADER_TRASPORTO, returnAlias);
  405.         }
  406.         if(field.equals(DumpMessaggio.model().ALLEGATO.CONTENT_TYPE)){
  407.             return this.toTable(DumpMessaggio.model().ALLEGATO, returnAlias);
  408.         }
  409.         if(field.equals(DumpMessaggio.model().ALLEGATO.CONTENT_ID)){
  410.             return this.toTable(DumpMessaggio.model().ALLEGATO, returnAlias);
  411.         }
  412.         if(field.equals(DumpMessaggio.model().ALLEGATO.CONTENT_LOCATION)){
  413.             return this.toTable(DumpMessaggio.model().ALLEGATO, returnAlias);
  414.         }
  415.         if(field.equals(DumpMessaggio.model().ALLEGATO.ALLEGATO)){
  416.             return this.toTable(DumpMessaggio.model().ALLEGATO, returnAlias);
  417.         }
  418.         if(field.equals(DumpMessaggio.model().ALLEGATO.HEADER.NOME)){
  419.             return this.toTable(DumpMessaggio.model().ALLEGATO.HEADER, returnAlias);
  420.         }
  421.         if(field.equals(DumpMessaggio.model().ALLEGATO.HEADER.VALORE)){
  422.             return this.toTable(DumpMessaggio.model().ALLEGATO.HEADER, returnAlias);
  423.         }
  424.         if(field.equals(DumpMessaggio.model().ALLEGATO.HEADER.DUMP_TIMESTAMP)){
  425.             return this.toTable(DumpMessaggio.model().ALLEGATO.HEADER, returnAlias);
  426.         }
  427.         if(field.equals(DumpMessaggio.model().ALLEGATO.DUMP_TIMESTAMP)){
  428.             return this.toTable(DumpMessaggio.model().ALLEGATO, returnAlias);
  429.         }
  430.         if(field.equals(DumpMessaggio.model().ALLEGATO.HEADER_EXT)){
  431.             return this.toTable(DumpMessaggio.model().ALLEGATO, returnAlias);
  432.         }
  433.         if(field.equals(DumpMessaggio.model().CONTENUTO.NOME)){
  434.             return this.toTable(DumpMessaggio.model().CONTENUTO, returnAlias);
  435.         }
  436.         if(field.equals(DumpMessaggio.model().CONTENUTO.VALORE)){
  437.             return this.toTable(DumpMessaggio.model().CONTENUTO, returnAlias);
  438.         }
  439.         if(field.equals(DumpMessaggio.model().CONTENUTO.VALORE_AS_BYTES)){
  440.             return this.toTable(DumpMessaggio.model().CONTENUTO, returnAlias);
  441.         }
  442.         if(field.equals(DumpMessaggio.model().CONTENUTO.DUMP_TIMESTAMP)){
  443.             return this.toTable(DumpMessaggio.model().CONTENUTO, returnAlias);
  444.         }
  445.         if(field.equals(DumpMessaggio.model().DUMP_TIMESTAMP)){
  446.             return this.toTable(DumpMessaggio.model(), returnAlias);
  447.         }
  448.         if(field.equals(DumpMessaggio.model().POST_PROCESS_HEADER)){
  449.             return this.toTable(DumpMessaggio.model(), returnAlias);
  450.         }
  451.         if(field.equals(DumpMessaggio.model().POST_PROCESS_FILENAME)){
  452.             return this.toTable(DumpMessaggio.model(), returnAlias);
  453.         }
  454.         if(field.equals(DumpMessaggio.model().POST_PROCESS_CONTENT)){
  455.             return this.toTable(DumpMessaggio.model(), returnAlias);
  456.         }
  457.         if(field.equals(DumpMessaggio.model().POST_PROCESS_CONFIG_ID)){
  458.             return this.toTable(DumpMessaggio.model(), returnAlias);
  459.         }
  460.         if(field.equals(DumpMessaggio.model().POST_PROCESS_TIMESTAMP)){
  461.             return this.toTable(DumpMessaggio.model(), returnAlias);
  462.         }
  463.         if(field.equals(DumpMessaggio.model().POST_PROCESSED)){
  464.             return this.toTable(DumpMessaggio.model(), returnAlias);
  465.         }
  466.         if(field.equals(DumpMessaggio.model().MULTIPART_HEADER_EXT)){
  467.             return this.toTable(DumpMessaggio.model(), returnAlias);
  468.         }
  469.         if(field.equals(DumpMessaggio.model().HEADER_EXT)){
  470.             return this.toTable(DumpMessaggio.model(), returnAlias);
  471.         }


  472.         return super.toTable(field,returnAlias);
  473.        
  474.     }

  475.     @Override
  476.     public String toTable(IModel<?> model,boolean returnAlias) throws ExpressionException {
  477.        
  478.         // In the case of table with alias, using parameter returnAlias​​,
  479.         // it is possible to drive the choice whether to return only the alias or
  480.         // the full definition of the table containing the alias
  481.        
  482.         if(model.equals(DumpMessaggio.model())){
  483.             return CostantiDB.DUMP_MESSAGGI;
  484.         }
  485.         if(model.equals(DumpMessaggio.model().MULTIPART_HEADER)){
  486.             return CostantiDB.DUMP_MULTIPART_HEADER;
  487.         }
  488.         if(model.equals(DumpMessaggio.model().HEADER_TRASPORTO)){
  489.             return CostantiDB.DUMP_HEADER_TRASPORTO;
  490.         }
  491.         if(model.equals(DumpMessaggio.model().ALLEGATO)){
  492.             return CostantiDB.DUMP_ALLEGATI;
  493.         }
  494.         if(model.equals(DumpMessaggio.model().ALLEGATO.HEADER)){
  495.             return CostantiDB.DUMP_ALLEGATI_HEADER;
  496.         }
  497.         if(model.equals(DumpMessaggio.model().CONTENUTO)){
  498.             return CostantiDB.DUMP_CONTENUTI;
  499.         }


  500.         return super.toTable(model,returnAlias);
  501.        
  502.     }

  503. }