Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
-
41aadc59
by tchemit at 2019-01-14T16:19:06Z
5 changed files:
- + dto/src/main/java/fr/ird/observe/dto/referential/SpeciesGroupHelper.java
- server-core/src/main/filtered-resources/mapping
- services-local/src/main/java/fr/ird/observe/services/local/service/data/seine/NonTargetCatchReleaseServiceLocal.java
- services-local/src/main/java/fr/ird/observe/services/local/service/referential/ReferentialServiceLocal.java
- services/src/main/java/fr/ird/observe/services/service/referential/ReferentialService.java
Changes:
| 1 |
+package fr.ird.observe.dto.referential;
|
|
| 2 |
+ |
|
| 3 |
+/*-
|
|
| 4 |
+ * #%L
|
|
| 5 |
+ * ObServe :: Dto
|
|
| 6 |
+ * %%
|
|
| 7 |
+ * Copyright (C) 2008 - 2019 IRD, Code Lutin, Ultreia.io
|
|
| 8 |
+ * %%
|
|
| 9 |
+ * This program is free software: you can redistribute it and/or modify
|
|
| 10 |
+ * it under the terms of the GNU General Public License as
|
|
| 11 |
+ * published by the Free Software Foundation, either version 3 of the
|
|
| 12 |
+ * License, or (at your option) any later version.
|
|
| 13 |
+ *
|
|
| 14 |
+ * This program is distributed in the hope that it will be useful,
|
|
| 15 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
| 16 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
| 17 |
+ * GNU General Public License for more details.
|
|
| 18 |
+ *
|
|
| 19 |
+ * You should have received a copy of the GNU General Public
|
|
| 20 |
+ * License along with this program. If not, see
|
|
| 21 |
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
|
|
| 22 |
+ * #L%
|
|
| 23 |
+ */
|
|
| 24 |
+ |
|
| 25 |
+import java.util.Arrays;
|
|
| 26 |
+import java.util.List;
|
|
| 27 |
+ |
|
| 28 |
+public class SpeciesGroupHelper extends GeneratedSpeciesGroupHelper {
|
|
| 29 |
+ //FIXME PROTECTED-ID
|
|
| 30 |
+ public static final List<String> SPECIES_GROUP_IDS = Arrays.asList(
|
|
| 31 |
+ "fr.ird.referential.common.SpeciesGroup#1445863056144#0.9820877553253712",
|
|
| 32 |
+ "fr.ird.referential.common.SpeciesGroup#1239832683690#0.24333033683679461",
|
|
| 33 |
+ "fr.ird.referential.common.SpeciesGroup#1446014286433#0.6480183366605247",
|
|
| 34 |
+ "fr.ird.referential.common.SpeciesGroup#1239832683689#0.7120116158620075"
|
|
| 35 |
+ );
|
|
| 36 |
+}
|
| ... | ... | @@ -228,6 +228,7 @@ GET /api/v1/referential/ReferentialService/getReferenceSet |
| 228 | 228 |
POST /api/v1/referential/ReferentialService/getReferentialIds v1.referential.ReferentialServiceRestApi.getReferentialIds
|
| 229 | 229 |
GET /api/v1/referential/ReferentialService/getReferentialReferenceSets v1.referential.ReferentialServiceRestApi.getReferentialReferenceSets
|
| 230 | 230 |
POST /api/v1/referential/ReferentialService/insertMissingReferential v1.referential.ReferentialServiceRestApi.insertMissingReferential
|
| 231 |
+GET /api/v1/referential/ReferentialService/loadDto v1.referential.ReferentialServiceRestApi.loadDto
|
|
| 231 | 232 |
GET /api/v1/referential/ReferentialService/loadForm v1.referential.ReferentialServiceRestApi.loadForm
|
| 232 | 233 |
GET /api/v1/referential/ReferentialService/loadObservedSystems v1.referential.ReferentialServiceRestApi.loadObservedSystems
|
| 233 | 234 |
GET /api/v1/referential/ReferentialService/loadReference v1.referential.ReferentialServiceRestApi.loadReference
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.services.local.service.data.seine; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -26,15 +26,16 @@ import fr.ird.observe.dto.data.seine.SetSeineNonTargetCatchReleaseDto; |
| 26 | 26 |
import fr.ird.observe.dto.form.Form;
|
| 27 | 27 |
import fr.ird.observe.dto.reference.ReferentialDtoReferenceSet;
|
| 28 | 28 |
import fr.ird.observe.dto.referential.SpeciesReference;
|
| 29 |
+import fr.ird.observe.dto.referential.SpeciesGroupHelper;
|
|
| 29 | 30 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 30 | 31 |
import fr.ird.observe.entities.seine.NonTargetCatch;
|
| 31 | 32 |
import fr.ird.observe.entities.seine.SetSeine;
|
| 32 | 33 |
import fr.ird.observe.services.local.service.ObserveServiceLocal;
|
| 33 |
-import fr.ird.observe.services.local.service.referential.ReferentialServiceLocal;
|
|
| 34 | 34 |
import fr.ird.observe.services.service.data.seine.NonTargetCatchReleaseService;
|
| 35 |
-import java.util.stream.Collectors;
|
|
| 36 |
-import org.apache.logging.log4j.Logger;
|
|
| 37 | 35 |
import org.apache.logging.log4j.LogManager;
|
| 36 |
+import org.apache.logging.log4j.Logger;
|
|
| 37 |
+ |
|
| 38 |
+import java.util.stream.Collectors;
|
|
| 38 | 39 |
|
| 39 | 40 |
/**
|
| 40 | 41 |
* @author Tony Chemit - dev@tchemit.fr
|
| ... | ... | @@ -54,7 +55,7 @@ public class NonTargetCatchReleaseServiceLocal extends ObserveServiceLocal imple |
| 54 | 55 |
return SPECIES_SPI.toReferentialReferenceSet(setSeine.getNonTargetCatch().stream()
|
| 55 | 56 |
.map(NonTargetCatch::getSpecies)
|
| 56 | 57 |
.distinct()
|
| 57 |
- .filter(s -> ReferentialServiceLocal.SPECIES_GROUP_IDS.contains(s.getSpeciesGroup().getTopiaId()))
|
|
| 58 |
+ .filter(s -> SpeciesGroupHelper.SPECIES_GROUP_IDS.contains(s.getSpeciesGroup().getTopiaId()))
|
|
| 58 | 59 |
.collect(Collectors.toList()), getReferentialLocale(), null);
|
| 59 | 60 |
}
|
| 60 | 61 |
|
| ... | ... | @@ -64,7 +65,7 @@ public class NonTargetCatchReleaseServiceLocal extends ObserveServiceLocal imple |
| 64 | 65 |
log.trace("loadForm(" + setSeineId + ")");
|
| 65 | 66 |
}
|
| 66 | 67 |
|
| 67 |
- SetSeine setSeine = SET_SEINE_NON_TARGET_RELEASE_SPI.loadEntity(getTopiaPersistenceContext(),setSeineId);
|
|
| 68 |
+ SetSeine setSeine = SET_SEINE_NON_TARGET_RELEASE_SPI.loadEntity(getTopiaPersistenceContext(), setSeineId);
|
|
| 68 | 69 |
|
| 69 | 70 |
return SET_SEINE_NON_TARGET_RELEASE_SPI.dataEntityToForm(setSeine, getReferentialLocale());
|
| 70 | 71 |
}
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.services.local.service.referential; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -41,6 +41,7 @@ import fr.ird.observe.dto.referential.ReferenceStatus; |
| 41 | 41 |
import fr.ird.observe.dto.referential.ReferentialDto;
|
| 42 | 42 |
import fr.ird.observe.dto.referential.SpeciesDto;
|
| 43 | 43 |
import fr.ird.observe.dto.referential.SpeciesGroupDto;
|
| 44 |
+import fr.ird.observe.dto.referential.SpeciesGroupHelper;
|
|
| 44 | 45 |
import fr.ird.observe.dto.referential.seine.ObservedSystemReference;
|
| 45 | 46 |
import fr.ird.observe.dto.result.SaveResultDto;
|
| 46 | 47 |
import fr.ird.observe.entities.ObserveDataEntity;
|
| ... | ... | @@ -82,7 +83,6 @@ import org.nuiton.topia.persistence.script.TopiaSqlScript; |
| 82 | 83 |
import org.nuiton.version.Version;
|
| 83 | 84 |
import org.nuiton.version.Versions;
|
| 84 | 85 |
|
| 85 |
-import java.util.Arrays;
|
|
| 86 | 86 |
import java.util.Collections;
|
| 87 | 87 |
import java.util.Date;
|
| 88 | 88 |
import java.util.LinkedHashSet;
|
| ... | ... | @@ -99,12 +99,6 @@ import java.util.Set; |
| 99 | 99 |
*/
|
| 100 | 100 |
public class ReferentialServiceLocal extends ObserveServiceLocal implements ReferentialService {
|
| 101 | 101 |
|
| 102 |
- public static final List<String> SPECIES_GROUP_IDS = Arrays.asList(
|
|
| 103 |
- "fr.ird.observe.entities.referentiel.SpeciesGroup#1445863056144#0.9820877553253712",
|
|
| 104 |
- "fr.ird.observe.entities.referentiel.SpeciesGroup#1239832683690#0.24333033683679461",
|
|
| 105 |
- "fr.ird.observe.entities.referentiel.SpeciesGroup#1446014286433#0.6480183366605247",
|
|
| 106 |
- "fr.ird.observe.entities.referentiel.SpeciesGroup#1239832683689#0.7120116158620075"
|
|
| 107 |
- );
|
|
| 108 | 102 |
private static final Logger log = LogManager.getLogger(ReferentialServiceLocal.class);
|
| 109 | 103 |
|
| 110 | 104 |
@Override
|
| ... | ... | @@ -151,12 +145,24 @@ public class ReferentialServiceLocal extends ObserveServiceLocal implements Refe |
| 151 | 145 |
@Override
|
| 152 | 146 |
public ImmutableSet<SpeciesGroupDto> loadSensibleSpeciesGroup() {
|
| 153 | 147 |
ImmutableSet.Builder<SpeciesGroupDto> result = ImmutableSet.builder();
|
| 154 |
- for (String speciesGroupId : SPECIES_GROUP_IDS) {
|
|
| 148 |
+ for (String speciesGroupId : SpeciesGroupHelper.SPECIES_GROUP_IDS) {
|
|
| 155 | 149 |
result.add(loadSpeciesGroup(speciesGroupId));
|
| 156 | 150 |
}
|
| 157 | 151 |
return result.build();
|
| 158 | 152 |
}
|
| 159 | 153 |
|
| 154 |
+ @Override
|
|
| 155 |
+ public <D extends ReferentialDto> D loadDto(Class<D> type, String id) {
|
|
| 156 |
+ ReferentialDtoEntityContext<D, ?, ?> spi = DbModelHelper.fromReferentialDto(type);
|
|
| 157 |
+ ObserveReferentialEntity entity = loadEntity(type, id);
|
|
| 158 |
+ D dto = spi.toDto(serviceContext.getReferentialLocale(), entity);
|
|
| 159 |
+ dto.setVersion(entity.getTopiaVersion());
|
|
| 160 |
+ dto.setCreateDate(entity.getTopiaCreateDate());
|
|
| 161 |
+ dto.setLastUpdateDate(entity.getLastUpdateDate());
|
|
| 162 |
+ dto.setStatus(ReferenceStatus.valueOf(entity.getStatus().name()));
|
|
| 163 |
+ return dto;
|
|
| 164 |
+ }
|
|
| 165 |
+ |
|
| 160 | 166 |
@Override
|
| 161 | 167 |
public <D extends ReferentialDto> Form<D> loadForm(Class<D> type, String id) {
|
| 162 | 168 |
ReferentialDtoEntityContext<D, ?, ?> spi = DbModelHelper.fromReferentialDto(type);
|
| ... | ... | @@ -10,12 +10,12 @@ package fr.ird.observe.services.service.referential; |
| 10 | 10 |
* it under the terms of the GNU General Public License as
|
| 11 | 11 |
* published by the Free Software Foundation, either version 3 of the
|
| 12 | 12 |
* License, or (at your option) any later version.
|
| 13 |
- *
|
|
| 13 |
+ *
|
|
| 14 | 14 |
* This program is distributed in the hope that it will be useful,
|
| 15 | 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 17 | 17 |
* GNU General Public License for more details.
|
| 18 |
- *
|
|
| 18 |
+ *
|
|
| 19 | 19 |
* You should have received a copy of the GNU General Public
|
| 20 | 20 |
* License along with this program. If not, see
|
| 21 | 21 |
* <http://www.gnu.org/licenses/gpl-3.0.html>.
|
| ... | ... | @@ -87,7 +87,11 @@ public interface ReferentialService extends ObserveService { |
| 87 | 87 |
|
| 88 | 88 |
@ReadReferentialPermission
|
| 89 | 89 |
@Get
|
| 90 |
- <R extends ReferentialDto> Form<R> loadForm(Class<R> type, String id);
|
|
| 90 |
+ <D extends ReferentialDto> D loadDto(Class<D> type, String id);
|
|
| 91 |
+ |
|
| 92 |
+ @ReadReferentialPermission
|
|
| 93 |
+ @Get
|
|
| 94 |
+ <D extends ReferentialDto> Form<D> loadForm(Class<D> type, String id);
|
|
| 91 | 95 |
|
| 92 | 96 |
@Get
|
| 93 | 97 |
@ReadReferentialPermission
|
| ... | ... | @@ -95,22 +99,24 @@ public interface ReferentialService extends ObserveService { |
| 95 | 99 |
|
| 96 | 100 |
@Get
|
| 97 | 101 |
@WriteReferentialPermission
|
| 98 |
- <R extends ReferentialDto> Form<R> preCreate(Class<R> type);
|
|
| 102 |
+ <D extends ReferentialDto> Form<D> preCreate(Class<D> type);
|
|
| 99 | 103 |
|
| 100 | 104 |
@WriteReferentialPermission
|
| 101 | 105 |
@Write
|
| 102 | 106 |
@Post
|
| 103 |
- <R extends ReferentialDto> SaveResultDto save(R bean);
|
|
| 107 |
+ <D extends ReferentialDto> SaveResultDto save(D bean);
|
|
| 104 | 108 |
|
| 105 | 109 |
@WriteReferentialPermission
|
| 110 |
+ @WriteDataPermission
|
|
| 106 | 111 |
@Write
|
| 107 | 112 |
@Delete
|
| 108 |
- <R extends ReferentialDto> void delete(Class<R> type, String id);
|
|
| 113 |
+ <D extends ReferentialDto> void delete(Class<D> type, String id);
|
|
| 109 | 114 |
|
| 110 | 115 |
@Post
|
| 111 | 116 |
@WriteReferentialPermission
|
| 117 |
+ @WriteDataPermission
|
|
| 112 | 118 |
@Write
|
| 113 |
- <E extends ReferentialDto> void replaceReference(Class<E> beanType, String idToReplace, String replaceId);
|
|
| 119 |
+ <D extends ReferentialDto> void replaceReference(Class<D> beanType, String idToReplace, String replaceId);
|
|
| 114 | 120 |
|
| 115 | 121 |
@Post(useMultiPartForm = true)
|
| 116 | 122 |
@ReadReferentialPermission
|
| ... | ... | @@ -118,13 +124,12 @@ public interface ReferentialService extends ObserveService { |
| 118 | 124 |
|
| 119 | 125 |
@Get
|
| 120 | 126 |
@ReadReferentialPermission
|
| 121 |
- <R extends ReferentialDto> boolean exists(Class<R> type, String id);
|
|
| 127 |
+ <D extends ReferentialDto> boolean exists(Class<D> type, String id);
|
|
| 122 | 128 |
|
| 123 | 129 |
@ReadReferentialPermission
|
| 124 | 130 |
@Post
|
| 125 | 131 |
ImmutableSetStringMap getReferentialIds();
|
| 126 | 132 |
|
| 127 |
- |
|
| 128 | 133 |
@ReadReferentialPermission
|
| 129 | 134 |
@ReadDataPermission
|
| 130 | 135 |
@Post(useMultiPartForm = true)
|