This is an automated email from the git hooks/post-receive script. New commit to branch struts2.5 in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git commit 96ae910553a9a12727d50b0b2e8397c7319bdb75 Author: jcouteau <couteau@codelutin.com> Date: Fri Mar 1 11:45:37 2019 +0100 refs #10215 refs #10216 refs #10217 --- .../service/atlantos/xml/VocabularyExport.java | 51 +++++++++++++++++++--- .../service/atlantos/xml/XmlAccousticExport.java | 31 +++---------- .../service/atlantos/xml/XmlBioticExport.java | 8 ++-- 3 files changed, 57 insertions(+), 33 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 695e04ac..df15e2e3 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 @@ -21,6 +21,9 @@ package fr.ifremer.echobase.services.service.atlantos.xml; * #L% */ +import fr.ifremer.echobase.entities.data.Category; +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 java.io.IOException; @@ -31,7 +34,6 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; -import org.apache.commons.lang3.StringUtils; /** * @@ -45,6 +47,9 @@ public class VocabularyExport implements EchoBaseService { protected Map<String, String> vocabularyTags; protected Map<String, String> vocabulary; protected Map<String, Set<String>> cache; + + //used to deal with echotypes in vocabulary export + protected Map<String, Category> categories; protected XmlWriter writer; protected Pattern pattern; @@ -54,8 +59,10 @@ public class VocabularyExport implements EchoBaseService { this.writer = writer; - this.vocabularyTags = new HashMap<String, String>(); + this.vocabularyTags = new HashMap<>(); this.cache = new HashMap<>(); + //special mechanism for echotypes + this.categories = new HashMap<>(); this.vocabularyTags.put("AC_Survey", "Survey"); this.vocabularyTags.put("ISO_3166", "Country"); @@ -85,7 +92,7 @@ public class VocabularyExport implements EchoBaseService { // For Biotic this.vocabularyTags.put("Gear", "Gear"); this.vocabularyTags.put("AC_HaulValidity", "HaulValidity"); - this.vocabularyTags.put("AC_DepthStratum", "DepthStratum"); + this.vocabularyTags.put("AC_Stratum", "Stratum"); this.vocabularyTags.put("AC_GearExceptions", "GearExceptions"); this.vocabularyTags.put("AC_DoorType", "DoorType"); this.vocabularyTags.put("AC_CatchDataType", "DataType"); @@ -107,8 +114,15 @@ public class VocabularyExport implements EchoBaseService { } public void generate() throws IOException { + + //Special mechanism for echotypes + for (Map.Entry<String, Category> entry: this.categories.entrySet()){ + exportEchotype(entry.getValue()); + } + this.writer.open("Vocabulary"); - + + for (Map.Entry<String, Set<String>> entry : this.cache.entrySet()) { String tag = entry.getKey(); Set<String> codes = entry.getValue(); @@ -123,7 +137,7 @@ public class VocabularyExport implements EchoBaseService { this.writer.create("Code", "ID", code, - "CodeType", "http://acoustic.ices.dk/Services/Schema/XML/" + prefix + ".xml", + "CodeType", "https://acoustic.ices.dk/Services/Schema/XML/" + prefix + ".xml", value); } @@ -169,5 +183,32 @@ public class VocabularyExport implements EchoBaseService { codes.add(code); } + + public void addCategory(Category category){ + this.categories.put(category.getEchotype().getName(), category); + } + + public void exportEchotype(Category category) throws IOException { + this.writer.open("EchoType", + "ID", category.getEchotype().getName()); + this.writer.create("Stratum", "IDREF", + getVocabularyCode("AC_Stratum_" + category.getEchotype().getDepthStratum().getId())); + + for (Species species:category.getEchotype().getSpecies()){ + exportSpecies(species, category.getSpeciesCategory()); + } + + this.writer.close("EchoType"); + } + + public void exportSpecies(Species species, SpeciesCategory speciesCategory) 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.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 6eade348..91ab855b 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 @@ -3,16 +3,10 @@ package fr.ifremer.echobase.services.service.atlantos.xml; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -import fr.ifremer.echobase.entities.data.Cell; -import fr.ifremer.echobase.entities.data.Data; -import fr.ifremer.echobase.entities.data.DataAcquisition; -import fr.ifremer.echobase.entities.data.DataProcessing; -import fr.ifremer.echobase.entities.data.Result; -import fr.ifremer.echobase.entities.data.Transect; -import fr.ifremer.echobase.entities.data.Transit; -import fr.ifremer.echobase.entities.data.Voyage; +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; @@ -113,7 +107,7 @@ public class XmlAccousticExport implements EchoBaseService { } Collection<Cell> cells = dataProcessing.getCell(); - List<Cell> orderingCells = new ArrayList<Cell>(cells); + List<Cell> orderingCells = new ArrayList<>(cells); orderingCells.removeIf(new Predicate<Cell>() { @Override public boolean test(Cell cell) { @@ -168,17 +162,6 @@ public class XmlAccousticExport implements EchoBaseService { xmlCruise.close("Sample"); } -// // EXPORT SAMPLE -// exportSample(voyage, cell, null, xmlCruise); -// -// Collection<Result> results = cell.getResult(); -// for (Result result : results) { -// if ("NASC".equals(result.getDataMetadata().getName())) { -// // EXPORT DATA -// exportData(result, xmlCruise); -// } -// } -// xmlCruise.close("Sample"); xmlCruise.close("Log"); } } @@ -321,7 +304,7 @@ public class XmlAccousticExport implements EchoBaseService { xml.close("DataProcessing"); } - + public void exportCruise(Voyage voyage, Vessel vessel, Transect transect, XmlWriter xml) throws IOException { xml.open("Cruise"); @@ -468,9 +451,9 @@ public class XmlAccousticExport implements EchoBaseService { public void exportData(Voyage voyage, Result result, XmlWriter xml) throws IOException { if (!result.getResultValue().equals("NA")) { xml.open("Data"); - - xml.create("SaCategory", - "IDREF", vocabulary.getVocabularyCode(voyage.getName() + ":" + result.getCategory().getEchotype().getName(),"AC_SaCategory_D4")); + xml.create("EchoType", + "IDREF", result.getCategory().getEchotype().getName()); + vocabulary.addCategory(result.getCategory()); xml.create("Type", "IDREF", vocabulary.getVocabularyCode("AC_AcousticDataType_C")); xml.create("Unit", 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 6ff6c7e5..5faf1ade 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 @@ -400,22 +400,22 @@ public class XmlBioticExport implements EchoBaseService { (int)((operation.getGearShootingEndTime().getTime() - operation.getGearShootingStartTime().getTime()) / (1000 * 60))); xml.create("Validity", "IDREF", vocabulary.getVocabularyCode("AC_HaulValidity_V")); - xml.create("DepthStratum", - "IDREF", vocabulary.getVocabularyCode("AC_DepthStratum_" + depthStratum)); xml.create("StartLatitude", startLatitude); xml.create("StartLongitude", startLongitude); xml.create("StopLatitude", endLatitude); xml.create("StopLongitude", endLongitude); xml.create("MinTrawlDepth", minTrawlDepth); - xml.create("MaxTrawlDepth", + xml.create("MaxTrawlDepth", maxTrawlDepth); xml.create("BottomDepth", meanWaterDepth.intValue()); - xml.create("Distance", + xml.create("Distance", distance); xml.create("Netopening", netopening); + xml.create("Stratum", + "IDREF", vocabulary.getVocabularyCode("AC_Stratum_" + depthStratum)); } public void exportCatch(Sample subsample, Float subsampledWeight, Float speciesCategoryWeight, Integer subsampledNumber, Integer speciesCategoryNumber, XmlWriter xml) throws IOException { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.