PortletDAO.java

  1. /*
  2.  * Copyright (c) 2002-2022, City of Paris
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  *  1. Redistributions of source code must retain the above copyright notice
  10.  *     and the following disclaimer.
  11.  *
  12.  *  2. Redistributions in binary form must reproduce the above copyright notice
  13.  *     and the following disclaimer in the documentation and/or other materials
  14.  *     provided with the distribution.
  15.  *
  16.  *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
  17.  *     contributors may be used to endorse or promote products derived from
  18.  *     this software without specific prior written permission.
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
  24.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30.  * POSSIBILITY OF SUCH DAMAGE.
  31.  *
  32.  * License 1.0
  33.  */
  34. package fr.paris.lutece.portal.business.portlet;

  35. import fr.paris.lutece.portal.business.stylesheet.StyleSheet;
  36. import fr.paris.lutece.util.ReferenceList;
  37. import fr.paris.lutece.util.sql.DAOUtil;

  38. import java.sql.Statement;
  39. import java.sql.Timestamp;

  40. import java.util.ArrayList;
  41. import java.util.Collection;
  42. import java.util.List;

  43. /**
  44.  * This class provides Data Access methods for Portlet objects
  45.  */
  46. public final class PortletDAO implements IPortletDAO
  47. {
  48.     // queries
  49.     private static final String SQL_QUERY_UPDATE = " UPDATE core_portlet SET name = ?, date_update = ?, column_no = ?, "
  50.             + " portlet_order = ? , id_style = ? , id_page = ?, accept_alias = ? , display_portlet_title = ?, role = ?, device_display_flags = ? "
  51.             + " WHERE id_portlet = ?";
  52.     private static final String SQL_QUERY_SELECT = " SELECT b.id_portlet_type, a.id_page, a.id_style, a.name , b.name, "
  53.             + " b.url_creation, b.url_update, a.date_update, a.column_no, a.portlet_order, "
  54.             + " b.home_class, a.accept_alias , a.role , b.plugin_name , a.display_portlet_title, a.status, a.device_display_flags "
  55.             + " FROM core_portlet a , core_portlet_type b WHERE a.id_portlet_type = b.id_portlet_type AND a.id_portlet = ?";
  56.     private static final String SQL_QUERY_SELECT_ALIAS = " SELECT a.id_portlet FROM core_portlet a, core_portlet_alias b "
  57.             + " WHERE a.id_portlet = b.id_portlet AND b.id_alias= ? ";
  58.     private static final String SQL_QUERY_DELETE = "DELETE FROM core_portlet WHERE id_portlet = ?";
  59.     private static final String SQL_QUERY_UPDATE_STATUS = " UPDATE core_portlet SET status = ?, date_update = ? WHERE id_portlet = ? ";
  60.     private static final String SQL_QUERY_UPDATE_POSITION = " UPDATE core_portlet SET column_no = ?, portlet_order = ? WHERE id_portlet = ? ";
  61.     private static final String SQL_QUERY_INSERT = " INSERT INTO core_portlet ( id_portlet_type, id_page, id_style, name, "
  62.             + " date_creation, date_update, status, column_no, portlet_order, accept_alias, display_portlet_title, role, device_display_flags ) "
  63.             + " VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? , ?, ?, ?)";
  64.     private static final String SQL_QUERY_SELECT_PORTLET_LIST_BY_STYLE = "SELECT id_portlet, name, id_page FROM core_portlet WHERE id_style=?";
  65.     private static final String SQL_QUERY_SELECT_PORTLET_LIST_BY_ROLE = "SELECT id_portlet, name, id_page FROM core_portlet WHERE role=?";
  66.     private static final String SQL_QUERY_SELECT_XSL_FILE = " SELECT a.id_stylesheet , a.description , a.file_name, a.source "
  67.             + " FROM core_stylesheet a, core_portlet b, core_style_mode_stylesheet c " + " WHERE a.id_stylesheet = c.id_stylesheet "
  68.             + " AND b.id_style = c.id_style AND b.id_portlet = ? AND c.id_mode = ? ";
  69.     private static final String SQL_QUERY_SELECT_STYLE_LIST = " SELECT distinct a.id_style , a.description_style "
  70.             + " FROM core_style a , core_style_mode_stylesheet b " + " WHERE  a.id_style = b.id_style "
  71.             + " AND a.id_portlet_type = ? ORDER BY a.description_style";
  72.     private static final String SQL_QUERY_SELECT_PORTLET_TYPE = " SELECT id_portlet_type , name , url_creation, url_update, plugin_name "
  73.             + " FROM core_portlet_type WHERE id_portlet_type = ? ORDER BY id_portlet_type ";
  74.     private static final String SQL_QUERY_SELECT_PORTLET_ALIAS = " SELECT a.id_portlet FROM core_portlet a , core_portlet_alias b"
  75.             + " WHERE a.id_portlet = b.id_portlet " + " AND b.id_alias= ? ";
  76.     private static final String SQL_QUERY_SELECT_ALIASES_FOR_PORTLET = "SELECT p.id_portlet, p.id_page, p.name "
  77.             + "FROM core_portlet_alias a JOIN core_portlet p ON p.id_portlet = a.id_portlet WHERE a.id_alias = ? ";
  78.     private static final String SQL_QUERY_SELECT_PORTLET_LIST_BY_NAME = " SELECT id_portlet , id_page , name FROM core_portlet WHERE name LIKE ? ";
  79.     private static final String SQL_QUERY_SELECT_PORTLET_LIST_BY_TYPE = " SELECT a.id_portlet, a.id_portlet_type, a.id_page, a.name, "
  80.             + "a.date_update, a.status, a.portlet_order, a.column_no, a.id_style, a.accept_alias, a.date_creation, a.display_portlet_title, a.role, a.device_display_flags "
  81.             + " FROM core_portlet a, core_page b  WHERE a.id_page = b.id_page " + " AND a.id_portlet_type = ? ";
  82.     private static final String SQL_QUERY_SELECT_LAST_MODIFIED_PORTLET = " SELECT a.id_portlet, b.id_portlet_type, a.id_page, a.id_style, a.name , b.name, "
  83.             + " b.url_creation, b.url_update, a.date_update, a.column_no, a.portlet_order, "
  84.             + " b.home_class, a.accept_alias , a.role , b.plugin_name , a.display_portlet_title, a.status , a.device_display_flags "
  85.             + " FROM core_portlet a , core_portlet_type b WHERE a.id_portlet_type = b.id_portlet_type ORDER BY a.date_update DESC LIMIT 1 ";
  86.     private static final String SQL_QUERY_SELECT_ORDER_FROM_PAGE_AND_COLUMN = " SELECT portlet_order FROM core_portlet WHERE column_no = ? AND id_page = ?  ORDER BY portlet_order";

  87.     // /////////////////////////////////////////////////////////////////////////////////////
  88.     // Access methods to data

  89.     /**
  90.      * {@inheritDoc}
  91.      */
  92.     public void insert( Portlet portlet )
  93.     {
  94.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT, Statement.RETURN_GENERATED_KEYS ) )
  95.         {
  96.             int nIndex = 1;
  97.             daoUtil.setString( nIndex++, portlet.getPortletTypeId( ) );
  98.             daoUtil.setInt( nIndex++, portlet.getPageId( ) );
  99.             daoUtil.setInt( nIndex++, portlet.getStyleId( ) );
  100.             daoUtil.setString( nIndex++, portlet.getName( ) );
  101.             daoUtil.setTimestamp( nIndex++, new Timestamp( new java.util.Date( ).getTime( ) ) );
  102.             daoUtil.setTimestamp( nIndex++, new Timestamp( new java.util.Date( ).getTime( ) ) );
  103.             daoUtil.setInt( nIndex++, portlet.getStatus( ) );
  104.             daoUtil.setInt( nIndex++, portlet.getColumn( ) );
  105.             daoUtil.setInt( nIndex++, portlet.getOrder( ) );
  106.             daoUtil.setInt( nIndex++, portlet.getAcceptAlias( ) );
  107.             daoUtil.setInt( nIndex++, portlet.getDisplayPortletTitle( ) );
  108.             daoUtil.setString( nIndex++, portlet.getRole( ) );
  109.             daoUtil.setInt( nIndex, portlet.getDeviceDisplayFlags( ) );

  110.             daoUtil.executeUpdate( );

  111.             if ( daoUtil.nextGeneratedKey( ) )
  112.             {
  113.                 portlet.setId( daoUtil.getGeneratedKeyInt( 1 ) );
  114.             }
  115.         }
  116.     }

  117.     /**
  118.      * {@inheritDoc}
  119.      */
  120.     public void delete( int nPortletId )
  121.     {
  122.         // we recover the alias of the portlet parent to delete
  123.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_ALIAS ) )
  124.         {
  125.             daoUtil.setInt( 1, nPortletId );
  126.             daoUtil.executeQuery( );

  127.             while ( daoUtil.next( ) )
  128.             {
  129.                 AliasPortletHome.getInstance( ).remove( PortletHome.findByPrimaryKey( daoUtil.getInt( 1 ) ) );
  130.             }

  131.         }

  132.         // we delete the portlet
  133.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE ) )
  134.         {
  135.             daoUtil.setInt( 1, nPortletId );

  136.             daoUtil.executeUpdate( );
  137.         }
  138.     }

  139.     /**
  140.      * {@inheritDoc}
  141.      */
  142.     public Portlet load( int nPortletId )
  143.     {
  144.         PortletImpl portlet = new PortletImpl( );
  145.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT ) )
  146.         {
  147.             daoUtil.setInt( 1, nPortletId );
  148.             daoUtil.executeQuery( );

  149.             if ( daoUtil.next( ) )
  150.             {
  151.                 portlet.setId( nPortletId );
  152.                 portlet.setPortletTypeId( daoUtil.getString( 1 ) );
  153.                 portlet.setPageId( daoUtil.getInt( 2 ) );
  154.                 portlet.setStyleId( daoUtil.getInt( 3 ) );
  155.                 portlet.setName( daoUtil.getString( 4 ) );
  156.                 portlet.setPortletTypeName( daoUtil.getString( 5 ) );
  157.                 portlet.setUrlCreation( daoUtil.getString( 6 ) );
  158.                 portlet.setUrlUpdate( daoUtil.getString( 7 ) );
  159.                 portlet.setDateUpdate( daoUtil.getTimestamp( 8 ) );
  160.                 portlet.setColumn( daoUtil.getInt( 9 ) );
  161.                 portlet.setOrder( daoUtil.getInt( 10 ) );
  162.                 portlet.setHomeClassName( daoUtil.getString( 11 ) );
  163.                 portlet.setAcceptAlias( daoUtil.getInt( 12 ) );
  164.                 portlet.setRole( daoUtil.getString( 13 ) );
  165.                 portlet.setPluginName( daoUtil.getString( 14 ) );
  166.                 portlet.setDisplayPortletTitle( daoUtil.getInt( 15 ) );
  167.                 portlet.setStatus( daoUtil.getInt( 16 ) );
  168.                 portlet.setDeviceDisplayFlags( daoUtil.getInt( 17 ) );
  169.             }

  170.         }

  171.         return portlet;
  172.     }

  173.     /**
  174.      * {@inheritDoc}
  175.      */
  176.     public void store( Portlet portlet )
  177.     {
  178.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE ) )
  179.         {

  180.             daoUtil.setString( 1, portlet.getName( ) );
  181.             daoUtil.setTimestamp( 2, new Timestamp( new java.util.Date( ).getTime( ) ) );
  182.             daoUtil.setInt( 3, portlet.getColumn( ) );
  183.             daoUtil.setInt( 4, portlet.getOrder( ) );
  184.             daoUtil.setInt( 5, portlet.getStyleId( ) );
  185.             daoUtil.setInt( 6, portlet.getPageId( ) );
  186.             daoUtil.setInt( 7, portlet.getAcceptAlias( ) );
  187.             daoUtil.setInt( 8, portlet.getDisplayPortletTitle( ) );
  188.             daoUtil.setString( 9, portlet.getRole( ) );
  189.             daoUtil.setInt( 10, portlet.getDeviceDisplayFlags( ) );
  190.             daoUtil.setInt( 11, portlet.getId( ) );

  191.             daoUtil.executeUpdate( );
  192.         }
  193.     }

  194.     /**
  195.      * {@inheritDoc}
  196.      */
  197.     public void updateStatus( Portlet portlet, int nStatus )
  198.     {
  199.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE_STATUS ) )
  200.         {

  201.             daoUtil.setInt( 1, nStatus );
  202.             daoUtil.setTimestamp( 2, new Timestamp( new java.util.Date( ).getTime( ) ) );
  203.             daoUtil.setInt( 3, portlet.getId( ) );

  204.             daoUtil.executeUpdate( );
  205.         }
  206.     }

  207.     /**
  208.      * {@inheritDoc}
  209.      */
  210.     public void updatePosition( Portlet portlet, int nColumn, int nOrder )
  211.     {
  212.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE_POSITION ) )
  213.         {
  214.             daoUtil.setInt( 1, nColumn );
  215.             daoUtil.setInt( 2, nOrder );
  216.             daoUtil.setInt( 3, portlet.getId( ) );

  217.             daoUtil.executeUpdate( );
  218.         }
  219.     }

  220.     /**
  221.      * {@inheritDoc}
  222.      */
  223.     public StyleSheet selectXslFile( int nPortletId, int nIdMode )
  224.     {
  225.         StyleSheet stylesheet = new StyleSheet( );
  226.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_XSL_FILE ) )
  227.         {
  228.             daoUtil.setInt( 1, nPortletId );
  229.             daoUtil.setInt( 2, nIdMode );
  230.             daoUtil.executeQuery( );

  231.             if ( daoUtil.next( ) )
  232.             {
  233.                 stylesheet.setId( daoUtil.getInt( 1 ) );
  234.                 stylesheet.setDescription( daoUtil.getString( 2 ) );
  235.                 stylesheet.setFile( daoUtil.getString( 3 ) );
  236.                 stylesheet.setSource( daoUtil.getBytes( 4 ) );
  237.             }

  238.         }

  239.         return stylesheet;
  240.     }

  241.     /**
  242.      * {@inheritDoc}
  243.      */
  244.     public Collection<PortletImpl> selectPortletsListbyName( String strPortletName )
  245.     {
  246.         List<PortletImpl> list = new ArrayList<>( );
  247.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_PORTLET_LIST_BY_NAME ) )
  248.         {
  249.             daoUtil.setString( 1, '%' + strPortletName + '%' );
  250.             daoUtil.executeQuery( );

  251.             while ( daoUtil.next( ) )
  252.             {
  253.                 PortletImpl portlet = new PortletImpl( );
  254.                 portlet.setId( daoUtil.getInt( 1 ) );
  255.                 portlet.setPageId( daoUtil.getInt( 2 ) );
  256.                 portlet.setName( daoUtil.getString( 3 ) );

  257.                 list.add( portlet );
  258.             }

  259.         }

  260.         return list;
  261.     }

  262.     /**
  263.      * {@inheritDoc}
  264.      */
  265.     public Collection<Portlet> selectAliasesForPortlet( int nPortletId )
  266.     {
  267.         List<Portlet> list = new ArrayList<>( );
  268.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_ALIASES_FOR_PORTLET ) )
  269.         {
  270.             daoUtil.setInt( 1, nPortletId );
  271.             daoUtil.executeQuery( );

  272.             while ( daoUtil.next( ) )
  273.             {
  274.                 PortletImpl portlet = new PortletImpl( );
  275.                 portlet.setId( daoUtil.getInt( 1 ) );
  276.                 portlet.setPageId( daoUtil.getInt( 2 ) );
  277.                 portlet.setName( daoUtil.getString( 3 ) );

  278.                 list.add( portlet );
  279.             }

  280.         }

  281.         return list;
  282.     }

  283.     /**
  284.      * {@inheritDoc}
  285.      */
  286.     public List<Portlet> selectPortletsByType( String strPortletTypeId )
  287.     {
  288.         List<Portlet> list = new ArrayList<>( );
  289.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_PORTLET_LIST_BY_TYPE ) )
  290.         {
  291.             daoUtil.setString( 1, strPortletTypeId );
  292.             daoUtil.executeQuery( );

  293.             while ( daoUtil.next( ) )
  294.             {
  295.                 PortletImpl portlet = new PortletImpl( );
  296.                 portlet.setId( daoUtil.getInt( 1 ) );
  297.                 portlet.setPortletTypeId( daoUtil.getString( 2 ) );
  298.                 portlet.setPageId( daoUtil.getInt( 3 ) );
  299.                 portlet.setName( daoUtil.getString( 4 ) );
  300.                 portlet.setDateUpdate( daoUtil.getTimestamp( 5 ) );
  301.                 portlet.setStatus( daoUtil.getInt( 6 ) );
  302.                 portlet.setOrder( daoUtil.getInt( 7 ) );
  303.                 portlet.setColumn( daoUtil.getInt( 8 ) );
  304.                 portlet.setStyleId( daoUtil.getInt( 9 ) );
  305.                 portlet.setAcceptAlias( daoUtil.getInt( 10 ) );
  306.                 portlet.setDateUpdate( daoUtil.getTimestamp( 11 ) );
  307.                 portlet.setDisplayPortletTitle( daoUtil.getInt( 12 ) );
  308.                 portlet.setRole( daoUtil.getString( 13 ) );
  309.                 portlet.setDeviceDisplayFlags( daoUtil.getInt( 14 ) );

  310.                 list.add( portlet );
  311.             }

  312.         }

  313.         return list;
  314.     }

  315.     /**
  316.      * {@inheritDoc}
  317.      */
  318.     public ReferenceList selectStylesList( String strPortletTypeId )
  319.     {
  320.         ReferenceList list = new ReferenceList( );
  321.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_STYLE_LIST ) )
  322.         {
  323.             daoUtil.setString( 1, strPortletTypeId );
  324.             daoUtil.executeQuery( );

  325.             while ( daoUtil.next( ) )
  326.             {
  327.                 list.addItem( daoUtil.getInt( 1 ), daoUtil.getString( 2 ) );
  328.             }

  329.         }

  330.         return list;
  331.     }

  332.     /**
  333.      * {@inheritDoc}
  334.      */
  335.     public boolean hasAlias( int nPortletId )
  336.     {
  337.         boolean bHasAlias = false;
  338.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_PORTLET_ALIAS ) )
  339.         {
  340.             daoUtil.setInt( 1, nPortletId );

  341.             daoUtil.executeQuery( );

  342.             if ( daoUtil.next( ) )
  343.             {
  344.                 bHasAlias = true;
  345.             }

  346.         }

  347.         return bHasAlias;
  348.     }

  349.     /**
  350.      * {@inheritDoc}
  351.      */
  352.     public PortletType selectPortletType( String strPortletTypeId )
  353.     {
  354.         PortletType portletType = new PortletType( );
  355.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_PORTLET_TYPE ) )
  356.         {

  357.             daoUtil.setString( 1, strPortletTypeId );
  358.             daoUtil.executeQuery( );

  359.             if ( daoUtil.next( ) )
  360.             {
  361.                 portletType.setId( daoUtil.getString( 1 ) );
  362.                 portletType.setNameKey( daoUtil.getString( 2 ) );
  363.                 portletType.setUrlCreation( daoUtil.getString( 3 ) );
  364.                 portletType.setUrlUpdate( daoUtil.getString( 4 ) );
  365.                 portletType.setPluginName( daoUtil.getString( 5 ) );
  366.             }

  367.         }

  368.         return portletType;
  369.     }

  370.     /**
  371.      * {@inheritDoc}
  372.      */
  373.     public Collection<PortletImpl> selectPortletListByStyle( int nStyleId )
  374.     {
  375.         Collection<PortletImpl> portletList = new ArrayList<>( );
  376.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_PORTLET_LIST_BY_STYLE ) )
  377.         {

  378.             daoUtil.setInt( 1, nStyleId );
  379.             daoUtil.executeQuery( );

  380.             while ( daoUtil.next( ) )
  381.             {
  382.                 PortletImpl portlet = new PortletImpl( );

  383.                 portlet.setId( daoUtil.getInt( 1 ) );
  384.                 portlet.setName( daoUtil.getString( 2 ) );
  385.                 portlet.setPageId( daoUtil.getInt( 3 ) );

  386.                 portletList.add( portlet );
  387.             }

  388.         }

  389.         return portletList;
  390.     }

  391.     /**
  392.      * {@inheritDoc }
  393.      */
  394.     public Collection<Portlet> selectPortletsByRole( String strRole )
  395.     {
  396.         List<Portlet> list = new ArrayList<>( );
  397.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_PORTLET_LIST_BY_ROLE ) )
  398.         {
  399.             daoUtil.setString( 1, strRole );
  400.             daoUtil.executeQuery( );

  401.             while ( daoUtil.next( ) )
  402.             {
  403.                 PortletImpl portlet = new PortletImpl( );
  404.                 portlet.setId( daoUtil.getInt( 1 ) );
  405.                 portlet.setPortletTypeId( daoUtil.getString( 2 ) );
  406.                 portlet.setPageId( daoUtil.getInt( 3 ) );

  407.                 list.add( portlet );
  408.             }

  409.         }

  410.         return list;
  411.     }

  412.     /**
  413.      * {@inheritDoc}
  414.      */
  415.     public Portlet loadLastModifiedPortlet( )
  416.     {
  417.         PortletImpl portlet = null;
  418.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_LAST_MODIFIED_PORTLET ) )
  419.         {
  420.             daoUtil.executeQuery( );

  421.             if ( daoUtil.next( ) )
  422.             {
  423.                 portlet = new PortletImpl( );

  424.                 int nIndex = 1;
  425.                 portlet.setId( daoUtil.getInt( nIndex++ ) );
  426.                 portlet.setPortletTypeId( daoUtil.getString( nIndex++ ) );
  427.                 portlet.setPageId( daoUtil.getInt( nIndex++ ) );
  428.                 portlet.setStyleId( daoUtil.getInt( nIndex++ ) );
  429.                 portlet.setName( daoUtil.getString( nIndex++ ) );
  430.                 portlet.setPortletTypeName( daoUtil.getString( nIndex++ ) );
  431.                 portlet.setUrlCreation( daoUtil.getString( nIndex++ ) );
  432.                 portlet.setUrlUpdate( daoUtil.getString( nIndex++ ) );
  433.                 portlet.setDateUpdate( daoUtil.getTimestamp( nIndex++ ) );
  434.                 portlet.setColumn( daoUtil.getInt( nIndex++ ) );
  435.                 portlet.setOrder( daoUtil.getInt( nIndex++ ) );
  436.                 portlet.setHomeClassName( daoUtil.getString( nIndex++ ) );
  437.                 portlet.setAcceptAlias( daoUtil.getInt( nIndex++ ) );
  438.                 portlet.setRole( daoUtil.getString( nIndex++ ) );
  439.                 portlet.setPluginName( daoUtil.getString( nIndex++ ) );
  440.                 portlet.setDisplayPortletTitle( daoUtil.getInt( nIndex++ ) );
  441.                 portlet.setStatus( daoUtil.getInt( nIndex++ ) );
  442.                 portlet.setDeviceDisplayFlags( daoUtil.getInt( nIndex++ ) );
  443.             }

  444.         }

  445.         return portlet;
  446.     }

  447.     /**
  448.      * {@inheritDoc}
  449.      */
  450.     @Override
  451.     public List<Integer> getUsedOrdersForColumns( int pageId, int columnId )
  452.     {
  453.         List<Integer> result = new ArrayList<>( );
  454.         try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_ORDER_FROM_PAGE_AND_COLUMN ) )
  455.         {
  456.             daoUtil.setInt( 1, columnId );
  457.             daoUtil.setInt( 2, pageId );

  458.             daoUtil.executeQuery( );

  459.             while ( daoUtil.next( ) )
  460.             {
  461.                 result.add( daoUtil.getInt( 1 ) );
  462.             }

  463.         }

  464.         return result;
  465.     }
  466. }