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 c4d81c82c34b751348956735c88837cb967073ea Author: jcouteau <couteau@codelutin.com> Date: Thu Feb 13 17:44:19 2020 +0100 fixes #10216 : Mise à jour de l’export Acoustic pour la base CIEM --- .../service/atlantos/xml/VocabularyExport.java | 54 ++++++++++++++-------- .../service/atlantos/xml/XmlAccousticExport.java | 16 ++++--- 2 files changed, 45 insertions(+), 25 deletions(-) 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 0c050920..638408e0 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 @@ -53,6 +53,8 @@ public class VocabularyExport implements EchoBaseService { //used to deal with echotypes in vocabulary export protected Map<String, Category> categories; + + protected boolean exportSpeciesCategory = true; protected XmlWriter writer; protected Pattern pattern; @@ -129,22 +131,25 @@ public class VocabularyExport implements EchoBaseService { for (Map.Entry<String, Set<String>> entry : this.cache.entrySet()) { String tag = entry.getKey(); Set<String> codes = entry.getValue(); - - this.writer.open(tag); - - for (String code : codes) { - Matcher matcher = this.pattern.matcher(code); - matcher.find(); - String prefix = matcher.group(1); - String value = matcher.group(7); - - this.writer.create("Code", - "ID", code, - "CodeType", "https://acoustic.ices.dk/Services/Schema/XML/" + prefix + ".xml", - value); - } - this.writer.close(tag); + if (!tag.equals("SpeciesCategory") || exportSpeciesCategory) { + + this.writer.open(tag); + + for (String code : codes) { + Matcher matcher = this.pattern.matcher(code); + matcher.find(); + String prefix = matcher.group(1); + String value = matcher.group(7); + + this.writer.create("Code", + "ID", code, + "CodeType", "https://acoustic.ices.dk/Services/Schema/XML/" + prefix + ".xml", + value); + } + + this.writer.close(tag); + } } this.writer.close("Vocabulary"); @@ -212,7 +217,12 @@ public class VocabularyExport implements EchoBaseService { getVocabularyCode("AC_Stratum_" + echotype.getDepthStratum().getId())); for (Species species : echotype.getSpecies()) { - exportSpecies(species, echotype.getId()); + if (category.getSpeciesCategory() != null) { + exportSpecies(species, + category.getSpeciesCategory().getSizeCategory().getName()); + } else { + exportSpecies(species, null); + } } this.writer.close("EchoType"); @@ -222,9 +232,17 @@ public class VocabularyExport implements EchoBaseService { this.writer.open("Species"); this.writer.create("SpeciesCode", "IDREF", getVocabularyCode("SpecWoRMS_" + species.getWormsCode())); - //this.writer.create("SpeciesCategory", speciesCategoryName); - this.writer.create("SpeciesCategory", "IDREF", getVocabularyCode(speciesCategoryName,"AC_CatchCategory_1")); + + //We get speciesCategory vocabulary value to parse it, so no export for this one. + String speciesCategoryCode = getVocabularyCode(speciesCategoryName,"AC_CatchCategory_1"); + setExportSpeciesCategory(false); + this.writer.create("SpeciesCategory", speciesCategoryCode.charAt(speciesCategoryCode.length()-1)); + this.writer.close("Species"); } + + public void setExportSpeciesCategory(boolean exportSpeciesCategory) { + this.exportSpeciesCategory = exportSpeciesCategory; + } } 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 ccb74c0e..1bb738d6 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 @@ -10,11 +10,7 @@ import fr.ifremer.echobase.entities.references.Vessel; import fr.ifremer.echobase.services.EchoBaseService; import fr.ifremer.echobase.services.csv.EchoBaseCsvUtil; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.function.Predicate; import javax.inject.Inject; import org.apache.commons.lang3.StringUtils; @@ -138,9 +134,16 @@ public class XmlAccousticExport implements EchoBaseService { if ("NASC".equals(result.getDataMetadata().getName())) { if (result.getCategory().getEchotype().getName().equals("D4")) { + //Add category to vocabulary (to get speciesCategories in echotype vocabulary export) + vocabulary.addCategory(result.getCategory()); resultForD4 = result; } else { - resultsWithoutD4.add(result); + //Add category to vocabulary (to get speciesCategories in echotype vocabulary export) + vocabulary.addCategory(result.getCategory()); + //Export only samples without speciesCategory + if (result.getCategory().getSpeciesCategory() == null) { + resultsWithoutD4.add(result); + } } } } @@ -452,7 +455,6 @@ public class XmlAccousticExport implements EchoBaseService { xml.open("Data"); xml.create("EchoType", "IDREF", result.getCategory().getEchotype().getName()); - vocabulary.addCategory(result.getCategory()); xml.create("Type", "IDREF", vocabulary.getVocabularyCode("AC_AcousticDataType_C")); xml.create("Unit", -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.