Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe Commits: 9e6160fe by Tony CHEMIT at 2018-09-19T04:51:49Z Only remove program node if it is enabled (otherwise it is not in navigation tree) - - - - - 295ce509 by Tony CHEMIT at 2018-09-19T04:51:51Z [SYNCHRO] Problème avec la synchro avancée d'un programme - Closes #1063 - - - - - a5fffee9 by Tony CHEMIT at 2018-09-19T04:51:51Z [SYNCHRO] La synchro avancée d'une marée nécessitant une référence absente dans la base cible provoque une exception - Closes #1064 - - - - - 20 changed files: - client/src/main/java/fr/ird/observe/client/db/ObserveSwingDataSource.java - client/src/main/java/fr/ird/observe/client/ui/admin/export/ExportUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroModel.java - client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroUI.jaxx - client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroUI.jcss - client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroUIHandler.java - client/src/main/java/fr/ird/observe/client/ui/content/ref/ContentReferenceUIHandler.java - client/src/main/resources/i18n/client_en_GB.properties - client/src/main/resources/i18n/client_es_ES.properties - client/src/main/resources/i18n/client_fr_FR.properties - pom.xml - server/src/main/java/fr/ird/observe/server/ObserveWebApplicationListener.java - + server/src/main/java/fr/ird/observe/server/injector/TopiaSqlScriptInjector.java - services-client/src/main/java/fr/ird/observe/services/client/ObserveRequestBuilder.java - services-local/src/main/java/fr/ird/observe/services/local/service/actions/synchro/referential/ng/ReferentialSynchronizeSqlsRequestBuilder.java - services-local/src/main/java/fr/ird/observe/services/local/service/referential/ReferentialServiceLocal.java - services-local/src/main/java/fr/ird/observe/services/local/service/referential/ReferentialShellBuilder.java - services/src/main/java/fr/ird/observe/services/service/referential/MissingReferentialRequest.java - services/src/main/java/fr/ird/observe/services/service/referential/MissingReferentialResult.java - services/src/main/java/fr/ird/observe/services/service/referential/ReferentialService.java Changes: ===================================== client/src/main/java/fr/ird/observe/client/db/ObserveSwingDataSource.java ===================================== @@ -99,8 +99,9 @@ import fr.ird.observe.services.service.referential.ReferentialService; import fr.ird.observe.services.service.sql.SqlScriptProducerService; import fr.ird.observe.spi.map.ImmutableDtoMap; import fr.ird.observe.spi.map.ImmutableSetDtoMap; -import org.apache.logging.log4j.Logger; +import fr.ird.observe.spi.map.ImmutableSetStringMap; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jdesktop.beans.AbstractSerializableBean; import org.nuiton.version.Version; @@ -561,7 +562,7 @@ public class ObserveSwingDataSource extends AbstractSerializableBean implements return ObserveServiceMainFactory.get().newService(observeServiceInitializer, serviceType); } - public ImmutableSetDtoMap<ReferentialDtoReference> getReferentialMap(ImmutableSetDtoMap<String> referentialIds) { + public ImmutableSetDtoMap<ReferentialDtoReference> getReferentialMap(ImmutableSetStringMap referentialIds) { ImmutableSetDtoMap.Builder<ReferentialDtoReference> result = ImmutableSetDtoMap.builder(); for (Class<? extends ReferentialDtoReference> dtoType : referentialIds.referentialReferenceTypes()) { ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/export/ExportUIHandler.java ===================================== @@ -50,9 +50,10 @@ import fr.ird.observe.services.service.referential.MissingReferentialRequest; import fr.ird.observe.services.service.referential.MissingReferentialResult; import fr.ird.observe.services.service.referential.ReferentialService; import fr.ird.observe.spi.map.ImmutableSetDtoMap; +import fr.ird.observe.spi.map.ImmutableSetStringMap; import org.apache.commons.collections4.CollectionUtils; -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.editor.MyDefaultCellEditor; @@ -266,7 +267,7 @@ public class ExportUIHandler extends AdminTabUIHandler<ExportUI> implements UIHa if (log.isInfoEnabled()) { log.info("Chargement du réferentiel de la base centrale."); } - ImmutableSetDtoMap<String> centralSourceReferential = centralReferentialService.getReferentialIds(); + ImmutableSetStringMap centralSourceReferential = centralReferentialService.getReferentialIds(); List<String> tripIds = tripEntries.stream().map(TripEntry::getTripId).collect(Collectors.toList()); ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroModel.java ===================================== @@ -30,8 +30,8 @@ import fr.ird.observe.client.ui.admin.config.ConfigUI; import fr.ird.observe.client.ui.admin.synchronize.data.task.DataSynchronizeTaskSupport; import fr.ird.observe.client.ui.tree.selection.SelectionTreeModel; import fr.ird.observe.client.ui.util.ProgressModel; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.swing.DefaultListModel; import javax.swing.border.TitledBorder; @@ -64,7 +64,7 @@ public class DataSynchroModel extends AdminActionModel { /** les données sélectionnées sur le panneau de droite. */ protected SelectionTreeModel rightSelectionDataModel; - + protected boolean insertMissingReferentials; protected final DefaultListModel<DataSynchronizeTaskSupport> tasks; private final ProgressModel progressModel = new ProgressModel(); @@ -131,6 +131,14 @@ public class DataSynchroModel extends AdminActionModel { return rightSelectionDataModel; } + public boolean isInsertMissingReferentials() { + return insertMissingReferentials; + } + + public void setInsertMissingReferentials(boolean insertMissingReferentials) { + this.insertMissingReferentials = insertMissingReferentials; + } + public void populateLeftSelectionModel() { populateSelectionModel(leftSource, leftSelectionDataModel, LEFT_SELECTION_MODEL_CHANGED_PROPERTY_NAME); } ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroUI.jaxx ===================================== @@ -49,6 +49,9 @@ </Table> </JPanel> <JPanel id='NEED_FIX_content'> + <JCheckBox id="insertMissingReferentials" constraints='BorderLayout.NORTH' + onStateChanged='getStepModel().setInsertMissingReferentials(((JCheckBox)event.getSource()).isSelected())'/> + <JSplitPane id="contentSplitPane" constraints='BorderLayout.CENTER'> <Table id='contentNorth' fill="both" weighty="1"> <row> ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroUI.jcss ===================================== @@ -45,6 +45,11 @@ mnemonic:Q; } +#insertMissingReferentials { + text:"observe.action.export.requiredInsertMissingReferentials"; + selected:{stepModel.isInsertMissingReferentials()}; +} + #leftTree { minimumSize:{UIHelper.newMinDimension()}; font-size:11; ===================================== client/src/main/java/fr/ird/observe/client/ui/admin/synchronize/data/DataSynchroUIHandler.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.client.ui.admin.synchronize.data; * 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,12 +33,17 @@ import fr.ird.observe.client.ui.admin.synchronize.data.task.CopyToRightDataSynch import fr.ird.observe.client.ui.admin.synchronize.data.task.DataSynchronizeTaskSupport; import fr.ird.observe.client.ui.admin.synchronize.data.task.DeleteFromLeftDataSynchronizeTask; import fr.ird.observe.client.ui.admin.synchronize.data.task.DeleteFromRightDataSynchronizeTask; +import fr.ird.observe.client.ui.content.ref.usage.UsageForDisplayUI; import fr.ird.observe.client.ui.tree.selection.SelectionTree; import fr.ird.observe.client.ui.tree.selection.SelectionTreeModel; import fr.ird.observe.client.ui.util.ProgressModel; +import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.dto.decoration.DecoratorService; +import fr.ird.observe.dto.decoration.ObserveI18nDecoratorHelper; import fr.ird.observe.dto.decoration.decorators.ReferentialReferenceDecorator; import fr.ird.observe.dto.reference.DataDtoReference; +import fr.ird.observe.dto.reference.DtoReference; +import fr.ird.observe.dto.reference.ReferentialDtoReference; import fr.ird.observe.dto.referential.ProgramReference; import fr.ird.observe.services.service.data.DeleteTripRequest; import fr.ird.observe.services.service.data.DeleteTripResult; @@ -47,14 +52,25 @@ import fr.ird.observe.services.service.data.ExportTripResult; import fr.ird.observe.services.service.data.ImportTripRequest; import fr.ird.observe.services.service.data.ImportTripResult; import fr.ird.observe.services.service.data.TripManagementService; +import fr.ird.observe.services.service.referential.MissingReferentialRequest; +import fr.ird.observe.services.service.referential.MissingReferentialResult; +import fr.ird.observe.services.service.referential.ReferentialService; +import fr.ird.observe.spi.map.ImmutableSetDtoMap; +import fr.ird.observe.spi.map.ImmutableSetStringMap; +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.wizard.ext.WizardState; import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; import javax.swing.border.TitledBorder; import java.awt.Color; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Set; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -67,6 +83,8 @@ import static org.nuiton.i18n.I18n.t; */ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> implements UIHandler<DataSynchroUI> { + private static final Logger log = LogManager.getLogger(DataSynchroUIHandler.class); + @Override public void afterInit(DataSynchroUI ui) { super.afterInit(this.ui); @@ -122,13 +140,10 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple } public void doStartAction() { - addAdminWorker(getUi().getStartAction().getToolTipText(), this::doStartAction0); - } public void addCopyToLeftTasks() { - SelectionTreeModel rightSelectionDataModel = getStepModel().getRightSelectionDataModel(); SelectionTreeModel leftSelectionDataModel = getStepModel().getLeftSelectionDataModel(); Map<ProgramReference, List<DataDtoReference<?, ?>>> selectedDataByProgram = rightSelectionDataModel.getSelectedDataByProgram(); @@ -138,17 +153,14 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple for (DataDtoReference trip : entry.getValue()) { boolean tripExistOnLeft = leftSelectionDataModel.containsData(program, trip); getStepModel().addTask(new CopyToLeftDataSynchronizeTask(program, trip, tripExistOnLeft)); - if (tripExistOnLeft) { leftSelectionDataModel.removeTrip(program, trip); } } } - } public void addCopyToRightTasks() { - SelectionTreeModel leftSelectionDataModel = getStepModel().getLeftSelectionDataModel(); SelectionTreeModel rightSelectionDataModel = getStepModel().getRightSelectionDataModel(); Map<ProgramReference, List<DataDtoReference<?, ?>>> selectedDataByProgram = leftSelectionDataModel.getSelectedDataByProgram(); @@ -156,20 +168,16 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple for (Map.Entry<ProgramReference, List<DataDtoReference<?, ?>>> entry : selectedDataByProgram.entrySet()) { ProgramReference program = entry.getKey(); for (DataDtoReference trip : entry.getValue()) { - boolean tripExistOnRight = rightSelectionDataModel.containsData(program, trip); getStepModel().addTask(new CopyToRightDataSynchronizeTask(program, trip, tripExistOnRight)); - if (tripExistOnRight) { rightSelectionDataModel.removeTrip(program, trip); } } } - } public void addDeleteFromLeftTasks() { - SelectionTreeModel selectionDataModel = getStepModel().getLeftSelectionDataModel(); Map<ProgramReference, List<DataDtoReference<?, ?>>> selectedDataByProgram = selectionDataModel.getSelectedDataByProgram(); selectionDataModel.removeAllSelectedData(); @@ -182,7 +190,6 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple } public void addDeleteFromRightTasks() { - SelectionTreeModel selectionDataModel = getStepModel().getRightSelectionDataModel(); Map<ProgramReference, List<DataDtoReference<?, ?>>> selectedDataByProgram = selectionDataModel.getSelectedDataByProgram(); selectionDataModel.removeAllSelectedData(); @@ -195,9 +202,7 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple } public void doExecuteAction() { - addAdminWorker(getUi().getStartAction().getToolTipText(), this::doExecuteAction0); - } private WizardState doStartAction0() { @@ -214,11 +219,11 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple ObserveSwingDataSource rightSource = configModel.getSafeCentralSource(true); stepModel.setRightSource(rightSource); -// tabUI.getLeftTreePane().setBorder(new TitledBorder(configModel.getLocalSourceModel().getLabel())); stepModel.populateLeftSelectionModel(); - sendMessage(t("observe.actions.synchro.referential.message.data.leftData.loaded")); + String leftLabelWithUrl = configModel.getLocalSourceModel().getLabelWithUrl(); + sendMessage(t("observe.actions.synchro.data.message.data.loaded", leftLabelWithUrl)); - TitledBorder leftBorder = new TitledBorder(configModel.getLocalSourceModel().getLabelWithUrl()); + TitledBorder leftBorder = new TitledBorder(leftLabelWithUrl); boolean leftCanWriteData = configModel.getLocalSourceModel().getDataSourceInformation().canWriteData(); leftBorder.setTitleColor(leftCanWriteData ? Color.GREEN : Color.RED); tabUI.getLeftTreePane().setBorder(leftBorder); @@ -228,11 +233,11 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple } configUI.getLocalSourceConfig().setBorder(leftBorder); -// tabUI.getRightTreePane().setBorder(new TitledBorder(configModel.getCentralSourceModel().getLabel())); stepModel.populateRightSelectionModel(); - sendMessage(t("observe.actions.synchro.referential.message.data.rightData.loaded")); + String rightLabelWithUrl = configModel.getCentralSourceModel().getLabelWithUrl(); + sendMessage(t("observe.actions.synchro.data.message.data.loaded", rightLabelWithUrl)); - TitledBorder rightBorder = new TitledBorder(configModel.getCentralSourceModel().getLabelWithUrl()); + TitledBorder rightBorder = new TitledBorder(rightLabelWithUrl); boolean rightCanWriteData = configModel.getCentralSourceModel().getDataSourceInformation().canWriteData(); rightBorder.setTitleColor(rightCanWriteData ? Color.GREEN : Color.RED); tabUI.getRightTreePane().setBorder(rightBorder); @@ -256,17 +261,161 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple int size = tasks.size(); int stepsCount = 0; + Set<String> idsToCopyToLeft = new LinkedHashSet<>(); + Set<String> idsToCopyToRight = new LinkedHashSet<>(); for (int i = 0; i < size; i++) { + DataSynchronizeTaskSupport task = tasks.getElementAt(i); stepsCount++; - if (task instanceof CopyToLeftDataSynchronizeTask || task instanceof CopyToRightDataSynchronizeTask) { + if (task instanceof CopyToLeftDataSynchronizeTask) { + stepsCount++; + idsToCopyToLeft.add(task.getTrip().getId()); + } + if (task instanceof CopyToRightDataSynchronizeTask) { stepsCount++; + idsToCopyToRight.add(task.getTrip().getId()); } } + boolean copyToLeft = !idsToCopyToLeft.isEmpty(); + if (copyToLeft) { + stepsCount += 3; + } + boolean copyToRight = !idsToCopyToRight.isEmpty(); + if (copyToRight) { + stepsCount += 3; + } + ProgressModel progressModel = getStepModel().getProgressModel(); progressModel.setStepsCount(stepsCount); DecoratorService decoratorService = getDecoratorService(); + boolean insertMissingReferentials = getStepModel().isInsertMissingReferentials(); + if (copyToLeft) { + + // generate add missing referential to left + + progressModel.incrementsCurrentStep(); + + ReferentialService leftReferentialService = leftSource.getReferentialService(); + ImmutableSetStringMap leftSourceReferential = leftReferentialService.getReferentialIds(); + MissingReferentialRequest leftMissingReferentialRequest = MissingReferentialRequest.of(leftSourceReferential, idsToCopyToLeft.toArray(new String[0])); + MissingReferentialResult leftMissingReferentialResult = + rightSource.getReferentialService().computeMissingReferential(leftMissingReferentialRequest); + + progressModel.incrementsCurrentStep(); + + if (!insertMissingReferentials && leftMissingReferentialResult != null) { + + // l'export n'est pas possible + UIHelper.displayWarning(t("observe.title.can.not.export.data.left"), t("observe.actions.exportData.error.missingReferentialsId.left")); + sendMessage(t("observe.actions.exportData.error.missingReferentialsId.left")); + return WizardState.CANCELED; + } + + if (leftMissingReferentialResult != null) { + + // there is some referential to add to left source + + String message = t("observe.message.show.usage.for.missingReferentials.left"); + + ImmutableSetDtoMap<ReferentialDtoReference> usages = rightSource.getReferentialMap(leftMissingReferentialResult.getMissingIds()); + UsageForDisplayUI usagesUI = UsageForDisplayUI.build(message, usages); + + int reponse = UIHelper.askUser(null, + t("observe.title.can.not.export.data.left"), + usagesUI, + JOptionPane.WARNING_MESSAGE, + new Object[]{ + t("observe.choice.confirm.insert"), + t("observe.choice.cancel")}, + 0); + + if (reponse != 0) { + + return WizardState.CANCELED; + } + + // insertion des référentiels manquants dans la base centrale + log.info("Insertion dans la base de gauche des référentiels manquants."); + + for (Class<? extends ReferentialDtoReference> key : usages.referentialReferenceTypes()) { + Set<? extends ReferentialDtoReference> references = usages.get(key); + String type = t(ObserveI18nDecoratorHelper.getTypePluralI18nKey(key)); + sendMessage(t("observe.actions.exportData.message.add.missing.referentials.left", references.size(), type)); + Decorator decorator = decoratorService.getReferenceDecorator(key); + for (DtoReference reference : references) { + sendMessage(t("observe.actions.exportData.message.add.missing.referential", decorator.toString(reference))); + } + } + + progressModel.incrementsCurrentStep(); + + leftReferentialService.insertMissingReferential(leftMissingReferentialResult.getSqlCode()); + + } + } + + if (copyToRight) { + + // generate add missing referential to right + + progressModel.incrementsCurrentStep(); + + ReferentialService rightReferentialService = rightSource.getReferentialService(); + ImmutableSetStringMap rightSourceReferential = rightReferentialService.getReferentialIds(); + MissingReferentialRequest rightMissingReferentialRequest = MissingReferentialRequest.of(rightSourceReferential, idsToCopyToRight.toArray(new String[0])); + MissingReferentialResult rightMissingReferentialResult = + leftSource.getReferentialService().computeMissingReferential(rightMissingReferentialRequest); + + progressModel.incrementsCurrentStep(); + + if (!insertMissingReferentials && rightMissingReferentialResult != null) { + + // l'export n'est pas possible + UIHelper.displayWarning(t("observe.title.can.not.export.data.right"), t("observe.actions.exportData.error.missingReferentialsId.right")); + sendMessage(t("observe.actions.exportData.error.missingReferentialsId.right")); + return WizardState.CANCELED; + } + + if (rightMissingReferentialResult != null) { + + // there is some referential to add to left source + + String message = t("observe.message.show.usage.for.missingReferentials.right"); + + ImmutableSetDtoMap<ReferentialDtoReference> usages = leftSource.getReferentialMap(rightMissingReferentialResult.getMissingIds()); + UsageForDisplayUI usagesUI = UsageForDisplayUI.build(message, usages); + + int reponse = UIHelper.askUser(null, + t("observe.title.can.not.export.data.right"), + usagesUI, + JOptionPane.WARNING_MESSAGE, + new Object[]{ + t("observe.choice.confirm.insert"), + t("observe.choice.cancel")}, + 0); + + if (reponse != 0) { + + return WizardState.CANCELED; + } + + log.info("Insertion dans la base de droite des référentiels manquants."); + + for (Class<? extends ReferentialDtoReference> key : usages.referentialReferenceTypes()) { + Set<? extends ReferentialDtoReference> references = usages.get(key); + String type = t(ObserveI18nDecoratorHelper.getTypePluralI18nKey(key)); + sendMessage(t("observe.actions.exportData.message.add.missing.referentials.right", references.size(), type)); + Decorator decorator = decoratorService.getReferenceDecorator(key); + for (DtoReference reference : references) { + sendMessage(t("observe.actions.exportData.message.add.missing.referential", decorator.toString(reference))); + } + } + progressModel.incrementsCurrentStep(); + rightReferentialService.insertMissingReferential(rightMissingReferentialResult.getSqlCode()); + } + } + ReferentialReferenceDecorator<ProgramReference> programDecorator = decoratorService.getReferentialReferenceDecorator(ProgramReference.class); TripManagementService leftTripManagementService = leftSource.getTripManagementService(); @@ -383,4 +532,5 @@ public class DataSynchroUIHandler extends AdminTabUIHandler<DataSynchroUI> imple return WizardState.SUCCESSED; } + } ===================================== client/src/main/java/fr/ird/observe/client/ui/content/ref/ContentReferenceUIHandler.java ===================================== @@ -31,6 +31,7 @@ import fr.ird.observe.client.ui.content.ref.usage.UsageForDeleteUI; import fr.ird.observe.client.ui.content.ref.usage.UsageForDesactivateUI; import fr.ird.observe.client.ui.content.ref.usage.UsageForDisplayUI; import fr.ird.observe.client.ui.tree.navigation.NavigationTree; +import fr.ird.observe.client.ui.tree.navigation.nodes.NavigationTreeNodeSupport; import fr.ird.observe.client.ui.util.UIHelper; import fr.ird.observe.client.validation.ClientValidationContext; import fr.ird.observe.dto.decoration.DecoratorService; @@ -125,47 +126,6 @@ public class ContentReferenceUIHandler<D extends ReferentialDto, R extends Refer }; } - @Override - protected ObserveLayoutFocusTraversalPolicy<U> creatFocusTraversalPolicy() { - return new ObserveLayoutFocusTraversalPolicy<U>() { - - @Override - protected Component getFirstComponentForEdit(Container aContainer) { - return getUi().getUri(); - } - - @Override - protected Component getLastComponentForEdit(Container aContainer) { - return getUi().getBackToList(); - } - - }; - } - - @Override - public void beforeInit(U ui) { - super.beforeInit(ui); - uiInitializer = new ContentReferenceUIInitializer<>(ui); - } - - @Override - public void afterInit(U ui) { - - uiInitializer.initUI(); - - ui.getViewLayout().addPropertyChangeListener(CardLayout2Ext.SELECTED_PROPERTY_NAME, - evt -> SwingUtilities.invokeLater(revalidate)); - - installFocusTraversalPolicy(); - - ui.getModel().addPropertyChangeListener(ContentReferenceUIModel.PROPERTY_EDITING, e -> updateView((Boolean) e.getNewValue())); - } - - @Override - protected String updateTitle(String title) { - return ui.getTypeI18nKey(); - } - private static <E extends ReferentialDto, R extends ReferentialDtoReference<E, R>> Pair<Boolean, R> showUsagesForDelete(E entity, ImmutableSetDtoMap<DtoReference> usages, List<R> referenceList) { @@ -248,6 +208,47 @@ public class ContentReferenceUIHandler<D extends ReferentialDto, R extends Refer return Pair.of(false, null); } + @Override + protected ObserveLayoutFocusTraversalPolicy<U> creatFocusTraversalPolicy() { + return new ObserveLayoutFocusTraversalPolicy<U>() { + + @Override + protected Component getFirstComponentForEdit(Container aContainer) { + return getUi().getUri(); + } + + @Override + protected Component getLastComponentForEdit(Container aContainer) { + return getUi().getBackToList(); + } + + }; + } + + @Override + public void beforeInit(U ui) { + super.beforeInit(ui); + uiInitializer = new ContentReferenceUIInitializer<>(ui); + } + + @Override + public void afterInit(U ui) { + + uiInitializer.initUI(); + + ui.getViewLayout().addPropertyChangeListener(CardLayout2Ext.SELECTED_PROPERTY_NAME, + evt -> SwingUtilities.invokeLater(revalidate)); + + installFocusTraversalPolicy(); + + ui.getModel().addPropertyChangeListener(ContentReferenceUIModel.PROPERTY_EDITING, e -> updateView((Boolean) e.getNewValue())); + } + + @Override + protected String updateTitle(String title) { + return ui.getTypeI18nKey(); + } + public void selectBean(R selectedReference) { if (selectedReference == null) { @@ -832,7 +833,10 @@ public class ContentReferenceUIHandler<D extends ReferentialDto, R extends Refer // remove the program in tree NavigationTree treeHelper = getNavigationTree(); - treeHelper.removeProgram(bean.getId()); + NavigationTreeNodeSupport programNode = treeHelper.getProgramNode(bean.getId()); + if (programNode != null) { + treeHelper.removeProgram(bean.getId()); + } } // on met a jour le referentiel dans le cache et le model ===================================== client/src/main/resources/i18n/client_en_GB.properties ===================================== @@ -151,8 +151,12 @@ observe.actions.consolidate.title.tip=Consolidate observed data observe.actions.exportData=Export data observe.actions.exportData.description=Export data observe.actions.exportData.error.missingReferentialsId=Can't export data, there is some missing referentials in central source and you did not select insert option. +observe.actions.exportData.error.missingReferentialsId.left=Can't export data, there is some missing referentials in left source and you did not select insert option. +observe.actions.exportData.error.missingReferentialsId.right=Can't export data, there is some missing referentials in right source and you did not select insert option. observe.actions.exportData.message.add.missing.referential=\t%s observe.actions.exportData.message.add.missing.referentials=Insert %s missing referentials of type «%s» +observe.actions.exportData.message.add.missing.referentials.left=Insert %s missing referentials of type «%s» in left source +observe.actions.exportData.message.add.missing.referentials.right=Insert %s missing referentials of type «%s» in right source observe.actions.exportData.message.not.possible=Export is not possible (see above messages) observe.actions.exportData.message.operation.needFix=Select data to export. observe.actions.exportData.message.prepare.data=Prepare data to export... @@ -202,6 +206,7 @@ observe.actions.synchro.data.deleteFromLeft.tip=Delete selected trip(s) from lef observe.actions.synchro.data.deleteFromRight.tip=Delete selected trip(s) from right database observe.actions.synchro.data.description=Advanced data management observe.actions.synchro.data.launch.operation=Get data fro databases +observe.actions.synchro.data.message.data.loaded=%s - Data loaded observe.actions.synchro.data.prepare.copyToLeftTask=Register operation copy to left database\: %s - %s observe.actions.synchro.data.prepare.copyToRightTask=Register operation copy to right database\: %s - %s observe.actions.synchro.data.prepare.deleteFromLeftTask=Register operation delete from left database\: %s - %s @@ -242,8 +247,6 @@ observe.actions.synchro.referential.legacy.launch.operation=Synchronize referent observe.actions.synchro.referential.legacy.tip=Synchronize objectOperation on local database observe.actions.synchro.referential.message.apply.done=Referential updated at 1$td/%1$tm/%1$tY à %1$tH\:%1$tM\:%1$tS observe.actions.synchro.referential.message.build.diff=Build differential of referential from %1$s -observe.actions.synchro.referential.message.data.leftData.loaded=Left referential panel loaded -observe.actions.synchro.referential.message.data.rightData.loaded=Right referential panel loaded observe.actions.synchro.referential.message.need.save.for.synchro.operation=Referential update has modified some local data. observe.actions.synchro.referential.message.need.save.for.validation.operation=Validation operation has modified some local data. observe.actions.synchro.referential.message.no.local.modification=No data modified, save is not required. @@ -1313,6 +1316,8 @@ observe.message.show.usage.for.desactivated=Referential %1$s "%2$s" will be disa observe.message.show.usage.for.desactivated2=Some data are using this referential, see following reference observe.message.show.usage.for.desactivated3=Those data need to use another enabled referential to be saved. observe.message.show.usage.for.missingReferentials=There is some referentials present in local source but not in centrale one. +observe.message.show.usage.for.missingReferentials.left=There is some referentials present in right source but not in left one. +observe.message.show.usage.for.missingReferentials.right=There is some referentials present in left source but not in right one. observe.message.show.usages=List of usage of referential %1$s\: '%2$s' observe.message.table.editBean.modified=Current entry is modifed and valid. observe.message.table.editBean.modified.but.invalid=Current entry is modified but not valid. @@ -1468,6 +1473,8 @@ observe.storage.useServerStorage.description=Please configure connexion to remot observe.title.about=About observe.title.can.not.delete.referentiel=Impossible to delete a referentiel data... observe.title.can.not.export.data=Could not export data +observe.title.can.not.export.data.left=Could not export data to left source +observe.title.can.not.export.data.right=Could not export data to right source observe.title.can.not.export.obstuna=Could not export obstuna data... observe.title.choose.db.dump=Choose a database backup observe.title.choose.db.dump.directory=Chhose directory of backup ===================================== client/src/main/resources/i18n/client_es_ES.properties ===================================== @@ -151,8 +151,12 @@ observe.actions.consolidate.title.tip=Consolidar los datos observados observe.actions.exportData=Exportar los datos observados observe.actions.exportData.description=Exportar los datos observados en la base central observe.actions.exportData.error.missingReferentialsId=Il existe des référentiels dans la base locale non présente en base centrale, mais vous n'avez pas activé l'option d'insertion automatique. \#TODO +observe.actions.exportData.error.missingReferentialsId.left=Il existe des référentiels dans la base de gauche non présente en base centrale, mais vous n'avez pas activé l'option d'insertion automatique. \#TODO +observe.actions.exportData.error.missingReferentialsId.right=Il existe des référentiels dans la base de droite non présente en base centrale, mais vous n'avez pas activé l'option d'insertion automatique. \#TODO observe.actions.exportData.message.add.missing.referential=\t%s observe.actions.exportData.message.add.missing.referentials=Insertion de %s référentiels de type «%s» \#TODO +observe.actions.exportData.message.add.missing.referentials.left=Insertion de %s référentiels de type «%s» dans la base de gauche\#TODO +observe.actions.exportData.message.add.missing.referentials.right=Insertion de %s référentiels de type «%s» dans la base de droite\#TODO observe.actions.exportData.message.not.possible=La exportación no es posible (vea el mensaje anterior). observe.actions.exportData.message.operation.needFix=Seleccione las mareas a exportar. observe.actions.exportData.message.prepare.data=Preparación de los datos a exportar... @@ -202,6 +206,7 @@ observe.actions.synchro.data.deleteFromLeft.tip=Eliminar la ou las mareas selecc observe.actions.synchro.data.deleteFromRight.tip=Eliminar la ou las mareas seleccionada(s) de la base de la derecha observe.actions.synchro.data.description=Gestión avanzada de los datos de los usuarios observe.actions.synchro.data.launch.operation=Recuperar los datos de las fuentes de datos +observe.actions.synchro.data.message.data.loaded=%s - Datos recuperadas. observe.actions.synchro.data.prepare.copyToLeftTask=Preparación de la copia en la base de la izquierda \: %s - %s observe.actions.synchro.data.prepare.copyToRightTask=Preparación de la copia en la base de la derecha \: %s - %s observe.actions.synchro.data.prepare.deleteFromLeftTask=Preparación de la eliminación de la base de la izquierda \: %s - %s @@ -242,8 +247,6 @@ observe.actions.synchro.referential.legacy.launch.operation=Calcular el diferenc observe.actions.synchro.referential.legacy.tip=Operación de actualización del referencial de la base local observe.actions.synchro.referential.message.apply.done=Referencial actualizado el %1$td/%1$tm/%1$tY a %1$tH\:%1$tM\:%1$tS observe.actions.synchro.referential.message.build.diff=Construcción del diferencial de referenciales desde\: %1$s -observe.actions.synchro.referential.message.data.leftData.loaded=Datos del pannel de la izquierda recuperadas. -observe.actions.synchro.referential.message.data.rightData.loaded=Datos del pannel de la derecha recuperadas. observe.actions.synchro.referential.message.need.save.for.synchro.operation=La operación de sincronización de referenciales ha generado cambios observe.actions.synchro.referential.message.need.save.for.validation.operation=la operación de validación de datos ha generado modificaciones. observe.actions.synchro.referential.message.no.local.modification=No se han modificado datos en la base local, no es necesario guardar. @@ -1313,6 +1316,8 @@ observe.message.show.usage.for.desactivated=El referencial %1$s "%2$s" se desact observe.message.show.usage.for.desactivated2=Los objetos están usando actualmente las referencias que se enumeran a continuación.. observe.message.show.usage.for.desactivated3=Estos objetos deben usar otro referencial (no desactivado) para poder actualizarse. observe.message.show.usage.for.missingReferentials=Il existe des référentiels présents dans la base locale mais non présents dans la base centrale. \#TODO +observe.message.show.usage.for.missingReferentials.left=Il existe des référentiels présents dans la base de droite mais non présents dans la base de gauche. +observe.message.show.usage.for.missingReferentials.right=Il existe des référentiels présents dans la base de gauche mais non présents dans la base droite. observe.message.show.usages=Listas de usos de referenciales %1$s \: '%2$s' observe.message.table.editBean.modified=El registro actual se ha modificado y es válido. observe.message.table.editBean.modified.but.invalid=El registro actual se ha modificado pero no es válido. @@ -1468,6 +1473,8 @@ observe.storage.useServerStorage.description=Configure su conexión al servidor observe.title.about=A proposito de ObServe... observe.title.can.not.delete.referentiel=Impossible eliminar un referencial en proceso de utilización... observe.title.can.not.export.data=Impossible d'exporter les données vers la base centrale... \#TODO +observe.title.can.not.export.data.left=Impossible d'exporter les données vers la base de gauche... \#TODO +observe.title.can.not.export.data.right=Impossible d'exporter les données vers la base de droite... \#TODO observe.title.can.not.export.obstuna=Impossible exportar los datos de obstuna... observe.title.choose.db.dump=Seleccionar una copia de seguridad de base local observe.title.choose.db.dump.directory=Seleccionar e directorio de destinación de la copia de seguridad ===================================== client/src/main/resources/i18n/client_fr_FR.properties ===================================== @@ -151,8 +151,12 @@ observe.actions.consolidate.title.tip=Consolider les données observateur observe.actions.exportData=Exporter les données observateurs observe.actions.exportData.description=Exporter les données observateurs vers la base centrale observe.actions.exportData.error.missingReferentialsId=Il existe des référentiels dans la base locale non présente en base centrale, mais vous n'avez pas activé l'option d'insertion automatique. +observe.actions.exportData.error.missingReferentialsId.left=Il existe des référentiels dans la base de gauche non présente en base centrale, mais vous n'avez pas activé l'option d'insertion automatique. +observe.actions.exportData.error.missingReferentialsId.right=Il existe des référentiels dans la base de droite non présente en base centrale, mais vous n'avez pas activé l'option d'insertion automatique. observe.actions.exportData.message.add.missing.referential=\t%s observe.actions.exportData.message.add.missing.referentials=Insertion de %s référentiels de type «%s» +observe.actions.exportData.message.add.missing.referentials.left=Insertion de %s référentiels de type «%s» dans la base de gauche +observe.actions.exportData.message.add.missing.referentials.right=Insertion de %s référentiels de type «%s» dans la base de droite observe.actions.exportData.message.not.possible=L'opération d'export n'est pas possible (voir les messages précédents). observe.actions.exportData.message.operation.needFix=Veuillez sélectionner les marées à exporter. observe.actions.exportData.message.prepare.data=Préparation des données à exporter... @@ -202,6 +206,7 @@ observe.actions.synchro.data.deleteFromLeft.tip=Supprimer la ou les marées sél observe.actions.synchro.data.deleteFromRight.tip=Supprimer la ou les marées sélectionnée(s) de la base de droite observe.actions.synchro.data.description=Gestion avancée des données utilisateurs observe.actions.synchro.data.launch.operation=Récupérer les données des sources de données +observe.actions.synchro.data.message.data.loaded=%s - Données du panneau gauche récupérées. observe.actions.synchro.data.prepare.copyToLeftTask=Préparation de la recopie vers la base de gauche \: %s - %s observe.actions.synchro.data.prepare.copyToRightTask=Préparation de la recopie vers la base de droite \: %s - %s observe.actions.synchro.data.prepare.deleteFromLeftTask=Préparation de la suppression de la base de gauche \: %s - %s @@ -242,8 +247,6 @@ observe.actions.synchro.referential.legacy.launch.operation=Calculer le différe observe.actions.synchro.referential.legacy.tip=Opération de mise à jour du référentiel de la base locale observe.actions.synchro.referential.message.apply.done=Référentiel mis à jour le %1$td/%1$tm/%1$tY à %1$tH\:%1$tM\:%1$tS observe.actions.synchro.referential.message.build.diff=Construction du différentiel de référentiel depuis %1$s -observe.actions.synchro.referential.message.data.leftData.loaded=Données du panneau gauche récupérées. -observe.actions.synchro.referential.message.data.rightData.loaded=Données du panneau droit récupérées. observe.actions.synchro.referential.message.need.save.for.synchro.operation=L'opération de synchronisation du référentiel a engendrée des modifications. observe.actions.synchro.referential.message.need.save.for.validation.operation=L'opération de validation des données a engendrée des modifications. observe.actions.synchro.referential.message.no.local.modification=Aucune donnée de la base locale n'a été modifiée @@ -1313,6 +1316,8 @@ observe.message.show.usage.for.desactivated=Le référentiel %1$s "%2$s" va êtr observe.message.show.usage.for.desactivated2=Des objets utilisent actuellement cet entité dont les références sont citées plus bas. observe.message.show.usage.for.desactivated3=Ces objets devront utiliser un autre référentiel (non désactivé) pour pouvoir être mis à jour. observe.message.show.usage.for.missingReferentials=Il existe des référentiels présents dans la base locale mais non présents dans la base centrale. +observe.message.show.usage.for.missingReferentials.left=Il existe des référentiels présents dans la base de droite mais non présents dans la base de gauche. +observe.message.show.usage.for.missingReferentials.right=Il existe des référentiels présents dans la base de gauche mais non présents dans la base droite. observe.message.show.usages=Listes des utilisations du référentiel %1$s \: '%2$s' observe.message.table.editBean.modified=L'entrée en cours d'édition a été modifiée et est valide. observe.message.table.editBean.modified.but.invalid=L'entrée en cours d'édition a été modifiée, mais n'est pas valide. @@ -1468,6 +1473,8 @@ observe.storage.useServerStorage.description=Veuillez configurer votre connexion observe.title.about=A propos d'ObServe... observe.title.can.not.delete.referentiel=Impossible de supprimer un référentiel en cours d'utilisation... observe.title.can.not.export.data=Impossible d'exporter les données vers la base centrale... +observe.title.can.not.export.data.left=Impossible d'exporter les données vers la base de gauche... +observe.title.can.not.export.data.right=Impossible d'exporter les données vers la base de droite... observe.title.can.not.export.obstuna=Impossible d'exporter des données d'obstuna... observe.title.choose.db.dump=Choisir une sauvegarder de base locale observe.title.choose.db.dump.directory=Choisir le répertoire de destination de la sauvegarde ===================================== pom.xml ===================================== @@ -26,7 +26,7 @@ <parent> <groupId>io.ultreia.maven</groupId> <artifactId>pom</artifactId> - <version>2018.56</version> + <version>2018.57</version> </parent> <groupId>fr.ird.observe</groupId> @@ -162,7 +162,7 @@ <lib.version.h2>1.4.196</lib.version.h2> <!--<lib.version.nuiton.topia>3.6-SNAPSHOT</lib.version.nuiton.topia>--> <!--<lib.version.java4all.eugene>3.0-alpha-21</lib.version.java4all.eugene>--> - <lib.version.java4all.topia>1.1.7-SNAPSHOT</lib.version.java4all.topia> + <!--<lib.version.java4all.topia>1.1.8-SNAPSHOT</lib.version.java4all.topia>--> <!-- license header configuration --> <license.licenseName>gpl_v3</license.licenseName> <license.organizationName>IRD, Code Lutin, Ultreia.io</license.organizationName> ===================================== server/src/main/java/fr/ird/observe/server/ObserveWebApplicationListener.java ===================================== @@ -32,11 +32,11 @@ import fr.ird.observe.server.injector.ObserveDataSourceConfigurationInjector; import fr.ird.observe.server.injector.ObserveDtoInjector; import fr.ird.observe.server.injector.ObserveReferenceSetRequestInjector; import fr.ird.observe.server.injector.SqlScriptProducerRequestInjector; +import fr.ird.observe.server.injector.TopiaSqlScriptInjector; import io.ultreia.java4all.http.HRequestBuilder; -import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.debux.webmotion.server.WebMotionServerListener; import org.debux.webmotion.server.call.ServerContext; import org.debux.webmotion.server.mapping.Mapping; @@ -80,6 +80,7 @@ public class ObserveWebApplicationListener implements WebMotionServerListener { context.addInjector(new DateInjector(HRequestBuilder.DATE_PATTERN)); context.addInjector(new SqlScriptProducerRequestInjector(gson)); context.addInjector(new ImmutableSetInjector(gson)); + context.addInjector(new TopiaSqlScriptInjector(gson)); context.addConverter(new ObserveDtoConverter(gson), ObserveDbUserDto.class); context.getServletContext().setAttribute(ObserveWebApplicationContext.APPLICATION_CONTEXT_PARAMETER, applicationContext); ===================================== server/src/main/java/fr/ird/observe/server/injector/TopiaSqlScriptInjector.java ===================================== @@ -0,0 +1,63 @@ +package fr.ird.observe.server.injector; + +/*- + * #%L + * ObServe :: Server + * %% + * 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.gson.Gson; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.debux.webmotion.server.call.Call; +import org.debux.webmotion.server.handler.ExecutorParametersInjectorHandler; +import org.debux.webmotion.server.mapping.Mapping; +import org.nuiton.topia.persistence.script.TopiaSqlScript; + +import java.lang.reflect.Type; +import java.util.Objects; + +/** + * @author Tony Chemit - dev@tchemit.fr + */ +public class TopiaSqlScriptInjector implements ExecutorParametersInjectorHandler.Injector { + + /** Logger. */ + private static final Logger log = LogManager.getLogger(TopiaSqlScriptInjector.class); + + protected final Gson gson; + + public TopiaSqlScriptInjector(Gson gson) { + this.gson = gson; + } + + @Override + public Object getValue(Mapping mapping, Call call, String name, Class<?> type, Type generic) { + TopiaSqlScript topiaSqlScript = null; + if (type.equals(TopiaSqlScript.class)) { + Call.ParameterTree parameterTree = call.getParameterTree().getObject().get(name); + Objects.requireNonNull(parameterTree, "Le paramètre " + name + " n'as pas été trouvé, recompiler (parameter)!"); + String gsonContent = ((String[]) parameterTree.getValue())[0]; + topiaSqlScript = gson.fromJson(gsonContent, TopiaSqlScript.class); + log.info("Inject topiaSqlScript: " + topiaSqlScript); + } + return topiaSqlScript; + } + +} ===================================== services-client/src/main/java/fr/ird/observe/services/client/ObserveRequestBuilder.java ===================================== @@ -24,6 +24,7 @@ package fr.ird.observe.services.client; import fr.ird.observe.services.configuration.rest.ObserveDataSourceConfigurationRestConstants; import io.ultreia.java4all.http.HRequestBuilder; +import org.nuiton.topia.persistence.script.TopiaSqlScript; import java.util.Objects; import java.util.concurrent.TimeUnit; @@ -72,4 +73,9 @@ public class ObserveRequestBuilder extends HRequestBuilder { addAuthTokenSupplier(serviceContext.getAuthTokenSupplier()); } } + + public ObserveRequestBuilder addParameter(String parameterName, TopiaSqlScript value) { + super.addParameter(parameterName, serviceContext.getResponseBuilder().getGson().get().toJson(value)); + return this; + } } ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/actions/synchro/referential/ng/ReferentialSynchronizeSqlsRequestBuilder.java ===================================== @@ -157,7 +157,8 @@ public class ReferentialSynchronizeSqlsRequestBuilder { @Override protected <DD extends ReferentialDto> ImmutableList<String> insertMissingReferential(Class<DD> referentialType, String id) { - return addExtraInsertStatement(id, binder); + ReferentialDtoEntityContext<DD, ?, ?> modelContext = DbModelHelper.fromReferentialDto(referentialType); + return addExtraInsertStatement(id, modelContext.toEntityBinder()); } }; ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/referential/ReferentialServiceLocal.java ===================================== @@ -70,6 +70,7 @@ import fr.ird.observe.spi.context.ReferentialEntityContext; import fr.ird.observe.spi.context.ReferentialReferenceEntityContext; import fr.ird.observe.spi.map.ImmutableDtoMap; import fr.ird.observe.spi.map.ImmutableSetDtoMap; +import fr.ird.observe.spi.map.ImmutableSetStringMap; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.nuiton.topia.persistence.TopiaDao; @@ -276,9 +277,9 @@ public class ReferentialServiceLocal extends ObserveServiceLocal implements Refe } @Override - public ImmutableSetDtoMap<String> getReferentialIds() { + public ImmutableSetStringMap getReferentialIds() { - ImmutableSetDtoMap.Builder<String> result = ImmutableSetDtoMap.builder(); + ImmutableSetStringMap.Builder result = ImmutableSetStringMap.builder(); for (Class<? extends ReferentialDto> dtoType : DtoModelClasses.REFERENTIAL_TYPES) { getReferentialIds0(dtoType, result); @@ -286,7 +287,7 @@ public class ReferentialServiceLocal extends ObserveServiceLocal implements Refe return result.build(); } - private <D extends ReferentialDto, R extends ReferentialDtoReference<D, R>, E extends ObserveReferentialEntity> void getReferentialIds0(Class<D> dtoType, ImmutableSetDtoMap.Builder<String> result) { + private <D extends ReferentialDto, R extends ReferentialDtoReference<D, R>, E extends ObserveReferentialEntity> void getReferentialIds0(Class<D> dtoType, ImmutableSetStringMap.Builder result) { ReferentialDtoEntityContext<D, R, E> typeContext = DbModelHelper.fromReferentialDto(dtoType); ReferentialEntityReferenceBinderSupport<D, R, E> binder = typeContext.toEntityReferenceBinder(); TopiaDao<E> dao = getTopiaPersistenceContext().getDao(binder.getEntityType()); @@ -312,7 +313,7 @@ public class ReferentialServiceLocal extends ObserveServiceLocal implements Refe } } - ImmutableSetDtoMap<String> missingReferentialIds = referentialShellBuilder.build(); + ImmutableSetStringMap missingReferentialIds = referentialShellBuilder.build(); if (missingReferentialIds.isEmpty()) { return null; ===================================== services-local/src/main/java/fr/ird/observe/services/local/service/referential/ReferentialShellBuilder.java ===================================== @@ -10,12 +10,12 @@ package fr.ird.observe.services.local.service.referential; * 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>. @@ -24,7 +24,7 @@ package fr.ird.observe.services.local.service.referential; import fr.ird.observe.entities.referentiel.ObserveReferentialEntity; import fr.ird.observe.spi.DbModelHelper; -import fr.ird.observe.spi.map.ImmutableSetDtoMap; +import fr.ird.observe.spi.map.ImmutableSetStringMap; import org.nuiton.topia.persistence.TopiaEntity; import org.nuiton.topia.persistence.TopiaEntityVisitor; @@ -39,35 +39,35 @@ import java.util.TreeSet; */ public class ReferentialShellBuilder { - public static ReferentialShellBuilder builder(ImmutableSetDtoMap<String> incomingReferentialIds) { - return new ReferentialShellBuilder(incomingReferentialIds); + private final GetEntityReferentialShellVisitor visitor; + + private ReferentialShellBuilder(ImmutableSetStringMap incomingReferentialIds) { + visitor = new GetEntityReferentialShellVisitor(incomingReferentialIds); } - private final GetEntityReferentialShellVisitor visitor; + public static ReferentialShellBuilder builder(ImmutableSetStringMap incomingReferentialIds) { + return new ReferentialShellBuilder(incomingReferentialIds); + } void scan(TopiaEntity entity) { entity.accept(visitor); } - public ImmutableSetDtoMap<String> build() { + public ImmutableSetStringMap build() { return visitor.missingReferentialIds.build(); } - private ReferentialShellBuilder(ImmutableSetDtoMap<String> incomingReferentialIds) { - visitor = new GetEntityReferentialShellVisitor(incomingReferentialIds); - } - private static class GetEntityReferentialShellVisitor implements TopiaEntityVisitor { private final Set<String> hitIds; - private final ImmutableSetDtoMap<String> incomingReferentialIds; - private final ImmutableSetDtoMap.Builder<String> missingReferentialIds; + private final ImmutableSetStringMap incomingReferentialIds; + private final ImmutableSetStringMap.Builder missingReferentialIds; - GetEntityReferentialShellVisitor(ImmutableSetDtoMap<String> incomingReferentialIds) { + GetEntityReferentialShellVisitor(ImmutableSetStringMap incomingReferentialIds) { this.incomingReferentialIds = incomingReferentialIds; this.hitIds = new TreeSet<>(); - this.missingReferentialIds = ImmutableSetDtoMap.builder(); + this.missingReferentialIds = ImmutableSetStringMap.builder(); } @Override ===================================== services/src/main/java/fr/ird/observe/services/service/referential/MissingReferentialRequest.java ===================================== @@ -23,7 +23,7 @@ package fr.ird.observe.services.service.referential; */ import fr.ird.observe.dto.ObserveDto; -import fr.ird.observe.spi.map.ImmutableSetDtoMap; +import fr.ird.observe.spi.map.ImmutableSetStringMap; /** * Created on 07/11/16. @@ -33,19 +33,19 @@ import fr.ird.observe.spi.map.ImmutableSetDtoMap; */ public class MissingReferentialRequest implements ObserveDto { - private final ImmutableSetDtoMap<String> centralSourceReferential; + private final ImmutableSetStringMap centralSourceReferential; private final String[] tripIds; - public static MissingReferentialRequest of(ImmutableSetDtoMap<String> centralSourceReferential, String... tripIds) { + public static MissingReferentialRequest of(ImmutableSetStringMap centralSourceReferential, String... tripIds) { return new MissingReferentialRequest(centralSourceReferential, tripIds); } - private MissingReferentialRequest(ImmutableSetDtoMap<String> centralSourceReferential, String... tripIds) { + private MissingReferentialRequest(ImmutableSetStringMap centralSourceReferential, String... tripIds) { this.centralSourceReferential = centralSourceReferential; this.tripIds = tripIds; } - public ImmutableSetDtoMap<String> getCentralSourceReferential() { + public ImmutableSetStringMap getCentralSourceReferential() { return centralSourceReferential; } ===================================== services/src/main/java/fr/ird/observe/services/service/referential/MissingReferentialResult.java ===================================== @@ -23,8 +23,8 @@ package fr.ird.observe.services.service.referential; */ import fr.ird.observe.dto.ObserveDto; +import fr.ird.observe.spi.map.ImmutableSetStringMap; import org.nuiton.topia.persistence.script.TopiaSqlScript; -import fr.ird.observe.spi.map.ImmutableSetDtoMap; /** * Created on 07/11/16. @@ -34,19 +34,19 @@ import fr.ird.observe.spi.map.ImmutableSetDtoMap; */ public class MissingReferentialResult implements ObserveDto { - private final ImmutableSetDtoMap<String> missingIds; + private final ImmutableSetStringMap missingIds; private final TopiaSqlScript sqlCode; - private MissingReferentialResult(ImmutableSetDtoMap<String> missingIds, TopiaSqlScript sqlCode) { + private MissingReferentialResult(ImmutableSetStringMap missingIds, TopiaSqlScript sqlCode) { this.missingIds = missingIds; this.sqlCode = sqlCode; } - public static MissingReferentialResult of(ImmutableSetDtoMap<String> missingReferentialIds, TopiaSqlScript sqlCode) { + public static MissingReferentialResult of(ImmutableSetStringMap missingReferentialIds, TopiaSqlScript sqlCode) { return new MissingReferentialResult(missingReferentialIds, sqlCode); } - public ImmutableSetDtoMap<String> getMissingIds() { + public ImmutableSetStringMap getMissingIds() { return missingIds; } ===================================== services/src/main/java/fr/ird/observe/services/service/referential/ReferentialService.java ===================================== @@ -40,6 +40,7 @@ import fr.ird.observe.services.spi.Write; import fr.ird.observe.services.spi.WriteDataPermission; import fr.ird.observe.services.spi.WriteReferentialPermission; import fr.ird.observe.spi.map.ImmutableSetDtoMap; +import fr.ird.observe.spi.map.ImmutableSetStringMap; import io.ultreia.java4all.http.spi.Delete; import io.ultreia.java4all.http.spi.Get; import io.ultreia.java4all.http.spi.Nullable; @@ -119,7 +120,7 @@ public interface ReferentialService extends ObserveService { @ReadReferentialPermission @Post - ImmutableSetDtoMap<String> getReferentialIds(); + ImmutableSetStringMap getReferentialIds(); @ReadReferentialPermission View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/0fbe5ba18d9798f4825c6448c1b... -- View it on GitLab: https://gitlab.com/ultreiaio/ird-observe/compare/0fbe5ba18d9798f4825c6448c1b... You're receiving this email because of your account on gitlab.com.