[tutti] branch develop updated (d7c0335 -> 284fe2f)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository tutti. See http://git.codelutin.com/tutti.git from d7c0335 fixes #5825: [CAPTURE] préciser intitulé d'une fenêtre new fb11091 refs #5411 [CAPTURE] Import BIGFIN new 3c37b63 refs #5411 [CAPTURE] Import BIGFIN new aa70ff2 refs #5411 [CAPTURE] Import BIGFIN new a930c6c refs #5411 [CAPTURE] Import BIGFIN new c5d1675 refs #5411 [CAPTURE] Import BIGFIN new 284fe2f fixes #5411 [CAPTURE] Import BIGFIN The 6 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 284fe2f9f7c18f1132637954af7d9c45a719ec21 Author: Kevin Morin <morin@codelutin.com> Date: Tue Sep 23 14:24:39 2014 +0200 fixes #5411 [CAPTURE] Import BIGFIN commit c5d1675e20130d1ad8801477519a9eacb3611506 Author: Kevin Morin <morin@codelutin.com> Date: Tue Sep 9 07:57:22 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN commit a930c6ccc85ba6d2dc3e2ece744905dc93ccbc4d Author: Kevin Morin <morin@codelutin.com> Date: Fri Sep 5 18:44:29 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN commit aa70ff22c2bd546e6528342281b170fb306c130b Author: Kevin Morin <morin@codelutin.com> Date: Wed Sep 3 17:49:38 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN commit 3c37b63abcce24f64a581dce47a4655fbdc35efc Author: Kevin Morin <morin@codelutin.com> Date: Wed Sep 3 16:55:06 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN commit fb11091ee74cb62e4f74ec971653ae23545bb173 Author: Kevin Morin <morin@codelutin.com> Date: Wed Sep 3 13:27:07 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN Summary of changes: .../persistence/entities/data/SpeciesBatchs.java | 21 + .../i18n/tutti-persistence_en_GB.properties | 24 + .../i18n/tutti-persistence_fr_FR.properties | 24 + .../fr/ifremer/tutti/service/TuttiCsvUtil.java | 4 + .../tutti/service/bigfin/BigfinDataRow.java | 106 ++++ .../tutti/service/bigfin/BigfinDataRowModel.java | 130 +++++ .../BigfinImportResult.java} | 44 +- .../tutti/service/bigfin/BigfinImportService.java | 611 +++++++++++++++++++++ .../tutti/service/{pupitri => bigfin}/Signs.java | 103 +++- .../resources/i18n/tutti-service_en_GB.properties | 15 + .../resources/i18n/tutti-service_fr_FR.properties | 10 + .../service/bigfin/BigfinImportServiceTest.java | 237 ++++++++ .../test/resources/bigfin/importbigfin-errors.csv | 4 + .../test/resources/bigfin/importbigfin-valid.csv | 36 ++ .../resources/bigfin/importbigfin-warnings.csv | 5 + .../{psion => bigfin}/protocol.tuttiProtocol | 1 - .../filtered-resources/tutti-help-fr.properties | 26 +- .../fr/ifremer/tutti/ui/swing/TuttiUIContext.java | 7 +- ...ortPsionAction.java => ImportBigfinAction.java} | 68 ++- .../tutti/ui/swing/action/ImportPsionAction.java | 6 +- .../operation/catches/species/SpeciesBatchUI.css | 9 + .../operation/catches/species/SpeciesBatchUI.jaxx | 1 + .../catches/species/SpeciesBatchUIHandler.java | 11 +- .../species/split/SplitSpeciesBatchUIHandler.java | 8 +- .../resources/i18n/tutti-ui-swing_en_GB.properties | 14 + .../resources/i18n/tutti-ui-swing_fr_FR.properties | 11 + ...-casino-import.png => action-bigfin-import.png} | Bin 27 files changed, 1426 insertions(+), 110 deletions(-) create mode 100644 tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SpeciesBatchs.java create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRow.java create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java copy tutti-service/src/main/java/fr/ifremer/tutti/service/{psionimport/PsionImportResult.java => bigfin/BigfinImportResult.java} (56%) create mode 100644 tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java copy tutti-service/src/main/java/fr/ifremer/tutti/service/{pupitri => bigfin}/Signs.java (64%) create mode 100644 tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java create mode 100644 tutti-service/src/test/resources/bigfin/importbigfin-errors.csv create mode 100644 tutti-service/src/test/resources/bigfin/importbigfin-valid.csv create mode 100644 tutti-service/src/test/resources/bigfin/importbigfin-warnings.csv copy tutti-service/src/test/resources/{psion => bigfin}/protocol.tuttiProtocol (99%) copy tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/{ImportPsionAction.java => ImportBigfinAction.java} (62%) copy tutti-ui-swing/src/main/resources/icons/{action-casino-import.png => action-bigfin-import.png} (100%) -- 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 tutti. See http://git.codelutin.com/tutti.git commit fb11091ee74cb62e4f74ec971653ae23545bb173 Author: Kevin Morin <morin@codelutin.com> Date: Wed Sep 3 13:27:07 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN --- .../fr/ifremer/tutti/service/TuttiCsvUtil.java | 4 + .../tutti/service/bigfin/BigfinDataRow.java | 96 ++++++ .../tutti/service/bigfin/BigfinDataRowModel.java | 122 ++++++++ .../tutti/service/bigfin/BigfinImportResult.java | 86 +++++ .../tutti/service/bigfin/BigfinImportService.java | 348 +++++++++++++++++++++ .../fr/ifremer/tutti/service/bigfin/Signs.java | 143 +++++++++ .../resources/i18n/tutti-service_en_GB.properties | 1 + .../resources/i18n/tutti-service_fr_FR.properties | 1 + .../filtered-resources/tutti-help-fr.properties | 26 +- .../fr/ifremer/tutti/ui/swing/TuttiUIContext.java | 7 +- ...ortPsionAction.java => ImportBigfinAction.java} | 57 ++-- .../tutti/ui/swing/action/ImportPsionAction.java | 6 +- .../operation/catches/species/SpeciesBatchUI.css | 9 + .../operation/catches/species/SpeciesBatchUI.jaxx | 1 + .../catches/species/SpeciesBatchUIHandler.java | 11 +- .../species/split/SplitSpeciesBatchUIHandler.java | 8 +- .../resources/i18n/tutti-ui-swing_en_GB.properties | 9 + .../resources/i18n/tutti-ui-swing_fr_FR.properties | 9 + .../main/resources/icons/action-bigfin-import.png | Bin 0 -> 532 bytes 19 files changed, 882 insertions(+), 62 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java index 31493f8..58f5556 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiCsvUtil.java @@ -838,6 +838,10 @@ public class TuttiCsvUtil extends Common { // no instance } + /** + * + * @param <M> + */ public static abstract class ImportModelWithHeader<M> extends AbstractTuttiImportModel<M> { protected ImportModelWithHeader(char separator) { diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRow.java new file mode 100644 index 0000000..111fe39 --- /dev/null +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRow.java @@ -0,0 +1,96 @@ +package fr.ifremer.tutti.service.bigfin; + +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; +import fr.ifremer.tutti.persistence.entities.referential.Species; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author Kevin Morin (Code Lutin) + * @since 3.8 + */ +public class BigfinDataRow implements Serializable { + + public static final String PROPERTY_RECORD_ID = "recordId"; + public static final String PROPERTY_LENGTH = "length"; + public static final String PROPERTY_WEIGHT = "weight"; + public static final String PROPERTY_SPECIES = "species"; + public static final String PROPERTY_STATION = "station"; + public static final String PROPERTY_DT = "dt"; + public static final String PROPERTY_SZ_CLASS = "szClass"; + public static final String PROPERTY_GENDER = "gender"; + + protected String recordId; + protected float length; + protected Float weight; + protected Species species; + protected Integer station; + protected Date dt; + protected Signs szClass; + protected Signs gender; + + public String getRecordId() { + return recordId; + } + + public void setRecordId(String recordId) { + this.recordId = recordId; + } + + public float getLength() { + return length; + } + + public void setLength(float length) { + this.length = length; + } + + public Float getWeight() { + return weight; + } + + public void setWeight(Float weight) { + this.weight = weight; + } + + public Species getSpecies() { + return species; + } + + public void setSpecies(Species species) { + this.species = species; + } + + public Integer getStation() { + return station; + } + + public void setStation(Integer station) { + this.station = station; + } + + public Date getDt() { + return dt; + } + + public void setDt(Date dt) { + this.dt = dt; + } + + public Signs getSzClass() { + return szClass; + } + + public void setSzClass(Signs szClass) { + this.szClass = szClass; + } + + public Signs getGender() { + return gender; + } + + public void setGender(Signs gender) { + this.gender = gender; + } +} diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java new file mode 100644 index 0000000..d16de6d --- /dev/null +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java @@ -0,0 +1,122 @@ +package fr.ifremer.tutti.service.bigfin; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; +import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.persistence.entities.referential.Speciess; +import fr.ifremer.tutti.service.TuttiCsvUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.nuiton.csv.Common; +import org.nuiton.csv.ImportRuntimeException; +import org.nuiton.csv.ValueParser; + +import java.text.ParseException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.nuiton.i18n.I18n.t; + +/** + * @author Kevin Morin (Code Lutin) + * @since 3.8 + */ +public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<BigfinDataRow> { + + public BigfinDataRowModel(char separator, + final Map<String, Species> speciesBySurveyCode) { + + super(separator); + + final Map<String, Species> foundSpecies = new HashMap<>(); + + newMandatoryColumn("length(mm)", BigfinDataRow.PROPERTY_LENGTH, Common.PRIMITIVE_FLOAT); + newMandatoryColumn("weight(g)", BigfinDataRow.PROPERTY_WEIGHT, Common.FLOAT); + +// code espèce = code campagne (saisie libre donc risque fort de mauvaise saisie) + newMandatoryColumn("species", BigfinDataRow.PROPERTY_SPECIES, new ValueParser<Object>() { + @Override + public Object parse(String value) throws ParseException { + Species result = null; + if (StringUtils.isNotBlank(value)) { + // if code already found + result = foundSpecies.get(value); + + //if not found, look for it in the survey codes + if (result == null) { + result = speciesBySurveyCode.get(value); + } + +// Si on ne trouve pas une espèce de code campagne XXXXXXX, on essaye alors avec le code XXXX-XXX et vice-versa. + if (result == null) { + String alternativeSpeciesCode = value; + int i = alternativeSpeciesCode.indexOf('-'); + if (i < 0) { + alternativeSpeciesCode = alternativeSpeciesCode.substring(0, 4) + + '-' + alternativeSpeciesCode.substring(4); + + } else { + alternativeSpeciesCode = alternativeSpeciesCode.substring(0, i) + alternativeSpeciesCode.substring(i + 1); + } + result = speciesBySurveyCode.get(alternativeSpeciesCode); + } + // record the code in the found codes + foundSpecies.put(value, result); + } + return result; + } + }); + +// n° de la station (non importé mais utile pour contrôle à l'import) + newMandatoryColumn("station", BigfinDataRow.PROPERTY_STATION, Common.INTEGER); +// date et heure de l'enregistrement (non importé mais utile pour contrôle à l'import) + newMandatoryColumn("Dt", BigfinDataRow.PROPERTY_DT, new Common.DateValue("MM/dd/yy HH:mm")); + +// sz class : si code différents de 0 1 ou 2 alors tout bloquer et donner l'id des lignes en anomalies + newMandatoryColumn("sz class", + BigfinDataRow.PROPERTY_SZ_CLASS, + new ValueParser<Signs>() { + @Override + public Signs parse(String value) throws ParseException { + Signs result = Signs.getSign(value.toUpperCase()); + if (result == null) { + throw new ParseException("Could not parse Sign value: " + value, 0); + } + return result; + } + }); + + newMandatoryColumn("gender", + BigfinDataRow.PROPERTY_GENDER, + new ValueParser<Signs>() { + @Override + public Signs parse(String value) throws ParseException { + Signs result = Signs.getSign(value.toUpperCase()); + if (result == null) { + throw new ParseException("Could not parse Sign value: " + value, 0); + } + return result; + } + }); + + newIgnoredColumn("Record_id"); + newIgnoredColumn("cruise"); + newIgnoredColumn("pan"); + newIgnoredColumn("text"); + } + + @Override + public BigfinDataRow newEmptyInstance() { + return new BigfinDataRow(); + } + +} diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java new file mode 100644 index 0000000..287650e --- /dev/null +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java @@ -0,0 +1,86 @@ +package fr.ifremer.tutti.service.bigfin; + +/* + * #%L + * Tutti :: Service + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * Created on 1/20/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 3.0.1 + */ +public class BigfinImportResult { + + protected final File importFile; + + protected final List<String> errors = new ArrayList<>(); + + protected int nbSortedImported; + + protected int nbUnsortedImported; + + public BigfinImportResult(File importFile) { + this.importFile = importFile; + } + + public File getImportFile() { + return importFile; + } + + public int getNbSortedImported() { + return nbSortedImported; + } + + public int getNbUnsortedImported() { + return nbUnsortedImported; + } + + public List<String> getErrors() { + return errors; + } + + void incrementNbSortedImported() { + this.nbSortedImported++; + } + + void incrementNbUnsortedImported() { + this.nbUnsortedImported++; + } + + void addError(String error) { + errors.add(error); + } + + void addErrors(List<String> errors) { + this.errors.addAll(errors); + } + + public boolean isDone() { + return errors.isEmpty(); + } +} diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java new file mode 100644 index 0000000..161e14b --- /dev/null +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java @@ -0,0 +1,348 @@ +package fr.ifremer.tutti.service.bigfin; + +import com.google.common.base.Charsets; +import com.google.common.base.Function; +import com.google.common.base.Preconditions; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; +import com.google.common.collect.Sets; +import com.google.common.io.Files; +import fr.ifremer.adagio.core.dao.referential.pmfm.ObjectTypeCode2; +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId; +import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; +import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId2; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.Attachment; +import fr.ifremer.tutti.persistence.entities.data.Attachments; +import fr.ifremer.tutti.persistence.entities.data.BatchContainer; +import fr.ifremer.tutti.persistence.entities.data.CatchBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchBean; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencyBean; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencys; +import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; +import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValues; +import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.service.AbstractTuttiService; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.service.TuttiServiceContext; +import fr.ifremer.tutti.service.psionimport.PsionImportResult; +import fr.ifremer.tutti.util.Weights; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.csv.Import; +import org.nuiton.csv.ImportRuntimeException; +import org.nuiton.jaxx.application.ApplicationBusinessException; + +import java.io.File; +import java.io.Reader; +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.nuiton.i18n.I18n.t; + +/** + * @author Kevin Morin (Code Lutin) + * @since 3.8 + */ +public class BigfinImportService extends AbstractTuttiService { + + private static final Log log = LogFactory.getLog(BigfinImportService.class); + + protected PersistenceService persistenceService; + + protected Map<Signs, CaracteristicQualitativeValue> signsToCaracteristicValue; + + protected Map<String, SpeciesProtocol> speciesProtocolBySurveyCode; + private CaracteristicQualitativeValue sortedCaracteristic; + + + @Override + public void setServiceContext(TuttiServiceContext context) { + super.setServiceContext(context); + persistenceService = getService(PersistenceService.class); + + signsToCaracteristicValue = Maps.newEnumMap(Signs.class); + + { // sorted/unsorted caracteristic + Caracteristic caracteristic = + persistenceService.getSortedUnsortedCaracteristic(); + + sortedCaracteristic = CaracteristicQualitativeValues.getQualitativeValue(caracteristic, QualitativeValueId.SORTED_VRAC.getValue()); + } + + { // size caracteristic + Caracteristic caracteristic = persistenceService.getSizeCategoryCaracteristic(); + Signs.NOT_SIZED.registerSign(caracteristic, signsToCaracteristicValue); + Signs.SMALL.registerSign(caracteristic, signsToCaracteristicValue); + Signs.BIG.registerSign(caracteristic, signsToCaracteristicValue); + } + + { // sex caracteristic + Caracteristic caracteristic = persistenceService.getSexCaracteristic(); + Signs.NOT_SEXED.registerSign(caracteristic, signsToCaracteristicValue); + Signs.MALE.registerSign(caracteristic, signsToCaracteristicValue); + Signs.FEMALE.registerSign(caracteristic, signsToCaracteristicValue); + } + + } + + public BigfinImportResult importFile(File bigfinFile, FishingOperation operation, CatchBatch catchBatch) { + + Preconditions.checkNotNull(bigfinFile); + Preconditions.checkArgument(bigfinFile.exists(), "Bigfin file " + bigfinFile + " does not exist."); + + TuttiProtocol protocol = persistenceService.getProtocol(); + + if (protocol == null) { + throw new ApplicationBusinessException(t("tutti.service.bigfinimport.error.no.protocol")); + } + + List<Species> allReferentSpecies = persistenceService.getAllReferentSpecies(); + List<Species> allSpeciesWithSurveyCode = persistenceService.getReferentSpeciesWithSurveyCode(allReferentSpecies); + + Map<String, Species> speciesBySurveyCode = Maps.newTreeMap(); + for (Species species : allSpeciesWithSurveyCode) { + String surveyCode = species.getSurveyCode(); + if (StringUtils.isNotBlank(surveyCode)) { + speciesBySurveyCode.put(surveyCode, species); + + } else { + speciesBySurveyCode.put(species.getRefTaxCode(), species); + } + } + speciesProtocolBySurveyCode = Maps.newTreeMap(); + + for (SpeciesProtocol speciesProtocol : protocol.getSpecies()) { + if (speciesProtocol.getSpeciesSurveyCode() != null) { + speciesProtocolBySurveyCode.put(speciesProtocol.getSpeciesSurveyCode(), speciesProtocol); + + } else { + speciesProtocolBySurveyCode.put(speciesProtocol.getSpeciesReferenceTaxonId().toString(), speciesProtocol); + } + + } + + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); + Set<Species> alreadyUsedSpecies = Sets.newHashSet(); + for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) { + alreadyUsedSpecies.add(speciesBatch.getSpecies()); + } + + Set<Species> speciesNotrecognized = new HashSet<>(); + Set<Species> speciesInProtocolButWithoutLengthStepPmfmId = new HashSet<>(); + + List<BigfinDataRow> rows = new ArrayList<>(); + // load model + BigfinDataRowModel importModel = new BigfinDataRowModel(';', speciesBySurveyCode); + Reader reader = null; + Import<BigfinDataRow> importer = null; + try { + reader = Files.newReader(bigfinFile, Charsets.UTF_8); + importer = Import.newImport(importModel, reader); + + for (BigfinDataRow bean : importer) { + + Species species = bean.getSpecies(); + + // check if the station is the one of the operation + // and do not check again a species that has not been recognized before + Integer station = bean.getStation(); + Date dt = bean.getDt(); + if (station != null && station.toString().equals(operation.getStationNumber()) + && dt != null && dt.after(operation.getGearShootingStartDate()) && dt.before(operation.getGearShootingEndDate())) { + + if (species == null) { +// bloquer tout si un "species" ne match pas le référentiel de Tutti : lister dans ce cas les codes non reconnus + speciesNotrecognized.add(species); + + } else { +// bloquer toute espèce reconnue du protocole mais qui n'a pas de méthode de mesure + SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(species.getSurveyCode()); + if (speciesProtocol != null && speciesProtocol.getLengthStepPmfmId() == null) { + speciesInProtocolButWithoutLengthStepPmfmId.add(species); + + } else if (alreadyUsedSpecies.contains(species)) { + // TODO on fait quoi ? + + } else { + rows.add(bean); + } + } + } + } + + } catch (ImportRuntimeException e) { + throw e; + + } catch (Exception e) { + throw new ImportRuntimeException("Could not import bigfin data from file " + bigfinFile, e); + + } finally { + IOUtils.closeQuietly(importer); + IOUtils.closeQuietly(reader); + } + + BigfinImportResult result = new BigfinImportResult(bigfinFile); + + if (!speciesInProtocolButWithoutLengthStepPmfmId.isEmpty() || !speciesNotrecognized.isEmpty()) { + //TODO kmorin 20140901 return errors + + + } else { + Multimap<Species, BigfinDataRow> rowsBySpecies = Multimaps.index(rows, new Function<BigfinDataRow, Species>() { + @Override + public Species apply(BigfinDataRow bigfinDataRow) { + return bigfinDataRow.getSpecies(); + } + }); + + for (Species species : rowsBySpecies.keySet()) { + + SpeciesBatch batch = new SpeciesBatchBean(); + batch.setSpecies(species); + batch.setFishingOperation(operation); + //TODO check in text if hv + batch.setSampleCategoryId(PmfmId.SORTED_UNSORTED.getValue()); + batch.setSampleCategoryValue(sortedCaracteristic); + + batch = persistenceService.createSpeciesBatch(batch, null); + + // new sorted batch imported + result.incrementNbSortedImported(); + + Collection<BigfinDataRow> speciesRows = rowsBySpecies.get(species); + Multimap<CaracteristicQualitativeValue, BigfinDataRow> rowsBySize = + Multimaps.index(speciesRows, new Function<BigfinDataRow, CaracteristicQualitativeValue>() { + @Override + public CaracteristicQualitativeValue apply(BigfinDataRow bigfinDataRow) { + CaracteristicQualitativeValue result = signsToCaracteristicValue.get(bigfinDataRow.getSzClass()); + return result; + } + }); + + for (CaracteristicQualitativeValue size : rowsBySize.keySet()) { + SpeciesBatch sizeBatch = new SpeciesBatchBean(); + sizeBatch.setSpecies(species); + sizeBatch.setFishingOperation(operation); + sizeBatch.setSampleCategoryId(PmfmId.SIZE_CATEGORY.getValue()); + sizeBatch.setSampleCategoryValue(size); + sizeBatch = persistenceService.createSpeciesBatch(sizeBatch, batch.getId()); + + Collection<BigfinDataRow> sizeRows = rowsBySize.get(size); + Multimap<CaracteristicQualitativeValue, BigfinDataRow> rowsByGender = + Multimaps.index(sizeRows, new Function<BigfinDataRow, CaracteristicQualitativeValue>() { + @Override + public CaracteristicQualitativeValue apply(BigfinDataRow bigfinDataRow) { + CaracteristicQualitativeValue result = signsToCaracteristicValue.get(bigfinDataRow.getGender()); + return result; + } + }); + for (CaracteristicQualitativeValue gender : rowsByGender.keySet()) { + Collection<BigfinDataRow> bigfinDataRows = rowsByGender.get(gender); + SpeciesBatch genderBatch = new SpeciesBatchBean(); + genderBatch.setSpecies(species); + genderBatch.setFishingOperation(operation); + genderBatch.setSampleCategoryId(PmfmId.SEX.getValue()); + genderBatch.setSampleCategoryValue(gender); + + genderBatch = persistenceService.createSpeciesBatch(genderBatch, sizeBatch.getId()); + + List<SpeciesBatchFrequency> frequencies = createFrequencies(genderBatch, bigfinDataRows); + persistenceService.saveSpeciesBatchFrequency(genderBatch.getId(), frequencies); + + } + } + } + } + + addFileAsAttachment(bigfinFile, catchBatch); + + return result; + } + + protected List<SpeciesBatchFrequency> createFrequencies(SpeciesBatch batch, Collection<BigfinDataRow> rows) { + SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(batch.getSpecies().getSurveyCode()); + Caracteristic lengthStepPmfm = persistenceService.getCaracteristic(Integer.parseInt(speciesProtocol.getLengthStepPmfmId())); + //TODO on fait quoi si c'est nul? + String unit = lengthStepPmfm.getUnit(); + Float precision = lengthStepPmfm.getPrecision(); + if (precision == null) { + precision = 1f; + } + + // board measurements are in mm + + ListMultimap<Float, Float> weightsByLengthStep = ArrayListMultimap.create(); + for (BigfinDataRow row : rows) { + Float weight = row.getWeight(); + float length = row.getLength(); + + if ("cm".equals(unit)) { + // measurement in cm asked + length = length / 10; + } + + int intValue = (int) (length * 10); + int intStep = (int) (precision * 10); + int correctIntStep = intValue - (intValue % intStep); + float lengthStep = correctIntStep / 10f; + + weightsByLengthStep.put(lengthStep, weight); + } + + List<SpeciesBatchFrequency> frequencies = new ArrayList<>(); + for (Float lengthStep : weightsByLengthStep.keySet()) { + SpeciesBatchFrequency frequency = SpeciesBatchFrequencys.newSpeciesBatchFrequency(); + frequencies.add(frequency); + + frequency.setBatch(batch); + frequency.setLengthStep(lengthStep); + frequency.setLengthStepCaracteristic(lengthStepPmfm); + + Collection<Float> weights = weightsByLengthStep.get(lengthStep); + frequency.setNumber(weights.size()); + + Float totalWeight = 0f; + for (Float weight : weights) { + if (weight != null) { + totalWeight += weight; + } + } + // convert grams to kilograms + totalWeight = Weights.roundKiloGram(totalWeight / 1000); + frequency.setWeight(totalWeight); + } + return frequencies; + } + + protected void addFileAsAttachment(File f, CatchBatch catchBatch) { + Attachment attachment = Attachments.newAttachment(); + attachment.setObjectType(ObjectTypeCode2.CATCH_BATCH); + attachment.setObjectId(Integer.valueOf(catchBatch.getId())); + attachment.setName(f.getName()); + String date = DateFormat.getDateTimeInstance().format(context.currentDate()); + String comment = t("tutti.service.bigfin.import.attachment.comment", date); + attachment.setComment(comment); + persistenceService.createAttachment(attachment, f); + } +} diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java new file mode 100644 index 0000000..524884d --- /dev/null +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java @@ -0,0 +1,143 @@ +package fr.ifremer.tutti.service.bigfin; + +/* + * #%L + * Tutti :: Service + * %% + * Copyright (C) 2012 - 2014 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; +import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; +import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId2; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; +import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValues; + +import java.util.Map; + +/** + * Created on 5/14/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 3.4.2 + */ +public enum Signs { + + // sexe, M= mâle ; F = femelle ; not set = non sexé + NOT_SEXED("NOT SET") { + @Override + public Integer getCategory() { + return PmfmId2.SEX.getValue(); + } + + @Override + public Integer getQualitativeValueId() { + return QualitativeValueId2.SEX_UNDEFINED.getValue(); + } + }, + MALE("M") { + @Override + public Integer getCategory() { + return PmfmId2.SEX.getValue(); + } + + @Override + public Integer getQualitativeValueId() { + return QualitativeValueId.SEX_MALE.getValue(); + } + }, + FEMALE("F") { + @Override + public Integer getCategory() { + return PmfmId2.SEX.getValue(); + } + + @Override + public Integer getQualitativeValueId() { + return QualitativeValueId.SEX_FEMALE.getValue(); + } + }, + +// classe de taille, 1 = petit ; 2 = gros ; 0 = pas de classe de taille (saisie libre donc risque fort de mauvaise saisie) + NOT_SIZED("0") { + @Override + public Integer getCategory() { + return PmfmId2.SIZE_CATEGORY.getValue(); + } + + @Override + public Integer getQualitativeValueId() { + return QualitativeValueId2.NOT_SIZED.getValue(); + } + }, + SMALL("1") { + @Override + public Integer getCategory() { + return PmfmId2.SIZE_CATEGORY.getValue(); + } + + @Override + public Integer getQualitativeValueId() { + return QualitativeValueId.SIZE_SMALL.getValue(); + } + }, + BIG("2") { + @Override + public Integer getCategory() { + return PmfmId2.SIZE_CATEGORY.getValue(); + } + + @Override + public Integer getQualitativeValueId() { + return QualitativeValueId.SIZE_BIG.getValue(); + } + }; + + private String sign; + + Signs(String sign) { + this.sign = sign; + } + + public String getSign() { + return sign; + } + + public static Signs getSign(String sign) { + Signs result = null; + for (Signs s : values()) { + if (s.sign.equals(sign)) { + result = s; + break; + } + } + return result; + } + + public abstract Integer getCategory(); + + public abstract Integer getQualitativeValueId(); + + public void registerSign(Caracteristic caracteristic, + Map<Signs, CaracteristicQualitativeValue> map) { + Integer valueId = getQualitativeValueId(); + CaracteristicQualitativeValue result = CaracteristicQualitativeValues.getQualitativeValue(caracteristic, valueId); + map.put(this, result); + } +} diff --git a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties index 60a31ec..7b41d9c 100644 --- a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties +++ b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties @@ -46,6 +46,7 @@ tutti.report.step.export.fishingOperation= tutti.report.step.generateReport= tutti.report.step.load.fishingOperation= tutti.service.arp.import.attachment.comment= +tutti.service.bigfinimport.error.no.protocol= tutti.service.compressZipFile.error= tutti.service.context.serviceInstanciation.error= tutti.service.csv.parse.entityNotFound= diff --git a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties index 1cea1ff..beaca46 100644 --- a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties +++ b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties @@ -43,6 +43,7 @@ tutti.propety.vessel.nation.registrationCode=%s (nat.) tutti.report.step.export.fishingOperation=Exporter le trait sélectionné tutti.report.step.generateReport=Générer le rapport tutti.report.step.load.fishingOperation=Charger le trait sélectionné +tutti.service.bigfinimport.error.no.protocol= tutti.service.compressZipFile.error=Erreur lors de la compression du dossier %1s dans le fichier %2s tutti.service.context.serviceInstanciation.error=Erreur lors de l'instanciation du service %s tutti.service.csv.parse.entityNotFound=L'entité de type %1s avec la propriété %2s de valeur %3s n'a pas été trouvée diff --git a/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties b/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties index f17b3dc..1ea1e8f 100644 --- a/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties +++ b/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties @@ -1,28 +1,5 @@ -### -# #%L -# Tutti :: UI -# $Id:$ -# $HeadURL:$ -# %% -# Copyright (C) 2012 - 2014 Ifremer -# %% -# 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% -### #Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo -#Thu Jul 10 09:24:16 CEST 2014 +#Tue Sep 02 15:54:43 CEST 2014 tutti.config.help=config.html tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions tutti.createAccidentalBatch.action.saveAndClose.help=editFishingOperation.html\#captureCapturesAccidentellesActions @@ -283,6 +260,7 @@ tutti.editSpeciesBatch.action.createBatch.help=editFishingOperation.html\#captur tutti.editSpeciesBatch.action.createMelag.help=editFishingOperation.html\#captureEspecesActions tutti.editSpeciesBatch.action.editFrequencies.help=editFishingOperation.html\#captureEspecesActions tutti.editSpeciesBatch.action.exportMultiPost.help=editFishingOperation.html\#captureEspecesActions +tutti.editSpeciesBatch.action.importBigfin.help=editFishingOperation.html\#captureEspecesActions tutti.editSpeciesBatch.action.importMultiPost.help=editFishingOperation.html\#captureEspecesActions tutti.editSpeciesBatch.action.importPsion.help=editFishingOperation.html\#captureEspecesActions tutti.editSpeciesBatch.action.importPupitri.help=editFishingOperation.html\#captureEspecesActions diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java index 53a26f2..06c5917 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java @@ -33,6 +33,7 @@ import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.TuttiDataContext; import fr.ifremer.tutti.service.TuttiServiceContext; import fr.ifremer.tutti.service.ValidationService; +import fr.ifremer.tutti.service.bigfin.BigfinImportService; import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService; import fr.ifremer.tutti.service.catches.WeightCleaningService; import fr.ifremer.tutti.service.catches.WeightComputingService; @@ -667,10 +668,14 @@ public class TuttiUIContext extends AbstractBean implements Closeable, UIMessage return serviceContext.getService(PupitriImportExportService.class); } - public PsionImportService getTuttiPsionImportExportService() { + public PsionImportService getTuttiPsionImportService() { return serviceContext.getService(PsionImportService.class); } + public BigfinImportService getTuttiBigfinImportService() { + return serviceContext.getService(BigfinImportService.class); + } + public ReferentialImportExportService getTuttiReferentialImportExportService() { return serviceContext.getService(ReferentialImportExportService.class); } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java similarity index 67% copy from tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java copy to tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java index ca6afc0..729da55 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java @@ -22,11 +22,19 @@ package fr.ifremer.tutti.ui.swing.action; * #L% */ +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.service.bigfin.BigfinImportResult; +import fr.ifremer.tutti.service.bigfin.BigfinImportService; import fr.ifremer.tutti.service.psionimport.PsionImportResult; import fr.ifremer.tutti.service.psionimport.PsionImportService; +import fr.ifremer.tutti.service.pupitri.PupitriImportExportService; +import fr.ifremer.tutti.service.pupitri.PupitriImportResult; import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; @@ -34,35 +42,34 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.species.ImportPupitri import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; +import javax.swing.*; import java.io.File; +import java.util.List; import static org.nuiton.i18n.I18n.t; /** - * Created on 1/21/14. - * - * @author Tony Chemit <chemit@codelutin.com> - * @since 3.1 + * @author tchemit <chemit@codelutin.com> + * @since 1.0 */ -public class ImportPsionAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> { +public class ImportBigfinAction extends AbstractTuttiAction<SpeciesBatchUIModel, SpeciesBatchUI, SpeciesBatchUIHandler> { - protected File importedTrunkFile; - - protected ImportPupitriPopupUI importPupitriDialog; + protected File importedBigfinFile; protected PersistenceService persistenceService; protected EditFishingOperationAction editAction; - protected PsionImportResult importResult; + protected BigfinImportResult importResult; - public ImportPsionAction(SpeciesBatchUIHandler handler) { + public ImportBigfinAction(SpeciesBatchUIHandler handler) { super(handler, false); persistenceService = getContext().getPersistenceService(); - importPupitriDialog = new ImportPupitriPopupUI(handler.getContext()); } + public EditFishingOperationAction getEditAction() { if (editAction == null) { FishingOperationsUI parentContainer = handler.getParentContainer(FishingOperationsUI.class); @@ -78,19 +85,19 @@ public class ImportPsionAction extends AbstractTuttiAction<SpeciesBatchUIModel, if (result) { // choose file to import - importedTrunkFile = chooseFile( - t("tutti.editSpeciesBatch.action.title.choose.importPsionFile"), - t("tutti.editSpeciesBatch.action.choosePsionFile.import"), - "^.*\\.IWA", t("tutti.common.file.iwa")); + importedBigfinFile = chooseFile( + t("tutti.editSpeciesBatch.action.title.choose.importBigfinFile"), + t("tutti.editSpeciesBatch.action.chooseBigfinFile.import"), + "^.*\\.csv", t("tutti.common.file.csv")); - result = importedTrunkFile != null; + result = importedBigfinFile != null; } return result; } @Override public void doAction() throws Exception { - PsionImportService importService = getContext().getTuttiPsionImportExportService(); + BigfinImportService importService = getContext().getTuttiBigfinImportService(); EditCatchesUI parentContainer = handler.getParentContainer(EditCatchesUI.class); EditCatchesUIModel model = parentContainer.getModel(); @@ -99,9 +106,7 @@ public class ImportPsionAction extends AbstractTuttiAction<SpeciesBatchUIModel, CatchBatch catchBatch = model.toEntity(); // import - importResult = importService.importFile(importedTrunkFile, - operation, - catchBatch); + importResult = importService.importFile(importedBigfinFile, operation, catchBatch); if (importResult.isDone()) { @@ -113,7 +118,7 @@ public class ImportPsionAction extends AbstractTuttiAction<SpeciesBatchUIModel, @Override public void releaseAction() { super.releaseAction(); - importedTrunkFile = null; + importedBigfinFile = null; } @Override @@ -122,7 +127,7 @@ public class ImportPsionAction extends AbstractTuttiAction<SpeciesBatchUIModel, if (importResult.isDone()) { - sendMessage(t("tutti.editSpeciesBatch.action.importPsion.success", + sendMessage(t("tutti.editSpeciesBatch.action.importBigfin.success", importResult.getNbSortedImported(), importResult.getNbUnsortedImported())); } else { @@ -131,12 +136,12 @@ public class ImportPsionAction extends AbstractTuttiAction<SpeciesBatchUIModel, sb.append("<li>").append(s).append("</li>"); } displayWarningMessage( - t("tutti.editSpeciesBatch.action.importPsion.no.matching.fishingOperation.title"), + t("tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation.title"), "<html><body>" + - t("tutti.editSpeciesBatch.action.importPsion.no.matching.fishingOperation", sb.toString()) + - "</body></html>" + t("tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation", sb.toString()) + + "</body></html>" ); - sendMessage(t("tutti.editSpeciesBatch.action.importPsion.no.matching.data")); + sendMessage(t("tutti.editSpeciesBatch.action.importBigfin.no.matching.data")); } } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java index ca6afc0..230d3e5 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportPsionAction.java @@ -30,7 +30,6 @@ import fr.ifremer.tutti.service.psionimport.PsionImportService; import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.ImportPupitriPopupUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; @@ -49,8 +48,6 @@ public class ImportPsionAction extends AbstractTuttiAction<SpeciesBatchUIModel, protected File importedTrunkFile; - protected ImportPupitriPopupUI importPupitriDialog; - protected PersistenceService persistenceService; protected EditFishingOperationAction editAction; @@ -60,7 +57,6 @@ public class ImportPsionAction extends AbstractTuttiAction<SpeciesBatchUIModel, public ImportPsionAction(SpeciesBatchUIHandler handler) { super(handler, false); persistenceService = getContext().getPersistenceService(); - importPupitriDialog = new ImportPupitriPopupUI(handler.getContext()); } public EditFishingOperationAction getEditAction() { @@ -90,7 +86,7 @@ public class ImportPsionAction extends AbstractTuttiAction<SpeciesBatchUIModel, @Override public void doAction() throws Exception { - PsionImportService importService = getContext().getTuttiPsionImportExportService(); + PsionImportService importService = getContext().getTuttiPsionImportService(); EditCatchesUI parentContainer = handler.getParentContainer(EditCatchesUI.class); EditCatchesUIModel model = parentContainer.getModel(); diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css index 1cb7d30..a8652cf 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css @@ -259,6 +259,15 @@ ComputableDataEditor { _help: {"tutti.editSpeciesBatch.action.importPsion.help"}; } +#importBigfinButton { + actionIcon: bigfin-import; + text: "tutti.editSpeciesBatch.action.importBigfin"; + toolTipText: "tutti.editSpeciesBatch.action.importBigfin.tip"; + i18nMnemonic: "tutti.editSpeciesBatch.action.importBigfin.mnemonic"; + _applicationAction: {fr.ifremer.tutti.ui.swing.action.ImportBigfinAction.class}; + _help: {"tutti.editSpeciesBatch.action.importBigfin.help"}; +} + #importMultiPostButton { actionIcon: import; text: "tutti.editSpeciesBatch.action.importMultiPost"; diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx index 56ce50c..22cef02 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx @@ -60,6 +60,7 @@ public SpeciesBatchUI(TuttiUI<?,?> parentUI) { <JToolBar id='speciesBatchTabToolBar'> <JButton id='importPupitriButton'/> <JButton id='importPsionButton'/> + <JButton id='importBigfinButton'/> <JButton id='importMultiPostButton'/> <JButton id='exportMultiPostButton'/> </JToolBar> diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java index 13bfa76..469b18e 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java @@ -209,11 +209,12 @@ public class SpeciesBatchUIHandler extends AbstractTuttiBatchTableUIHandler<Spec SpeciesBatchRowModel rootRow = loadBatch(aBatch, null, rows); - if (log.isDebugEnabled()) { - log.debug("Loaded root batch " + - decorate(rootRow.getSpecies(), DecoratorService.FROM_PROTOCOL) + " - " + - decorate(rootRow.getSampleCategoryById(firstCategoryId))); - } + //FIXME kmorin 20140902 NPE decorator does not exist +// if (log.isDebugEnabled()) { +// log.debug("Loaded root batch " + +// decorate(rootRow.getSpecies(), DecoratorService.FROM_PROTOCOL) + " - " + +// decorate(rootRow.getSampleCategoryById(firstCategoryId))); +// } } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java index 30eb7d1..81f326a 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java @@ -431,12 +431,17 @@ public class SplitSpeciesBatchUIHandler } boolean editableCategoryValue = false; - if (category != null) { + log.debug("category " + category); + if (category != null) { + log.debug("category " + category.getLabel()); if (!category.getCaracteristic().isQualitativeValueEmpty()) { // qualitative category data = category.getCaracteristic(); + + log.debug("data " + data); + } else { editableCategoryValue = true; addFloatColumnToModel(columnModel, @@ -493,6 +498,7 @@ public class SplitSpeciesBatchUIHandler // add a row for each qualitative value for (CaracteristicQualitativeValue qualitativeValue : data.getQualitativeValue()) { + log.debug("QV: " + qualitativeValue); if (log.isDebugEnabled()) { log.debug("Add QV: " + qualitativeValue); } diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties index 07bca9e..a99239a 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties @@ -973,6 +973,7 @@ tutti.editSpeciesBatch.action.addSampleCategory.tip= tutti.editSpeciesBatch.action.changeSampleCategory= tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic= tutti.editSpeciesBatch.action.changeSampleCategory.tip= +tutti.editSpeciesBatch.action.chooseBigfinFile.import= tutti.editSpeciesBatch.action.choosePsionFile.import= tutti.editSpeciesBatch.action.createBatch= tutti.editSpeciesBatch.action.createBatch.mnemonic= @@ -992,6 +993,13 @@ tutti.editSpeciesBatch.action.exportMultiPost.tip= tutti.editSpeciesBatch.action.ichtyometer= tutti.editSpeciesBatch.action.ichtyometer.mnemonic= tutti.editSpeciesBatch.action.ichtyometer.tip= +tutti.editSpeciesBatch.action.importBigfin= +tutti.editSpeciesBatch.action.importBigfin.mnemonic= +tutti.editSpeciesBatch.action.importBigfin.no.matching.data= +tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation= +tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation.title= +tutti.editSpeciesBatch.action.importBigfin.success= +tutti.editSpeciesBatch.action.importBigfin.tip= tutti.editSpeciesBatch.action.importMultiPost= tutti.editSpeciesBatch.action.importMultiPost.mnemonic= tutti.editSpeciesBatch.action.importMultiPost.sourceFile.button= @@ -1038,6 +1046,7 @@ tutti.editSpeciesBatch.action.renameBatch.tip= tutti.editSpeciesBatch.action.splitBatch= tutti.editSpeciesBatch.action.splitBatch.mnemonic= tutti.editSpeciesBatch.action.splitBatch.tip= +tutti.editSpeciesBatch.action.title.choose.importBigfinFile= tutti.editSpeciesBatch.action.title.choose.importPsionFile= tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable= tutti.editSpeciesBatch.field.speciesTotalInertWeight= diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties index 5e039d0..34edbdc 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties @@ -960,6 +960,7 @@ tutti.editSpeciesBatch.action.addSampleCategory.tip=Ajouter une catégorie manqu tutti.editSpeciesBatch.action.changeSampleCategory=Modifier la catégorie tutti.editSpeciesBatch.action.changeSampleCategory.mnemonic=M tutti.editSpeciesBatch.action.changeSampleCategory.tip=Modifier la catégorie de la cellule sélectionnée +tutti.editSpeciesBatch.action.chooseBigfinFile.import=Importer tutti.editSpeciesBatch.action.choosePsionFile.import=Importer tutti.editSpeciesBatch.action.createBatch=Créer un lot pour une espèce tutti.editSpeciesBatch.action.createBatch.mnemonic=C @@ -976,6 +977,13 @@ tutti.editSpeciesBatch.action.exportMultiPost.destinationFile.title=Exporter les tutti.editSpeciesBatch.action.exportMultiPost.mnemonic=E tutti.editSpeciesBatch.action.exportMultiPost.success=Les lots d'espèces ont été exportés dans le fichier %s tutti.editSpeciesBatch.action.exportMultiPost.tip=Exporter les lots d'espèces pour les importer sur le poste maître +tutti.editSpeciesBatch.action.importBigfin=Import Bigfin +tutti.editSpeciesBatch.action.importBigfin.mnemonic=B +tutti.editSpeciesBatch.action.importBigfin.no.matching.data= +tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation= +tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation.title= +tutti.editSpeciesBatch.action.importBigfin.success=Import Bigfin réussi \: %1s espèces importées (Vrac), %2s espèces importées (Hors-Vrac) +tutti.editSpeciesBatch.action.importBigfin.tip=Import Bigfin tutti.editSpeciesBatch.action.importMultiPost=Importer des lots d'espèces tutti.editSpeciesBatch.action.importMultiPost.mnemonic=I tutti.editSpeciesBatch.action.importMultiPost.sourceFile.button=Choisir le fichier à importer @@ -1022,6 +1030,7 @@ tutti.editSpeciesBatch.action.renameBatch.tip=Corriger l'espèce tutti.editSpeciesBatch.action.splitBatch=Catégoriser le lot tutti.editSpeciesBatch.action.splitBatch.mnemonic=C tutti.editSpeciesBatch.action.splitBatch.tip=Catégoriser le lot courant (celui de la ligne sélectionné) +tutti.editSpeciesBatch.action.title.choose.importBigfinFile=Importer un fichier Bigfin tutti.editSpeciesBatch.action.title.choose.importPsionFile=Importer un fichier Psion tutti.editSpeciesBatch.error.sampleCategoryValue.notAvailable=La valeur %s de la catégorie %s est déjà utilisée tutti.editSpeciesBatch.field.speciesTotalInertWeight=Poids inerte trié diff --git a/tutti-ui-swing/src/main/resources/icons/action-bigfin-import.png b/tutti-ui-swing/src/main/resources/icons/action-bigfin-import.png new file mode 100644 index 0000000..cafac61 Binary files /dev/null and b/tutti-ui-swing/src/main/resources/icons/action-bigfin-import.png differ -- 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 tutti. See http://git.codelutin.com/tutti.git commit 3c37b63abcce24f64a581dce47a4655fbdc35efc Author: Kevin Morin <morin@codelutin.com> Date: Wed Sep 3 16:55:06 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN --- .../tutti/service/bigfin/BigfinDataRowModel.java | 10 +- .../tutti/service/bigfin/BigfinImportService.java | 130 ++++++++++++++------- .../resources/i18n/tutti-service_en_GB.properties | 4 + .../resources/i18n/tutti-service_fr_FR.properties | 6 +- .../resources/i18n/tutti-ui-swing_fr_FR.properties | 6 +- 5 files changed, 104 insertions(+), 52 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java index d16de6d..dd592e6 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java @@ -39,6 +39,7 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi final Map<String, Species> foundSpecies = new HashMap<>(); + newMandatoryColumn("Record_id", BigfinDataRow.PROPERTY_RECORD_ID); newMandatoryColumn("length(mm)", BigfinDataRow.PROPERTY_LENGTH, Common.PRIMITIVE_FLOAT); newMandatoryColumn("weight(g)", BigfinDataRow.PROPERTY_WEIGHT, Common.FLOAT); @@ -72,6 +73,11 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi // record the code in the found codes foundSpecies.put(value, result); } + // if the species is not found, create a new one with the value in external code + if (result == null) { + result = Speciess.newSpecies(); + result.setExternalCode(value); + } return result; } }); @@ -88,9 +94,6 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi @Override public Signs parse(String value) throws ParseException { Signs result = Signs.getSign(value.toUpperCase()); - if (result == null) { - throw new ParseException("Could not parse Sign value: " + value, 0); - } return result; } }); @@ -108,7 +111,6 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi } }); - newIgnoredColumn("Record_id"); newIgnoredColumn("cruise"); newIgnoredColumn("pan"); newIgnoredColumn("text"); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java index 161e14b..7f18157 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java @@ -27,6 +27,7 @@ import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchBean; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencyBean; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencys; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchs; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; @@ -34,6 +35,7 @@ import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativ import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValues; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.service.AbstractTuttiService; +import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.TuttiServiceContext; import fr.ifremer.tutti.service.psionimport.PsionImportResult; @@ -48,6 +50,7 @@ import org.nuiton.jaxx.application.ApplicationBusinessException; import java.io.File; import java.io.Reader; +import java.io.Serializable; import java.text.DateFormat; import java.util.ArrayList; import java.util.Collection; @@ -148,10 +151,14 @@ public class BigfinImportService extends AbstractTuttiService { alreadyUsedSpecies.add(speciesBatch.getSpecies()); } - Set<Species> speciesNotrecognized = new HashSet<>(); + // set of not found species already added in the errors + Set<Species> speciesNotRecognized = new HashSet<>(); + // set of species without lengthstep alreay added in the errors Set<Species> speciesInProtocolButWithoutLengthStepPmfmId = new HashSet<>(); List<BigfinDataRow> rows = new ArrayList<>(); + BigfinImportResult result = new BigfinImportResult(bigfinFile); + // load model BigfinDataRowModel importModel = new BigfinDataRowModel(';', speciesBySurveyCode); Reader reader = null; @@ -171,15 +178,37 @@ public class BigfinImportService extends AbstractTuttiService { if (station != null && station.toString().equals(operation.getStationNumber()) && dt != null && dt.after(operation.getGearShootingStartDate()) && dt.before(operation.getGearShootingEndDate())) { - if (species == null) { + if (bean.getSzClass() == null) { + String error = t("tutti.service.bigfinImport.error.szClass.unknwon", bean.getRecordId()); + if (log.isWarnEnabled()) { + log.warn(error); + } + result.addError(error); + } + if (species == null || species.getId() == null) { // bloquer tout si un "species" ne match pas le référentiel de Tutti : lister dans ce cas les codes non reconnus - speciesNotrecognized.add(species); + if (speciesNotRecognized.add(species)) { + String error = t("tutti.service.bigfinImport.error.species.not.found", species.getExternalCode()); + if (log.isWarnEnabled()) { + log.warn(error); + } + result.addError(error); + } } else { // bloquer toute espèce reconnue du protocole mais qui n'a pas de méthode de mesure - SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(species.getSurveyCode()); - if (speciesProtocol != null && speciesProtocol.getLengthStepPmfmId() == null) { - speciesInProtocolButWithoutLengthStepPmfmId.add(species); + String code = species.getSurveyCode(); + if (code == null) { + code = species.getReferenceTaxonId().toString(); + } + SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(code); + if (speciesProtocol != null && speciesProtocol.getLengthStepPmfmId() == null + && speciesInProtocolButWithoutLengthStepPmfmId.add(species)) { + String error = t("tutti.service.bigfinImport.error.species.without.lengthstep", code); + if (log.isWarnEnabled()) { + log.warn(error); + } + result.addError(error); } else if (alreadyUsedSpecies.contains(species)) { // TODO on fait quoi ? @@ -202,13 +231,7 @@ public class BigfinImportService extends AbstractTuttiService { IOUtils.closeQuietly(reader); } - BigfinImportResult result = new BigfinImportResult(bigfinFile); - - if (!speciesInProtocolButWithoutLengthStepPmfmId.isEmpty() || !speciesNotrecognized.isEmpty()) { - //TODO kmorin 20140901 return errors - - - } else { + if (result.isDone()) { Multimap<Species, BigfinDataRow> rowsBySpecies = Multimaps.index(rows, new Function<BigfinDataRow, Species>() { @Override public Species apply(BigfinDataRow bigfinDataRow) { @@ -217,19 +240,22 @@ public class BigfinImportService extends AbstractTuttiService { }); for (Species species : rowsBySpecies.keySet()) { - - SpeciesBatch batch = new SpeciesBatchBean(); - batch.setSpecies(species); - batch.setFishingOperation(operation); - //TODO check in text if hv - batch.setSampleCategoryId(PmfmId.SORTED_UNSORTED.getValue()); - batch.setSampleCategoryValue(sortedCaracteristic); - - batch = persistenceService.createSpeciesBatch(batch, null); + SpeciesBatch batch = createSpeciesBatch(species, + operation, + PmfmId.SORTED_UNSORTED.getValue(), + sortedCaracteristic, + null); // new sorted batch imported result.incrementNbSortedImported(); + String code = batch.getSpecies().getSurveyCode(); + if (code == null) { + code = species.getReferenceTaxonId().toString(); + } + SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(code); + Caracteristic lengthStepPmfm = persistenceService.getCaracteristic(Integer.parseInt(speciesProtocol.getLengthStepPmfmId())); + Collection<BigfinDataRow> speciesRows = rowsBySpecies.get(species); Multimap<CaracteristicQualitativeValue, BigfinDataRow> rowsBySize = Multimaps.index(speciesRows, new Function<BigfinDataRow, CaracteristicQualitativeValue>() { @@ -241,12 +267,12 @@ public class BigfinImportService extends AbstractTuttiService { }); for (CaracteristicQualitativeValue size : rowsBySize.keySet()) { - SpeciesBatch sizeBatch = new SpeciesBatchBean(); - sizeBatch.setSpecies(species); - sizeBatch.setFishingOperation(operation); - sizeBatch.setSampleCategoryId(PmfmId.SIZE_CATEGORY.getValue()); - sizeBatch.setSampleCategoryValue(size); - sizeBatch = persistenceService.createSpeciesBatch(sizeBatch, batch.getId()); + + SpeciesBatch sizeBatch = createSpeciesBatch(species, + operation, + PmfmId.SIZE_CATEGORY.getValue(), + size, + batch.getId()); Collection<BigfinDataRow> sizeRows = rowsBySize.get(size); Multimap<CaracteristicQualitativeValue, BigfinDataRow> rowsByGender = @@ -257,33 +283,47 @@ public class BigfinImportService extends AbstractTuttiService { return result; } }); + for (CaracteristicQualitativeValue gender : rowsByGender.keySet()) { Collection<BigfinDataRow> bigfinDataRows = rowsByGender.get(gender); - SpeciesBatch genderBatch = new SpeciesBatchBean(); - genderBatch.setSpecies(species); - genderBatch.setFishingOperation(operation); - genderBatch.setSampleCategoryId(PmfmId.SEX.getValue()); - genderBatch.setSampleCategoryValue(gender); - genderBatch = persistenceService.createSpeciesBatch(genderBatch, sizeBatch.getId()); + SpeciesBatch genderBatch = createSpeciesBatch(species, + operation, + PmfmId.SEX.getValue(), + gender, + sizeBatch.getId()); - List<SpeciesBatchFrequency> frequencies = createFrequencies(genderBatch, bigfinDataRows); + List<SpeciesBatchFrequency> frequencies = createFrequencies(genderBatch, bigfinDataRows, lengthStepPmfm); persistenceService.saveSpeciesBatchFrequency(genderBatch.getId(), frequencies); } } } - } - addFileAsAttachment(bigfinFile, catchBatch); + addFileAsAttachment(bigfinFile, catchBatch); + } return result; } - protected List<SpeciesBatchFrequency> createFrequencies(SpeciesBatch batch, Collection<BigfinDataRow> rows) { - SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(batch.getSpecies().getSurveyCode()); - Caracteristic lengthStepPmfm = persistenceService.getCaracteristic(Integer.parseInt(speciesProtocol.getLengthStepPmfmId())); - //TODO on fait quoi si c'est nul? + protected SpeciesBatch createSpeciesBatch(Species species, + FishingOperation operation, + Integer categoryId, + Serializable categoryValue, + String parentBatchId) { + SpeciesBatch batch = SpeciesBatchs.newSpeciesBatch(); + batch.setSpecies(species); + batch.setFishingOperation(operation); + //TODO check in text if hv + batch.setSampleCategoryId(categoryId); + batch.setSampleCategoryValue(categoryValue); + + batch = persistenceService.createSpeciesBatch(batch, parentBatchId); + return batch; + } + + protected List<SpeciesBatchFrequency> createFrequencies(SpeciesBatch batch, Collection<BigfinDataRow> rows, Caracteristic lengthStepPmfm) { + //TODO on fait quoi si lengthStepPmfm est nul? String unit = lengthStepPmfm.getUnit(); Float precision = lengthStepPmfm.getPrecision(); if (precision == null) { @@ -328,9 +368,11 @@ public class BigfinImportService extends AbstractTuttiService { totalWeight += weight; } } - // convert grams to kilograms - totalWeight = Weights.roundKiloGram(totalWeight / 1000); - frequency.setWeight(totalWeight); + if (totalWeight > 0f) { + // convert grams to kilograms + totalWeight = Weights.roundKiloGram(totalWeight / 1000); + frequency.setWeight(totalWeight); + } } return frequencies; } diff --git a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties index 7b41d9c..5232704 100644 --- a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties +++ b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties @@ -46,6 +46,10 @@ tutti.report.step.export.fishingOperation= tutti.report.step.generateReport= tutti.report.step.load.fishingOperation= tutti.service.arp.import.attachment.comment= +tutti.service.bigfin.import.attachment.comment= +tutti.service.bigfinImport.error.species.not.found= +tutti.service.bigfinImport.error.species.without.lengthstep= +tutti.service.bigfinImport.error.szClass.unknwon= tutti.service.bigfinimport.error.no.protocol= tutti.service.compressZipFile.error= tutti.service.context.serviceInstanciation.error= diff --git a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties index beaca46..6cd20b4 100644 --- a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties +++ b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties @@ -43,7 +43,11 @@ tutti.propety.vessel.nation.registrationCode=%s (nat.) tutti.report.step.export.fishingOperation=Exporter le trait sélectionné tutti.report.step.generateReport=Générer le rapport tutti.report.step.load.fishingOperation=Charger le trait sélectionné -tutti.service.bigfinimport.error.no.protocol= +tutti.service.bigfin.import.attachment.comment=Import Bigfin du %s +tutti.service.bigfinImport.error.species.not.found=L'espèce '<strong>%s</strong>' est inconnue +tutti.service.bigfinImport.error.species.without.lengthstep=L'espèce '<strong>%s</strong>' n'a pas de classe de taille associée dans le protocole. +tutti.service.bigfinImport.error.szClass.unknwon=Ligne <i>%s</i>, code inconnu (doit être 0, 1 ou 2) +tutti.service.bigfinimport.error.no.protocol=Impossible de faire un import Bigfin sans protocol. tutti.service.compressZipFile.error=Erreur lors de la compression du dossier %1s dans le fichier %2s tutti.service.context.serviceInstanciation.error=Erreur lors de l'instanciation du service %s tutti.service.csv.parse.entityNotFound=L'entité de type %1s avec la propriété %2s de valeur %3s n'a pas été trouvée diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties index 34edbdc..c2a6941 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties @@ -979,9 +979,9 @@ tutti.editSpeciesBatch.action.exportMultiPost.success=Les lots d'espèces ont é tutti.editSpeciesBatch.action.exportMultiPost.tip=Exporter les lots d'espèces pour les importer sur le poste maître tutti.editSpeciesBatch.action.importBigfin=Import Bigfin tutti.editSpeciesBatch.action.importBigfin.mnemonic=B -tutti.editSpeciesBatch.action.importBigfin.no.matching.data= -tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation= -tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation.title= +tutti.editSpeciesBatch.action.importBigfin.no.matching.data=Import Bigfin non réalisé (des erreurs ont été détectées lors de la lecture du fichier) +tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation=L'import Bigfin n'a pas été réalisé, des erreurs ont été détectées \:<ul>%s</ul><br/>Aucun lot n'a donc été importé. +tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation.title=Import Bigfin tutti.editSpeciesBatch.action.importBigfin.success=Import Bigfin réussi \: %1s espèces importées (Vrac), %2s espèces importées (Hors-Vrac) tutti.editSpeciesBatch.action.importBigfin.tip=Import Bigfin tutti.editSpeciesBatch.action.importMultiPost=Importer des lots d'espèces -- 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 tutti. See http://git.codelutin.com/tutti.git commit aa70ff22c2bd546e6528342281b170fb306c130b Author: Kevin Morin <morin@codelutin.com> Date: Wed Sep 3 17:49:38 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN --- .../service/bigfin/BigfinImportServiceTest.java | 191 ++ .../test/resources/bigfin/importbigfin-invalid.csv | 31 + .../test/resources/bigfin/importbigfin-valid.csv | 31 + .../test/resources/bigfin/protocol.tuttiProtocol | 2426 ++++++++++++++++++++ 4 files changed, 2679 insertions(+) diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java new file mode 100644 index 0000000..5db965b --- /dev/null +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java @@ -0,0 +1,191 @@ +package fr.ifremer.tutti.service.bigfin; + +import com.google.common.base.Predicate; +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; +import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; +import fr.ifremer.tutti.TuttiConfigurationOption; +import fr.ifremer.tutti.persistence.ProgressionModel; +import fr.ifremer.tutti.persistence.entities.data.BatchContainer; +import fr.ifremer.tutti.persistence.entities.data.CatchBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchs; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.service.ServiceDbResource; +import fr.ifremer.tutti.service.TuttiServiceContext; +import fr.ifremer.tutti.service.psionimport.PsionImportService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +/** + * @author Kevin Morin (Code Lutin) + * @since 3.8 + */ +public class BigfinImportServiceTest { + + @ClassRule + public static final ServiceDbResource dbResource = ServiceDbResource.writeDb("dbExport"); + + /** Logger. */ + private static final Log log = LogFactory.getLog(BigfinImportServiceTest.class); + + public static final String PROGRAM_ID = "CAM-TEST_ELEVATION"; + + public static final String CRUISE_ID = "100003"; + + public static final String OPERATION_1_ID = "100112"; + + public static final String OPERATION_2_ID = "100113"; + + public static final String OPERATION_3_ID = "100115"; + + protected BigfinImportService service; + + protected PersistenceService persistenceService; + + protected ServiceDbResource.DataContext dataContext; + + protected ProgressionModel progressionModel; + + protected File dataDirectory; + + protected Predicate<SpeciesAbleBatch> vracPredicate; + + @Before + public void setUp() throws Exception { + + dataDirectory = dbResource.getConfig().getDataDirectory(); + + TuttiServiceContext serviceContext = dbResource.getServiceContext(); + + File protocol = dbResource.copyClassPathResource("bigfin/protocol.tuttiProtocol", "protocol.tuttiProtocol"); + dbResource.getConfig().getApplicationConfig().setOption(TuttiConfigurationOption.DB_PROTOCOL_DIRECTORY.getKey(), protocol.getParentFile().getAbsolutePath()); + serviceContext.getDataContext().setProtocolId("protocol"); + + dbResource.openDataContext(); + + persistenceService = serviceContext.getService(PersistenceService.class); + service = serviceContext.getService(BigfinImportService.class); + + progressionModel = new ProgressionModel(); + progressionModel.setTotal(9); + + dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 3, OPERATION_2_ID, OPERATION_1_ID, OPERATION_3_ID); + + vracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate(PmfmId2.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue()); + } + + @Test + public void importValid() throws IOException { + + File importFile = dbResource.copyClassPathResource("bigfin/importbigfin-valid.csv", "importbigfin-valid.csv"); + + FishingOperation operation = dataContext.operations.get(1); + CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); + catchBatch.setFishingOperation(operation); + + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); + for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) { + persistenceService.deleteSpeciesBatch(speciesBatch.getId()); + } + + BigfinImportResult importResult = service.importFile(importFile, operation, catchBatch); + + int nbSortedAdded = importResult.getNbSortedImported(); + int nbUnsortedAdded = importResult.getNbUnsortedImported(); + List<String> errors = importResult.getErrors(); + + if (log.isInfoEnabled()) { + log.info("Sorted Imported: " + nbSortedAdded); + log.info("Unsorted Imported: " + nbUnsortedAdded); + log.info("Errors: " + errors.size()); + } + + int nbNewSortedBatchs = 3; + int nbNewUnsortedBatchs = 0; + Assert.assertEquals(nbNewSortedBatchs, nbSortedAdded); + Assert.assertEquals(nbNewUnsortedBatchs, nbUnsortedAdded); + Assert.assertEquals(0, errors.size()); + + // no batch imported + BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); + + int totalSortedBatchs = 0; + int totalUnsortedBatchs = 0; + for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { + + boolean sorted = vracPredicate.apply(speciesBatch); + + if (sorted) { + totalSortedBatchs++; + } else { + totalUnsortedBatchs++; + } + } + + Assert.assertEquals(nbNewSortedBatchs, totalSortedBatchs); + Assert.assertEquals(nbNewUnsortedBatchs, totalUnsortedBatchs); + } + + @Test + public void importInvalid() throws IOException { + + File importFile = dbResource.copyClassPathResource("bigfin/importbigfin-invalid.csv", "importbigfin-invalid.csv"); + + FishingOperation operation = dataContext.operations.get(1); + CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); + catchBatch.setFishingOperation(operation); + + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); + for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) { + persistenceService.deleteSpeciesBatch(speciesBatch.getId()); + } + + BigfinImportResult importResult = service.importFile(importFile, operation, catchBatch); + + int nbSortedAdded = importResult.getNbSortedImported(); + int nbUnsortedAdded = importResult.getNbUnsortedImported(); + List<String> errors = importResult.getErrors(); + + if (log.isInfoEnabled()) { + log.info("Sorted Imported: " + nbSortedAdded); + log.info("Unsorted Imported: " + nbUnsortedAdded); + log.info("Errors: " + errors.size()); + } + + int nbNewSortedBatchs = 0; + int nbNewUnsortedBatchs = 0; + int nbErrors = 3; + Assert.assertEquals(nbNewSortedBatchs, nbSortedAdded); + Assert.assertEquals(nbNewUnsortedBatchs, nbUnsortedAdded); + Assert.assertEquals(nbErrors, errors.size()); + + // no batch imported + BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); + + int totalSortedBatchs = 0; + int totalUnsortedBatchs = 0; + for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { + + boolean sorted = vracPredicate.apply(speciesBatch); + + if (sorted) { + totalSortedBatchs++; + } else { + totalUnsortedBatchs++; + } + } + + Assert.assertEquals(nbNewSortedBatchs, totalSortedBatchs); + Assert.assertEquals(nbNewUnsortedBatchs, totalUnsortedBatchs); + } +} diff --git a/tutti-service/src/test/resources/bigfin/importbigfin-invalid.csv b/tutti-service/src/test/resources/bigfin/importbigfin-invalid.csv new file mode 100644 index 0000000..4d5dabe --- /dev/null +++ b/tutti-service/src/test/resources/bigfin/importbigfin-invalid.csv @@ -0,0 +1,31 @@ +Record_id;length(mm);weight(g);species;cruise;station;pan;Dt;sz class;gender;text +0;98;250;ARISFOL;THALASSA;1;VB;05/31/14 20:20;42;Not set;libre +1;123;360;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; +2;185;215;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; +3;101;145;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; +5;90;256;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +6;131;258;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +7;168;365;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +8;165;324;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +9;136;124;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +10;145;241;ARISFOL;THALASSA;1;VB;05/31/14 20:21;2;Not set; +11;125;256;ARISFOL;THALASSA;1;VB;05/31/14 20:22;2;Not set; +12;650;0;ARITANT;THALASSA;1;VB;05/31/14 20:23;0;M; +13;654;0;ARITANT;THALASSA;1;VB;05/31/14 20:24;0;M; +14;521;0;ARITANT;THALASSA;1;VB;05/31/14 20:25;0;F; +15;587;0;ARITANT;THALASSA;1;VB;05/31/14 20:26;0;F; +16;456;0;ARITANT;THALASSA;1;VB;05/31/14 20:27;0;M; +17;562;0;ARITANT;THALASSA;1;VB;05/31/14 20:28;0;F; +18;562;0;ARITANT;THALASSA;1;VB;05/31/14 20:29;0;F; +19;125;1025;TRACTRU;THALASSA;1;VB;05/31/14 20:30;0;Not set; +20;145;0;TRACTRU;THALASSA;1;VB;05/31/14 20:31;0;Not set; +21;102;0;TRACTRU;THALASSA;1;VB;05/31/14 20:32;0;Not set; +22;96;0;TRACTRU;THALASSA;1;VB;05/31/14 20:33;0;Not set; +23;84;0;TRACTRU;THALASSA;1;VB;05/31/14 20:34;0;Not set; +24;84;0;TRACTRU;THALASSA;1;VB;05/31/14 20:35;0;Not set; +25;132;0;TRACTRU;THALASSA;1;VB;05/31/14 20:36;0;Not set; +26;105;0;TRACTRU;THALASSA;1;VB;05/31/14 20:37;0;Not set; +27;80;0;TRACTRU;THALASSA;1;VB;05/31/14 20:38;0;Not set; +28;96;0;TRACTRU;THALASSA;1;VB;05/31/14 20:39;0;Not set; +29;87;0;PAPELON;THALASSA;1;VB;05/31/14 20:40;0;Not set; +30;785;1240;DICE-LAB;THALASSA;1;VB;05/31/14 20:41;2;M; diff --git a/tutti-service/src/test/resources/bigfin/importbigfin-valid.csv b/tutti-service/src/test/resources/bigfin/importbigfin-valid.csv new file mode 100644 index 0000000..66cd72b --- /dev/null +++ b/tutti-service/src/test/resources/bigfin/importbigfin-valid.csv @@ -0,0 +1,31 @@ +Record_id;length(mm);weight(g);species;cruise;station;pan;Dt;sz class;gender;text +0;98;250;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set;libre +1;123;360;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; +2;185;215;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; +3;101;145;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; +5;90;256;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +6;131;258;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +7;168;365;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +8;165;324;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +9;136;124;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; +10;145;241;ARISFOL;THALASSA;1;VB;05/31/14 20:21;2;Not set; +11;125;256;ARISFOL;THALASSA;1;VB;05/31/14 20:22;2;Not set; +12;650;0;ARITANT;THALASSA;1;VB;05/31/14 20:23;0;M; +13;654;0;ARITANT;THALASSA;1;VB;05/31/14 20:24;0;M; +14;521;0;ARITANT;THALASSA;1;VB;05/31/14 20:25;0;F; +15;587;0;ARITANT;THALASSA;1;VB;05/31/14 20:26;0;F; +16;456;0;ARITANT;THALASSA;1;VB;05/31/14 20:27;0;M; +17;562;0;ARITANT;THALASSA;1;VB;05/31/14 20:28;0;F; +18;562;0;ARITANT;THALASSA;1;VB;05/31/14 20:29;0;F; +19;125;1025;TRACTRU;THALASSA;;VB;05/31/14 20:30;0;Not set; +20;145;0;TRACTRU;THALASSA;;VB;05/31/14 20:31;0;Not set; +21;102;0;TRACTRU;THALASSA;;VB;05/31/14 20:32;0;Not set; +22;96;0;TRACTRU;THALASSA;;VB;05/31/14 20:33;0;Not set; +23;84;0;TRACTRU;THALASSA;;VB;05/31/14 20:34;0;Not set; +24;84;0;TRACTRU;THALASSA;;VB;05/31/14 20:35;0;Not set; +25;132;0;TRACTRU;THALASSA;;VB;05/31/14 20:36;0;Not set; +26;105;0;TRACTRU;THALASSA;;VB;05/31/14 20:37;0;Not set; +27;80;0;TRACTRU;THALASSA;;VB;05/31/14 20:38;0;Not set; +28;96;0;TRACTRU;THALASSA;;VB;05/31/14 20:39;0;Not set; +29;87;0;TRACTRU;THALASSA;;VB;05/31/14 20:40;0;Not set; +30;785;1240;DICE-LAB;THALASSA;1;VB;05/31/14 20:41;2;M; diff --git a/tutti-service/src/test/resources/bigfin/protocol.tuttiProtocol b/tutti-service/src/test/resources/bigfin/protocol.tuttiProtocol new file mode 100644 index 0000000..347653b --- /dev/null +++ b/tutti-service/src/test/resources/bigfin/protocol.tuttiProtocol @@ -0,0 +1,2426 @@ +id: 7a959cb1-2bf0-4876-8e20-ba0021c27835 +name: Protocole MEDITS +benthos: +- !SpeciesProtocol + id: e48d74a1-3ed9-4063-b970-fa95601ce813 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 907 + speciesSurveyCode: ALPHGLA + weightEnabled: true +- !SpeciesProtocol + id: bedf43f2-1ba4-404e-ada2-cdd5c66e67b3 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 886 + speciesSurveyCode: CHLOGRA + weightEnabled: true +- !SpeciesProtocol + id: 99d3c435-ce9e-48f2-a2e5-de1e30af1c05 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 931 + speciesSurveyCode: CRANSPP + weightEnabled: true +- !SpeciesProtocol + id: 6b2491d8-d237-489c-b98a-460594276fec + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 990 + speciesSurveyCode: DARDSPP + weightEnabled: true +- !SpeciesProtocol + id: cab84c60-0637-49b8-880e-74bf53fe8de8 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1140 + speciesSurveyCode: DORILAN + weightEnabled: true +- !SpeciesProtocol + id: ce1dc3a2-912b-439b-8930-83c6bb5a9112 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1012 + speciesSurveyCode: GALADIS + weightEnabled: true +- !SpeciesProtocol + id: ddfe6e29-03e4-4387-b052-a698f5087bf2 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1013 + speciesSurveyCode: GALAINT + weightEnabled: true +- !SpeciesProtocol + id: fe7f5f8d-bfac-4ae9-8e9e-3abed1c6aa1e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1014 + speciesSurveyCode: GALANEX + weightEnabled: true +- !SpeciesProtocol + id: 03fd6fe9-9e9b-409e-96bf-57caa9e9419a + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1103 + speciesSurveyCode: GONERHO + weightEnabled: true +- !SpeciesProtocol + id: fb000dfa-157d-42d8-affe-3585b21addb0 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 951 + speciesSurveyCode: HOMAVUL + weightEnabled: true +- !SpeciesProtocol + id: 6e3a1545-86ff-41f7-ab1a-892c60e12a55 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1029 + speciesSurveyCode: HOMOBAR + weightEnabled: true +- !SpeciesProtocol + id: 6c61c141-d7de-4201-8291-53bfd17f856f + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1129 + speciesSurveyCode: INACSPP + weightEnabled: true +- !SpeciesProtocol + id: 6f594c41-c44a-4d26-a76a-a54ec9368862 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1136 + speciesSurveyCode: MACRSPP + weightEnabled: true +- !SpeciesProtocol + id: 50e66761-7754-4c68-bd89-b2a4a8749421 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1111 + speciesSurveyCode: MAJASQU + weightEnabled: true +- !SpeciesProtocol + id: c4fc0b86-0848-49b1-b150-8f2bf4ca2034 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1067 + speciesSurveyCode: MCPIDEP + weightEnabled: true +- !SpeciesProtocol + id: 242174d3-8ca9-4cf9-b8b9-21316ffa5a93 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1066 + speciesSurveyCode: MCPITUB + weightEnabled: true +- !SpeciesProtocol + id: a3915c98-71ec-4561-8673-95933e8edf70 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1075 + speciesSurveyCode: MCPIVER + weightEnabled: true +- !SpeciesProtocol + id: ac3f2c25-fc67-4820-95a2-1de26faf840c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1015 + speciesSurveyCode: MUNISPP + weightEnabled: true +- !SpeciesProtocol + id: 83bf86a4-810d-4c9b-8dcb-37c66735b33c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 999 + speciesSurveyCode: PAGUEXC + weightEnabled: true +- !SpeciesProtocol + id: 2c53f5e8-688b-4766-8b22-d62d92109f8a + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 994 + speciesSurveyCode: PAGUPRI + weightEnabled: true +- !SpeciesProtocol + id: baafb7ef-164c-4b98-975c-28c518a7315a + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 997 + speciesSurveyCode: PAGUSPP + weightEnabled: true +- !SpeciesProtocol + id: e26e4708-50e8-4947-b395-18dbd51e25fb + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 885 + speciesSurveyCode: PAPANAR + weightEnabled: true +- !SpeciesProtocol + id: c4b0705b-5657-480e-ad6b-4d6327de8073 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1028 + speciesSurveyCode: PAROCUV + weightEnabled: true +- !SpeciesProtocol + id: 33b8eb55-932c-488a-8de9-d4696a485c21 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 868 + speciesSurveyCode: PASISIV + weightEnabled: true +- !SpeciesProtocol + id: 2e4c871c-d943-4dff-8d8d-a23bf39f8482 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 866 + speciesSurveyCode: PASISPP + weightEnabled: true +- !SpeciesProtocol + id: 423733e0-43c8-48ef-b6b9-b0077b8a03ae + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 880 + speciesSurveyCode: PLESACA + weightEnabled: true +- !SpeciesProtocol + id: 2cc65b6e-4f4d-4757-aa89-40dd52f13f3c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 881 + speciesSurveyCode: PLESANT + weightEnabled: true +- !SpeciesProtocol + id: 99805344-1325-4139-b3dd-f6e4690b5316 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 7185 + speciesSurveyCode: PLESEDW + weightEnabled: true +- !SpeciesProtocol + id: 6aa66a07-fcd1-4fdf-aec9-29ce15c595f9 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 882 + speciesSurveyCode: PLESGIG + weightEnabled: true +- !SpeciesProtocol + id: fe2af1be-2d65-4658-b587-49f22d4b939f + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 883 + speciesSurveyCode: PLESHET + weightEnabled: true +- !SpeciesProtocol + id: 5fde324e-f7a1-4516-9190-7eaf2239c69b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 884 + speciesSurveyCode: PLESMAR + weightEnabled: true +- !SpeciesProtocol + id: 8a8129f5-f66a-4057-8282-6c6287e80629 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 879 + speciesSurveyCode: PLESSPP + weightEnabled: true +- !SpeciesProtocol + id: ff17d20e-bfa6-4752-8c52-5614a4d0ae3e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 953 + speciesSurveyCode: POLCTYP + weightEnabled: true +- !SpeciesProtocol + id: 5b3ccbb3-2f1a-4b55-b5b3-69a0559edbb9 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 935 + speciesSurveyCode: PONPNOR + weightEnabled: true +- !SpeciesProtocol + id: ebc7e293-3dd4-4d9a-b314-fdc7b0a23d89 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 934 + speciesSurveyCode: PONPSPI + weightEnabled: true +- !SpeciesProtocol + id: 95fa55c4-f2f3-451f-ae27-3f520e43af38 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 928 + speciesSurveyCode: PONTCAT + weightEnabled: true +- !SpeciesProtocol + id: fa1a37a0-3623-47be-aaa4-4b6c725b8b1d + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 929 + speciesSurveyCode: PONTLAC + weightEnabled: true +- !SpeciesProtocol + id: d9a9967d-f191-4e6e-9a5c-a5dea4b8b774 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 10607 + speciesSurveyCode: PROCEDU + weightEnabled: true +- !SpeciesProtocol + id: bbf63159-be69-444d-a004-66a13a63088b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 915 + speciesSurveyCode: PROCSPP + weightEnabled: true +- !SpeciesProtocol + id: 489084e7-7442-4ade-b356-cacb09e0ed3f + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 858 + speciesSurveyCode: SOLOMEM + weightEnabled: true +- !SpeciesProtocol + id: c0ed971f-8a60-4ddc-888a-866483167241 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 715 + speciesSurveyCode: SCALSCA + weightEnabled: true +- !SpeciesProtocol + id: 1e9007ee-a31d-451f-9ad2-f6de5048f4cb + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 837 + speciesSurveyCode: EUPHSPP + weightEnabled: true +- !SpeciesProtocol + id: 1a27e40d-2660-4e47-badd-0df6cb48efc1 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 831 + speciesSurveyCode: SQUIMAN + lengthStepPmfmId: 1417 + weightEnabled: true +- !SpeciesProtocol + id: 04601e60-e556-428c-8aec-2beb1d8a5784 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 353 + speciesSurveyCode: ATRIFRA + weightEnabled: true +- !SpeciesProtocol + id: 4a296117-cfea-41fa-ba1d-9ddee2480957 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 379 + speciesSurveyCode: CARDACU + weightEnabled: true +- !SpeciesProtocol + id: e16a2e50-fc6f-4255-897f-337286659f38 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 378 + speciesSurveyCode: CARDECH + weightEnabled: true +- !SpeciesProtocol + id: a70dcb6b-6dc1-48f3-b95c-d47b933ff50a + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 382 + speciesSurveyCode: CARDSPI + weightEnabled: true +- !SpeciesProtocol + id: a2c6201f-12f1-432a-b4a5-d5fa8b44e860 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 362 + speciesSurveyCode: PECTSPP + weightEnabled: true +- !SpeciesProtocol + id: fcba0a99-625d-4854-9305-da4a346dbcc9 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 261 + speciesSurveyCode: APORPES + weightEnabled: true +- !SpeciesProtocol + id: 90fca18f-1277-4de4-8ee2-50711a0fed72 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 262 + speciesSurveyCode: APORSER + weightEnabled: true +- !SpeciesProtocol + id: 84b81e6a-3b65-485d-9bca-f37ef670709f + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 305 + speciesSurveyCode: BUCCSPP + weightEnabled: true +- !SpeciesProtocol + id: e8c86081-2b02-4e6b-a82b-c28b2d3422fd + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 280 + speciesSurveyCode: CASSECH + weightEnabled: true +- !SpeciesProtocol + id: c43a3c68-95e0-405b-87c4-9c8313ef68a4 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 281 + speciesSurveyCode: CASSTYR + weightEnabled: true +- !SpeciesProtocol + id: b7aedc06-1d73-4a11-8369-c71f5d244f37 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 2451 + speciesSurveyCode: GIBBSPP + weightEnabled: true +- !SpeciesProtocol + id: dd2dfe21-db6d-4a42-a480-610051e55f4a + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 3928 + speciesSurveyCode: MUREBRA + weightEnabled: true +- !SpeciesProtocol + id: 37db060c-6c26-46f2-bce3-44cfb88f4c2c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 292 + speciesSurveyCode: MURETRU + weightEnabled: true +- !SpeciesProtocol + id: d15aee86-46a1-4b67-9228-75ca54cbd4e2 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 318 + speciesSurveyCode: SCAPNIG + weightEnabled: true +- !SpeciesProtocol + id: 3fe5fc8e-0cc7-43cb-a9a6-16c7875a1011 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1189 + speciesSurveyCode: MICOSPP + weightEnabled: true +- !SpeciesProtocol + id: ca52cdab-2b66-4d37-8af8-b81529aa8d52 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1191 + speciesSurveyCode: MICOVUL + weightEnabled: true +- !SpeciesProtocol + id: 6ac82f3b-a242-4923-92ad-5eee494c0861 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 224 + speciesSurveyCode: MBBRYOZ + weightEnabled: true +- !SpeciesProtocol + id: 13b65cd0-a23c-47e0-a92c-30b68f2edde5 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 3671 + speciesSurveyCode: GRYPVIT + weightEnabled: true +- !SpeciesProtocol + id: 547f9754-999d-46c6-853e-83bb687604be + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 4626 + speciesSurveyCode: ADAMCAR + weightEnabled: true +- !SpeciesProtocol + id: a353ed3f-76e8-4c26-a270-17f06b539e14 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 133 + speciesSurveyCode: ALCYPAL + weightEnabled: true +- !SpeciesProtocol + id: c1023085-ad82-46a7-aef8-7bb04c5ef860 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 3037 + speciesSurveyCode: ALCYSPP + weightEnabled: true +- !SpeciesProtocol + id: 50328180-2c0b-410b-bd0f-875957542e42 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 6758 + speciesSurveyCode: FMVERET + weightEnabled: true +- !SpeciesProtocol + id: 3b787133-a724-411e-a625-8baf34542b7a + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 6804 + speciesSurveyCode: FUNIQUA + weightEnabled: true +- !SpeciesProtocol + id: d0cc902e-ad69-46e8-9448-c70b3f343d6f + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 2224 + speciesSurveyCode: ORACTIN + weightEnabled: true +- !SpeciesProtocol + id: f66c8ecd-afdf-4227-b10a-9ec3a34cb87c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 7390 + speciesSurveyCode: ANTESPP + weightEnabled: true +- !SpeciesProtocol + id: 10d40446-c9e5-4822-9de5-4b746c24977c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 11181 + speciesSurveyCode: ASTRIRR + weightEnabled: true +- !SpeciesProtocol + id: 3754b3ad-1723-4f42-a746-7a320da08171 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 11943 + speciesSurveyCode: ASTRSPP + weightEnabled: true +- !SpeciesProtocol + id: 78d430ba-4d36-42e5-bb53-0a03a3f4ac6a + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 6812 + speciesSurveyCode: CIDACID + weightEnabled: true +- !SpeciesProtocol + id: a28fbcad-63b7-4f7f-8d22-b26a3aafbd49 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1151 + speciesSurveyCode: CLOPHIU + weightEnabled: true +- !SpeciesProtocol + id: 9d5fc95c-52cc-4e29-a901-a832db1ad7f3 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 4235 + speciesSurveyCode: ECHNACU + weightEnabled: true +- !SpeciesProtocol + id: 14271e01-b001-427d-b14a-d65667dd47b5 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 3397 + speciesSurveyCode: HOLOSPP + weightEnabled: true +- !SpeciesProtocol + id: b3b6e938-7f0d-46eb-9cfb-3b7d48dc6919 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 4240 + speciesSurveyCode: LEPRSPP + weightEnabled: true +- !SpeciesProtocol + id: 24b681d8-981c-4257-b8e2-680e66bce967 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1155 + speciesSurveyCode: OPHUOPH + weightEnabled: true +- !SpeciesProtocol + id: ec4f46f8-6c1d-42a7-85bf-953694f97218 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1177 + speciesSurveyCode: STICREG + weightEnabled: true +- !SpeciesProtocol + id: c9e18e97-92fa-4c87-b032-dd2efc434ab3 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 395 + speciesSurveyCode: SPISSPP + weightEnabled: true +- !SpeciesProtocol + id: a88de136-eac9-4cca-b22c-5f7ca1d14da9 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 246 + speciesSurveyCode: CANIGRA + weightEnabled: true +- !SpeciesProtocol + id: 55b686b8-6249-408d-b303-77c58e1cff48 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 245 + speciesSurveyCode: CANIZIZ + weightEnabled: true +- !SpeciesProtocol + id: 667f6b5c-f295-4c00-b03e-c097b5cd3aed + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 226 + speciesSurveyCode: CLGASTE + weightEnabled: true +- !SpeciesProtocol + id: 11c25935-9e93-49b5-b4ef-22de3aac3d0e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 12060 + speciesSurveyCode: FMAPLYS + weightEnabled: true +- !SpeciesProtocol + id: 6fe77fe1-fafe-4846-ac80-1ec79b15ee34 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 250 + speciesSurveyCode: TURRSPP + weightEnabled: true +- !SpeciesProtocol + id: 199934f5-b6a6-46cd-bfc6-db1e81c48e40 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 4413 + speciesSurveyCode: APLYSPP + weightEnabled: true +- !SpeciesProtocol + id: 338fa494-885b-4392-8d89-bc19ee5cbfbf + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 155 + speciesSurveyCode: APHRACU + weightEnabled: true +- !SpeciesProtocol + id: 751705d4-25f2-4bb4-9a53-96aed1fc3d84 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 196 + speciesSurveyCode: FMMALDA + weightEnabled: true +- !SpeciesProtocol + id: 443aa667-4773-443a-ae48-76f80d016310 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 3032 + speciesSurveyCode: FMSABED + weightEnabled: true +- !SpeciesProtocol + id: 42af4c8f-fe49-4e33-a539-d4a966726530 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 209 + speciesSurveyCode: FMSERPU + weightEnabled: true +- !SpeciesProtocol + id: 94bec064-27cf-40c2-b746-ee1ddb0ef089 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 150 + speciesSurveyCode: MBANNEL + weightEnabled: true +- !SpeciesProtocol + id: dbe23df9-1ef9-44f3-a272-7dec649b4e87 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 211 + speciesSurveyCode: STERSCU + weightEnabled: true +- !SpeciesProtocol + id: 3c55f53b-2998-46e6-b1bf-f2761df75b29 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 3668 + speciesSurveyCode: DENTSPP + weightEnabled: true +- !SpeciesProtocol + id: 1f798975-e4ca-4df6-9adb-184e1ca167a4 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 147 + speciesSurveyCode: SIPSNUD + weightEnabled: true +- !SpeciesProtocol + id: b0f41012-8aa8-4633-b632-8b415f721606 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 7 + speciesSurveyCode: MBPORIF + weightEnabled: true +- !SpeciesProtocol + id: 3df8daac-bf56-4041-8ff0-02899d7f6dca + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1182 + speciesSurveyCode: CLASCID + weightEnabled: true +gearUseFeaturePmfmId: !com.google.common.collect.Lists$TransformingRandomAccessList +- 833 +- 828 +- 905 +- 826 +individualObservationPmfmId: !com.google.common.collect.Lists$TransformingRandomAccessList +- 196 +- 174 +- 1435 +lengthClassesPmfmId: +- 1417 +- 299 +- 307 +species: +- !SpeciesProtocol + id: 4c712b41-ab72-4ab2-88ef-75eabbcd3f94 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 299 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 848 + speciesSurveyCode: ARISFOL + weightEnabled: true +- !SpeciesProtocol + id: 3d9610bd-cd71-4f8c-8bd9-e0ab89e3023c + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 299 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 849 + speciesSurveyCode: ARITANT + weightEnabled: true +- !SpeciesProtocol + id: cdc14002-96d8-42e5-abe0-07cab51e8bc0 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 855 + speciesSurveyCode: PAPELON + weightEnabled: true +- !SpeciesProtocol + id: 972082e1-b1bf-4228-b8f6-19c5f040792e + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 299 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 949 + speciesSurveyCode: NEPRNOR + weightEnabled: true +- !SpeciesProtocol + id: f3149d94-a711-45b3-b9b3-1f734454a06e + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 1417 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 507 + speciesSurveyCode: ILLECOI + weightEnabled: true +- !SpeciesProtocol + id: b1da88e2-55ae-49f6-9174-4c189cc98e54 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 1417 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 489 + speciesSurveyCode: LOLIVUL + weightEnabled: true +- !SpeciesProtocol + id: 0dc70454-fccc-46cf-9176-2e38cb5c5c3a + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1277 + speciesSurveyCode: CENTGRA + weightEnabled: true +- !SpeciesProtocol + id: 4f70310c-2dd3-452f-8f44-d90feb39248e + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1282 + speciesSurveyCode: SCYMLIC + weightEnabled: true +- !SpeciesProtocol + id: 0d57db02-07d7-4b24-85d7-b2ffffd6b255 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1275 + speciesSurveyCode: ETMOSPI + weightEnabled: true +- !SpeciesProtocol + id: bd461ac9-f897-4fcd-ab23-abbf981279f1 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1254 + speciesSurveyCode: GALEGAL + weightEnabled: true +- !SpeciesProtocol + id: 1c264e2f-96f9-423b-a54b-cb5aa762b0cc + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1245 + speciesSurveyCode: GALUMEL + weightEnabled: true +- !SpeciesProtocol + id: 6efe4eb1-e2a7-4fdb-89ad-3b2d6b47e2ec + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1222 + speciesSurveyCode: HEPTPER + weightEnabled: true +- !SpeciesProtocol + id: 48412543-cf57-452d-979a-4e908cdd3f4c + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1220 + speciesSurveyCode: HEXAGRI + weightEnabled: true +- !SpeciesProtocol + id: baeca8b7-a1d7-4224-b3d6-022f15c6be5a + calcifySampleEnabled: true + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 2050 + speciesSurveyCode: LOPHBUD + weightEnabled: true +- !SpeciesProtocol + id: ec5d8fb6-e26b-4e61-89d8-7c169fbe6096 + calcifySampleEnabled: true + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 2049 + speciesSurveyCode: LOPHPIS + weightEnabled: true +- !SpeciesProtocol + id: 73b81c79-5117-4475-a393-ede51babfebe + calcifySampleEnabled: true + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1540 + speciesSurveyCode: MERLMER + weightEnabled: true +- !SpeciesProtocol + id: 944b5f40-f4d0-4fce-8b5d-5df2eb7ef30d + calcifySampleEnabled: true + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1689 + speciesSurveyCode: MULLBAR + weightEnabled: true +- !SpeciesProtocol + id: c5174b9b-061d-46e5-9a36-259d8dbe7ebf + calcifySampleEnabled: true + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1690 + speciesSurveyCode: MULLSUR + weightEnabled: true +- !SpeciesProtocol + id: b6f62ed7-34ea-48f3-a91c-196e5be13d45 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1257 + speciesSurveyCode: MUSTAST + weightEnabled: true +- !SpeciesProtocol + id: 543a37c5-1b1a-49b4-9a1e-2c0022b17b5c + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1258 + speciesSurveyCode: MUSTMED + weightEnabled: true +- !SpeciesProtocol + id: 1cc14725-4f35-4669-9048-0613a698a356 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1256 + speciesSurveyCode: MUSTMUS + weightEnabled: true +- !SpeciesProtocol + id: 310f665a-7c07-48fd-a6fd-65f5b43bd098 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1329 + speciesSurveyCode: MYLIAQU + weightEnabled: true +- !SpeciesProtocol + id: b83d4fd8-391a-42d5-8003-c71ecb8a9937 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1263 + speciesSurveyCode: OXYNCEN + weightEnabled: true +- !SpeciesProtocol + id: 2ec145c1-0184-4c26-ae12-34fcd006c48b + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1312 + speciesSurveyCode: RAJAALB + weightEnabled: true +- !SpeciesProtocol + id: 5fca8811-4586-43f8-8908-2f83ee9fa90d + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1313 + speciesSurveyCode: RAJAAST + weightEnabled: true +- !SpeciesProtocol + id: d7b06817-a0d9-4b7e-aa7f-77acf6916ce1 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1306 + speciesSurveyCode: RAJABAT + weightEnabled: true +- !SpeciesProtocol + id: 7d20d463-8c8e-4b1e-95b9-21076ab708ca + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1310 + speciesSurveyCode: RAJACIR + weightEnabled: true +- !SpeciesProtocol + id: 933d3b3a-b4cb-4239-896b-1f13f7ea6938 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1302 + speciesSurveyCode: RAJACLA + weightEnabled: true +- !SpeciesProtocol + id: 02521403-26cc-4338-98fa-c437de064538 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1314 + speciesSurveyCode: RAJAMEL + weightEnabled: true +- !SpeciesProtocol + id: b8cb7a32-93c9-4203-9e52-a13691528e21 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1315 + speciesSurveyCode: RAJAMIR + weightEnabled: true +- !SpeciesProtocol + id: dca10109-c771-4290-adac-3220d72a15d9 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1308 + speciesSurveyCode: RAJAOXY + weightEnabled: true +- !SpeciesProtocol + id: eaec42f0-ca79-481c-9062-5b2787c552c4 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1316 + speciesSurveyCode: RAJAPOL + weightEnabled: true +- !SpeciesProtocol + id: 498f415a-bd36-4076-9dce-86015c89f678 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1318 + speciesSurveyCode: RAJAUND + weightEnabled: true +- !SpeciesProtocol + id: e8269d24-6773-4b7f-88a0-de3ecafa83d6 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1292 + speciesSurveyCode: RHINCEM + weightEnabled: true +- !SpeciesProtocol + id: 401bd28f-f102-4529-a535-c02cfe561424 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1293 + speciesSurveyCode: RHINRHI + weightEnabled: true +- !SpeciesProtocol + id: c1f9efff-260f-4855-9f5f-25cbddd76dd8 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1242 + speciesSurveyCode: SCYOCAN + weightEnabled: true +- !SpeciesProtocol + id: f4b01ee8-9dbc-4dfb-a597-668924690e98 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1243 + speciesSurveyCode: SCYOSTE + weightEnabled: true +- !SpeciesProtocol + id: 3309c9a2-6e23-47a5-bf3c-83719215f6bf + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1266 + speciesSurveyCode: SQUAACA + weightEnabled: true +- !SpeciesProtocol + id: 2c7cbd7d-d5a1-4ab8-b27d-90d561074a2a + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1267 + speciesSurveyCode: SQUABLA + weightEnabled: true +- !SpeciesProtocol + id: f13d6105-09e6-4485-9b23-6fa034a4a707 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1288 + speciesSurveyCode: SQUTACU + weightEnabled: true +- !SpeciesProtocol + id: f1fba700-1436-42b2-8be0-86781893fb29 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1289 + speciesSurveyCode: SQUTOCL + weightEnabled: true +- !SpeciesProtocol + id: 519bcc67-852a-4cd6-8328-cad0931e6732 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1287 + speciesSurveyCode: SQUTSQU + weightEnabled: true +- !SpeciesProtocol + id: 87fb8821-e053-4f5c-8940-4f5540fb85c8 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 174 + - 196 + speciesReferenceTaxonId: 1297 + speciesSurveyCode: TORPMAR + weightEnabled: true +- !SpeciesProtocol + id: a744eb4d-43a7-4e7c-b51b-6c9b0c5a56d9 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 299 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 957 + speciesSurveyCode: PALIELE + weightEnabled: true +- !SpeciesProtocol + id: 3e854d0b-7592-43be-9bf0-00152ad19cf0 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 299 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 853 + speciesSurveyCode: PENAKER + weightEnabled: true +- !SpeciesProtocol + id: f684a970-b662-473e-aeff-b3b25881dc42 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 1417 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 514 + speciesSurveyCode: OCTOVUL + weightEnabled: true +- !SpeciesProtocol + id: 04d6c377-d267-4897-bfeb-eda10b88b082 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 1417 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 522 + speciesSurveyCode: ELEDCIR + weightEnabled: true +- !SpeciesProtocol + id: 767b25a5-b89e-4dc7-82c3-6d7046f21e34 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 1417 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 521 + speciesSurveyCode: ELEDMOS + weightEnabled: true +- !SpeciesProtocol + id: 52d095a6-ad24-4d03-b318-95a6b6434f89 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 1417 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 467 + speciesSurveyCode: SEPIOFF + weightEnabled: true +- !SpeciesProtocol + id: 2d5ae016-cb48-498d-949c-bc99f84b1c9b + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 1417 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 509 + speciesSurveyCode: TODASAG + weightEnabled: true +- !SpeciesProtocol + id: 033ae020-e315-4b51-9f62-6408f436ec7e + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1912 + speciesSurveyCode: ASPICUC + weightEnabled: true +- !SpeciesProtocol + id: 0a405bc2-1330-4cbb-87d2-a925a9393991 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1698 + speciesSurveyCode: BOOPBOO + weightEnabled: true +- !SpeciesProtocol + id: f75aa101-3ba5-4577-a2fc-f40d907dc896 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1953 + speciesSurveyCode: CITHMAC + weightEnabled: true +- !SpeciesProtocol + id: 0f84dfac-6bed-40b8-8df6-78d2fc6f8fa9 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1700 + speciesSurveyCode: DIPLANN + weightEnabled: true +- !SpeciesProtocol + id: c5b257e3-8d83-4d59-8d22-ceba000efdaa + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1702 + speciesSurveyCode: DIPLPUN + weightEnabled: true +- !SpeciesProtocol + id: 6e72e9cb-285d-455d-b943-ca68288438a6 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1703 + speciesSurveyCode: DIPLSAR + weightEnabled: true +- !SpeciesProtocol + id: 521f937a-f6ce-44cf-a32a-5567eaf45e6a + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1704 + speciesSurveyCode: DIPLVUL + weightEnabled: true +- !SpeciesProtocol + id: c1a0bb60-ff2c-4430-9ea6-fdd80bc350dd + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1362 + speciesSurveyCode: ENGRENC + weightEnabled: true +- !SpeciesProtocol + id: 46b2419d-80e8-45ce-8845-1deb7c744300 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1632 + speciesSurveyCode: EPINSPP + weightEnabled: true +- !SpeciesProtocol + id: 67bca5b0-b534-41fd-a81e-969168446289 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1920 + speciesSurveyCode: EUTRGUR + weightEnabled: true +- !SpeciesProtocol + id: d787ebfa-c8fe-4fac-b8f5-16c2b70e462c + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1905 + speciesSurveyCode: HELIDAC + weightEnabled: true +- !SpeciesProtocol + id: 3ef4b084-2080-4e17-a8f4-eb5eae314151 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1961 + speciesSurveyCode: LEPMBOS + weightEnabled: true +- !SpeciesProtocol + id: d565422d-5a09-4f63-8df7-3736726d012d + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1710 + speciesSurveyCode: LITHMOR + weightEnabled: true +- !SpeciesProtocol + id: 7ab19715-e91b-4ff0-bd3d-605be8a890e6 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1553 + speciesSurveyCode: MICMPOU + weightEnabled: true +- !SpeciesProtocol + id: ff7b2f1b-50ae-4d8d-82ce-916ac63c60bd + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1714 + speciesSurveyCode: PAGEACA + weightEnabled: true +- !SpeciesProtocol + id: 0415fc50-f9ac-4ad6-a4b2-a9d2875e2a26 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1715 + speciesSurveyCode: PAGEBOG + weightEnabled: true +- !SpeciesProtocol + id: e0d8f887-16ff-4d44-a35a-70a35146d44b + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1713 + speciesSurveyCode: PAGEERY + weightEnabled: true +- !SpeciesProtocol + id: 17e577d9-9b23-430d-b6aa-b4600378ced7 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1695 + speciesSurveyCode: SPARPAG + weightEnabled: true +- !SpeciesProtocol + id: d84bc931-3c2a-4819-ad4f-e007a830accc + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1573 + speciesSurveyCode: PHYIBLE + weightEnabled: true +- !SpeciesProtocol + id: a334e7b1-73a8-410d-a348-ed6ad81846fb + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1641 + speciesSurveyCode: POLYAME + weightEnabled: true +- !SpeciesProtocol + id: cc57956b-1fa1-40a0-a913-1550c0479052 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1957 + speciesSurveyCode: PSETMAX + weightEnabled: true +- !SpeciesProtocol + id: aa43606f-a395-453a-9e5c-8e75320f5559 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1351 + speciesSurveyCode: SARDPIL + weightEnabled: true +- !SpeciesProtocol + id: 56846282-2998-455e-a3c0-5b5adca223af + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 3789 + speciesSurveyCode: SCOMPNE + weightEnabled: true +- !SpeciesProtocol + id: 7f637203-607f-4f24-9076-9ec6f05bcd7e + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1772 + speciesSurveyCode: SCOMSCO + weightEnabled: true +- !SpeciesProtocol + id: 3969d69f-a17d-47ff-87d4-af539ae8ed45 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1996 + speciesSurveyCode: SOLEVUL + weightEnabled: true +- !SpeciesProtocol + id: 466b5b93-b472-4c8a-aa08-5bf53d90bfa0 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1723 + speciesSurveyCode: SPICMAE + weightEnabled: true +- !SpeciesProtocol + id: 1ee6372f-c2e8-4633-8db9-36b5f487a005 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1724 + speciesSurveyCode: SPICSMA + weightEnabled: true +- !SpeciesProtocol + id: 933968a6-1352-474f-a408-9939ad16e5b1 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1663 + speciesSurveyCode: TRACMED + weightEnabled: true +- !SpeciesProtocol + id: 69f476b0-862e-47e1-b593-2bb096616f9e + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1662 + speciesSurveyCode: TRACTRA + weightEnabled: true +- !SpeciesProtocol + id: 3ca8616b-71db-40d3-9b50-caaf2ec20b41 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1921 + speciesSurveyCode: TRIGLUC + weightEnabled: true +- !SpeciesProtocol + id: f5adec71-9859-487d-b728-e2edf84dd1e7 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1922 + speciesSurveyCode: TRIPLAS + weightEnabled: true +- !SpeciesProtocol + id: 9c337552-d9ce-43c8-baee-bb8a16990f06 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1558 + speciesSurveyCode: TRISCAP + weightEnabled: true +- !SpeciesProtocol + id: 6a8c710e-561b-42fa-822b-38fae515f841 + countIfNoFrequencyEnabled: true + lengthStepPmfmId: 307 + mandatorySampleCategoryId: + - 198 + speciesReferenceTaxonId: 1619 + speciesSurveyCode: ZEUSFAB + weightEnabled: true +- !SpeciesProtocol + id: d6b592f0-715e-469c-b5f9-a878a40d96f0 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 495 + speciesSurveyCode: ABRAVER + weightEnabled: true +- !SpeciesProtocol + id: b7be5501-ab00-4d28-970d-0a6ea8c68f85 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 491 + speciesSurveyCode: ALLOSPP + weightEnabled: true +- !SpeciesProtocol + id: 3219f09e-3d2b-47ad-bf3d-3f47f5678989 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1358 + speciesSurveyCode: ALOSALO + weightEnabled: true +- !SpeciesProtocol + id: 056bdc4b-11da-42d1-9974-8c95d20a8ad1 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1359 + speciesSurveyCode: ALOSFAL + weightEnabled: true +- !SpeciesProtocol + id: 9382a0b5-cb31-41e7-a928-8bf9adf1232a + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1637 + speciesSurveyCode: ANTHANT + weightEnabled: true +- !SpeciesProtocol + id: 14ebb140-3775-4e69-aa2e-edec2d2aca44 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1547 + speciesSurveyCode: ANTOMEG + weightEnabled: true +- !SpeciesProtocol + id: 2455d46e-558b-4400-8578-e2dfee943d81 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1394 + speciesSurveyCode: ARGESPY + weightEnabled: true +- !SpeciesProtocol + id: 5b560316-efa2-47a6-a200-4f1d1c7f15d3 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1970 + speciesSurveyCode: ARNOSPP + weightEnabled: true +- !SpeciesProtocol + id: 2dcb33c5-27f9-4b4f-9899-09a8fc8a79fa + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1972 + speciesSurveyCode: ARNOIMP + weightEnabled: true +- !SpeciesProtocol + id: 8a757c0c-ba3e-4fb5-a909-cb064927de06 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1971 + speciesSurveyCode: ARNOLAT + weightEnabled: true +- !SpeciesProtocol + id: 3d2ab930-a3ae-427e-a051-fd10a1082fd6 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1973 + speciesSurveyCode: ARNORUP + weightEnabled: true +- !SpeciesProtocol + id: cf728432-af31-4025-bb73-dfe8c5c59dd3 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1974 + speciesSurveyCode: ARNOTHO + weightEnabled: true +- !SpeciesProtocol + id: 8eaf92d2-cc37-496d-8163-ebf04822a274 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1913 + speciesSurveyCode: ASPIOBS + weightEnabled: true +- !SpeciesProtocol + id: f716bcb0-4378-4e06-b98e-3f60a16aaad8 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 523 + speciesSurveyCode: BATISPO + weightEnabled: true +- !SpeciesProtocol + id: cdc46f8e-8e52-4c79-a2f2-03e028df5f13 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1818 + speciesSurveyCode: BLENOCE + weightEnabled: true +- !SpeciesProtocol + id: d3ba3646-93fd-40ef-93fb-832a3cb660e6 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 2004 + speciesSurveyCode: BUGLLUT + weightEnabled: true +- !SpeciesProtocol + id: cf2b786c-4982-4ff8-8e3d-79aadc7f538f + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1810 + speciesSurveyCode: CALMSPP + weightEnabled: true +- !SpeciesProtocol + id: a08a8d64-6347-49b1-a04c-515a40721381 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1811 + speciesSurveyCode: CALMLYR + weightEnabled: true +- !SpeciesProtocol + id: c023762c-40ab-45cf-86e1-e706d9379a4e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1812 + speciesSurveyCode: CALMMAC + weightEnabled: true +- !SpeciesProtocol + id: d5efefa8-395d-4432-b742-42705c605c2c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1814 + speciesSurveyCode: CALMRIS + weightEnabled: true +- !SpeciesProtocol + id: bd1b7e19-f2ee-4604-894c-c47d66538ceb + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1624 + speciesSurveyCode: CAPOAPE + weightEnabled: true +- !SpeciesProtocol + id: 62aeb758-506f-4d20-979c-57dcc774e9c0 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1860 + speciesSurveyCode: CARPACU + weightEnabled: true +- !SpeciesProtocol + id: 21b09e73-3869-47b4-92fd-ee4673b0e3c0 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1720 + speciesSurveyCode: CECACIR + weightEnabled: true +- !SpeciesProtocol + id: 864923f3-cc7f-4abd-a624-868e1f1e6731 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1279 + speciesSurveyCode: CENTUYA + weightEnabled: true +- !SpeciesProtocol + id: 1c48f803-e058-4c2c-a924-b29507422267 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1654 + speciesSurveyCode: CEPOMAC + weightEnabled: true +- !SpeciesProtocol + id: 432de6bf-9f6e-4790-946b-75da0c9929d5 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1383 + speciesSurveyCode: CHAUSLO + weightEnabled: true +- !SpeciesProtocol + id: e9f97268-2810-429d-9194-aac6768f25d3 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1335 + speciesSurveyCode: CHIMMON + weightEnabled: true +- !SpeciesProtocol + id: 254fde77-2969-479f-b1d5-73addd18449b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1410 + speciesSurveyCode: CLORAGA + weightEnabled: true +- !SpeciesProtocol + id: 16e7adde-7c7a-4ff3-910b-e50f34ba777b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1532 + speciesSurveyCode: COELCOE + weightEnabled: true +- !SpeciesProtocol + id: eec35479-9550-4bf5-aca6-b2f9388df19d + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1533 + speciesSurveyCode: COELOCC + weightEnabled: true +- !SpeciesProtocol + id: 3537d192-e998-4caa-b760-4cb6a8f4d0b7 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1467 + speciesSurveyCode: CONGCON + weightEnabled: true +- !SpeciesProtocol + id: 25dce34d-5ebe-488b-aad6-3734314a641c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1474 + speciesSurveyCode: DALOIMB + weightEnabled: true +- !SpeciesProtocol + id: d54f1cca-cb49-40e1-a8c0-10ab46df1d6c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1321 + speciesSurveyCode: DASICEN + weightEnabled: true +- !SpeciesProtocol + id: 4ad0e928-afe2-444b-aeb9-50a92b48622b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1322 + speciesSurveyCode: DASIPAS + weightEnabled: true +- !SpeciesProtocol + id: 339c15a6-1518-44cd-b23f-722f21370bf0 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 3003 + speciesSurveyCode: DASITOR + weightEnabled: true +- !SpeciesProtocol + id: ef87ff58-12f9-496e-9d87-05ab13fc6906 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1323 + speciesSurveyCode: DASIVIO + weightEnabled: true +- !SpeciesProtocol + id: 7fe7b385-ce85-464d-8b87-ff88814d005b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1789 + speciesSurveyCode: GOBIQUA + weightEnabled: true +- !SpeciesProtocol + id: 56032d3e-93c6-4940-989c-c77e6830a821 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1706 + speciesSurveyCode: DENTDEN + weightEnabled: true +- !SpeciesProtocol + id: ed034eaf-6fe9-4404-bbae-72a1d1fef38e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1644 + speciesSurveyCode: DICELAB + weightEnabled: true +- !SpeciesProtocol + id: 15918297-cb98-49cb-905e-145e8d7231c9 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 10581 + speciesSurveyCode: DIPLCER + weightEnabled: true +- !SpeciesProtocol + id: f29352c8-5caf-4bbb-ab30-6c13b9c5cd6b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1475 + speciesSurveyCode: ECHEMIR + weightEnabled: true +- !SpeciesProtocol + id: fff748a1-94b9-4623-827d-c3d10a0e1af6 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1648 + speciesSurveyCode: EPIGSPP + weightEnabled: true +- !SpeciesProtocol + id: 51909bed-9e38-4db2-bfe6-bfcab3dfce70 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1649 + speciesSurveyCode: EPIGCON + weightEnabled: true +- !SpeciesProtocol + id: 720c4f61-6aaa-4462-ba80-bbfebff36c8e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1650 + speciesSurveyCode: EPIGDEN + weightEnabled: true +- !SpeciesProtocol + id: 48859723-699c-4662-b965-ef7020c2c526 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1586 + speciesSurveyCode: GADAMAR + weightEnabled: true +- !SpeciesProtocol + id: d43881ee-1fc7-4e03-8fa7-540e321547c2 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 7693 + speciesSurveyCode: GADIARG + weightEnabled: true +- !SpeciesProtocol + id: 56c555be-f691-4e6a-9d2e-925fd3afa638 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1579 + speciesSurveyCode: GAIDMED + weightEnabled: true +- !SpeciesProtocol + id: ee845d00-009b-46fd-883d-ebdb547e0f20 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1580 + speciesSurveyCode: GAIDVUL + weightEnabled: true +- !SpeciesProtocol + id: b4ea935c-957e-47ce-81ec-c471f15c135b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1396 + speciesSurveyCode: GLOSLEI + weightEnabled: true +- !SpeciesProtocol + id: 87b2f346-a827-4516-9d08-184ca2c87c7f + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1783 + speciesSurveyCode: GOBISPP + weightEnabled: true +- !SpeciesProtocol + id: 9b165269-d44e-4ccf-a4be-a809a5eeadef + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1785 + speciesSurveyCode: GOBINIG + weightEnabled: true +- !SpeciesProtocol + id: 12476229-943a-4037-8b79-83f14da19921 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 501 + speciesSurveyCode: HISTSPP + weightEnabled: true +- !SpeciesProtocol + id: b3843058-f126-44f1-823e-cac25ba4b6f6 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 7700 + speciesSurveyCode: HOPLMED + weightEnabled: true +- !SpeciesProtocol + id: c6b6e928-c8f2-4e3c-a8c1-4a6463f6980c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1428 + speciesSurveyCode: LAMASPP + weightEnabled: true +- !SpeciesProtocol + id: 6637d2d8-5ffb-4e2a-8277-d185a44c3061 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1429 + speciesSurveyCode: LAMACRO + weightEnabled: true +- !SpeciesProtocol + id: 3ab57331-ec76-44ee-bab7-96c780e603f0 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1590 + speciesSurveyCode: LEPOLEP + weightEnabled: true +- !SpeciesProtocol + id: f1b914a1-37bf-42c8-9387-920a422b9963 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1960 + speciesSurveyCode: LEPMWHS + weightEnabled: true +- !SpeciesProtocol + id: 7c41537e-af2a-49ba-9959-39fb85d56527 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1917 + speciesSurveyCode: LEPTCAV + weightEnabled: true +- !SpeciesProtocol + id: abaab523-9759-4ec4-b103-5df101d0b510 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1918 + speciesSurveyCode: LEPTDIE + weightEnabled: true +- !SpeciesProtocol + id: a2ce385c-0786-459b-aa26-02d936797165 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1791 + speciesSurveyCode: GOBIFRI + weightEnabled: true +- !SpeciesProtocol + id: 91008a01-63e4-4e37-bdc1-dec8f0f0e9a5 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1882 + speciesSurveyCode: LIZAAUR + weightEnabled: true +- !SpeciesProtocol + id: eddfe767-343e-4cc6-97af-59dd8367ba8d + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1881 + speciesSurveyCode: LIZARAM + weightEnabled: true +- !SpeciesProtocol + id: 1ec767ba-1430-4678-a88f-ab9cfca572c2 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1883 + speciesSurveyCode: LIZASAL + weightEnabled: true +- !SpeciesProtocol + id: db272acd-412c-4fa3-8750-e9ba6c664331 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 488 + speciesSurveyCode: LOLISPP + weightEnabled: true +- !SpeciesProtocol + id: 67fa6ded-3a71-4ee3-a68c-b9c66b915775 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 12582 + speciesSurveyCode: LOLIFOR + weightEnabled: true +- !SpeciesProtocol + id: 3c5f43b9-3c1b-4416-b4fb-ac9627e6f305 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1497 + speciesSurveyCode: MACOSCO + weightEnabled: true +- !SpeciesProtocol + id: 5b6f52bb-9014-47d5-a642-67465903521f + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1379 + speciesSurveyCode: MAURMUE + weightEnabled: true +- !SpeciesProtocol + id: b9928831-f097-434e-b023-ec19e673b328 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1551 + speciesSurveyCode: GADUMER + weightEnabled: true +- !SpeciesProtocol + id: 5a0dbd0c-a97b-4b03-8fa3-65cac4dcafce + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 2011 + speciesSurveyCode: MICUVAR + weightEnabled: true +- !SpeciesProtocol + id: 590ad66e-8a57-4fb6-9160-64216646fa4e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1567 + speciesSurveyCode: MOLVDYP + weightEnabled: true +- !SpeciesProtocol + id: 8c123060-9d02-4938-ad86-867b14c37f6c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1568 + speciesSurveyCode: MOLVMAC + weightEnabled: true +- !SpeciesProtocol + id: 08628555-a63c-4def-a9f0-330fdb250092 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1566 + speciesSurveyCode: MOLVMOL + weightEnabled: true +- !SpeciesProtocol + id: 7d640ad6-0104-4dde-9792-36d792e8be3b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1593 + speciesSurveyCode: MORAMOR + weightEnabled: true +- !SpeciesProtocol + id: 27ac2050-f2f2-425b-a203-33171a22b0c4 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1877 + speciesSurveyCode: MUGICEP + weightEnabled: true +- !SpeciesProtocol + id: 3ff92ada-84b8-4b8c-9be2-346a39e2aeaf + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1414 + speciesSurveyCode: MYCOSPP + weightEnabled: true +- !SpeciesProtocol + id: acbc1c5d-3125-4ce3-816f-b92135e53cf5 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1464 + speciesSurveyCode: NETTMEL + weightEnabled: true +- !SpeciesProtocol + id: 5c12bd71-e723-413d-9be9-2e062646070b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1527 + speciesSurveyCode: NEZUAEQ + weightEnabled: true +- !SpeciesProtocol + id: db8b2566-540d-4d22-aaea-cd2949136a31 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1528 + speciesSurveyCode: NEZUSCL + weightEnabled: true +- !SpeciesProtocol + id: 7bd39d56-8571-4936-9247-2c3f7db3ca8c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1483 + speciesSurveyCode: NOTABON + weightEnabled: true +- !SpeciesProtocol + id: 35cdc743-e4bf-45a8-b80f-9ac6f50e6b3e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1711 + speciesSurveyCode: OBLAMEL + weightEnabled: true +- !SpeciesProtocol + id: 7aa028ca-c686-4592-8482-10be13c54d77 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 513 + speciesSurveyCode: OCTOSPP + weightEnabled: true +- !SpeciesProtocol + id: 2acef86b-b195-4ff7-8164-874751de27e4 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 515 + speciesSurveyCode: OCTODEP + weightEnabled: true +- !SpeciesProtocol + id: 4d715d15-f9e1-4081-9d10-cf0f651b728d + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 517 + speciesSurveyCode: OCTOSAL + weightEnabled: true +- !SpeciesProtocol + id: ee9780a1-4ffc-43d1-bda0-8c180b59b18d + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1476 + speciesSurveyCode: OPHCRUF + weightEnabled: true +- !SpeciesProtocol + id: 99345448-fefe-468f-bd59-6a0ba827dc8c + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1857 + speciesSurveyCode: OPDIBAR + weightEnabled: true +- !SpeciesProtocol + id: 9b50141a-7e9f-45bb-8cb9-0609aec8952e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1858 + speciesSurveyCode: OPDIROC + weightEnabled: true +- !SpeciesProtocol + id: 6282d580-dde1-4477-89dd-f6ab1e4e63f1 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1477 + speciesSurveyCode: OPHISER + weightEnabled: true +- !SpeciesProtocol + id: 44dbd32c-d339-4666-941b-8be80326a7d5 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1572 + speciesSurveyCode: PHYIPHY + weightEnabled: true +- !SpeciesProtocol + id: b333a01f-33af-4fae-a8ee-372cbf0afd08 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 519 + speciesSurveyCode: OCTOTET + weightEnabled: true +- !SpeciesProtocol + id: 3951b007-79c2-40f9-9ce2-f56f2b66e480 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1300 + speciesSurveyCode: RAJASPP + weightEnabled: true +- !SpeciesProtocol + id: dd590225-43f1-4403-8acb-6894ca3a7ebb + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1301 + speciesSurveyCode: RAJABRA + weightEnabled: true +- !SpeciesProtocol + id: 9ac0e7e4-563d-4f60-957e-22fe39c0860a + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1309 + speciesSurveyCode: RAJAFUL + weightEnabled: true +- !SpeciesProtocol + id: 7efd6a9a-1e6a-47da-915c-b68d1fd00017 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1304 + speciesSurveyCode: RAJAMON + weightEnabled: true +- !SpeciesProtocol + id: f4b357aa-1c5c-40d8-8acd-b1ecffa18025 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1311 + speciesSurveyCode: RAJANAE + weightEnabled: true +- !SpeciesProtocol + id: 003afb88-af45-457c-a84b-16975a529645 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1317 + speciesSurveyCode: RAJARDA + weightEnabled: true +- !SpeciesProtocol + id: 4ae3247b-a7d3-4d1d-bd78-9e866821c072 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 471 + speciesSurveyCode: ROSSMAC + weightEnabled: true +- !SpeciesProtocol + id: 88da67b0-2f77-4d0b-bed1-08f3102fcd98 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1775 + speciesSurveyCode: SADASAR + weightEnabled: true +- !SpeciesProtocol + id: 12079205-9148-41b1-9d64-a920793f70bb + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1716 + speciesSurveyCode: SARPSAL + weightEnabled: true +- !SpeciesProtocol + id: 14bfc0d8-46cd-4f85-805e-8549a0ab90b8 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1894 + speciesSurveyCode: SCORSPP + weightEnabled: true +- !SpeciesProtocol + id: 8d055995-0c6f-4f52-bc05-bc79cc35e867 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1895 + speciesSurveyCode: SCORELO + weightEnabled: true +- !SpeciesProtocol + id: 8eda25d1-73d8-4e79-80e4-0829fb8bd1c3 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1897 + speciesSurveyCode: SCORLOP + weightEnabled: true +- !SpeciesProtocol + id: 220da7a9-05cb-484b-b299-49658e585bff + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1898 + speciesSurveyCode: SCORMAD + weightEnabled: true +- !SpeciesProtocol + id: f27a7a08-2fa9-402a-8601-f8c26bb8f29d + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1899 + speciesSurveyCode: SCORNOT + weightEnabled: true +- !SpeciesProtocol + id: 19328f63-e90d-4be0-a332-9efe14c87038 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1896 + speciesSurveyCode: SCORPOR + weightEnabled: true +- !SpeciesProtocol + id: 6c7342d2-f50f-4231-bc91-5851e778a916 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1900 + speciesSurveyCode: SCORSCO + weightEnabled: true +- !SpeciesProtocol + id: 7b68433c-0e52-4369-9f13-9b300a0a31cb + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 466 + speciesSurveyCode: SEPISPP + weightEnabled: true +- !SpeciesProtocol + id: ec368e8f-6152-4828-9d85-38d2cd6fe2ab + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 468 + speciesSurveyCode: SEPIELE + weightEnabled: true +- !SpeciesProtocol + id: 72688083-ed6d-418c-8195-b7290d2aeeba + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 469 + speciesSurveyCode: SEPIORB + weightEnabled: true +- !SpeciesProtocol + id: 9bbb3bcb-f770-448e-8141-2a2a250dff45 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 476 + speciesSurveyCode: SEPOSPP + weightEnabled: true +- !SpeciesProtocol + id: bb6f45c4-c085-4809-b63a-1b0750f58ac2 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1628 + speciesSurveyCode: SERACAB + weightEnabled: true +- !SpeciesProtocol + id: 5976284b-a33e-4f31-aef3-cd5190f40b34 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1629 + speciesSurveyCode: SERAHEP + weightEnabled: true +- !SpeciesProtocol + id: 1b37cc5c-5164-4fa6-8f48-08173ace1507 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1995 + speciesSurveyCode: SOLESPP + weightEnabled: true +- !SpeciesProtocol + id: be091828-e022-4725-a682-f0e9ea3af3ba + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1998 + speciesSurveyCode: SOLEIMP + weightEnabled: true +- !SpeciesProtocol + id: 1075356e-b3b8-4c38-aba4-73f359a6b98b + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1999 + speciesSurveyCode: SOLEKLE + weightEnabled: true +- !SpeciesProtocol + id: 00d90ba4-c2af-408b-a497-30a4c35c34dc + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 2000 + speciesSurveyCode: SOLELAS + weightEnabled: true +- !SpeciesProtocol + id: f49aadd1-65ea-4820-bed9-583a25761cf6 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1997 + speciesSurveyCode: SOLESEN + weightEnabled: true +- !SpeciesProtocol + id: 220088e3-a661-48a1-a837-ab6a8888f170 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1693 + speciesSurveyCode: SPARAUR + weightEnabled: true +- !SpeciesProtocol + id: e3a09923-8414-4ad9-b131-825f41537ba7 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1874 + speciesSurveyCode: SPHYSPY + weightEnabled: true +- !SpeciesProtocol + id: ccf5602f-99b2-4976-a1b4-b27efedeaeb2 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1721 + speciesSurveyCode: SPICSPP + weightEnabled: true +- !SpeciesProtocol + id: 2d623cc1-c373-4b00-844f-7933d5599b56 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1718 + speciesSurveyCode: SPODCAN + weightEnabled: true +- !SpeciesProtocol + id: 01748fc9-794b-4951-9e0a-e38dfc479f30 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1356 + speciesSurveyCode: SPRASPR + weightEnabled: true +- !SpeciesProtocol + id: d49011fc-ec85-40de-afd0-e0ab033557ff + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1286 + speciesSurveyCode: SQUTSPP + weightEnabled: true +- !SpeciesProtocol + id: 23d7fd79-fa86-4f82-80f6-6a8d84c81171 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 6835 + speciesSurveyCode: STOMBOA + weightEnabled: true +- !SpeciesProtocol + id: 04dfc865-479b-4c52-b1fa-4c9ea6832eba + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 2018 + speciesSurveyCode: SYMPNIG + weightEnabled: true +- !SpeciesProtocol + id: c0331582-7102-4ce4-b3a0-07d49ae7c93e + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1815 + speciesSurveyCode: CALMPHA + weightEnabled: true +- !SpeciesProtocol + id: 9afd6c5b-773c-4d54-a378-5e194f8d5964 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 508 + speciesSurveyCode: TODIEBL + weightEnabled: true +- !SpeciesProtocol + id: d94abbd3-a93b-4ecb-ad20-26da4e3b8516 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1295 + speciesSurveyCode: TORPSPP + weightEnabled: true +- !SpeciesProtocol + id: cd2d62d0-edd9-4033-ad35-c376a5087fdf + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1298 + speciesSurveyCode: TORPNOB + weightEnabled: true +- !SpeciesProtocol + id: 2a676665-dd81-4df7-945e-006ee86ba7b8 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1296 + speciesSurveyCode: TORPTOR + weightEnabled: true +- !SpeciesProtocol + id: f57e191d-a6ec-49c5-a485-b437e5b290d1 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1760 + speciesSurveyCode: TRAHARA + weightEnabled: true +- !SpeciesProtocol + id: b35892d0-732f-4490-a369-32c35ee580cc + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1759 + speciesSurveyCode: TRAHDRA + weightEnabled: true +- !SpeciesProtocol + id: 500570c2-7875-4f17-a865-664c065631f4 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1761 + speciesSurveyCode: TRAHRAD + weightEnabled: true +- !SpeciesProtocol + id: a6c14a6b-f9a8-45be-ac57-0330bf385a05 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1664 + speciesSurveyCode: TRACPIC + weightEnabled: true +- !SpeciesProtocol + id: 729c0fba-b454-4bf8-a41d-6e513b63954f + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1910 + speciesSurveyCode: TRIGLYR + weightEnabled: true +- !SpeciesProtocol + id: dd584b99-1065-475f-8257-eaafc85dc0c8 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1560 + speciesSurveyCode: TRISLUS + weightEnabled: true +- !SpeciesProtocol + id: fb9842ce-13fa-48b8-b294-db418257f706 + countIfNoFrequencyEnabled: true + mandatorySampleCategoryId: [] + speciesReferenceTaxonId: 1764 + speciesSurveyCode: URANSCA + weightEnabled: true +vesselUseFeaturePmfmId: !com.google.common.collect.Lists$TransformingRandomAccessList +- 863 +- 862 +- 173 -- 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 tutti. See http://git.codelutin.com/tutti.git commit a930c6ccc85ba6d2dc3e2ece744905dc93ccbc4d Author: Kevin Morin <morin@codelutin.com> Date: Fri Sep 5 18:44:29 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN --- .../tutti/service/bigfin/BigfinDataRow.java | 10 + .../tutti/service/bigfin/BigfinDataRowModel.java | 31 ++- .../tutti/service/bigfin/BigfinImportResult.java | 24 +- .../tutti/service/bigfin/BigfinImportService.java | 289 ++++++++++++++++----- .../fr/ifremer/tutti/service/bigfin/Signs.java | 33 ++- .../service/bigfin/BigfinImportServiceTest.java | 9 +- .../tutti/ui/swing/action/ImportBigfinAction.java | 14 +- 7 files changed, 298 insertions(+), 112 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRow.java index 111fe39..09475c1 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRow.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRow.java @@ -20,6 +20,7 @@ public class BigfinDataRow implements Serializable { public static final String PROPERTY_DT = "dt"; public static final String PROPERTY_SZ_CLASS = "szClass"; public static final String PROPERTY_GENDER = "gender"; + public static final String PROPERTY_VRAC_HORS_VRAC = "vracHorsVrac"; protected String recordId; protected float length; @@ -29,6 +30,7 @@ public class BigfinDataRow implements Serializable { protected Date dt; protected Signs szClass; protected Signs gender; + protected Signs vracHorsVrac; public String getRecordId() { return recordId; @@ -93,4 +95,12 @@ public class BigfinDataRow implements Serializable { public void setGender(Signs gender) { this.gender = gender; } + + public Signs getVracHorsVrac() { + return vracHorsVrac; + } + + public void setVracHorsVrac(Signs vracHorsVrac) { + this.vracHorsVrac = vracHorsVrac; + } } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java index dd592e6..dd94d7c 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java @@ -5,6 +5,7 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.Sets; +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; @@ -57,17 +58,9 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi result = speciesBySurveyCode.get(value); } -// Si on ne trouve pas une espèce de code campagne XXXXXXX, on essaye alors avec le code XXXX-XXX et vice-versa. +// Si on ne trouve pas une espèce de code campagne XXXXXXX, on essaye alors avec le code XXXX-XXX if (result == null) { - String alternativeSpeciesCode = value; - int i = alternativeSpeciesCode.indexOf('-'); - if (i < 0) { - alternativeSpeciesCode = alternativeSpeciesCode.substring(0, 4) + - '-' + alternativeSpeciesCode.substring(4); - - } else { - alternativeSpeciesCode = alternativeSpeciesCode.substring(0, i) + alternativeSpeciesCode.substring(i + 1); - } + String alternativeSpeciesCode = value.substring(0, 4) + '-' + value.substring(4); result = speciesBySurveyCode.get(alternativeSpeciesCode); } // record the code in the found codes @@ -93,7 +86,7 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi new ValueParser<Signs>() { @Override public Signs parse(String value) throws ParseException { - Signs result = Signs.getSign(value.toUpperCase()); + Signs result = Signs.getSign(value.toUpperCase(), PmfmId2.SIZE_CATEGORY.getValue()); return result; } }); @@ -103,7 +96,7 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi new ValueParser<Signs>() { @Override public Signs parse(String value) throws ParseException { - Signs result = Signs.getSign(value.toUpperCase()); + Signs result = Signs.getSign(value.toUpperCase(), PmfmId2.SEX.getValue()); if (result == null) { throw new ParseException("Could not parse Sign value: " + value, 0); } @@ -111,9 +104,21 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi } }); + newMandatoryColumn("text", BigfinDataRow.PROPERTY_VRAC_HORS_VRAC, new ValueParser<Signs>() { + @Override + public Signs parse(String value) throws ParseException { +// On importe dans le Vrac par défaut, sauf si il y a le texte HV ou hv dans le champ text + Signs result = Signs.getSign(value.toUpperCase(), PmfmId2.SORTED_UNSORTED.getValue()); + if (result == null) { + result = Signs.VRAC; + } + return result; + } + }); + + newIgnoredColumn("cruise"); newIgnoredColumn("pan"); - newIgnoredColumn("text"); } @Override diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java index 287650e..6478e79 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java @@ -22,7 +22,7 @@ package fr.ifremer.tutti.service.bigfin; * #L% */ -import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.referential.Species; import java.io.File; import java.util.ArrayList; @@ -40,9 +40,11 @@ public class BigfinImportResult { protected final List<String> errors = new ArrayList<>(); - protected int nbSortedImported; + protected int nbVracImported; - protected int nbUnsortedImported; + protected int nbHorsVracImported; + + protected final List<Species> speciesNotInProtocol = new ArrayList<>(); public BigfinImportResult(File importFile) { this.importFile = importFile; @@ -52,12 +54,12 @@ public class BigfinImportResult { return importFile; } - public int getNbSortedImported() { - return nbSortedImported; + public int getNbVracImported() { + return nbVracImported; } - public int getNbUnsortedImported() { - return nbUnsortedImported; + public int getNbHorsVracImported() { + return nbHorsVracImported; } public List<String> getErrors() { @@ -65,19 +67,19 @@ public class BigfinImportResult { } void incrementNbSortedImported() { - this.nbSortedImported++; + this.nbVracImported++; } void incrementNbUnsortedImported() { - this.nbUnsortedImported++; + this.nbHorsVracImported++; } void addError(String error) { errors.add(error); } - void addErrors(List<String> errors) { - this.errors.addAll(errors); + void addSpeciesNotInProtocol(Species species) { + speciesNotInProtocol.add(species); } public boolean isDone() { diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java index 7f18157..a8f7683 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java @@ -13,7 +13,9 @@ import com.google.common.collect.Multimaps; import com.google.common.collect.Sets; import com.google.common.io.Files; import fr.ifremer.adagio.core.dao.referential.pmfm.ObjectTypeCode2; +import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm; import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId; +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId2; import fr.ifremer.tutti.persistence.entities.TuttiEntities; @@ -42,11 +44,13 @@ import fr.ifremer.tutti.service.psionimport.PsionImportResult; import fr.ifremer.tutti.util.Weights; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.csv.Import; import org.nuiton.csv.ImportRuntimeException; import org.nuiton.jaxx.application.ApplicationBusinessException; +import org.nuiton.util.DateUtil; import java.io.File; import java.io.Reader; @@ -76,8 +80,6 @@ public class BigfinImportService extends AbstractTuttiService { protected Map<Signs, CaracteristicQualitativeValue> signsToCaracteristicValue; protected Map<String, SpeciesProtocol> speciesProtocolBySurveyCode; - private CaracteristicQualitativeValue sortedCaracteristic; - @Override public void setServiceContext(TuttiServiceContext context) { @@ -89,8 +91,8 @@ public class BigfinImportService extends AbstractTuttiService { { // sorted/unsorted caracteristic Caracteristic caracteristic = persistenceService.getSortedUnsortedCaracteristic(); - - sortedCaracteristic = CaracteristicQualitativeValues.getQualitativeValue(caracteristic, QualitativeValueId.SORTED_VRAC.getValue()); + Signs.VRAC.registerSign(caracteristic, signsToCaracteristicValue); + Signs.HORS_VRAC.registerSign(caracteristic, signsToCaracteristicValue); } { // size caracteristic @@ -146,10 +148,6 @@ public class BigfinImportService extends AbstractTuttiService { } BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); - Set<Species> alreadyUsedSpecies = Sets.newHashSet(); - for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) { - alreadyUsedSpecies.add(speciesBatch.getSpecies()); - } // set of not found species already added in the errors Set<Species> speciesNotRecognized = new HashSet<>(); @@ -176,7 +174,7 @@ public class BigfinImportService extends AbstractTuttiService { Integer station = bean.getStation(); Date dt = bean.getDt(); if (station != null && station.toString().equals(operation.getStationNumber()) - && dt != null && dt.after(operation.getGearShootingStartDate()) && dt.before(operation.getGearShootingEndDate())) { + && dt != null && DateUtils.isSameDay(dt, operation.getGearShootingStartDate())) { if (bean.getSzClass() == null) { String error = t("tutti.service.bigfinImport.error.szClass.unknwon", bean.getRecordId()); @@ -196,23 +194,27 @@ public class BigfinImportService extends AbstractTuttiService { } } else { -// bloquer toute espèce reconnue du protocole mais qui n'a pas de méthode de mesure String code = species.getSurveyCode(); if (code == null) { code = species.getReferenceTaxonId().toString(); } SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(code); - if (speciesProtocol != null && speciesProtocol.getLengthStepPmfmId() == null + +// On n'importe pas les espèces non présentes dans le protocole et +// on liste les espèces/catégorisées non importées pour aider l'utilisateur +// à identifier le problème et on fait l'import des autres + if (speciesProtocol == null) { + result.addSpeciesNotInProtocol(species); + + } else if (speciesProtocol.getLengthStepPmfmId() == null && speciesInProtocolButWithoutLengthStepPmfmId.add(species)) { +// bloquer toute espèce reconnue du protocole mais qui n'a pas de méthode de mesure String error = t("tutti.service.bigfinImport.error.species.without.lengthstep", code); if (log.isWarnEnabled()) { log.warn(error); } result.addError(error); - } else if (alreadyUsedSpecies.contains(species)) { - // TODO on fait quoi ? - } else { rows.add(bean); } @@ -231,7 +233,19 @@ public class BigfinImportService extends AbstractTuttiService { IOUtils.closeQuietly(reader); } + // if no error if (result.isDone()) { + // get the root batches + List<SpeciesBatch> rootSpeciesBatches = rootSpeciesBatch.getChildren(); + // and separate them by species + Multimap<Species, SpeciesBatch> batchesBySpecies = Multimaps.index(rootSpeciesBatches, new Function<SpeciesBatch, Species>() { + @Override + public Species apply(SpeciesBatch input) { + return input.getSpecies(); + } + }); + + // separate the imported rows by species Multimap<Species, BigfinDataRow> rowsBySpecies = Multimaps.index(rows, new Function<BigfinDataRow, Species>() { @Override public Species apply(BigfinDataRow bigfinDataRow) { @@ -239,65 +253,139 @@ public class BigfinImportService extends AbstractTuttiService { } }); + // for each species imported for (Species species : rowsBySpecies.keySet()) { - SpeciesBatch batch = createSpeciesBatch(species, - operation, - PmfmId.SORTED_UNSORTED.getValue(), - sortedCaracteristic, - null); - // new sorted batch imported - result.incrementNbSortedImported(); - - String code = batch.getSpecies().getSurveyCode(); + // get the speciesprotocol and its lengthstep pmfm + String code = species.getSurveyCode(); if (code == null) { code = species.getReferenceTaxonId().toString(); } SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(code); Caracteristic lengthStepPmfm = persistenceService.getCaracteristic(Integer.parseInt(speciesProtocol.getLengthStepPmfmId())); + // get the rows whith the current species and separate them by vrac/hors varc Collection<BigfinDataRow> speciesRows = rowsBySpecies.get(species); - Multimap<CaracteristicQualitativeValue, BigfinDataRow> rowsBySize = - Multimaps.index(speciesRows, new Function<BigfinDataRow, CaracteristicQualitativeValue>() { - @Override - public CaracteristicQualitativeValue apply(BigfinDataRow bigfinDataRow) { - CaracteristicQualitativeValue result = signsToCaracteristicValue.get(bigfinDataRow.getSzClass()); - return result; - } - }); - - for (CaracteristicQualitativeValue size : rowsBySize.keySet()) { - - SpeciesBatch sizeBatch = createSpeciesBatch(species, - operation, - PmfmId.SIZE_CATEGORY.getValue(), - size, - batch.getId()); - - Collection<BigfinDataRow> sizeRows = rowsBySize.get(size); - Multimap<CaracteristicQualitativeValue, BigfinDataRow> rowsByGender = - Multimaps.index(sizeRows, new Function<BigfinDataRow, CaracteristicQualitativeValue>() { - @Override - public CaracteristicQualitativeValue apply(BigfinDataRow bigfinDataRow) { - CaracteristicQualitativeValue result = signsToCaracteristicValue.get(bigfinDataRow.getGender()); - return result; - } - }); - - for (CaracteristicQualitativeValue gender : rowsByGender.keySet()) { - Collection<BigfinDataRow> bigfinDataRows = rowsByGender.get(gender); - - SpeciesBatch genderBatch = createSpeciesBatch(species, - operation, - PmfmId.SEX.getValue(), - gender, - sizeBatch.getId()); - - List<SpeciesBatchFrequency> frequencies = createFrequencies(genderBatch, bigfinDataRows, lengthStepPmfm); - persistenceService.saveSpeciesBatchFrequency(genderBatch.getId(), frequencies); - - } - } + Multimap<Signs, BigfinDataRow> rowsByVracHorsVrac = + Multimaps.index(speciesRows, new Function<BigfinDataRow, Signs>() { + @Override + public Signs apply(BigfinDataRow bigfinDataRow) { + Signs result = bigfinDataRow.getVracHorsVrac(); + return result; + } + }); + + //TODO kmorin 20140905 get categories from the conf + Test[] tests = new Test[] { + new Test(PmfmId.SORTED_UNSORTED, + new Function<BigfinDataRow, Signs>() { + @Override + public Signs apply(BigfinDataRow bigfinDataRow) { + Signs result = bigfinDataRow.getSzClass(); + return result; + } + }), + new Test(PmfmId.SIZE_CATEGORY, + new Function<BigfinDataRow, Signs>() { + @Override + public Signs apply(BigfinDataRow bigfinDataRow) { + Signs result = bigfinDataRow.getGender(); + return result; + } + }), + new Test(PmfmId.SEX, null) + }; + + test(operation, species, lengthStepPmfm, null, tests, 0, rowsByVracHorsVrac); +// // get the batches whose species is the current species and separate them by vrac/hors vrac +// Collection<SpeciesBatch> speciesSpeciesBatches = batchesBySpecies.get(species); +// Map<Serializable, SpeciesBatch> batchesByVracHorsVrac = Maps.uniqueIndex(speciesSpeciesBatches, +// new Function<SpeciesBatch, Serializable>() { +// @Override +// public Serializable apply(SpeciesBatch input) { +// return input.getSampleCategoryValue(); +// } +// }); +// +// // for each imported vrac/hors vrac found for the current species +// for (Signs vracHorsVrac : rowsByVracHorsVrac.keySet()) { +// +// // get the batch with the current vrac/hors vrac value +// SpeciesBatch batch = batchesByVracHorsVrac.get(signsToCaracteristicValue.get(vracHorsVrac)); +// // if it does not exists, create the batch +// if (batch == null) { +// batch = createSpeciesBatch(species, +// operation, +// PmfmId.SORTED_UNSORTED.getValue(), +// vracHorsVrac, +// null); +// } else { +// persistenceService.saveSpeciesBatchFrequency(batch.getId(), new ArrayList<SpeciesBatchFrequency>()); +// } +// +// // new vrac or hors vrac batch imported, increment the number +// if (Signs.VRAC.getQualitativeValueId().equals(vracHorsVrac.getQualitativeValueId())) { +// result.incrementNbSortedImported(); +// } else { +// result.incrementNbUnsortedImported(); +// } +// +// // get the imported rows with the current species and vrac / hors vrac and separate them by size +// Collection<BigfinDataRow> vracHorsVracRows = rowsByVracHorsVrac.get(vracHorsVrac); +// Multimap<Signs, BigfinDataRow> rowsBySize = +// Multimaps.index(vracHorsVracRows, new Function<BigfinDataRow, Signs>() { +// @Override +// public Signs apply(BigfinDataRow bigfinDataRow) { +// Signs result = bigfinDataRow.getSzClass(); +// return result; +// } +// }); +// +// // get the children of the current batch and separate them by size +// List<SpeciesBatch> vracHorsVracBatchChildren = batch.getChildBatchs(); +// Map<Serializable, SpeciesBatch> batchesBySize = new HashMap<>(); +// if (vracHorsVracBatchChildren != null) { +// batchesBySize.putAll(Maps.uniqueIndex(vracHorsVracBatchChildren, +// new Function<SpeciesBatch, Serializable>() { +// @Override +// public Serializable apply(SpeciesBatch input) { +// return input.getSampleCategoryValue(); +// } +// })); +// } +// +// // for each imported size found for the current species and vrac / hors vrac +// for (Signs size : rowsBySize.keySet()) { +// +// // get the batch with the size +// SpeciesBatch sizeBatch = batchesBySize.get(signsToCaracteristicValue.get(size)); +// // if it does not exists, create the batch +// if (sizeBatch == null) { +// sizeBatch = createSpeciesBatch(species, +// operation, +// PmfmId.SIZE_CATEGORY.getValue(), +// size, +// batch.getId()); +// } else { +// persistenceService.saveSpeciesBatchFrequency(sizeBatch.getId(), new ArrayList<SpeciesBatchFrequency>()); +// } +// +// // get the imported rows with the current species and vrac / hors vrac and size +// // and separate them by gender +// Collection<BigfinDataRow> sizeRows = rowsBySize.get(size); +// Multimap<Signs, BigfinDataRow> rowsByGender = +// Multimaps.index(sizeRows, new Function<BigfinDataRow, Signs>() { +// @Override +// public Signs apply(BigfinDataRow bigfinDataRow) { +// Signs result = bigfinDataRow.getGender(); +// return result; +// } +// }); +// test(operation, species, lengthStepPmfm, sizeBatch, PmfmId2.SEX, rowsByGender, true); +// +// +// } +// } } addFileAsAttachment(bigfinFile, catchBatch); @@ -306,24 +394,79 @@ public class BigfinImportService extends AbstractTuttiService { return result; } + //TODO kmorin 20140905 check why data are not overriden + protected void test(FishingOperation operation, + Species species, + Caracteristic lengthStepPmfm, + SpeciesBatch parentBatch, + Test[] tests, + int depth, + Multimap<Signs, BigfinDataRow> rowsByCaracteristic) { + + // get the children of the current batch and separate them by gender + List<SpeciesBatch> batchChildren = parentBatch != null ? parentBatch.getChildBatchs() : null; + Map<Serializable, SpeciesBatch> batchesByCaracteristic = new HashMap<>(); + if (batchChildren != null) { + batchesByCaracteristic.putAll(Maps.uniqueIndex(batchChildren, + new Function<SpeciesBatch, Serializable>() { + @Override + public Serializable apply(SpeciesBatch input) { + return input.getSampleCategoryValue(); + } + })); + } + + Test test = tests[depth++]; + + for (Signs caracteristic : rowsByCaracteristic.keySet()) { + Collection<BigfinDataRow> bigfinDataRows = rowsByCaracteristic.get(caracteristic); + + // get the batch with the gender + SpeciesBatch batch = batchesByCaracteristic.get(signsToCaracteristicValue.get(caracteristic)); + // if it does not exists, create the batch + if (batch == null) { + batch = createSpeciesBatch(species, + operation, + test.pmfmId.getValue(), + caracteristic, + parentBatch != null ? parentBatch.getId() : null); + } + + if (test.function != null) { + Multimap<Signs, BigfinDataRow> rowsByNewCaracteristic = + Multimaps.index(bigfinDataRows, test.function); + + test(operation, species, lengthStepPmfm, batch, tests, depth, rowsByNewCaracteristic); + + } else { + List<SpeciesBatchFrequency> frequencies = createFrequencies(batch, bigfinDataRows, lengthStepPmfm); + persistenceService.saveSpeciesBatchFrequency(batch.getId(), frequencies); + } + + } + } + protected SpeciesBatch createSpeciesBatch(Species species, FishingOperation operation, Integer categoryId, - Serializable categoryValue, + Signs signs, String parentBatchId) { + + Preconditions.checkArgument(signs.getCategory().equals(categoryId)); + SpeciesBatch batch = SpeciesBatchs.newSpeciesBatch(); batch.setSpecies(species); batch.setFishingOperation(operation); - //TODO check in text if hv + batch.setSampleCategoryId(categoryId); - batch.setSampleCategoryValue(categoryValue); + batch.setSampleCategoryValue(signsToCaracteristicValue.get(signs)); batch = persistenceService.createSpeciesBatch(batch, parentBatchId); return batch; } protected List<SpeciesBatchFrequency> createFrequencies(SpeciesBatch batch, Collection<BigfinDataRow> rows, Caracteristic lengthStepPmfm) { - //TODO on fait quoi si lengthStepPmfm est nul? + Preconditions.checkNotNull(lengthStepPmfm); String unit = lengthStepPmfm.getUnit(); Float precision = lengthStepPmfm.getPrecision(); if (precision == null) { @@ -387,4 +530,14 @@ public class BigfinImportService extends AbstractTuttiService { attachment.setComment(comment); persistenceService.createAttachment(attachment, f); } + + protected class Test { + PmfmId pmfmId; + Function<BigfinDataRow, Signs> function; + + public Test(PmfmId pmfmId, Function<BigfinDataRow, Signs> function) { + this.pmfmId = pmfmId; + this.function = function; + } + } } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java index 524884d..169a14d 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java @@ -48,7 +48,7 @@ public enum Signs { @Override public Integer getQualitativeValueId() { - return QualitativeValueId2.SEX_UNDEFINED.getValue(); + return QualitativeValueId.NON_SEXED_SEX.getValue(); } }, MALE("M") { @@ -107,6 +107,30 @@ public enum Signs { public Integer getQualitativeValueId() { return QualitativeValueId.SIZE_BIG.getValue(); } + }, + + // vrac / hors vrac + VRAC("") { + @Override + public Integer getCategory() { + return PmfmId2.SORTED_UNSORTED.getValue(); + } + + @Override + public Integer getQualitativeValueId() { + return QualitativeValueId.SORTED_VRAC.getValue(); + } + }, + HORS_VRAC("HV") { + @Override + public Integer getCategory() { + return PmfmId2.SORTED_UNSORTED.getValue(); + } + + @Override + public Integer getQualitativeValueId() { + return QualitativeValueId.SORTED_HORS_VRAC.getValue(); + } }; private String sign; @@ -120,9 +144,14 @@ public enum Signs { } public static Signs getSign(String sign) { + Signs result = getSign(sign, null); + return result; + } + public static Signs getSign(String sign, Integer categoryId) { Signs result = null; for (Signs s : values()) { - if (s.sign.equals(sign)) { + if (s.sign.equals(sign) && + (categoryId == null || s.getCategory().equals(categoryId))) { result = s; break; } diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java index 5db965b..5846a42 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java @@ -14,7 +14,6 @@ import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.ServiceDbResource; import fr.ifremer.tutti.service.TuttiServiceContext; -import fr.ifremer.tutti.service.psionimport.PsionImportService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; @@ -100,8 +99,8 @@ public class BigfinImportServiceTest { BigfinImportResult importResult = service.importFile(importFile, operation, catchBatch); - int nbSortedAdded = importResult.getNbSortedImported(); - int nbUnsortedAdded = importResult.getNbUnsortedImported(); + int nbSortedAdded = importResult.getNbVracImported(); + int nbUnsortedAdded = importResult.getNbHorsVracImported(); List<String> errors = importResult.getErrors(); if (log.isInfoEnabled()) { @@ -152,8 +151,8 @@ public class BigfinImportServiceTest { BigfinImportResult importResult = service.importFile(importFile, operation, catchBatch); - int nbSortedAdded = importResult.getNbSortedImported(); - int nbUnsortedAdded = importResult.getNbUnsortedImported(); + int nbSortedAdded = importResult.getNbVracImported(); + int nbUnsortedAdded = importResult.getNbHorsVracImported(); List<String> errors = importResult.getErrors(); if (log.isInfoEnabled()) { diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java index 729da55..e615f14 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java @@ -22,31 +22,19 @@ package fr.ifremer.tutti.ui.swing.action; * #L% */ -import com.google.common.base.Joiner; -import com.google.common.collect.Lists; -import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.bigfin.BigfinImportResult; import fr.ifremer.tutti.service.bigfin.BigfinImportService; -import fr.ifremer.tutti.service.psionimport.PsionImportResult; -import fr.ifremer.tutti.service.psionimport.PsionImportService; -import fr.ifremer.tutti.service.pupitri.PupitriImportExportService; -import fr.ifremer.tutti.service.pupitri.PupitriImportResult; import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; -import fr.ifremer.tutti.ui.swing.content.operation.catches.species.ImportPupitriPopupUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchUIModel; -import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; -import javax.swing.*; import java.io.File; -import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -128,7 +116,7 @@ public class ImportBigfinAction extends AbstractTuttiAction<SpeciesBatchUIModel, if (importResult.isDone()) { sendMessage(t("tutti.editSpeciesBatch.action.importBigfin.success", - importResult.getNbSortedImported(), importResult.getNbUnsortedImported())); + importResult.getNbVracImported(), importResult.getNbHorsVracImported())); } else { StringBuilder sb = new StringBuilder(); -- 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 tutti. See http://git.codelutin.com/tutti.git commit c5d1675e20130d1ad8801477519a9eacb3611506 Author: Kevin Morin <morin@codelutin.com> Date: Tue Sep 9 07:57:22 2014 +0200 refs #5411 [CAPTURE] Import BIGFIN --- .../persistence/entities/data/SpeciesBatchs.java | 21 ++ .../i18n/tutti-persistence_en_GB.properties | 24 ++ .../i18n/tutti-persistence_fr_FR.properties | 24 ++ .../tutti/service/bigfin/BigfinImportResult.java | 32 +- .../tutti/service/bigfin/BigfinImportService.java | 405 ++++++++++++--------- .../fr/ifremer/tutti/service/bigfin/Signs.java | 44 +++ .../resources/i18n/tutti-service_en_GB.properties | 5 + .../resources/i18n/tutti-service_fr_FR.properties | 4 + .../service/bigfin/BigfinImportServiceTest.java | 91 +++-- .../tutti/ui/swing/action/ImportBigfinAction.java | 25 +- .../resources/i18n/tutti-ui-swing_en_GB.properties | 5 + .../resources/i18n/tutti-ui-swing_fr_FR.properties | 10 +- 12 files changed, 451 insertions(+), 239 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SpeciesBatchs.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SpeciesBatchs.java new file mode 100644 index 0000000..3c8741e --- /dev/null +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/SpeciesBatchs.java @@ -0,0 +1,21 @@ +package fr.ifremer.tutti.persistence.entities.data; + +import com.google.common.base.Function; + +import java.io.Serializable; + +/** + * @author Kevin Morin (Code Lutin) + * @since x.x + */ +public class SpeciesBatchs extends AbstractSpeciesBatchs { + + public static final Function<SpeciesBatch, Serializable> GET_SAMPLE_CATEGORY_VALUE = + new Function<SpeciesBatch, Serializable>() { + @Override + public Serializable apply(SpeciesBatch input) { + return input.getSampleCategoryValue(); + } + }; + +} diff --git a/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties b/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties index aab6417..adbacf1 100644 --- a/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties +++ b/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties @@ -1,4 +1,28 @@ adagio.enumeration.PmfmId.ID_PSFM.description= +adagio.enumeration.PmfmId.MARINE_LITTER_SIZE_CATEGORY.description= +adagio.enumeration.PmfmId.MARINE_LITTER_TYPE.description= +adagio.enumeration.PmfmId.MATURITY.description= +adagio.enumeration.PmfmId.MULTIRIG_AGGREGATION.description= +adagio.enumeration.PmfmId.MULTIRIG_NUMBER.description= +adagio.enumeration.PmfmId.RECTILINEAR_OPERATION.description= +adagio.enumeration.PmfmId.SCIENTIFIC_CRUISE_SORTING_TYPE.description= +adagio.enumeration.PmfmId.SCIENTIFIC_CRUISE_SORTING_TYPE2.description= +adagio.enumeration.PmfmId.SEX.description= +adagio.enumeration.PmfmId.SIZE_CATEGORY.description= +adagio.enumeration.PmfmId.SORTED_UNSORTED.description= +adagio.enumeration.PmfmId.SORTING_TYPE_TCC.description= +adagio.enumeration.PmfmId.STATION_NUMBER.description= +adagio.enumeration.PmfmId.SURVEY_PART.description= +adagio.enumeration.PmfmId.TRAWL_DISTANCE.description= +adagio.enumeration.PmfmId.VERTICAL_OPENING.description= +adagio.enumeration.PmfmId.WEIGHT_MEASURED.description= +adagio.enumeration.QualitativeValueId.MATURITY_1.description= +adagio.enumeration.QualitativeValueId.MATURITY_2.description= +adagio.enumeration.QualitativeValueId.MATURITY_3.description= +adagio.enumeration.QualitativeValueId.MATURITY_4.description= +adagio.enumeration.QualitativeValueId.MATURITY_5.description= +adagio.enumeration.QualitativeValueId.NOT_SIZED.description= +adagio.enumeration.QualitativeValueId.SEX_UNDEFINED.description= application.common.unit=Unit application.common.unit.g=Gram application.common.unit.kg=Kilogram diff --git a/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties b/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties index f637ac0..30a0de2 100644 --- a/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties +++ b/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties @@ -1,4 +1,28 @@ adagio.enumeration.PmfmId.ID_PSFM.description= +adagio.enumeration.PmfmId.MARINE_LITTER_SIZE_CATEGORY.description= +adagio.enumeration.PmfmId.MARINE_LITTER_TYPE.description= +adagio.enumeration.PmfmId.MATURITY.description= +adagio.enumeration.PmfmId.MULTIRIG_AGGREGATION.description= +adagio.enumeration.PmfmId.MULTIRIG_NUMBER.description= +adagio.enumeration.PmfmId.RECTILINEAR_OPERATION.description= +adagio.enumeration.PmfmId.SCIENTIFIC_CRUISE_SORTING_TYPE.description= +adagio.enumeration.PmfmId.SCIENTIFIC_CRUISE_SORTING_TYPE2.description= +adagio.enumeration.PmfmId.SEX.description= +adagio.enumeration.PmfmId.SIZE_CATEGORY.description= +adagio.enumeration.PmfmId.SORTED_UNSORTED.description= +adagio.enumeration.PmfmId.SORTING_TYPE_TCC.description= +adagio.enumeration.PmfmId.STATION_NUMBER.description= +adagio.enumeration.PmfmId.SURVEY_PART.description= +adagio.enumeration.PmfmId.TRAWL_DISTANCE.description= +adagio.enumeration.PmfmId.VERTICAL_OPENING.description= +adagio.enumeration.PmfmId.WEIGHT_MEASURED.description= +adagio.enumeration.QualitativeValueId.MATURITY_1.description= +adagio.enumeration.QualitativeValueId.MATURITY_2.description= +adagio.enumeration.QualitativeValueId.MATURITY_3.description= +adagio.enumeration.QualitativeValueId.MATURITY_4.description= +adagio.enumeration.QualitativeValueId.MATURITY_5.description= +adagio.enumeration.QualitativeValueId.NOT_SIZED.description= +adagio.enumeration.QualitativeValueId.SEX_UNDEFINED.description= application.common.unit=Unité application.common.unit.g=Gramme application.common.unit.kg=Kilogramme diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java index 6478e79..407f10c 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java @@ -38,11 +38,13 @@ public class BigfinImportResult { protected final File importFile; + protected final List<String> fatalErrors = new ArrayList<>(); + protected final List<String> errors = new ArrayList<>(); - protected int nbVracImported; + protected int nbFrequenciesImported; - protected int nbHorsVracImported; + protected int nbFrequenciesDeleted; protected final List<Species> speciesNotInProtocol = new ArrayList<>(); @@ -54,24 +56,32 @@ public class BigfinImportResult { return importFile; } - public int getNbVracImported() { - return nbVracImported; + public int getNbFrequenciesImported() { + return nbFrequenciesImported; + } + + public int getNbFrequenciesDeleted() { + return nbFrequenciesDeleted; } - public int getNbHorsVracImported() { - return nbHorsVracImported; + public List<String> getFatalErrors() { + return fatalErrors; } public List<String> getErrors() { return errors; } - void incrementNbSortedImported() { - this.nbVracImported++; + void incrementNbFrequenciesImported(int nb) { + this.nbFrequenciesImported += nb; + } + + void incrementNbFrequenciesDeleted(int nb) { + this.nbFrequenciesDeleted += nb; } - void incrementNbUnsortedImported() { - this.nbHorsVracImported++; + void addFatalError(String error) { + fatalErrors.add(error); } void addError(String error) { @@ -83,6 +93,6 @@ public class BigfinImportResult { } public boolean isDone() { - return errors.isEmpty(); + return fatalErrors.isEmpty(); } } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java index a8f7683..1f40312 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java @@ -4,44 +4,34 @@ import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableSet; import com.google.common.collect.ListMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; -import com.google.common.collect.Sets; import com.google.common.io.Files; import fr.ifremer.adagio.core.dao.referential.pmfm.ObjectTypeCode2; -import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm; import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId; -import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; -import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; -import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId2; -import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.Attachments; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchBean; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; -import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencyBean; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencys; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchs; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; -import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValues; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.service.AbstractTuttiService; -import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.TuttiServiceContext; -import fr.ifremer.tutti.service.psionimport.PsionImportResult; import fr.ifremer.tutti.util.Weights; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; @@ -50,7 +40,6 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.csv.Import; import org.nuiton.csv.ImportRuntimeException; import org.nuiton.jaxx.application.ApplicationBusinessException; -import org.nuiton.util.DateUtil; import java.io.File; import java.io.Reader; @@ -77,6 +66,9 @@ public class BigfinImportService extends AbstractTuttiService { protected PersistenceService persistenceService; + protected Caracteristic sizeCaracteristic; + protected Caracteristic genderCaracteristic; + protected Map<Signs, CaracteristicQualitativeValue> signsToCaracteristicValue; protected Map<String, SpeciesProtocol> speciesProtocolBySurveyCode; @@ -96,17 +88,17 @@ public class BigfinImportService extends AbstractTuttiService { } { // size caracteristic - Caracteristic caracteristic = persistenceService.getSizeCategoryCaracteristic(); - Signs.NOT_SIZED.registerSign(caracteristic, signsToCaracteristicValue); - Signs.SMALL.registerSign(caracteristic, signsToCaracteristicValue); - Signs.BIG.registerSign(caracteristic, signsToCaracteristicValue); + sizeCaracteristic = persistenceService.getSizeCategoryCaracteristic(); + Signs.NOT_SIZED.registerSign(sizeCaracteristic, signsToCaracteristicValue); + Signs.SMALL.registerSign(sizeCaracteristic, signsToCaracteristicValue); + Signs.BIG.registerSign(sizeCaracteristic, signsToCaracteristicValue); } { // sex caracteristic - Caracteristic caracteristic = persistenceService.getSexCaracteristic(); - Signs.NOT_SEXED.registerSign(caracteristic, signsToCaracteristicValue); - Signs.MALE.registerSign(caracteristic, signsToCaracteristicValue); - Signs.FEMALE.registerSign(caracteristic, signsToCaracteristicValue); + genderCaracteristic = persistenceService.getSexCaracteristic(); + Signs.NOT_SEXED.registerSign(genderCaracteristic, signsToCaracteristicValue); + Signs.MALE.registerSign(genderCaracteristic, signsToCaracteristicValue); + Signs.FEMALE.registerSign(genderCaracteristic, signsToCaracteristicValue); } } @@ -181,7 +173,7 @@ public class BigfinImportService extends AbstractTuttiService { if (log.isWarnEnabled()) { log.warn(error); } - result.addError(error); + result.addFatalError(error); } if (species == null || species.getId() == null) { // bloquer tout si un "species" ne match pas le référentiel de Tutti : lister dans ce cas les codes non reconnus @@ -190,7 +182,7 @@ public class BigfinImportService extends AbstractTuttiService { if (log.isWarnEnabled()) { log.warn(error); } - result.addError(error); + result.addFatalError(error); } } else { @@ -209,11 +201,15 @@ public class BigfinImportService extends AbstractTuttiService { } else if (speciesProtocol.getLengthStepPmfmId() == null && speciesInProtocolButWithoutLengthStepPmfmId.add(species)) { // bloquer toute espèce reconnue du protocole mais qui n'a pas de méthode de mesure - String error = t("tutti.service.bigfinImport.error.species.without.lengthstep", code); + String speciesLabel = species.getSurveyCode(); + if (StringUtils.isBlank(speciesLabel)) { + speciesLabel = species.getRefTaxCode(); + } + String error = t("tutti.service.bigfinImport.error.species.without.lengthstep", speciesLabel); if (log.isWarnEnabled()) { log.warn(error); } - result.addError(error); + result.addFatalError(error); } else { rows.add(bean); @@ -264,7 +260,7 @@ public class BigfinImportService extends AbstractTuttiService { SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(code); Caracteristic lengthStepPmfm = persistenceService.getCaracteristic(Integer.parseInt(speciesProtocol.getLengthStepPmfmId())); - // get the rows whith the current species and separate them by vrac/hors varc + // get the rows with the current species and separate them by vrac/hors varc Collection<BigfinDataRow> speciesRows = rowsBySpecies.get(species); Multimap<Signs, BigfinDataRow> rowsByVracHorsVrac = Multimaps.index(speciesRows, new Function<BigfinDataRow, Signs>() { @@ -275,117 +271,49 @@ public class BigfinImportService extends AbstractTuttiService { } }); - //TODO kmorin 20140905 get categories from the conf - Test[] tests = new Test[] { - new Test(PmfmId.SORTED_UNSORTED, - new Function<BigfinDataRow, Signs>() { - @Override - public Signs apply(BigfinDataRow bigfinDataRow) { - Signs result = bigfinDataRow.getSzClass(); - return result; - } - }), - new Test(PmfmId.SIZE_CATEGORY, - new Function<BigfinDataRow, Signs>() { - @Override - public Signs apply(BigfinDataRow bigfinDataRow) { - Signs result = bigfinDataRow.getGender(); - return result; - } - }), - new Test(PmfmId.SEX, null) - }; - - test(operation, species, lengthStepPmfm, null, tests, 0, rowsByVracHorsVrac); -// // get the batches whose species is the current species and separate them by vrac/hors vrac -// Collection<SpeciesBatch> speciesSpeciesBatches = batchesBySpecies.get(species); -// Map<Serializable, SpeciesBatch> batchesByVracHorsVrac = Maps.uniqueIndex(speciesSpeciesBatches, -// new Function<SpeciesBatch, Serializable>() { -// @Override -// public Serializable apply(SpeciesBatch input) { -// return input.getSampleCategoryValue(); -// } -// }); -// -// // for each imported vrac/hors vrac found for the current species -// for (Signs vracHorsVrac : rowsByVracHorsVrac.keySet()) { -// -// // get the batch with the current vrac/hors vrac value -// SpeciesBatch batch = batchesByVracHorsVrac.get(signsToCaracteristicValue.get(vracHorsVrac)); -// // if it does not exists, create the batch -// if (batch == null) { -// batch = createSpeciesBatch(species, -// operation, -// PmfmId.SORTED_UNSORTED.getValue(), -// vracHorsVrac, -// null); -// } else { -// persistenceService.saveSpeciesBatchFrequency(batch.getId(), new ArrayList<SpeciesBatchFrequency>()); -// } -// -// // new vrac or hors vrac batch imported, increment the number -// if (Signs.VRAC.getQualitativeValueId().equals(vracHorsVrac.getQualitativeValueId())) { -// result.incrementNbSortedImported(); -// } else { -// result.incrementNbUnsortedImported(); -// } -// -// // get the imported rows with the current species and vrac / hors vrac and separate them by size -// Collection<BigfinDataRow> vracHorsVracRows = rowsByVracHorsVrac.get(vracHorsVrac); -// Multimap<Signs, BigfinDataRow> rowsBySize = -// Multimaps.index(vracHorsVracRows, new Function<BigfinDataRow, Signs>() { -// @Override -// public Signs apply(BigfinDataRow bigfinDataRow) { -// Signs result = bigfinDataRow.getSzClass(); -// return result; -// } -// }); -// -// // get the children of the current batch and separate them by size -// List<SpeciesBatch> vracHorsVracBatchChildren = batch.getChildBatchs(); -// Map<Serializable, SpeciesBatch> batchesBySize = new HashMap<>(); -// if (vracHorsVracBatchChildren != null) { -// batchesBySize.putAll(Maps.uniqueIndex(vracHorsVracBatchChildren, -// new Function<SpeciesBatch, Serializable>() { -// @Override -// public Serializable apply(SpeciesBatch input) { -// return input.getSampleCategoryValue(); -// } -// })); -// } -// -// // for each imported size found for the current species and vrac / hors vrac -// for (Signs size : rowsBySize.keySet()) { -// -// // get the batch with the size -// SpeciesBatch sizeBatch = batchesBySize.get(signsToCaracteristicValue.get(size)); -// // if it does not exists, create the batch -// if (sizeBatch == null) { -// sizeBatch = createSpeciesBatch(species, -// operation, -// PmfmId.SIZE_CATEGORY.getValue(), -// size, -// batch.getId()); -// } else { -// persistenceService.saveSpeciesBatchFrequency(sizeBatch.getId(), new ArrayList<SpeciesBatchFrequency>()); -// } -// -// // get the imported rows with the current species and vrac / hors vrac and size -// // and separate them by gender -// Collection<BigfinDataRow> sizeRows = rowsBySize.get(size); -// Multimap<Signs, BigfinDataRow> rowsByGender = -// Multimaps.index(sizeRows, new Function<BigfinDataRow, Signs>() { -// @Override -// public Signs apply(BigfinDataRow bigfinDataRow) { -// Signs result = bigfinDataRow.getGender(); -// return result; -// } -// }); -// test(operation, species, lengthStepPmfm, sizeBatch, PmfmId2.SEX, rowsByGender, true); -// -// -// } -// } + SampleCategoryModel sampleCategoryModel = context.getSampleCategoryModel(); + List<Integer> samplingOrder = sampleCategoryModel.getSamplingOrder(); + + List<Integer> pmfmIds = new ArrayList<>(); + pmfmIds.add(PmfmId.SORTED_UNSORTED.getValue()); + List<Function<BigfinDataRow, Signs>> functions = new ArrayList<>(); + + // put the size and order in the right order + for (Integer categoryId: samplingOrder) { + if (PmfmId.SIZE_CATEGORY.getValue().equals(categoryId)) { + pmfmIds.add(categoryId); + functions.add(new Function<BigfinDataRow, Signs>() { + @Override + public Signs apply(BigfinDataRow bigfinDataRow) { + Signs result = bigfinDataRow.getSzClass(); + return result; + } + }); + + } else if (PmfmId.SEX.getValue().equals(categoryId)) { + pmfmIds.add(categoryId); + functions.add(new Function<BigfinDataRow, Signs>() { + @Override + public Signs apply(BigfinDataRow bigfinDataRow) { + Signs result = bigfinDataRow.getGender(); + return result; + } + }); + } + } + + List<Category> categories = new ArrayList<>(); + for (int i = 0 ; i < pmfmIds.size() ; i++) { + Category category = new Category(pmfmIds.get(i), i < functions.size() ? functions.get(i) : null); + categories.add(category); + } + + Collection<SpeciesBatch> speciesBatches = batchesBySpecies.get(species); + Map<Serializable, SpeciesBatch> speciesBatchByVracHorsVrac = Maps.uniqueIndex(speciesBatches, SpeciesBatchs.GET_SAMPLE_CATEGORY_VALUE); + + BrowseBatchesParameter commonParameter = new BrowseBatchesParameter(operation, species, + lengthStepPmfm, categories, result); + browseBatchesToAddFrequencies(commonParameter, null, 0, speciesBatchByVracHorsVrac, rowsByVracHorsVrac); } addFileAsAttachment(bigfinFile, catchBatch); @@ -394,53 +322,116 @@ public class BigfinImportService extends AbstractTuttiService { return result; } - //TODO kmorin 20140905 check why data are not overriden - protected void test(FishingOperation operation, - Species species, - Caracteristic lengthStepPmfm, + /** + * Go deeper in the batches until it finds the last of gender or size class, then add the frequencies + * + * @param commonParameter The parameter containing the parameters which do not change while browsing + * @param parentBatch The parent batch (null if root) + * @param depth The depth in the batch children + * @param batchesByCaracteristic a map containing the batches by caracteristic value + * @param rowsByCaracteristic a multimap containing the rows to import by caracteristic value + */ + protected void browseBatchesToAddFrequencies(BrowseBatchesParameter commonParameter, SpeciesBatch parentBatch, - Test[] tests, int depth, + Map<Serializable, SpeciesBatch> batchesByCaracteristic, Multimap<Signs, BigfinDataRow> rowsByCaracteristic) { - // get the children of the current batch and separate them by gender - List<SpeciesBatch> batchChildren = parentBatch != null ? parentBatch.getChildBatchs() : null; - Map<Serializable, SpeciesBatch> batchesByCaracteristic = new HashMap<>(); - if (batchChildren != null) { - batchesByCaracteristic.putAll(Maps.uniqueIndex(batchChildren, - new Function<SpeciesBatch, Serializable>() { - @Override - public Serializable apply(SpeciesBatch input) { - return input.getSampleCategoryValue(); - } - })); - } - - Test test = tests[depth++]; + Category category = commonParameter.getCategories().get(depth++); for (Signs caracteristic : rowsByCaracteristic.keySet()) { Collection<BigfinDataRow> bigfinDataRows = rowsByCaracteristic.get(caracteristic); - // get the batch with the gender + // get the batch with the caracteristic SpeciesBatch batch = batchesByCaracteristic.get(signsToCaracteristicValue.get(caracteristic)); + + boolean batchHasFrequencies = false; + // if it does not exists, create the batch if (batch == null) { - batch = createSpeciesBatch(species, - operation, - test.pmfmId.getValue(), + batch = createSpeciesBatch(commonParameter.getSpecies(), + commonParameter.getOperation(), + category.getPmfmId(), caracteristic, parentBatch != null ? parentBatch.getId() : null); + + } else { + List<SpeciesBatchFrequency> frequencies = persistenceService.getAllSpeciesBatchFrequency(batch.getId()); + batchHasFrequencies = CollectionUtils.isNotEmpty(frequencies); } - if (test.function != null) { - Multimap<Signs, BigfinDataRow> rowsByNewCaracteristic = - Multimaps.index(bigfinDataRows, test.function); + // if the function is null, do not go deeper in the batch children, add the frequencies in this batch + if (category.getCategoryValueGetter() == null) { + // if the batch is not the last one, error, we cannot add the frequencies to a more categorized batch + if (CollectionUtils.isNotEmpty(batch.getChildBatchs())) { + commonParameter.getResult().addError(t("tutti.service.bigfinImport.error.species.tooCategorized", + commonParameter.getSpeciesLabel(), + sizeCaracteristic.getParameterName(), + genderCaracteristic.getParameterName())); + + } else { + // create the frequencies + Integer deletedNb = persistenceService.countFrequenciesNumber( + persistenceService.getAllSpeciesBatchFrequency(batch.getId()), false); + List<SpeciesBatchFrequency> frequencies = createFrequencies(batch, bigfinDataRows, commonParameter.getLengthStepPmfm()); + persistenceService.saveSpeciesBatchFrequency(batch.getId(), frequencies); + commonParameter.getResult().incrementNbFrequenciesDeleted(deletedNb != null ? deletedNb : 0); + Integer importedNb = persistenceService.countFrequenciesNumber(frequencies, false); + commonParameter.getResult().incrementNbFrequenciesImported(importedNb != null ? importedNb : 0); + } - test(operation, species, lengthStepPmfm, batch, tests, depth, rowsByNewCaracteristic); + } else if (batchHasFrequencies) { // if the batch is supposed to be categorized again, but already has frequencies + CaracteristicQualitativeValue qualitativeValue = signsToCaracteristicValue.get(caracteristic); + commonParameter.getResult().addError(t("tutti.service.bigfinImport.error.species.batch.frequenciesOnHigherLevel", + commonParameter.getSpeciesLabel(), qualitativeValue.getName())); } else { - List<SpeciesBatchFrequency> frequencies = createFrequencies(batch, bigfinDataRows, lengthStepPmfm); - persistenceService.saveSpeciesBatchFrequency(batch.getId(), frequencies); + List<SpeciesBatch> batchChildren = batch.getChildBatchs(); + + Multimap<Signs, BigfinDataRow> rowsByNewCaracteristic = Multimaps.index(bigfinDataRows, category.getCategoryValueGetter()); + + // get the children of the current batch and separate them by caracteristic + Map<Serializable, SpeciesBatch> childrenByCaracteristic = new HashMap<>(); + if (CollectionUtils.isNotEmpty(batchChildren)) { + + SpeciesBatch firstBatch = batchChildren.get(0); + Integer categoryId = firstBatch.getSampleCategoryId(); + Category nextCategory = commonParameter.getCategories().get(depth); + + // check the category is the right next one + if (!nextCategory.getPmfmId().equals(categoryId)) { + // if all the rows to import have a gender or size (the first category in the list) null equivalent + // then ok + // else error + Set<Signs> signsSet = rowsByNewCaracteristic.keySet(); + if (signsSet.size() == 1 && signsSet.iterator().next().isNullEquivalent()) {// we can go deeper + category = commonParameter.getCategories().get(depth++); + rowsByNewCaracteristic = Multimaps.index(bigfinDataRows, category.getCategoryValueGetter()); + + // check that this time, it is the right category. We can only skip one + nextCategory = commonParameter.getCategories().get(depth); + if (!nextCategory.getPmfmId().equals(categoryId)) { + commonParameter.getResult().addError(t("tutti.service.bigfinImport.error.species.categoriesSkipped", + commonParameter.getSpeciesLabel(), + sizeCaracteristic.getParameterName(), + genderCaracteristic.getParameterName() + )); + continue; + } + + } else { + commonParameter.getResult().addError(t("tutti.service.bigfinImport.error.species.categorySkipped", + commonParameter.getSpeciesLabel(), + persistenceService.getCaracteristic(nextCategory.getPmfmId()).getParameterName() + )); + continue; + } + } + childrenByCaracteristic.putAll(Maps.uniqueIndex(batchChildren, SpeciesBatchs.GET_SAMPLE_CATEGORY_VALUE)); + } + + // go deeper in the batch children + browseBatchesToAddFrequencies(commonParameter, batch, depth, childrenByCaracteristic, rowsByNewCaracteristic); } } @@ -531,13 +522,83 @@ public class BigfinImportService extends AbstractTuttiService { persistenceService.createAttachment(attachment, f); } - protected class Test { - PmfmId pmfmId; - Function<BigfinDataRow, Signs> function; + /** + * Class describing the category of a batch level and the function to separate the rows to import by category value + */ + private class Category { - public Test(PmfmId pmfmId, Function<BigfinDataRow, Signs> function) { + private Integer pmfmId; + /** function to get the value of the caracteristic we want to group the batches by (eg size or gender) */ + private Function<BigfinDataRow, Signs> categoryValueGetter; + + public Category(Integer pmfmId, Function<BigfinDataRow, Signs> dataGetter) { this.pmfmId = pmfmId; - this.function = function; + this.categoryValueGetter = dataGetter; + } + + public Integer getPmfmId() { + return pmfmId; + } + + public Function<BigfinDataRow, Signs> getCategoryValueGetter() { + return categoryValueGetter; + } + } + + /** + * Class containing the common parameters for the batch browsing + * These parameter do not change when you go deeper. + */ + private class BrowseBatchesParameter { + /** the current fishing operation */ + private FishingOperation operation; + /** the current species */ + private Species species; + /** the lengthstep caracteristic found in the protocol */ + private Caracteristic lengthStepPmfm; + /** the ordered categories */ + private List<Category> categories; + /** the result of the import (to add the errors) */ + private BigfinImportResult result; + /** label for the species in the errors */ + private String speciesLabel; + + public BrowseBatchesParameter(FishingOperation operation, Species species, Caracteristic lengthStepPmfm, + List<Category> categories, BigfinImportResult result) { + this.operation = operation; + this.species = species; + this.lengthStepPmfm = lengthStepPmfm; + this.categories = categories; + this.result = result; + + speciesLabel = species.getSurveyCode(); + if (StringUtils.isBlank(speciesLabel)) { + speciesLabel = species.getRefTaxCode(); + } + } + + public FishingOperation getOperation() { + return operation; + } + + public Species getSpecies() { + return species; + } + + public Caracteristic getLengthStepPmfm() { + return lengthStepPmfm; + } + + public List<Category> getCategories() { + return categories; + } + + public BigfinImportResult getResult() { + return result; + } + + public String getSpeciesLabel() { + return speciesLabel; } } } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java index 169a14d..208325e 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java @@ -50,6 +50,11 @@ public enum Signs { public Integer getQualitativeValueId() { return QualitativeValueId.NON_SEXED_SEX.getValue(); } + + @Override + public boolean isNullEquivalent() { + return true; + } }, MALE("M") { @Override @@ -61,6 +66,11 @@ public enum Signs { public Integer getQualitativeValueId() { return QualitativeValueId.SEX_MALE.getValue(); } + + @Override + public boolean isNullEquivalent() { + return false; + } }, FEMALE("F") { @Override @@ -72,6 +82,11 @@ public enum Signs { public Integer getQualitativeValueId() { return QualitativeValueId.SEX_FEMALE.getValue(); } + + @Override + public boolean isNullEquivalent() { + return false; + } }, // classe de taille, 1 = petit ; 2 = gros ; 0 = pas de classe de taille (saisie libre donc risque fort de mauvaise saisie) @@ -85,6 +100,12 @@ public enum Signs { public Integer getQualitativeValueId() { return QualitativeValueId2.NOT_SIZED.getValue(); } + + @Override + public boolean isNullEquivalent() { + return true; + } + }, SMALL("1") { @Override @@ -96,6 +117,11 @@ public enum Signs { public Integer getQualitativeValueId() { return QualitativeValueId.SIZE_SMALL.getValue(); } + + @Override + public boolean isNullEquivalent() { + return false; + } }, BIG("2") { @Override @@ -107,6 +133,11 @@ public enum Signs { public Integer getQualitativeValueId() { return QualitativeValueId.SIZE_BIG.getValue(); } + + @Override + public boolean isNullEquivalent() { + return false; + } }, // vrac / hors vrac @@ -120,6 +151,11 @@ public enum Signs { public Integer getQualitativeValueId() { return QualitativeValueId.SORTED_VRAC.getValue(); } + + @Override + public boolean isNullEquivalent() { + return false; + } }, HORS_VRAC("HV") { @Override @@ -131,6 +167,11 @@ public enum Signs { public Integer getQualitativeValueId() { return QualitativeValueId.SORTED_HORS_VRAC.getValue(); } + + @Override + public boolean isNullEquivalent() { + return false; + } }; private String sign; @@ -163,6 +204,9 @@ public enum Signs { public abstract Integer getQualitativeValueId(); + // if true, can use this value in the import file to replace a skipped category + public abstract boolean isNullEquivalent(); + public void registerSign(Caracteristic caracteristic, Map<Signs, CaracteristicQualitativeValue> map) { Integer valueId = getQualitativeValueId(); diff --git a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties index 5232704..7c70c0e 100644 --- a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties +++ b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties @@ -47,8 +47,13 @@ tutti.report.step.generateReport= tutti.report.step.load.fishingOperation= tutti.service.arp.import.attachment.comment= tutti.service.bigfin.import.attachment.comment= +tutti.service.bigfinImport.error.species.batch.frequenciesOnHigherLevel= +tutti.service.bigfinImport.error.species.categoriesSkipped= +tutti.service.bigfinImport.error.species.categorySkipped= tutti.service.bigfinImport.error.species.not.found= +tutti.service.bigfinImport.error.species.tooCategorized= tutti.service.bigfinImport.error.species.without.lengthstep= +tutti.service.bigfinImport.error.species.wrongNextCategory= tutti.service.bigfinImport.error.szClass.unknwon= tutti.service.bigfinimport.error.no.protocol= tutti.service.compressZipFile.error= diff --git a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties index 6cd20b4..5446ee6 100644 --- a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties +++ b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties @@ -44,7 +44,11 @@ tutti.report.step.export.fishingOperation=Exporter le trait sélectionné tutti.report.step.generateReport=Générer le rapport tutti.report.step.load.fishingOperation=Charger le trait sélectionné tutti.service.bigfin.import.attachment.comment=Import Bigfin du %s +tutti.service.bigfinImport.error.species.batch.frequenciesOnHigherLevel=Le lot de '<strong>%1s / %2s</strong>' a déjà des mensurations +tutti.service.bigfinImport.error.species.categoriesSkipped=L'espèce '<strong>%1s</strong>' a été catégorisée sans les catégories '<strong>%2s</strong>' et '<strong>%3s</strong>' +tutti.service.bigfinImport.error.species.categorySkipped=L'espèce '<strong>%1s</strong>' a été catégorisée sans la catégorie '<strong>%2s</strong>' tutti.service.bigfinImport.error.species.not.found=L'espèce '<strong>%s</strong>' est inconnue +tutti.service.bigfinImport.error.species.tooCategorized=L'espèce '<strong>%1s</strong>' est trop catégorisée (pas limitée à '<strong>%2s</strong>' et '<strong>%3s</strong>') tutti.service.bigfinImport.error.species.without.lengthstep=L'espèce '<strong>%s</strong>' n'a pas de classe de taille associée dans le protocole. tutti.service.bigfinImport.error.szClass.unknwon=Ligne <i>%s</i>, code inconnu (doit être 0, 1 ou 2) tutti.service.bigfinimport.error.no.protocol=Impossible de faire un import Bigfin sans protocol. diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java index 5846a42..035d440 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java @@ -99,40 +99,39 @@ public class BigfinImportServiceTest { BigfinImportResult importResult = service.importFile(importFile, operation, catchBatch); - int nbSortedAdded = importResult.getNbVracImported(); - int nbUnsortedAdded = importResult.getNbHorsVracImported(); + int nbFrequenciesAdded = importResult.getNbFrequenciesImported(); + List<String> fatals = importResult.getFatalErrors(); List<String> errors = importResult.getErrors(); if (log.isInfoEnabled()) { - log.info("Sorted Imported: " + nbSortedAdded); - log.info("Unsorted Imported: " + nbUnsortedAdded); + log.info("Frequencies Imported: " + nbFrequenciesAdded); + log.info("Fatals: " + fatals.size()); log.info("Errors: " + errors.size()); } - int nbNewSortedBatchs = 3; - int nbNewUnsortedBatchs = 0; - Assert.assertEquals(nbNewSortedBatchs, nbSortedAdded); - Assert.assertEquals(nbNewUnsortedBatchs, nbUnsortedAdded); + int nbNewFrequencies = 3; + Assert.assertEquals(nbNewFrequencies, nbFrequenciesAdded); + Assert.assertEquals(0, fatals.size()); Assert.assertEquals(0, errors.size()); // no batch imported BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); - int totalSortedBatchs = 0; - int totalUnsortedBatchs = 0; - for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { - - boolean sorted = vracPredicate.apply(speciesBatch); - - if (sorted) { - totalSortedBatchs++; - } else { - totalUnsortedBatchs++; - } - } - - Assert.assertEquals(nbNewSortedBatchs, totalSortedBatchs); - Assert.assertEquals(nbNewUnsortedBatchs, totalUnsortedBatchs); +// int totalSortedBatchs = 0; +// int totalUnsortedBatchs = 0; +// for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { +// +// boolean sorted = vracPredicate.apply(speciesBatch); +// +// if (sorted) { +// totalSortedBatchs++; +// } else { +// totalUnsortedBatchs++; +// } +// } +// +// Assert.assertEquals(nbNewSortedBatchs, totalSortedBatchs); +// Assert.assertEquals(nbNewUnsortedBatchs, totalUnsortedBatchs); } @Test @@ -151,40 +150,38 @@ public class BigfinImportServiceTest { BigfinImportResult importResult = service.importFile(importFile, operation, catchBatch); - int nbSortedAdded = importResult.getNbVracImported(); - int nbUnsortedAdded = importResult.getNbHorsVracImported(); + int nbFrequenciesAdded = importResult.getNbFrequenciesImported(); + List<String> fatals = importResult.getFatalErrors(); List<String> errors = importResult.getErrors(); if (log.isInfoEnabled()) { - log.info("Sorted Imported: " + nbSortedAdded); - log.info("Unsorted Imported: " + nbUnsortedAdded); + log.info("Frequencies Imported: " + nbFrequenciesAdded); + log.info("Fatals: " + fatals.size()); log.info("Errors: " + errors.size()); } - int nbNewSortedBatchs = 0; - int nbNewUnsortedBatchs = 0; - int nbErrors = 3; - Assert.assertEquals(nbNewSortedBatchs, nbSortedAdded); - Assert.assertEquals(nbNewUnsortedBatchs, nbUnsortedAdded); + int nbNewFrequencies = 0; + int nbFatals = 3; + int nbErrors = 0; + Assert.assertEquals(nbNewFrequencies, nbFrequenciesAdded); + Assert.assertEquals(nbFatals, fatals.size()); Assert.assertEquals(nbErrors, errors.size()); // no batch imported BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); - int totalSortedBatchs = 0; - int totalUnsortedBatchs = 0; - for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { - - boolean sorted = vracPredicate.apply(speciesBatch); - - if (sorted) { - totalSortedBatchs++; - } else { - totalUnsortedBatchs++; - } - } - - Assert.assertEquals(nbNewSortedBatchs, totalSortedBatchs); - Assert.assertEquals(nbNewUnsortedBatchs, totalUnsortedBatchs); +// int totalSortedBatchs = 0; +// for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { +// +// boolean sorted = vracPredicate.apply(speciesBatch); +// +// if (sorted) { +// totalSortedBatchs++; +// } else { +// totalUnsortedBatchs++; +// } +// } + +// Assert.assertEquals(nbFrequenciesAdded, totalSortedBatchs); } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java index e615f14..cf4aa9b 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java @@ -116,20 +116,35 @@ public class ImportBigfinAction extends AbstractTuttiAction<SpeciesBatchUIModel, if (importResult.isDone()) { sendMessage(t("tutti.editSpeciesBatch.action.importBigfin.success", - importResult.getNbVracImported(), importResult.getNbHorsVracImported())); + importResult.getNbFrequenciesImported(), + importResult.getNbFrequenciesDeleted())); + + if (!importResult.getErrors().isEmpty()) { + StringBuilder sb = new StringBuilder(); + for (String s : importResult.getErrors()) { + sb.append("<li>").append(s).append("</li>"); + } + displayWarningMessage( + t("tutti.editSpeciesBatch.action.importBigfin.errors.fishingOperation.title"), + "<html><body>" + + t("tutti.editSpeciesBatch.action.importBigfin.errors.fishingOperation", sb.toString()) + + "</body></html>" + ); + } + } else { StringBuilder sb = new StringBuilder(); - for (String s : importResult.getErrors()) { + for (String s : importResult.getFatalErrors()) { sb.append("<li>").append(s).append("</li>"); } displayWarningMessage( - t("tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation.title"), + t("tutti.editSpeciesBatch.action.importBigfin.fatal.fishingOperation.title"), "<html><body>" + - t("tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation", sb.toString()) + + t("tutti.editSpeciesBatch.action.importBigfin.fatal.fishingOperation", sb.toString()) + "</body></html>" ); - sendMessage(t("tutti.editSpeciesBatch.action.importBigfin.no.matching.data")); + sendMessage(t("tutti.editSpeciesBatch.action.importBigfin.fatal.data")); } } } diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties index a99239a..9be01fb 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties @@ -994,6 +994,11 @@ tutti.editSpeciesBatch.action.ichtyometer= tutti.editSpeciesBatch.action.ichtyometer.mnemonic= tutti.editSpeciesBatch.action.ichtyometer.tip= tutti.editSpeciesBatch.action.importBigfin= +tutti.editSpeciesBatch.action.importBigfin.errors.fishingOperation= +tutti.editSpeciesBatch.action.importBigfin.errors.fishingOperation.title= +tutti.editSpeciesBatch.action.importBigfin.fatal.data= +tutti.editSpeciesBatch.action.importBigfin.fatal.fishingOperation= +tutti.editSpeciesBatch.action.importBigfin.fatal.fishingOperation.title= tutti.editSpeciesBatch.action.importBigfin.mnemonic= tutti.editSpeciesBatch.action.importBigfin.no.matching.data= tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation= diff --git a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties index c2a6941..70a5c8d 100644 --- a/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties +++ b/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties @@ -978,11 +978,13 @@ tutti.editSpeciesBatch.action.exportMultiPost.mnemonic=E tutti.editSpeciesBatch.action.exportMultiPost.success=Les lots d'espèces ont été exportés dans le fichier %s tutti.editSpeciesBatch.action.exportMultiPost.tip=Exporter les lots d'espèces pour les importer sur le poste maître tutti.editSpeciesBatch.action.importBigfin=Import Bigfin +tutti.editSpeciesBatch.action.importBigfin.errors.fishingOperation=L'import Bigfin a été réalisé, mais des erreurs ont été détectées \:<ul>%s</ul><br/> +tutti.editSpeciesBatch.action.importBigfin.errors.fishingOperation.title=Import Bigfin +tutti.editSpeciesBatch.action.importBigfin.fatal.data=Import Bigfin non réalisé (des erreurs ont été détectées lors de la lecture du fichier) +tutti.editSpeciesBatch.action.importBigfin.fatal.fishingOperation=L'import Bigfin n'a pas été réalisé, des erreurs ont été détectées \:<ul>%s</ul><br/>Aucun lot n'a donc été importé. +tutti.editSpeciesBatch.action.importBigfin.fatal.fishingOperation.title=Import Bigfin tutti.editSpeciesBatch.action.importBigfin.mnemonic=B -tutti.editSpeciesBatch.action.importBigfin.no.matching.data=Import Bigfin non réalisé (des erreurs ont été détectées lors de la lecture du fichier) -tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation=L'import Bigfin n'a pas été réalisé, des erreurs ont été détectées \:<ul>%s</ul><br/>Aucun lot n'a donc été importé. -tutti.editSpeciesBatch.action.importBigfin.no.matching.fishingOperation.title=Import Bigfin -tutti.editSpeciesBatch.action.importBigfin.success=Import Bigfin réussi \: %1s espèces importées (Vrac), %2s espèces importées (Hors-Vrac) +tutti.editSpeciesBatch.action.importBigfin.success=Import Bigfin réussi \: %1s mensurations importées, %2s mensurations supprimées tutti.editSpeciesBatch.action.importBigfin.tip=Import Bigfin tutti.editSpeciesBatch.action.importMultiPost=Importer des lots d'espèces tutti.editSpeciesBatch.action.importMultiPost.mnemonic=I -- 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 tutti. See http://git.codelutin.com/tutti.git commit 284fe2f9f7c18f1132637954af7d9c45a719ec21 Author: Kevin Morin <morin@codelutin.com> Date: Tue Sep 23 14:24:39 2014 +0200 fixes #5411 [CAPTURE] Import BIGFIN --- .../tutti/service/bigfin/BigfinDataRowModel.java | 7 +- .../tutti/service/bigfin/BigfinImportResult.java | 30 ++--- .../tutti/service/bigfin/BigfinImportService.java | 95 +++++++------- .../fr/ifremer/tutti/service/bigfin/Signs.java | 19 +-- .../resources/i18n/tutti-service_en_GB.properties | 5 + .../resources/i18n/tutti-service_fr_FR.properties | 9 +- .../service/bigfin/BigfinImportServiceTest.java | 142 ++++++++++++++------- .../test/resources/bigfin/importbigfin-errors.csv | 4 + .../test/resources/bigfin/importbigfin-invalid.csv | 31 ----- .../test/resources/bigfin/importbigfin-valid.csv | 65 +++++----- .../resources/bigfin/importbigfin-warnings.csv | 5 + .../tutti/ui/swing/action/ImportBigfinAction.java | 6 +- 12 files changed, 230 insertions(+), 188 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java index dd94d7c..a4500c6 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinDataRowModel.java @@ -5,6 +5,7 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.Sets; +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId; import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; @@ -86,7 +87,7 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi new ValueParser<Signs>() { @Override public Signs parse(String value) throws ParseException { - Signs result = Signs.getSign(value.toUpperCase(), PmfmId2.SIZE_CATEGORY.getValue()); + Signs result = Signs.getSign(value.toUpperCase(), PmfmId.SIZE_CATEGORY.getValue()); return result; } }); @@ -96,7 +97,7 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi new ValueParser<Signs>() { @Override public Signs parse(String value) throws ParseException { - Signs result = Signs.getSign(value.toUpperCase(), PmfmId2.SEX.getValue()); + Signs result = Signs.getSign(value.toUpperCase(), PmfmId.SEX.getValue()); if (result == null) { throw new ParseException("Could not parse Sign value: " + value, 0); } @@ -108,7 +109,7 @@ public class BigfinDataRowModel extends TuttiCsvUtil.AbstractTuttiImportModel<Bi @Override public Signs parse(String value) throws ParseException { // On importe dans le Vrac par défaut, sauf si il y a le texte HV ou hv dans le champ text - Signs result = Signs.getSign(value.toUpperCase(), PmfmId2.SORTED_UNSORTED.getValue()); + Signs result = Signs.getSign(value.toUpperCase(), PmfmId.SORTED_UNSORTED.getValue()); if (result == null) { result = Signs.VRAC; } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java index 407f10c..7f4d1da 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportResult.java @@ -38,16 +38,14 @@ public class BigfinImportResult { protected final File importFile; - protected final List<String> fatalErrors = new ArrayList<>(); - protected final List<String> errors = new ArrayList<>(); + protected final List<String> warnings = new ArrayList<>(); + protected int nbFrequenciesImported; protected int nbFrequenciesDeleted; - protected final List<Species> speciesNotInProtocol = new ArrayList<>(); - public BigfinImportResult(File importFile) { this.importFile = importFile; } @@ -64,35 +62,31 @@ public class BigfinImportResult { return nbFrequenciesDeleted; } - public List<String> getFatalErrors() { - return fatalErrors; - } - public List<String> getErrors() { return errors; } - void incrementNbFrequenciesImported(int nb) { - this.nbFrequenciesImported += nb; + public List<String> getWarnings() { + return warnings; } - void incrementNbFrequenciesDeleted(int nb) { - this.nbFrequenciesDeleted += nb; + public void incrementNbFrequenciesImported(int nb) { + this.nbFrequenciesImported += nb; } - void addFatalError(String error) { - fatalErrors.add(error); + public void incrementNbFrequenciesDeleted(int nb) { + this.nbFrequenciesDeleted += nb; } - void addError(String error) { + public void addError(String error) { errors.add(error); } - void addSpeciesNotInProtocol(Species species) { - speciesNotInProtocol.add(species); + public void addWarning(String warning) { + warnings.add(warning); } public boolean isDone() { - return fatalErrors.isEmpty(); + return errors.isEmpty(); } } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java index 1f40312..f06b104 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java @@ -9,9 +9,8 @@ import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.io.Files; -import fr.ifremer.adagio.core.dao.referential.pmfm.ObjectTypeCode2; +import fr.ifremer.adagio.core.dao.referential.ObjectTypeCode; import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId; -import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.Attachments; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; @@ -118,31 +117,32 @@ public class BigfinImportService extends AbstractTuttiService { List<Species> allSpeciesWithSurveyCode = persistenceService.getReferentSpeciesWithSurveyCode(allReferentSpecies); Map<String, Species> speciesBySurveyCode = Maps.newTreeMap(); - for (Species species : allSpeciesWithSurveyCode) { + for (Species species : allReferentSpecies) { String surveyCode = species.getSurveyCode(); if (StringUtils.isNotBlank(surveyCode)) { speciesBySurveyCode.put(surveyCode, species); - } else { + } else if (species.getRefTaxCode() != null) { speciesBySurveyCode.put(species.getRefTaxCode(), species); } } - speciesProtocolBySurveyCode = Maps.newTreeMap(); + speciesProtocolBySurveyCode = Maps.newTreeMap(); for (SpeciesProtocol speciesProtocol : protocol.getSpecies()) { - if (speciesProtocol.getSpeciesSurveyCode() != null) { + if (StringUtils.isNotBlank(speciesProtocol.getSpeciesSurveyCode())) { speciesProtocolBySurveyCode.put(speciesProtocol.getSpeciesSurveyCode(), speciesProtocol); } else { speciesProtocolBySurveyCode.put(speciesProtocol.getSpeciesReferenceTaxonId().toString(), speciesProtocol); } - } BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); // set of not found species already added in the errors Set<Species> speciesNotRecognized = new HashSet<>(); + //set of species not in the protocol + Set<Species> speciesNotInProtocol = new HashSet<>(); // set of species without lengthstep alreay added in the errors Set<Species> speciesInProtocolButWithoutLengthStepPmfmId = new HashSet<>(); @@ -170,47 +170,54 @@ public class BigfinImportService extends AbstractTuttiService { if (bean.getSzClass() == null) { String error = t("tutti.service.bigfinImport.error.szClass.unknwon", bean.getRecordId()); - if (log.isWarnEnabled()) { - log.warn(error); + if (log.isErrorEnabled()) { + log.error(error); } - result.addFatalError(error); + result.addError(error); } if (species == null || species.getId() == null) { // bloquer tout si un "species" ne match pas le référentiel de Tutti : lister dans ce cas les codes non reconnus if (speciesNotRecognized.add(species)) { String error = t("tutti.service.bigfinImport.error.species.not.found", species.getExternalCode()); - if (log.isWarnEnabled()) { - log.warn(error); + if (log.isErrorEnabled()) { + log.error(error); } - result.addFatalError(error); + result.addError(error); } } else { String code = species.getSurveyCode(); - if (code == null) { + if (StringUtils.isBlank(code)) { code = species.getReferenceTaxonId().toString(); } SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(code); + String speciesLabel = species.getSurveyCode(); + if (StringUtils.isBlank(speciesLabel)) { + speciesLabel = species.getRefTaxCode(); + } + // On n'importe pas les espèces non présentes dans le protocole et // on liste les espèces/catégorisées non importées pour aider l'utilisateur // à identifier le problème et on fait l'import des autres if (speciesProtocol == null) { - result.addSpeciesNotInProtocol(species); - - } else if (speciesProtocol.getLengthStepPmfmId() == null - && speciesInProtocolButWithoutLengthStepPmfmId.add(species)) { -// bloquer toute espèce reconnue du protocole mais qui n'a pas de méthode de mesure - String speciesLabel = species.getSurveyCode(); - if (StringUtils.isBlank(speciesLabel)) { - speciesLabel = species.getRefTaxCode(); + if (speciesNotInProtocol.add(species)) { + String error = t("tutti.service.bigfinImport.warning.species.notInProtocol", speciesLabel); + if (log.isWarnEnabled()) { + log.warn(error); + } + result.addWarning(error); } - String error = t("tutti.service.bigfinImport.error.species.without.lengthstep", speciesLabel); - if (log.isWarnEnabled()) { - log.warn(error); - } - result.addFatalError(error); + } else if (speciesProtocol.getLengthStepPmfmId() == null) { + if (speciesInProtocolButWithoutLengthStepPmfmId.add(species)) { +// bloquer toute espèce reconnue du protocole mais qui n'a pas de méthode de mesure + String error = t("tutti.service.bigfinImport.error.species.without.lengthstep", speciesLabel); + if (log.isErrorEnabled()) { + log.error(error); + } + result.addError(error); + } } else { rows.add(bean); } @@ -254,7 +261,7 @@ public class BigfinImportService extends AbstractTuttiService { // get the speciesprotocol and its lengthstep pmfm String code = species.getSurveyCode(); - if (code == null) { + if (StringUtils.isBlank(code)) { code = species.getReferenceTaxonId().toString(); } SpeciesProtocol speciesProtocol = speciesProtocolBySurveyCode.get(code); @@ -364,10 +371,10 @@ public class BigfinImportService extends AbstractTuttiService { if (category.getCategoryValueGetter() == null) { // if the batch is not the last one, error, we cannot add the frequencies to a more categorized batch if (CollectionUtils.isNotEmpty(batch.getChildBatchs())) { - commonParameter.getResult().addError(t("tutti.service.bigfinImport.error.species.tooCategorized", - commonParameter.getSpeciesLabel(), - sizeCaracteristic.getParameterName(), - genderCaracteristic.getParameterName())); + commonParameter.getResult().addWarning(t("tutti.service.bigfinImport.warning.species.tooCategorized", + commonParameter.getSpeciesLabel(), + sizeCaracteristic.getParameterName(), + genderCaracteristic.getParameterName())); } else { // create the frequencies @@ -382,8 +389,8 @@ public class BigfinImportService extends AbstractTuttiService { } else if (batchHasFrequencies) { // if the batch is supposed to be categorized again, but already has frequencies CaracteristicQualitativeValue qualitativeValue = signsToCaracteristicValue.get(caracteristic); - commonParameter.getResult().addError(t("tutti.service.bigfinImport.error.species.batch.frequenciesOnHigherLevel", - commonParameter.getSpeciesLabel(), qualitativeValue.getName())); + commonParameter.getResult().addWarning(t("tutti.service.bigfinImport.warning.species.batch.frequenciesOnHigherLevel", + commonParameter.getSpeciesLabel(), qualitativeValue.getName())); } else { List<SpeciesBatch> batchChildren = batch.getChildBatchs(); @@ -411,19 +418,19 @@ public class BigfinImportService extends AbstractTuttiService { // check that this time, it is the right category. We can only skip one nextCategory = commonParameter.getCategories().get(depth); if (!nextCategory.getPmfmId().equals(categoryId)) { - commonParameter.getResult().addError(t("tutti.service.bigfinImport.error.species.categoriesSkipped", - commonParameter.getSpeciesLabel(), - sizeCaracteristic.getParameterName(), - genderCaracteristic.getParameterName() - )); + commonParameter.getResult().addWarning(t("tutti.service.bigfinImport.warning.species.categoriesSkipped", + commonParameter.getSpeciesLabel(), + sizeCaracteristic.getParameterName(), + genderCaracteristic.getParameterName() + )); continue; } } else { - commonParameter.getResult().addError(t("tutti.service.bigfinImport.error.species.categorySkipped", - commonParameter.getSpeciesLabel(), - persistenceService.getCaracteristic(nextCategory.getPmfmId()).getParameterName() - )); + commonParameter.getResult().addWarning(t("tutti.service.bigfinImport.warning.species.categorySkipped", + commonParameter.getSpeciesLabel(), + persistenceService.getCaracteristic(nextCategory.getPmfmId()).getParameterName() + )); continue; } } @@ -513,7 +520,7 @@ public class BigfinImportService extends AbstractTuttiService { protected void addFileAsAttachment(File f, CatchBatch catchBatch) { Attachment attachment = Attachments.newAttachment(); - attachment.setObjectType(ObjectTypeCode2.CATCH_BATCH); + attachment.setObjectType(ObjectTypeCode.CATCH_BATCH); attachment.setObjectId(Integer.valueOf(catchBatch.getId())); attachment.setName(f.getName()); String date = DateFormat.getDateTimeInstance().format(context.currentDate()); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java index 208325e..0e0cec8 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/Signs.java @@ -22,6 +22,7 @@ package fr.ifremer.tutti.service.bigfin; * #L% */ +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId; import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId2; @@ -43,7 +44,7 @@ public enum Signs { NOT_SEXED("NOT SET") { @Override public Integer getCategory() { - return PmfmId2.SEX.getValue(); + return PmfmId.SEX.getValue(); } @Override @@ -59,7 +60,7 @@ public enum Signs { MALE("M") { @Override public Integer getCategory() { - return PmfmId2.SEX.getValue(); + return PmfmId.SEX.getValue(); } @Override @@ -75,7 +76,7 @@ public enum Signs { FEMALE("F") { @Override public Integer getCategory() { - return PmfmId2.SEX.getValue(); + return PmfmId.SEX.getValue(); } @Override @@ -93,12 +94,12 @@ public enum Signs { NOT_SIZED("0") { @Override public Integer getCategory() { - return PmfmId2.SIZE_CATEGORY.getValue(); + return PmfmId.SIZE_CATEGORY.getValue(); } @Override public Integer getQualitativeValueId() { - return QualitativeValueId2.NOT_SIZED.getValue(); + return QualitativeValueId.UNSORTED.getValue(); } @Override @@ -110,7 +111,7 @@ public enum Signs { SMALL("1") { @Override public Integer getCategory() { - return PmfmId2.SIZE_CATEGORY.getValue(); + return PmfmId.SIZE_CATEGORY.getValue(); } @Override @@ -126,7 +127,7 @@ public enum Signs { BIG("2") { @Override public Integer getCategory() { - return PmfmId2.SIZE_CATEGORY.getValue(); + return PmfmId.SIZE_CATEGORY.getValue(); } @Override @@ -144,7 +145,7 @@ public enum Signs { VRAC("") { @Override public Integer getCategory() { - return PmfmId2.SORTED_UNSORTED.getValue(); + return PmfmId.SORTED_UNSORTED.getValue(); } @Override @@ -160,7 +161,7 @@ public enum Signs { HORS_VRAC("HV") { @Override public Integer getCategory() { - return PmfmId2.SORTED_UNSORTED.getValue(); + return PmfmId.SORTED_UNSORTED.getValue(); } @Override diff --git a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties index 7c70c0e..d686b05 100644 --- a/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties +++ b/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties @@ -55,6 +55,11 @@ tutti.service.bigfinImport.error.species.tooCategorized= tutti.service.bigfinImport.error.species.without.lengthstep= tutti.service.bigfinImport.error.species.wrongNextCategory= tutti.service.bigfinImport.error.szClass.unknwon= +tutti.service.bigfinImport.warning.species.batch.frequenciesOnHigherLevel= +tutti.service.bigfinImport.warning.species.categoriesSkipped= +tutti.service.bigfinImport.warning.species.categorySkipped= +tutti.service.bigfinImport.warning.species.notInProtocol= +tutti.service.bigfinImport.warning.species.tooCategorized= tutti.service.bigfinimport.error.no.protocol= tutti.service.compressZipFile.error= tutti.service.context.serviceInstanciation.error= diff --git a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties index 5446ee6..14cec28 100644 --- a/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties +++ b/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties @@ -44,13 +44,14 @@ tutti.report.step.export.fishingOperation=Exporter le trait sélectionné tutti.report.step.generateReport=Générer le rapport tutti.report.step.load.fishingOperation=Charger le trait sélectionné tutti.service.bigfin.import.attachment.comment=Import Bigfin du %s -tutti.service.bigfinImport.error.species.batch.frequenciesOnHigherLevel=Le lot de '<strong>%1s / %2s</strong>' a déjà des mensurations -tutti.service.bigfinImport.error.species.categoriesSkipped=L'espèce '<strong>%1s</strong>' a été catégorisée sans les catégories '<strong>%2s</strong>' et '<strong>%3s</strong>' -tutti.service.bigfinImport.error.species.categorySkipped=L'espèce '<strong>%1s</strong>' a été catégorisée sans la catégorie '<strong>%2s</strong>' tutti.service.bigfinImport.error.species.not.found=L'espèce '<strong>%s</strong>' est inconnue -tutti.service.bigfinImport.error.species.tooCategorized=L'espèce '<strong>%1s</strong>' est trop catégorisée (pas limitée à '<strong>%2s</strong>' et '<strong>%3s</strong>') tutti.service.bigfinImport.error.species.without.lengthstep=L'espèce '<strong>%s</strong>' n'a pas de classe de taille associée dans le protocole. tutti.service.bigfinImport.error.szClass.unknwon=Ligne <i>%s</i>, code inconnu (doit être 0, 1 ou 2) +tutti.service.bigfinImport.warning.species.batch.frequenciesOnHigherLevel=Le lot de '<strong>%1s / %2s</strong>' a déjà des mensurations +tutti.service.bigfinImport.warning.species.categoriesSkipped=L'espèce '<strong>%1s</strong>' a été catégorisée sans les catégories '<strong>%2s</strong>' et '<strong>%3s</strong>' +tutti.service.bigfinImport.warning.species.categorySkipped=L'espèce '<strong>%1s</strong>' a été catégorisée sans la catégorie '<strong>%2s</strong>' +tutti.service.bigfinImport.warning.species.notInProtocol=L'espèce '<strong>%1s</strong>' n'est pas présente dans le protocole +tutti.service.bigfinImport.warning.species.tooCategorized=L'espèce '<strong>%1s</strong>' est trop catégorisée (pas limitée à '<strong>%2s</strong>' et '<strong>%3s</strong>') tutti.service.bigfinimport.error.no.protocol=Impossible de faire un import Bigfin sans protocol. tutti.service.compressZipFile.error=Erreur lors de la compression du dossier %1s dans le fichier %2s tutti.service.context.serviceInstanciation.error=Erreur lors de l'instanciation du service %s diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java index 035d440..f50fc2e 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java @@ -1,10 +1,8 @@ package fr.ifremer.tutti.service.bigfin; import com.google.common.base.Predicate; -import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId2; +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmId; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; -import fr.ifremer.tutti.TuttiConfigurationOption; -import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; @@ -20,6 +18,10 @@ import org.junit.Assert; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; +<<<<<<< HEAD +======= +import org.nuiton.jaxx.application.ApplicationBusinessException; +>>>>>>> fixes #5411 [CAPTURE] Import BIGFIN import java.io.File; import java.io.IOException; @@ -32,11 +34,16 @@ import java.util.List; public class BigfinImportServiceTest { @ClassRule +<<<<<<< HEAD public static final ServiceDbResource dbResource = ServiceDbResource.writeDb("dbExport"); +======= + public static final ServiceDbResource dbResource = ServiceDbResource.writeDb("dbImportBigfin"); +>>>>>>> fixes #5411 [CAPTURE] Import BIGFIN /** Logger. */ private static final Log log = LogFactory.getLog(BigfinImportServiceTest.class); +<<<<<<< HEAD public static final String PROGRAM_ID = "CAM-TEST_ELEVATION"; public static final String CRUISE_ID = "100003"; @@ -46,6 +53,13 @@ public class BigfinImportServiceTest { public static final String OPERATION_2_ID = "100113"; public static final String OPERATION_3_ID = "100115"; +======= + public static final String PROGRAM_ID = "CAM-TEST_"; + + public static final String CRUISE_ID = "0"; + + public static final String OPERATION_1_ID = "0"; +>>>>>>> fixes #5411 [CAPTURE] Import BIGFIN protected BigfinImportService service; @@ -53,8 +67,6 @@ public class BigfinImportServiceTest { protected ServiceDbResource.DataContext dataContext; - protected ProgressionModel progressionModel; - protected File dataDirectory; protected Predicate<SpeciesAbleBatch> vracPredicate; @@ -66,21 +78,23 @@ public class BigfinImportServiceTest { TuttiServiceContext serviceContext = dbResource.getServiceContext(); - File protocol = dbResource.copyClassPathResource("bigfin/protocol.tuttiProtocol", "protocol.tuttiProtocol"); - dbResource.getConfig().getApplicationConfig().setOption(TuttiConfigurationOption.DB_PROTOCOL_DIRECTORY.getKey(), protocol.getParentFile().getAbsolutePath()); - serviceContext.getDataContext().setProtocolId("protocol"); + dbResource.loadInternalProtocolFile(); dbResource.openDataContext(); persistenceService = serviceContext.getService(PersistenceService.class); service = serviceContext.getService(BigfinImportService.class); +<<<<<<< HEAD progressionModel = new ProgressionModel(); progressionModel.setTotal(9); dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 3, OPERATION_2_ID, OPERATION_1_ID, OPERATION_3_ID); +======= + dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 1, OPERATION_1_ID); +>>>>>>> fixes #5411 [CAPTURE] Import BIGFIN - vracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate(PmfmId2.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue()); + vracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate(PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue()); } @Test @@ -88,82 +102,72 @@ public class BigfinImportServiceTest { File importFile = dbResource.copyClassPathResource("bigfin/importbigfin-valid.csv", "importbigfin-valid.csv"); - FishingOperation operation = dataContext.operations.get(1); + FishingOperation operation = dataContext.operations.get(0); CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); catchBatch.setFishingOperation(operation); - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); - for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) { - persistenceService.deleteSpeciesBatch(speciesBatch.getId()); - } - BigfinImportResult importResult = service.importFile(importFile, operation, catchBatch); int nbFrequenciesAdded = importResult.getNbFrequenciesImported(); - List<String> fatals = importResult.getFatalErrors(); List<String> errors = importResult.getErrors(); + List<String> warnings = importResult.getWarnings(); if (log.isInfoEnabled()) { log.info("Frequencies Imported: " + nbFrequenciesAdded); - log.info("Fatals: " + fatals.size()); log.info("Errors: " + errors.size()); + log.info("Warnings: " + warnings.size()); } - int nbNewFrequencies = 3; + int nbNewFrequencies = 32; Assert.assertEquals(nbNewFrequencies, nbFrequenciesAdded); - Assert.assertEquals(0, fatals.size()); Assert.assertEquals(0, errors.size()); + Assert.assertEquals(0, warnings.size()); // no batch imported BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); -// int totalSortedBatchs = 0; -// int totalUnsortedBatchs = 0; -// for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { -// -// boolean sorted = vracPredicate.apply(speciesBatch); -// -// if (sorted) { -// totalSortedBatchs++; -// } else { -// totalUnsortedBatchs++; -// } -// } -// -// Assert.assertEquals(nbNewSortedBatchs, totalSortedBatchs); -// Assert.assertEquals(nbNewUnsortedBatchs, totalUnsortedBatchs); + int totalSortedBatchs = 0; + int totalUnsortedBatchs = 0; + for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) { + + boolean sorted = vracPredicate.apply(speciesBatch); + + if (sorted) { + totalSortedBatchs++; + } else { + totalUnsortedBatchs++; + } + } + + Assert.assertEquals(4, totalSortedBatchs); + Assert.assertEquals(3, totalUnsortedBatchs); } @Test - public void importInvalid() throws IOException { + public void importWithErrors() throws IOException { - File importFile = dbResource.copyClassPathResource("bigfin/importbigfin-invalid.csv", "importbigfin-invalid.csv"); + File importFile = dbResource.copyClassPathResource("bigfin/importbigfin-errors.csv", "importbigfin-invalid-errors.csv"); - FishingOperation operation = dataContext.operations.get(1); + FishingOperation operation = dataContext.operations.get(0); CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); catchBatch.setFishingOperation(operation); - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); - for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) { - persistenceService.deleteSpeciesBatch(speciesBatch.getId()); - } - BigfinImportResult importResult = service.importFile(importFile, operation, catchBatch); int nbFrequenciesAdded = importResult.getNbFrequenciesImported(); - List<String> fatals = importResult.getFatalErrors(); List<String> errors = importResult.getErrors(); + List<String> warnings = importResult.getWarnings(); + if (log.isInfoEnabled()) { log.info("Frequencies Imported: " + nbFrequenciesAdded); - log.info("Fatals: " + fatals.size()); log.info("Errors: " + errors.size()); + log.info("Warnings: " + warnings.size()); } int nbNewFrequencies = 0; - int nbFatals = 3; - int nbErrors = 0; Assert.assertEquals(nbNewFrequencies, nbFrequenciesAdded); +<<<<<<< HEAD Assert.assertEquals(nbFatals, fatals.size()); Assert.assertEquals(nbErrors, errors.size()); @@ -183,5 +187,51 @@ public class BigfinImportServiceTest { // } // Assert.assertEquals(nbFrequenciesAdded, totalSortedBatchs); +======= + Assert.assertEquals(2, errors.size()); + Assert.assertEquals(0, warnings.size()); + + TuttiServiceContext serviceContext = dbResource.getServiceContext(); + serviceContext.getDataContext().resetProtocol(); + + boolean failIfNoProtocol = false; + try { + service.importFile(importFile, operation, catchBatch); + } catch (ApplicationBusinessException e) { + if (log.isErrorEnabled()) { + log.error("Error during import: " + e.getMessage()); + } + failIfNoProtocol = true; + } + Assert.assertTrue(failIfNoProtocol); +>>>>>>> fixes #5411 [CAPTURE] Import BIGFIN + } + + @Test + public void importWithWarnings() throws IOException { + + File importFile = dbResource.copyClassPathResource("bigfin/importbigfin-warnings.csv", "importbigfin-invalid-warnings.csv"); + + FishingOperation operation = dataContext.operations.get(0); + CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); + catchBatch.setFishingOperation(operation); + + BigfinImportResult importResult = service.importFile(importFile, operation, catchBatch); + + int nbFrequenciesAdded = importResult.getNbFrequenciesImported(); + List<String> errors = importResult.getErrors(); + List<String> warnings = importResult.getWarnings(); + + if (log.isInfoEnabled()) { + log.info("Frequencies Imported: " + nbFrequenciesAdded); + log.info("Errors: " + errors.size()); + log.info("Warnings: " + warnings.size()); + } + + int nbNewFrequencies = 1; + Assert.assertEquals(nbNewFrequencies, nbFrequenciesAdded); + Assert.assertEquals(0, errors.size()); + Assert.assertEquals(3, warnings.size()); + } } diff --git a/tutti-service/src/test/resources/bigfin/importbigfin-errors.csv b/tutti-service/src/test/resources/bigfin/importbigfin-errors.csv new file mode 100644 index 0000000..378a0dc --- /dev/null +++ b/tutti-service/src/test/resources/bigfin/importbigfin-errors.csv @@ -0,0 +1,4 @@ +Record_id;length(mm);weight(g);species;cruise;station;pan;Dt;sz class;gender;text +0;98;250;NOLSESP;;1;VB;05/31/14 20:20;1;Not set;libre +1;185;215;ESP1;;1;VB;05/31/14 20:20;1;Not set; +2;156;321;ESP1;;1;VB;05/31/14 20:20;6;Not set; diff --git a/tutti-service/src/test/resources/bigfin/importbigfin-invalid.csv b/tutti-service/src/test/resources/bigfin/importbigfin-invalid.csv deleted file mode 100644 index 4d5dabe..0000000 --- a/tutti-service/src/test/resources/bigfin/importbigfin-invalid.csv +++ /dev/null @@ -1,31 +0,0 @@ -Record_id;length(mm);weight(g);species;cruise;station;pan;Dt;sz class;gender;text -0;98;250;ARISFOL;THALASSA;1;VB;05/31/14 20:20;42;Not set;libre -1;123;360;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; -2;185;215;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; -3;101;145;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; -5;90;256;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -6;131;258;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -7;168;365;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -8;165;324;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -9;136;124;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -10;145;241;ARISFOL;THALASSA;1;VB;05/31/14 20:21;2;Not set; -11;125;256;ARISFOL;THALASSA;1;VB;05/31/14 20:22;2;Not set; -12;650;0;ARITANT;THALASSA;1;VB;05/31/14 20:23;0;M; -13;654;0;ARITANT;THALASSA;1;VB;05/31/14 20:24;0;M; -14;521;0;ARITANT;THALASSA;1;VB;05/31/14 20:25;0;F; -15;587;0;ARITANT;THALASSA;1;VB;05/31/14 20:26;0;F; -16;456;0;ARITANT;THALASSA;1;VB;05/31/14 20:27;0;M; -17;562;0;ARITANT;THALASSA;1;VB;05/31/14 20:28;0;F; -18;562;0;ARITANT;THALASSA;1;VB;05/31/14 20:29;0;F; -19;125;1025;TRACTRU;THALASSA;1;VB;05/31/14 20:30;0;Not set; -20;145;0;TRACTRU;THALASSA;1;VB;05/31/14 20:31;0;Not set; -21;102;0;TRACTRU;THALASSA;1;VB;05/31/14 20:32;0;Not set; -22;96;0;TRACTRU;THALASSA;1;VB;05/31/14 20:33;0;Not set; -23;84;0;TRACTRU;THALASSA;1;VB;05/31/14 20:34;0;Not set; -24;84;0;TRACTRU;THALASSA;1;VB;05/31/14 20:35;0;Not set; -25;132;0;TRACTRU;THALASSA;1;VB;05/31/14 20:36;0;Not set; -26;105;0;TRACTRU;THALASSA;1;VB;05/31/14 20:37;0;Not set; -27;80;0;TRACTRU;THALASSA;1;VB;05/31/14 20:38;0;Not set; -28;96;0;TRACTRU;THALASSA;1;VB;05/31/14 20:39;0;Not set; -29;87;0;PAPELON;THALASSA;1;VB;05/31/14 20:40;0;Not set; -30;785;1240;DICE-LAB;THALASSA;1;VB;05/31/14 20:41;2;M; diff --git a/tutti-service/src/test/resources/bigfin/importbigfin-valid.csv b/tutti-service/src/test/resources/bigfin/importbigfin-valid.csv index 66cd72b..b165688 100644 --- a/tutti-service/src/test/resources/bigfin/importbigfin-valid.csv +++ b/tutti-service/src/test/resources/bigfin/importbigfin-valid.csv @@ -1,31 +1,36 @@ Record_id;length(mm);weight(g);species;cruise;station;pan;Dt;sz class;gender;text -0;98;250;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set;libre -1;123;360;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; -2;185;215;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; -3;101;145;ARISFOL;THALASSA;1;VB;05/31/14 20:20;1;Not set; -5;90;256;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -6;131;258;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -7;168;365;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -8;165;324;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -9;136;124;ARISFOL;THALASSA;1;VB;05/31/14 20:20;2;Not set; -10;145;241;ARISFOL;THALASSA;1;VB;05/31/14 20:21;2;Not set; -11;125;256;ARISFOL;THALASSA;1;VB;05/31/14 20:22;2;Not set; -12;650;0;ARITANT;THALASSA;1;VB;05/31/14 20:23;0;M; -13;654;0;ARITANT;THALASSA;1;VB;05/31/14 20:24;0;M; -14;521;0;ARITANT;THALASSA;1;VB;05/31/14 20:25;0;F; -15;587;0;ARITANT;THALASSA;1;VB;05/31/14 20:26;0;F; -16;456;0;ARITANT;THALASSA;1;VB;05/31/14 20:27;0;M; -17;562;0;ARITANT;THALASSA;1;VB;05/31/14 20:28;0;F; -18;562;0;ARITANT;THALASSA;1;VB;05/31/14 20:29;0;F; -19;125;1025;TRACTRU;THALASSA;;VB;05/31/14 20:30;0;Not set; -20;145;0;TRACTRU;THALASSA;;VB;05/31/14 20:31;0;Not set; -21;102;0;TRACTRU;THALASSA;;VB;05/31/14 20:32;0;Not set; -22;96;0;TRACTRU;THALASSA;;VB;05/31/14 20:33;0;Not set; -23;84;0;TRACTRU;THALASSA;;VB;05/31/14 20:34;0;Not set; -24;84;0;TRACTRU;THALASSA;;VB;05/31/14 20:35;0;Not set; -25;132;0;TRACTRU;THALASSA;;VB;05/31/14 20:36;0;Not set; -26;105;0;TRACTRU;THALASSA;;VB;05/31/14 20:37;0;Not set; -27;80;0;TRACTRU;THALASSA;;VB;05/31/14 20:38;0;Not set; -28;96;0;TRACTRU;THALASSA;;VB;05/31/14 20:39;0;Not set; -29;87;0;TRACTRU;THALASSA;;VB;05/31/14 20:40;0;Not set; -30;785;1240;DICE-LAB;THALASSA;1;VB;05/31/14 20:41;2;M; +0;98;250;ESP1;;1;VB;05/31/14 20:20;1;Not set;libre +1;123;360;ESP1;;1;VB;05/31/14 20:20;1;Not set; +2;185;215;ESP1;;1;VB;05/31/14 20:20;1;Not set; +3;101;145;ESP1;;1;VB;05/31/14 20:20;1;M; +4;90;256;ESP1;;1;VB;05/31/14 20:20;2;M; +5;90;256;ESP1;;1;VB;05/31/14 20:20;2;M; +6;131;258;ESP1;;1;VB;05/31/14 20:20;2;Not set; +7;168;365;ESP1;;1;VB;05/31/14 20:20;2;Not set; +8;165;324;ESP1;;1;VB;05/31/14 20:20;2;M; +9;136;124;ESP1;;1;VB;05/31/14 20:20;2;M; +10;145;241;ESP2;;1;VB;05/31/14 20:21;2;M;hv +11;125;256;ESP2;;1;VB;05/31/14 20:22;2;M;hV +12;650;0;DICELAB;;1;VB;05/31/14 20:23;0;M; +13;654;0;DICELAB;;1;VB;05/31/14 20:24;0;M; +14;521;0;DICELAB;;1;VB;05/31/14 20:25;0;F; +15;587;0;DICELAB;;1;VB;05/31/14 20:26;0;F; +16;456;0;DICELAB;;1;VB;05/31/14 20:27;0;M; +17;562;0;DICELAB;;1;VB;05/31/14 20:28;0;F; +18;562;0;DICELAB;;1;VB;05/31/14 20:29;0;F; +19;125;0;ESP2;;1;VB;05/31/14 20:30;0;M; +20;145;0;ESP2;;1;VB;05/31/14 20:31;0;M; +21;102;0;ESP2;;1;VB;05/31/14 20:32;0;M; +22;96;125;ESP2;;1;VB;05/31/14 20:33;0;F; +23;84;412;ESP2;;1;VB;05/31/14 20:34;0;F; +24;84;362;ESP2;;1;VB;05/31/14 20:35;0;F; +25;132;865;ESP2;;1;VB;05/31/14 20:36;0;F; +26;105;254;ESP2;;1;VB;05/31/14 20:37;0;F; +27;80;0;ESP3;;1;VB;05/31/14 20:38;0;Not set; +28;96;0;ESP3;;1;VB;05/31/14 20:39;0;Not set; +29;87;0;ESP3;;1;VB;05/31/14 20:40;0;Not set; +30;785;1240;DICELAB;1;1;VB;05/31/14 20:41;2;M;Hv +31;780;1220;DICELAB;1;1;VB;05/31/14 20:41;2;M;HV +32;80;0;ESP3;;2;VB;05/31/14 20:38;0;Not set; +33;96;0;ESP3;;1;VB;05/31/13 20:39;0;Not set; +34;87;0;ESP3;;1;VB;05/31/15 20:40;0;Not set; \ No newline at end of file diff --git a/tutti-service/src/test/resources/bigfin/importbigfin-warnings.csv b/tutti-service/src/test/resources/bigfin/importbigfin-warnings.csv new file mode 100644 index 0000000..48dc309 --- /dev/null +++ b/tutti-service/src/test/resources/bigfin/importbigfin-warnings.csv @@ -0,0 +1,5 @@ +Record_id;length(mm);weight(g);species;cruise;station;pan;Dt;sz class;gender;text +0;98;250;ABAL;;1;VB;05/31/14 20:20;1;Not set;libre +1;185;215;ESP1;;1;VB;05/31/14 20:20;1;F; +2;156;321;ESP1;;1;VB;05/31/14 20:20;1;Not set; +3;156;321;ESP1;;1;VB;05/31/14 20:20;1;F;hv \ No newline at end of file diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java index cf4aa9b..ed35109 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/ImportBigfinAction.java @@ -119,9 +119,9 @@ public class ImportBigfinAction extends AbstractTuttiAction<SpeciesBatchUIModel, importResult.getNbFrequenciesImported(), importResult.getNbFrequenciesDeleted())); - if (!importResult.getErrors().isEmpty()) { + if (!importResult.getWarnings().isEmpty()) { StringBuilder sb = new StringBuilder(); - for (String s : importResult.getErrors()) { + for (String s : importResult.getWarnings()) { sb.append("<li>").append(s).append("</li>"); } displayWarningMessage( @@ -135,7 +135,7 @@ public class ImportBigfinAction extends AbstractTuttiAction<SpeciesBatchUIModel, } else { StringBuilder sb = new StringBuilder(); - for (String s : importResult.getFatalErrors()) { + for (String s : importResult.getErrors()) { sb.append("<li>").append(s).append("</li>"); } displayWarningMessage( -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm