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 53bf52b072c284946349bd840d04ec5511c0690e Author: Julien Ruchaud <julien.ruchaud@debux.org> Date: Wed Nov 16 11:31:33 2016 +0100 Correct export atlantos --- .../workingDb/h2/3.912-0-atlantos-operation.sql | 3 +++ .../workingDb/pg/3.912-0-atlantos-operation.sql | 3 +++ echobase-domain/src/main/xmi/echobase.zargo | Bin 100352 -> 100351 bytes .../service/atlantos/xml/VocabularyExport.java | 16 +++++++++--- .../service/atlantos/xml/XmlAccousticExport.java | 29 ++++++++++++--------- .../atlantos/ExportAtlantosServiceTest.java | 16 +++++++++++- 6 files changed, 51 insertions(+), 16 deletions(-) diff --git a/echobase-domain/src/main/resources/migration/workingDb/h2/3.912-0-atlantos-operation.sql b/echobase-domain/src/main/resources/migration/workingDb/h2/3.912-0-atlantos-operation.sql index e7e6a81..6041b96 100644 --- a/echobase-domain/src/main/resources/migration/workingDb/h2/3.912-0-atlantos-operation.sql +++ b/echobase-domain/src/main/resources/migration/workingDb/h2/3.912-0-atlantos-operation.sql @@ -42,3 +42,6 @@ insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150289', 0, '2016-04-29 00:00:00.000', 'Maturity_4', 'AC_MaturityCode_63'); insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150290', 0, '2016-04-29 00:00:00.000', 'Maturity_5', 'AC_MaturityCode_64'); insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150291', 0, '2016-04-29 00:00:00.000', 'Maturity_6', 'AC_MaturityCode_65'); + +update vocabularyciem SET code = 'Gear_PMT_57x52' WHERE label = '57x52'; +update vocabularyciem SET code = 'Gear_PMT_76x70' WHERE label = '76x70'; diff --git a/echobase-domain/src/main/resources/migration/workingDb/pg/3.912-0-atlantos-operation.sql b/echobase-domain/src/main/resources/migration/workingDb/pg/3.912-0-atlantos-operation.sql index e21a147..f724762 100644 --- a/echobase-domain/src/main/resources/migration/workingDb/pg/3.912-0-atlantos-operation.sql +++ b/echobase-domain/src/main/resources/migration/workingDb/pg/3.912-0-atlantos-operation.sql @@ -42,3 +42,6 @@ insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150289', 0, '2016-04-29 00:00:00.000', 'Maturity_4', 'AC_MaturityCode_63'); insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150290', 0, '2016-04-29 00:00:00.000', 'Maturity_5', 'AC_MaturityCode_64'); insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150291', 0, '2016-04-29 00:00:00.000', 'Maturity_6', 'AC_MaturityCode_65'); + +update vocabularyciem SET code = 'Gear_PMT_57x52' WHERE label = '57x52'; +update vocabularyciem SET code = 'Gear_PMT_76x70' WHERE label = '76x70'; diff --git a/echobase-domain/src/main/xmi/echobase.zargo b/echobase-domain/src/main/xmi/echobase.zargo index 6df5581..ffaaeb1 100644 Binary files a/echobase-domain/src/main/xmi/echobase.zargo and b/echobase-domain/src/main/xmi/echobase.zargo differ 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 70a85e8..2d398a2 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 @@ -28,6 +28,8 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; 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,8 +47,11 @@ public class VocabularyExport implements EchoBaseService { protected Map<String, Set<String>> cache; protected XmlWriter writer; + protected Pattern pattern; public void init(XmlWriter writer) throws IOException { + this.pattern = Pattern.compile("^(((AC_)|(ISO_)|(ICES_))?[^_]+)_(\\w+)"); + this.writer = writer; this.vocabularyTags = new HashMap<String, String>(); @@ -108,8 +113,10 @@ public class VocabularyExport implements EchoBaseService { this.writer.open(tag); for (String code : codes) { - String prefix = StringUtils.substringBeforeLast(code, "_"); - String value = StringUtils.substringAfterLast(code, "_"); + Matcher matcher = this.pattern.matcher(code); + matcher.find(); + String prefix = matcher.group(1); + String value = matcher.group(6); this.writer.create("Code", "ID", code, @@ -145,7 +152,10 @@ public class VocabularyExport implements EchoBaseService { } protected void addVocabulary(String code) throws IOException { - String prefix = StringUtils.substringBeforeLast(code, "_"); + Matcher matcher = this.pattern.matcher(code); + matcher.find(); + String prefix = matcher.group(1); + String tag = this.vocabularyTags.get(prefix); Set<String> codes = this.cache.get(tag); 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 1b89272..26c335f 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 @@ -24,6 +24,7 @@ import java.util.List; import java.util.function.Predicate; import javax.inject.Inject; import org.apache.commons.lang3.StringUtils; +import org.nuiton.topia.persistence.TopiaEntity; /* * #%L @@ -55,6 +56,10 @@ public class XmlAccousticExport implements EchoBaseService { @Inject protected VocabularyExport vocabulary; + public static String getFormatedTopiaId(TopiaEntity entity) { + return entity.getTopiaId().replaceAll("#", "_"); + } + public void doExport(Voyage voyage, XmlWriter xmlHead, XmlWriter xmlVoca, XmlWriter xmlCruise) throws IOException { boolean exportCruiseDone = false; vocabulary.init(xmlVoca); @@ -151,7 +156,7 @@ public class XmlAccousticExport implements EchoBaseService { public void exportInstrument(AcousticInstrument instrument, XmlWriter xml) throws IOException { xml.open("Instrument", - "ID", instrument.getTopiaId()); + "ID", XmlAccousticExport.getFormatedTopiaId(instrument)); xml.create("Frequency", instrument.getTransducerFrequency()); @@ -197,7 +202,7 @@ public class XmlAccousticExport implements EchoBaseService { public void exportCalibration(Calibration calibration, XmlWriter xml) throws IOException { xml.open("Calibration", - "ID", calibration.getTopiaId()); + "ID", XmlAccousticExport.getFormatedTopiaId(calibration)); xml.create("Date", EchoBaseCsvUtil.ISO8611_DATE_FORMATTER.format(calibration.getDate())); @@ -217,7 +222,7 @@ public class XmlAccousticExport implements EchoBaseService { public void exportDataAcquisition(DataAcquisition dataAcquisition, XmlWriter xml) throws IOException { xml.open("DataAcquisition", - "ID", dataAcquisition.getTopiaId()); + "ID", XmlAccousticExport.getFormatedTopiaId(dataAcquisition)); xml.create("SoftwareName", "IDREF", vocabulary.getVocabularyCode("Software_" + dataAcquisition.getSoftwareName(), "AC_DataAcquisitionSoftwareName_ER60")); @@ -235,7 +240,7 @@ public class XmlAccousticExport implements EchoBaseService { public void exportDataProcessing(DataProcessing dataProcessing, XmlWriter xml) throws IOException { xml.open("DataProcessing", - "ID", dataProcessing.getTopiaId()); + "ID", XmlAccousticExport.getFormatedTopiaId(dataProcessing)); xml.create("SoftwareName", "IDREF", vocabulary.getVocabularyCode(dataProcessing.getSoftwareName(), "AC_DataProcessingSoftwareName_test1")); @@ -360,7 +365,7 @@ public class XmlAccousticExport implements EchoBaseService { Float upperDepth = depthRefSurfaceData != null ? Float.parseFloat(depthRefSurfaceData.getDataValue()) : 0f; if (upperDepth >= 50) { - if (result.getCategory().getEchotypeLabel().equals("D4")) { + if (result.getCategory().getEchotype().getName().equals("D4")) { upperDepth = 30f; } else { lowerDepth = 30f; @@ -368,9 +373,9 @@ public class XmlAccousticExport implements EchoBaseService { } xml.create("ChannelDepthUpper", - upperDepth); + upperDepth.intValue()); xml.create("ChannelDepthLower", - lowerDepth); + lowerDepth.intValue()); xml.create("PingAxisInterval", 1); @@ -382,13 +387,13 @@ public class XmlAccousticExport implements EchoBaseService { cell.getDataProcessing().geteIThresholdLow()); xml.create("Instrument", - "IDREF", cell.getDataProcessing().getDataAcquisition().getAcousticInstrument().getTopiaId()); + "IDREF", XmlAccousticExport.getFormatedTopiaId(cell.getDataProcessing().getDataAcquisition().getAcousticInstrument())); xml.create("Calibration", - "IDREF", calibrationFound != null ? calibrationFound.getTopiaId() : ""); + "IDREF", calibrationFound != null ? XmlAccousticExport.getFormatedTopiaId(calibrationFound) : ""); xml.create("DataAcquisition", - "IDREF", cell.getDataProcessing().getDataAcquisition().getTopiaId()); + "IDREF", XmlAccousticExport.getFormatedTopiaId(cell.getDataProcessing().getDataAcquisition())); xml.create("DataProcessing", - "IDREF", cell.getDataProcessing().getTopiaId()); + "IDREF", XmlAccousticExport.getFormatedTopiaId(cell.getDataProcessing())); xml.create("PingAxisIntervalOrigin", "IDREF", vocabulary.getVocabularyCode("AC_PingAxisIntervalOrigin_" + prefix)); } @@ -397,7 +402,7 @@ public class XmlAccousticExport implements EchoBaseService { xml.open("Data"); xml.create("SaCategory", - "IDREF", vocabulary.getVocabularyCode(result.getCategory().getEchotypeLabel(), "AC_SaCategory_D4")); + "IDREF", vocabulary.getVocabularyCode(result.getCategory().getEchotype().getName(), "AC_SaCategory_D4")); xml.create("Type", "IDREF", vocabulary.getVocabularyCode("AC_AcousticDataType_C")); xml.create("Unit", diff --git a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/atlantos/ExportAtlantosServiceTest.java b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/atlantos/ExportAtlantosServiceTest.java index 21a3b93..3d242da 100644 --- a/echobase-services/src/test/java/fr/ifremer/echobase/services/service/atlantos/ExportAtlantosServiceTest.java +++ b/echobase-services/src/test/java/fr/ifremer/echobase/services/service/atlantos/ExportAtlantosServiceTest.java @@ -24,12 +24,13 @@ package fr.ifremer.echobase.services.service.atlantos; import fr.ifremer.echobase.services.EchoBaseTestServiceSupport; import fr.ifremer.echobase.services.FakeEchoBaseServiceContext; import fr.ifremer.echobase.services.ImportDataFixtures; -import org.junit.Assert; import org.junit.Test; import org.nuiton.util.FileUtil; import javax.inject.Inject; import java.io.File; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @author Julien Ruchaud - ruchaud@codelutin.com @@ -59,5 +60,18 @@ public class ExportAtlantosServiceTest extends EchoBaseTestServiceSupport { exportService.doXmlExport(model); } + +// @Test + public void testPattern() { + Pattern pattern = Pattern.compile("^(((AC_)|(ISO_)|(ICES_))?[^_]+)_(\\w+)"); + Matcher matcher = pattern.matcher("Gear_PMT_57x52"); + matcher.find(); + + matcher = pattern.matcher("SHIPC_35HT"); + matcher.find(); + + matcher = pattern.matcher("AC_SaCategory_D1"); + matcher.find(); + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.