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.directory.service.record; 35 36 import fr.paris.lutece.plugins.directory.business.Record; 37 import fr.paris.lutece.plugins.directory.business.RecordFieldFilter; 38 import fr.paris.lutece.portal.service.plugin.Plugin; 39 40 import javax.servlet.http.HttpServletRequest; 41 42 import org.springframework.transaction.annotation.Transactional; 43 44 import java.util.List; 45 46 /** 47 * 48 * IRecordService 49 * 50 */ 51 public interface IRecordService 52 { 53 /** 54 * Creation of an instance of record 55 * 56 * @param record 57 * The instance of the record which contains the informations to store 58 * @param plugin 59 * the Plugin 60 * @return the id of the new record 61 */ 62 @Transactional( "directory.transactionManager" ) 63 int create( Record record, Plugin plugin ); 64 65 /** 66 * Copy an instance of record 67 * 68 * @param record 69 * The instance of the record who must copy 70 * @param plugin 71 * the Plugin 72 * @return the id of the record 73 */ 74 @Transactional( "directory.transactionManager" ) 75 int copy( Record record, Plugin plugin ); 76 77 /** 78 * Update of the record which is specified in parameter 79 * 80 * @param record 81 * The instance of the record which contains the informations to update 82 * @param plugin 83 * the Plugin 84 */ 85 @Transactional( "directory.transactionManager" ) 86 void updateWidthRecordField( Record record, Plugin plugin ); 87 88 /** 89 * Update of the record 90 * 91 * @param record 92 * The instance of the record which contains the informations to update 93 * @param plugin 94 * the Plugin 95 */ 96 @Transactional( "directory.transactionManager" ) 97 void update( Record record, Plugin plugin ); 98 99 /** 100 * Remove the record whose identifier is specified in parameter 101 * 102 * @param nIdRecord 103 * The recordId 104 * @param plugin 105 * the Plugin 106 */ 107 @Transactional( "directory.transactionManager" ) 108 void remove( int nIdRecord, Plugin plugin ); 109 110 // ///////////////////////////////////////////////////////////////////////// 111 // Finders 112 113 /** 114 * Returns an instance of a recordwhose identifier is specified in parameter 115 * 116 * @param nKey 117 * The formResponse primary key 118 * @param plugin 119 * the Plugin 120 * @return an instance of FormResponse 121 */ 122 Record findByPrimaryKey( int nKey, Plugin plugin ); 123 124 /** 125 * Test if the given directory record list has a worflow 126 * 127 * @param nIdDirectory 128 * directory Id 129 * @param plugin 130 * the plugin 131 * @return true if has at least one 132 */ 133 Boolean directoryRecordListHasWorkflow( int nIdDirectory, Plugin plugin ); 134 135 /** 136 * Load a list of record 137 * 138 * @param lIdList 139 * list of record id 140 * @param plugin 141 * the plugin 142 * @return list of Record 143 */ 144 List<Record> loadListByListId( List<Integer> lIdList, Plugin plugin ); 145 146 /** 147 * Load the data of all the record who verify the filter and returns them in a list 148 * 149 * @param filter 150 * the filter 151 * @param plugin 152 * the plugin 153 * @return the list of record 154 */ 155 List<Record> getListRecord( RecordFieldFilter filter, Plugin plugin ); 156 157 /** 158 * Count record who verify the filter 159 * 160 * @param filter 161 * the filter 162 * @param plugin 163 * the plugin 164 * @return the number of record 165 */ 166 int getCountRecord( RecordFieldFilter filter, Plugin plugin ); 167 168 /** 169 * Load the data of all the record who verify the filter and returns them in a list 170 * 171 * @param filter 172 * the filter 173 * @param plugin 174 * the plugin 175 * @return the list of record 176 */ 177 List<Integer> getListRecordId( RecordFieldFilter filter, Plugin plugin ); 178 179 /** 180 * Get directory id by by record id 181 * 182 * @param nRecordId 183 * the record id 184 * @param plugin 185 * the plugin 186 * @return the directory id 187 */ 188 Integer getDirectoryIdByRecordId( Integer nRecordId, Plugin plugin ); 189 190 /** 191 * Is the file authorized for viewing. 192 * 193 * This checks for front and back access rules and does an OR. 194 * 195 * @param nFileId 196 * the file id 197 * @param request 198 * the request 199 * @param plugin 200 * the plugin 201 * @return the directory id 202 */ 203 boolean isFileAuthorized( int nFileId, HttpServletRequest request, Plugin plugin ); 204 }