branch develop updated (a8b986e -> b247f3d)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository observe. See http://git.codelutin.com/observe.git from a8b986e suppresion des paramètres specifiques à une base H2 new 1e61487 Migration de l'écran des rejet de thon + generalisation des services sur les captures pour gérer les rejéts.(refs #7605) new 40f8542 mise en place de la validation (refs #7605) new b247f3d Merge branch 'feature/7605' into develop The 3 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 b247f3dc2b341a8fef649d72012d0dcefbe32954 Merge: a8b986e 40f8542 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Oct 20 15:53:50 2015 +0200 Merge branch 'feature/7605' into develop commit 40f8542ce3c6113f14ab14c2b4818e17bdabeae8 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Oct 20 15:53:09 2015 +0200 mise en place de la validation (refs #7605) commit 1e614877585a081efd2f01ac16df714ad860f2ba Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Oct 20 15:41:00 2015 +0200 Migration de l'écran des rejet de thon + generalisation des services sur les captures pour gérer les rejéts.(refs #7605) Summary of changes: .../ui/content/table/impl/seine/TargetCatchUI.jaxx | 2 +- .../table/impl/seine/TargetCatchUIHandler.java | 6 +- .../table/impl/seine/TargetCatchUIModel.java | 1 + .../table/impl/seine/TargetDiscardCatchUI.jaxx | 15 +- .../impl/seine/TargetDiscardCatchUIHandler.java | 426 +++++++-------------- .../impl/seine/TargetDiscardCatchUIModel.java | 38 +- ...Dto-n1-update-targetCatch-error-validation.xml} | 0 ...-n1-update-targetDiscarded-error-validation.xml | 2 +- ...-n1-update-targetDiscarded-error-validation.xml | 0 ...1-update-targetDiscarded-warning-validation.xml | 0 .../v1/seine/TargetCatchServiceController.java | 8 +- .../ird/observe/entities/seine/TargetCatchs.java | 10 + .../services/service/seine/TargetCatchService.java | 4 +- .../src/main/xmi/observe-services-dto-seine.zargo | Bin 61190 -> 61271 bytes .../service/seine/TargetCatchServiceTopia.java | 66 +++- 15 files changed, 246 insertions(+), 332 deletions(-) rename observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/{SetSeineTargetCatchDto-n1-update-error-validation.xml => SetSeineTargetCatchDto-n1-update-targetCatch-error-validation.xml} (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/SetSeine-n1-update-targetDiscarded-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-targetDiscarded-error-validation.xml (93%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/TargetCatch-n1-update-targetDiscarded-error-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/TargetCatchDto-n1-update-targetDiscarded-error-validation.xml (100%) copy observe-entities-validation/src/main/resources/fr/ird/observe/entities/seine/TargetCatch-n1-update-targetDiscarded-warning-validation.xml => observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/TargetCatchDto-n1-update-targetDiscarded-warning-validation.xml (100%) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit 1e614877585a081efd2f01ac16df714ad860f2ba Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Oct 20 15:41:00 2015 +0200 Migration de l'écran des rejet de thon + generalisation des services sur les captures pour gérer les rejéts.(refs #7605) --- .../table/impl/seine/TargetCatchUIHandler.java | 6 +- .../table/impl/seine/TargetCatchUIModel.java | 1 + .../table/impl/seine/TargetDiscardCatchUI.jaxx | 15 +- .../impl/seine/TargetDiscardCatchUIHandler.java | 426 +++++++-------------- .../impl/seine/TargetDiscardCatchUIModel.java | 38 +- .../v1/seine/TargetCatchServiceController.java | 8 +- .../ird/observe/entities/seine/TargetCatchs.java | 10 + .../services/service/seine/TargetCatchService.java | 4 +- .../src/main/xmi/observe-services-dto-seine.zargo | Bin 61190 -> 61271 bytes .../service/seine/TargetCatchServiceTopia.java | 66 +++- 10 files changed, 244 insertions(+), 330 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java index 55fe43e..d633ed4 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIHandler.java @@ -33,6 +33,7 @@ import fr.ird.observe.services.dto.ReferenceSetDto; import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; +import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.dto.seine.SetSeineTargetCatchDto; import fr.ird.observe.services.dto.seine.SetSeineTargetCatchDtos; import fr.ird.observe.services.dto.seine.TargetCatchDto; @@ -300,7 +301,8 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa @Override protected void doPersist(SetSeineTargetCatchDto bean) { - getTargetCatchService().save(bean); + SaveResultDto save = getTargetCatchService().save(bean); + bean.setLastUpdate(save.getLastUpdate()); } @Override @@ -308,7 +310,7 @@ public class TargetCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCa String tripSeineId = getDataContext().getSelectedTripSeineId(); - FormDto<SetSeineTargetCatchDto> formDto = getTargetCatchService().loadToEdit(beanId, tripSeineId); + FormDto<SetSeineTargetCatchDto> formDto = getTargetCatchService().loadToEdit(beanId, false, tripSeineId); getModel().setFormDto(formDto); diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIModel.java index b4930cc..e5c3262 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUIModel.java @@ -50,6 +50,7 @@ public class TargetCatchUIModel extends ContentTableUIModel<SetSeineTargetCatchD super(SetSeineTargetCatchDto.class, TargetCatchDto.class, new String[]{ + SetSeineTargetCatchDto.PROPERTY_DISCARDED, SetSeineTargetCatchDto.PROPERTY_TARGET_CATCH }, new String[]{ diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUI.jaxx index 7c2729e..8ea3383 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUI.jaxx @@ -21,19 +21,17 @@ --> <fr.ird.observe.ui.content.table.ContentTableUI - superGenericType='SetSeineDto, TargetCatchDto' + superGenericType='SetSeineTargetCatchDto, TargetCatchDto' contentTitle='{n("observe.common.targetDiscarded")}' saveNewEntryText='{n("observe.action.create.targetDiscarded")}' - saveNewEntryTip='{n("observe.action.create.targetDiscarded.tip")}' - - > + saveNewEntryTip='{n("observe.action.create.targetDiscarded.tip")}'> <style source="../../CommonTable.css"/> <import> fr.ird.observe.services.dto.ReferenceDto fr.ird.observe.services.dto.CommentableDto - fr.ird.observe.services.dto.seine.SetSeineDto + fr.ird.observe.services.dto.seine.SetSeineTargetCatchDto fr.ird.observe.services.dto.seine.TargetCatchDto fr.ird.observe.services.dto.referential.seine.WeightCategoryDto fr.ird.observe.services.dto.referential.SpeciesDto @@ -57,7 +55,7 @@ <TargetDiscardCatchUIModel id='model' constructorParams='this'/> <!-- edit bean --> - <SetSeineDto id='bean'/> + <SetSeineTargetCatchDto id='bean'/> <!-- table edit bean --> <TargetCatchDto id='tableEditBean'/> @@ -67,12 +65,11 @@ <!-- le validateur de l'écran --> <BeanValidator id='validator' - beanClass='fr.ird.observe.services.dto.seine.SetSeineDto' + beanClass='fr.ird.observe.services.dto.seine.SetSeineTargetCatchDto' errorTableModel='{getErrorTableModel()}' context='n1-update-targetDiscarded'> <!-- clef unique --> - <!--FIXME--> - <!--<field name="targetCatch" component="editorPanel"/>--> + <field name="targetCatch" component="editorPanel"/> </BeanValidator> <!-- le validateur d'une entrée de tableau --> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java index dd5146a..2493a40 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIHandler.java @@ -21,38 +21,44 @@ */ package fr.ird.observe.ui.content.table.impl.seine; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import fr.ird.observe.ObserveSwingApplicationContext; import fr.ird.observe.business.db.constants.DataContextType; import fr.ird.observe.services.dto.FormDto; import fr.ird.observe.services.dto.ReferenceDto; +import fr.ird.observe.services.dto.ReferenceSetDto; +import fr.ird.observe.services.dto.referential.ReferentialReferenceDto; import fr.ird.observe.services.dto.referential.SpeciesDto; import fr.ird.observe.services.dto.referential.seine.ReasonForDiscardDto; import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; -import fr.ird.observe.services.dto.seine.SetSeineDto; -import fr.ird.observe.services.dto.seine.SetSeineDtos; +import fr.ird.observe.services.dto.result.SaveResultDto; +import fr.ird.observe.services.dto.seine.SetSeineTargetCatchDto; +import fr.ird.observe.services.dto.seine.SetSeineTargetCatchDtos; import fr.ird.observe.services.dto.seine.TargetCatchDto; -import fr.ird.observe.services.dto.seine.TargetLengthDto; -import fr.ird.observe.services.service.seine.SetSeineService; +import fr.ird.observe.services.dto.seine.TargetCatchDtos; +import fr.ird.observe.services.service.seine.TargetCatchService; import fr.ird.observe.ui.UIHelper; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ContentTableUIHandler; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.context.JAXXContextEntryDef; import jaxx.runtime.swing.editor.bean.BeanComboBox; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; -import javax.swing.*; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; 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.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; @@ -61,53 +67,36 @@ import static org.nuiton.i18n.I18n.t; * @author Tony Chemit - chemit@codelutin.com * @since 1.0 */ -public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineDto, TargetCatchDto> { +public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineTargetCatchDto, TargetCatchDto> { /** Logger */ static private Log log = LogFactory.getLog(TargetDiscardCatchUIHandler.class); - JAXXContextEntryDef<List<ReferenceDto<WeightCategoryDto>>> ALL_CATEGORIES_ENTRY = - UIHelper.newListContextEntryDef("RejetThonUI-all-categories"); - - JAXXContextEntryDef<List<ReferenceDto<ReasonForDiscardDto>>> ALL_RAISONS_REJET_ENTRY = - UIHelper.newListContextEntryDef("RejetThonUI-all-reasonForDiscards"); - - JAXXContextEntryDef<List<ReferenceDto<TargetLengthDto>>> ALL_TAILLES_TO_DELETE_ENTRY = - UIHelper.newListContextEntryDef("RejetThonUI-all-taille-to-delete"); - - //FIXME -// TopiaExecutor<WeightCategoryDto> weightCategoryTopiaExecutor = new TopiaExecutor<WeightCategoryDto>() { -// @Override -// public void execute(TopiaContext tx, WeightCategory bean) { -// getDecoratorService().decorate(bean.getSpecies()); -// } -// }; - public TargetDiscardCatchUIHandler(TargetDiscardCatchUI ui) { super(ui, DataContextType.SetSeine); } - protected static Collection<WeightCategoryDto> getWeightCategoryUsed( - ContentTableModel<SetSeineDto, TargetCatchDto> model) { - List<WeightCategoryDto> list = model.getColumnValues(1); - Collection<WeightCategoryDto> set = new HashSet<WeightCategoryDto>(list); + protected static Collection<ReferenceDto<WeightCategoryDto>> getWeightCategoryUsed( + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model) { + + List<ReferenceDto<WeightCategoryDto>> list = model.getColumnValues(1); + Collection<ReferenceDto<WeightCategoryDto>> set = Sets.newHashSet(list); list.clear(); return set; } - protected static Collection<ReasonForDiscardDto> getReasonForDiscardUsed( - ContentTableModel<SetSeineDto, TargetCatchDto> model, - WeightCategoryDto weightCategory) { + protected static Collection<ReferenceDto<ReasonForDiscardDto>> getReasonForDiscardUsed( + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model, + ReferenceDto<WeightCategoryDto> weightCategory) { - Collection<ReasonForDiscardDto> set = new HashSet<ReasonForDiscardDto>(); + Collection<ReferenceDto<ReasonForDiscardDto>> set = Sets.newHashSet(); if (weightCategory != null) { for (int i = 0; i < model.getRowCount(); i++) { TargetCatchDto c = model.getValueAt(i); if (c != null && weightCategory.equals(c.getWeightCategory()) && c.getReasonForDiscard() != null) { - //FIXME -// set.add(c.getReasonForDiscard()); + set.add(c.getReasonForDiscard()); } } } @@ -137,7 +126,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD @Override public void propertyChange(PropertyChangeEvent evt) { - ContentTableModel<SetSeineDto, TargetCatchDto> model = + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); TargetCatchDto bean = model.getRowBean(); @@ -145,7 +134,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD // en mode creation , on doit recalculer la liste // des categories - SpeciesDto species = (SpeciesDto) evt.getNewValue(); + ReferenceDto<SpeciesDto> species = (ReferenceDto<SpeciesDto>) evt.getNewValue(); onEspeceChanged(bean, species); } } @@ -163,14 +152,14 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD @Override public void propertyChange(PropertyChangeEvent evt) { - ContentTableModel<SetSeineDto, TargetCatchDto> model = + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); TargetCatchDto bean = model.getRowBean(); if (bean.getId() == null) { // en mode creation , on doit recalculer la liste // des raison rejet - WeightCategoryDto weightCategory = - (WeightCategoryDto) evt.getNewValue(); + ReferenceDto<WeightCategoryDto> weightCategory = + (ReferenceDto<WeightCategoryDto>) evt.getNewValue(); onCategorieChanged(bean, weightCategory); } @@ -185,163 +174,45 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD return getDataContext().getSelectedSetId(); } - //FIXME -// @Override -// protected SetSeine loadEditBean(ContentMode mode, -// DataContext dataContext, -// DataService dataService, -// DataSource dataSource) { -// -// List<WeightCategory> categorieList; -// List<ReasonForDiscard> reasonForDiscardList; -// -// if (mode == ContentMode.UPDATE) { -// -// // on charge le formulaire uniquement si en mode édition -// -// categorieList = new ArrayList<WeightCategory>( -// dataService.loadDecoratedEntities( -// dataSource, -// WeightCategory.class, -// weightCategoryTopiaExecutor) -// ); -// -// // filtre sur la liste d'espèce configuree -// ObserveSwingApplicationConfig config = getUi().getContextValue(ObserveSwingApplicationConfig.class); -// String speciesListId = config.getSpeciesListSeineTargetCatchId(); -// java.util.Set<String> speciesIds = loadSpeciesList(speciesListId, n("observe.error.speciesList.seine.targetCatch.notFound")); -// -// categorieList = Species2.filterWeightCategoryBySpeciesIds( -// categorieList, speciesIds); -// -// // filtre par status actif -// ReferenceEntities.filterReferentielListByStatus(categorieList); -// -// // get current ocean -// Ocean ocean = dataService.getTripOcean(dataSource, dataContext.getSelectedTripId()); -// -// // filtre par ocean -// categorieList = Species2.filterWeightCategoryByOcean(categorieList, ocean); -// -// reasonForDiscardList = new ArrayList<ReasonForDiscard>( -// dataService.loadDecoratedEntities(dataSource, ReasonForDiscard.class)); -// -// // filtre par status actif -// ReferenceEntities.filterReferentielListByStatus(reasonForDiscardList); -// -// } else { -// -// categorieList = new ArrayList<WeightCategory>(); -// reasonForDiscardList = new ArrayList<ReasonForDiscard>(); -// } -// -// TargetDiscardCatchUI ui = getUi(); -// -// ALL_CATEGORIES_ENTRY.setContextValue(ui, categorieList); -// ALL_RAISONS_REJET_ENTRY.setContextValue(ui, reasonForDiscardList); -// -// return super.loadEditBean(mode, dataContext, dataService, dataSource); -// } - - //FIXME -// @Override -// protected Collection<TargetCatch> loadChilds(TopiaContext tx, SetSeine bean) throws TopiaException { -// Collection<TargetCatch> childs = getModel().getChildsUpdator().getChilds(bean); -// Collection<TargetCatch> data = new ArrayList<TargetCatch>(); -// if (CollectionUtils.isNotEmpty(childs)) { -// TopiaDAO<TargetCatch> dao = -// getDataSource().getDAO(tx, getTableEditBean()); -// TopiaEntityBinder<TargetCatch> childLoador = getModel().getChildLoador(); -// DecoratorService decoratorService = getDecoratorService(); -// for (TargetCatch c : childs) { -// if (!c.isDiscarded()) { -// // ce n'est pas un rejet, on ne le retient pas dans cette -// // liste -// if (log.isDebugEnabled()) { -// log.debug("targetCatch " + c.getSpecies().getLabel2() + " non retenu."); -// } -// continue; -// } -// try { -// TargetCatch c2 = getModel().newTableEditBean(); -// TargetCatch safeC = dao.findByTopiaId(c.getTopiaId()); -// WeightCategory weightCategory = safeC.getWeightCategory(); -// if (weightCategory != null) { -// Species species = weightCategory.getSpecies(); -// decoratorService.decorate(species); -// } -// childLoador.load(safeC, c2, true); -// data.add(c2); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// } -// } -// return data; -// } - - //FIXME @Override - protected boolean doSave(SetSeineDto bean) throws Exception { + protected boolean prepareSave(SetSeineTargetCatchDto bean, List<TargetCatchDto> objets) { - try { - return super.doSave(bean); + //on cherche si parmis les captures supprimer certaines ont des échantillon + SetSeineTargetCatchDto originalSetSeineTargetCatchDto = getModel().getFormDto().getForm(); + SetSeineTargetCatchDto currentSetSeineTargetCatch = getModel().getBean(); - } finally { + Set<ReferentialReferenceDto<SpeciesDto>> speciesToDelete = Sets.newHashSet(); - // toujours supprimer la référence du context, quoiqu'il arrive - ALL_TAILLES_TO_DELETE_ENTRY.removeContextValue(getUi()); - } - } + for (TargetCatchDto targetCatchDto : originalSetSeineTargetCatchDto.getTargetCatch()) { - @Override - protected boolean prepareSave(SetSeineDto bean, List<TargetCatchDto> objets) { + if (targetCatchDto.isHasSample()) { - // on recupere les speciess acceptables pour des echantillonnages - // i.e une species d'un targetDiscarded montee sur le pont + ReferentialReferenceDto<SpeciesDto> species = targetCatchDto.getSpecies(); - java.util.Set<SpeciesDto> speciessUsed = new HashSet<SpeciesDto>(); - for (TargetCatchDto c : objets) { - if (c.getBroughtOnDeck() != null && c.getBroughtOnDeck()) { - //FIXME -// speciessUsed.add(c.getSpecies()); - } - } + Iterable<TargetCatchDto> currentTargetCatchSpecies = TargetCatchDtos.filterBySpecies(currentSetSeineTargetCatch.getTargetCatch(), species); - // il faut supprimer les echantillon thons sur des speciess qui ne - // sont plus sur un rejet + if (Iterables.isEmpty(currentTargetCatchSpecies)) { - List<ReferenceDto<TargetLengthDto>> tailleToDelete = new ArrayList<>(); - java.util.Set<SpeciesDto> speciessToDelete = new HashSet<SpeciesDto>(); + speciesToDelete.add(species); - //FIXME -// getDataService().getObsoleteEspeceForTargetSample(getDataSource(), -// bean.getTopiaId(), -// speciessUsed, -// speciessToDelete, -// tailleToDelete, -// true); + } + } - if (!tailleToDelete.isEmpty()) { + } + if (!speciesToDelete.isEmpty()) { // il existe des echantillon thon a supprimer on demande une // confirmation StringBuilder sb = new StringBuilder(512); - StringBuilder sb2 = new StringBuilder(512); - Decorator<SpeciesDto> decorator = - getDecoratorService().getDecoratorByType(SpeciesDto.class); - Decorator<TargetLengthDto> decorator2 = - getDecoratorService().getDecoratorByType(TargetLengthDto.class); - - for (SpeciesDto e : speciessToDelete) { - sb.append(" - ").append(decorator.toString(e)).append('\n'); - } - for (ReferenceDto<TargetLengthDto> t : tailleToDelete) { - sb2.append(" - ").append(decorator2.toString(t)).append('\n'); + Decorator<ReferenceDto> decorator = + getDecoratorService().getDecoratorByType(ReferenceDto.class, SpeciesDto.class.getSimpleName()); + + for (ReferentialReferenceDto<SpeciesDto> species : speciesToDelete) { + sb.append(" - ").append(decorator.toString(species)).append('\n'); } int reponse = UIHelper.askUser( t("observe.title.need.confirm"), - t("observe.targetDiscarded.message.table.will.delete.targetLength", sb.toString(), sb2.toString()), + t("observe.targetDiscarded.message.table.will.delete.targetLength", sb.toString()), JOptionPane.ERROR_MESSAGE, new Object[]{ t("observe.choice.continue"), @@ -363,79 +234,33 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD // l'utilisateur a choisi de ne pas continuer return false; } - - // on conserve les tailles a supprimer - ALL_TAILLES_TO_DELETE_ENTRY.setContextValue(getUi(), tailleToDelete); - } - - // mise a jour de la propriete targetDiscarded - bean.setTargetDiscarded(!objets.isEmpty()); - - for (TargetCatchDto discarded : objets) { - - // FIXME : on devrait pas a avoir a repositionner la propriete discarded - discarded.setDiscarded(true); - - // on attache la set - //FIXME -// discarded.setSetSeine(bean); } return true; } - //FIXME -// @Override -// protected void onUpdateFinalize(TopiaContext tx, SetSeine bean, Collection<TargetCatch> oldChilds) { -// -// if (oldChilds != null && !oldChilds.isEmpty()) { -// -// // on reinjecte les discarded thon precedemment saisies dans la set -// // et qui ne sont pas des rejets -// -// for (TargetCatch targetCatch : oldChilds) { -// if (!targetCatch.isDiscarded()) { -// bean.addTargetCatch(targetCatch); -// } -// } -// } -// -// List<TargetLength> tailleToDelete = ALL_TAILLES_TO_DELETE_ENTRY.getContextValue(getUi()); -// -// if (tailleToDelete != null && !tailleToDelete.isEmpty()) { -// -// // on a demande la suppression de taille obsoletes -// -// if (log.isInfoEnabled()) { -// log.info("Will remove " + tailleToDelete.size() + -// " obsolete targetLength(s)."); -// } -// -// TargetSample echantillon = bean.getTargetSample(true); -// -// // on supprime les echantillons obsoletes -// echantillon.getTargetLength().removeAll(tailleToDelete); -// } -// } - @Override protected void onSelectedRowChanged(int editingRow, TargetCatchDto bean, boolean create) { TargetDiscardCatchUI ui = getUi(); - //FIXME -// WeightCategoryDto beanWeightCategory = bean.getWeightCategory(); -// SpeciesDto beanEspece = beanWeightCategory == null ? null : -// beanWeightCategory.getSpecies(); -// ReasonForDiscardDto beanReasonForDiscard = bean.getReasonForDiscard(); -// if (log.isDebugEnabled()) { -// log.debug("selected categoriePoid " + beanWeightCategory); -// log.debug("selected species " + beanEspece); -// log.debug("selected reasonForDiscard " + beanReasonForDiscard); -// } + ReferenceDto<WeightCategoryDto> beanWeightCategory = bean.getWeightCategory(); + + ReferenceDto<SpeciesDto> beanSpecies = null; + if (beanWeightCategory != null) { + beanSpecies = (ReferenceDto<SpeciesDto>) beanWeightCategory.getPropertyValue(WeightCategoryDto.PROPERTY_SPECIES); + } + + ReferenceDto<ReasonForDiscardDto> beanReasonForDiscard = bean.getReasonForDiscard(); + if (log.isDebugEnabled()) { + log.debug("selected categoriePoid " + beanWeightCategory); + log.debug("selected species " + beanSpecies); + log.debug("selected reasonForDiscard " + beanReasonForDiscard); + } JComponent requestFocus; if (create) { - ContentTableModel<SetSeineDto, TargetCatchDto> model = getTableModel(); + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); + if (model.isCreate()) { // par défaut, on considère que l'espèce a été monté sur le pont // c'est le cas le plus fréquent. @@ -443,24 +268,20 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD } // on recalcule la liste des speciess disponibles - //FIXME -// List<SpeciesDto> availableEspeces = buildEspeceList( -// beanEspece, beanWeightCategory); - //FIXME -// ui.getSpecies().setData(availableEspeces); + List<ReferenceDto<SpeciesDto>> availableSpecies = buildEspeceList(beanSpecies, beanWeightCategory); + ui.getSpecies().setData(availableSpecies); // on reinitilise toujours l'species (pour reinitialiser la liste // des categories) ui.getSpecies().setSelectedItem(null); if (!model.isCreate()) { - //FIXME -// // on repositionne l'species (cela reconstruira la liste -// // des categories) -// ui.getSpecies().setSelectedItem(beanEspece); -// // on repositionne la categorie -// ui.getWeightCategory().setSelectedItem(beanWeightCategory); -// ui.getReasonForDiscard().setSelectedItem(beanReasonForDiscard); + // on repositionne l'species (cela reconstruira la liste + // des categories) + ui.getSpecies().setSelectedItem(beanSpecies); + // on repositionne la categorie + ui.getWeightCategory().setSelectedItem(beanWeightCategory); + ui.getReasonForDiscard().setSelectedItem(beanReasonForDiscard); } requestFocus = ui.getSpecies(); @@ -469,12 +290,11 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD // au singleton de sa valeur correspondante dans le bean // puisque dans ce mode, pas possibilite de modifier de cette // valeur (clef metier) - //FIXME -// ui.getSpecies().setSelectedItem(beanEspece); -// ui.getWeightCategory().setData(Arrays.asList(beanWeightCategory)); -// ui.getWeightCategory().setSelectedItem(beanWeightCategory); -// ui.getReasonForDiscard().setData(Arrays.asList(beanReasonForDiscard)); -// ui.getReasonForDiscard().setSelectedItem(beanReasonForDiscard); + ui.getSpecies().setSelectedItem(beanSpecies); + ui.getWeightCategory().setData(Arrays.asList(beanWeightCategory)); + ui.getWeightCategory().setSelectedItem(beanWeightCategory); + ui.getReasonForDiscard().setData(Arrays.asList(beanReasonForDiscard)); + ui.getReasonForDiscard().setSelectedItem(beanReasonForDiscard); requestFocus = ui.getCatchWeight(); } @@ -504,15 +324,15 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD n("observe.targetDiscarded.table.comment"), n("observe.targetDiscarded.table.comment.tip")); - UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, SpeciesDto.class)); - UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, WeightCategoryDto.class)); - UIHelper.setTableColumnRenderer(table, 2, UIHelper.newDecorateTableCellRenderer(renderer, ReasonForDiscardDto.class)); + UIHelper.setTableColumnRenderer(table, 0, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, SpeciesDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 1, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, WeightCategoryDto.class.getSimpleName())); + UIHelper.setTableColumnRenderer(table, 2, UIHelper.newDecorateTableCellRenderer(renderer, ReferenceDto.class, ReasonForDiscardDto.class.getSimpleName())); UIHelper.setTableColumnRenderer(table, 3, UIHelper.newEmptyNumberTableCellRenderer(renderer)); UIHelper.setTableColumnRenderer(table, 4, UIHelper.newStringTableCellRenderer(renderer, 20, false)); UIHelper.setTableColumnRenderer(table, 5, UIHelper.newStringTableCellRenderer(renderer, 10, true)); } - protected void onEspeceChanged(TargetCatchDto bean, SpeciesDto species) { + protected void onEspeceChanged(TargetCatchDto bean, ReferenceDto<SpeciesDto> species) { ReferenceDto<WeightCategoryDto> weightCategory = null; @@ -551,7 +371,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD combo.setSelectedItem(weightCategory); } - protected void onCategorieChanged(TargetCatchDto bean, WeightCategoryDto weightCategory) { + protected void onCategorieChanged(TargetCatchDto bean, ReferenceDto<WeightCategoryDto> weightCategory) { TargetDiscardCatchUI ui = getUi(); ReferenceDto<ReasonForDiscardDto> reasonForDiscard = null; @@ -568,7 +388,9 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD // un categorie est selectionne, on met a jour la liste des raisons // rejet disponible pour cette categorie - List<ReferenceDto<ReasonForDiscardDto>> reasonForDiscardList = buildReasonFordiscardList(weightCategory); + reasonForDiscard = bean.getReasonForDiscard(); + + List<ReferenceDto<ReasonForDiscardDto>> reasonForDiscardList = buildReasonFordiscardList(weightCategory, reasonForDiscard); if (log.isDebugEnabled()) { log.debug("new reasonForDiscard list " + reasonForDiscardList); @@ -576,7 +398,7 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD data = reasonForDiscardList; - reasonForDiscard = bean.getReasonForDiscard(); + if (reasonForDiscard != null && !reasonForDiscardList.contains(reasonForDiscard)) { @@ -594,9 +416,9 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD combo.setSelectedItem(reasonForDiscard); } - protected List<SpeciesDto> buildEspeceList(SpeciesDto species, ReferenceDto<WeightCategoryDto> weightCategory) { + protected List<ReferenceDto<SpeciesDto>> buildEspeceList(ReferenceDto<SpeciesDto> species, ReferenceDto<WeightCategoryDto> weightCategory) { - List<ReferenceDto<WeightCategoryDto>> weightCategoryList = getAllCategories(getUi()); + List<ReferenceDto<WeightCategoryDto>> weightCategoryList = getAllCategories(); removeFullyUsedCategories(weightCategoryList); @@ -604,21 +426,20 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD weightCategoryList.add(weightCategory); } - Collection<SpeciesDto> usedEspeces = new HashSet<SpeciesDto>(); + Collection<ReferenceDto<SpeciesDto>> usedEspeces = Sets.newHashSet(); for (ReferenceDto<WeightCategoryDto> cat : weightCategoryList) { - //FIXME -// usedEspeces.add(cat.getSpecies()); + usedEspeces.add((ReferenceDto<SpeciesDto>) cat.getPropertyValue(WeightCategoryDto.PROPERTY_SPECIES)); } - List<SpeciesDto> result = new ArrayList<SpeciesDto>(usedEspeces); + List<ReferenceDto<SpeciesDto>> result = Lists.newArrayList(usedEspeces); weightCategoryList.clear(); usedEspeces.clear(); return result; } - protected List<ReferenceDto<WeightCategoryDto>> buildWeightCategoryList(SpeciesDto species) { + protected List<ReferenceDto<WeightCategoryDto>> buildWeightCategoryList(ReferenceDto<SpeciesDto> species) { - List<ReferenceDto<WeightCategoryDto>> weightCategoryList = getAllCategories(getUi()); + List<ReferenceDto<WeightCategoryDto>> weightCategoryList = getAllCategories(); // on filtre les categories sur l'espèce donnée for (Iterator<ReferenceDto<WeightCategoryDto>> it = weightCategoryList.iterator(); @@ -637,17 +458,20 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD } @SuppressWarnings("unchecked") - protected List<ReferenceDto<ReasonForDiscardDto>> buildReasonFordiscardList(WeightCategoryDto weightCategory) { + protected List<ReferenceDto<ReasonForDiscardDto>> buildReasonFordiscardList(ReferenceDto<WeightCategoryDto> weightCategory, ReferenceDto<ReasonForDiscardDto> currentReason) { - ContentTableModel<SetSeineDto, TargetCatchDto> model = getTableModel(); - List<ReferenceDto<ReasonForDiscardDto>> reasonForDiscardList = - new ArrayList<>(ALL_RAISONS_REJET_ENTRY.getContextValue(getUi())); + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); + ReferenceSetDto<ReasonForDiscardDto> reasonForDiscardSetDto = getModel().getFormDto().getReferenceSetDto(ReasonForDiscardDto.class); + + List<ReferenceDto<ReasonForDiscardDto>> reasonForDiscardList = Lists.newArrayList((Set) reasonForDiscardSetDto.getReference()); // on filtre les raison rejet sur la categorie for (int i = 0; i < model.getRowCount(); i++) { TargetCatchDto c = model.getValueAt(i); - if (c != null && c.getReasonForDiscard() != null && - weightCategory.equals(c.getWeightCategory())) { + if (c != null + && c.getReasonForDiscard() != null + && (currentReason == null || ! currentReason.equals(c.getReasonForDiscard())) + && weightCategory.equals(c.getWeightCategory())) { reasonForDiscardList.remove(c.getReasonForDiscard()); } } @@ -655,24 +479,27 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD return reasonForDiscardList; } - protected List<ReferenceDto<WeightCategoryDto>> getAllCategories(JAXXContext context) { - List<ReferenceDto<WeightCategoryDto>> list = new ArrayList<>( - ALL_CATEGORIES_ENTRY.getContextValue(context)); - return list; + protected List<ReferenceDto<WeightCategoryDto>> getAllCategories() { + ReferenceSetDto<WeightCategoryDto> weightCategorySetDto = getModel().getFormDto().getReferenceSetDto(WeightCategoryDto.class); + + List<ReferenceDto<WeightCategoryDto>> weightCategoryList = Lists.newArrayList((Set) weightCategorySetDto.getReference()); + + return weightCategoryList; } protected void removeFullyUsedCategories( List<ReferenceDto<WeightCategoryDto>> weightCategoryAvaillable) { - ContentTableModel<SetSeineDto, TargetCatchDto> model = getTableModel(); + ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> model = getTableModel(); + + ReferenceSetDto<ReasonForDiscardDto> reasonForDiscardSetDto = getModel().getFormDto().getReferenceSetDto(ReasonForDiscardDto.class); - int nbReasonForDiscard = - ALL_RAISONS_REJET_ENTRY.getContextValue(getUi()).size(); + int nbReasonForDiscard = reasonForDiscardSetDto.sizeReference(); // on filtre toutes les weightCategory qui ont deja references toutes // les raisons rejets - for (WeightCategoryDto c : getWeightCategoryUsed(model)) { - Collection<ReasonForDiscardDto> raisonUsed = getReasonForDiscardUsed(model, c); + for (ReferenceDto<WeightCategoryDto> c : getWeightCategoryUsed(model)) { + Collection<ReferenceDto<ReasonForDiscardDto>> raisonUsed = getReasonForDiscardUsed(model, c); if (raisonUsed.size() == nbReasonForDiscard) { // toutes les raison de rejet epuisé pour cette categorie weightCategoryAvaillable.remove(c); @@ -681,18 +508,25 @@ public class TargetDiscardCatchUIHandler extends ContentTableUIHandler<SetSeineD } @Override - protected void doPersist(SetSeineDto bean) { - getSetSeineService().save(getSelectedParentId(), bean); + protected void doPersist(SetSeineTargetCatchDto bean) { + SaveResultDto save = getTargetCatchService().save(bean); + bean.setLastUpdate(save.getLastUpdate()); } + @Override protected void loadEditBean(String beanId) { - FormDto<SetSeineDto> formDto = getSetSeineService().loadToEdit(beanId); + + String tripSeineId = getDataContext().getSelectedTripSeineId(); + + FormDto<SetSeineTargetCatchDto> formDto = getTargetCatchService().loadToEdit(beanId, true, tripSeineId); + getModel().setFormDto(formDto); - SetSeineDtos.copySetSeineDto(formDto.getForm(), getBean()); + + SetSeineTargetCatchDtos.copySetSeineTargetCatchDto(formDto.getForm(), getBean()); } - protected SetSeineService getSetSeineService() { - return ObserveSwingApplicationContext.get().newService(SetSeineService.class); + protected TargetCatchService getTargetCatchService() { + return ObserveSwingApplicationContext.get().newService(TargetCatchService.class); } } diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIModel.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIModel.java index f64b986..7115cb9 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIModel.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetDiscardCatchUIModel.java @@ -24,13 +24,15 @@ package fr.ird.observe.ui.content.table.impl.seine; import com.google.common.collect.Lists; import fr.ird.observe.services.dto.referential.seine.WeightCategoryDto; -import fr.ird.observe.services.dto.seine.SetSeineDto; +import fr.ird.observe.services.dto.seine.SetSeineTargetCatchDto; import fr.ird.observe.services.dto.seine.TargetCatchDto; +import fr.ird.observe.services.dto.seine.TargetCatchDtos; import fr.ird.observe.ui.content.table.ContentTableMeta; import fr.ird.observe.ui.content.table.ContentTableModel; import fr.ird.observe.ui.content.table.ContentTableUIModel; import fr.ird.observe.ui.content.table.ObserveContentTableUI; +import java.util.Collection; import java.util.List; /** @@ -39,21 +41,18 @@ import java.util.List; * @author Tony Chemit - chemit@codelutin.com * @since XXX */ -public class TargetDiscardCatchUIModel extends ContentTableUIModel<SetSeineDto, TargetCatchDto> { +public class TargetDiscardCatchUIModel extends ContentTableUIModel<SetSeineTargetCatchDto, TargetCatchDto> { private static final long serialVersionUID = 1L; public TargetDiscardCatchUIModel(TargetDiscardCatchUI ui) { - super(SetSeineDto.class, + super(SetSeineTargetCatchDto.class, TargetCatchDto.class, new String[]{ - //FIXME -// SetSeineDto.PROPERTY_TARGET_CATCH, - SetSeineDto.PROPERTY_TARGET_DISCARDED}, + SetSeineTargetCatchDto.PROPERTY_DISCARDED, + SetSeineTargetCatchDto.PROPERTY_TARGET_CATCH}, new String[]{ - //FIXME -// TargetCatchDto.PROPERTY_SET_SEINE, TargetCatchDto.PROPERTY_WEIGHT_CATEGORY, TargetCatchDto.PROPERTY_CATCH_WEIGHT, TargetCatchDto.PROPERTY_REASON_FOR_DISCARD, @@ -74,8 +73,25 @@ public class TargetDiscardCatchUIModel extends ContentTableUIModel<SetSeineDto, } @Override - protected ContentTableModel<SetSeineDto, TargetCatchDto> createTableModel(ObserveContentTableUI<SetSeineDto, TargetCatchDto> ui, List<ContentTableMeta<TargetCatchDto>> contentTableMetas) { - // FIXME - return null; + protected ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto> createTableModel( + ObserveContentTableUI<SetSeineTargetCatchDto, TargetCatchDto> ui, + List<ContentTableMeta<TargetCatchDto>> contentTableMetas) { + + return new ContentTableModel<SetSeineTargetCatchDto, TargetCatchDto>(ui, contentTableMetas) { + @Override + protected Collection<TargetCatchDto> getChilds(SetSeineTargetCatchDto bean) { + return bean.getTargetCatch(); + } + + @Override + protected void load(TargetCatchDto source, TargetCatchDto target) { + TargetCatchDtos.copyTargetCatchDto(source, target); + } + + @Override + protected void setChilds(SetSeineTargetCatchDto parent, List<TargetCatchDto> childs) { + bean.setTargetCatch(childs); + } + }; } } diff --git a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TargetCatchServiceController.java b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TargetCatchServiceController.java index 56634d4..7a270ef 100644 --- a/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TargetCatchServiceController.java +++ b/observe-application-web/src/main/java/fr/ird/observe/application/web/controller/v1/seine/TargetCatchServiceController.java @@ -38,13 +38,13 @@ public class TargetCatchServiceController extends ObserveAuthenticatedServiceCon } @Override - public FormDto<SetSeineTargetCatchDto> loadToRead(String setSeineId) { - return service.loadToRead(setSeineId); + public FormDto<SetSeineTargetCatchDto> loadToRead(String setSeineId, boolean discarded) { + return service.loadToRead(setSeineId, discarded); } @Override - public FormDto<SetSeineTargetCatchDto> loadToEdit(String setSeineId, String tripSeineId) { - return service.loadToEdit(setSeineId, tripSeineId); + public FormDto<SetSeineTargetCatchDto> loadToEdit(String setSeineId, boolean discarded, String tripSeineId) { + return service.loadToEdit(setSeineId, discarded, tripSeineId); } @Override diff --git a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchs.java b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchs.java index df3882f..5c53e07 100644 --- a/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchs.java +++ b/observe-entities/src/main/java/fr/ird/observe/entities/seine/TargetCatchs.java @@ -1,6 +1,7 @@ package fr.ird.observe.entities.seine; import com.google.common.base.Function; +import com.google.common.base.Predicate; import fr.ird.observe.entities.referentiel.Species; /** @@ -17,4 +18,13 @@ public class TargetCatchs { }; } + public static Predicate<TargetCatch> newDiscardedPredicate(final boolean discarded) { + return new Predicate<TargetCatch>() { + @Override + public boolean apply(TargetCatch input) { + return discarded == input.isDiscarded(); + } + }; + } + } diff --git a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TargetCatchService.java b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TargetCatchService.java index 8cbe090..850339a 100644 --- a/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TargetCatchService.java +++ b/observe-services-api/src/main/java/fr/ird/observe/services/service/seine/TargetCatchService.java @@ -37,10 +37,10 @@ import fr.ird.observe.services.spi.WriteDataPermission; public interface TargetCatchService extends ObserveService { @ReadDataPermission - FormDto<SetSeineTargetCatchDto> loadToRead(String setSeineId); + FormDto<SetSeineTargetCatchDto> loadToRead(String setSeineId, boolean discarded); @WriteDataPermission - FormDto<SetSeineTargetCatchDto> loadToEdit(String setSeineId, String tripSeineId); + FormDto<SetSeineTargetCatchDto> loadToEdit(String setSeineId, boolean discarded, String tripSeineId); @Write @WriteDataPermission diff --git a/observe-services-model/src/main/xmi/observe-services-dto-seine.zargo b/observe-services-model/src/main/xmi/observe-services-dto-seine.zargo index 7e29c36..3e11620 100644 Binary files a/observe-services-model/src/main/xmi/observe-services-dto-seine.zargo and b/observe-services-model/src/main/xmi/observe-services-dto-seine.zargo differ diff --git a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TargetCatchServiceTopia.java b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TargetCatchServiceTopia.java index 2613c8b..254b91a 100644 --- a/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TargetCatchServiceTopia.java +++ b/observe-services-topia/src/main/java/fr/ird/observe/services/service/seine/TargetCatchServiceTopia.java @@ -1,7 +1,9 @@ package fr.ird.observe.services.service.seine; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import com.google.common.collect.Sets; import fr.ird.observe.entities.referentiel.Ocean; import fr.ird.observe.entities.referentiel.Species; @@ -22,27 +24,43 @@ import fr.ird.observe.services.dto.result.SaveResultDto; import fr.ird.observe.services.dto.result.SaveResultDtos; import fr.ird.observe.services.dto.seine.SetSeineTargetCatchDto; import fr.ird.observe.services.dto.seine.TargetCatchDto; +import fr.ird.observe.services.dto.seine.TargetCatchDtos; import fr.ird.observe.services.dto.seine.TripSeineDto; import org.nuiton.topia.persistence.TopiaEntities; +import java.util.Collection; +import java.util.List; import java.util.Set; /** * @author Sylvain Bavencoff - bavencoff@codelutin.com */ public class TargetCatchServiceTopia extends ObserveServiceTopia implements TargetCatchService { + @Override - public FormDto<SetSeineTargetCatchDto> loadToRead(String setSeineId) { + public FormDto<SetSeineTargetCatchDto> loadToRead(String setSeineId, boolean discarded) { SetSeine setSeine = loadEntity(SetSeineTargetCatchDto.class, SetSeine.class, setSeineId); FormDto<SetSeineTargetCatchDto> form = entityToReadFormDto(SetSeineTargetCatchDto.class, SetSeine.class, setSeine); + SetSeineTargetCatchDto setSeineTargetCatchDto = form.getForm(); + + setSeineTargetCatchDto.setDiscarded(discarded); + + // on filtre les captures pour ne garder que les conservées ou les rejetées + Collection<TargetCatchDto> allTargetCatchDtos = setSeineTargetCatchDto.getTargetCatch(); + + List<TargetCatchDto> targetCatchDtos = Lists.newArrayList(Iterables.filter(allTargetCatchDtos, TargetCatchDtos.newDiscardedPredicate(discarded))); + + setSeineTargetCatchDto.setTargetCatch(targetCatchDtos); + + return form; } @Override - public FormDto<SetSeineTargetCatchDto> loadToEdit(String setSeineId, String tripSeineId) { + public FormDto<SetSeineTargetCatchDto> loadToEdit(String setSeineId, boolean discarded, String tripSeineId) { SetSeine setSeine = loadEntity(SetSeineTargetCatchDto.class, SetSeine.class, setSeineId); @@ -61,8 +79,18 @@ public class TargetCatchServiceTopia extends ObserveServiceTopia implements Targ SetSeineTargetCatchDto setSeineTargetCatchDto = form.getForm(); + setSeineTargetCatchDto.setDiscarded(discarded); + + // on filtre les captures pour ne garder que les conservées ou les rejetées + Collection<TargetCatchDto> allTargetCatchDtos = setSeineTargetCatchDto.getTargetCatch(); + + List<TargetCatchDto> targetCatchDtos = Lists.newArrayList(Iterables.filter(allTargetCatchDtos, TargetCatchDtos.newDiscardedPredicate(discarded))); + + setSeineTargetCatchDto.setTargetCatch(targetCatchDtos); + + // on cherche si il y a des échantillons sur les captures - TargetSample targetSample = setSeine.getTargetSample(false); + TargetSample targetSample = setSeine.getTargetSample(discarded); if (targetSample != null) { @@ -87,13 +115,35 @@ public class TargetCatchServiceTopia extends ObserveServiceTopia implements Targ @Override public SaveResultDto save(SetSeineTargetCatchDto dto) { - SetSeine setSeine = dtoToEntity(SetSeineTargetCatchDto.class, SetSeine.class, dto); + // on affect le discarded a toute les capture reçus. + for (TargetCatchDto targetCatchDto : dto.getTargetCatch()) { + targetCatchDto.setDiscarded(dto.isDiscarded()); + } + + // on conserve la liste des captures rejetées ou conservées + SetSeine setSeine = loadEntity(SetSeineTargetCatchDto.class, SetSeine.class, dto.getId()); + + SetSeineTargetCatchDto oldDto = entityToDto(SetSeineTargetCatchDto.class, SetSeine.class, setSeine); + + Collection<TargetCatchDto> allTargetCatchDtos = oldDto.getTargetCatch(); + + List<TargetCatchDto> otherTargetCatchDtos = Lists.newArrayList(Iterables.filter( + allTargetCatchDtos, + TargetCatchDtos.newDiscardedPredicate( ! dto.isDiscarded()))); + + dto.addAllTargetCatch(otherTargetCatchDtos); + + setSeine = dtoToEntity(SetSeineTargetCatchDto.class, SetSeine.class, dto); // on supprime les échantillons qui ne correspondent plus a des capture - TargetSample targetSample = setSeine.getTargetSample(false); + TargetSample targetSample = setSeine.getTargetSample(dto.isDiscarded()); - Set<Species> speciesCatchs = Sets.newHashSet(Iterables.transform( + Iterable<TargetCatch> targetCatches = Iterables.filter( setSeine.getTargetCatch(), + TargetCatchs.newDiscardedPredicate(dto.isDiscarded())); + + Set<Species> speciesCatchs = Sets.newHashSet(Iterables.transform( + targetCatches, TargetCatchs.getSpeciesFunction())); Set<TargetLength> targetLengthToDelete = Sets.newHashSet(); @@ -121,8 +171,12 @@ public class TargetCatchServiceTopia extends ObserveServiceTopia implements Targ targetCatch.setSetSeine(setSeine); } + Optional<TargetCatch> targetCatchDiscardedOptional = Iterables.tryFind(setSeine.getTargetCatch(), TargetCatchs.newDiscardedPredicate(true)); + setSeine.setTargetDiscarded(targetCatchDiscardedOptional.isPresent()); + setSeine = saveEntity(SetSeine.class, setSeine); return SaveResultDtos.newSaveResult(setSeine.getTopiaId(), setSeine.getLastUpdate()); } + } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit 40f8542ce3c6113f14ab14c2b4818e17bdabeae8 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Oct 20 15:53:09 2015 +0200 mise en place de la validation (refs #7605) --- .../ui/content/table/impl/seine/TargetCatchUI.jaxx | 2 +- ...Dto-n1-update-targetCatch-error-validation.xml} | 0 ...n1-update-targetDiscarded-error-validation.xml} | 6 +- ...-n1-update-targetDiscarded-error-validation.xml | 98 ++++++++++++++++++++++ ...-update-targetDiscarded-warning-validation.xml} | 24 +++--- 5 files changed, 116 insertions(+), 14 deletions(-) diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUI.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUI.jaxx index 881e02d..193fb48 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUI.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/content/table/impl/seine/TargetCatchUI.jaxx @@ -65,7 +65,7 @@ <BeanValidator id='validator' beanClass='fr.ird.observe.services.dto.seine.SetSeineTargetCatchDto' errorTableModel='{getErrorTableModel()}' - context='n1-update'> + context='n1-update-targetCatch'> <!-- clef unique --> <field name="targetCatch" component="editorPanel"/> </BeanValidator> diff --git a/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-error-validation.xml b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-targetCatch-error-validation.xml similarity index 100% copy from observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-error-validation.xml copy to observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-targetCatch-error-validation.xml diff --git a/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-error-validation.xml b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-targetDiscarded-error-validation.xml similarity index 84% copy from observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-error-validation.xml copy to observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-targetDiscarded-error-validation.xml index f6d972a..551d94a 100644 --- a/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-error-validation.xml +++ b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-targetDiscarded-error-validation.xml @@ -28,12 +28,12 @@ <field name="targetCatch"> - <!-- clef unique sur la categorie weight et well --> + <!-- clef unique sur la categorie weight et la raison rejet --> <field-validator type="collectionFieldExpression"> <param name="mode">UNIQUE_KEY</param> - <param name="keys">weightCategory.id,well</param> - <message>validator.targetCatch.uniqueKey</message> + <param name="keys">weightCategory.id,reasonForDiscard.id</param> + <message>validator.targetDiscarded.uniqueKey</message> </field-validator> </field> diff --git a/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/TargetCatchDto-n1-update-targetDiscarded-error-validation.xml b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/TargetCatchDto-n1-update-targetDiscarded-error-validation.xml new file mode 100644 index 0000000..d01264e --- /dev/null +++ b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/TargetCatchDto-n1-update-targetDiscarded-error-validation.xml @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + ObServe :: Validation + %% + Copyright (C) 2008 - 2010 IRD, Codelutin, Tony Chemit + %% + 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% + --> + +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="species"> + + <!-- pas de species selectionnee --> + <field-validator type="required" short-circuit="true"> + <message>validator.targetDiscarded.required.species</message> + </field-validator> + + <!-- species desactive --> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ species.enabled ]]> + </param> + <message>validator.targetDiscarded.desactivated.species</message> + </field-validator> + + </field> + + <field name="weightCategory"> + + <!-- pas de categorie weight selectionnee --> + <field-validator type="required" short-circuit="true"> + <message>validator.targetDiscarded.required.weightCategory</message> + </field-validator> + + <!-- weightCategory desactive --> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ weightCategory.enabled ]]> + </param> + <message>validator.targetDiscarded.desactivated.weightCategory</message> + </field-validator> + + </field> + + <field name="reasonForDiscard"> + + <!-- pas de raison rejet selectionne --> + <field-validator type="required" short-circuit="true"> + <message>validator.targetDiscarded.required.reasonForDiscard</message> + </field-validator> + + <!-- reasonForDiscard desactive --> + <field-validator type="fieldexpression" short-circuit="true"> + <param name="expression"> + <![CDATA[ reasonForDiscard.enabled ]]> + </param> + <message>validator.targetDiscarded.desactivated.reasonForDiscard</message> + </field-validator> + + </field> + + <field name="comment"> + + <!-- comentaire de moins de 1024 caractères --> + <field-validator type="stringlength"> + <param name="maxLength">1024</param> + <message>validator.targetDiscarded.comment.tobig</message> + </field-validator> + + <!-- comment requis selon le raison rejet --> + + <field-validator type="fieldexpression"> + <param name="expression"> + <![CDATA[ (comment != null && !comment.empty) || reasonForDiscard == null || !reasonForDiscard.needComment ]]></param> + <message>validator.targetDiscarded.required.comment.for.reasonForDiscard</message> + </field-validator> + + </field> + +</validators> diff --git a/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-error-validation.xml b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/TargetCatchDto-n1-update-targetDiscarded-warning-validation.xml similarity index 62% rename from observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-error-validation.xml rename to observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/TargetCatchDto-n1-update-targetDiscarded-warning-validation.xml index f6d972a..47eff2d 100644 --- a/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/SetSeineTargetCatchDto-n1-update-error-validation.xml +++ b/observe-application-swing/src/main/resources/fr/ird/observe/services/dto/seine/TargetCatchDto-n1-update-targetDiscarded-warning-validation.xml @@ -7,15 +7,13 @@ %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the + published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.html>. #L% @@ -26,14 +24,20 @@ "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> <validators> - <field name="targetCatch"> + <field name="catchWeight"> - <!-- clef unique sur la categorie weight et well --> + <!-- weight non renseigné --> + <field-validator type="required" short-circuit="true"> + <message>validator.targetDiscarded.required.weight</message> + </field-validator> - <field-validator type="collectionFieldExpression"> - <param name="mode">UNIQUE_KEY</param> - <param name="keys">weightCategory.id,well</param> - <message>validator.targetCatch.uniqueKey</message> + <!-- weight entre 0 et 400 --> + <field-validator type="double" short-circuit="true"> + <param name="minExclusive">0</param> + <param name="maxInclusive">400</param> + <message> + validator.targetDiscarded.bound.weight##${minExclusive}##${maxInclusive} + </message> </field-validator> </field> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See http://git.codelutin.com/observe.git commit b247f3dc2b341a8fef649d72012d0dcefbe32954 Merge: a8b986e 40f8542 Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Tue Oct 20 15:53:50 2015 +0200 Merge branch 'feature/7605' into develop .../ui/content/table/impl/seine/TargetCatchUI.jaxx | 2 +- .../table/impl/seine/TargetCatchUIHandler.java | 6 +- .../table/impl/seine/TargetCatchUIModel.java | 1 + .../table/impl/seine/TargetDiscardCatchUI.jaxx | 15 +- .../impl/seine/TargetDiscardCatchUIHandler.java | 426 +++++++-------------- .../impl/seine/TargetDiscardCatchUIModel.java | 38 +- ...Dto-n1-update-targetCatch-error-validation.xml} | 0 ...n1-update-targetDiscarded-error-validation.xml} | 6 +- ...-n1-update-targetDiscarded-error-validation.xml | 98 +++++ ...-update-targetDiscarded-warning-validation.xml} | 24 +- .../v1/seine/TargetCatchServiceController.java | 8 +- .../ird/observe/entities/seine/TargetCatchs.java | 10 + .../services/service/seine/TargetCatchService.java | 4 +- .../src/main/xmi/observe-services-dto-seine.zargo | Bin 61190 -> 61271 bytes .../service/seine/TargetCatchServiceTopia.java | 66 +++- 15 files changed, 360 insertions(+), 344 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@list.forge.codelutin.com>.
participants (1)
-
codelutin.com scm