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.links.business.portlet; 35 36 import fr.paris.lutece.plugins.links.business.Link; 37 import fr.paris.lutece.portal.business.portlet.IPortletInterfaceDAO; 38 import fr.paris.lutece.portal.business.portlet.Portlet; 39 import fr.paris.lutece.util.ReferenceList; 40 41 import java.util.Collection; 42 43 44 public interface ILinksPortletDAO extends IPortletInterfaceDAO 45 { 46 /** 47 * Insert the portlet 48 * 49 * @param portlet The Portlet object 50 */ 51 void insert( Portlet portlet ); 52 53 /** 54 * Insert a new record in the table. 55 * 56 * @param nPortletId The identifier of the portlet 57 * @param nLinkId The identifier of the link 58 * @param nOrder The order of the portlet to insert 59 */ 60 void insertLink( int nPortletId, int nLinkId, int nOrder ); 61 62 /** 63 * Remove a specified link from a specified portlet 64 * 65 * @param nPortletId The identifier of the portlet 66 * @param nLinkId The identifier of the link 67 */ 68 void deleteLink( int nPortletId, int nLinkId ); 69 70 /** 71 * Deletes the portlet whose identifier is specified in parameter 72 * 73 * @param nPortletId The identifier of the portlet 74 */ 75 void delete( int nPortletId ); 76 77 /** 78 * Load the portlet whose identifier is specified in parameter 79 * 80 * @param nPortletId the identifier of the portlet 81 * @return The portlet instance 82 */ 83 Portlet load( int nPortletId ); 84 85 /** 86 * Update the portlet 87 * 88 * @param portlet The portlet object 89 */ 90 void store( Portlet portlet ); 91 92 /** 93 * Returns a list of all the links 94 * 95 * @return A list of links in form of a ReferenceList object 96 */ 97 ReferenceList selectLinksList( ); 98 99 /** 100 * Check if a specified links is not already registered in a specified portlet 101 * 102 * @param nPortletId The identifier of the portlet 103 * @param nLinkId The identifier of the link 104 * @return The result(boolean) 105 */ 106 boolean testDuplicate( int nPortletId, int nLinkId ); 107 108 /** 109 * Return a list of links wich belong to a specified portlet 110 * 111 * @param nPortletId The identifier of the portlet 112 * @return A collection of links objects 113 */ 114 Collection<Link> selectLinksInPortletList( int nPortletId ); 115 116 /** 117 * Return the order of a specified link in a specified portlet 118 * 119 * @param nPortletId The identifier of the portlet 120 * @param nLinkId The identifier of the link 121 * @return The link's order 122 */ 123 int selectLinkOrder( int nPortletId, int nLinkId ); 124 125 /** 126 * Calculate a new primary key to add a new link 127 * 128 * @param nPortletId The identifier of the portlet 129 * @return The new key. 130 */ 131 int selectMaxOrder( int nPortletId ); 132 133 /** 134 * Returns the maximum order of the portlets in the links page 135 * 136 * @return the max order 137 */ 138 int selectPortletMaxOrder( ); 139 140 /** 141 * Update the order of a specified link in a specified portlet 142 * 143 * @param nPortletId The identifier of the portlet 144 * @param nLinkId The identifier of the link 145 * @param nOrder The new order 146 */ 147 void storeLinkOrder( int nOrder, int nPortletId, int nLinkId ); 148 149 /** 150 * Returns the id of an link wich has a specified order in a specified portlet 151 * 152 * @param nPortletId The identifier of the portlet 153 * @param nOrder The link's order 154 * @return The identifier of the link 155 */ 156 int selectLinkIdByOrder( int nPortletId, int nOrder ); 157 158 /** 159 * Finds the portlets which have not been selected in the links page 160 * 161 * @return the list of the unselected portlets 162 */ 163 ReferenceList findUnselectedPortlets( ); 164 165 /** 166 * Selects the list of the portlets in the links page 167 * 168 * @return a collection of the unselected portlets 169 */ 170 Collection<Portlet> selectPortletsInLinksPage( ); 171 172 /** 173 * Selects the order of a portlet in the links page 174 * 175 * @param nPortletId The identifier of the portlet 176 * @return the order 177 */ 178 int selectPortletOrder( int nPortletId ); 179 180 /** 181 * Remove a portlet from the links page 182 * 183 * @param nPortletId The identifier of the portlet 184 */ 185 void removePortlet( int nPortletId ); 186 187 /** 188 * Removes a link from all the portlets 189 * 190 * @param nLinkId The identifier of the link 191 */ 192 void removeLinkFromPortlets( int nLinkId ); 193 194 /** 195 * Insert a new portlet in the links page 196 * 197 * @param nPortletId The identifier of the portlet 198 * @param nOrder The order of the portlet 199 */ 200 void insertPortlet( int nPortletId, int nOrder ); 201 202 /** 203 * Selects a portlet Id from the links page by its order 204 * 205 * @param nOrder The order of the portlet 206 * @return the portlet Id 207 */ 208 int selectPortletIdByOrder( int nOrder ); 209 210 /** 211 * Stores the order of a portlet in the links page 212 * 213 * @param nOrder The order of the portlet 214 * @param nPortletId The identifier of the portlet 215 */ 216 void storePortletOrder( int nOrder, int nPortletId ); 217 }