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.updatercatalog.business; 35 36 import fr.paris.lutece.portal.service.plugin.Plugin; 37 import fr.paris.lutece.portal.service.plugin.PluginService; 38 import fr.paris.lutece.portal.service.spring.SpringContextService; 39 import fr.paris.lutece.util.ReferenceList; 40 41 import java.util.List; 42 43 44 /** 45 * This class provides instances management methods (create, find, ...) for CatalogPlugin objects 46 */ 47 public final class CatalogPluginHome 48 { 49 // Static variable pointed at the DAO instance 50 private static ICatalogPluginDAO _dao = (ICatalogPluginDAO) SpringContextService.getPluginBean( "updatercatalog", 51 "updatercatalog.catalogPluginDAO" ); 52 private static Plugin _plugin = PluginService.getPlugin( "updatercatalog" ); 53 54 /** 55 * Private constructor - this class need not be instantiated 56 */ 57 private CatalogPluginHome( ) 58 { 59 } 60 61 /** 62 * Create an instance of the catalogPlugin class 63 * @param catalogPlugin The instance of the CatalogPlugin which contains the informations to store 64 * @return The instance of catalogPlugin which has been created with its primary key. 65 */ 66 public static CatalogPlugin create( CatalogPlugin catalogPlugin ) 67 { 68 _dao.insert( catalogPlugin, _plugin ); 69 70 return catalogPlugin; 71 } 72 73 /** 74 * Update of the catalogPlugin which is specified in parameter 75 * @param catalogPlugin The instance of the CatalogPlugin which contains the data to store 76 * @return The instance of the catalogPlugin which has been updated 77 */ 78 public static CatalogPlugin update( CatalogPlugin catalogPlugin ) 79 { 80 _dao.store( catalogPlugin, _plugin ); 81 82 return catalogPlugin; 83 } 84 85 /** 86 * Remove the catalogPlugin whose identifier is specified in parameter 87 * @param strPluginName The catalogPlugin Id 88 * @param strLocale The Locale 89 */ 90 public static void remove( String strPluginName, String strLocale ) 91 { 92 _dao.delete( strPluginName, strLocale, _plugin ); 93 } 94 95 /////////////////////////////////////////////////////////////////////////// 96 // Finders 97 /** 98 * Returns an instance of a catalogPlugin whose identifier is specified in parameter 99 * @param strPluginName The catalogPlugin primary key 100 * @param strLocale The Locale 101 * @return an instance of CatalogPlugin 102 */ 103 public static CatalogPlugin findByPrimaryKey( String strPluginName, String strLocale ) 104 { 105 return _dao.load( strPluginName, strLocale, _plugin ); 106 } 107 108 /** 109 * Load the data of all the catalogPlugin objects and returns them in form of a List 110 * @return the List which contains the data of all the catalogPlugin objects 111 */ 112 public static List<CatalogPlugin> findAll( ) 113 { 114 return _dao.selectCatalogPluginsList( _plugin ); 115 } 116 117 /** 118 * Returns a list of plugins for a given locale 119 * @param strLocale The locale as String 120 * @return The list of plugins 121 */ 122 public static ReferenceList selectPluginsListByLocale( String strLocale ) 123 { 124 return _dao.selectPluginsListByLocale( _plugin, strLocale ); 125 } 126 127 /** 128 * Returns a list of plugins for a given locale 129 * @param strLocale The locale 130 * @return The list of plugins 131 */ 132 public static List<CatalogPluginEntry> getAvailablePluginsByLocale( String strLocale ) 133 { 134 return _dao.selectAvailablePluginsByLocale( _plugin, strLocale ); 135 } 136 137 /** 138 * Gets the list of all plugins 139 * @return A reference list 140 */ 141 public static ReferenceList getPlugins( ) 142 { 143 return _dao.getPlugins( _plugin ); 144 } 145 }