Coverage Report - fr.paris.lutece.plugins.adminsql.business.DataHome
 
Classes in this File Line Coverage Branch Coverage Complexity
DataHome
0 %
0/15
N/A
1
 
 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  
 /*
 35  
  * DataHome.java
 36  
  *
 37  
  * Created on 24 octobre 2008, 14:53
 38  
  *
 39  
  * To change this template, choose Tools | Template Manager
 40  
  * and open the template in the editor.
 41  
  */
 42  
 package fr.paris.lutece.plugins.adminsql.business;
 43  
 
 44  
 import fr.paris.lutece.portal.service.database.PluginConnectionService;
 45  
 import fr.paris.lutece.portal.service.spring.SpringContextService;
 46  
 
 47  
 
 48  
 import java.util.List;
 49  
 
 50  
 
 51  
 /**
 52  
  * The class calling the business objects
 53  
  */
 54  0
 public class DataHome
 55  
 {
 56  0
     private static IDataDAO _dao = (IDataDAO) SpringContextService.getPluginBean( "adminsql", "dataDAO" );
 57  
 
 58  
     /**
 59  
      * Creates a new instance of DataHome
 60  
      * @param strTableName Name of the table
 61  
      * @param connectionService Plugin connectionService
 62  
      * @return List of all data in a table
 63  
      */
 64  
     public static List<List<String>> findAll( String strTableName, PluginConnectionService connectionService )
 65  
     {
 66  0
         return _dao.selectDataList( strTableName, connectionService );
 67  
     }
 68  
 
 69  
     /**
 70  
      * List of data of user request
 71  
      * @param strPoolName Name of the pool
 72  
      * @param strUserRequest User Request
 73  
      * @param connectionService PluginConnectionService
 74  
      * @return List of data of user request
 75  
      */
 76  
     public static List<List<String>> findAllInUserRequest( String strPoolName, String strUserRequest,
 77  
         PluginConnectionService connectionService )
 78  
     {
 79  0
         return _dao.selectDataListUserRequest( strPoolName, strUserRequest, connectionService );
 80  
     }
 81  
 
 82  
     /**
 83  
      * Create an instance of data
 84  
      * @param strPoolName the name of the current pool
 85  
      * @param strTableName the name of the table
 86  
      * @param listData data to insert
 87  
      * @param listFieldsNames fields of a table
 88  
      * @param connectionService PluginConnectionService
 89  
      * @return list of data
 90  
      */
 91  
     public static List<String> create( String strPoolName, String strTableName, List<String> listData,
 92  
         List<String> listFieldsNames, PluginConnectionService connectionService )
 93  
     {
 94  0
         _dao.insert( strPoolName, strTableName, listData, listFieldsNames, connectionService );
 95  
 
 96  0
         return listData;
 97  
     }
 98  
 
 99  
     /**
 100  
      * Create an instance of data with user request
 101  
      * @param strUserRequest user request
 102  
      * @param connectionService PluginConnctionSerice object
 103  
      * @param strPoolName the name of the pool
 104  
      */
 105  
     public static void createWithUserRequest( String strUserRequest, PluginConnectionService connectionService,
 106  
         String strPoolName )
 107  
     {
 108  0
         _dao.insertWithUserRequest( strUserRequest, connectionService, strPoolName );
 109  0
     }
 110  
 
 111  
     /**
 112  
      * find a row of a table
 113  
      * @param strTableName the name of the table
 114  
      * @param strContatFieldNameAndData the concatenation of the field name and the data
 115  
      * @param listFields list of field table
 116  
      * @param connectionService PluginConnectionService object
 117  
      * @return a row of a table
 118  
      */
 119  
     public static List<List<String>> findByPrimaryKey( String strTableName, String strContatFieldNameAndData,
 120  
         List<Field> listFields, PluginConnectionService connectionService )
 121  
     {
 122  0
         return _dao.load( strTableName, strContatFieldNameAndData, listFields, connectionService );
 123  
     }
 124  
 
 125  
     /**
 126  
      * Result of a select request type
 127  
      * @param strUserRequest user request
 128  
      * @param connectionService PluginConnectionService object
 129  
      * @return the result of the user request
 130  
      */
 131  
     public static List<List<String>> userRequest( String strUserRequest, PluginConnectionService connectionService )
 132  
     {
 133  0
         return _dao.findResultOfUserRequest( strUserRequest, connectionService );
 134  
     }
 135  
 
 136  
     /**
 137  
      * Find fields names of a table for user request
 138  
      * @param strUserRequest user request
 139  
      * @param connectionService PluginConnectionService object
 140  
      * @param strPoolName the name of the pool
 141  
      * @return list of fields names
 142  
      */
 143  
     public static List<String> findFieldsNames( String strUserRequest, PluginConnectionService connectionService,
 144  
         String strPoolName )
 145  
     {
 146  0
         return _dao.selectColumnNames( strUserRequest, connectionService, strPoolName );
 147  
     }
 148  
 
 149  
     /**
 150  
      * Update a row in a table
 151  
      * @param strPoolName the name of the pool
 152  
      * @param strTableName the name of the table
 153  
      * @param listFieldValues list of table fields
 154  
      * @param connectionService PluginConnectionService object
 155  
      */
 156  
     public static void update( String strPoolName, String strTableName, List<FieldValues> listFieldValues,
 157  
         PluginConnectionService connectionService )
 158  
     {
 159  0
         _dao.store( strPoolName, strTableName, listFieldValues, connectionService );
 160  0
     }
 161  
 
 162  
     /**
 163  
      * Delete a row
 164  
      * @param strPoolName the name of the pool
 165  
      * @param strTableName the name of the table
 166  
      * @param listConcatFieldNameAndData list of concatenation of field name and data
 167  
      * @param connectionService PluginConnectionService object
 168  
      */
 169  
     public static void remove( String strPoolName, String strTableName, List<String> listConcatFieldNameAndData,
 170  
         PluginConnectionService connectionService )
 171  
     {
 172  0
         _dao.delete( strPoolName, strTableName, listConcatFieldNameAndData, connectionService );
 173  0
     }
 174  
 }