Tony CHEMIT pushed to branch master-7.x at ultreiaio / ird-observe Commits: 3ba166c4 by Tony CHEMIT at 2018-09-23T20:08:24Z optimize i18n + detect again all we can - - - - - bd699648 by Tony CHEMIT at 2018-09-23T20:08:29Z optimize dependencies - - - - - e72eae33 by Tony CHEMIT at 2018-09-23T20:08:29Z fix desactivate referential generated sql - - - - - e8cf278f by Tony CHEMIT at 2018-09-23T20:08:30Z Fix validation result serializatoin on server mode - - - - - 5bd56caf by Tony CHEMIT at 2018-09-23T20:33:04Z Les rapports ne fonctionnent pas très bien - Closes #1081 - - - - - 6a9d6644 by Tony CHEMIT at 2018-09-23T20:33:05Z remove some default shortcuts on some uis (but it still does not work for some of them)... - - - - - 96c75a89 by Tony CHEMIT at 2018-09-23T20:41:19Z [jgitflow-maven-plugin]updating poms for 7.0-RC-22 branch with snapshot versions[skip ci] - - - - - 99b971a7 by Tony CHEMIT at 2018-09-23T20:46:59Z [jgitflow-maven-plugin]updating poms for branch'release/7.0-RC-22' with non-snapshot versions[skip ci] - - - - - 6521b438 by Tony CHEMIT at 2018-09-23T20:58:12Z [jgitflow-maven-plugin]merging 'release/7.0-RC-22' into 'master-7.x' - - - - - 27 changed files: - client/src/main/java/fr/ird/observe/client/ui/admin/config/SelectDataModel.java - client/src/main/java/fr/ird/observe/client/ui/admin/report/ReportUI.jcss - client/src/main/java/fr/ird/observe/client/ui/admin/report/ReportUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/admin/validate/ValidateConfigUI.jcss - client/src/main/java/fr/ird/observe/client/ui/admin/validate/ValidateUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/dcprefs/FloatingObjectPresetsUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/storage/presets/RemotePresetsUIHandler.java - services-client/src/test/java/fr/ird/observe/services/client/service/actions/report/AbstractReportServiceClientTest.java - services-local/src/main/java/fr/ird/observe/services/local/service/actions/report/ReportServiceLocal.java - services-local/src/main/java/fr/ird/observe/services/local/service/actions/synchro/referential/sql/DisableSqlStatementGenerator.java - services-local/src/main/java/fr/ird/observe/services/local/service/actions/validate/ValidateServiceLocal.java - services-local/src/main/java/fr/ird/observe/services/local/service/actions/validate/ValidationMessageDetector.java - services-local/src/test/java/fr/ird/observe/services/local/service/actions/report/AbstractReportServiceLocalTest.java - + services-local/src/test/java/fr/ird/observe/services/local/service/actions/report/ReportNonTargetDistributionLengthsTest.java - services/pom.xml - services/src/main/java/fr/ird/observe/services/gson/ObserveDtoGsonSupplier.java - services/src/main/java/fr/ird/observe/services/gson/ReportVariableAdapter.java - + services/src/main/java/fr/ird/observe/services/gson/ValidationResultDtoAdapter.java - services/src/main/java/fr/ird/observe/services/service/actions/report/ReportBuilder.java - services/src/main/java/fr/ird/observe/services/service/actions/report/ReportRequest.java - services/src/main/java/fr/ird/observe/services/service/actions/report/ReportService.java - + services/src/main/java/fr/ird/observe/services/service/actions/validate/DataValidationResult.java - + services/src/main/java/fr/ird/observe/services/service/actions/validate/ReferentialValidationResult.java - services/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateService.java - services/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationResult.java - services/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationResultDto.java - services/src/main/resources/observe-reports.properties Changes: ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/config/SelectDataModel.java ===================================== @@ -10,36 +10,39 @@ package fr.ird.observe.client.ui.admin.config; * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ +import com.google.common.collect.ImmutableSet; import fr.ird.observe.client.db.ObserveSwingDataSource; import fr.ird.observe.client.ui.admin.AdminActionModel; import fr.ird.observe.client.ui.admin.AdminStep; import fr.ird.observe.client.ui.admin.AdminUIModel; import fr.ird.observe.client.ui.admin.report.ReportModel; import fr.ird.observe.client.ui.tree.selection.SelectionTreeModel; +import fr.ird.observe.dto.IdDto; import fr.ird.observe.dto.IdHelper; import fr.ird.observe.dto.ObserveModelType; import fr.ird.observe.dto.data.longline.TripLonglineReference; import fr.ird.observe.dto.data.seine.TripSeineReference; import fr.ird.observe.dto.reference.DataDtoReference; import fr.ird.observe.dto.reference.DataDtoReferenceSet; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; /** * Created on 28/11/16. @@ -99,10 +102,8 @@ public class SelectDataModel extends AdminActionModel { // on doit aussi calculer les ids des marées distantes ObserveSwingDataSource safeCentralSource = uiModel.getConfigModel().getSafeCentralSource(true); - List<DataDtoReference<?, ?>> existingTrip = new ArrayList<>(); - DataDtoReferenceSet<TripSeineReference> tripSeineSet = safeCentralSource.getTripSeineService().getAllTripSeine(); - existingTrip.addAll(tripSeineSet.toSet()); + List<DataDtoReference<?, ?>> existingTrip = new ArrayList<>(tripSeineSet.toSet()); DataDtoReferenceSet<TripLonglineReference> tripLonglineSet = safeCentralSource.getTripLonglineService().getAllTripLongline(); existingTrip.addAll(tripLonglineSet.toSet()); @@ -136,6 +137,17 @@ public class SelectDataModel extends AdminActionModel { return null; } + public ImmutableSet<DataDtoReference> getSelectedTrips() { + ImmutableSet.Builder<DataDtoReference> result = ImmutableSet.builder(); + Set<DataDtoReference<?, ?>> data = getSelectionDataModel().getSelectedData(); + for (DataDtoReference<?, ?> datum : data) { + if (IdHelper.isTrip(datum)) { + result.add(datum); + } + } + return result.build(); + } + public void start(AdminUIModel uiModel) { if (!uiModel.needSelect()) { @@ -194,6 +206,7 @@ public class SelectDataModel extends AdminActionModel { public boolean validate(AdminUIModel uiModel) { boolean validate = true; + boolean empty = selectionDataModel.isSelectionEmpty(); if (uiModel.containsOperation(AdminStep.VALIDATE)) { @@ -202,7 +215,6 @@ public class SelectDataModel extends AdminActionModel { if (validate) { // il faut au moins une donnee de selectionnee - boolean empty = selectionDataModel.isSelectionEmpty(); validate = !empty; } } @@ -213,7 +225,6 @@ public class SelectDataModel extends AdminActionModel { if (validate) { // il faut au moins une donnee de selectionnee - boolean empty = selectionDataModel.isSelectionEmpty(); validate = !empty; } } @@ -224,7 +235,6 @@ public class SelectDataModel extends AdminActionModel { if (validate) { // il faut au moins une donnee de selectionnee - boolean empty = selectionDataModel.isSelectionEmpty(); validate = !empty; } } @@ -234,12 +244,15 @@ public class SelectDataModel extends AdminActionModel { validate &= uiModel.validate(AdminStep.CONFIG); if (validate) { - // il faut exactement une Trip de selectionnee - int selectedCount = selectionDataModel.getSelectedCount(); - validate = selectedCount == 1; + // il faut au moins une donnee de selectionnee + validate = !empty; } } return validate; } + + public ImmutableSet<String> getSelectedTripIds() { + return ImmutableSet.copyOf(getSelectedTrips().stream().map(IdDto::getId).collect(Collectors.toSet())); + } } ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/report/ReportUI.jcss ===================================== @@ -71,7 +71,7 @@ JToolBar { } #reportDescription { - text:{getHandler().updateSelectedReportDescrption(stepModel.getSelectedReport())}; + text:{getHandler().updateSelectedReportDescription(stepModel.getSelectedReport())}; editable:false; focusable:false; } ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/report/ReportUIHandler.java ===================================== @@ -6,22 +6,22 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ package fr.ird.observe.client.ui.admin.report; -import com.google.common.collect.Lists; +import com.google.common.collect.ImmutableSet; import fr.ird.observe.client.ObserveSwingTechnicalException; import fr.ird.observe.client.db.ObserveSwingDataSource; import fr.ird.observe.client.ui.admin.AdminStep; @@ -36,8 +36,9 @@ import fr.ird.observe.services.service.actions.report.DataMatrix; import fr.ird.observe.services.service.actions.report.Report; import fr.ird.observe.services.service.actions.report.ReportService; import fr.ird.observe.services.service.actions.report.ReportVariable; -import org.apache.logging.log4j.Logger; +import fr.ird.observe.spi.DtoModelHelper; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.decorator.Decorator; import org.nuiton.decorator.JXPathDecorator; import org.nuiton.jaxx.runtime.context.JAXXInitialContext; @@ -57,6 +58,7 @@ import java.awt.Component; import java.awt.Font; import java.awt.event.ItemEvent; import java.io.File; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; @@ -71,7 +73,7 @@ import static org.nuiton.i18n.I18n.t; */ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHandler<ReportUI> { - public static final String VARIABLE_NAME = "variableName"; + private static final String VARIABLE_NAME = "variableName"; /** Logger */ private static final Logger log = LogManager.getLogger(ReportUIHandler.class); @@ -142,14 +144,14 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa Font headerFont; - public Font getDefaultFont(JTable table) { + Font getDefaultFont(JTable table) { if (defaultFont == null) { defaultFont = table.getFont(); } return defaultFont; } - public Font getHeaderFont(JTable table) { + Font getHeaderFont(JTable table) { if (headerFont == null) { headerFont = getDefaultFont(table).deriveFont(Font.BOLD); } @@ -187,13 +189,13 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa configUI.getExtraConfig().add(extraConfig); } - public void setModelTypeFromEvent(ItemEvent event) { + void setModelTypeFromEvent(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { getStepModel().setModelType((ObserveModelType) event.getItem()); } } - public void updateSelectedReportFromEvent(ItemEvent event) { + void updateSelectedReportFromEvent(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { if (log.isInfoEnabled()) { @@ -204,7 +206,7 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa } } - public void updateSelectedReport(Report report) { + void updateSelectedReport(Report report) { ui.getModel().setBusy(true); try { if (log.isInfoEnabled()) { @@ -217,14 +219,14 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa } } - public String updateSelectedReportDescrption(Report report) { + String updateSelectedReportDescription(Report report) { if (report == null) { return t("observe.message.no.report.selected"); } return t(report.getDescription()); } - public void updateVariable(JComboBox combo, Object value) { + private void updateVariable(JComboBox combo, Object value) { String variableName = (String) combo.getClientProperty(VARIABLE_NAME); if (variableName == null) { throw new IllegalStateException( @@ -236,7 +238,7 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa getStepModel().addVariable(variableName, value); } - public void chooseReportFile() { + void chooseReportFile() { ReportModel model = ui.getModel().getReportModel(); File f = UIHelper.chooseFile( ui, @@ -248,10 +250,10 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa model.setReportFile(f); } - public void copyReportToClipBoard(Report report, - ResultTableModel model, - boolean copyRowHeaders, - boolean copyColumnHeaders) { + void copyReportToClipBoard(Report report, + ResultTableModel model, + boolean copyRowHeaders, + boolean copyColumnHeaders) { if (report == null) { // pas de report sélectionné, rien à faire @@ -267,7 +269,7 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa UIHelper.copyToClipBoard(content); } - protected void onReportsChanged(ReportUI tabUI, List<?> newValue) { + private void onReportsChanged(ReportUI tabUI, List<?> newValue) { if (log.isDebugEnabled()) { log.debug("New reports : " + newValue); @@ -281,7 +283,7 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa } @SuppressWarnings({"unchecked"}) - protected void onSelectedReportChanged(ReportUI tabUI, ReportModel model, Report report) { + private void onSelectedReportChanged(ReportUI tabUI, ReportModel model, Report report) { if (log.isInfoEnabled()) { log.info("New selected report [" + report + "]"); @@ -309,7 +311,7 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa ReportService reportService = dataSource.getReportService(); - report = reportService.populateVariables(report, ui.getModel().getSelectDataModel().getSelectedTrip().getId()); + report = reportService.populateVariables(report, ui.getModel().getSelectDataModel().getSelectedTripIds()); } catch (Exception e) { throw new ObserveSwingTechnicalException("unable to populate report : " + report.getName(), e); @@ -322,16 +324,18 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa String variableName = variable.getName(); // String value = variables.get(variableName); Set values = variable.getValues(); - List<Object> universe = Lists.newArrayList(values); + List<Object> universe = new ArrayList<>(values); BeanComboBox<Object> combo = new BeanComboBox<>(); combo.setShowReset(true); variablesPanel.add(combo); Decorator decorator; if (ReferentialDto.class.isAssignableFrom(variable.getType()) && !universe.isEmpty()) { - decorator = getDecoratorService().getReferentialReferenceDecorator(variable.getType()); + Class type = DtoModelHelper.fromReferentialDto(variable.getType()).toReferenceType(); + decorator = getDecoratorService().getReferentialReferenceDecorator(type); } else if (DataDto.class.isAssignableFrom(variable.getType()) && !universe.isEmpty()) { - decorator = getDecoratorService().getDataReferenceDecorator(variable.getType()); + Class type = DtoModelHelper.fromDataDto(variable.getType()).toReferenceType(); + decorator = getDecoratorService().getDataReferenceDecorator(type); } else { decorator = getDecoratorService().getDecoratorByType(variable.getType()); } @@ -372,7 +376,7 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa } } - protected void onVariablesChanges(ReportModel model, Map<String, Object> variables) { + private void onVariablesChanges(ReportModel model, Map<String, Object> variables) { Report report = model.getSelectedReport(); if (report != null) { @@ -381,7 +385,7 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa } } - protected void onValidChanged(ReportModel model, boolean valid) { + private void onValidChanged(ReportModel model, boolean valid) { if (log.isInfoEnabled()) { log.info("valid state changed to " + valid); @@ -399,11 +403,10 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa Report report = model.getSelectedReport(); + ImmutableSet<String> tripIds = ui.getModel().getSelectDataModel().getSelectedTripIds(); DataDtoReference trip = ui.getModel().getSelectDataModel().getSelectedTrip(); - if (log.isDebugEnabled()) { - log.debug("Build result for report [" + report.getName() + "] on " + trip); - } + log.info(String.format("Build result for report [%s] on %s", report.getName(), trip)); Map<String, Object> variables = model.getVariables(); @@ -421,13 +424,11 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa ReportService reportService = dataSource.getReportService(); - DataMatrix data = reportService.executeReport(report, trip.getId()); + DataMatrix data = reportService.executeReport(report, tripIds); timeLog.log(startTime, "execute", report.getName()); - if (log.isInfoEnabled()) { - log.info("Result to dispaly:\n" + data.getClipboardContent(true, true, false, '\t')); - } + log.info("Result to display:\n" + data.getClipboardContent(true, true, false, '\t')); // calcul des données et contruction du tableau model.getResultModel().populate(report, data); @@ -439,17 +440,11 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa model.isCopyRowHeaders(), model.isCopyColumnHeaders()); } - } catch (Exception e) { - UIHelper.handlingError("Could not obtain report data", e); - model.getResultModel().clear(); - } finally { - ui.getModel().setBusy(false); - } } @@ -457,15 +452,13 @@ public class ReportUIHandler extends AdminTabUIHandler<ReportUI> implements UIHa return ui.getModel().getReportModel(); } - protected void updateValidState(Report report, Map<String, Object> variables) { - + private void updateValidState(Report report, Map<String, Object> variables) { boolean canExecute = report != null && report.canExecute(variables); getStepModel().setValid(canExecute); } public void destroy() { ObserveSwingDataSource dataSource = ui.getModel().getConfigModel().getSafeLocalSource(false); - if (dataSource.isOpen()) { dataSource.close(); } ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/validate/ValidateConfigUI.jcss ===================================== @@ -68,19 +68,19 @@ #ERROR { _value:{NuitonValidatorScope.ERROR}; - text:{NuitonValidatorScope.ERROR.getLabel()}; + text:{t(NuitonValidatorScope.ERROR.getLabel())}; selected:{getHandler().isScopeSelected(validateModel.getScopes(), ERROR)}; } #WARNING { _value:{NuitonValidatorScope.WARNING}; - text:{NuitonValidatorScope.WARNING.getLabel()}; + text:{t(NuitonValidatorScope.WARNING.getLabel())}; selected:{getHandler().isScopeSelected(validateModel.getScopes(), WARNING)}; } #INFO { _value:{NuitonValidatorScope.INFO}; - text:{NuitonValidatorScope.INFO.getLabel()}; + text:{t(NuitonValidatorScope.INFO.getLabel())}; selected:{getHandler().isScopeSelected(validateModel.getScopes(), INFO)}; } ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/validate/ValidateUIHandler.java ===================================== @@ -6,15 +6,15 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -43,6 +43,7 @@ import fr.ird.observe.dto.reference.DataDtoReference; import fr.ird.observe.dto.reference.DtoReference; import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.services.service.actions.validate.DataValidationRequest; +import fr.ird.observe.services.service.actions.validate.DataValidationResult; import fr.ird.observe.services.service.actions.validate.ReferentialValidationRequest; import fr.ird.observe.services.service.actions.validate.ValidateService; import fr.ird.observe.services.service.actions.validate.ValidationResult; @@ -50,8 +51,8 @@ import fr.ird.observe.services.service.actions.validate.ValidationResultDto; import fr.ird.observe.services.service.actions.validate.ValidationResultDtoMessage; import fr.ird.observe.services.validation.ValidatorDto; import org.apache.commons.io.FileUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.jaxx.runtime.context.JAXXInitialContext; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.jaxx.runtime.swing.wizard.ext.WizardState; @@ -410,7 +411,7 @@ public class ValidateUIHandler extends AdminTabUIHandler<ValidateUI> implements mainRequest.setValidationLengthWeightEnable(config.getValidationLengthWeightEnable()); mainRequest.setSeineBycatchObservedSystemConfig(config.getSeineBycatchObservedSystem()); - ValidationResult.Builder<DataValidationRequest> resultBuilder = ValidationResult.builder(ReferentialLocale.valueOf(config.getDbLocale()), mainRequest); + ValidationResult.Builder<DataValidationRequest, DataValidationResult> resultBuilder = DataValidationResult.builder(ReferentialLocale.valueOf(config.getDbLocale()), mainRequest); for (DataDtoReference<?, ?> dataReference : dataModel.getSelectedData()) { ===================================== client/src/main/java/fr/ird/observe/client/ui/dcprefs/FloatingObjectPresetsUIHandler.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.dcprefs; * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. @@ -33,8 +33,12 @@ import org.nuiton.jaxx.runtime.swing.renderer.DecoratorListCellRenderer; import javax.swing.AbstractButton; import javax.swing.DefaultListModel; +import javax.swing.JComponent; +import javax.swing.JSplitPane; +import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import java.awt.BorderLayout; +import java.awt.event.KeyEvent; import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -69,6 +73,8 @@ public class FloatingObjectPresetsUIHandler implements UIHandler<FloatingObjectP if (o instanceof AbstractButton) { init(actionMap, (AbstractButton) o); + } else if (o instanceof JSplitPane) { + init((JSplitPane) o); } } @@ -119,6 +125,12 @@ public class FloatingObjectPresetsUIHandler implements UIHandler<FloatingObjectP UIHelper.askFocus(ui.getQuitAction()); } + + protected void init(JSplitPane editor) { + editor.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) + .put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), "none"); + } + protected void init(ObserveActionMap actionMap, AbstractButton editor) { String actionId = (String) editor.getClientProperty(OBSERVE_ACTION); if (actionId == null) { ===================================== client/src/main/java/fr/ird/observe/client/ui/storage/presets/RemotePresetsUIHandler.java ===================================== @@ -29,8 +29,8 @@ import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.dto.decoration.DecoratorService; import fr.ird.observe.dto.presets.RemoteDataSourceConfiguration; import fr.ird.observe.dto.presets.ServerDataSourceConfiguration; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.decorator.Decorator; import org.nuiton.jaxx.runtime.spi.UIHandler; import org.nuiton.jaxx.runtime.swing.renderer.DecoratorListCellRenderer; @@ -40,8 +40,11 @@ import javax.swing.ActionMap; import javax.swing.DefaultListModel; import javax.swing.InputMap; import javax.swing.JComponent; +import javax.swing.JSplitPane; +import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import java.awt.BorderLayout; +import java.awt.event.KeyEvent; import java.util.List; import java.util.Objects; @@ -79,6 +82,8 @@ public class RemotePresetsUIHandler implements UIHandler<RemotePresetsUI> { if (o instanceof AbstractButton) { init(inputMap, actionMap, (AbstractButton) o); + } else if (o instanceof JSplitPane) { + init((JSplitPane) o); } } @@ -190,6 +195,11 @@ public class RemotePresetsUIHandler implements UIHandler<RemotePresetsUI> { } + protected void init(JSplitPane editor) { + editor.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) + .put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), "none"); + } + protected void init(InputMap inputMap, ActionMap actionMap, AbstractButton editor) { String actionId = (String) editor.getClientProperty(OBSERVE_ACTION); if (actionId == null) { ===================================== services-client/src/test/java/fr/ird/observe/services/client/service/actions/report/AbstractReportServiceClientTest.java ===================================== @@ -6,15 +6,15 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -22,6 +22,7 @@ package fr.ird.observe.services.client.service.actions.report; +import com.google.common.collect.ImmutableSet; import fr.ird.observe.dto.reference.DtoReference; import fr.ird.observe.services.client.service.ServiceClientTestSupport; import fr.ird.observe.services.service.actions.report.DataMatrix; @@ -43,7 +44,7 @@ import java.util.List; /** * Classe abstraite de test d'un report. - * + * <p> * On définit ici le mécanisme pour tester unitairement un report et son * résultat. * @@ -54,15 +55,45 @@ public abstract class AbstractReportServiceClientTest extends ServiceClientTestS /** Logger */ private static final Logger log = LogManager.getLogger(AbstractReportServiceClientTest.class); - - protected ReportService service; - /** La liste de tous les reports connus. */ protected static List<Report> reports; - + protected ReportService service; /** Le report à tester. */ private Report report; + protected static Report getReport(Logger log, String reportId) throws IOException { + if (reports == null) { + + URL reportLocation = + AbstractReportServiceClientTest.class.getResource("/observe-reports.properties"); + + if (log.isInfoEnabled()) { + log.info("Loading reports from " + reportLocation); + } + + ReportBuilder builder = new ReportBuilder(); + + reports = builder.load(reportLocation); + + builder.clear(); + + Assert.assertNotNull(reports); + Assert.assertFalse(reports.isEmpty()); + } + + Report result = null; + // recuperation du report à tester + for (Report report : reports) { + if (reportId.equals(report.getId())) { + result = report; + break; + } + } + + Assert.assertNotNull("Could not find report with id " + reportId, reports); + return result; + } + protected abstract String getReportId(); @Before @@ -81,16 +112,14 @@ public abstract class AbstractReportServiceClientTest extends ServiceClientTestS } - /** * L'unique test à lancer. - * + * <p> * On vérifie : * <ul> * <li>la syntaxe du report via {@link #testReportSyntax(Report)}</li> * <li>le résultat du report via {@link #testReportResult(DataMatrix)}</li> * </ul> - * */ @Test public final void testReport() { @@ -99,23 +128,25 @@ public abstract class AbstractReportServiceClientTest extends ServiceClientTestS testReportSyntax(report); // creation de l'executeur de report - report = service.populateVariables(report, ObserveFixtures.TRIP_SEINE_ID_1); + ImmutableSet<String> tripIds = getTripIds(); + report = service.populateVariables(report, tripIds); // preparation des variables prepareVariables(); // on execute le report - DataMatrix result = service.executeReport(report,ObserveFixtures. TRIP_SEINE_ID_1); - - if (log.isInfoEnabled()) { - log.info("Result :\n" + result.getClipboardContent(true, true, false, '\t')); - } + DataMatrix result = service.executeReport(report, tripIds); + log.info("Result :\n" + result.getClipboardContent(true, true, false, '\t')); // on verifie le resultat testReportResult(result); } + protected ImmutableSet<String> getTripIds() { + return ImmutableSet.of(ObserveFixtures.TRIP_SEINE_ID_1); + } + protected void prepareVariables() { } @@ -127,9 +158,9 @@ public abstract class AbstractReportServiceClientTest extends ServiceClientTestS if (variableName.equals(variable.getName())) { Object value = variable.getValues().stream() - .filter(DtoReference.newIdPredicate(id)) - .findFirst() - .orElse(null); + .filter(DtoReference.newIdPredicate(id)) + .findFirst() + .orElse(null); variable.setSelectedValue(value); @@ -143,39 +174,6 @@ public abstract class AbstractReportServiceClientTest extends ServiceClientTestS protected abstract void testReportResult(DataMatrix result); - protected static Report getReport(Logger log, String reportId) throws IOException { - if (reports == null) { - - URL reportLocation = - AbstractReportServiceClientTest.class.getResource("/observe-reports.properties"); - - if (log.isInfoEnabled()) { - log.info("Loading reports from " + reportLocation); - } - - ReportBuilder builder = new ReportBuilder(); - - reports = builder.load(reportLocation); - - builder.clear(); - - Assert.assertNotNull(reports); - Assert.assertFalse(reports.isEmpty()); - } - - Report result = null; - // recuperation du report à tester - for (Report report : reports) { - if (reportId.equals(report.getId())) { - result = report; - break; - } - } - - Assert.assertNotNull("Could not find report with id " + reportId, reports); - return result; - } - protected void assertReportName(Report report, String name, String description) { ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/actions/report/ReportServiceLocal.java ===================================== @@ -10,18 +10,19 @@ package fr.ird.observe.services.local.service.actions.report; * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import fr.ird.observe.dto.data.DataDto; import fr.ird.observe.dto.reference.DataDtoReferenceSet; @@ -42,6 +43,10 @@ import fr.ird.observe.services.service.actions.report.ReportVariable; import fr.ird.observe.spi.DbModelHelper; import fr.ird.observe.spi.context.DataDtoEntityContext; import fr.ird.observe.spi.context.ReferentialDtoEntityContext; +import org.apache.commons.lang3.mutable.MutableInt; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.awt.Dimension; import java.awt.Point; import java.io.Serializable; @@ -53,9 +58,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; -import org.apache.commons.lang3.mutable.MutableInt; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; /** * @author Tony Chemit - dev@tchemit.fr @@ -66,11 +68,11 @@ public class ReportServiceLocal extends ObserveServiceLocal implements ReportSer private static final Logger log = LogManager.getLogger(ReportServiceLocal.class); @Override - public Report populateVariables(Report report, String tripId) { + public Report populateVariables(Report report, ImmutableSet<String> tripIds) { Map<String, Object> vars = new TreeMap<>(); - vars.put(ReportRequest.TRIP_ID_VARIABLE, tripId); + vars.put(ReportRequest.TRIP_ID_VARIABLE, tripIds); for (ReportVariable variable : report.getVariables()) { @@ -116,7 +118,7 @@ public class ReportServiceLocal extends ObserveServiceLocal implements ReportSer } @Override - public DataMatrix executeReport(Report report, String tripId) { + public DataMatrix executeReport(Report report, ImmutableSet<String> tripId) { if (report == null) { @@ -171,7 +173,7 @@ public class ReportServiceLocal extends ObserveServiceLocal implements ReportSer return result; } - private DataMatrix executeReportOperation(ReportOperation executeRequests, Report report, String tripId, DataMatrix incoming) { + private DataMatrix executeReportOperation(ReportOperation executeRequests, Report report, ImmutableSet<String> tripId, DataMatrix incoming) { DataMatrix result = incoming; @@ -413,7 +415,7 @@ public class ReportServiceLocal extends ObserveServiceLocal implements ReportSer return result; } - private DataMatrix executeReportRequest(ReportRequest request, Report report, String tripId, ReportVariable repeatValues) { + private DataMatrix executeReportRequest(ReportRequest request, Report report, ImmutableSet<String> tripId, ReportVariable repeatValues) { DataMatrix result = new DataMatrix(); @@ -457,7 +459,7 @@ public class ReportServiceLocal extends ObserveServiceLocal implements ReportSer return result; } - private DataMatrix executeReportRequest(ReportRequest request, Report report, String tripId) { + private DataMatrix executeReportRequest(ReportRequest request, Report report, ImmutableSet<String> tripId) { Map<String, Object> params = ReportRequest.extractParams(report, tripId); return executeReportRequest(request, params); @@ -650,10 +652,11 @@ public class ReportServiceLocal extends ObserveServiceLocal implements ReportSer AbstractObserveTopiaDao dao = (AbstractObserveTopiaDao) getTopiaPersistenceContext().getDao(TripSeine.class); + log.info(String.format("Request: %s, params: %s", request, paramsFixes)); return dao.findAllFromHql(request, paramsFixes); } - private void doPopulateRepeatVariables(Report report, String tripId) { + private void doPopulateRepeatVariables(Report report, ImmutableSet<String> tripId) { Map<String, Object> vars = ReportRequest.extractParams(report, tripId); ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/actions/synchro/referential/sql/DisableSqlStatementGenerator.java ===================================== @@ -43,7 +43,7 @@ public class DisableSqlStatementGenerator { } public String generateSql(String sourceId) { - return TopiaSqlStatements.generateUpdateStatement(metadataEntity, sourceId, "enabled = false, topiaVersion = topiaVersion + 1"); + return TopiaSqlStatements.generateUpdateStatement(metadataEntity, sourceId, "status = 0, topiaVersion = topiaVersion + 1"); } } ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/actions/validate/ValidateServiceLocal.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.services.local.service.actions.validate; * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. @@ -33,25 +33,24 @@ import fr.ird.observe.dto.reference.ReferentialDtoReference; import fr.ird.observe.dto.referential.ReferentialDto; import fr.ird.observe.dto.referential.ReferentialLocale; import fr.ird.observe.dto.referential.SpeciesDto; -import fr.ird.observe.dto.referential.seine.ObservedSystemReference; import fr.ird.observe.entities.Trip; import fr.ird.observe.entities.referentiel.ObserveReferentialEntity; import fr.ird.observe.entities.referentiel.Species; -import fr.ird.observe.entities.referentiel.seine.ObservedSystem; import fr.ird.observe.persistence.Entities; import fr.ird.observe.services.local.service.ObserveServiceLocal; import fr.ird.observe.services.service.actions.validate.DataValidationRequest; +import fr.ird.observe.services.service.actions.validate.DataValidationResult; import fr.ird.observe.services.service.actions.validate.ReferentialValidationRequest; +import fr.ird.observe.services.service.actions.validate.ReferentialValidationResult; import fr.ird.observe.services.service.actions.validate.ValidateService; import fr.ird.observe.services.service.actions.validate.ValidationRequest; -import fr.ird.observe.services.service.actions.validate.ValidationResult; import fr.ird.observe.services.service.referential.ReferentialService; import fr.ird.observe.services.validation.ServiceValidationContext; import fr.ird.observe.services.validation.ValidationDataContext; import fr.ird.observe.services.validation.ValidatorsMap; import fr.ird.observe.spi.DbModelHelper; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.validator.xwork2.XWork2ValidatorUtil; import java.util.List; @@ -71,12 +70,12 @@ public class ValidateServiceLocal extends ObserveServiceLocal implements Validat private static final ExecutorService EXECUTOR_SERVICE = Executors.newFixedThreadPool(5); @Override - public ValidationResult<ReferentialValidationRequest> validateReferential(ReferentialValidationRequest request) { + public ReferentialValidationResult validateReferential(ReferentialValidationRequest request) { - Future<ValidationResult<ReferentialValidationRequest>> future = EXECUTOR_SERVICE.submit(() -> { + Future<ReferentialValidationResult> future = EXECUTOR_SERVICE.submit(() -> { ReferentialLocale referentialLocale = getReferentialLocale(); - ValidationResult.Builder<ReferentialValidationRequest> resultBuilder = ValidationResult.builder(referentialLocale, request); + ReferentialValidationResult.Builder<ReferentialValidationRequest, ReferentialValidationResult> resultBuilder = ReferentialValidationResult.builder(referentialLocale, request); ServiceValidationContext validationContext = createServiceValidationContext(request); @@ -101,12 +100,12 @@ public class ValidateServiceLocal extends ObserveServiceLocal implements Validat } @Override - public ValidationResult<DataValidationRequest> validateData(DataValidationRequest request) { + public DataValidationResult validateData(DataValidationRequest request) { - Future<ValidationResult<DataValidationRequest>> future = EXECUTOR_SERVICE.submit(() -> { + Future<DataValidationResult> future = EXECUTOR_SERVICE.submit(() -> { ReferentialLocale referentialLocale = getReferentialLocale(); - ValidationResult.Builder<DataValidationRequest> resultBuilder = ValidationResult.builder(referentialLocale, request); + DataValidationResult.Builder<DataValidationRequest, DataValidationResult> resultBuilder = DataValidationResult.builder(referentialLocale, request); ServiceValidationContext validationContext = createServiceValidationContext(request); ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/actions/validate/ValidationMessageDetector.java ===================================== @@ -35,6 +35,7 @@ import fr.ird.observe.dto.data.seine.RouteDto; import fr.ird.observe.dto.data.seine.SetSeineDto; import fr.ird.observe.dto.data.seine.TripSeineDto; import fr.ird.observe.entities.ObserveEntity; +import fr.ird.observe.services.service.actions.validate.ReferentialValidationResult; import fr.ird.observe.services.service.actions.validate.ValidationResult; import fr.ird.observe.services.validation.ServiceValidationContext; import fr.ird.observe.services.validation.ValidatorsMap; @@ -135,7 +136,7 @@ class ValidationMessageDetector implements SimpleBeanValidatorListener { static ValidationMessageDetector forReferential(ValidatorsMap validators, ServiceValidationContext validationDataContext, ReferentialLocale referentialLocale, - ValidationResult.Builder resultBuilder) { + ReferentialValidationResult.Builder resultBuilder) { ImmutableMap.Builder<Class, EntityInterceptor> interceptorsBuilder = ImmutableMap.builder(); ===================================== services-local/src/test/java/fr/ird/observe/services/local/service/actions/report/AbstractReportServiceLocalTest.java ===================================== @@ -6,15 +6,15 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -22,6 +22,7 @@ package fr.ird.observe.services.local.service.actions.report; +import com.google.common.collect.ImmutableSet; import fr.ird.observe.dto.reference.DtoReference; import fr.ird.observe.services.local.service.ServiceLocalTestSupport; import fr.ird.observe.services.service.actions.report.DataMatrix; @@ -33,15 +34,16 @@ import fr.ird.observe.services.service.actions.report.ReportVariable; import fr.ird.observe.test.DatabaseName; import fr.ird.observe.test.ObserveFixtures; import fr.ird.observe.test.spi.DatabaseNameConfiguration; -import java.io.IOException; -import java.net.URL; -import java.util.List; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.io.IOException; +import java.net.URL; +import java.util.List; + /** * Classe abstraite de test d'un report. * <p> @@ -56,15 +58,45 @@ public abstract class AbstractReportServiceLocalTest extends ServiceLocalTestSup /** Logger */ private static final Logger log = LogManager.getLogger(AbstractReportServiceLocalTest.class); - - protected ReportService service; - /** La liste de tous les reports connus. */ protected static List<Report> reports; - + protected ReportService service; /** Le report à tester. */ private Report report; + protected static Report getReport(Logger log, String reportId) throws IOException { + if (reports == null) { + + URL reportLocation = + AbstractReportServiceLocalTest.class.getResource("/observe-reports.properties"); + + if (log.isInfoEnabled()) { + log.info("Loading reports from " + reportLocation); + } + + ReportBuilder builder = new ReportBuilder(); + + reports = builder.load(reportLocation); + + builder.clear(); + + Assert.assertNotNull(reports); + Assert.assertFalse(reports.isEmpty()); + } + + Report result = null; + // recuperation du report à tester + for (Report report : reports) { + if (reportId.equals(report.getId())) { + result = report; + break; + } + } + + Assert.assertNotNull("Could not find report with id " + reportId, reports); + return result; + } + protected abstract String getReportId(); @Before @@ -81,7 +113,6 @@ public abstract class AbstractReportServiceLocalTest extends ServiceLocalTestSup } - /** * L'unique test à lancer. * <p> @@ -90,7 +121,6 @@ public abstract class AbstractReportServiceLocalTest extends ServiceLocalTestSup * <li>la syntaxe du report via {@link #testReportSyntax(Report)}</li> * <li>le résultat du report via {@link #testReportResult(DataMatrix)}</li> * </ul> - * */ @Test public final void testReport() { @@ -98,24 +128,28 @@ public abstract class AbstractReportServiceLocalTest extends ServiceLocalTestSup // test de la syntaxe du report testReportSyntax(report); + ImmutableSet<String> tripIds = getTripIds(); + // creation de l'executeur de report - report = service.populateVariables(report, ObserveFixtures.TRIP_SEINE_ID_1); + report = service.populateVariables(report, tripIds); // preparation des variables prepareVariables(); // on execute le report - DataMatrix result = service.executeReport(report, ObserveFixtures.TRIP_SEINE_ID_1); + DataMatrix result = service.executeReport(report, tripIds); - if (log.isInfoEnabled()) { - log.info("Result :\n" + result.getClipboardContent(true, true, true, ',')); - } + log.info(String.format("Result :\n%s", result.getClipboardContent(true, true, true, ','))); // on verifie le resultat testReportResult(result); } + protected ImmutableSet<String> getTripIds() { + return ImmutableSet.of(ObserveFixtures.TRIP_SEINE_ID_1); + } + protected void prepareVariables() { } @@ -143,39 +177,6 @@ public abstract class AbstractReportServiceLocalTest extends ServiceLocalTestSup protected abstract void testReportResult(DataMatrix result); - protected static Report getReport(Logger log, String reportId) throws IOException { - if (reports == null) { - - URL reportLocation = - AbstractReportServiceLocalTest.class.getResource("/observe-reports.properties"); - - if (log.isInfoEnabled()) { - log.info("Loading reports from " + reportLocation); - } - - ReportBuilder builder = new ReportBuilder(); - - reports = builder.load(reportLocation); - - builder.clear(); - - Assert.assertNotNull(reports); - Assert.assertFalse(reports.isEmpty()); - } - - Report result = null; - // recuperation du report à tester - for (Report report : reports) { - if (reportId.equals(report.getId())) { - result = report; - break; - } - } - - Assert.assertNotNull("Could not find report with id " + reportId, reports); - return result; - } - protected void assertReportName(Report report, String name, String description) { @@ -228,12 +229,12 @@ public abstract class AbstractReportServiceLocalTest extends ServiceLocalTestSup protected void assertResultRow(DataMatrix result, int rowId, Object... row) { Object[] actualRow = result.getData()[rowId]; - int index=0; + int index = 0; for (Object o : actualRow) { - if (o==null) { + if (o == null) { Assert.assertEquals(row[index++], o); - }else { - Assert.assertArrayEquals(row[index++].toString().split("\\s*\\n\\s*"),o.toString().split("\\s*\\n\\s*")); + } else { + Assert.assertArrayEquals(row[index++].toString().split("\\s*\\n\\s*"), o.toString().split("\\s*\\n\\s*")); } } //Assert.assertArrayEquals(row, actualRow); ===================================== services-local/src/test/java/fr/ird/observe/services/local/service/actions/report/ReportNonTargetDistributionLengthsTest.java ===================================== @@ -0,0 +1,89 @@ +/* + * #%L + * ObServe :: Services local implementation + * %% + * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package fr.ird.observe.services.local.service.actions.report; + + +import com.google.common.collect.ImmutableSet; +import fr.ird.observe.services.service.actions.report.DataMatrix; +import fr.ird.observe.services.service.actions.report.Report; +import fr.ird.observe.services.service.actions.report.ReportRequest; +import fr.ird.observe.test.ObserveFixtures; +import org.junit.Assert; + +/** + * Test du report {@code accessoryCatch}. + * + * @author Tony Chemit - dev@tchemit.fr + * @since 1.9 + */ +public class ReportNonTargetDistributionLengthsTest extends AbstractReportServiceLocalTest { + + @Override + protected void testReportSyntax(Report report) { + Assert.assertNotNull(report); + assertReportName( + report, + "Distribution des tailles par espèces non ciblées", + "Afficher la nombre d'individus mesurés par classe de taille pour les espèces non ciblées" + ); + + assertReportDimension( + report, + -1, + 2, + new String[]{"Classe de taille", "Effectif"} + ); + + assertReportNbRequests(report, 1); + + ReportRequest[] requests = report.getRequests(); + + assertReportRequestDimension( + requests[0], + ReportRequest.RequestLayout.row, + 0, + 0 + ); + + } + + @Override + protected String getReportId() { + return "nonTargetDistributionLengths"; + } + + @Override + protected ImmutableSet<String> getTripIds() { + return ImmutableSet.of(ObserveFixtures.TRIP_SEINE_ID_1, ObserveFixtures.TRIP_SEINE_ID_2); + } + + @Override + protected void prepareVariables() { + setVariableValue("speciesId", "fr.ird.observe.entities.referentiel.Species#1239832684439#0.9130769003657221"); + } + + @Override + protected void testReportResult(DataMatrix result) { + assertResultDimension(result, 2, 1, 0, 1); + assertResultRow(result, 0, "14.0", "1"); + } +} ===================================== services/pom.xml ===================================== @@ -93,6 +93,10 @@ <groupId>io.ultreia.java4all.jaxx</groupId> <artifactId>jaxx-widgets-gis</artifactId> </dependency> + <dependency> + <groupId>io.ultreia.java4all</groupId> + <artifactId>java-lang</artifactId> + </dependency> <!-- XWork --> <dependency> ===================================== services/src/main/java/fr/ird/observe/services/gson/ObserveDtoGsonSupplier.java ===================================== @@ -25,6 +25,7 @@ package fr.ird.observe.services.gson; import com.google.gson.GsonBuilder; import fr.ird.observe.services.service.actions.consolidate.dcp.FloatingObjectModification; import fr.ird.observe.services.service.actions.report.ReportVariable; +import fr.ird.observe.services.service.actions.validate.ValidationResultDto; import io.ultreia.java4all.http.HResponseError; import io.ultreia.java4all.http.HResponseErrorAdapter; @@ -51,7 +52,7 @@ public class ObserveDtoGsonSupplier extends ObserveDtoGsonSupplierSupport { gsonBuilder.registerTypeAdapter(ReportVariable.class, new ReportVariableAdapter()); gsonBuilder.registerTypeAdapter(HResponseError.class, new HResponseErrorAdapter()); gsonBuilder.registerTypeAdapter(FloatingObjectModification.class, new FloatingObjectModificationAdapter()); - + gsonBuilder.registerTypeAdapter(ValidationResultDto.class, new ValidationResultDtoAdapter()); } return gsonBuilder; ===================================== services/src/main/java/fr/ird/observe/services/gson/ReportVariableAdapter.java ===================================== @@ -29,10 +29,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; import fr.ird.observe.dto.data.DataDto; -import fr.ird.observe.dto.reference.DataDtoReference; -import fr.ird.observe.dto.reference.ReferentialDtoReference; import fr.ird.observe.dto.referential.ReferentialDto; import fr.ird.observe.services.service.actions.report.ReportVariable; +import fr.ird.observe.spi.DtoModelHelper; import java.lang.reflect.Type; import java.util.Set; @@ -55,10 +54,10 @@ public class ReportVariableAdapter implements JsonDeserializer<ReportVariable> { Class valueType = type; if (DataDto.class.isAssignableFrom(type)) { - valueType = DataDtoReference.class; + valueType = DtoModelHelper.fromDataDto((Class) type).toReferenceType(); } if (ReferentialDto.class.isAssignableFrom(type)) { - valueType = ReferentialDtoReference.class; + valueType = DtoModelHelper.fromReferentialDto((Class) type).toReferenceType(); } JsonElement valuesJson = reportVariableJson.get(ReportVariable.PROPERTY_VALUES); ===================================== services/src/main/java/fr/ird/observe/services/gson/ValidationResultDtoAdapter.java ===================================== @@ -0,0 +1,65 @@ +package fr.ird.observe.services.gson; + +/* + * #%L + * ObServe :: Services API + * %% + * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import fr.ird.observe.dto.reference.DtoReference; +import fr.ird.observe.services.service.actions.validate.ValidationResultDto; +import fr.ird.observe.services.service.actions.validate.ValidationResultDtoMessage; + +import java.lang.reflect.Type; +import java.util.Set; + +/** + * Created by tchemit on 23/09/2018. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class ValidationResultDtoAdapter implements JsonDeserializer<ValidationResultDto>, JsonSerializer<ValidationResultDto> { + + @Override + public ValidationResultDto deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + JsonObject reportVariableJson = json.getAsJsonObject(); + Class<?> type = context.deserialize(reportVariableJson.get("type"), Class.class); + DtoReference dtoReference = context.deserialize(reportVariableJson.get("dtoReference"), type); + Set<ValidationResultDtoMessage> messages = context.deserialize(reportVariableJson.get("messages"), ImmutableSetAdapter.setOf(TypeToken.of(ValidationResultDtoMessage.class)).getType()); + return new ValidationResultDto(dtoReference, ImmutableSet.copyOf(messages)); + } + + @Override + public JsonElement serialize(ValidationResultDto src, Type typeOfSrc, JsonSerializationContext context) { + JsonObject result = new JsonObject(); + result.add("type", context.serialize(src.getReference().getReferenceType())); + result.add("dtoReference", context.serialize(src.getReference())); + result.add("messages", context.serialize(src.getMessages().asList())); + return result; + } +} ===================================== services/src/main/java/fr/ird/observe/services/service/actions/report/ReportBuilder.java ===================================== @@ -6,15 +6,15 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -23,6 +23,7 @@ package fr.ird.observe.services.service.actions.report; import fr.ird.observe.dto.ObserveModelType; +import io.ultreia.java4all.lang.Objects2; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import org.nuiton.util.SortedProperties; @@ -62,16 +63,13 @@ public class ReportBuilder { /** Logger */ private static final Logger log = LogManager.getLogger(ReportBuilder.class); - + /** les operations connues par le système */ + protected static Map<String, Class<?>> operations; /** les propriétés chargées par le builder pour construire les reports */ protected Properties properties; - /** la liste des lastName sde reports connus par le système */ protected List<String> reportNames; - /** les operations connues par le système */ - protected static Map<String, Class<?>> operations; - public List<String> getReportNames() { return reportNames; } @@ -331,7 +329,7 @@ public class ReportBuilder { // on interdit l'utilisation de la variable tripId if (ReportRequest.TRIP_ID_VARIABLE.equals(id)) { - throw new IllegalArgumentException("La variable tripId n'est pas utilisable (c'est uen variable réservée) pour le report " + reportName); + throw new IllegalArgumentException("La variable tripId n'est pas utilisable (c'est une variable réservée) pour le report " + reportName); } ids.add(id); String[] parts = operations.split("\\|"); @@ -341,13 +339,8 @@ public class ReportBuilder { } String typeStr = parts[0].trim(); String request = parts[1].trim(); - Class<?> type; - try { - type = Class.forName(typeStr); - } catch (ClassNotFoundException eee) { - throw new IllegalArgumentException("Le type " + typeStr + " n'est pas connu", eee); - } - ReportVariable variable = new ReportVariable(id, type, request); + Class<?> type = Objects2.forName(typeStr); + ReportVariable<?> variable = new ReportVariable<>(id, type, request); log.debug(String.format("Detects a variable : [%s:%s] = %s (type = %s)", reportName, variable.getName(), variable.getRequest(), variable.getType().getName())); result.add(variable); itr.remove(); @@ -386,12 +379,7 @@ public class ReportBuilder { } String typeStr = parts[0].trim(); String request = parts[1].trim(); - Class<?> type = null; - try { - type = Class.forName(typeStr); - } catch (ClassNotFoundException eee) { - throw new IllegalArgumentException("Le type " + typeStr + " n'est pas connu", eee); - } + Class<?> type = Objects2.forName(typeStr); ReportVariable<?> variable = new ReportVariable<>(id, type, request); log.debug(String.format("Detects a variable : [%s:%s] = %s (type = %s)", reportName, variable.getName(), variable.getRequest(), variable.getType().getName())); result.add(variable); ===================================== services/src/main/java/fr/ird/observe/services/service/actions/report/ReportRequest.java ===================================== @@ -6,26 +6,27 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% */ package fr.ird.observe.services.service.actions.report; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import fr.ird.observe.dto.ObserveDto; import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.awt.Point; import java.io.Serializable; @@ -41,61 +42,16 @@ import java.util.Map; */ public class ReportRequest implements Serializable, ObserveDto { + public static final String TRIP_ID_VARIABLE = "tripId"; private static final long serialVersionUID = 1L; - /** Logger. */ private static final Logger log = LogManager.getLogger(ReportRequest.class); - - public static final String TRIP_ID_VARIABLE = "tripId"; - - /** le layout de la requete. */ - public enum RequestLayout { - /** lorsque les résultats de la requète sont les lignes du résultat. */ - row, - /** lorsque les résultats de la requète sont les colonnes du résultat. */ - column - } - - /** Un repeater optionnel sur la requête. */ - public static class RequestRepeat implements Serializable, ObserveDto { - - protected final String variableName; - - protected final RequestLayout layout; - - private static final long serialVersionUID = 1L; - - public RequestRepeat(String variableName, RequestLayout layout) { - this.variableName = variableName; - this.layout = layout; - } - - public String getVariableName() { - return variableName; - } - - public RequestLayout getLayout() { - return layout; - } - - @Override - public String toString() { - ToStringBuilder builder = new ToStringBuilder(this); - builder.append("variableName", getVariableName()); - builder.append("layout", getLayout()); - return builder.toString(); - } - } - /** layout de la requète. */ protected final RequestLayout layout; - /** la requète à exécuter. */ protected final String request; - /** la position de la requète. */ protected final Point location; - /** le repeater optionel. */ protected final RequestRepeat repeat; @@ -110,31 +66,7 @@ public class ReportRequest implements Serializable, ObserveDto { location = new Point(x, y); } - public RequestLayout getLayout() { - return layout; - } - - public int getX() { - return (int) location.getX(); - } - - public int getY() { - return (int) location.getY(); - } - - public Point getLocation() { - return location; - } - - public String getRequest() { - return request; - } - - public RequestRepeat getRepeat() { - return repeat; - } - - public static Map<String, Object> extractParams(Report report, String tripId) { + public static Map<String, Object> extractParams(Report report, ImmutableSet<String> tripId) { Map<String, Object> params = Maps.newHashMap(); @@ -175,6 +107,30 @@ public class ReportRequest implements Serializable, ObserveDto { return datas; } + public RequestLayout getLayout() { + return layout; + } + + public int getX() { + return (int) location.getX(); + } + + public int getY() { + return (int) location.getY(); + } + + public Point getLocation() { + return location; + } + + public String getRequest() { + return request; + } + + public RequestRepeat getRepeat() { + return repeat; + } + @Override public String toString() { ToStringBuilder builder = new ToStringBuilder(this); @@ -184,4 +140,41 @@ public class ReportRequest implements Serializable, ObserveDto { builder.append("repeatVariable", getRepeat()); return builder.toString(); } + + /** le layout de la requete. */ + public enum RequestLayout { + /** lorsque les résultats de la requète sont les lignes du résultat. */ + row, + /** lorsque les résultats de la requète sont les colonnes du résultat. */ + column + } + + /** Un repeater optionnel sur la requête. */ + public static class RequestRepeat implements Serializable, ObserveDto { + + private static final long serialVersionUID = 1L; + protected final String variableName; + protected final RequestLayout layout; + + public RequestRepeat(String variableName, RequestLayout layout) { + this.variableName = variableName; + this.layout = layout; + } + + public String getVariableName() { + return variableName; + } + + public RequestLayout getLayout() { + return layout; + } + + @Override + public String toString() { + ToStringBuilder builder = new ToStringBuilder(this); + builder.append("variableName", getVariableName()); + builder.append("layout", getLayout()); + return builder.toString(); + } + } } ===================================== services/src/main/java/fr/ird/observe/services/service/actions/report/ReportService.java ===================================== @@ -22,6 +22,7 @@ package fr.ird.observe.services.service.actions.report; * #L% */ +import com.google.common.collect.ImmutableSet; import fr.ird.observe.services.service.ObserveService; import fr.ird.observe.services.spi.ReadDataPermission; import fr.ird.observe.services.spi.ReadReferentialPermission; @@ -35,10 +36,10 @@ public interface ReportService extends ObserveService { @ReadDataPermission @ReadReferentialPermission @Post - Report populateVariables(Report report, String tripId); + Report populateVariables(Report report, ImmutableSet<String> tripId); @ReadDataPermission @ReadReferentialPermission @Post - DataMatrix executeReport(Report report, String tripId); + DataMatrix executeReport(Report report, ImmutableSet<String> tripId); } ===================================== services/src/main/java/fr/ird/observe/services/service/actions/validate/DataValidationResult.java ===================================== @@ -0,0 +1,57 @@ +package fr.ird.observe.services.service.actions.validate; + +/*- + * #%L + * ObServe :: Services API + * %% + * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.ImmutableSet; +import fr.ird.observe.dto.referential.ReferentialLocale; + +/** + * Created by tchemit on 06/08/17. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class DataValidationResult extends ValidationResult<DataValidationRequest> { + + private final DataValidationRequest request; + + private DataValidationResult(DataValidationRequest request, ImmutableSet<ValidationResultDto> data) { + super(data); + this.request = request; + } + + @Override + public DataValidationRequest getRequest() { + return request; + } + + public static Builder<DataValidationRequest, DataValidationResult> builder(ReferentialLocale referenceLocale, DataValidationRequest request) { + return new Builder<DataValidationRequest, DataValidationResult>(referenceLocale, request) { + + @Override + protected DataValidationResult newResult(DataValidationRequest request, ImmutableSet<ValidationResultDto> result) { + return new DataValidationResult(request, result); + } + }; + } + +} ===================================== services/src/main/java/fr/ird/observe/services/service/actions/validate/ReferentialValidationResult.java ===================================== @@ -0,0 +1,57 @@ +package fr.ird.observe.services.service.actions.validate; + +/*- + * #%L + * ObServe :: Services API + * %% + * Copyright (C) 2008 - 2018 IRD, Code Lutin, Ultreia.io + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.ImmutableSet; +import fr.ird.observe.dto.referential.ReferentialLocale; + +/** + * Created by tchemit on 06/08/17. + * + * @author Tony Chemit - dev@tchemit.fr + */ +public class ReferentialValidationResult extends ValidationResult<ReferentialValidationRequest> { + + private final ReferentialValidationRequest request; + + private ReferentialValidationResult(ReferentialValidationRequest request, ImmutableSet<ValidationResultDto> data) { + super(data); + this.request = request; + } + + @Override + public ReferentialValidationRequest getRequest() { + return request; + } + + public static Builder<ReferentialValidationRequest, ReferentialValidationResult> builder(ReferentialLocale referenceLocale, ReferentialValidationRequest request) { + return new Builder<ReferentialValidationRequest, ReferentialValidationResult>(referenceLocale, request) { + + @Override + protected ReferentialValidationResult newResult(ReferentialValidationRequest request, ImmutableSet<ValidationResultDto> result) { + return new ReferentialValidationResult(request, result); + } + }; + } + +} ===================================== services/src/main/java/fr/ird/observe/services/service/actions/validate/ValidateService.java ===================================== @@ -37,11 +37,11 @@ public interface ValidateService extends ObserveService { @ReadReferentialPermission @Post - ValidationResult<ReferentialValidationRequest> validateReferential(ReferentialValidationRequest request); + ReferentialValidationResult validateReferential(ReferentialValidationRequest request); @ReadDataPermission @ReadReferentialPermission @Post - ValidationResult<DataValidationRequest> validateData(DataValidationRequest request); + DataValidationResult validateData(DataValidationRequest request); } ===================================== services/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationResult.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.services.service.actions.validate; * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. @@ -28,8 +28,8 @@ import com.google.common.collect.Multimap; import fr.ird.observe.dto.ObserveDto; import fr.ird.observe.dto.reference.DtoReference; import fr.ird.observe.dto.referential.ReferentialLocale; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.nuiton.validator.bean.simple.SimpleBeanValidatorEvent; import java.util.ArrayList; @@ -47,23 +47,15 @@ import static org.nuiton.i18n.I18n.l; * * @author Tony Chemit - dev@tchemit.fr */ -public class ValidationResult<R extends ValidationRequest> implements ObserveDto { +public abstract class ValidationResult<R extends ValidationRequest> implements ObserveDto { - private final R request; private final ImmutableSet<ValidationResultDto> data; - public static <R extends ValidationRequest> Builder<R> builder(ReferentialLocale referenceLocale, R request) { - return new Builder<>(referenceLocale, request); - } - - private ValidationResult(R request, ImmutableSet<ValidationResultDto> data) { - this.request = request; + ValidationResult(ImmutableSet<ValidationResultDto> data) { this.data = data; } - public R getRequest() { - return request; - } + public abstract R getRequest(); public ImmutableSet<ValidationResultDto> getData() { return data; @@ -91,7 +83,7 @@ public class ValidationResult<R extends ValidationRequest> implements ObserveDto * * @author Tony Chemit - dev@tchemit.fr */ - public static class Builder<R extends ValidationRequest> { + public static abstract class Builder<R extends ValidationRequest, S extends ValidationResult<R>> { /** Logger. */ private static final Logger log = LogManager.getLogger(Builder.class); @@ -100,7 +92,7 @@ public class ValidationResult<R extends ValidationRequest> implements ObserveDto private final R request; private final ReferentialLocale referenceLocale; - private Builder(ReferentialLocale referenceLocale, R request) { + Builder(ReferentialLocale referenceLocale, R request) { this.referenceLocale = referenceLocale; this.request = request; data = HashMultimap.create(); @@ -119,12 +111,14 @@ public class ValidationResult<R extends ValidationRequest> implements ObserveDto return this; } - public ValidationResult<R> build() { + protected abstract S newResult(R request, ImmutableSet<ValidationResultDto> result); + + public S build() { ImmutableSet.Builder<ValidationResultDto> result = ImmutableSet.builder(); for (Map.Entry<DtoReference, Collection<ValidationResultDtoMessage>> entry : data.asMap().entrySet()) { result.add(new ValidationResultDto(entry.getKey(), ImmutableSet.copyOf(entry.getValue()))); } - return new ValidationResult<>(request, result.build()); + return newResult(request, result.build()); } private String translateMessage(String message) { ===================================== services/src/main/java/fr/ird/observe/services/service/actions/validate/ValidationResultDto.java ===================================== @@ -35,7 +35,7 @@ public class ValidationResultDto { private final DtoReference reference; private final ImmutableSet<ValidationResultDtoMessage> messages; - ValidationResultDto(DtoReference reference, ImmutableSet<ValidationResultDtoMessage> messages) { + public ValidationResultDto(DtoReference reference, ImmutableSet<ValidationResultDtoMessage> messages) { this.reference = reference; this.messages = messages; } ===================================== services/src/main/resources/observe-reports.properties ===================================== @@ -19,7 +19,6 @@ # <http://www.gnu.org/licenses/gpl-3.0.html>. # #L% ### - ################################################################################ ## Liste des \u00e9quipements (Seine) ################################################################################ @@ -33,10 +32,9 @@ report.tripSeineGearUseFeatures.repeatVariable.gearUseFeaturesId=java.lang.Strin From TripSeineImpl m \ Join m.gearUseFeaturesSeine g \ Where \ - m.id = :tripId \ + m.id In :tripId \ and g in elements (m.gearUseFeaturesSeine) \ Order By g.gear.label2 - report.tripSeineGearUseFeatures.request.1=0,0|row|\ Select \ concat(CASE When g.gear.code IS NULL Then 'Aucun code' Else g.gear.code End, ' - ', g.gear.label2), \ @@ -44,9 +42,7 @@ report.tripSeineGearUseFeatures.request.1=0,0|row|\ ( CASE g.usedInTrip When true Then 'Oui' Else Case g.usedInTrip When false Then 'Non' Else 'Ind\u00e9termin\u00e9' End End )\ From GearUseFeaturesSeineImpl g \ Where g.id = :gearUseFeaturesId - report.tripSeineGearUseFeatures.request.1.repeat=gearUseFeaturesId|column - ################################################################################ ## Liste des \u00e9quipements (Longline) ################################################################################ @@ -60,10 +56,9 @@ report.tripLonglineGearUseFeatures.repeatVariable.gearUseFeaturesId=java.lang.St From TripLonglineImpl m \ Join m.gearUseFeaturesLongline g \ Where \ - m.id = :tripId \ + m.id In :tripId \ and g in elements (m.gearUseFeaturesLongline) \ Order By g.gear.label2 - report.tripLonglineGearUseFeatures.request.1=0,0|row|\ Select \ concat(CASE When g.gear.code IS NULL Then 'Aucun code' Else g.gear.code End, ' - ', g.gear.label2), \ @@ -71,9 +66,7 @@ report.tripLonglineGearUseFeatures.request.1=0,0|row|\ ( CASE g.usedInTrip When true Then 'Oui' Else Case g.usedInTrip When false Then 'Non' Else 'Ind\u00e9termin\u00e9' End End )\ From GearUseFeaturesLonglineImpl g \ Where g.id = :gearUseFeaturesId - report.tripLonglineGearUseFeatures.request.1.repeat=gearUseFeaturesId|column - ################################################################################ ## Liste des activit\u00e9s avec des comments ################################################################################ @@ -88,10 +81,9 @@ report.activityWithComment.request.1=0,0|row|\ Join r.activitySeine a \ Join a.vesselActivitySeine ab \ Where \ - m.id = :tripId \ + m.id In :tripId \ and a.comment is not null \ Order By r.date, a.time - ################################################################################ ## Liste de toutes les activit\u00e9s et leurs positions ################################################################################ @@ -106,9 +98,8 @@ report.allActivitys.request.1=0,0|row|\ Join r.activitySeine a \ Join a.vesselActivitySeine ab \ Where \ - m.id = :tripId \ + m.id In :tripId \ Order By r.date, a.time - ################################################################################ ## Nombre de cal\u00e9es et captures journali\u00e8res d'une mar\u00e9e ################################################################################ @@ -124,10 +115,9 @@ report.dailySetAndCatch.request.1=0,0|row|\ Join a.setSeine s \ left join s.targetCatch as ct \ Where \ - m.id = :tripId \ + m.id In :tripId \ Group By r.date \ Order By r.date - ################################################################################ ## Utilisation des DCP ################################################################################ @@ -143,16 +133,14 @@ report.dcpUsage.repeatVariable.typeObjetId=java.lang.String|\ Join a.floatingObject dcp \ Join dcp.objectType to \ Where \ - m.id = :tripId \ + m.id In :tripId \ Order by to.code - report.dcpUsage.request.1=0,0|row|\ Select concat(str(to.code) , ' - ', to.label2) \ From ObjectTypeImpl to \ Where \ to.id = :typeObjetId report.dcpUsage.request.1.repeat=typeObjetId|column - report.dcpUsage.request.2=1,0|row|\ Select Count(dcp) \ From TripSeineImpl m \ @@ -160,11 +148,10 @@ report.dcpUsage.request.2=1,0|row|\ Join r.activitySeine a \ Join a.floatingObject dcp \ Where \ - m.id = :tripId \ + m.id In :tripId \ and dcp.objectType.id = :typeObjetId \ and dcp.objectOperation.id = 'fr.ird.observe.entities.referentiel.seine.ObjectOperation#1239832686249#0.8268884472438458' report.dcpUsage.request.2.repeat=typeObjetId|column - report.dcpUsage.request.3=2,0|row|\ Select Count(dcp) \ From TripSeineImpl m \ @@ -172,11 +159,10 @@ report.dcpUsage.request.3=2,0|row|\ Join r.activitySeine a \ Join a.floatingObject dcp \ Where \ - m.id = :tripId \ + m.id In :tripId \ and dcp.objectType.id = :typeObjetId \ and dcp.objectOperation.id = 'fr.ird.observe.entities.referentiel.seine.ObjectOperation#1239832686249#0.8431519556575698' report.dcpUsage.request.3.repeat=typeObjetId|column - report.dcpUsage.request.4=3,0|row|\ Select Count(dcp) \ From TripSeineImpl m \ @@ -184,11 +170,10 @@ report.dcpUsage.request.4=3,0|row|\ Join r.activitySeine a \ Join a.floatingObject dcp \ Where \ - m.id = :tripId \ + m.id In :tripId \ and dcp.objectType.id = :typeObjetId \ and dcp.objectOperation.id = 'fr.ird.observe.entities.referentiel.seine.ObjectOperation#1239832686248#0.8669327599318251' report.dcpUsage.request.4.repeat=typeObjetId|column - report.dcpUsage.request.5=4,0|row|\ Select Count(dcp) \ From TripSeineImpl m \ @@ -196,12 +181,11 @@ report.dcpUsage.request.5=4,0|row|\ Join r.activitySeine a \ Join a.floatingObject dcp \ Where \ - m.id = :tripId \ + m.id In :tripId \ and dcp.objectType.id = :typeObjetId \ and dcp.objectFate.id = 'fr.ird.observe.entities.referentiel.seine.ObjectFate#1396860761530#0.8869464242156488' \ and dcp.objectOperation.id != 'fr.ird.observe.entities.referentiel.seine.ObjectOperation#1239832686248#0.8669327599318251' report.dcpUsage.request.5.repeat=typeObjetId|column - report.dcpUsage.request.6=5,0|row|\ Select Count(dcp) \ From TripSeineImpl m \ @@ -209,11 +193,10 @@ report.dcpUsage.request.6=5,0|row|\ Join r.activitySeine a \ Join a.floatingObject dcp \ Where \ - m.id = :tripId \ + m.id In :tripId \ and dcp.objectType.id = :typeObjetId \ and dcp.objectOperation.id = 'fr.ird.observe.entities.referentiel.seine.ObjectOperation#1239832686249#0.7838704130950722' report.dcpUsage.request.6.repeat=typeObjetId|column - report.dcpUsage.request.7=6,0|row| \ Select Sum(efo.count) \ From TripSeineImpl m \ @@ -222,11 +205,10 @@ report.dcpUsage.request.7=6,0|row| \ Join a.floatingObject dcp \ Join dcp.objectObservedSpecies efo \ Where \ - m.id = :tripId \ + m.id In :tripId \ and dcp.objectType.id = :typeObjetId \ and efo.species.speciesGroup.id = 'fr.ird.observe.entities.referentiel.SpeciesGroup#1239832683690#0.24333033683679461' report.dcpUsage.request.7.repeat=typeObjetId|column - ################################################################################ ## Nombre des cal\u00e9es selon le type d'association ################################################################################ @@ -244,12 +226,11 @@ report.setByAssociation.request.1=0,0|column|\ Join r.activitySeine a, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and a.setSeine.schoolType = 2 \ and a.setSeine.reasonForNullSet is null \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9395222812356602' \ and os not in elements(a.observedSystem) - report.setByAssociation.request.2=0,1|column|\ Select Count(a) \ From TripSeineImpl m \ @@ -257,12 +238,11 @@ report.setByAssociation.request.2=0,1|column|\ Join r.activitySeine a, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and a.setSeine.schoolType = 2 \ and a.setSeine.reasonForNullSet is not null \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9395222812356602' \ and os not in elements(a.observedSystem) - report.setByAssociation.request.3=1,0|column|\ Select Count(a) \ From TripSeineImpl m \ @@ -270,12 +250,11 @@ report.setByAssociation.request.3=1,0|column|\ Join r.activitySeine a, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and a.setSeine.schoolType = 2 \ and a.setSeine.reasonForNullSet is null \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9395222812356602' \ and os in elements(a.observedSystem) - report.setByAssociation.request.4=1,1|column|\ Select Count(a) \ From TripSeineImpl m \ @@ -283,12 +262,11 @@ report.setByAssociation.request.4=1,1|column|\ Join r.activitySeine a, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and a.setSeine.schoolType = 2 \ and a.setSeine.reasonForNullSet is not null \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9395222812356602' \ and os in elements(a.observedSystem) - report.setByAssociation.request.5=2,0|column|\ Select Count(a) \ From TripSeineImpl m \ @@ -296,12 +274,11 @@ report.setByAssociation.request.5=2,0|column|\ Join r.activitySeine a, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and a.setSeine.schoolType = 1 \ and a.setSeine.reasonForNullSet is null \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9217864901728908' \ and os in elements(a.observedSystem) - report.setByAssociation.request.6=2,1|column|\ Select Count(a) \ From TripSeineImpl m \ @@ -309,12 +286,11 @@ report.setByAssociation.request.6=2,1|column|\ Join r.activitySeine a, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and a.setSeine.schoolType = 1 \ and a.setSeine.reasonForNullSet is not null \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9217864901728908' \ and os in elements(a.observedSystem) - report.setByAssociation.request.7=3,0|column|\ Select Count(a) \ From TripSeineImpl m \ @@ -322,12 +298,11 @@ report.setByAssociation.request.7=3,0|column|\ Join r.activitySeine a, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and a.setSeine.schoolType = 1 \ and a.setSeine.reasonForNullSet is null \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) - report.setByAssociation.request.8=3,1|column|\ Select Count(a) \ From TripSeineImpl m \ @@ -335,12 +310,11 @@ report.setByAssociation.request.8=3,1|column|\ Join r.activitySeine a, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and a.setSeine.schoolType = 1 \ and a.setSeine.reasonForNullSet is not null \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) - ################################################################################ ## Captures thon par type d'association ################################################################################ @@ -351,7 +325,6 @@ report.targetCatchByAssociation.columns=YFT, SKJ, BET, LTA, FRI, Autres, Total report.targetCatchByAssociation.rows=BL sans baleine, BL avec baleine, BO avec requin-baleine, BO sans requin-baleine, Total report.targetCatchByAssociation.operations.1=SumRow report.targetCatchByAssociation.operations.2=SumColumn - # ligne 1 report.targetCatchByAssociation.request.1=0,0|row|\ Select \ @@ -380,10 +353,9 @@ report.targetCatchByAssociation.request.1=0,0|row|\ with ct.discarded = false, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9395222812356602' \ and os not in elements(a.observedSystem) - # ligne 2 report.targetCatchByAssociation.request.7=0,1|row|\ Select \ @@ -412,10 +384,9 @@ report.targetCatchByAssociation.request.7=0,1|row|\ with ct.discarded = false, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9395222812356602' \ and os in elements(a.observedSystem) - # ligne 3 report.targetCatchByAssociation.request.13=0,2|row|\ Select \ @@ -444,10 +415,9 @@ report.targetCatchByAssociation.request.13=0,2|row|\ with ct.discarded = false, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9217864901728908' \ and os in elements(a.observedSystem) - # ligne 4 report.targetCatchByAssociation.request.19=0,3|row|\ Select \ @@ -476,10 +446,9 @@ report.targetCatchByAssociation.request.19=0,3|row|\ with ct.discarded = false, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) - ################################################################################ ## Rejets thons selon le type d'association ################################################################################ @@ -490,7 +459,6 @@ report.targetDiscardedByAssociation.columns=YFT, SKJ, BET, LTA, FRI, Autres, Tot report.targetDiscardedByAssociation.rows=BL sans baleine, BL avec baleine, BO avec requin-baleine, BO sans requin-baleine, Total report.targetDiscardedByAssociation.operations.1=SumRow report.targetDiscardedByAssociation.operations.2=SumColumn - # ligne 1 report.targetDiscardedByAssociation.request.1=0,0|row|\ Select \ @@ -519,10 +487,9 @@ report.targetDiscardedByAssociation.request.1=0,0|row|\ with ct.discarded = true, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9395222812356602' \ and os not in elements(a.observedSystem) - # ligne 2 report.targetDiscardedByAssociation.request.7=0,1|row|\ Select \ @@ -551,10 +518,9 @@ report.targetDiscardedByAssociation.request.7=0,1|row|\ with ct.discarded = true, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9395222812356602' \ and os in elements(a.observedSystem) - # ligne 3 report.targetDiscardedByAssociation.request.13=0,2|row|\ Select \ @@ -583,10 +549,9 @@ report.targetDiscardedByAssociation.request.13=0,2|row|\ with ct.discarded = true, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9217864901728908' \ and os in elements(a.observedSystem) - # ligne 4 report.targetDiscardedByAssociation.request.19=0,3|row|\ Select \ @@ -615,10 +580,9 @@ report.targetDiscardedByAssociation.request.19=0,3|row|\ with ct.discarded = true, \ ObservedSystemImpl os \ Where \ - m.id = :tripId \ + m.id In :tripId \ and os.topiaId = 'fr.ird.observe.entities.referentiel.seine.ObservedSystem#1239832686428#0.9217864901728908' \ and os not in elements(a.observedSystem) - ################################################################################ ## Captures accessoires observ\u00e9es ################################################################################ @@ -631,7 +595,6 @@ report.accessoryCatch.repeatVariable.speciesId=java.lang.String|\ Select e.id From SpeciesImpl e \ Where e.speciesGroup.id = :speciesGroup \ Order By e.homeId - report.accessoryCatch.request.1=0,0|row|\ Select \ concat('[FAO]', (case when e.faoCode is not null then e.faoCode else '-' end), \ @@ -640,7 +603,6 @@ report.accessoryCatch.request.1=0,0|row|\ From SpeciesImpl e \ Where e.id = :speciesId report.accessoryCatch.request.1.repeat=speciesId|column - report.accessoryCatch.request.2=1,0|row|\ Select \ case when Count(ca) > 0 then \ @@ -655,9 +617,8 @@ report.accessoryCatch.request.2=1,0|row|\ with c.schoolType = 2 \ Join c.nonTargetCatch ca \ with ca.species.id = :speciesId \ - Where m.id = :tripId + Where m.id In :tripId report.accessoryCatch.request.2.repeat=speciesId|column - report.accessoryCatch.request.3=2,0|row|\ Select \ case when Count(ca) > 0 then \ @@ -672,9 +633,8 @@ report.accessoryCatch.request.3=2,0|row|\ with c.schoolType = 1 \ Join c.nonTargetCatch ca \ with ca.species.id = :speciesId \ - Where m.id = :tripId + Where m.id In :tripId report.accessoryCatch.request.3.repeat=speciesId|column - ################################################################################ ## Captures accessoires par speciesGroup d'esp\u00e8ces ################################################################################ @@ -683,7 +643,6 @@ report.accessoryCatchByGroup.name=D\u00e9nombrement des captures accessoires et report.accessoryCatchByGroup.description=Afficher les nombres de captures accessoires par groupe d'esp\u00e8ce selon le type de banc et le devenir report.accessoryCatchByGroup.columns=Esp\u00e8ce, Total BL, Total BO, Sorti vivant/\u00e9chapp\u00e9, Sorti mort, Rejet\u00e9 vivant, Rejet\u00e9 mort, Partiellement conserv\u00e9, Cuve, Cuisine, Autre report.accessoryCatchByGroup.variable.speciesGroup=fr.ird.observe.dto.referential.SpeciesGroupDto|From SpeciesGroupImpl ge Order By ge.code - report.accessoryCatchByGroup.request.1=0,0|row|\ Select \ concat(\ @@ -723,10 +682,9 @@ report.accessoryCatchByGroup.request.1=0,0|row|\ Join c.nonTargetCatch ca \ Join ca.species e \ with e.speciesGroup.id = :speciesGroup \ - Where m.id = :tripId \ + Where m.id In :tripId \ Group by e \ Order By e.homeId - ########################################################### ## Distribution des tailles par espèces non ciblées ########################################################### @@ -742,7 +700,7 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.nonTargetSample nts \ Join nts.nonTargetLength ntl \ -Where t.id = :tripId +Where t.id In :tripId report.nonTargetDistributionLengths.request.1=0,0|row| \ Select ntl.length, sum(ntl.count) \ From TripSeineImpl t \ @@ -750,11 +708,10 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.nonTargetSample nts \ Join nts.nonTargetLength ntl \ -Where t.id = :tripId \ +Where t.id In :tripId \ And ntl.species.id = :speciesId \ Group By ntl.length \ Order By ntl.length - #################################################################### ## Distribution des tailles des conservés par espèces ciblées (LD1) #################################################################### @@ -770,7 +727,7 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.targetSample ts \ Join ts.targetLength tl \ -Where t.id = :tripId \ +Where t.id In :tripId \ And tl.sizeMeasureType = 1 \ And ts.discarded = false report.targetStoredDistributionLengthsLD1.request.1=0,0|row| \ @@ -780,13 +737,12 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.targetSample ts \ Join ts.targetLength tl \ -Where t.id = :tripId \ +Where t.id In :tripId \ And tl.species.id = :speciesId \ And tl.sizeMeasureType = 1 \ And ts.discarded = false \ Group By tl.length \ Order By tl.length - ################################################################ ## Distribution des tailles des rejets par espèces ciblées (LD1) ################################################################ @@ -802,7 +758,7 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.targetSample ts \ Join ts.targetLength tl \ -Where t.id = :tripId \ +Where t.id In :tripId \ And tl.sizeMeasureType = 1 \ And ts.discarded = true report.targetDiscardedDistributionLengthsLD1.request.1=0,0|row| \ @@ -812,13 +768,12 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.targetSample ts \ Join ts.targetLength tl \ -Where t.id = :tripId \ +Where t.id In :tripId \ And tl.species.id = :speciesId \ And tl.sizeMeasureType = 1\ And ts.discarded = true \ Group By tl.length \ Order By tl.length - ############################################################### ## Distribution des tailles des conservés par espèces ciblées (LF) ############################################################### @@ -834,7 +789,7 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.targetSample ts \ Join ts.targetLength tl \ -Where t.id = :tripId \ +Where t.id In :tripId \ And tl.sizeMeasureType = 2 \ And ts.discarded = false report.targetStoredDistributionLengthsLF.request.1=0,0|row| \ @@ -844,13 +799,12 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.targetSample ts \ Join ts.targetLength tl \ -Where t.id = :tripId \ +Where t.id In :tripId \ And tl.species.id = :speciesId \ And tl.sizeMeasureType = 2 \ And ts.discarded = false \ Group By tl.length \ Order By tl.length - ############################################################### ## Distribution des tailles des rejets par espèces ciblées (LF) ############################################################### @@ -866,7 +820,7 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.targetSample ts \ Join ts.targetLength tl \ -Where t.id = :tripId \ +Where t.id In :tripId \ And tl.sizeMeasureType = 2 \ And ts.discarded = true report.targetDiscardedDistributionLengthsLF.request.1=0,0|row| \ @@ -876,13 +830,12 @@ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.targetSample ts \ Join ts.targetLength tl \ -Where t.id = :tripId \ +Where t.id In :tripId \ And tl.species.id = :speciesId \ And tl.sizeMeasureType = 2 \ And ts.discarded = true \ Group By tl.length \ Order By tl.length - ############################################ ## Répartition des calées par cuves ############################################ @@ -902,6 +855,6 @@ From TripSeineImpl t \ Join t.route r \ Join r.activitySeine a \ Join a.setSeine.targetCatch tc \ -Where t.id = :tripId \ +Where t.id In :tripId \ Group By r.date, a.time, a.latitude, a.longitude, tc.weightCategory.species, tc.weightCategory.species.faoCode, tc.well, a.setSeine.schoolType \ Order By r.date, a.time, tc.weightCategory.species, tc.well View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/5051afba523ad7aabee29ab8c9c... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/5051afba523ad7aabee29ab8c9c... You're receiving this email because of your account on gitlab.com.