Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
f5fd9e69
by Tony Chemit at 2022-02-22T18:57:55+01:00
-
eb34f407
by Tony Chemit at 2022-02-22T18:57:55+01:00
-
e8e1ebaf
by Tony Chemit at 2022-02-22T18:57:55+01:00
-
20cbe332
by Tony Chemit at 2022-02-22T18:58:18+01:00
15 changed files:
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/common/TripGearUseFeaturesSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/logbook/ActivitySampleSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/logbook/ActivitySpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/logbook/SampleSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/observation/BranchlineSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ll/observation/SetDetailCompositionSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripBatchSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/common/TripGearUseFeaturesSpi.java
- core/persistence/java/src/main/java/fr/ird/observe/entities/data/ps/observation/SampleSpi.java
- core/services/local/src/test/java/fr/ird/observe/services/local/service/api/DataEntityServiceLocalWriteTest.java
- core/services/test/src/main/java/fr/ird/observe/services/service/api/DataEntityServiceFixtures.java
- core/services/test/src/main/resources/fixtures/fr/ird/observe/services/service/data/ps/common/TripService-routeLogbook.json
- pom.xml
- server/configuration/src/main/java/fr/ird/observe/server/configuration/ServerConfig.java
- server/configuration/src/main/java/fr/ird/observe/server/configuration/ServerResources.java
Changes:
| ... | ... | @@ -22,18 +22,14 @@ package fr.ird.observe.entities.data.ll.common; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | -import java.util.Date;
|
|
| 26 | -import java.util.function.BiConsumer;
|
|
| 25 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 27 | 26 | |
| 28 | 27 | public class TripGearUseFeaturesSpi extends GeneratedTripGearUseFeaturesSpi {
|
| 29 | 28 | |
| 30 | 29 | @Override
|
| 31 | - public BiConsumer<Trip, Date> saveCallback() {
|
|
| 32 | - return (e, lastUpdateDate) -> {
|
|
| 33 | - for (GearUseFeatures features : e.getGearUseFeatures()) {
|
|
| 34 | - features.setLastUpdateDate(lastUpdateDate);
|
|
| 35 | - features.getGearUseFeaturesMeasurement().forEach(measurement -> measurement.setLastUpdateDate(lastUpdateDate));
|
|
| 36 | - }
|
|
| 37 | - };
|
|
| 30 | + public void saveCallback(AddEntityToUpdateStep saveHelper, Trip entity) {
|
|
| 31 | + super.saveCallback(saveHelper, entity);
|
|
| 32 | + entity.getGearUseFeatures().forEach(c -> saveHelper.updateCollection(GearUseFeaturesMeasurement.SPI, c.getGearUseFeaturesMeasurement(), false));
|
|
| 33 | + saveHelper.updateLastUpdateDateTable(GearUseFeaturesMeasurement.SPI);
|
|
| 38 | 34 | }
|
| 39 | 35 | } |
| ... | ... | @@ -48,8 +48,8 @@ public class ActivitySampleSpi extends GeneratedActivitySampleSpi { |
| 48 | 48 | @Override
|
| 49 | 49 | protected SaveResultDto saveEntity(ServiceContext context, Activity parent, Sample entity) {
|
| 50 | 50 | return newSaveHelper(context)
|
| 51 | - .update(this, entity, false, true)
|
|
| 52 | - .updateLastUpdateDateField(Activity.SPI, parent)
|
|
| 51 | + .update(this, entity)
|
|
| 52 | +// .updateLastUpdateDateField(Activity.SPI, parent)
|
|
| 53 | 53 | .build(entity);
|
| 54 | 54 | }
|
| 55 | 55 | } |
| ... | ... | @@ -143,7 +143,8 @@ public class ActivitySpi extends GeneratedActivitySpi { |
| 143 | 143 | newActivity.setSample(sample);
|
| 144 | 144 | newSaveHelper(context)
|
| 145 | 145 | .update(this, oldActivity)
|
| 146 | - .update(this, newActivity, (activity, date) -> activity.getSample().setLastUpdateDate(date))
|
|
| 146 | + .update(this, newActivity, false)
|
|
| 147 | + .update(Sample.ACTIVITY_SAMPLE_SPI, sample)
|
|
| 147 | 148 | .updateLastUpdateDateTable(Sample.ACTIVITY_SAMPLE_SPI)
|
| 148 | 149 | .build();
|
| 149 | 150 | return Collections.singleton(sample.getTopiaId());
|
| ... | ... | @@ -156,7 +157,7 @@ public class ActivitySpi extends GeneratedActivitySpi { |
| 156 | 157 | TripSpi.copyTripLogbookMetaData(oldTrip, newTrip);
|
| 157 | 158 | newSaveHelper(context)
|
| 158 | 159 | .update(this, oldActivity)
|
| 159 | - .update(Sample.ACTIVITY_SAMPLE_SPI, sample)
|
|
| 160 | + .update(Sample.SPI, sample)
|
|
| 160 | 161 | .build();
|
| 161 | 162 | return Collections.singleton(sample.getTopiaId());
|
| 162 | 163 | }
|
| ... | ... | @@ -85,8 +85,9 @@ public class SampleSpi extends GeneratedSampleSpi { |
| 85 | 85 | TripSpi.copyTripLogbookMetaData(oldParent, newTrip);
|
| 86 | 86 | newSaveHelper(context)
|
| 87 | 87 | .update(Trip.SPI, oldParent)
|
| 88 | - .update(Activity.SPI, newParent, (activity, date) -> activity.getSample().setLastUpdateDate(date))
|
|
| 89 | - .updateLastUpdateDateTable(Sample.SPI)
|
|
| 88 | + .update(Activity.SPI, newParent, false)
|
|
| 89 | + .update(Sample.ACTIVITY_SAMPLE_SPI, replicateData)
|
|
| 90 | +// .updateLastUpdateDateTable(Sample.SPI)
|
|
| 90 | 91 | .build();
|
| 91 | 92 | return Collections.singleton(replicateData.getTopiaId());
|
| 92 | 93 | }
|
| ... | ... | @@ -26,7 +26,6 @@ import fr.ird.observe.dto.ToolkitParentIdDtoBean; |
| 26 | 26 | import fr.ird.observe.dto.data.ll.observation.BranchlineDto;
|
| 27 | 27 | import fr.ird.observe.dto.form.Form;
|
| 28 | 28 | import fr.ird.observe.dto.result.SaveResultDto;
|
| 29 | -import fr.ird.observe.entities.Entity;
|
|
| 30 | 29 | import fr.ird.observe.spi.service.ServiceContext;
|
| 31 | 30 | |
| 32 | 31 | public class BranchlineSpi extends GeneratedBranchlineSpi {
|
| ... | ... | @@ -42,7 +41,8 @@ public class BranchlineSpi extends GeneratedBranchlineSpi { |
| 42 | 41 | checkLastUpdateDate(context, entity, dto);
|
| 43 | 42 | Branchline.fromDto(context.getReferentialLocale(), entity, dto);
|
| 44 | 43 | return newSaveHelper(context)
|
| 45 | - .update(this, entity, Entity::setLastUpdateDate, false, true)
|
|
| 44 | +// .update(this, entity, Entity::setLastUpdateDate, true)
|
|
| 45 | + .update(this, entity)
|
|
| 46 | 46 | .updateLastUpdateDateField(Set.SPI, parent)
|
| 47 | 47 | .build(entity);
|
| 48 | 48 | }
|
| ... | ... | @@ -35,7 +35,8 @@ import fr.ird.observe.spi.service.ServiceContext; |
| 35 | 35 | public class SetDetailCompositionSpi extends GeneratedSetDetailCompositionSpi {
|
| 36 | 36 | |
| 37 | 37 | @Override
|
| 38 | - public void onLoadForm(ServiceContext context, Set entity, Form<SetDetailCompositionDto> form) {
|
|
| 38 | + public Form<SetDetailCompositionDto> entityToForm(ServiceContext context, Set entity) {
|
|
| 39 | + Form<SetDetailCompositionDto> form = super.entityToForm(context, entity);
|
|
| 39 | 40 | SetDetailCompositionDto dto = form.getObject();
|
| 40 | 41 | SetTopiaDao dao = Set.getDao(context);
|
| 41 | 42 | //FIXME Use a real sql query to get this in one time
|
| ... | ... | @@ -57,5 +58,6 @@ public class SetDetailCompositionSpi extends GeneratedSetDetailCompositionSpi { |
| 57 | 58 | });
|
| 58 | 59 | });
|
| 59 | 60 | });
|
| 61 | + return form;
|
|
| 60 | 62 | }
|
| 61 | 63 | } |
| ... | ... | @@ -31,7 +31,6 @@ import fr.ird.observe.spi.service.ServiceContext; |
| 31 | 31 | |
| 32 | 32 | import java.util.Date;
|
| 33 | 33 | import java.util.LinkedHashSet;
|
| 34 | -import java.util.function.BiConsumer;
|
|
| 35 | 34 | import java.util.stream.Collectors;
|
| 36 | 35 | |
| 37 | 36 | public class TripBatchSpi extends GeneratedTripBatchSpi {
|
| ... | ... | @@ -42,11 +41,6 @@ public class TripBatchSpi extends GeneratedTripBatchSpi { |
| 42 | 41 | form.getObject().setAvailablePackagings(availablePackaging);
|
| 43 | 42 | }
|
| 44 | 43 | |
| 45 | - @Override
|
|
| 46 | - public BiConsumer<Trip, Date> saveCallback() {
|
|
| 47 | - return (e, lastUpdateDate) -> e.getLocalmarketBatch().forEach(c -> c.setLastUpdateDate(lastUpdateDate));
|
|
| 48 | - }
|
|
| 49 | - |
|
| 50 | 44 | protected LinkedHashSet<PackagingReference> getPackaging(ServiceContext context, Trip trip) {
|
| 51 | 45 | Harbour landingHarbour = trip.getLandingHarbour();
|
| 52 | 46 | Date date = trip.getEndDate();
|
| ... | ... | @@ -22,18 +22,14 @@ package fr.ird.observe.entities.data.ps.common; |
| 22 | 22 | * #L%
|
| 23 | 23 | */
|
| 24 | 24 | |
| 25 | -import java.util.Date;
|
|
| 26 | -import java.util.function.BiConsumer;
|
|
| 25 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 27 | 26 | |
| 28 | 27 | public class TripGearUseFeaturesSpi extends GeneratedTripGearUseFeaturesSpi {
|
| 29 | 28 | |
| 30 | 29 | @Override
|
| 31 | - public BiConsumer<Trip, Date> saveCallback() {
|
|
| 32 | - return (e, lastUpdateDate) -> {
|
|
| 33 | - for (GearUseFeatures features : e.getGearUseFeatures()) {
|
|
| 34 | - features.setLastUpdateDate(lastUpdateDate);
|
|
| 35 | - features.getGearUseFeaturesMeasurement().forEach(measurement -> measurement.setLastUpdateDate(lastUpdateDate));
|
|
| 36 | - }
|
|
| 37 | - };
|
|
| 30 | + public void saveCallback(AddEntityToUpdateStep saveHelper, Trip entity) {
|
|
| 31 | + super.saveCallback(saveHelper, entity);
|
|
| 32 | + entity.getGearUseFeatures().forEach(c -> saveHelper.updateCollection(GearUseFeaturesMeasurement.SPI, c.getGearUseFeaturesMeasurement(), false));
|
|
| 33 | + saveHelper.updateLastUpdateDateTable(GearUseFeaturesMeasurement.SPI);
|
|
| 38 | 34 | }
|
| 39 | 35 | } |
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.dto.form.Form; |
| 27 | 27 | import fr.ird.observe.dto.result.SaveResultDto;
|
| 28 | 28 | import fr.ird.observe.entities.referential.common.Species;
|
| 29 | 29 | import fr.ird.observe.entities.referential.ps.common.SpeciesFate;
|
| 30 | +import fr.ird.observe.spi.result.AddEntityToUpdateStep;
|
|
| 30 | 31 | import fr.ird.observe.spi.service.ServiceContext;
|
| 31 | 32 | |
| 32 | 33 | import java.util.Objects;
|
| ... | ... | @@ -62,8 +63,10 @@ public class SampleSpi extends GeneratedSampleSpi { |
| 62 | 63 | parent.addSample(entity);
|
| 63 | 64 | }
|
| 64 | 65 | context.getTopiaPersistenceContext().flush();
|
| 65 | - return newSaveHelper(context)
|
|
| 66 | - .update(this, entity)
|
|
| 66 | + AddEntityToUpdateStep saveHelper = newSaveHelper(context)
|
|
| 67 | + .update(this, entity);
|
|
| 68 | + saveCallback(saveHelper, entity);
|
|
| 69 | + return saveHelper
|
|
| 67 | 70 | .updateLastUpdateDateField(Set.SPI, parent)
|
| 68 | 71 | .build(entity);
|
| 69 | 72 | }
|
| ... | ... | @@ -24,15 +24,19 @@ package fr.ird.observe.services.local.service.api; |
| 24 | 24 | |
| 25 | 25 | import fr.ird.observe.dto.ToolkitId;
|
| 26 | 26 | import fr.ird.observe.dto.data.DataDto;
|
| 27 | +import fr.ird.observe.dto.data.ps.common.TripDto;
|
|
| 27 | 28 | import fr.ird.observe.dto.db.DataSourceValidationMode;
|
| 29 | +import fr.ird.observe.entities.data.ps.common.Trip;
|
|
| 28 | 30 | import fr.ird.observe.navigation.tree.io.ToolkitTreeNodeStates;
|
| 29 | 31 | import fr.ird.observe.services.service.api.InvalidDataException;
|
| 32 | +import fr.ird.observe.services.service.data.ps.common.TripService;
|
|
| 30 | 33 | import fr.ird.observe.test.DatabaseName;
|
| 31 | 34 | import fr.ird.observe.test.spi.CopyDatabaseConfiguration;
|
| 32 | 35 | import fr.ird.observe.test.spi.DatabaseNameConfiguration;
|
| 33 | 36 | import org.junit.Assert;
|
| 34 | 37 | import org.junit.Test;
|
| 35 | 38 | |
| 39 | +import java.util.Collection;
|
|
| 36 | 40 | import java.util.List;
|
| 37 | 41 | import java.util.Map;
|
| 38 | 42 | import java.util.Objects;
|
| ... | ... | @@ -108,24 +112,54 @@ public class DataEntityServiceLocalWriteTest extends GeneratedDataEntityServiceL |
| 108 | 112 | @DatabaseNameConfiguration(DatabaseName.referential)
|
| 109 | 113 | public void updatePsTrip() throws InvalidDataException {
|
| 110 | 114 | TOPIA_TEST_CLASS_RESOURCE.getServiceInitializerConfig().setValidationMode(DataSourceValidationMode.NONE);
|
| 111 | - Map<?, ?> tripMap = null;
|
|
| 115 | + Map<?, ?> tripMap;
|
|
| 112 | 116 | {
|
| 113 | 117 | tripMap = assertCreateTrip0(fr.ird.observe.services.service.data.ps.common.TripService.class,
|
| 114 | 118 | fr.ird.observe.dto.data.ps.common.TripDto.class, "gearUseFeatures");
|
| 115 | 119 | Assert.assertNotNull(tripMap);
|
| 120 | + Assert.assertNotNull(tripMap.get(Trip.PROPERTY_GEAR_USE_FEATURES));
|
|
| 121 | + Assert.assertEquals(1, ((Collection<?>) tripMap.get(Trip.PROPERTY_GEAR_USE_FEATURES)).size());
|
|
| 122 | + Assert.assertNotNull(tripMap.get(Trip.PROPERTY_ROUTE_OBS));
|
|
| 123 | + Assert.assertEquals(0, ((Collection<?>) tripMap.get(Trip.PROPERTY_ROUTE_OBS)).size());
|
|
| 124 | + Assert.assertNotNull(tripMap.get(Trip.PROPERTY_ROUTE_LOGBOOK));
|
|
| 125 | + Assert.assertEquals(0, ((Collection<?>) tripMap.get(Trip.PROPERTY_ROUTE_LOGBOOK)).size());
|
|
| 116 | 126 | }
|
| 117 | 127 | Objects.requireNonNull(tripMap);
|
| 118 | 128 | String tripId = (String) tripMap.get(ToolkitId.PROPERTY_TOOLKIT_TOPIA_ID);
|
| 119 | - int exceptedRouteCount = 2;
|
|
| 129 | + int exceptedRouteObsCount = 2;
|
|
| 130 | + int exceptedRouteLogbookCount = 1;
|
|
| 120 | 131 | {
|
| 121 | - List<?> data = assertUpdateTrip(fr.ird.observe.services.service.data.ps.common.TripService.class,
|
|
| 122 | - fr.ird.observe.dto.data.ps.common.TripDto.class, Objects.requireNonNull(tripId), "routeObs", exceptedRouteCount);
|
|
| 132 | + Map<String, Object> data = assertUpdateTrip(TripService.class,
|
|
| 133 | + TripDto.class, Objects.requireNonNull(tripId), Trip.PROPERTY_ROUTE_OBS, exceptedRouteObsCount);
|
|
| 123 | 134 | Assert.assertNotNull(data);
|
| 135 | + Assert.assertNotNull(data.get(Trip.PROPERTY_GEAR_USE_FEATURES));
|
|
| 136 | + Assert.assertEquals(0, ((Collection<?>) data.get(Trip.PROPERTY_GEAR_USE_FEATURES)).size());
|
|
| 137 | + Assert.assertNotNull(data.get(Trip.PROPERTY_ROUTE_OBS));
|
|
| 138 | + Assert.assertEquals(exceptedRouteObsCount, ((Collection<?>) data.get(Trip.PROPERTY_ROUTE_OBS)).size());
|
|
| 139 | + Assert.assertNotNull(data.get(Trip.PROPERTY_ROUTE_LOGBOOK));
|
|
| 140 | + Assert.assertEquals(0, ((Collection<?>) data.get(Trip.PROPERTY_ROUTE_LOGBOOK)).size());
|
|
| 124 | 141 | }
|
| 125 | 142 | {
|
| 126 | - List<?> data = assertUpdateTrip(fr.ird.observe.services.service.data.ps.common.TripService.class,
|
|
| 127 | - fr.ird.observe.dto.data.ps.common.TripDto.class, Objects.requireNonNull(tripId), "routeObs", 2*exceptedRouteCount);
|
|
| 143 | + Map<String, Object> data = assertUpdateTrip(TripService.class,
|
|
| 144 | + TripDto.class, Objects.requireNonNull(tripId), Trip.PROPERTY_ROUTE_OBS, exceptedRouteObsCount);
|
|
| 128 | 145 | Assert.assertNotNull(data);
|
| 146 | + Assert.assertNotNull(data.get(Trip.PROPERTY_GEAR_USE_FEATURES));
|
|
| 147 | + Assert.assertEquals(0, ((Collection<?>) data.get(Trip.PROPERTY_GEAR_USE_FEATURES)).size());
|
|
| 148 | + Assert.assertNotNull(data.get(Trip.PROPERTY_ROUTE_OBS));
|
|
| 149 | + Assert.assertEquals(exceptedRouteObsCount, ((Collection<?>) data.get(Trip.PROPERTY_ROUTE_OBS)).size());
|
|
| 150 | + Assert.assertNotNull(data.get(Trip.PROPERTY_ROUTE_LOGBOOK));
|
|
| 151 | + Assert.assertEquals(0, ((Collection<?>) data.get(Trip.PROPERTY_ROUTE_LOGBOOK)).size());
|
|
| 152 | + }
|
|
| 153 | + {
|
|
| 154 | + Map<String, Object> data = assertUpdateTrip(TripService.class,
|
|
| 155 | + TripDto.class, Objects.requireNonNull(tripId), Trip.PROPERTY_ROUTE_LOGBOOK, exceptedRouteLogbookCount);
|
|
| 156 | + Assert.assertNotNull(data);
|
|
| 157 | + Assert.assertNotNull(data.get(Trip.PROPERTY_GEAR_USE_FEATURES));
|
|
| 158 | + Assert.assertEquals(0, ((Collection<?>) data.get(Trip.PROPERTY_GEAR_USE_FEATURES)).size());
|
|
| 159 | + Assert.assertNotNull(data.get(Trip.PROPERTY_ROUTE_OBS));
|
|
| 160 | + Assert.assertEquals(0, ((Collection<?>) data.get(Trip.PROPERTY_ROUTE_OBS)).size());
|
|
| 161 | + Assert.assertNotNull(data.get(Trip.PROPERTY_ROUTE_LOGBOOK));
|
|
| 162 | + Assert.assertEquals(exceptedRouteLogbookCount, ((Collection<?>) data.get(Trip.PROPERTY_ROUTE_LOGBOOK)).size());
|
|
| 129 | 163 | }
|
| 130 | 164 | //FIXME Add more test for update https://gitlab.com/ultreiaio/ird-observe/-/issues/2171
|
| 131 | 165 | }
|
| ... | ... | @@ -196,14 +230,14 @@ public class DataEntityServiceLocalWriteTest extends GeneratedDataEntityServiceL |
| 196 | 230 | |
| 197 | 231 | }
|
| 198 | 232 | |
| 199 | - protected List<?> assertUpdateTrip(Class<?> serviceType, Class<? extends DataDto> dtoType, String id, String classifier, int expectedCount) throws InvalidDataException {
|
|
| 233 | + protected Map<String, Object> assertUpdateTrip(Class<?> serviceType, Class<? extends DataDto> dtoType, String id, String classifier, int expectedCount) throws InvalidDataException {
|
|
| 200 | 234 | Map<String, Object> resultObject = assertUpdateTrip0(serviceType, dtoType, id, classifier);
|
| 201 | 235 | Assert.assertNotNull(resultObject);
|
| 202 | 236 | |
| 203 | 237 | List<?> data = (List<?>) resultObject.get(classifier);
|
| 204 | 238 | Assert.assertNotNull(data);
|
| 205 | 239 | Assert.assertEquals(expectedCount, data.size());
|
| 206 | - return data;
|
|
| 240 | + return resultObject;
|
|
| 207 | 241 | }
|
| 208 | 242 | |
| 209 | 243 | protected Map<String, Object> assertUpdateTrip0(Class<?> serviceType, Class<? extends DataDto> dtoType, String id, String classifier) throws InvalidDataException {
|
| ... | ... | @@ -376,6 +376,10 @@ public class DataEntityServiceFixtures extends GeneratedDataEntityServiceFixture |
| 376 | 376 | if (mainDtoType != dtoType && !EditableDto.class.isAssignableFrom(dtoType)) {
|
| 377 | 377 | return;
|
| 378 | 378 | }
|
| 379 | + if (RootOpenableDto.class.isAssignableFrom(dtoType)) {
|
|
| 380 | + // This will regenerate some ids, can't do it here
|
|
| 381 | + return;
|
|
| 382 | + }
|
|
| 379 | 383 | try {
|
| 380 | 384 | String content = loadFixture(module, subModule, dtoType, "content.json");
|
| 381 | 385 | testUpdate(service, dtoType, null, content);
|
| ... | ... | @@ -408,7 +412,7 @@ public class DataEntityServiceFixtures extends GeneratedDataEntityServiceFixture |
| 408 | 412 | log.debug(String.format("for type: %s", dtoType.getName()));
|
| 409 | 413 | Pair<String, List<Object>> result = JsonHelper.removeAndCollectProperties(gson, content, ToolkitId.PROPERTY_TOOLKIT_TOPIA_ID, ToolkitId.PROPERTY_TOOLKIT_CREATE_DATE, ToolkitId.PROPERTY_TOOLKIT_LAST_UPDATE_DATE);
|
| 410 | 414 | content = result.getKey();
|
| 411 | - if (id==null) {
|
|
| 415 | + if (id == null) {
|
|
| 412 | 416 | |
| 413 | 417 | id = (String) result.getValue().get(0);
|
| 414 | 418 | }
|
| ... | ... | @@ -23,6 +23,7 @@ |
| 23 | 23 | "latitude": 3.0,
|
| 24 | 24 | "longitude": -4.0,
|
| 25 | 25 | "number": 1.0,
|
| 26 | + "topiaId": "$$fr.ird.data.ps.logbook.Activity#1616767975989#0.4873500558653976",
|
|
| 26 | 27 | "vesselActivity": "fr.ird.referential.ps.common.VesselActivity#1239832675369#0.12552908048322586",
|
| 27 | 28 | "catches": [
|
| 28 | 29 | {
|
| ... | ... | @@ -76,7 +77,7 @@ |
| 76 | 77 | ],
|
| 77 | 78 | "wellPlan": [
|
| 78 | 79 | {
|
| 79 | - "activity": "fr.ird.data.ps.logbook.Activity#1616767975989#0.4873500558653976",
|
|
| 80 | + "activity": "$$fr.ird.data.ps.logbook.Activity#1616767975989#0.4873500558653976",
|
|
| 80 | 81 | "well": "3T",
|
| 81 | 82 | "species": "fr.ird.referential.common.Species#1239832685475#0.13349466123905152",
|
| 82 | 83 | "weightCategory": "fr.ird.referential.ps.common.WeightCategory#1464000000000#00001",
|
| ... | ... | @@ -95,10 +96,7 @@ |
| 95 | 96 | "totalWeight": 45.0,
|
| 96 | 97 | "sampleActivity": [
|
| 97 | 98 | {
|
| 98 | - "topiaId": "fr.ird.data.ps.logbook.SampleActivity#1612861310013#0.9926675881926301",
|
|
| 99 | - "topiaCreateDate": "2021-02-09T10:01:31.980Z",
|
|
| 100 | - "lastUpdateDate": "2021-02-09T10:01:50.010Z",
|
|
| 101 | - "activity": "fr.ird.data.ps.logbook.Activity#1616767975989#0.4873500558653976",
|
|
| 99 | + "activity": "$$fr.ird.data.ps.logbook.Activity#1616767975989#0.4873500558653976",
|
|
| 102 | 100 | "weightedWeight": 1.2
|
| 103 | 101 | }
|
| 104 | 102 | ],
|
| ... | ... | @@ -140,18 +138,19 @@ |
| 140 | 138 | "species": "fr.ird.referential.common.Species#1308738639113#0.434038308601438",
|
| 141 | 139 | "packaging": "fr.ird.referential.ps.localmarket.Packaging#1464000000000#005",
|
| 142 | 140 | "count": 12.0,
|
| 143 | - "survey": "fr.ird.data.ps.localmarket.Survey#1616777784834#0.5204977416802337",
|
|
| 141 | + "survey": "$$fr.ird.data.ps.localmarket.Survey#1616777784834#0.5204977416802337",
|
|
| 144 | 142 | "origin": "zzz"
|
| 145 | 143 | },
|
| 146 | 144 | {
|
| 147 | 145 | "species": "fr.ird.referential.common.Species#1308738639113#0.434038308601438",
|
| 148 | 146 | "packaging": "fr.ird.referential.ps.localmarket.Packaging#1464000000000#001",
|
| 149 | 147 | "weight": 4.99,
|
| 150 | - "survey": "fr.ird.data.ps.localmarket.Survey#1616777784834#0.5204977416802337"
|
|
| 148 | + "survey": "$$fr.ird.data.ps.localmarket.Survey#1616777784834#0.5204977416802337"
|
|
| 151 | 149 | }
|
| 152 | 150 | ],
|
| 153 | 151 | "localmarketSurvey": [
|
| 154 | 152 | {
|
| 153 | + "topiaId": "$$fr.ird.data.ps.localmarket.Survey#1616777784834#0.5204977416802337",
|
|
| 155 | 154 | "comment": "djdjdj",
|
| 156 | 155 | "date": "2021-03-26T00:00:00.000Z",
|
| 157 | 156 | "number": 1.0,
|
| ... | ... | @@ -155,7 +155,7 @@ |
| 155 | 155 | <!-- build timestamp configuration -->
|
| 156 | 156 | <maven.build.timestamp.format>dd/MM/yyyy HH:mm z</maven.build.timestamp.format>
|
| 157 | 157 | <buildDate>${maven.build.timestamp}</buildDate>
|
| 158 | - <lib.version.toolkit>6.0.3</lib.version.toolkit>
|
|
| 158 | + <lib.version.toolkit>6.0.4-SNAPSHOT</lib.version.toolkit>
|
|
| 159 | 159 | <lib.version.ognl>3.1.29</lib.version.ognl>
|
| 160 | 160 | <!--can't use 1.4.197 (date has changed + blob also)-->
|
| 161 | 161 | <lib.version.h2>1.4.196</lib.version.h2>
|
| ... | ... | @@ -105,7 +105,6 @@ public class ServerConfig extends GeneratedServerConfig implements CleanTemporar |
| 105 | 105 | .forAllScopesWithout(ApplicationConfigScope.CURRENT,
|
| 106 | 106 | ApplicationConfigScope.HOME,
|
| 107 | 107 | ApplicationConfigScope.ENV,
|
| 108 | - ApplicationConfigScope.JVM,
|
|
| 109 | 108 | ApplicationConfigScope.CLASS_PATH,
|
| 110 | 109 | ApplicationConfigScope.SYSTEM)
|
| 111 | 110 | .addDefaults(ServerConfigOption.CONTEXT_PATH.getKey(), "observe-${build.version}")
|
| ... | ... | @@ -153,6 +152,10 @@ public class ServerConfig extends GeneratedServerConfig implements CleanTemporar |
| 153 | 152 | }
|
| 154 | 153 | }
|
| 155 | 154 | |
| 155 | + public boolean isWindows() {
|
|
| 156 | + return get().getOsName().toLowerCase().contains("windows");
|
|
| 157 | + }
|
|
| 158 | + |
|
| 156 | 159 | public void init(boolean strict) {
|
| 157 | 160 | log.info("Starts to init ObServe server configuration...");
|
| 158 | 161 | |
| ... | ... | @@ -164,7 +167,7 @@ public class ServerConfig extends GeneratedServerConfig implements CleanTemporar |
| 164 | 167 | |
| 165 | 168 | File extraConfigFile = get().getExtraConfigFile();
|
| 166 | 169 | if (Files.notExists(extraConfigFile.toPath())) {
|
| 167 | - boolean generated = ServerResources.APPLICATION_CONFIGURATION.copyResource(getCommonConfigurationFile().toPath(), extraConfigFile);
|
|
| 170 | + boolean generated = ServerResources.APPLICATION_CONFIGURATION.setForWindows(isWindows()).copyResource(getCommonConfigurationFile().toPath(), extraConfigFile);
|
|
| 168 | 171 | if (generated) {
|
| 169 | 172 | log.info(String.format("Generate empty configuration file to: %s", extraConfigFile));
|
| 170 | 173 | } else {
|
| ... | ... | @@ -181,7 +184,7 @@ public class ServerConfig extends GeneratedServerConfig implements CleanTemporar |
| 181 | 184 | if (strict && !commonSecurityConfigurationFile.exists()) {
|
| 182 | 185 | throw new IllegalStateException(String.format("Can not start application. Could not find security.yml file.\n\nPlease add it to one of this places:\n\t%s\n\t%s", commonSecurityConfigurationFile, securityConfigurationFile));
|
| 183 | 186 | }
|
| 184 | - boolean generated = ServerResources.SECURITY_CONFIGURATION.setStrict(strict).copyResource(commonSecurityConfigurationFile.toPath(), securityConfigurationFile);
|
|
| 187 | + boolean generated = ServerResources.SECURITY_CONFIGURATION.setStrict(strict).setForWindows(isWindows()).copyResource(commonSecurityConfigurationFile.toPath(), securityConfigurationFile);
|
|
| 185 | 188 | if (generated) {
|
| 186 | 189 | log.info("Generate default security.yml");
|
| 187 | 190 | } else {
|
| ... | ... | @@ -25,6 +25,7 @@ package fr.ird.observe.server.configuration; |
| 25 | 25 | import io.ultreia.java4all.config.ConfigResource;
|
| 26 | 26 | |
| 27 | 27 | import java.io.File;
|
| 28 | +import java.io.IOException;
|
|
| 28 | 29 | import java.nio.file.Files;
|
| 29 | 30 | import java.nio.file.Path;
|
| 30 | 31 | |
| ... | ... | @@ -35,13 +36,14 @@ import java.nio.file.Path; |
| 35 | 36 | * @since 9.0.0
|
| 36 | 37 | */
|
| 37 | 38 | public class ServerResources {
|
| 38 | - public static final ConfigResource APPLICATION_CONFIGURATION = new ConfigResource("/META-INF/configuration/observe-server.conf");
|
|
| 39 | + public static final ConfigResource2 APPLICATION_CONFIGURATION = new ConfigResource2("/META-INF/configuration/observe-server.conf");
|
|
| 39 | 40 | public static final ConfigResource2 SECURITY_CONFIGURATION = new ConfigResource2("/META-INF/configuration/security.yml");
|
| 40 | - public static final ConfigResource LOG_CONFIGURATION = new ConfigResource("/META-INF/configuration/log.xml");
|
|
| 41 | + public static final ConfigResource2 LOG_CONFIGURATION = new ConfigResource2("/META-INF/configuration/log.xml");
|
|
| 41 | 42 | |
| 42 | 43 | static class ConfigResource2 extends ConfigResource {
|
| 43 | 44 | |
| 44 | 45 | private boolean strict;
|
| 46 | + private boolean forWindows;
|
|
| 45 | 47 | |
| 46 | 48 | public ConfigResource2(String location) {
|
| 47 | 49 | super(location);
|
| ... | ... | @@ -56,11 +58,32 @@ public class ServerResources { |
| 56 | 58 | return this;
|
| 57 | 59 | }
|
| 58 | 60 | |
| 61 | + public boolean isForWindows() {
|
|
| 62 | + return forWindows;
|
|
| 63 | + }
|
|
| 64 | + |
|
| 65 | + public ConfigResource2 setForWindows(boolean forWindows) {
|
|
| 66 | + this.forWindows = forWindows;
|
|
| 67 | + return this;
|
|
| 68 | + }
|
|
| 69 | + |
|
| 59 | 70 | @Override
|
| 60 | 71 | public boolean copyResource(Path sharedFile, File file) {
|
| 61 | 72 | if (isStrict() && Files.notExists(sharedFile)) {
|
| 62 | 73 | throw new IllegalStateException(String.format("You are not allowed to copy this resource: %s", this));
|
| 63 | 74 | }
|
| 75 | + if (isForWindows()) {
|
|
| 76 | + if (Files.exists(sharedFile)) {
|
|
| 77 | + try {
|
|
| 78 | + Files.copy(sharedFile, file.toPath());
|
|
| 79 | + return false;
|
|
| 80 | + } catch (IOException e) {
|
|
| 81 | + throw new IllegalStateException(String.format("Could not copy from %s to %s", sharedFile, file), e);
|
|
| 82 | + }
|
|
| 83 | + }
|
|
| 84 | + copyResource(file);
|
|
| 85 | + return true;
|
|
| 86 | + }
|
|
| 64 | 87 | return super.copyResource(sharedFile, file);
|
| 65 | 88 | }
|
| 66 | 89 | }
|