1 /* 2 * Copyright (c) 2002-2022, 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 package fr.paris.lutece.plugins.dansmarue.modules.rest.service; 35 36 import java.io.InputStream; 37 import java.util.Collection; 38 import java.util.List; 39 40 import javax.servlet.http.HttpServletRequest; 41 42 import fr.paris.lutece.plugins.dansmarue.business.entities.Arrondissement; 43 import fr.paris.lutece.plugins.dansmarue.business.entities.Priorite; 44 import fr.paris.lutece.plugins.dansmarue.business.entities.Signalement; 45 import fr.paris.lutece.plugins.dansmarue.modules.rest.pojo.SignalementsPOJO; 46 import fr.paris.lutece.plugins.dansmarue.modules.rest.util.exception.ParseSignalementFromJSONException; 47 import fr.paris.lutece.plugins.dansmarue.service.dto.DossierSignalementDTO; 48 import fr.paris.lutece.plugins.dansmarue.web.SignalementJspBean; 49 import fr.paris.lutece.plugins.leaflet.modules.dansmarue.entities.Address; 50 import fr.paris.lutece.plugins.workflowcore.business.action.Action; 51 import fr.paris.lutece.portal.business.user.AdminUser; 52 import net.sf.json.JSONObject; 53 54 /** 55 * ISignalementRestService. 56 */ 57 public interface ISignalementRestService 58 { 59 /** 60 * Method to check the request and use specific function to answer to request. 61 * 62 * @param strRequest 63 * the json stream sended by request 64 * @param request 65 * the http request 66 * @return the answer to request 67 * @throws ParseSignalementFromJSONException 68 * parse exception 69 */ 70 String processResquestAnswer( String strRequest, HttpServletRequest request ) throws ParseSignalementFromJSONException; 71 72 /** 73 * This function send incident statistics, it is used at application launch. 74 * 75 * @param jsonSrc 76 * json stream 77 * @param request 78 * the http request 79 * @return the answer 80 */ 81 String getIncidentStats( JSONObject jsonSrc, HttpServletRequest request ); 82 83 /** 84 * This request is used to get an incident by its identifier. 85 * 86 * @param jsonSrc 87 * json stream 88 * @return json response 89 */ 90 String getIncidentsById( JSONObject jsonSrc ); 91 92 /** 93 * This request is sent to make a list of the closest incidents to the user's geographical position. 94 * 95 * @param jsonSrc 96 * json stream 97 * @return json respons 98 */ 99 String getIncidentsByPosition( JSONObject jsonSrc ); 100 101 /** 102 * Save a report. 103 * 104 * @param jsonSrc 105 * json stream 106 * @return json response 107 * @throws ParseSignalementFromJSONException 108 * {@link SignalementJspBean} 109 */ 110 String saveIncident( JSONObject jsonSrc ) throws ParseSignalementFromJSONException; 111 112 /** 113 * This request is sent by the application to get the list of all the ongoing incidents that user has created, updated and all the incidents the user 114 * declared as resolved. 115 * 116 * @param jsonSrc 117 * json stream 118 * @return json response 119 */ 120 String getReports( JSONObject jsonSrc ); 121 122 /** 123 * This request is sent to update an existing incident. This update of the incident means to change the state of the incident. Addnd a new picture is done 124 * by an other interface and request. 125 * 126 * @param jsonSrc 127 * json stream 128 * @param request 129 * the http request 130 * @return json response 131 */ 132 String updateIncident( JSONObject jsonSrc, HttpServletRequest request ); 133 134 /** 135 * This request is sent to update an existing report. This update of the report means to change the precision terrain of the report. 136 * 137 * @param jsonSrc 138 * json stream 139 * @return json response 140 */ 141 String savePrecisionsTerrain( JSONObject jsonSrc ); 142 143 /** 144 * This request is sent to update a feuille de tournee. This update of the report means to change the infos apres tournee of the incident 145 * 146 * @param jsonSrc 147 * json stream 148 * @return json response 149 */ 150 String saveInfoApresTournee( JSONObject jsonSrc ); 151 152 /** 153 * This request is sent to get all activities around an user. An activity can be: add a picture to one incident, confirm an incident... And an incident can 154 * have many activities. 155 * 156 * @param jsonSrc 157 * json stream 158 * @return json response 159 */ 160 String getUsersActivities( JSONObject jsonSrc ); 161 162 /** 163 * This request allows to change status for a report. 164 * 165 * @param jsonSrc 166 * json stream 167 * @param request 168 * the http request 169 * @return json response 170 */ 171 String changeStatus( JSONObject jsonSrc, HttpServletRequest request ); 172 173 /** 174 * This request is sent if the user need to change the incident category or the indent address. 175 * 176 * @param jsonSrc 177 * json stream 178 * @return json response 179 */ 180 String changeIncident( JSONObject jsonSrc ); 181 182 /** 183 * This request allows to get the pictures of an incident and the commentary of each picture and the date of the picture. 184 * 185 * @param jsonSrc 186 * json stream 187 * @return json response 188 */ 189 String getIncidentPhotos( JSONObject jsonSrc ); 190 191 /** 192 * Get list of categorie. 193 * 194 * @param jsonSrc 195 * json stream 196 * @return json response 197 */ 198 String getCategoriesList( JSONObject jsonSrc ); 199 200 /** 201 * Send incident pictures. 202 * 203 * @param request 204 * the http request 205 * @param requestBodyStream 206 * the input stream 207 * @return json response 208 */ 209 String updatePictureIncident( HttpServletRequest request, InputStream requestBodyStream ); 210 211 /** 212 * get reject report. 213 * 214 * @return a report Pojo 215 */ 216 SignalementsPOJO signalementAArchiverRejete( ); 217 218 /** 219 * get report in status done. 220 * 221 * @return a report Pojo 222 */ 223 SignalementsPOJO signalementAArchiverServiceFait( ); 224 225 /** 226 * get list of address. 227 * 228 * @param address 229 * an address 230 * @return list of address 231 */ 232 List<Address> getAddressItem( String address ); 233 234 /** 235 * Get the coordinate. 236 * 237 * @param dLatLambert 238 * latitude lambert. 239 * @param dLngLambert 240 * longitude lambert. 241 * @return geom coordinate 242 */ 243 Double [ ] getGeomFromLambertToWgs84( Double dLatLambert, Double dLngLambert ); 244 245 /** 246 * Gets the geom from lambert 93 to wgs 84. 247 * 248 * @param dLatLambert 249 * the d lat lambert 250 * @param dLngLambert 251 * the d lng lambert 252 * @return the geom from lambert 93 to wgs 84 253 */ 254 Double [ ] getGeomFromLambert93ToWgs84( Double dLatLambert, Double dLngLambert ); 255 256 /** 257 * Find all reports in perimeter. 258 * 259 * @param lat 260 * latitude 261 * @param lng 262 * longitude 263 * @param radius 264 * radius 265 * @return list of report 266 */ 267 List<DossierSignalementDTO> findAllSignalementInPerimeterWithDTO( Double lat, Double lng, Integer radius ); 268 269 /** 270 * Find distance between two reports. 271 * 272 * @param lat1 273 * latitude reports 1 274 * @param lng1 275 * longitude reports 1 276 * @param lat2 277 * latitude reports 2 278 * @param lng2 279 * longitude reports 2 280 * @return the distance 281 */ 282 Integer getDistanceBetweenSignalement( double lat1, double lng1, double lat2, double lng2 ); 283 284 /** 285 * Check if the report is follow by the user. 286 * 287 * @param nIdSignalement 288 * report id 289 * @param userGuid 290 * user guid 291 * @return true if is follow 292 */ 293 boolean isSignalementFollowableAndisSignalementFollowedByUser( int nIdSignalement, String userGuid ); 294 295 /** 296 * Get all priority. 297 * 298 * @return list of priority 299 */ 300 List<Priorite> getAllPriorite( ); 301 302 /** 303 * Find prority by id. 304 * 305 * @param lId 306 * id of the priority 307 * @return a priority 308 */ 309 Priorite loadPrioriteById( long lId ); 310 311 /** 312 * Find district with geom coordinate. 313 * 314 * @param lng 315 * longitude 316 * @param lat 317 * latitude 318 * @return district 319 */ 320 Arrondissement getArrondissementByGeom( double lng, double lat ); 321 322 /** 323 * add a follower to a report. 324 * 325 * @param signalementId 326 * report id 327 * @param guid 328 * user guid 329 * @param strUDID 330 * phone udid 331 * @param email 332 * user email 333 * @param device 334 * phone type 335 * @param userToken 336 * token 337 * @param createUser 338 * user 339 */ 340 void addFollower( Long signalementId, String guid, String strUDID, String email, String device, String userToken, boolean createUser ); 341 342 /** 343 * Get current folder. 344 * 345 * @param longitude 346 * longitude 347 * @param latitude 348 * latitude 349 * @return current folder 350 */ 351 String getDossiersCourrantsByGeomWithLimit( Double longitude, Double latitude ); 352 353 /** 354 * Save a report. 355 * 356 * @param demandeSignalement 357 * a report. 358 * @param userName 359 * user name 360 * @param userMail 361 * user mail 362 * @return true if is ok 363 */ 364 JSONObject sauvegarderSignalement( Signalement demandeSignalement, String userName, String userMail ); 365 366 /** 367 * list of workflow action. 368 * 369 * @param nIdSignalement 370 * id report 371 * @param user 372 * user 373 * @return lis of action 374 */ 375 Collection<Action> getListActionsByIdSignalementAndUser( int nIdSignalement, AdminUser user ); 376 377 }