branch develop updated (afab4f6 -> 85315cc)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository echobase. See https://gitlab.nuiton.org/codelutin/echobase.git from afab4f6 Export biotic export for atlantos new 85315cc Handle vocabulary in xml The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 85315cc6e7032a866886bf2f431f34e9f9407b75 Author: Julien Ruchaud <julien.ruchaud@debux.org> Date: Tue Oct 25 15:49:50 2016 +0200 Handle vocabulary in xml Summary of changes: .../migration/workingDb/h2/3.911-0-atlantos.sql | 32 +++++- .../migration/workingDb/pg/3.911-0-atlantos.sql | 30 +++++ .../service/atlantos/ExportAtlantosService.java | 36 ++++-- .../service/atlantos/xml/VocabularyExport.java | 123 +++++++++++++++------ .../service/atlantos/xml/XmlAccousticExport.java | 51 ++++----- .../service/atlantos/xml/XmlBioticExport.java | 36 +++--- .../services/service/atlantos/xml/XmlWriter.java | 11 +- 7 files changed, 228 insertions(+), 91 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 85315cc6e7032a866886bf2f431f34e9f9407b75 Author: Julien Ruchaud <julien.ruchaud@debux.org> Date: Tue Oct 25 15:49:50 2016 +0200 Handle vocabulary in xml --- .../migration/workingDb/h2/3.911-0-atlantos.sql | 32 +++++- .../migration/workingDb/pg/3.911-0-atlantos.sql | 30 +++++ .../service/atlantos/ExportAtlantosService.java | 36 ++++-- .../service/atlantos/xml/VocabularyExport.java | 123 +++++++++++++++------ .../service/atlantos/xml/XmlAccousticExport.java | 51 ++++----- .../service/atlantos/xml/XmlBioticExport.java | 36 +++--- .../services/service/atlantos/xml/XmlWriter.java | 11 +- 7 files changed, 228 insertions(+), 91 deletions(-) diff --git a/echobase-domain/src/main/resources/migration/workingDb/h2/3.911-0-atlantos.sql b/echobase-domain/src/main/resources/migration/workingDb/h2/3.911-0-atlantos.sql index f7c1d6c..fb07614 100644 --- a/echobase-domain/src/main/resources/migration/workingDb/h2/3.911-0-atlantos.sql +++ b/echobase-domain/src/main/resources/migration/workingDb/h2/3.911-0-atlantos.sql @@ -24,4 +24,34 @@ alter table vocabularyciem add constraint PK_VOCA primary key (topiaId); alter table vocabularyciem add constraint UK_VOCA_LABEL unique (label); alter table mission add column country varchar(255); -alter table species add column wormscode varchar(255); \ No newline at end of file +alter table species add column wormscode varchar(255); + +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150250', 0, '2016-04-29 00:00:00.000', 'Hull', 'AC_TransducerLocation_AA'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150251', 0, '2016-04-29 00:00:00.000', 'Split', 'AC_TransducerBeamType_S2'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150252', 0, '2016-04-29 00:00:00.000', '.hac and .raw formats', 'AC_StoredDataFormat_HAC'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150253', 0, '2016-04-29 00:00:00.000', 'ER60', 'AC_DataAcquisitionSoftwareName_ER60'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150254', 0, '2016-04-29 00:00:00.000', 'Movies3D', 'AC_DataProcessingSoftwareName_Movies3D'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150255', 0, '2016-04-29 00:00:00.000', 'PELGAS', 'AC_Survey_PELGAS'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150256', 0, '2016-04-29 00:00:00.000', 'France', 'ISO_3166_FR'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150257', 0, '2016-04-29 00:00:00.000', '35HT', 'SHIPC_35HT'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150258', 0, '2016-04-29 00:00:00.000', 'D1', 'AC_SaCategory_D1'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150259', 0, '2016-04-29 00:00:00.000', 'D2', 'AC_SaCategory_D2'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150260', 0, '2016-04-29 00:00:00.000', 'D3', 'AC_SaCategory_D3'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150261', 0, '2016-04-29 00:00:00.000', 'D4', 'AC_SaCategory_D4'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150262', 0, '2016-04-29 00:00:00.000', 'D5', 'AC_SaCategory_D5'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150263', 0, '2016-04-29 00:00:00.000', 'D6', 'AC_SaCategory_D6'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150264', 0, '2016-04-29 00:00:00.000', 'D7', 'AC_SaCategory_D7'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150265', 0, '2016-04-29 00:00:00.000', 'D8', 'AC_SaCategory_D8'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150266', 0, '2016-04-29 00:00:00.000', 'D9', 'AC_SaCategory_D9'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150267', 0, '2016-04-29 00:00:00.000', 'D10', 'AC_SaCategory_D10'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150268', 0, '2016-04-29 00:00:00.000', 'D11', 'AC_SaCategory_D11'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150269', 0, '2016-04-29 00:00:00.000', 'D12', 'AC_SaCategory_D12'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150270', 0, '2016-04-29 00:00:00.000', 'Standard sphere, in-situ', 'AC_AcquisitionMethod_SS'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150271', 0, '2016-04-29 00:00:00.000', 'ER', 'AC_ProcessingMethod_ER60'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150272', 0, '2016-04-29 00:00:00.000', '57x52', 'Gear_57x52'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150273', 0, '2016-04-29 00:00:00.000', '76x70', 'Gear_76x70'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150274', 0, '2016-04-29 00:00:00.000', '942OBS', 'Gear_PAR'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150275', 0, '2016-04-29 00:00:00.000', '0', 'AC_CatchCategory_1'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150276', 0, '2016-04-29 00:00:00.000', 'G', 'AC_CatchCategory_2'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150277', 0, '2016-04-29 00:00:00.000', 'P', 'AC_CatchCategory_3'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150278', 0, '2016-04-29 00:00:00.000', 'TP', 'AC_CatchCategory_4'); diff --git a/echobase-domain/src/main/resources/migration/workingDb/pg/3.911-0-atlantos.sql b/echobase-domain/src/main/resources/migration/workingDb/pg/3.911-0-atlantos.sql index ffb7a2b..ea3d5e0 100644 --- a/echobase-domain/src/main/resources/migration/workingDb/pg/3.911-0-atlantos.sql +++ b/echobase-domain/src/main/resources/migration/workingDb/pg/3.911-0-atlantos.sql @@ -25,3 +25,33 @@ alter table vocabularyciem add constraint UK_VOCA_LABEL unique (label); alter table mission add column country character varying(255); alter table species add column wormscode character varying(255); + +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150250', 0, '2016-04-29 00:00:00.000', 'Hull', 'AC_TransducerLocation_AA'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150251', 0, '2016-04-29 00:00:00.000', 'Split', 'AC_TransducerBeamType_S2'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150252', 0, '2016-04-29 00:00:00.000', '.hac and .raw formats', 'AC_StoredDataFormat_HAC'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150253', 0, '2016-04-29 00:00:00.000', 'ER60', 'AC_DataAcquisitionSoftwareName_ER60'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150254', 0, '2016-04-29 00:00:00.000', 'Movies3D', 'AC_DataProcessingSoftwareName_Movies3D'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150255', 0, '2016-04-29 00:00:00.000', 'PELGAS', 'AC_Survey_PELGAS'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150256', 0, '2016-04-29 00:00:00.000', 'France', 'ISO_3166_FR'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150257', 0, '2016-04-29 00:00:00.000', '35HT', 'SHIPC_35HT'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150258', 0, '2016-04-29 00:00:00.000', 'D1', 'AC_SaCategory_D1'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150259', 0, '2016-04-29 00:00:00.000', 'D2', 'AC_SaCategory_D2'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150260', 0, '2016-04-29 00:00:00.000', 'D3', 'AC_SaCategory_D3'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150261', 0, '2016-04-29 00:00:00.000', 'D4', 'AC_SaCategory_D4'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150262', 0, '2016-04-29 00:00:00.000', 'D5', 'AC_SaCategory_D5'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150263', 0, '2016-04-29 00:00:00.000', 'D6', 'AC_SaCategory_D6'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150264', 0, '2016-04-29 00:00:00.000', 'D7', 'AC_SaCategory_D7'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150265', 0, '2016-04-29 00:00:00.000', 'D8', 'AC_SaCategory_D8'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150266', 0, '2016-04-29 00:00:00.000', 'D9', 'AC_SaCategory_D9'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150267', 0, '2016-04-29 00:00:00.000', 'D10', 'AC_SaCategory_D10'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150268', 0, '2016-04-29 00:00:00.000', 'D11', 'AC_SaCategory_D11'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150269', 0, '2016-04-29 00:00:00.000', 'D12', 'AC_SaCategory_D12'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150270', 0, '2016-04-29 00:00:00.000', 'Standard sphere, in-situ', 'AC_AcquisitionMethod_SS'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150271', 0, '2016-04-29 00:00:00.000', 'ER', 'AC_ProcessingMethod_ER60'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150272', 0, '2016-04-29 00:00:00.000', '57x52', 'Gear_57x52'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150273', 0, '2016-04-29 00:00:00.000', '76x70', 'Gear_76x70'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150274', 0, '2016-04-29 00:00:00.000', '942OBS', 'Gear_PAR'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150275', 0, '2016-04-29 00:00:00.000', '0', 'AC_CatchCategory_1'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150276', 0, '2016-04-29 00:00:00.000', 'G', 'AC_CatchCategory_2'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150277', 0, '2016-04-29 00:00:00.000', 'P', 'AC_CatchCategory_3'); +insert into vocabularyciem (topiaId, topiaVersion, topiaCreateDate, label, code) values ('fr.ifremer.echobase.entities.references.VocabularyCIEM#5553610280597#0.93226150278', 0, '2016-04-29 00:00:00.000', 'TP', 'AC_CatchCategory_4'); diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/ExportAtlantosService.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/ExportAtlantosService.java index b00269a..802d7a9 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/ExportAtlantosService.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/ExportAtlantosService.java @@ -38,6 +38,7 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.text.SimpleDateFormat; +import org.apache.commons.io.IOUtils; /** * @author Julien Ruchaud - ruchaud@codelutin.com @@ -76,22 +77,37 @@ public class ExportAtlantosService extends EchoBaseServiceSupport { String year = formatter.format(voyage.getStartDate()); // Export Accoustic - Path output = Paths.get(basePath, "Acoustic_" + year + name + ".xml"); - FileWriter file = new FileWriter(output.toFile()); - XmlWriter xml = new XmlWriter(file); + Path outputAccousticHead = Paths.get(basePath, "Acoustic_" + year + name + "-head.xml"); + FileWriter fileAccousticHead = new FileWriter(outputAccousticHead.toFile()); + XmlWriter xmlAccousticHead = new XmlWriter(fileAccousticHead); - xmlAccousticExport.doExport(voyage, xml); - file.flush(); + Path outputAccousticVoca = Paths.get(basePath, "Acoustic_" + year + name + "-voca.xml"); + FileWriter fileAccousticVoca = new FileWriter(outputAccousticVoca.toFile()); + XmlWriter xmlAccousticVoca = new XmlWriter(fileAccousticVoca); + + Path outputAccousticCruise = Paths.get(basePath, "Acoustic_" + year + name + "-cruise.xml"); + FileWriter fileAccousticCruise = new FileWriter(outputAccousticCruise.toFile()); + XmlWriter xmlAccousticCruise = new XmlWriter(fileAccousticCruise); + + xmlAccousticExport.doExport(voyage, xmlAccousticHead, xmlAccousticVoca, xmlAccousticCruise); + fileAccousticHead.flush(); + fileAccousticVoca.flush(); + fileAccousticCruise.flush(); model.incrementsProgress(); // Export Biotic - output = Paths.get(basePath, "Biotic_" + year + name + ".xml"); - file = new FileWriter(output.toFile()); - xml = new XmlWriter(file); + Path outputBioticVoca = Paths.get(basePath, "Biotic_" + year + name + "-voca.xml"); + FileWriter fileBioticVoca = new FileWriter(outputBioticVoca.toFile()); + XmlWriter xmlBioticVoca = new XmlWriter(fileBioticVoca); + + Path outputBioticCruise = Paths.get(basePath, "Biotic_" + year + name + "-cruise.xml"); + FileWriter fileBioticCruise = new FileWriter(outputBioticCruise.toFile()); + XmlWriter xmlBioticCruise = new XmlWriter(fileBioticCruise); - xmlBioticExport.doExport(voyage, xml); - file.flush(); + xmlBioticExport.doExport(voyage, xmlBioticVoca, xmlBioticCruise); + fileBioticVoca.flush(); + fileBioticCruise.flush(); model.incrementsProgress(); } 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 5fe9231..763c3e8 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 @@ -2,9 +2,11 @@ package fr.ifremer.echobase.services.service.atlantos.xml; import fr.ifremer.echobase.services.EchoBaseService; import fr.ifremer.echobase.services.service.UserDbPersistenceService; +import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import org.apache.commons.lang3.StringUtils; /** * @@ -15,56 +17,107 @@ public class VocabularyExport implements EchoBaseService { @Inject private UserDbPersistenceService persistenceService; + protected Map<String, String> vocabularyTags; protected Map<String, String> vocabulary; + + protected XmlWriter writer; - public void init() { - vocabulary = new HashMap<String, String>(); + public void init(XmlWriter writer) throws IOException { + this.writer = writer; + + this.vocabularyTags = new HashMap<String, String>(); + + this.vocabularyTags.put("AC_Survey", "Survey"); + this.vocabularyTags.put("ISO_3166", "Country"); + this.vocabularyTags.put("SHIPC", "Platform"); + this.vocabularyTags.put("EDMO", "Organisation"); - vocabulary.put("Hull", "AC_TransducerLocation_AA"); - vocabulary.put("Split", "AC_TransducerBeamType_S2"); - vocabulary.put(".hac and .raw formats", "AC_StoredDataFormat_HAC"); - vocabulary.put("ER60", "AC_DataAcquisitionSoftwareName_ER60"); - vocabulary.put("Movies3D", "AC_DataProcessingSoftwareName_Movies3D"); - vocabulary.put("PELGAS", "AC_Survey_PELGAS"); - vocabulary.put("France", "ISO_3166_FR"); - vocabulary.put("35HT", "SHIPC_35HT"); - vocabulary.put("D1", "AC_SaCategory_D1"); - vocabulary.put("D2", "AC_SaCategory_D2"); - vocabulary.put("D3", "AC_SaCategory_D3"); - vocabulary.put("D4", "AC_SaCategory_D4"); - vocabulary.put("D5", "AC_SaCategory_D5"); - vocabulary.put("D6", "AC_SaCategory_D6"); - vocabulary.put("D7", "AC_SaCategory_D7"); - vocabulary.put("D8", "AC_SaCategory_D8"); - vocabulary.put("D9", "AC_SaCategory_D9"); - vocabulary.put("D10", "AC_SaCategory_D10"); - vocabulary.put("D11", "AC_SaCategory_D11"); - vocabulary.put("D12", "AC_SaCategory_D12"); - vocabulary.put("Standard sphere, in-situ", "AC_AcquisitionMethod_SS"); - vocabulary.put("ER60", "AC_ProcessingMethod_ER60"); // À vérifier dans le voca - vocabulary.put("57x52", "Gear_57x52"); // À vérifier dans le voca - vocabulary.put("76x70", "Gear_76x70"); // À vérifier dans le voca - vocabulary.put("942OBS", "Gear_PAR"); // À vérifier dans le voca - vocabulary.put("0", "AC_CatchCategory_1"); - vocabulary.put("G", "AC_CatchCategory_2"); - vocabulary.put("P", "AC_CatchCategory_3"); - vocabulary.put("TP", "AC_CatchCategory_4"); + // For Accoustic + this.vocabularyTags.put("AC_LogOrigin", "Origin"); + this.vocabularyTags.put("AC_SaCategory", "SaCategory"); + this.vocabularyTags.put("AC_AcousticDataType", "Type"); + this.vocabularyTags.put("AC_DataUnit", "Unit"); + this.vocabularyTags.put("AC_PingAxisIntervalType", "PingAxisIntervalType"); + this.vocabularyTags.put("AC_PingAxisIntervalUnit", "PingAxisIntervalUnit"); + this.vocabularyTags.put("AC_PingAxisIntervalOrigin", "PingAxisIntervalOrigin"); + this.vocabularyTags.put("AC_TransducerLocation", "TransducerLocation"); + this.vocabularyTags.put("AC_TransducerBeamType", "TransducerBeamType"); + this.vocabularyTags.put("AC_AcquisitionMethod", "AcquisitionMethod"); + this.vocabularyTags.put("AC_ProcessingMethod", "ProcessingMethod"); + this.vocabularyTags.put("AC_DataAcquisitionSoftwareName", "DataAcquisitionSoftwareName"); + this.vocabularyTags.put("AC_StoredDataFormat", "StoredDataFormat"); + this.vocabularyTags.put("AC_DataProcessingSoftwareName", "DataProcessingSoftwareName"); + this.vocabularyTags.put("AC_TriwaveCorrection", "TriwaveCorrection"); + this.vocabularyTags.put("AC_OnAxisGainUnit", "OnAxisGainUnit"); - Map<String, String> fromDB = persistenceService.getVocabulary(); - vocabulary.putAll(fromDB); + // For Biotic + this.vocabularyTags.put("Gear", "Gear"); + this.vocabularyTags.put("AC_HaulValidity", "HaulValidity"); + this.vocabularyTags.put("AC_GearExceptions", "GearExceptions"); + this.vocabularyTags.put("AC_DoorType", "DoorType"); + this.vocabularyTags.put("AC_CatchDataType", "DataType"); + this.vocabularyTags.put("SpecWoRMS", "SpeciesCode"); + this.vocabularyTags.put("AC_SpeciesValidity", "SpeciesValidity"); + this.vocabularyTags.put("AC_CatchCategory", "SpeciesCategory"); + this.vocabularyTags.put("AC_Sex", "Sex"); + this.vocabularyTags.put("AC_LengthCode", "LengthCode"); + this.vocabularyTags.put("AC_LengthMeasurementType", "LengthType"); + this.vocabularyTags.put("ICES_StockCode", "StockCode"); + this.vocabularyTags.put("AC_WeightUnit", "WeightUnit"); + this.vocabularyTags.put("AC_MaturityCode", "Maturity"); + this.vocabularyTags.put("AC_MaturityScale", "MaturityScale"); + this.vocabularyTags.put("AC_AgePlusGroup", "AgePlusGroup"); + this.vocabularyTags.put("AC_AgeSource", "AgeSource"); + this.vocabularyTags.put("AC_SamplingFlag", "SamplingFlag"); + + this.vocabulary = persistenceService.getVocabulary(); } - public String getVocabularyCode(String key, String defaultValue) { + public void begin() throws IOException { + this.writer.open("Vocabulary"); + } + + public void end() throws IOException { + this.writer.close("Vocabulary"); + } + + public String getVocabularyCode(String key, String defaultValue) throws IOException { if (key == null || key.trim().equals("")) { + this.addVocabulary(defaultValue); return defaultValue; } - String code = vocabulary.get(key.trim()); + String code = this.vocabulary.get(key.trim()); if (code == null) { + this.addVocabulary(defaultValue); return defaultValue; } + this.addVocabulary(code); return code; } + public String getVocabularyCode(String code) throws IOException { + this.addVocabulary(code); + return code; + } + + protected void addVocabulary(String code) throws IOException { + String prefix = StringUtils.substringBeforeLast(code, "_"); + String value = StringUtils.substringAfterLast(code, "_"); + + String tag = this.vocabularyTags.remove(prefix); + if (tag != null) { + + this.writer.open(tag); + + this.writer.create("Code", + "ID", code, + "CodeType", "http://acoustic.ices.dk/Services/Schema/XML/" + prefix + ".xml", + value); + + this.writer.close(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 66b229b..775f797 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 @@ -20,9 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.Date; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.function.Predicate; import javax.inject.Inject; import org.apache.commons.lang3.StringUtils; @@ -57,12 +55,14 @@ public class XmlAccousticExport implements EchoBaseService { @Inject protected VocabularyExport vocabulary; - public void doExport(Voyage voyage, XmlWriter xml) throws IOException { + public void doExport(Voyage voyage, XmlWriter xmlHead, XmlWriter xmlVoca, XmlWriter xmlCruise) throws IOException { boolean exportCruiseDone = false; - vocabulary.init(); + vocabulary.init(xmlVoca); + vocabulary.begin(); // EXPORT ACCOUSTIC - xml.open("Acoustic", + xmlHead.append("<?xml version=\"1.0\"?>\n"); + xmlHead.open("Acoustic", "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance", "xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); @@ -77,26 +77,26 @@ public class XmlAccousticExport implements EchoBaseService { // EXPORT INSTRUMENT AcousticInstrument acousticInstrument = dataAcquisition.getAcousticInstrument(); - this.exportInstrument(acousticInstrument, xml); + this.exportInstrument(acousticInstrument, xmlHead); // EXPORT CALIBRATION Collection<Calibration> calibrations = acousticInstrument.getCalibration(); for (Calibration calibration : calibrations) { - this.exportCalibration(calibration, xml); + this.exportCalibration(calibration, xmlHead); } // EXPORT DATA ACQUISITION - exportDataAcquisition(dataAcquisition, xml); + exportDataAcquisition(dataAcquisition, xmlHead); Collection<DataProcessing> dataProcessings = dataAcquisition.getDataProcessing(); for (DataProcessing dataProcessing : dataProcessings) { // EXPORT DATA PROCESSING - exportDataProcessing(dataProcessing, xml); + exportDataProcessing(dataProcessing, xmlHead); // EXPORT CRUISE if (!exportCruiseDone) { - exportCruise(voyage, transect, xml); + exportCruise(voyage, transect, xmlCruise); exportCruiseDone = true; } @@ -120,22 +120,22 @@ public class XmlAccousticExport implements EchoBaseService { for (Cell cell : orderingCells) { // EXPORT LOG - exportLog(cell, position++, xml); + exportLog(cell, position++, xmlCruise); Collection<Result> results = cell.getResult(); for (Result result : results) { if ("NASC".equals(result.getResultLabel())) { // EXPORT SAMPLE - exportSample(voyage, cell, result, xml); + exportSample(voyage, cell, result, xmlCruise); // EXPORT DATA - exportData(result, xml); - xml.close("Sample"); + exportData(result, xmlCruise); + xmlCruise.close("Sample"); } } - xml.close("Log"); + xmlCruise.close("Log"); } } } @@ -143,10 +143,11 @@ public class XmlAccousticExport implements EchoBaseService { } if (exportCruiseDone) { - xml.close("Cruise"); + xmlCruise.close("Cruise"); } - xml.close("Acoustic"); + xmlCruise.close("Acoustic"); + vocabulary.end(); } public void exportInstrument(AcousticInstrument instrument, XmlWriter xml) throws IOException { @@ -242,7 +243,7 @@ public class XmlAccousticExport implements EchoBaseService { xml.create("SoftwareVersion", dataProcessing.getProcessingSoftwareVersion()); xml.create("TriwaveCorrection", "IDREF", - "AC_TriwaveCorrection_NA"); + vocabulary.getVocabularyCode("AC_TriwaveCorrection_NA")); xml.create("ChannelID", dataProcessing.getChannelId()); xml.create("Bandwidth", @@ -256,7 +257,7 @@ public class XmlAccousticExport implements EchoBaseService { xml.create("OnAxisGain", dataProcessing.getTransceiverProcessingGain()); xml.create("OnAxisGainUnit", "IDREF", - "AC_OnAxisGainUnit_dB"); + vocabulary.getVocabularyCode("AC_OnAxisGainUnit_dB")); xml.create("SaCorrection", dataProcessing.getTransceiverProcessingSacorrection()); xml.create("Absorption", @@ -318,7 +319,7 @@ public class XmlAccousticExport implements EchoBaseService { xml.create("Longitude", dataValues.get("Longitude" + prefix).getDataValue()); xml.create("Origin", - "IDREF", "AC_LogOrigin_" + prefix); + "IDREF", vocabulary.getVocabularyCode("AC_LogOrigin_" + prefix)); } public void exportSample(Voyage voyage, Cell cell, Result result, XmlWriter xml) throws IOException { @@ -369,9 +370,9 @@ public class XmlAccousticExport implements EchoBaseService { xml.create("PingAxisInterval", 1); xml.create("PingAxisIntervalType", - "IDREF", "AC_PingAxisIntervalType_distance"); + "IDREF", vocabulary.getVocabularyCode("AC_PingAxisIntervalType_distance")); xml.create("PingAxisIntervalUnit", - "IDREF", "AC_PingAxisIntervalUnit_nmi"); + "IDREF", vocabulary.getVocabularyCode("AC_PingAxisIntervalUnit_nmi")); xml.create("SvThreshhold", cell.getDataProcessing().geteIThresholdLow()); @@ -384,7 +385,7 @@ public class XmlAccousticExport implements EchoBaseService { xml.create("DataProcessing", "IDREF", cell.getDataProcessing().getTopiaId()); xml.create("PingAxisIntervalOrigin", - "IDREF", "AC_PingAxisIntervalOrigin_" + prefix); + "IDREF", vocabulary.getVocabularyCode("AC_PingAxisIntervalOrigin_" + prefix)); } public void exportData(Result result, XmlWriter xml) throws IOException { @@ -393,9 +394,9 @@ public class XmlAccousticExport implements EchoBaseService { xml.create("SaCategory", "IDREF", vocabulary.getVocabularyCode(result.getCategory().getEchotypeLabel(), "AC_SaCategory_D4")); xml.create("Type", - "IDREF", "AC_AcousticDataType_C"); + "IDREF", vocabulary.getVocabularyCode("AC_AcousticDataType_C")); xml.create("Unit", - "IDREF", "AC_DataUnit_m2nmi-2"); + "IDREF", vocabulary.getVocabularyCode("AC_DataUnit_m2nmi-2")); xml.create("Value", result.getResultValue()); 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 d35f359..3660b7a 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 @@ -3,7 +3,6 @@ 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.GearMetadataValue; import fr.ifremer.echobase.entities.data.Operation; import fr.ifremer.echobase.entities.data.OperationMetadataValue; import fr.ifremer.echobase.entities.data.Sample; @@ -52,13 +51,15 @@ public class XmlBioticExport implements EchoBaseService { @Inject protected VocabularyExport vocabulary; - public void doExport(Voyage voyage, XmlWriter xml) throws IOException { - vocabulary.init(); + public void doExport(Voyage voyage, XmlWriter xmlVoca, XmlWriter xmlCruise) throws IOException { + vocabulary.init(xmlVoca); // EXPORT BIOTIC - xml.open("Biotic", + xmlVoca.append("<?xml version=\"1.0\"?>\n"); + xmlVoca.open("Biotic", "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance", "xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); + vocabulary.begin(); Collection<Transit> transits = voyage.getTransit(); Transit transit = transits.iterator().next(); @@ -66,14 +67,14 @@ public class XmlBioticExport implements EchoBaseService { Collection<Transect> transects = transit.getTransect(); Transect transect = transects.iterator().next(); - exportCruise(voyage, transect, xml); + exportCruise(voyage, transect, xmlCruise); int index = 1; Collection<Operation> operations = voyage.getAllOperations(); for (Operation operation : operations) { // EXPORT HAUL - exportHaul(operation, index++, xml); + exportHaul(operation, index++, xmlCruise); Map<String, Float> totalWeight = new HashMap<String, Float>(); Map<String, Integer> totalNumber = new HashMap<String, Integer>(); @@ -126,18 +127,19 @@ public class XmlBioticExport implements EchoBaseService { Integer number = totalNumber.get(code); // EXPORT CATCH - exportCatch(sample, weight, number, xml); + exportCatch(sample, weight, number, xmlCruise); // EXPORT BIOLOGY: nothing we don't have the data for the moment - xml.close("Catch"); + xmlCruise.close("Catch"); } - xml.close("Haul"); + xmlCruise.close("Haul"); } - xml.close("Cruise"); - xml.close("Biotic"); + xmlCruise.close("Cruise"); + xmlCruise.close("Biotic"); + vocabulary.end(); } public void exportCruise(Voyage voyage, Transect transect, XmlWriter xml) throws IOException { @@ -230,7 +232,7 @@ public class XmlBioticExport implements EchoBaseService { xml.create("Duration", (int)((operation.getGearShootingEndTime().getTime() - operation.getGearShootingStartTime().getTime()) / (1000 * 60))); xml.create("Validity", - "IDREF", "AC_HaulValidity_V"); + "IDREF", vocabulary.getVocabularyCode("AC_HaulValidity_V")); xml.create("StartLatitude", startLatitude); xml.create("StartLongitude", startLongitude); xml.create("StopLatitude", endLatitude); @@ -301,15 +303,15 @@ public class XmlBioticExport implements EchoBaseService { SpeciesCategory category = sample.getSpeciesCategory(); xml.create("DataType", - "IDREF", "AC_CatchDataType_R"); + "IDREF", vocabulary.getVocabularyCode("AC_CatchDataType_R")); xml.create("SpeciesCode", "IDREF", "SpecWoRMS_" + category.getSpecies().getWormsCode()); xml.create("SpeciesValidity", - "IDREF", "AC_SpeciesValidity_1"); + "IDREF", vocabulary.getVocabularyCode("AC_SpeciesValidity_1")); xml.create("SpeciesTotalNumber", number); xml.create("WeightUnit", - "IDREF", "AC_WeightUnit_kg"); + "IDREF", vocabulary.getVocabularyCode("AC_WeightUnit_kg")); xml.create("SpeciesTotalWeight", weight.intValue()); @@ -325,11 +327,11 @@ public class XmlBioticExport implements EchoBaseService { sample.getSampleWeight()); xml.create("LengthCode", - "IDREF", sampleDataValues.containsKey(SampleDataTypeImpl.LTCM0_5) ? "AC_LengthCode_halfcm" : "AC_LengthCode_cm"); + "IDREF", vocabulary.getVocabularyCode(sampleDataValues.containsKey(SampleDataTypeImpl.LTCM0_5) ? "AC_LengthCode_halfcm" : "AC_LengthCode_cm")); xml.create("LengthClass", sampleDataValues.get("LengthClass")); xml.create("LengthType", - "IDREF", "AC_LengthMeasurementType_1"); + "IDREF", vocabulary.getVocabularyCode("AC_LengthMeasurementType_1")); xml.create("NumberAtLength", sampleDataValues.get(SampleDataTypeImpl.NUMBER_AT_LENGTH)); xml.create("WeightAtLength", diff --git a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlWriter.java b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlWriter.java index 6ce3845..0c40036 100644 --- a/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlWriter.java +++ b/echobase-services/src/main/java/fr/ifremer/echobase/services/service/atlantos/xml/XmlWriter.java @@ -2,6 +2,7 @@ package fr.ifremer.echobase.services.service.atlantos.xml; import java.io.IOException; import java.io.Writer; +import java.util.Arrays; import org.apache.commons.lang.StringUtils; /* @@ -36,10 +37,14 @@ public class XmlWriter { public XmlWriter(Writer writer) throws IOException { this.writer = writer; - this.writer.append("<?xml version=\"1.0\"?>\n"); this.tab = ""; } + public Writer append(String content) throws IOException { + this.writer.append(content); + return this.writer; + } + public Writer open(String tag, String ... attributes) throws IOException { this.writer.append(this.tab + "<" + tag); this.addAttributes(attributes); @@ -75,8 +80,8 @@ public class XmlWriter { } protected void addAttributes(Object[] attributes) throws IOException { - if (attributes.length == 1) { - return; + if (attributes.length % 2 != 0) { + attributes = Arrays.copyOf(attributes, attributes.length - 1); } for (int index = 0; index < attributes.length; index+=2) { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm