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 4c5074d84f8f527deb6d8b2064e3ac70bc7dc628 Author: Julien Ruchaud <julien.ruchaud@debux.org> Date: Thu Oct 27 17:37:00 2016 +0200 #8173 Fix SubsamplingFactor --- .../service/atlantos/xml/XmlBioticExport.java | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) 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 4122393..7d1f8a7 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 @@ -7,8 +7,6 @@ import fr.ifremer.echobase.entities.data.Operation; import fr.ifremer.echobase.entities.data.OperationMetadataValue; import fr.ifremer.echobase.entities.data.Sample; import fr.ifremer.echobase.entities.data.SampleData; -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.references.SampleDataTypeImpl; import fr.ifremer.echobase.entities.references.SpeciesCategory; @@ -72,6 +70,7 @@ public class XmlBioticExport implements EchoBaseService { exportHaul(operation, index++, xmlCruise); Map<String, Float> totalWeight = new HashMap<String, Float>(); + Map<String, Float> totalWeightBySize = new HashMap<String, Float>(); Map<String, Integer> totalNumber = new HashMap<String, Integer>(); Collection<Sample> subSamples = new ArrayList<Sample>(); @@ -83,6 +82,7 @@ public class XmlBioticExport implements EchoBaseService { if ("Total".equals(name)) { SpeciesCategory category = sample.getSpeciesCategory(); String code = category.getSpecies().getBaracoudaCode(); + String size = code + "#" + category.getSizeCategoryLabel(); Float weight = totalWeight.get(code); if (weight == null) { @@ -95,6 +95,16 @@ public class XmlBioticExport implements EchoBaseService { } totalWeight.put(code, weight); + Float weightBySize = totalWeightBySize.get(size); + if (weightBySize == null) { + weightBySize = 0f; + } + + if (sampleWeight != null) { + weightBySize += sampleWeight; + } + totalWeightBySize.put(size, weightBySize); + Integer number = totalNumber.get(code); if (number == null) { number = 0; @@ -117,12 +127,14 @@ public class XmlBioticExport implements EchoBaseService { for (Sample sample : subSamples) { SpeciesCategory category = sample.getSpeciesCategory(); String code = category.getSpecies().getBaracoudaCode(); + String size = code + "#" + category.getSizeCategoryLabel(); Float weight = totalWeight.get(code); + Float weightBySize = totalWeightBySize.get(size); Integer number = totalNumber.get(code); // EXPORT CATCH - exportCatch(sample, weight, number, xmlCruise); + exportCatch(sample, weightBySize, weight, number, xmlCruise); // EXPORT BIOLOGY: nothing we don't have the data for the moment @@ -272,11 +284,11 @@ public class XmlBioticExport implements EchoBaseService { // xml.create("LogDistance"); } - public void exportCatch(Sample sample, Float weight, Integer number, XmlWriter xml) throws IOException { + public void exportCatch(Sample subsample, Float weightBySize, Float weight, Integer number, XmlWriter xml) throws IOException { xml.open("Catch"); Map<String, String> sampleDataValues = new HashMap<String, String>(); - Collection<SampleData> datas = sample.getSampleData(); + Collection<SampleData> datas = subsample.getSampleData(); for (SampleData data : datas) { String name = data.getSampleDataType().getName(); @@ -295,7 +307,7 @@ public class XmlBioticExport implements EchoBaseService { } } - SpeciesCategory category = sample.getSpeciesCategory(); + SpeciesCategory category = subsample.getSpeciesCategory(); String lengthClass = sampleDataValues.get("LengthClass"); Float lengthClassValue = 0f; @@ -314,18 +326,18 @@ public class XmlBioticExport implements EchoBaseService { xml.create("WeightUnit", "IDREF", vocabulary.getVocabularyCode("AC_WeightUnit_kg")); xml.create("SpeciesTotalWeight", - weight.intValue()); + weight != null ? weight.intValue() : 0); xml.create("SpeciesCategory", "IDREF", vocabulary.getVocabularyCode(category.getSizeCategoryLabel(), "AC_CatchCategory_1")); // xml.create("SpeciesSex"); // xml.create("CategoryWeight"); xml.create("SubsampledNumber", - sample.getNumberSampled()); + subsample.getNumberSampled()); xml.create("SubsamplingFactor", - weight / sample.getSampleWeight()); + weightBySize != null ? weightBySize / subsample.getSampleWeight() : 0); xml.create("SubsampleWeight", - sample.getSampleWeight()); + subsample.getSampleWeight()); xml.create("LengthCode", "IDREF", vocabulary.getVocabularyCode("AC_LengthCode_mm")); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.