Coverage Report - fr.paris.lutece.plugins.announce.modules.workflow.business.TaskChangeAnnounceStatusConfigDAO
 
Classes in this File Line Coverage Branch Coverage Complexity
TaskChangeAnnounceStatusConfigDAO
0 %
0/31
0 %
0/2
1,25
 
 1  
 /*
 2  
  * Copyright (c) 2002-2017, Mairie de 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.plugins.announce.modules.workflow.business;
 35  
 
 36  
 import fr.paris.lutece.plugins.announce.modules.workflow.service.AnnounceWorkflowPlugin;
 37  
 import fr.paris.lutece.plugins.workflowcore.business.config.ITaskConfigDAO;
 38  
 import fr.paris.lutece.util.sql.DAOUtil;
 39  
 
 40  
 
 41  
 /**
 42  
  * TaskChangeAnnounceStatusConfigDAO
 43  
  */
 44  0
 public class TaskChangeAnnounceStatusConfigDAO implements ITaskConfigDAO<TaskChangeAnnounceStatusConfig>
 45  
 {
 46  
     private static final String SQL_QUERY_FIND_BY_PRIMARY_KEY = "SELECT id_task,announce_published "
 47  
             + "FROM workflow_task_change_announce_status_cf WHERE id_task=?";
 48  
     private static final String SQL_QUERY_INSERT = "INSERT INTO workflow_task_change_announce_status_cf( "
 49  
             + "id_task,announce_published)" + "VALUES (?,?)";
 50  
     private static final String SQL_QUERY_UPDATE = "UPDATE workflow_task_change_announce_status_cf SET announce_published = ?"
 51  
             + " WHERE id_task = ? ";
 52  
     private static final String SQL_QUERY_DELETE = "DELETE FROM workflow_task_change_announce_status_cf WHERE id_task = ? ";
 53  
 
 54  
     /**
 55  
      * {@inheritDoc}
 56  
      */
 57  
     @Override
 58  
     public synchronized void insert( TaskChangeAnnounceStatusConfig config )
 59  
     {
 60  0
         DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT, AnnounceWorkflowPlugin.getPlugin( ) );
 61  
 
 62  0
         int nPos = 0;
 63  
 
 64  0
         daoUtil.setInt( ++nPos, config.getIdTask( ) );
 65  0
         daoUtil.setBoolean( ++nPos, config.getPublish( ) );
 66  
 
 67  0
         daoUtil.executeUpdate( );
 68  0
         daoUtil.free( );
 69  0
     }
 70  
 
 71  
     /**
 72  
      * {@inheritDoc}
 73  
      */
 74  
     @Override
 75  
     public void store( TaskChangeAnnounceStatusConfig config )
 76  
     {
 77  0
         DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE, AnnounceWorkflowPlugin.getPlugin( ) );
 78  
 
 79  0
         int nPos = 0;
 80  
 
 81  0
         daoUtil.setBoolean( ++nPos, config.getPublish( ) );
 82  
 
 83  0
         daoUtil.setInt( ++nPos, config.getIdTask( ) );
 84  0
         daoUtil.executeUpdate( );
 85  0
         daoUtil.free( );
 86  0
     }
 87  
 
 88  
     /**
 89  
      * {@inheritDoc}
 90  
      */
 91  
     @Override
 92  
     public TaskChangeAnnounceStatusConfig load( int nIdTask )
 93  
     {
 94  0
         TaskChangeAnnounceStatusConfig config = null;
 95  0
         DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_BY_PRIMARY_KEY, AnnounceWorkflowPlugin.getPlugin( ) );
 96  
 
 97  0
         daoUtil.setInt( 1, nIdTask );
 98  
 
 99  0
         daoUtil.executeQuery( );
 100  
 
 101  0
         int nPos = 0;
 102  
 
 103  0
         if ( daoUtil.next( ) )
 104  
         {
 105  0
             config = new TaskChangeAnnounceStatusConfig( );
 106  0
             config.setIdTask( daoUtil.getInt( ++nPos ) );
 107  0
             config.setPublish( daoUtil.getBoolean( ++nPos ) );
 108  
         }
 109  
 
 110  0
         daoUtil.free( );
 111  
 
 112  0
         return config;
 113  
     }
 114  
 
 115  
     /**
 116  
      * {@inheritDoc}
 117  
      */
 118  
     @Override
 119  
     public void delete( int nIdState )
 120  
     {
 121  0
         DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE, AnnounceWorkflowPlugin.getPlugin( ) );
 122  
 
 123  0
         daoUtil.setInt( 1, nIdState );
 124  0
         daoUtil.executeUpdate( );
 125  0
         daoUtil.free( );
 126  0
     }
 127  
 }