1 package fr.ifremer.tutti.persistence.service.referential;
2
3 /*
4 * #%L
5 * Tutti :: Persistence
6 * $Id:$
7 * $HeadURL:$
8 * %%
9 * Copyright (C) 2012 - 2014 Ifremer
10 * %%
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation, either version 3 of the
14 * License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public
22 * License along with this program. If not, see
23 * <http://www.gnu.org/licenses/gpl-3.0.html>.
24 * #L%
25 */
26
27 import com.google.common.collect.ImmutableSet;
28 import com.google.common.collect.Multimap;
29 import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
30 import fr.ifremer.tutti.persistence.entities.data.Cruise;
31 import fr.ifremer.tutti.persistence.entities.data.Program;
32 import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
33 import org.springframework.cache.annotation.Cacheable;
34 import org.springframework.transaction.annotation.Transactional;
35
36 import java.util.List;
37
38 /**
39 * Created on 11/3/14.
40 *
41 * @author Tony Chemit - chemit@codelutin.com
42 * @since 3.8
43 */
44 @Transactional(readOnly = true)
45 public interface LocationPersistenceService extends TuttiPersistenceServiceImplementor {
46
47 /**
48 * @return all available zones (used by a {@link Program}.
49 * @see Program#getZone()
50 * @see Program#setZone(TuttiLocation)
51 * @since 0.3
52 */
53 @Cacheable(value = "programZones")
54 List<TuttiLocation> getAllProgramZone();
55
56 /**
57 * @return all countries (used by a {@link Cruise}).
58 * @since 0.1
59 */
60 @Cacheable(value = "countries")
61 List<TuttiLocation> getAllCountry();
62
63 /**
64 * @return all harbours (used by a {@link Cruise}).
65 * @see Cruise#getDepartureLocation()
66 * @see Cruise#setDepartureLocation(TuttiLocation)
67 * @see Cruise#getReturnLocation()
68 * @see Cruise#setReturnLocation(TuttiLocation)
69 * @since 1.2
70 */
71 @Cacheable(value = "harbours")
72 List<TuttiLocation> getAllHarbour();
73
74 @Cacheable(value = "harboursWithObsoletes")
75 List<TuttiLocation> getAllHarbourWithObsoletes();
76
77 /**
78 * Get the set of all ids of stratas or substratas that match the given zone id.
79 *
80 * @param zoneId id of the program zone
81 * @return set of all strata or substrata that match the given zone id.
82 * @since 4.5
83 */
84 ImmutableSet<Integer> getAllFishingOperationStratasAndSubstratasIdsForProgram(String zoneId);
85
86 /**
87 * Get a multimap of location of type substrata by location of type strata that match the given zone id.
88 *
89 * @param zoneId id of the parent zone (can not be null)
90 * @return the stratas and substratas with given zone id as location parent
91 * @since 1.0
92 */
93 Multimap<TuttiLocation, TuttiLocation> getAllFishingOperationStratasAndSubstratas(String zoneId);
94
95 /**
96 * Get the list of location of type strata that match the given zone id.
97 *
98 * @param zoneId id of the parent zone (can not be null)
99 * @return the stratas with given zone id as location parent
100 * @since 1.0
101 */
102 List<TuttiLocation> getAllFishingOperationStrata(String zoneId);
103
104 List<TuttiLocation> getAllFishingOperationStrataWithObsoletes(String zoneId);
105
106 /**
107 * Get the list of location of type substra that match the given zone id or
108 * if not null the given strata id.
109 *
110 * @param zoneId id of the parent zone (can not be null)
111 * @param strataId id of the optional parent strata
112 * @return the list of localite with given zone id as location parent / or strata
113 * @since 1.0
114 */
115 List<TuttiLocation> getAllFishingOperationSubStrata(String zoneId, String strataId);
116
117 List<TuttiLocation> getAllFishingOperationSubStrataWithObsoletes(String zoneId, String strataId);
118
119 /**
120 * Get the list of location of type substra that match the given zone id or
121 * if not null the given strata id or if not null the given substrata id if
122 * not null.
123 *
124 * @param zoneId id of the parent zone (can not be null)
125 * @param strataId id of the optional parent strata
126 * @param subStrataId id of the optional parent subStrata
127 * @return the list of localite with given zone id as location parent / or strata or substrata
128 * @since 1.0
129 */
130 List<TuttiLocation> getAllFishingOperationLocation(String zoneId, String strataId, String subStrataId);
131
132 List<TuttiLocation> getAllFishingOperationLocationWithObsoletes(String zoneId, String strataId, String subStrataId);
133
134 /**
135 * Get a location by id .
136 *
137 * @param id the id of location to load
138 * @return the location for the given id, or {@code null} if not found
139 * @since 1.0
140 */
141 TuttiLocation getLocation(String id);
142
143 /**
144 * Return location label from a longitude and a latitude (in decimal degrees - WG84).
145 *
146 * @param latitude a latitude (in decimal degrees - WG84)
147 * @param longitude a longitude (in decimal degrees - WG84)
148 * @return A location label (corresponding to a statistical rectangle), or null if no statistical rectangle exists for this position
149 */
150 String getLocationLabelByLatLong(Float latitude, Float longitude);
151
152 /**
153 * Return a location Id, from a longitude and a latitude (in decimal degrees - WG84).
154 * This method typically use getLocationLabelByLatLong().
155 *
156 * @param latitude a latitude (in decimal degrees - WG84)
157 * @param longitude a longitude (in decimal degrees - WG84)
158 * @return A location Id (corresponding to a statistical rectangle), or null if no statistical rectangle exists for this position
159 */
160 Integer getLocationIdByLatLong(Float latitude, Float longitude);
161
162 }