Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
5e1b7baa
by Tony Chemit at 2020-07-01T13:45:10+02:00
-
db96c24b
by Tony Chemit at 2020-07-01T13:48:53+02:00
3 changed files:
- client-datasource-actions/src/main/java/fr/ird/observe/client/datasource/actions/config/ConfigModel.java
- client-datasource-actions/src/main/java/fr/ird/observe/client/datasource/actions/report/ReportModel.java
- client-datasource-editor-ps/src/main/java/fr/ird/observe/client/datasource/editor/content/data/ps/observation/NonTargetCatchUIHandler.java
Changes:
| ... | ... | @@ -27,6 +27,7 @@ import fr.ird.observe.client.datasource.actions.AdminActionModel; |
| 27 | 27 |
import fr.ird.observe.client.datasource.actions.AdminStep;
|
| 28 | 28 |
import fr.ird.observe.client.datasource.actions.AdminUI;
|
| 29 | 29 |
import fr.ird.observe.client.datasource.actions.AdminUIModel;
|
| 30 |
+import fr.ird.observe.client.datasource.actions.report.ReportModel;
|
|
| 30 | 31 |
import fr.ird.observe.client.datasource.actions.synchronize.referential.ng.ReferentialSynchronizeMode;
|
| 31 | 32 |
import fr.ird.observe.client.datasource.api.ObserveDataSourcesManagerApplicationComponent;
|
| 32 | 33 |
import fr.ird.observe.client.datasource.api.ObserveSwingDataSource;
|
| ... | ... | @@ -37,6 +38,7 @@ import fr.ird.observe.client.util.ObserveKeyStrokesSupport; |
| 37 | 38 |
import fr.ird.observe.client.util.UIHelper;
|
| 38 | 39 |
import fr.ird.observe.services.configuration.ObserveDataSourceConfiguration;
|
| 39 | 40 |
import fr.ird.observe.services.configuration.ObserveDataSourceInformation;
|
| 41 |
+import fr.ird.observe.services.service.actions.report.Report;
|
|
| 40 | 42 |
import org.apache.commons.lang3.StringUtils;
|
| 41 | 43 |
import org.apache.logging.log4j.LogManager;
|
| 42 | 44 |
import org.apache.logging.log4j.Logger;
|
| ... | ... | @@ -44,6 +46,7 @@ import org.apache.logging.log4j.Logger; |
| 44 | 46 |
import java.beans.PropertyChangeListener;
|
| 45 | 47 |
import java.io.File;
|
| 46 | 48 |
import java.util.EnumSet;
|
| 49 |
+import java.util.List;
|
|
| 47 | 50 |
import java.util.Objects;
|
| 48 | 51 |
|
| 49 | 52 |
import static fr.ird.observe.client.constants.DbMode.USE_LOCAL;
|
| ... | ... | @@ -365,8 +368,10 @@ public class ConfigModel extends AdminActionModel { |
| 365 | 368 |
if (uiModel.containsOperation(AdminStep.REPORT)) {
|
| 366 | 369 |
|
| 367 | 370 |
// il faut le fichier di'mport existe
|
| 368 |
- File reportFile = uiModel.getReportModel().getReportFile();
|
|
| 369 |
- validate &= reportFile != null && reportFile.exists();
|
|
| 371 |
+ ReportModel reportModel = uiModel.getReportModel();
|
|
| 372 |
+ File reportFile = reportModel.getReportFile();
|
|
| 373 |
+ List<Report> reports = reportModel.getReports();
|
|
| 374 |
+ validate &= reportFile != null && reportFile.exists() && reports!=null && !reports.isEmpty();
|
|
| 370 | 375 |
}
|
| 371 | 376 |
if (uiModel.containsOperation(AdminStep.ACTIVITY_LONGLINE_PAIRING)) {
|
| 372 | 377 |
validate &= localSourceModel.getDataSourceInformation() != null
|
| ... | ... | @@ -39,6 +39,8 @@ import java.beans.PropertyChangeListener; |
| 39 | 39 |
import java.io.File;
|
| 40 | 40 |
import java.io.IOException;
|
| 41 | 41 |
import java.net.URL;
|
| 42 |
+import java.nio.file.Files;
|
|
| 43 |
+import java.util.Collections;
|
|
| 42 | 44 |
import java.util.List;
|
| 43 | 45 |
import java.util.Map;
|
| 44 | 46 |
import java.util.TreeMap;
|
| ... | ... | @@ -184,12 +186,18 @@ public class ReportModel extends AdminActionModel { |
| 184 | 186 |
|
| 185 | 187 |
public List<Report> getAllReports() {
|
| 186 | 188 |
if (allReports == null) {
|
| 187 |
- try {
|
|
| 188 |
- URL resource = reportFile.toURI().toURL();
|
|
| 189 |
- allReports = loadReports(resource);
|
|
| 190 |
- log.debug(String.format("Add loaded %d report(s).", allReports.size()));
|
|
| 191 |
- } catch (IOException e) {
|
|
| 192 |
- throw new IllegalStateException(String.format("Could not load reports definition file (%s).", reportFile), e);
|
|
| 189 |
+ if (reportFile == null || Files.notExists(reportFile.toPath())) {
|
|
| 190 |
+ log.warn("No report file, no reports loaded.");
|
|
| 191 |
+ allReports = Collections.emptyList();
|
|
| 192 |
+ } else {
|
|
| 193 |
+ try {
|
|
| 194 |
+ URL resource = reportFile.toURI().toURL();
|
|
| 195 |
+ allReports = loadReports(resource);
|
|
| 196 |
+ log.debug(String.format("Add loaded %d report(s).", allReports.size()));
|
|
| 197 |
+ } catch (IOException e) {
|
|
| 198 |
+ throw new IllegalStateException(
|
|
| 199 |
+ String.format("Could not load reports definition file (%s).", reportFile), e);
|
|
| 200 |
+ }
|
|
| 193 | 201 |
}
|
| 194 | 202 |
}
|
| 195 | 203 |
return allReports;
|
| ... | ... | @@ -257,6 +265,7 @@ public class ReportModel extends AdminActionModel { |
| 257 | 265 |
|
| 258 | 266 |
public void updateReports() {
|
| 259 | 267 |
setSelectedReport(null);
|
| 268 |
+ allReports = null;
|
|
| 260 | 269 |
if (reportFile == null) {
|
| 261 | 270 |
return;
|
| 262 | 271 |
}
|
| ... | ... | @@ -272,12 +281,11 @@ public class ReportModel extends AdminActionModel { |
| 272 | 281 |
File reportFile = ObserveClientResourceManager.Resource.report.getFile(config.getReportDirectory());
|
| 273 | 282 |
|
| 274 | 283 |
if (reportFile.exists()) {
|
| 275 |
- log.info(String.format("Will use report file : %s", reportFile));
|
|
| 276 |
- |
|
| 277 |
- setReportFile(reportFile);
|
|
| 284 |
+ log.info(String.format("Will use default report file : %s", reportFile));
|
|
| 278 | 285 |
} else {
|
| 279 | 286 |
log.warn(String.format("Default report file %s does not exists.", reportFile));
|
| 280 | 287 |
}
|
| 288 |
+ setReportFile(reportFile);
|
|
| 281 | 289 |
|
| 282 | 290 |
// on ecoute la modification du modèle
|
| 283 | 291 |
PropertyChangeListener listenReportModified = evt -> {
|
| ... | ... | @@ -179,13 +179,6 @@ public class NonTargetCatchUIHandler extends ContentTableUIHandler<SetNonTargetC |
| 179 | 179 |
protected void loadEditBean(String beanId) {
|
| 180 | 180 |
Form<SetNonTargetCatchDto> form = getPsObservationNonTargetCatchService().loadForm(beanId);
|
| 181 | 181 |
getModel().openForm(form);
|
| 182 |
- //FIXME voir pk on faisait ça à ce moment
|
|
| 183 |
-// addReferentialFilter(NonTargetCatchDto.PROPERTY_SPECIES, (ReferentialReferencesFilter<SpeciesDto, SpeciesReference>) incomingReferences -> {
|
|
| 184 |
-// String speciesListId = getClientConfig().getSpeciesListSeineObservationNonTargetCatchId();
|
|
| 185 |
-// String tripId = ObserveSelectModelApplicationComponent.value().getSeine().getTrip().getId();
|
|
| 186 |
-// List<SpeciesReference> result = getTripService().getSpeciesByListAndTrip(tripId, speciesListId).toList();
|
|
| 187 |
-// return DtoReferenceCollection.filterEnabled(result);
|
|
| 188 |
-// });
|
|
| 189 | 182 |
}
|
| 190 | 183 |
|
| 191 | 184 |
@Override
|