Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
e5b394d8
by Tony CHEMIT at 2017-10-27T13:34:13+02:00
-
6a24f3b4
by Tony CHEMIT at 2017-10-27T13:34:40+02:00
14 changed files:
- client/src/main/java/fr/ird/observe/client/ui/admin/export/ExportUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroUIHandler.java
- client/src/main/java/fr/ird/observe/client/ui/storage/StorageBackupUILauncher.java
- persistence/src/main/models/Observe.model
- services-local/src/main/java/fr/ird/observe/services/local/service/data/TripManagementServiceLocal.java
- services-local/src/test/java/fr/ird/observe/entity/ReplicateTestSupport.java
- services-local/src/test/java/fr/ird/observe/entity/ReplicateTripLonglineTest.java
- services-local/src/test/java/fr/ird/observe/entity/ReplicateTripSeineTest.java
- services-test/src/main/java/fr/ird/observe/services/service/data/TripManagementServiceTest.java
- services/src/main/java/fr/ird/observe/services/service/data/ExportTripRequest.java
- services/src/main/java/fr/ird/observe/services/service/data/ExportTripResult.java
- test/src/main/java/fr/ird/observe/test/ObserveFixtures.java
- test/src/main/resources/db/6.0/referentiel.sql.gz
- test/src/main/resources/db/6.904/referentiel.sql.gz
Changes:
| ... | ... | @@ -332,7 +332,7 @@ public class ExportUIHandler extends AdminTabUIHandler<ExportUI> implements UIHa |
| 332 | 332 |
for (TripEntry tripEntry : tripEntries) {
|
| 333 | 333 |
|
| 334 | 334 |
progressModel.incrementsCurrentStep();
|
| 335 |
- ExportTripRequest exportTripRequest = new ExportTripRequest(false, tripEntry.getProgramId(), tripEntry.getTripId());
|
|
| 335 |
+ ExportTripRequest exportTripRequest = new ExportTripRequest(false, tripEntry.getTripId());
|
|
| 336 | 336 |
ExportTripResult exportTripResult = localTripManagementService.exportTrip(exportTripRequest);
|
| 337 | 337 |
logExportResult(n("observe.actions.exportData.message.result.export.trip"),
|
| 338 | 338 |
exportTripResult,
|
| ... | ... | @@ -326,7 +326,7 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple |
| 326 | 326 |
|
| 327 | 327 |
sendMessage(t("observe.actions.synchro.data.prepare.copyToLeftTask", programStr, tripStr));
|
| 328 | 328 |
|
| 329 |
- ExportTripRequest exportTripRequest = new ExportTripRequest(!leftSource.isLocal(), programId, tripId);
|
|
| 329 |
+ ExportTripRequest exportTripRequest = new ExportTripRequest(!leftSource.isLocal(), tripId);
|
|
| 330 | 330 |
ExportTripResult exportTripResult = rightTripManagementService.exportTrip(exportTripRequest);
|
| 331 | 331 |
logExportResult(n("observe.actions.synchro.data.result.export.right.trip"),
|
| 332 | 332 |
exportTripResult,
|
| ... | ... | @@ -355,7 +355,7 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple |
| 355 | 355 |
|
| 356 | 356 |
sendMessage(t("observe.actions.synchro.data.prepare.copyToRightTask", programStr, tripStr));
|
| 357 | 357 |
|
| 358 |
- ExportTripRequest exportTripRequest = new ExportTripRequest(!rightSource.isLocal(), programId, tripId);
|
|
| 358 |
+ ExportTripRequest exportTripRequest = new ExportTripRequest(!rightSource.isLocal(), tripId);
|
|
| 359 | 359 |
ExportTripResult exportTripResult = leftTripManagementService.exportTrip(exportTripRequest);
|
| 360 | 360 |
logExportResult(n("observe.actions.synchro.data.result.export.left.trip"),
|
| 361 | 361 |
exportTripResult,
|
| ... | ... | @@ -154,7 +154,7 @@ public class StorageBackupUILauncher extends StorageUILauncher { |
| 154 | 154 |
|
| 155 | 155 |
for (DataDtoReference trip : entry.getValue()) {
|
| 156 | 156 |
|
| 157 |
- ExportTripRequest exportRequest = new ExportTripRequest(false, entry.getKey().getId(), trip.getId());
|
|
| 157 |
+ ExportTripRequest exportRequest = new ExportTripRequest(false, trip.getId());
|
|
| 158 | 158 |
ExportTripResult exportTripResult = managementService.exportTrip(exportRequest);
|
| 159 | 159 |
progressModel.incrementsCurrentStep();
|
| 160 | 160 |
|
| ... | ... | @@ -264,7 +264,7 @@ sensorType {*:1} referentiel.longline.SensorType |
| 264 | 264 |
sensorDataFormat {*:0..1} referentiel.longline.SensorDataFormat
|
| 265 | 265 |
sensorBrand {*:1} referentiel.longline.SensorBrand
|
| 266 | 266 |
|
| 267 |
-longline.SetLonglineObs > CommentableEntity >> ObserveSet | entity dbName=SetObs
|
|
| 267 |
+longline.SetLonglineObs > CommentableEntity >> ObserveSet | entity dbName=setObs
|
|
| 268 | 268 |
homeId + {*:1} String
|
| 269 | 269 |
number + {*:1} Integer
|
| 270 | 270 |
basketsPerSectionCount + {*:1} Integer
|
| ... | ... | @@ -25,6 +25,7 @@ package fr.ird.observe.services.local.service.data; |
| 25 | 25 |
import com.google.common.collect.ImmutableSet;
|
| 26 | 26 |
import fr.ird.observe.dto.IdHelper;
|
| 27 | 27 |
import fr.ird.observe.dto.db.ObserveBlobsContainer;
|
| 28 |
+import fr.ird.observe.entities.Trip;
|
|
| 28 | 29 |
import fr.ird.observe.persistence.ObserveTopiaPersistenceContext;
|
| 29 | 30 |
import fr.ird.observe.services.local.ObserveServiceContextLocal;
|
| 30 | 31 |
import fr.ird.observe.services.local.service.ObserveServiceLocal;
|
| ... | ... | @@ -87,7 +88,9 @@ public class TripManagementServiceLocal extends ObserveServiceLocal implements T |
| 87 | 88 |
|
| 88 | 89 |
long time = System.nanoTime() - t0;
|
| 89 | 90 |
|
| 90 |
- return new ExportTripResult(exportRequest, tripContent, blobsContainers, time);
|
|
| 91 |
+ Trip trip = getTopiaPersistenceContext().findByTopiaId(tripId);
|
|
| 92 |
+ String programId = trip.getProgram().getTopiaId();
|
|
| 93 |
+ return new ExportTripResult(exportRequest, programId,tripContent, blobsContainers, time);
|
|
| 91 | 94 |
|
| 92 | 95 |
}
|
| 93 | 96 |
|
| ... | ... | @@ -46,6 +46,7 @@ import org.apache.commons.logging.Log; |
| 46 | 46 |
import org.apache.commons.logging.LogFactory;
|
| 47 | 47 |
import org.junit.Assert;
|
| 48 | 48 |
import org.nuiton.topia.service.sql.batch.actions.ReplicateTablesRequest;
|
| 49 |
+import org.nuiton.topia.service.sql.batch.actions.TopiaSqlTableSelectArgument;
|
|
| 49 | 50 |
import org.nuiton.topia.service.sql.batch.tables.TopiaSqlTable;
|
| 50 | 51 |
import org.nuiton.topia.service.sql.batch.tables.TopiaSqlTables;
|
| 51 | 52 |
import org.nuiton.util.StringUtil;
|
| ... | ... | @@ -140,4 +141,15 @@ class ReplicateTestSupport extends ServiceTestSupport { |
| 140 | 141 |
|
| 141 | 142 |
}
|
| 142 | 143 |
|
| 144 |
+ protected void testReplicate(TopiaSqlTables tables, ImmutableMap<String, Long> expectedTablesCount, Iterable<String> tripIds) throws DataSourceCreateWithNoReferentialImportException, IOException, IncompatibleDataSourceCreateConfigurationException, DatabaseNotFoundException, DatabaseConnexionNotAuthorizedException, BabModelVersionException {
|
|
| 145 |
+ |
|
| 146 |
+ ReplicateTablesRequest request
|
|
| 147 |
+ = createReplicateTablesRequest(DatabaseName.referentiel)
|
|
| 148 |
+ .setSelectArgument(TopiaSqlTableSelectArgument.of(tripIds))
|
|
| 149 |
+ .setTables(tables)
|
|
| 150 |
+ .build();
|
|
| 151 |
+ |
|
| 152 |
+ testReplicate0(request, expectedTablesCount);
|
|
| 153 |
+ |
|
| 154 |
+ }
|
|
| 143 | 155 |
}
|
| ... | ... | @@ -22,71 +22,48 @@ package fr.ird.observe.entity; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import com.google.common.collect.ImmutableMap;
|
|
| 26 |
-import fr.ird.observe.services.configuration.DataSourceCreateWithNoReferentialImportException;
|
|
| 27 |
-import fr.ird.observe.services.configuration.IncompatibleDataSourceCreateConfigurationException;
|
|
| 28 |
-import fr.ird.observe.services.service.BabModelVersionException;
|
|
| 29 |
-import fr.ird.observe.services.service.DatabaseConnexionNotAuthorizedException;
|
|
| 30 |
-import fr.ird.observe.services.service.DatabaseNotFoundException;
|
|
| 25 |
+import fr.ird.observe.dto.data.longline.TripLonglineDto;
|
|
| 31 | 26 |
import fr.ird.observe.services.test.DatabaseName;
|
| 32 | 27 |
import fr.ird.observe.services.test.spi.DatabaseNameConfiguration;
|
| 33 | 28 |
import fr.ird.observe.test.ObserveFixtures;
|
| 34 |
-import java.io.IOException;
|
|
| 35 |
-import org.junit.Ignore;
|
|
| 29 |
+import java.util.Set;
|
|
| 30 |
+import org.apache.commons.logging.Log;
|
|
| 31 |
+import org.apache.commons.logging.LogFactory;
|
|
| 36 | 32 |
import org.junit.Test;
|
| 37 |
-import org.nuiton.topia.service.sql.batch.actions.ReplicateTablesRequest;
|
|
| 38 |
-import org.nuiton.topia.service.sql.batch.actions.TopiaSqlTableSelectArgument;
|
|
| 39 | 33 |
import org.nuiton.topia.service.sql.batch.tables.TopiaSqlTables;
|
| 40 | 34 |
|
| 41 | 35 |
/**
|
| 42 | 36 |
* Created on 29/12/15.
|
| 43 | 37 |
*
|
| 44 | 38 |
* @author Tony Chemit - dev@tchemit.fr
|
| 45 |
- * FIXME Review database, there is some missing in new referential, so it does not work.
|
|
| 46 | 39 |
*/
|
| 47 |
-@Ignore
|
|
| 48 | 40 |
@DatabaseNameConfiguration(DatabaseName.dataForTestLongline)
|
| 49 | 41 |
public class ReplicateTripLonglineTest extends ReplicateTestSupport {
|
| 50 | 42 |
|
| 51 |
- @Test
|
|
| 52 |
- public void testReplicateAllTripLongline() throws Exception {
|
|
| 53 |
- testReplicate(ObserveFixtures.ALL_TRIP_LONGLINE_COUNT);
|
|
| 54 |
- }
|
|
| 55 |
- |
|
| 56 |
- @Test
|
|
| 57 |
- public void testReplicateAllTripLongline2() throws Exception {
|
|
| 58 |
- testReplicate(ObserveFixtures.ALL_TRIP_LONGLINE_COUNT,
|
|
| 59 |
- ObserveFixtures.TRIP_LONGLINE_ID_1,
|
|
| 60 |
- ObserveFixtures.TRIP_LONGLINE_ID_2,
|
|
| 61 |
- ObserveFixtures.TRIP_LONGLINE_ID_3);
|
|
| 62 |
- }
|
|
| 43 |
+ /** Logger. */
|
|
| 44 |
+ private static final Log log = LogFactory.getLog(ReplicateTripLonglineTest.class);
|
|
| 63 | 45 |
|
| 64 | 46 |
@Test
|
| 65 |
- public void testReplicateTripLonline1() throws Exception {
|
|
| 66 |
- testReplicate(ObserveFixtures.TRIP_LONGLINE_1_TABLES_COUNT, ObserveFixtures.TRIP_LONGLINE_ID_1);
|
|
| 67 |
- }
|
|
| 68 |
- |
|
| 69 |
- @Test
|
|
| 70 |
- public void testReplicateTripLonline2() throws Exception {
|
|
| 71 |
- testReplicate(ObserveFixtures.TRIP_LONGLINE_2_TABLES_COUNT, ObserveFixtures.TRIP_LONGLINE_ID_2);
|
|
| 72 |
- }
|
|
| 73 |
- |
|
| 74 |
- @Test
|
|
| 75 |
- public void testReplicateTripLonline3() throws Exception {
|
|
| 76 |
- testReplicate(ObserveFixtures.TRIP_LONGLINE_3_TABLES_COUNT, ObserveFixtures.TRIP_LONGLINE_ID_3);
|
|
| 77 |
- }
|
|
| 78 |
- |
|
| 79 |
- protected void testReplicate(ImmutableMap<String, Long> expectedTablesCount, String... tripIds) throws DataSourceCreateWithNoReferentialImportException, IOException, IncompatibleDataSourceCreateConfigurationException, DatabaseNotFoundException, DatabaseConnexionNotAuthorizedException, BabModelVersionException {
|
|
| 80 |
- |
|
| 47 |
+ public void testReplicate() throws Exception {
|
|
| 48 |
+ Set<String> ids = getTestMethodResource().getDatabaseFixtures().ids(TripLonglineDto.class);
|
|
| 49 |
+ log.info(String.format("will replicate %d trip(s).", ids.size()));
|
|
| 81 | 50 |
TopiaSqlTables tables = getTestMethodResource().getTopiaApplicationContext().getTripLonglineTables();
|
| 82 |
- ReplicateTablesRequest request
|
|
| 83 |
- = createReplicateTablesRequest(DatabaseName.referentiel)
|
|
| 84 |
- .setSelectArgument(TopiaSqlTableSelectArgument.of(tripIds))
|
|
| 85 |
- .setTables(tables)
|
|
| 86 |
- .build();
|
|
| 87 |
- |
|
| 88 |
- testReplicate0(request, expectedTablesCount);
|
|
| 89 |
- |
|
| 51 |
+ testReplicate(tables, ObserveFixtures.ALL_TRIP_LONGLINE_COUNT, ids);
|
|
| 90 | 52 |
}
|
| 91 | 53 |
|
| 54 |
+// @Test
|
|
| 55 |
+// public void testReplicateTripLonline1() throws Exception {
|
|
| 56 |
+// testReplicate(ObserveFixtures.TRIP_LONGLINE_1_TABLES_COUNT, ObserveFixtures.TRIP_LONGLINE_ID_1);
|
|
| 57 |
+// }
|
|
| 58 |
+//
|
|
| 59 |
+// @Test
|
|
| 60 |
+// public void testReplicateTripLonline2() throws Exception {
|
|
| 61 |
+// testReplicate(ObserveFixtures.TRIP_LONGLINE_2_TABLES_COUNT, ObserveFixtures.TRIP_LONGLINE_ID_2);
|
|
| 62 |
+// }
|
|
| 63 |
+//
|
|
| 64 |
+// @Test
|
|
| 65 |
+// public void testReplicateTripLonline3() throws Exception {
|
|
| 66 |
+// testReplicate(ObserveFixtures.TRIP_LONGLINE_3_TABLES_COUNT, ObserveFixtures.TRIP_LONGLINE_ID_3);
|
|
| 67 |
+// }
|
|
| 68 |
+ |
|
| 92 | 69 |
}
|
| ... | ... | @@ -22,13 +22,14 @@ package fr.ird.observe.entity; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import com.google.common.collect.ImmutableMap;
|
|
| 25 |
+import fr.ird.observe.dto.data.seine.TripSeineDto;
|
|
| 26 | 26 |
import fr.ird.observe.services.test.DatabaseName;
|
| 27 | 27 |
import fr.ird.observe.services.test.spi.DatabaseNameConfiguration;
|
| 28 | 28 |
import fr.ird.observe.test.ObserveFixtures;
|
| 29 |
+import java.util.Set;
|
|
| 30 |
+import org.apache.commons.logging.Log;
|
|
| 31 |
+import org.apache.commons.logging.LogFactory;
|
|
| 29 | 32 |
import org.junit.Test;
|
| 30 |
-import org.nuiton.topia.service.sql.batch.actions.ReplicateTablesRequest;
|
|
| 31 |
-import org.nuiton.topia.service.sql.batch.actions.TopiaSqlTableSelectArgument;
|
|
| 32 | 33 |
import org.nuiton.topia.service.sql.batch.tables.TopiaSqlTables;
|
| 33 | 34 |
|
| 34 | 35 |
/**
|
| ... | ... | @@ -38,47 +39,30 @@ import org.nuiton.topia.service.sql.batch.tables.TopiaSqlTables; |
| 38 | 39 |
*/
|
| 39 | 40 |
@DatabaseNameConfiguration(DatabaseName.dataForTestSeine)
|
| 40 | 41 |
public class ReplicateTripSeineTest extends ReplicateTestSupport {
|
| 42 |
+ /** Logger. */
|
|
| 43 |
+ private static final Log log = LogFactory.getLog(ReplicateTripSeineTest.class);
|
|
| 41 | 44 |
|
| 42 | 45 |
@Test
|
| 43 |
- public void testReplicateAllTripSeine() throws Exception {
|
|
| 44 |
- testReplicate(ObserveFixtures.ALL_TRIP_SEINE_COUNT);
|
|
| 45 |
- }
|
|
| 46 |
- |
|
| 47 |
- @Test
|
|
| 48 |
- public void testReplicateTripSeine1() throws Exception {
|
|
| 49 |
- testReplicate(ObserveFixtures.TRIP_SEINE_1_TABLES_COUNT, ObserveFixtures.TRIP_SEINE_ID_1);
|
|
| 50 |
- }
|
|
| 51 |
- |
|
| 52 |
- @Test
|
|
| 53 |
- public void testReplicateAllTripSeine2() throws Exception {
|
|
| 54 |
- testReplicate(ObserveFixtures.ALL_TRIP_SEINE_COUNT,
|
|
| 55 |
- ObserveFixtures.TRIP_SEINE_ID_1,
|
|
| 56 |
- ObserveFixtures.TRIP_SEINE_ID_2,
|
|
| 57 |
- ObserveFixtures.TRIP_SEINE_ID_3);
|
|
| 58 |
- }
|
|
| 59 |
- |
|
| 60 |
- @Test
|
|
| 61 |
- public void testReplicateTripSeine2() throws Exception {
|
|
| 62 |
- testReplicate(ObserveFixtures.TRIP_SEINE_2_TABLES_COUNT, ObserveFixtures.TRIP_SEINE_ID_2);
|
|
| 63 |
- }
|
|
| 64 |
- |
|
| 65 |
- @Test
|
|
| 66 |
- public void testReplicateTripSeine3() throws Exception {
|
|
| 67 |
- testReplicate(ObserveFixtures.TRIP_SEINE_3_TABLES_COUNT, ObserveFixtures.TRIP_SEINE_ID_3);
|
|
| 68 |
- }
|
|
| 69 |
- |
|
| 70 |
- protected void testReplicate(ImmutableMap<String, Long> expectedTablesCount, String... tripIds) throws Exception {
|
|
| 71 |
- |
|
| 46 |
+ public void testReplicate() throws Exception {
|
|
| 47 |
+ Set<String> ids = getTestMethodResource().getDatabaseFixtures().ids(TripSeineDto.class);
|
|
| 48 |
+ log.info(String.format("will replicate %d trip(s).", ids.size()));
|
|
| 72 | 49 |
TopiaSqlTables tables = getTestMethodResource().getTopiaApplicationContext().getTripSeineTables();
|
| 73 |
- |
|
| 74 |
- ReplicateTablesRequest request
|
|
| 75 |
- = createReplicateTablesRequest(DatabaseName.referentiel)
|
|
| 76 |
- .setSelectArgument(TopiaSqlTableSelectArgument.of(tripIds))
|
|
| 77 |
- .setTables(tables)
|
|
| 78 |
- .build();
|
|
| 79 |
- |
|
| 80 |
- testReplicate0(request, expectedTablesCount);
|
|
| 81 |
- |
|
| 50 |
+ testReplicate(tables, ObserveFixtures.ALL_TRIP_SEINE_COUNT, ids);
|
|
| 82 | 51 |
}
|
| 83 | 52 |
|
| 53 |
+// @Test
|
|
| 54 |
+// public void testReplicateTripSeine1() throws Exception {
|
|
| 55 |
+// testReplicate(ObserveFixtures.TRIP_SEINE_1_TABLES_COUNT, ObserveFixtures.TRIP_SEINE_ID_1);
|
|
| 56 |
+// }
|
|
| 57 |
+//
|
|
| 58 |
+// @Test
|
|
| 59 |
+// public void testReplicateTripSeine2() throws Exception {
|
|
| 60 |
+// testReplicate(ObserveFixtures.TRIP_SEINE_2_TABLES_COUNT, ObserveFixtures.TRIP_SEINE_ID_2);
|
|
| 61 |
+// }
|
|
| 62 |
+//
|
|
| 63 |
+// @Test
|
|
| 64 |
+// public void testReplicateTripSeine3() throws Exception {
|
|
| 65 |
+// testReplicate(ObserveFixtures.TRIP_SEINE_3_TABLES_COUNT, ObserveFixtures.TRIP_SEINE_ID_3);
|
|
| 66 |
+// }
|
|
| 67 |
+ |
|
| 84 | 68 |
}
|
| ... | ... | @@ -22,6 +22,9 @@ package fr.ird.observe.services.service.data; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
+import fr.ird.observe.dto.data.longline.TripLonglineDto;
|
|
| 26 |
+import fr.ird.observe.dto.data.longline.TripLonglineReference;
|
|
| 27 |
+import fr.ird.observe.dto.data.seine.TripSeineDto;
|
|
| 25 | 28 |
import fr.ird.observe.dto.data.seine.TripSeineReference;
|
| 26 | 29 |
import fr.ird.observe.dto.reference.DataDtoReferenceSet;
|
| 27 | 30 |
import fr.ird.observe.services.configuration.DataSourceCreateConfigurationDto;
|
| ... | ... | @@ -41,6 +44,7 @@ import fr.ird.observe.services.test.ServiceTestSupport; |
| 41 | 44 |
import fr.ird.observe.services.test.spi.CopyDatabaseConfiguration;
|
| 42 | 45 |
import fr.ird.observe.services.test.spi.DatabaseNameConfiguration;
|
| 43 | 46 |
import fr.ird.observe.test.ObserveFixtures;
|
| 47 |
+import java.util.Set;
|
|
| 44 | 48 |
import org.junit.Assert;
|
| 45 | 49 |
import org.junit.Before;
|
| 46 | 50 |
import org.junit.Test;
|
| ... | ... | @@ -54,19 +58,24 @@ public class TripManagementServiceTest extends ServiceTestSupport { |
| 54 | 58 |
|
| 55 | 59 |
private TripManagementService tripManagementService;
|
| 56 | 60 |
private TripSeineService tripSeineService;
|
| 61 |
+ private TripLonglineService tripLonglineService;
|
|
| 57 | 62 |
|
| 58 | 63 |
@Before
|
| 59 | 64 |
public void setUp() throws Exception {
|
| 60 | 65 |
tripManagementService = getTestMethodResource().newService(TripManagementService.class);
|
| 61 | 66 |
tripSeineService = getTestMethodResource().newService(TripSeineService.class);
|
| 67 |
+ tripLonglineService = getTestMethodResource().newService(TripLonglineService.class);
|
|
| 62 | 68 |
}
|
| 63 | 69 |
|
| 64 | 70 |
@DatabaseNameConfiguration(DatabaseName.dataForTestSeine)
|
| 65 | 71 |
@Test
|
| 66 | 72 |
public void exportTripSeine() {
|
| 67 |
- ExportTripRequest request = new ExportTripRequest(false, ObserveFixtures.PROGRAM_ID, ObserveFixtures.TRIP_SEINE_ID_1);
|
|
| 68 |
- ExportTripResult result = tripManagementService.exportTrip(request);
|
|
| 69 |
- Assert.assertNotNull(result);
|
|
| 73 |
+ Set<String> ids = getTestMethodResource().getDatabaseFixtures().ids(TripSeineDto.class);
|
|
| 74 |
+ for (String id : ids) {
|
|
| 75 |
+ ExportTripRequest request = new ExportTripRequest(false, id);
|
|
| 76 |
+ ExportTripResult result = tripManagementService.exportTrip(request);
|
|
| 77 |
+ Assert.assertNotNull(result);
|
|
| 78 |
+ }
|
|
| 70 | 79 |
}
|
| 71 | 80 |
|
| 72 | 81 |
@DatabaseNameConfiguration(DatabaseName.dataForTestSeine)
|
| ... | ... | @@ -74,64 +83,93 @@ public class TripManagementServiceTest extends ServiceTestSupport { |
| 74 | 83 |
@Test
|
| 75 | 84 |
public void deleteTripSeine() {
|
| 76 | 85 |
|
| 77 |
- DataDtoReferenceSet<TripSeineReference> allTripSeineBefore = tripSeineService.getAllTripSeine();
|
|
| 86 |
+ Set<String> ids = getTestMethodResource().getDatabaseFixtures().ids(TripSeineDto.class);
|
|
| 87 |
+ for (String id : ids) {
|
|
| 78 | 88 |
|
| 79 |
- DeleteTripRequest request = new DeleteTripRequest(ObserveFixtures.PROGRAM_ID, ObserveFixtures.TRIP_SEINE_ID_1);
|
|
| 80 |
- DeleteTripResult result = tripManagementService.deleteTrip(request);
|
|
| 81 |
- Assert.assertNotNull(result);
|
|
| 89 |
+ DataDtoReferenceSet<TripSeineReference> allTripBefore = tripSeineService.getAllTripSeine();
|
|
| 90 |
+ DeleteTripRequest request = new DeleteTripRequest(ObserveFixtures.PROGRAM_ID, id);
|
|
| 91 |
+ DeleteTripResult result = tripManagementService.deleteTrip(request);
|
|
| 92 |
+ Assert.assertNotNull(result);
|
|
| 82 | 93 |
|
| 83 |
- DataDtoReferenceSet<TripSeineReference> allTripSeineAfter = tripSeineService.getAllTripSeine();
|
|
| 84 |
- Assert.assertTrue(allTripSeineBefore.size() == allTripSeineAfter.size() + 1);
|
|
| 94 |
+ DataDtoReferenceSet<TripSeineReference> allTripAfter = tripSeineService.getAllTripSeine();
|
|
| 95 |
+ Assert.assertTrue(allTripBefore.size() == allTripAfter.size() + 1);
|
|
| 96 |
+ }
|
|
| 85 | 97 |
}
|
| 86 | 98 |
|
| 87 | 99 |
@DatabaseNameConfiguration(DatabaseName.dataForTestSeine)
|
| 88 | 100 |
@CopyDatabaseConfiguration
|
| 89 | 101 |
@Test
|
| 90 | 102 |
public void importTripSeine() throws DatabaseConnexionNotAuthorizedException, DataSourceCreateWithNoReferentialImportException, BabModelVersionException, IncompatibleDataSourceCreateConfigurationException, DatabaseNotFoundException {
|
| 91 |
- |
|
| 92 |
- ExportTripRequest request = new ExportTripRequest(false, ObserveFixtures.PROGRAM_ID, ObserveFixtures.TRIP_SEINE_ID_1);
|
|
| 93 |
- importTrip(request, true);
|
|
| 94 |
- |
|
| 103 |
+ Set<String> ids = getTestMethodResource().getDatabaseFixtures().ids(TripSeineDto.class);
|
|
| 104 |
+ importTrip(true, ids);
|
|
| 95 | 105 |
}
|
| 96 | 106 |
|
| 97 |
- // FIXME Le test met 6 minutes, comprendre pourquoi l'import est aussi long (environ 18000 branchlines)
|
|
| 98 |
-// @Ignore
|
|
| 99 | 107 |
@DatabaseNameConfiguration(DatabaseName.dataForTestLongline)
|
| 100 | 108 |
@CopyDatabaseConfiguration
|
| 101 | 109 |
@Test
|
| 102 | 110 |
public void importTripLongline() throws DatabaseConnexionNotAuthorizedException, DataSourceCreateWithNoReferentialImportException, BabModelVersionException, IncompatibleDataSourceCreateConfigurationException, DatabaseNotFoundException {
|
| 111 |
+ Set<String> ids = getTestMethodResource().getDatabaseFixtures().ids(TripLonglineDto.class);
|
|
| 112 |
+ importTrip(false, ids);
|
|
| 113 |
+ }
|
|
| 114 |
+ |
|
| 115 |
+ @DatabaseNameConfiguration(DatabaseName.dataForTestLongline)
|
|
| 116 |
+ @CopyDatabaseConfiguration
|
|
| 117 |
+ @Test
|
|
| 118 |
+ public void deleteTripLongline() {
|
|
| 119 |
+ Set<String> ids = getTestMethodResource().getDatabaseFixtures().ids(TripLonglineDto.class);
|
|
| 120 |
+ for (String id : ids) {
|
|
| 121 |
+ DataDtoReferenceSet<TripLonglineReference> allTripBefore = tripLonglineService.getAllTripLongline();
|
|
| 122 |
+ |
|
| 123 |
+ DeleteTripRequest request = new DeleteTripRequest(ObserveFixtures.PROGRAM_ID, id);
|
|
| 124 |
+ DeleteTripResult result = tripManagementService.deleteTrip(request);
|
|
| 125 |
+ Assert.assertNotNull(result);
|
|
| 103 | 126 |
|
| 104 |
- ExportTripRequest request = new ExportTripRequest(false, ObserveFixtures.PROGRAM_ID, ObserveFixtures.TRIP_LONGLINE_ID_1);
|
|
| 105 |
- importTrip(request, false);
|
|
| 127 |
+ DataDtoReferenceSet<TripLonglineReference> allTripAfter = tripLonglineService.getAllTripLongline();
|
|
| 128 |
+ Assert.assertTrue(allTripBefore.size() == allTripAfter.size() + 1);
|
|
| 129 |
+ }
|
|
| 130 |
+ }
|
|
| 106 | 131 |
|
| 132 |
+ @DatabaseNameConfiguration(DatabaseName.dataForTestLongline)
|
|
| 133 |
+ @Test
|
|
| 134 |
+ public void exportTripLongline() {
|
|
| 135 |
+ Set<String> ids = getTestMethodResource().getDatabaseFixtures().ids(TripLonglineDto.class);
|
|
| 136 |
+ for (String id : ids) {
|
|
| 137 |
+ ExportTripRequest request = new ExportTripRequest(false, id);
|
|
| 138 |
+ ExportTripResult result = tripManagementService.exportTrip(request);
|
|
| 139 |
+ Assert.assertNotNull(result);
|
|
| 140 |
+ }
|
|
| 107 | 141 |
}
|
| 108 | 142 |
|
| 109 |
- private void importTrip(ExportTripRequest request, boolean forSeine) throws DatabaseConnexionNotAuthorizedException, DataSourceCreateWithNoReferentialImportException, BabModelVersionException, IncompatibleDataSourceCreateConfigurationException, DatabaseNotFoundException {
|
|
| 110 | 143 |
|
| 111 |
- ExportTripResult result = tripManagementService.exportTrip(request);
|
|
| 144 |
+ private void importTrip(boolean forSeine, Set<String> ids) throws DatabaseConnexionNotAuthorizedException, DataSourceCreateWithNoReferentialImportException, BabModelVersionException, IncompatibleDataSourceCreateConfigurationException, DatabaseNotFoundException {
|
|
| 112 | 145 |
|
| 113 |
- ObserveDataSourceConfigurationTopiaH2 dataSourceConfiguration = getTestMethodResource().createDataSourceConfigurationH2(getClass(), "importTripTarget");
|
|
| 146 |
+ ObserveDataSourceConfigurationTopiaH2 dataSourceConfiguration = getTestMethodResource().createDataSourceConfigurationH2(getClass(), "importTripTarget" + forSeine);
|
|
| 114 | 147 |
|
| 115 | 148 |
try (DataSourceService dataSourceService = getTestClassResource().newService(dataSourceConfiguration, DataSourceService.class)) {
|
| 116 | 149 |
|
| 117 | 150 |
DataSourceCreateConfigurationDto dataSourceCreateConfiguration = new DataSourceCreateConfigurationDto();
|
| 118 | 151 |
dataSourceCreateConfiguration.setImportReferentialDataSourceConfiguration(getTestMethodResource().getDataSourceConfiguration());
|
| 119 |
- |
|
| 152 |
+ dataSourceCreateConfiguration.setLeaveOpenSource(true);
|
|
| 120 | 153 |
ObserveDataSourceConnection dataSourceConnection = dataSourceService.create(dataSourceConfiguration, dataSourceCreateConfiguration);
|
| 121 | 154 |
dataSourceConnection = new ObserveDataSourceConnectionTopiaForTest(dataSourceConnection.getAuthenticationToken());
|
| 122 |
- |
|
| 123 | 155 |
TripManagementService tripManagementService = getTestClassResource().newService(dataSourceConnection, TripManagementService.class);
|
| 124 | 156 |
TripSeineService tripSeineService = getTestClassResource().newService(dataSourceConnection, TripSeineService.class);
|
| 125 | 157 |
TripLonglineService tripLonglineService = getTestClassResource().newService(dataSourceConnection, TripLonglineService.class);
|
| 126 | 158 |
|
| 127 |
- int allTripSeineBefore = forSeine ? tripSeineService.getAllTripSeine().size() :
|
|
| 159 |
+ int allTripBefore = forSeine ? tripSeineService.getAllTripSeine().size() :
|
|
| 128 | 160 |
tripLonglineService.getAllTripLongline().size();
|
| 129 | 161 |
|
| 130 |
- tripManagementService.importTrip(new ImportTripRequest(result));
|
|
| 162 |
+ for (String id : ids) {
|
|
| 131 | 163 |
|
| 132 |
- int allTripSeineAfter = forSeine ? tripSeineService.getAllTripSeine().size() :
|
|
| 133 |
- tripLonglineService.getAllTripLongline().size();
|
|
| 134 |
- Assert.assertTrue(allTripSeineAfter == allTripSeineBefore + 1);
|
|
| 164 |
+ ExportTripRequest request = new ExportTripRequest(false, id);
|
|
| 165 |
+ ExportTripResult result = this.tripManagementService.exportTrip(request);
|
|
| 166 |
+ |
|
| 167 |
+ tripManagementService.importTrip(new ImportTripRequest(result));
|
|
| 168 |
+ |
|
| 169 |
+ int allTripAfter = forSeine ? tripSeineService.getAllTripSeine().size() :
|
|
| 170 |
+ tripLonglineService.getAllTripLongline().size();
|
|
| 171 |
+ Assert.assertEquals(allTripAfter, ++allTripBefore);
|
|
| 172 |
+ }
|
|
| 135 | 173 |
|
| 136 | 174 |
}
|
| 137 | 175 |
|
| ... | ... | @@ -33,12 +33,10 @@ import fr.ird.observe.dto.ObserveDto; |
| 33 | 33 |
public class ExportTripRequest implements ObserveDto {
|
| 34 | 34 |
|
| 35 | 35 |
private final boolean forPG;
|
| 36 |
- private final String programId;
|
|
| 37 | 36 |
private final String tripId;
|
| 38 | 37 |
|
| 39 |
- public ExportTripRequest(boolean forPG, String programId, String tripId) {
|
|
| 38 |
+ public ExportTripRequest(boolean forPG, String tripId) {
|
|
| 40 | 39 |
this.forPG = forPG;
|
| 41 |
- this.programId = programId;
|
|
| 42 | 40 |
this.tripId = tripId;
|
| 43 | 41 |
}
|
| 44 | 42 |
|
| ... | ... | @@ -46,10 +44,6 @@ public class ExportTripRequest implements ObserveDto { |
| 46 | 44 |
return forPG;
|
| 47 | 45 |
}
|
| 48 | 46 |
|
| 49 |
- public String getProgramId() {
|
|
| 50 |
- return programId;
|
|
| 51 |
- }
|
|
| 52 |
- |
|
| 53 | 47 |
public String getTripId() {
|
| 54 | 48 |
return tripId;
|
| 55 | 49 |
}
|
| ... | ... | @@ -41,10 +41,10 @@ public class ExportTripResult implements ObserveDto { |
| 41 | 41 |
private final long time;
|
| 42 | 42 |
|
| 43 | 43 |
public ExportTripResult(ExportTripRequest request,
|
| 44 |
- byte[] sqlContent,
|
|
| 44 |
+ String programId, byte[] sqlContent,
|
|
| 45 | 45 |
ImmutableSet<ObserveBlobsContainer> blobsContainers,
|
| 46 | 46 |
long time) {
|
| 47 |
- this.programId = request.getProgramId();
|
|
| 47 |
+ this.programId = programId;
|
|
| 48 | 48 |
this.tripId = request.getTripId();
|
| 49 | 49 |
this.sqlContent = sqlContent;
|
| 50 | 50 |
this.blobsContainers = blobsContainers;
|
| ... | ... | @@ -94,19 +94,19 @@ public class ObserveFixtures { |
| 94 | 94 |
.put("observe_common.lengthlengthparameter", 0L)
|
| 95 | 95 |
.put("observe_common.lengthweightparameter", 365L)
|
| 96 | 96 |
.put("observe_common.ocean", 3L)
|
| 97 |
- .put("observe_common.ocean_species", 500L)
|
|
| 97 |
+ .put("observe_common.ocean_species", 517L)
|
|
| 98 | 98 |
.put("observe_common.organism", 9L)
|
| 99 |
- .put("observe_common.person", 512L)
|
|
| 99 |
+ .put("observe_common.person", 514L)
|
|
| 100 | 100 |
.put("observe_common.program", 27L)
|
| 101 | 101 |
.put("observe_common.shipOwner", 27L)
|
| 102 |
- .put("observe_common.sex", 5L)
|
|
| 103 |
- .put("observe_common.sizemeasuretype", 17L)
|
|
| 104 |
- .put("observe_common.species", 285L)
|
|
| 105 |
- .put("observe_common.species_specieslist", 401L)
|
|
| 102 |
+ .put("observe_common.shipowner", 27L)
|
|
| 103 |
+ .put("observe_common.sizemeasuretype", 24L)
|
|
| 104 |
+ .put("observe_common.species", 294L)
|
|
| 105 |
+ .put("observe_common.species_specieslist", 410L)
|
|
| 106 | 106 |
.put("observe_common.speciesgroup", 11L)
|
| 107 |
- .put("observe_common.speciesgroupreleasemode", 10L)
|
|
| 107 |
+ .put("observe_common.speciesgroup_speciesgroupreleasemode", 20L)
|
|
| 108 | 108 |
.put("observe_common.specieslist", 6L)
|
| 109 |
- .put("observe_common.vessel", 1172L)
|
|
| 109 |
+ .put("observe_common.vessel", 1175L)
|
|
| 110 | 110 |
.put("observe_common.vesselsizecategory", 13L)
|
| 111 | 111 |
.put("observe_common.vesseltype", 14L)
|
| 112 | 112 |
.put("observe_common.weightmeasuretype", 3L)
|
| ... | ... | @@ -135,13 +135,13 @@ public class ObserveFixtures { |
| 135 | 135 |
private static final ImmutableMap<String, Long> REFERENTIAL_LONGLINE_TABLES_COUNT = ImmutableMap
|
| 136 | 136 |
.<String, Long>builder()
|
| 137 | 137 |
.put("observe_longline.baithaulingstatus", 5L)
|
| 138 |
- .put("observe_longline.baitsettingstatus", 5L)
|
|
| 139 |
- .put("observe_longline.baittype", 16L)
|
|
| 140 |
- .put("observe_longline.catchfate", 5L)
|
|
| 138 |
+ .put("observe_longline.baitsettingstatus", 6L)
|
|
| 139 |
+ .put("observe_longline.baittype", 17L)
|
|
| 140 |
+ .put("observe_longline.catchfate", 6L)
|
|
| 141 | 141 |
.put("observe_longline.encountertype", 12L)
|
| 142 | 142 |
.put("observe_longline.healthness", 6L)
|
| 143 | 143 |
.put("observe_longline.hookposition", 13L)
|
| 144 |
- .put("observe_longline.hooksize", 22L)
|
|
| 144 |
+ .put("observe_longline.hooksize", 23L)
|
|
| 145 | 145 |
.put("observe_longline.hooktype", 13L)
|
| 146 | 146 |
.put("observe_longline.itemverticalposition", 3L)
|
| 147 | 147 |
.put("observe_longline.itemhorizontalposition", 3L)
|
| ... | ... | @@ -153,8 +153,8 @@ public class ObserveFixtures { |
| 153 | 153 |
.put("observe_longline.sensorbrand", 4L)
|
| 154 | 154 |
.put("observe_longline.sensordataformat", 2L)
|
| 155 | 155 |
.put("observe_longline.sensortype", 4L)
|
| 156 |
- .put("observe_longline.settingshape", 6L)
|
|
| 157 |
- .put("observe_longline.stomacfullness", 7L)
|
|
| 156 |
+ .put("observe_longline.settingshape", 7L)
|
|
| 157 |
+ .put("observe_longline.stomacfullness", 8L)
|
|
| 158 | 158 |
.put("observe_longline.triptype", 3L)
|
| 159 | 159 |
.put("observe_longline.vesselactivity", 5L)
|
| 160 | 160 |
.build();
|
| ... | ... | @@ -307,7 +307,7 @@ public class ObserveFixtures { |
| 307 | 307 |
.put("observe_longline.basket", 3229L)
|
| 308 | 308 |
.put("observe_longline.branchline", 19374L)
|
| 309 | 309 |
.put("observe_longline.catch", 677L)
|
| 310 |
- .put("observe_longline.mitigationtype_set", 0L)
|
|
| 310 |
+ .put("observe_longline.mitigationtype_setobs", 0L)
|
|
| 311 | 311 |
.put("observe_longline.sizemeasure", 647L)
|
| 312 | 312 |
.put("observe_longline.weightmeasure", 0L)
|
| 313 | 313 |
.put("observe_longline.catch_predator", 25L)
|
No preview for this file type
No preview for this file type