1 /* 2 * Copyright (c) 2002-2023, 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 35 36 package fr.paris.lutece.plugins.broadcastproxy.business; 37 38 import fr.paris.lutece.portal.service.plugin.Plugin; 39 import fr.paris.lutece.portal.service.plugin.PluginService; 40 import fr.paris.lutece.portal.service.spring.SpringContextService; 41 import fr.paris.lutece.util.ReferenceList; 42 43 44 import java.util.List; 45 import java.util.Optional; 46 47 /** 48 * This class provides instances management methods (create, find, ...) for SubscriptionLink objects 49 */ 50 public final class SubscriptionLinkHome 51 { 52 // Static variable pointed at the DAO instance 53 private static ISubscriptionLinkDAO _dao = SpringContextService.getBean( "broadcastproxy.subscriptionLinkDAO" ); 54 private static Plugin _plugin = PluginService.getPlugin( "broadcastproxy" ); 55 56 /** 57 * Private constructor - this class need not be instantiated 58 */ 59 private SubscriptionLinkHome( ) 60 { 61 } 62 63 /** 64 * Create an instance of the subscriptionLink class 65 * @param subscriptionLink The instance of the SubscriptionLink which contains the informations to store 66 * @return The instance of subscriptionLink which has been created with its primary key. 67 */ 68 public static SubscriptionLink/../../../fr/paris/lutece/plugins/broadcastproxy/business/SubscriptionLink.html#SubscriptionLink">SubscriptionLink create( SubscriptionLink subscriptionLink ) 69 { 70 _dao.insert( subscriptionLink, _plugin ); 71 72 return subscriptionLink; 73 } 74 75 /** 76 * Update of the subscriptionLink which is specified in parameter 77 * @param subscriptionLink The instance of the SubscriptionLink which contains the data to store 78 * @return The instance of the subscriptionLink which has been updated 79 */ 80 public static SubscriptionLink/../../../fr/paris/lutece/plugins/broadcastproxy/business/SubscriptionLink.html#SubscriptionLink">SubscriptionLink update( SubscriptionLink subscriptionLink ) 81 { 82 _dao.store( subscriptionLink, _plugin ); 83 84 return subscriptionLink; 85 } 86 87 /** 88 * Remove the subscriptionLink whose identifier is specified in parameter 89 * @param nKey The subscriptionLink Id 90 */ 91 public static void remove( int nKey ) 92 { 93 _dao.delete( nKey, _plugin ); 94 } 95 96 /** 97 * Returns an instance of a subscriptionLink whose identifier is specified in parameter 98 * @param nKey The subscriptionLink primary key 99 * @return an instance of SubscriptionLink 100 */ 101 public static Optional<SubscriptionLink> findByPrimaryKey( int nKey ) 102 { 103 return _dao.load( nKey, _plugin ); 104 } 105 106 /** 107 * Returns an instance of a subscriptionLink whose identifier is specified in parameter 108 * @param nSubscriptionId The subscriptionLink subscription id 109 * @return an instance of SubscriptionLink 110 */ 111 public static Optional<SubscriptionLink> findBySubscriptionId ( int nSubscriptionId ) 112 { 113 return _dao.loadBySubscriptionId( nSubscriptionId, _plugin ); 114 } 115 116 /** 117 * Load the data of all the subscriptionLink objects and returns them as a list 118 * @return the list which contains the data of all the subscriptionLink objects 119 */ 120 public static List<SubscriptionLink> getSubscriptionLinksList( ) 121 { 122 return _dao.selectSubscriptionLinksList( _plugin ); 123 } 124 125 /** 126 * Load the id of all the subscriptionLink objects and returns them as a list 127 * @return the list which contains the id of all the subscriptionLink objects 128 */ 129 public static List<Integer> getIdSubscriptionLinksList( ) 130 { 131 return _dao.selectIdSubscriptionLinksList( _plugin ); 132 } 133 134 /** 135 * Load the data of all the subscriptionLink objects and returns them as a referenceList 136 * @return the referenceList which contains the data of all the subscriptionLink objects 137 */ 138 public static ReferenceList getSubscriptionLinksReferenceList( ) 139 { 140 return _dao.selectSubscriptionLinksReferenceList( _plugin ); 141 } 142 143 144 /** 145 * Load the data of all the avant objects and returns them as a list 146 * @param listIds liste of ids 147 * @return the list which contains the data of all the avant objects 148 */ 149 public static List<SubscriptionLink> getSubscriptionLinksListByIds( List<Integer> listIds ) 150 { 151 return _dao.selectSubscriptionLinksListByIds( _plugin, listIds ); 152 } 153 154 /** 155 * Return true if exist disabled newsletter 156 * @param plugin 157 * @return Return true if exist disabled newsletter 158 */ 159 public static boolean existDisabledNewsletter ( ) 160 { 161 return _dao.existDisabledNewsletter( _plugin ); 162 } 163 164 } 165