branch develop updated (2feac37 -> 2e18713)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git from 2feac37 There is still some errors on longline data in test dbs... new 88ca0f2 Ne pas sélectionner deux fois les objets dans le référentiel new 7d7cd08 amélioration de code (lambda,...) new 1191467 Utilisation du code compilé new efda480 Focus sur la double liste new 75b542b Toujours charger les combobox dans les écrans de référentiel new 15436d9 Bien chargé le formulaire du référentiel new 2e18713 Faire refonctionner les utilisations de référentiels The 7 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 2e187133dd8cbf7ec9b33a20f3e0d8f41d06b137 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 13:08:46 2016 +0200 Faire refonctionner les utilisations de référentiels commit 15436d9bf52ffa5bbc2e4f6aaaa29098eca850f5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:55:18 2016 +0200 Bien chargé le formulaire du référentiel commit 75b542b04ccb0514e71d9627b94580d94500ad8c Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:55:02 2016 +0200 Toujours charger les combobox dans les écrans de référentiel commit efda4800399877e14345e0d5d105f2d53c99d9ad Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:18:31 2016 +0200 Focus sur la double liste commit 1191467736261d27fb93b1ef94a06dc230d37bae Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:18:15 2016 +0200 Utilisation du code compilé commit 7d7cd08179f0d00fd1c382fa9b8ccddfcc3209c9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:17:58 2016 +0200 amélioration de code (lambda,...) commit 88ca0f2ebdb38d50edb61d93d0a2dfb5f56151c5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:17:46 2016 +0200 Ne pas sélectionner deux fois les objets dans le référentiel Summary of changes: .../ird/observe/ui/content/ContentUIHandler.java | 7 +- .../observe/ui/content/ContentUIInitializer.java | 128 +++++---------------- .../ird/observe/ui/content/ObserveContentUI.java | 2 + .../observe/ui/content/ref/ContentReferenceUI.jaxx | 2 +- .../ui/content/ref/ContentReferenceUIHandler.java | 90 ++++----------- .../ui/content/ref/impl/ReferenceEntity.jcss | 5 + .../ird/observe/ui/content/ref/impl/SpeciesUI.jaxx | 2 +- .../ird/observe/ui/content/ref/impl/SpeciesUI.jcss | 12 +- .../java/fr/ird/observe/ui/usage/UsagesUI.jaxx | 6 +- .../fr/ird/observe/ui/usage/UsagesUIHandler.java | 115 ++++++++++-------- .../v1/ReferentialServiceController.java | 4 +- .../services/service/ReferentialService.java | 4 +- .../dto/{DtoMap.java => ReferenceMap.java} | 13 +-- .../services/service/ReferentialServiceTopia.java | 31 +++-- 14 files changed, 160 insertions(+), 261 deletions(-) rename observe-services-model/src/main/java/fr/ird/observe/services/dto/{DtoMap.java => ReferenceMap.java} (75%) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 88ca0f2ebdb38d50edb61d93d0a2dfb5f56151c5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:17:46 2016 +0200 Ne pas sélectionner deux fois les objets dans le référentiel --- .../src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUI.jaxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUI.jaxx index 8ac51ef..1252346 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUI.jaxx @@ -83,7 +83,7 @@ viewLayout.addLayoutComponent(editView, DETAIL_VIEW); <JPanel id="listView" constraints="LIST_VIEW"> <JScrollPane id='listPane' constraints='BorderLayout.CENTER' columnHeaderView='{referentialListHeader}'> <JList id='list' - onValueChanged='getHandler().selectBean((ReferentialReference<E>)getSelectedBean(list))' + onValueChanged='if (!event.getValueIsAdjusting()) { getHandler().selectBean((ReferentialReference<E>)getSelectedBean(list)); }' onMouseClicked='if (event.getClickCount() == 2) { getHandler().modifyUI(); }'/> <BeanListHeader id='referentialListHeader' genericType='ReferentialReference<E>' _entityClass="getModel().getBeanType()"/> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 7d7cd08179f0d00fd1c382fa9b8ccddfcc3209c9 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:17:58 2016 +0200 amélioration de code (lambda,...) --- .../observe/ui/content/ContentUIInitializer.java | 128 +++++---------------- 1 file changed, 30 insertions(+), 98 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java index 8915c46..04806b7 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIInitializer.java @@ -157,15 +157,15 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E public static <B> ComboBoxCellEditor newDataColumnEditor(List<B> data, Decorator<B> decorator) { - JComboBox comboBox = new JComboBox(); + JComboBox<B> comboBox = new JComboBox<>(); return newDataColumnEditor(comboBox, data, decorator); } - public static <B> ComboBoxCellEditor newDataColumnEditor(JComboBox comboBox, List<B> data, Decorator<B> decorator) { + public static <B> ComboBoxCellEditor newDataColumnEditor(JComboBox<B> comboBox, List<B> data, Decorator<B> decorator) { - ListCellRenderer renderer = new DecoratorListCellRenderer(decorator); + ListCellRenderer<B> renderer = new DecoratorListCellRenderer(decorator); comboBox.setRenderer(renderer); prepareComboBoxData(comboBox, data); @@ -327,13 +327,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E final String propertyName = (String) editor.getClientProperty(CLIENT_PROPERTY_RESET_PROPERTY_NAME); if (propertyName != null) { - editor.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - JavaBeanObjectUtil.setProperty(getBean(), propertyName, null); - } - }); + editor.addActionListener(e -> JavaBeanObjectUtil.setProperty(getBean(), propertyName, null)); } return; @@ -424,11 +418,8 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E editor.init(); if (isAutoSelectOnFocus(editor)) { - JSpinner.DateEditor hourEditor = (JSpinner.DateEditor) editor.getHourEditor().getEditor(); - addAutoSelectOnFocus(hourEditor.getTextField()); - - JSpinner.DateEditor minuteEditor = (JSpinner.DateEditor) editor.getMinuteEditor().getEditor(); - addAutoSelectOnFocus(minuteEditor.getTextField()); + addAutoSelectOnFocus((JSpinner.DateEditor) editor.getHourEditor().getEditor()); + addAutoSelectOnFocus((JSpinner.DateEditor) editor.getMinuteEditor().getEditor()); } } @@ -440,15 +431,16 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E editor.init(); if (isAutoSelectOnFocus(editor)) { - JSpinner.DateEditor hourEditor = (JSpinner.DateEditor) editor.getHourEditor().getEditor(); - addAutoSelectOnFocus(hourEditor.getTextField()); - - JSpinner.DateEditor minuteEditor = (JSpinner.DateEditor) editor.getMinuteEditor().getEditor(); - addAutoSelectOnFocus(minuteEditor.getTextField()); + addAutoSelectOnFocus((JSpinner.DateEditor) editor.getHourEditor().getEditor()); + addAutoSelectOnFocus((JSpinner.DateEditor) editor.getMinuteEditor().getEditor()); } } + private void addAutoSelectOnFocus(JSpinner.DateEditor hourEditor) { + addAutoSelectOnFocus(hourEditor.getTextField()); + } + protected void init(CoordinatesEditor editor) { if (log.isDebugEnabled()) { log.debug("init coordinates editor " + editor.getName()); @@ -494,15 +486,11 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E } final String propertyName = (String) editor.getClientProperty(CLIENT_PROPERTY_PROPERTY_NAME); if (propertyName != null) { - editor.addItemListener(new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent event) { - if (event.getStateChange() == ItemEvent.SELECTED) { + editor.addItemListener(event -> { + if (event.getStateChange() == ItemEvent.SELECTED) { - Boolean newValue = ((BooleanEditor) event.getSource()).getBooleanValue(); - JavaBeanObjectUtil.setProperty(getBean(), propertyName, newValue); - } + Boolean newValue = ((BooleanEditor) event.getSource()).getBooleanValue(); + JavaBeanObjectUtil.setProperty(getBean(), propertyName, newValue); } }); } @@ -531,13 +519,9 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E } final String propertyName = (String) editor.getClientProperty(CLIENT_PROPERTY_PROPERTY_NAME); if (propertyName != null) { - editor.addItemListener(new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent event) { - Boolean newValue = ((JCheckBox) event.getSource()).isSelected(); - JavaBeanObjectUtil.setProperty(getBean(), propertyName, newValue); - } + editor.addItemListener(event -> { + Boolean newValue = ((JCheckBox) event.getSource()).isSelected(); + JavaBeanObjectUtil.setProperty(getBean(), propertyName, newValue); }); } } @@ -556,25 +540,21 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E final String propertyName = (String) picker.getClientProperty(CLIENT_PROPERTY_PROPERTY_NAME); if (propertyName != null) { - picker.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - JXDatePicker source = (JXDatePicker) e.getSource(); - Date date = source.getDate(); - JavaBeanObjectUtil.setProperty(getBean(), propertyName, date); - } + picker.addActionListener(e -> { + JXDatePicker source = (JXDatePicker) e.getSource(); + Date date = source.getDate(); + JavaBeanObjectUtil.setProperty(getBean(), propertyName, date); }); } } - protected <E extends Enum<E>> void init(EnumEditor<E> editor) { + protected <B extends Enum<B>> void init(EnumEditor<B> editor) { if (log.isDebugEnabled()) { log.debug("init enumEditor editor " + editor.getName()); } - ImmutableMap.Builder<E, String> labelsBuilder = ImmutableMap.builder(); - for (E e : EnumSet.allOf(editor.getType())) { + ImmutableMap.Builder<B, String> labelsBuilder = ImmutableMap.builder(); + for (B e : EnumSet.allOf(editor.getType())) { String label = I18nEnumUtil.getLabel(e); labelsBuilder.put(e, label); } @@ -591,13 +571,9 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E @Override public void focusGained(final FocusEvent e) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - JTextField source = (JTextField) e.getSource(); - source.selectAll(); - } + SwingUtilities.invokeLater(() -> { + JTextField source = (JTextField) e.getSource(); + source.selectAll(); }); } @@ -829,51 +805,7 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E comp.setToolTipText(tip); return comp; } -// -// @Override -// public Component getListCellRendererComponent(JList<? extends D> list, -// D value, -// int index, -// boolean isSelected, -// boolean cellHasFocus) { -// JComponent comp; -// comp = (JComponent) delegate.getListCellRendererComponent( -// list, -// value, -// index, -// isSelected, -// cellHasFocus); -// if (normalColor == null) { -// // premiere fois, on intialise la couleur dite normale -// normalColor = comp.getForeground(); -// } -// -// String tip = null; -// -// // par defaut, on utilise la couleur normale -// Color col = normalColor; -// if (value != null) { -// -// boolean enabled = true; -// -// if (value instanceof ReferentialReference<?>) { -// -// ReferentialReference e = (ReferentialReference) value; -// enabled = e.isEnabled(); -// -// } -// -// if (!enabled) { -// // l'entite est desactivee -// // on la grise pour bien la differencier -// col = disableColor; -// tip = t("observe.common.obsolete.entity", ((JLabel) comp).getText()); -// } -// } -// comp.setForeground(col); -// comp.setToolTipText(tip); -// return comp; -// } + } private static class ComboBoxListCellRenderer<E> implements ListCellRenderer<E> { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 1191467736261d27fb93b1ef94a06dc230d37bae Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:18:15 2016 +0200 Utilisation du code compilé --- .../java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jcss | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jcss b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jcss index a4c9a02..0429e30 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jcss +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jcss @@ -69,7 +69,7 @@ } #ocean { - property: ocean; + property: {SpeciesDto.PROPERTY_OCEAN}; selected:{(Collection)bean.getOcean()}; _validatorLabel: {t("observe.common.ocean")}; showListLabel: true; @@ -83,7 +83,7 @@ } #speciesGroup { - property:"speciesGroup"; + property:{SpeciesDto.PROPERTY_SPECIES_GROUP}; bean:{bean}; showReset:true; selectedItem:{bean.getSpeciesGroup()}; @@ -116,7 +116,7 @@ #minLength { bean:{bean}; - property:"minLength"; + property: {SpeciesDto.PROPERTY_MIN_LENGTH}; model:{bean.getMinLength()}; autoPopup:{config.isAutoPopupNumberEditor()}; showPopupButton:{config.isShowNumberEditorButton()}; @@ -127,7 +127,7 @@ #maxLength { bean:{bean}; - property:"maxLength"; + property:{SpeciesDto.PROPERTY_MAX_LENGTH}; model:{bean.getMaxLength()}; autoPopup:{config.isAutoPopupNumberEditor()}; showPopupButton:{config.isShowNumberEditorButton()}; @@ -138,7 +138,7 @@ #minWeight { bean:{bean}; - property:"minWeight"; + property:{SpeciesDto.PROPERTY_MIN_WEIGHT}; model:{bean.getMinWeight()}; autoPopup:{config.isAutoPopupNumberEditor()}; showPopupButton:{config.isShowNumberEditorButton()}; @@ -149,7 +149,7 @@ #maxWeight { bean:{bean}; - property:"maxWeight"; + property:{SpeciesDto.PROPERTY_MAX_WEIGHT}; model:{bean.getMaxWeight()}; autoPopup:{config.isAutoPopupNumberEditor()}; showPopupButton:{config.isShowNumberEditorButton()}; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit efda4800399877e14345e0d5d105f2d53c99d9ad Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:18:31 2016 +0200 Focus sur la double liste --- .../src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jaxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jaxx index dfe7f96..24cf71a 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/SpeciesUI.jaxx @@ -260,7 +260,7 @@ <row> <cell weightx="1"> - <JScrollPane id='oceanPane' layout='{new GridLayout(1,1)}'> + <JScrollPane id='oceanPane' layout='{new GridLayout(1,1)}' onFocusGained='ocean.requestFocus()'> <FilterableDoubleList id='ocean' genericType='ReferentialReference<OceanDto>' _entityClass='OceanDto.class'/> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 75b542b04ccb0514e71d9627b94580d94500ad8c Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:55:02 2016 +0200 Toujours charger les combobox dans les écrans de référentiel --- .../src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java | 3 ++- .../src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java | 2 ++ .../main/java/fr/ird/observe/ui/content/ref/impl/ReferenceEntity.jcss | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java index d8792f0..1ee6728 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java @@ -1002,11 +1002,12 @@ public abstract class ContentUIHandler<E extends IdDto> { protected <R extends ReferentialDto> void updateReferentialBeanComboBox(Class<R> dtoClass, BeanComboBox<ReferentialReference<R>> comboBox) { Boolean noLoad = (Boolean) comboBox.getClientProperty(ObserveContentUI.CLIENT_PROPERTY_LIST_NO_LOAD); + Boolean forceLoadComboBox = (Boolean) comboBox.getClientProperty(ObserveContentUI.CLIENT_PROPERTY_FORCE_LOAD_COMBO_BOX); String propertyName = comboBox.getProperty(); List<ReferentialReference<R>> data; - if (BooleanUtils.isTrue(noLoad) || getModel().getForm() == null) { + if (BooleanUtils.isNotTrue(forceLoadComboBox) && (BooleanUtils.isTrue(noLoad) || getModel().getForm() == null ) ) { if (log.isInfoEnabled()) { log.info(String.format("Skip loading of comboBox [%s-%s] (listNoLoad property found or form is null)", dtoClass.getSimpleName(), propertyName)); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java index 4d736c2..74cc597 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java @@ -41,6 +41,8 @@ import javax.swing.JToolBar; */ public interface ObserveContentUI<E extends IdDto> extends JAXXObject { + String CLIENT_PROPERTY_FORCE_LOAD_COMBO_BOX = "forceLoadComboBox"; + String CLIENT_PROPERTY_LIST_NO_LOAD = "listNoLoad"; String CLIENT_PROPERTY_ENTITY_CLASS = "entityClass"; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ReferenceEntity.jcss b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ReferenceEntity.jcss index eeaec30..cdcc2bf 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ReferenceEntity.jcss +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ReferenceEntity.jcss @@ -56,3 +56,7 @@ FilterableDoubleList { bean: {bean}; } + +BeanComboBox { + _forceLoadComboBox:true; +} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 15436d9bf52ffa5bbc2e4f6aaaa29098eca850f5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 11:55:18 2016 +0200 Bien chargé le formulaire du référentiel --- .../java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java | 1 + .../java/fr/ird/observe/services/service/ReferentialServiceTopia.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java index c15b241..dfff598 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java @@ -214,6 +214,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content if (selectedReference != null) { Form<E> form = getReferentialService().loadForm(getBeanType(), selectedReference.getId()); + getModel().setForm(form); E selectedBean = form.getObject(); diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java index 14ec415..56d5570 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java @@ -142,8 +142,8 @@ public class ReferentialServiceTopia extends ObserveServiceTopia implements Refe } ObserveReferentialEntity entity = loadEntity(type, id); - //FIXME Definir une definition pour chaque formulaire de référentiel - Form<D> form = referentialEntityToForm(type, entity, null); + ReferenceSetRequestDefinitions request = ReferenceSetRequestDefinitions.get(type); + Form<D> form = referentialEntityToForm(type, entity, request); D dto = form.getObject(); dto.setVersion(entity.getTopiaVersion()); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 2e187133dd8cbf7ec9b33a20f3e0d8f41d06b137 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Jul 26 13:08:46 2016 +0200 Faire refonctionner les utilisations de référentiels --- .../ird/observe/ui/content/ContentUIHandler.java | 6 +- .../ird/observe/ui/content/ObserveContentUI.java | 2 +- .../ui/content/ref/ContentReferenceUIHandler.java | 89 ++++------------ .../ui/content/ref/impl/ReferenceEntity.jcss | 3 +- .../java/fr/ird/observe/ui/usage/UsagesUI.jaxx | 6 +- .../fr/ird/observe/ui/usage/UsagesUIHandler.java | 115 ++++++++++++--------- .../v1/ReferentialServiceController.java | 4 +- .../services/service/ReferentialService.java | 4 +- .../dto/{DtoMap.java => ReferenceMap.java} | 13 +-- .../services/service/ReferentialServiceTopia.java | 27 ++--- 10 files changed, 114 insertions(+), 155 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java index 1ee6728..08db6d7 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ContentUIHandler.java @@ -913,9 +913,11 @@ public abstract class ContentUIHandler<E extends IdDto> { protected <R extends ReferentialDto> void updateReferentialFilterableDoubleList(Class<R> dtoClass, FilterableDoubleList<ReferentialReference<R>> list) { + Boolean forceLoadComboBox = (Boolean) list.getClientProperty(ObserveContentUI.CLIENT_PROPERTY_FORCE_LOAD); + List<ReferentialReference<R>> data; - if (getModel().getForm() == null) { + if (BooleanUtils.isNotTrue(forceLoadComboBox) && getModel().getForm() == null) { data = Collections.emptyList(); } else { @@ -1002,7 +1004,7 @@ public abstract class ContentUIHandler<E extends IdDto> { protected <R extends ReferentialDto> void updateReferentialBeanComboBox(Class<R> dtoClass, BeanComboBox<ReferentialReference<R>> comboBox) { Boolean noLoad = (Boolean) comboBox.getClientProperty(ObserveContentUI.CLIENT_PROPERTY_LIST_NO_LOAD); - Boolean forceLoadComboBox = (Boolean) comboBox.getClientProperty(ObserveContentUI.CLIENT_PROPERTY_FORCE_LOAD_COMBO_BOX); + Boolean forceLoadComboBox = (Boolean) comboBox.getClientProperty(ObserveContentUI.CLIENT_PROPERTY_FORCE_LOAD); String propertyName = comboBox.getProperty(); List<ReferentialReference<R>> data; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java index 74cc597..4d8cbe6 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ObserveContentUI.java @@ -41,7 +41,7 @@ import javax.swing.JToolBar; */ public interface ObserveContentUI<E extends IdDto> extends JAXXObject { - String CLIENT_PROPERTY_FORCE_LOAD_COMBO_BOX = "forceLoadComboBox"; + String CLIENT_PROPERTY_FORCE_LOAD = "forceLoad"; String CLIENT_PROPERTY_LIST_NO_LOAD = "listNoLoad"; diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java index dfff598..4281e80 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/ContentReferenceUIHandler.java @@ -24,7 +24,7 @@ package fr.ird.observe.ui.content.ref; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.db.DataContext; import fr.ird.observe.db.ObserveSwingDataSource; -import fr.ird.observe.services.dto.DtoMap; +import fr.ird.observe.services.dto.ReferenceMap; import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.IdDto; import fr.ird.observe.services.dto.constants.ReferenceStatus; @@ -63,34 +63,28 @@ import org.nuiton.util.beans.BinderFactory; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; -import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JToolBar; -import javax.swing.ListModel; import javax.swing.RowSorter; import javax.swing.SortOrder; import javax.swing.SpringLayout; import javax.swing.SwingUtilities; import javax.swing.border.TitledBorder; import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellRenderer; import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.beans.Introspector; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Locale; -import java.util.Map; import java.util.Set; import static org.nuiton.i18n.I18n.t; @@ -144,10 +138,9 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } - public static <E extends IdDto> void showUsagesForDelete( - JAXXContext tx, - E entity, - Map<Class<? extends IdDto>, List<? extends IdDto>> usages) { + public static <E extends IdDto> void showUsagesForDelete(JAXXContext tx, + E entity, + ReferenceMap usages) { DecoratorService service = ObserveSwingApplicationContext.get().getDecoratorService(); Decorator<?> decorator = service.getDecoratorByType(entity.getClass()); @@ -171,10 +164,9 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content 0); } - public static <E extends IdDto> boolean showUsagesForDesactivated( - JAXXContext tx, - E entity, - Map<Class<? extends IdDto>, List<? extends IdDto>> usages) { + public static <E extends IdDto> boolean showUsagesForDesactivated(JAXXContext tx, + E entity, + ReferenceMap usages) { DecoratorService service = ObserveSwingApplicationContext.get().getDecoratorService(); Decorator<?> decorator = service.getDecoratorByType(entity.getClass()); @@ -221,9 +213,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content getModel().setSelectedBean(selectedBean); // copy right now the selected bean to the model bean to respect contract - // of parent handler (for delation or save objectOperation...) - //FIXME - // getLoadBinder().load(selectedBean, getBean(), true); + // of parent handler (for delation or save object...) Binder<E, E> binder = BinderFactory.newBinder(getBeanType()); binder.copy(selectedBean, getBean()); @@ -322,8 +312,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content JTable table = new JTable(new UniqueKeyTableModel(columns, datas)); table.setAutoCreateRowSorter(true); - table.getRowSorter().setSortKeys(Arrays.asList( - new RowSorter.SortKey(0, SortOrder.ASCENDING))); + table.getRowSorter().setSortKeys(Collections.singletonList(new RowSorter.SortKey(0, SortOrder.ASCENDING))); table.setFillsViewportHeight(true); JScrollPane pane = new JScrollPane(); @@ -359,7 +348,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } // recherche des utilisation du bean dans la base - DtoMap usages; + ReferenceMap usages; try { usages = getReferentialService().findAllUsages(bean); @@ -438,16 +427,8 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content ContentReferenceUI<E> ui = getUi(); - ui.getViewLayout().addPropertyChangeListener( - CardLayout2Ext.SELECTED_PROPERTY_NAME, - new PropertyChangeListener() { - - @Override - public void propertyChange(PropertyChangeEvent evt) { - - SwingUtilities.invokeLater(revalidate); - } - }); + ui.getViewLayout().addPropertyChangeListener(CardLayout2Ext.SELECTED_PROPERTY_NAME, + evt -> SwingUtilities.invokeLater(revalidate)); // UIHelper.getLayer(ui.getEditKeyTable()).setUI(ui.getEditKeyTableLayerUI()); } @@ -706,18 +687,18 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content E oldBean = model.getSelectedBean(); if (oldBean != null && - oldBean.getStatus() == ReferenceStatus.enabled && - bean.getStatus() == ReferenceStatus.disabled) { + oldBean.getStatus() == ReferenceStatus.enabled && + bean.getStatus() == ReferenceStatus.disabled) { // l'entite a ete desactive // on recherche les objets utilisant cette entitee // on indique a l'utilisateur ce changement if (log.isDebugEnabled()) { log.debug("entity status was desactivated, looking " + - "for usage"); + "for usage"); } - DtoMap usages = getReferentialService().findAllUsages(bean); + ReferenceMap usages = getReferentialService().findAllUsages(bean); if (usages.isEmpty()) { if (log.isInfoEnabled()) { @@ -730,7 +711,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content if (!willsave) { if (log.isDebugEnabled()) { log.debug("User refuses to continue, skip " + - "saving..."); + "saving..."); } return false; } @@ -767,7 +748,7 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content } // recherche des utilisation du bean dans la base - DtoMap usages = getReferentialService().findAllUsages(bean); + ReferenceMap usages = getReferentialService().findAllUsages(bean); if (MapUtils.isEmpty(usages)) { if (log.isDebugEnabled()) { @@ -810,42 +791,10 @@ public class ContentReferenceUIHandler<E extends ReferentialDto> extends Content return incomingReferences; } - - public <I> int[] updateIndices(JList<I> jlist, Collection<I> list) { - if (log.isDebugEnabled()) { - log.debug(list == null ? 0 : list.size()); - } - List<Integer> indices = new ArrayList<>(); - - if (list != null && !list.isEmpty()) { - - ListModel<I> model = jlist.getModel(); - for (int i = 0, max = model.getSize(); i < max; i++) { - I s = model.getElementAt(i); - if (list.contains(s)) { - indices.add(i); - } - } - } - - int[] result = new int[indices.size()]; - int i = 0; - for (Integer indice : indices) { - result[i++] = indice; - } - indices.clear(); - return result; - } - public boolean canSeeI18nTable(E bean) { return bean instanceof I18nReferentialDto || bean instanceof VesselSizeCategoryDto; } - public void decorateUniqueKeyTable(JTable table, TableCellRenderer renderer, JScrollPane pane) { - table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); - UIHelper.fixTableColumnWidth(table, 1, 70); - } - public String updateView(boolean editing) { if (log.isDebugEnabled()) { log.debug("Editing has changed : " + editing); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ReferenceEntity.jcss b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ReferenceEntity.jcss index cdcc2bf..0101df4 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ReferenceEntity.jcss +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/ref/impl/ReferenceEntity.jcss @@ -55,8 +55,9 @@ FilterableDoubleList { bean: {bean}; + _forceLoad:true; } BeanComboBox { - _forceLoadComboBox:true; + _forceLoad:true; } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUI.jaxx index cf668af..30d5538 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUI.jaxx @@ -29,11 +29,9 @@ Interface graphique pour afficher la liste des usages d'une entitee donnee. fr.ird.observe.ObserveSwingApplicationContext fr.ird.observe.ui.UIHelper - fr.ird.observe.services.dto.IdDto + fr.ird.observe.services.dto.ReferenceMap java.awt.Dimension - java.util.List - java.util.Map </import> <script><![CDATA[ @@ -43,7 +41,7 @@ private UsagesUIHandler handler = new UsagesUIHandler(); public void init(String message, String message2, String message3, - Map<Class<? extends IdDto>, List<? extends IdDto>> usages) { + ReferenceMap usages) { getHandler().initUI(this, message,message2, message3, usages); } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java index a13e91e..73f4536 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/usage/UsagesUIHandler.java @@ -22,10 +22,14 @@ package fr.ird.observe.ui.usage; import fr.ird.observe.ObserveSwingApplicationContext; +import fr.ird.observe.services.dto.AbstractReference; +import fr.ird.observe.services.dto.DataDto; +import fr.ird.observe.services.dto.DataReference; import fr.ird.observe.services.dto.IdDto; -import fr.ird.observe.ui.DecoratorService; -import fr.ird.observe.services.dto.AbstractObserveDto; +import fr.ird.observe.services.dto.ReferenceMap; import fr.ird.observe.services.dto.referential.ReferentialDto; +import fr.ird.observe.services.dto.referential.ReferentialReference; +import fr.ird.observe.ui.DecoratorService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; @@ -37,6 +41,9 @@ import java.awt.Dimension; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -61,9 +68,9 @@ public class UsagesUIHandler { */ public void initUI(UsagesUI ui, String message, - String message2, String message3, - Map<Class<? extends IdDto>, - List<? extends IdDto>> usages) { + String message2, + String message3, + ReferenceMap usages) { // toujours nettoyer l'ui avant tout cleanUI(ui); @@ -77,17 +84,19 @@ public class UsagesUIHandler { ui.getMessage3().setText(message3); } if (usages.isEmpty()) { - ui.getUsages().add(new JLabel( - t("observe.message.no.usage.for.entity"))); + ui.getUsages().add(new JLabel(t("observe.message.no.usage.for.entity"))); } else { - for (Map.Entry<Class<? extends IdDto>, - List<? extends IdDto>> entry : usages.entrySet()) { - Class<? extends IdDto> type = entry.getKey(); - List<? extends IdDto> entitites = entry.getValue(); - String typeTitle = DecoratorService.getEntityLabel(type); - typeTitle = t(typeTitle); - addUsages(ui, type, entitites, typeTitle); + for (Map.Entry<Class<? extends IdDto>, Set<? extends AbstractReference>> entry : usages.entrySet()) { + Class dtoType = entry.getKey(); + Set references = entry.getValue(); + String typeTitle = t(DecoratorService.getEntityLabel(dtoType)); + if (DataDto.class.isAssignableFrom(dtoType)) { + addDataReferenceUsages(ui, dtoType, references, typeTitle); + } else { + addReferentialReferenceUsages(ui, dtoType, references, typeTitle); + } + } } } @@ -101,47 +110,59 @@ public class UsagesUIHandler { ui.getMessage3().setVisible(false); } - protected void addUsages(UsagesUI ui, - Class<? extends AbstractObserveDto> type, - List<? extends AbstractObserveDto> entitites, - String typeTitle) { + protected <D extends DataDto> void addDataReferenceUsages(UsagesUI ui, + Class<D> dtoType, + Set<DataReference<D>> references, + String typeTitle) { + + int size = references.size(); + String typetitle = n("observe.label.usage.data.title"); + typetitle = t(typetitle, typeTitle, size); + + Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDataReferenceDecorator(dtoType); + Objects.requireNonNull(decorator, "could not find decorator for type " + dtoType); + + List<String> data = new ArrayList<>(size); + data.addAll(references.stream().map(decorator::toString).collect(Collectors.toList())); + + JList<? super String> l = new JList<>(data.toArray()); JScrollPane pane = new JScrollPane(); - pane.setHorizontalScrollBarPolicy( - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - pane.setVerticalScrollBarPolicy( - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); pane.setMinimumSize(new Dimension(300, 30)); // pane.setMaximumSize(new Dimension(300, 100)); - String typetitle; - int size = entitites.size(); - if (ReferentialDto.class.isAssignableFrom(type)) { - typetitle = n("observe.label.usage.referentiel.title"); - } else { - typetitle = n("observe.label.usage.data.title"); - } - typetitle = t(typetitle, typeTitle, size); pane.setColumnHeaderView(new JLabel(typetitle)); - List<String> data = new ArrayList<>(size); - Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getDecoratorByType(type); - if (decorator == null) { - throw new NullPointerException( - "could not find decorator for type " + type); - } - for (AbstractObserveDto entitite : entitites) { - try { - String s = decorator.toString(entitite); - data.add(s); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error(e); - } - } - } - JList l = new JList(data.toArray()); pane.setViewportView(l); ui.getUsages().add(pane); } + protected <D extends ReferentialDto> void addReferentialReferenceUsages(UsagesUI ui, + Class<D> dtoType, + Set<ReferentialReference<D>> references, + String typeTitle) { + + int size = references.size(); + String typetitle = n("observe.label.usage.referentiel.title"); + typetitle = t(typetitle, typeTitle, size); + + Decorator<?> decorator = ObserveSwingApplicationContext.get().getDecoratorService().getReferentialReferenceDecorator(dtoType); + Objects.requireNonNull(decorator, "could not find decorator for type " + dtoType); + + List<String> data = new ArrayList<>(size); + data.addAll(references.stream().map(decorator::toString).collect(Collectors.toList())); + + JList<? super String> l = new JList<>(data.toArray()); + + JScrollPane pane = new JScrollPane(); + pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + pane.setMinimumSize(new Dimension(300, 30)); +// pane.setMaximumSize(new Dimension(300, 100)); + pane.setColumnHeaderView(new JLabel(typetitle)); + pane.setViewportView(l); + ui.getUsages().add(pane); + } + } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ReferentialServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ReferentialServiceController.java index 6e44588..2deb0f8 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ReferentialServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/ReferentialServiceController.java @@ -23,7 +23,7 @@ package fr.ird.observe.application.web.controller.v1; */ import com.google.common.collect.ImmutableSet; -import fr.ird.observe.services.dto.DtoMap; +import fr.ird.observe.services.dto.ReferenceMap; import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.ReferentialReference; @@ -94,7 +94,7 @@ public class ReferentialServiceController extends ObserveAuthenticatedServiceCon } @Override - public <R extends ReferentialDto> DtoMap findAllUsages(R bean) throws DataNotFoundException { + public <R extends ReferentialDto> ReferenceMap findAllUsages(R bean) throws DataNotFoundException { return service.findAllUsages(bean); } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/ReferentialService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/ReferentialService.java index fed9025..566914f 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/ReferentialService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/ReferentialService.java @@ -24,7 +24,7 @@ package fr.ird.observe.services.service; import com.google.common.collect.ImmutableSet; import fr.ird.observe.services.ObserveService; -import fr.ird.observe.services.dto.DtoMap; +import fr.ird.observe.services.dto.ReferenceMap; import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.referential.ReferentialDto; import fr.ird.observe.services.dto.referential.ReferentialReference; @@ -85,7 +85,7 @@ public interface ReferentialService extends ObserveService { //FIXME Pfff, on ne veut pas récuperer des dto, mais des références @ReadReferentialPermission @ReadDataPermission - <R extends ReferentialDto> DtoMap findAllUsages(R bean) throws DataNotFoundException; + <R extends ReferentialDto> ReferenceMap findAllUsages(R bean) throws DataNotFoundException; @ReadReferentialPermission @ReadDataPermission diff --git a/observe-services-model/src/main/java/fr/ird/observe/services/dto/DtoMap.java b/observe-services-model/src/main/java/fr/ird/observe/services/dto/ReferenceMap.java similarity index 75% rename from observe-services-model/src/main/java/fr/ird/observe/services/dto/DtoMap.java rename to observe-services-model/src/main/java/fr/ird/observe/services/dto/ReferenceMap.java index 3dd3487..8ff0aee 100644 --- a/observe-services-model/src/main/java/fr/ird/observe/services/dto/DtoMap.java +++ b/observe-services-model/src/main/java/fr/ird/observe/services/dto/ReferenceMap.java @@ -22,22 +22,15 @@ package fr.ird.observe.services.dto; import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.Set; /** - * A Dictionary of dtos + * A Dictionary of references indexed by their type. * * @author Kevin Morin (Code Lutin) */ -public class DtoMap extends HashMap<Class<? extends IdDto>, List<? extends IdDto>> { +public class ReferenceMap extends HashMap<Class<? extends IdDto>, Set<? extends AbstractReference>> { private static final long serialVersionUID = 1L; - public DtoMap() { - } - - public DtoMap(Map<? extends Class<? extends IdDto>, ? extends List<? extends IdDto>> m) { - super(m); - } } diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java index 56d5570..1a4ec1a 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/ReferentialServiceTopia.java @@ -33,9 +33,9 @@ import fr.ird.observe.entities.referentiel.Species; import fr.ird.observe.services.ObserveServiceTopia; import fr.ird.observe.services.binder.BinderEngine; import fr.ird.observe.services.binder.referential.ReferentialBinderSupport; -import fr.ird.observe.services.dto.AbstractReferenceSet; import fr.ird.observe.services.dto.DataDto; -import fr.ird.observe.services.dto.DtoMap; +import fr.ird.observe.services.dto.DataReferenceSet; +import fr.ird.observe.services.dto.ReferenceMap; import fr.ird.observe.services.dto.Form; import fr.ird.observe.services.dto.constants.ReferenceStatus; import fr.ird.observe.services.dto.reference.ReferenceSetDefinition; @@ -54,9 +54,7 @@ import org.nuiton.topia.persistence.TopiaEntity; import java.util.Collection; import java.util.Collections; import java.util.Date; -import java.util.LinkedHashSet; import java.util.List; -import java.util.Set; /** * Created on 16/08/15. @@ -70,7 +68,7 @@ public class ReferentialServiceTopia extends ObserveServiceTopia implements Refe @Override public <D extends ReferentialDto> ReferentialReferenceSet<D> getReferenceSet(Class<D> type, Date lastUpdateDate) { if (log.isTraceEnabled()) { - log.trace("getReferenceSet(" + type.getName() + ", " + lastUpdateDate + ")" ); + log.trace("getReferenceSet(" + type.getName() + ", " + lastUpdateDate + ")"); } Class<ObserveReferentialEntity> entityType = BinderEngine.get().getReferentialEntityType(type); @@ -215,7 +213,7 @@ public class ReferentialServiceTopia extends ObserveServiceTopia implements Refe } @Override - public <R extends ReferentialDto> DtoMap findAllUsages(R bean) throws DataNotFoundException { + public <R extends ReferentialDto> ReferenceMap findAllUsages(R bean) throws DataNotFoundException { if (log.isTraceEnabled()) { log.trace("findAllUsages(" + bean.getId() + ")"); } @@ -228,9 +226,8 @@ public class ReferentialServiceTopia extends ObserveServiceTopia implements Refe TopiaDao<ObserveReferentialEntity> dao = getTopiaPersistenceContext().getDao(entityType); EntityMap allUsages = new EntityMap(dao.findAllUsages(entity)); - Set<AbstractReferenceSet<?, ?>> result = new LinkedHashSet<>(allUsages.size()); + ReferenceMap result = new ReferenceMap(); - AbstractReferenceSet referenceSet; for (Class<? extends TopiaEntity> type : allUsages.keySet()) { List<? extends TopiaEntity> entities = allUsages.get(type); @@ -238,20 +235,18 @@ public class ReferentialServiceTopia extends ObserveServiceTopia implements Refe if (ObserveReferentialEntity.class.isAssignableFrom(type)) { Class<ReferentialDto> dtoType = BINDER_ENGINE.getReferentialDtoType((Class) type); - referenceSet = toReferentialReferenceSet(dtoType, (List) entities, null); - + ReferentialReferenceSet referenceSet = toReferentialReferenceSet(dtoType, (List) entities, null); + result.put(dtoType, referenceSet.getReferences()); } else { - Class<DataDto> dtoType = BINDER_ENGINE.getDataDtoType((Class)type); - referenceSet = toDataReferenceSet(dtoType, (List) entities); - + Class<DataDto> dtoType = BINDER_ENGINE.getDataDtoType((Class) type); + DataReferenceSet referenceSet = toDataReferenceSet(dtoType, (List) entities); + result.put(dtoType, referenceSet.getReferences()); } - result.add(referenceSet); } - //FIXME Revoir cette partie... - return null; + return result; } @Override -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm