This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git commit 39cff1761a62cc902b95102c882bfb536e220294 Author: jcouteau <couteau@codelutin.com> Date: Thu Dec 5 11:16:53 2019 +0100 fixes #9731 : Suppression des sampleDataType LTcm1 et LTcm0.5 --- .../entities/references/SampleDataTypeImpl.java | 4 --- .../service/atlantos/xml/VocabularyExport.java | 36 ++++++++++++++++------ .../service/atlantos/xml/XmlAccousticExport.java | 1 - .../service/atlantos/xml/XmlBioticExport.java | 5 +-- .../VoyageCatchesSubSampleImportAction.java | 27 +--------------- .../contexts/VoyageCatchesImportDataContext.java | 16 ---------- .../csv/VoyageCatchesSubSampleImportRow.java | 9 ------ 7 files changed, 28 insertions(+), 70 deletions(-) diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypeImpl.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypeImpl.java index b1020bd4..034934c5 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypeImpl.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypeImpl.java @@ -35,10 +35,6 @@ public class SampleDataTypeImpl extends SampleDataTypeAbstract { public static final String WEIGHT_AT_LENGTHKG = "WeightAtLengthkg"; - public static final String L_TCM_1 = "LTcm1"; - - public static final String LTCM0_5 = "LTcm0.5"; - public static final String NUMBER_AT_LENGTH = "NumberAtLength"; private static final long serialVersionUID = 1L; diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/VocabularyExport.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/VocabularyExport.java index df15e2e3..25b91434 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/VocabularyExport.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/VocabularyExport.java @@ -22,10 +22,14 @@ package fr.ifremer.echobase.services.service.atlantos.xml; */ import fr.ifremer.echobase.entities.data.Category; +import fr.ifremer.echobase.entities.data.Echotype; +import fr.ifremer.echobase.entities.references.SizeCategory; import fr.ifremer.echobase.entities.references.Species; import fr.ifremer.echobase.entities.references.SpeciesCategory; import fr.ifremer.echobase.services.EchoBaseService; import fr.ifremer.echobase.services.service.UserDbPersistenceService; +import org.apache.commons.lang.StringUtils; + import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashSet; @@ -146,7 +150,13 @@ public class VocabularyExport implements EchoBaseService { this.writer.close("Vocabulary"); } - + + /** + * Method to get vocabulary code from VocabularyCIEM for a key (without prefix) + * @param key key in VocabularyCIEM + * @param defaultValue used if nothing in VocabularyCIEM + * @return value from VocabularyCIEM (or default value if used) + */ public String getVocabularyCode(String key, String defaultValue) { if (key == null || key.trim().equals("")) { this.addVocabulary(defaultValue); @@ -162,7 +172,12 @@ public class VocabularyExport implements EchoBaseService { this.addVocabulary(code); return code; } - + + /** + * Method to get vocabulary CIEM value for code. Should have prefix + * @param code + * @return + */ public String getVocabularyCode(String code) { this.addVocabulary(code); return code; @@ -189,25 +204,26 @@ public class VocabularyExport implements EchoBaseService { } public void exportEchotype(Category category) throws IOException { + + Echotype echotype = category.getEchotype(); + this.writer.open("EchoType", - "ID", category.getEchotype().getName()); + "ID", echotype.getName()); this.writer.create("Stratum", "IDREF", - getVocabularyCode("AC_Stratum_" + category.getEchotype().getDepthStratum().getId())); + getVocabularyCode("AC_Stratum_" + echotype.getDepthStratum().getId())); - for (Species species:category.getEchotype().getSpecies()){ - exportSpecies(species, category.getSpeciesCategory()); + for (Species species : echotype.getSpecies()) { + exportSpecies(species, echotype.getId()); } this.writer.close("EchoType"); } - public void exportSpecies(Species species, SpeciesCategory speciesCategory) throws IOException { + public void exportSpecies(Species species, int speciesCategoryName) throws IOException { this.writer.open("Species"); this.writer.create("SpeciesCode", "IDREF", getVocabularyCode("SpecWoRMS_" + species.getWormsCode())); - if (speciesCategory != null && speciesCategory.getSizeCategory() != null) { - this.writer.create("SpeciesCategory", speciesCategory.getSizeCategory().getName()); - } + this.writer.create("SpeciesCategory", speciesCategoryName); this.writer.close("Species"); } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlAccousticExport.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlAccousticExport.java index 91ab855b..658d4a62 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlAccousticExport.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlAccousticExport.java @@ -6,7 +6,6 @@ import com.google.common.collect.Maps; import fr.ifremer.echobase.entities.data.*; import fr.ifremer.echobase.entities.references.AcousticInstrument; import fr.ifremer.echobase.entities.references.Calibration; -import fr.ifremer.echobase.entities.references.Species; import fr.ifremer.echobase.entities.references.Vessel; import fr.ifremer.echobase.services.EchoBaseService; import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlBioticExport.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlBioticExport.java index 5faf1ade..58a7e26e 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlBioticExport.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlBioticExport.java @@ -570,13 +570,10 @@ public class XmlBioticExport implements EchoBaseService { Float value = data.getDataValue(); String label = data.getDataLabel(); - if (SampleDataTypeImpl.LTCM0_5.equals(dataName) - || SampleDataTypeImpl.L_TCM_1.equals(dataName)) { - + if (SampleDataTypeImpl.NUMBER_AT_LENGTH.equals(dataName)) { sampleDataValues.put(SampleDataTypeImpl.NUMBER_AT_LENGTH, String.valueOf(value)); sampleDataValues.put(dataName, label); sampleDataValues.put("LengthClass", label); - } else { sampleDataValues.put(dataName, String.valueOf(value)); } diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageCatchesSubSampleImportAction.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageCatchesSubSampleImportAction.java index 6eb3d25c..630a172d 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageCatchesSubSampleImportAction.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/actions/VoyageCatchesSubSampleImportAction.java @@ -86,8 +86,6 @@ public class VoyageCatchesSubSampleImportAction extends VoyageCatchesImportDataA SampleType sampleTypeSubsample = importDataContext.getSampleTypeSubsample(); SampleDataType sampleDataTypeNumberAtLength = importDataContext.getSampleDataTypeNumberAtLength(); - SampleDataType sampleDataTypeNumberAtLength05cm = importDataContext.getSampleDataTypeNumberAtLength05cm(); - SampleDataType sampleDataTypeNumberAtLength1cm = importDataContext.getSampleDataTypeNumberAtLength1cm(); SampleDataType sampleDataTypeWeightAtLength = importDataContext.getSampleDataTypeWeightAtLength(); try (Import<VoyageCatchesSubSampleImportRow> importer = open()) { @@ -135,18 +133,9 @@ public class VoyageCatchesSubSampleImportAction extends VoyageCatchesImportDataA addProcessedRow(result, row); - Integer round = row.getRound(); SampleDataType dataType; - if (round == null) { - dataType = sampleDataTypeNumberAtLength; - } else if (round == 5) { - dataType = sampleDataTypeNumberAtLength05cm; - } else if (round == 1) { - dataType = sampleDataTypeNumberAtLength1cm; - } else { - throw new IllegalStateException("Can't deal with round value: " + round); - } + dataType = sampleDataTypeNumberAtLength; { @@ -227,8 +216,6 @@ public class VoyageCatchesSubSampleImportAction extends VoyageCatchesImportDataA Set<SampleDataType> lengthSampleDataTypes = new LinkedHashSet<>(); lengthSampleDataTypes.add(importDataContext.getSampleDataTypeNumberAtLength()); - lengthSampleDataTypes.add(importDataContext.getSampleDataTypeNumberAtLength05cm()); - lengthSampleDataTypes.add(importDataContext.getSampleDataTypeNumberAtLength1cm()); Preconditions.checkState(sample.isSampleDataNotEmpty()); @@ -283,8 +270,6 @@ public class VoyageCatchesSubSampleImportAction extends VoyageCatchesImportDataA protected void addImportedSampleData(VoyageCatchesImportDataContext importDataContext, VoyageCatchesSubSampleImportRow importedRow, SampleData sampleData) { SampleDataType sampleDataTypeNumberAtLength = importDataContext.getSampleDataTypeNumberAtLength(); - SampleDataType sampleDataTypeNumberAtLength05cm = importDataContext.getSampleDataTypeNumberAtLength05cm(); - SampleDataType sampleDataTypeNumberAtLength1cm = importDataContext.getSampleDataTypeNumberAtLength1cm(); SampleDataType sampleDataTypeWeightAtLength = importDataContext.getSampleDataTypeWeightAtLength(); SampleDataType sampleDataType = sampleData.getSampleDataType(); @@ -293,16 +278,6 @@ public class VoyageCatchesSubSampleImportAction extends VoyageCatchesImportDataA importedRow.setNumberAtLength(sampleData.getDataValue()); - } else if (sampleDataTypeNumberAtLength05cm.equals(sampleDataType)) { - - importedRow.setNumberAtLength(sampleData.getDataValue()); - importedRow.setRound(5); - - } else if (sampleDataTypeNumberAtLength1cm.equals(sampleDataType)) { - - importedRow.setNumberAtLength(sampleData.getDataValue()); - importedRow.setRound(1); - } else if (sampleDataTypeWeightAtLength.equals(sampleDataType)) { importedRow.setWeightAtLength(sampleData.getDataValue()); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/contexts/VoyageCatchesImportDataContext.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/contexts/VoyageCatchesImportDataContext.java index 141fdfff..2e8ba985 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/contexts/VoyageCatchesImportDataContext.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/contexts/VoyageCatchesImportDataContext.java @@ -49,8 +49,6 @@ public class VoyageCatchesImportDataContext extends VoyageImportDataContextSuppo private SampleDataType sampleDataTypeNoPerKg; private SampleDataType sampleDataTypeFishIndex; private SampleDataType sampleDataTypeNumberAtLength; - private SampleDataType sampleDataTypeNumberAtLength05cm; - private SampleDataType sampleDataTypeNumberAtLength1cm; private SampleDataType sampleDataTypeWeightAtLength; public VoyageCatchesImportDataContext(UserDbPersistenceService persistenceService, Locale locale, char csvSeparator, VoyageCatchesImportConfiguration configuration, EchoBaseUser user, Date importDate) { @@ -71,20 +69,6 @@ public class VoyageCatchesImportDataContext extends VoyageImportDataContextSuppo return sampleDataTypeNumberAtLength; } - public final SampleDataType getSampleDataTypeNumberAtLength05cm() { - if (sampleDataTypeNumberAtLength05cm == null) { - sampleDataTypeNumberAtLength05cm = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.LTCM0_5); - } - return sampleDataTypeNumberAtLength05cm; - } - - public final SampleDataType getSampleDataTypeNumberAtLength1cm() { - if (sampleDataTypeNumberAtLength1cm == null) { - sampleDataTypeNumberAtLength1cm = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.L_TCM_1); - } - return sampleDataTypeNumberAtLength1cm; - } - public final SampleDataType getSampleDataTypeWeightAtLength() { if (sampleDataTypeWeightAtLength == null) { sampleDataTypeWeightAtLength = persistenceService.getSampleDataTypeByName(SampleDataTypeImpl.WEIGHT_AT_LENGTHKG); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageCatchesSubSampleImportRow.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageCatchesSubSampleImportRow.java index 1844f282..ab2e1ae8 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageCatchesSubSampleImportRow.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/importdata/csv/VoyageCatchesSubSampleImportRow.java @@ -60,7 +60,6 @@ public class VoyageCatchesSubSampleImportRow { protected float numberAtLength; protected Float weightAtLength; protected String lengthClass; - protected Integer round; public static VoyageCatchesSubSampleImportRow of(Operation operation, Sample sample) { VoyageCatchesSubSampleImportRow row = new VoyageCatchesSubSampleImportRow(sample); @@ -107,14 +106,6 @@ public class VoyageCatchesSubSampleImportRow { this.sizeCategory = sizeCategory; } - public Integer getRound() { - return round; - } - - public void setRound(Integer round) { - this.round = round; - } - public Float getSampleWeight() { return sample.getSampleWeight(); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.