r293 - in trunk: echobase-entities/src/main/java/fr/ifremer/echobase echobase-services/src/main/java/fr/ifremer/echobase/services echobase-services/src/main/java/fr/ifremer/echobase/services/configurations echobase-services/src/main/java/fr/ifremer/echobase/services/csv echobase-ui/src/main/resources/i18n echobase-ui/src/main/webapp/WEB-INF/jsp/importData
Author: tchemit Date: 2012-01-26 11:54:27 +0100 (Thu, 26 Jan 2012) New Revision: 293 Url: http://forge.codelutin.com/repositories/revision/echobase/293 Log: - improve csv model api - finalize acousticData import (service side) - improve comma data import (use real bean instead of a Map) Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModel.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModelRow.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransectImportModelRow.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransitImportModelRow.java Removed: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/models/ Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AccousticDataImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CommonDataCompleteImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CommonDataFromTransectImportService.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/configurations/AccousticDataImportConfiguration.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/CsvModelUtil.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityAssociationExportModel.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityAssociationImportModel.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityCsvModel.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/ExportQueryCsvModel.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransectImportModel.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransitImportModel.java trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/VoyageImportModel.java trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureAccousticData.jsp Modified: trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java =================================================================== --- trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-entities/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java 2012-01-26 10:54:27 UTC (rev 293) @@ -30,6 +30,8 @@ import fr.ifremer.echobase.entities.references.AcousticInstrument; import fr.ifremer.echobase.entities.references.AreaOfOperation; import fr.ifremer.echobase.entities.references.CellMethod; +import fr.ifremer.echobase.entities.references.CellType; +import fr.ifremer.echobase.entities.references.DataMetadata; import fr.ifremer.echobase.entities.references.DataQuality; import fr.ifremer.echobase.entities.references.DataType; import fr.ifremer.echobase.entities.references.DepthStratum; @@ -88,6 +90,13 @@ } }; + public static final Function<CellType, String> CELL_TYPE_ID = new Function<CellType, String>() { + @Override + public String apply(CellType input) { + return input.getId(); + } + }; + public static final Function<DepthStratum, String> DEPTH_STRATUM_ID = new Function<DepthStratum, String>() { @Override public String apply(DepthStratum input) { @@ -129,18 +138,21 @@ return input.getName(); } }; + public static final Function<DataType, String> DATA_TYPE_NAME = new Function<DataType, String>() { @Override public String apply(DataType input) { return input.getName(); } }; + public static final Function<CellMethod, String> CELL_METHOD_NAME = new Function<CellMethod, String>() { @Override public String apply(CellMethod input) { return input.getName(); } }; + public static final Function<DataProcessing, String> DATA_PROCESSING_ID = new Function<DataProcessing, String>() { @Override public String apply(DataProcessing input) { @@ -154,6 +166,7 @@ return input.getQualityDataFlagValues(); } }; + public static final Function<TopiaEntity, String> TO_TOPIAID = new Function<TopiaEntity, String>() { @Override @@ -161,12 +174,14 @@ return input.getTopiaId(); } }; + public static final Function<File, String> FILE_NAME = new Function<File, String>() { @Override public String apply(File input) { return input.getName(); } }; + public static final Function<SampleDataType, String> SAMPLE_DATA_TYPE_RAPTRI_CODE = new Function<SampleDataType, String>() { @Override public String apply(SampleDataType input) { @@ -180,6 +195,7 @@ return input.getName(); } }; + public static final Function<Gear, String> GEAR_CASINO_GEAR_NAME = new Function<Gear, String>() { @Override public String apply(Gear input) { @@ -195,6 +211,7 @@ return input.getId(); } }; + public static final Function<SizeCategory, String> SIZE_CATEGORY_NAME = new Function<SizeCategory, String>() { @Override public String apply(SizeCategory input) { @@ -216,7 +233,14 @@ } }; - public static String getSpeciesCategoryKey(Species species, SizeCategory sizeCategory,SexCategory sexCategory) { + public static final Function<DataMetadata, String> DATA_METADATA_NAME = new Function<DataMetadata, String>() { + @Override + public String apply(DataMetadata input) { + return input.getName(); + } + }; + + public static String getSpeciesCategoryKey(Species species, SizeCategory sizeCategory, SexCategory sexCategory) { String key = species.getBaracoudaCode(); if (sizeCategory != null) { key += "_" + sizeCategory.getName(); Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AccousticDataImportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AccousticDataImportService.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/AccousticDataImportService.java 2012-01-26 10:54:27 UTC (rev 293) @@ -23,11 +23,39 @@ */ package fr.ifremer.echobase.services; +import com.google.common.base.Preconditions; import com.google.common.collect.Maps; +import fr.ifremer.echobase.EchoBaseFunctions; import fr.ifremer.echobase.InputFile; import fr.ifremer.echobase.entities.EchoBaseUser; +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.data.CellDAO; +import fr.ifremer.echobase.entities.data.Data; +import fr.ifremer.echobase.entities.data.DataAcquisition; +import fr.ifremer.echobase.entities.data.DataAcquisitionDAO; +import fr.ifremer.echobase.entities.data.DataDAO; +import fr.ifremer.echobase.entities.data.DataProcessing; +import fr.ifremer.echobase.entities.data.DataProcessingDAO; +import fr.ifremer.echobase.entities.data.Transect; +import fr.ifremer.echobase.entities.data.Transit; +import fr.ifremer.echobase.entities.references.AcousticInstrument; +import fr.ifremer.echobase.entities.references.CellType; +import fr.ifremer.echobase.entities.references.DataMetadata; +import fr.ifremer.echobase.entities.references.Vessel; import fr.ifremer.echobase.services.configurations.AccousticDataImportConfiguration; +import fr.ifremer.echobase.services.csv.AcousticDataImportModel; +import fr.ifremer.echobase.services.csv.AcousticDataImportModelRow; +import org.nuiton.topia.TopiaException; +import org.nuiton.util.csv.Import; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.io.Reader; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; import java.util.Map; /** @@ -40,14 +68,409 @@ @Override public Map<InputFile, CsvImportResult> startImport(AccousticDataImportConfiguration configuration, - EchoBaseUser user) { + EchoBaseUser user) throws IOException, TopiaException { Map<InputFile, CsvImportResult> result = Maps.newHashMap(); - char csvSeparator = serviceContext.getConfiguration().getCsvSeparator(); - importMoviesFile(configuration.getMoviesFile(), csvSeparator); + + Transit transit = getEntityById(Transit.class, configuration.getTransitId()); + Vessel vessel = getEntityById(Vessel.class, configuration.getVesselId()); + + // find out the correct transect to use + Transect transect = transit.getTransect(vessel); + + List<AcousticInstrument> acousticInstruments = getEntities(AcousticInstrument.class); + Map<String, AcousticInstrument> acousticInstrumentsById = Maps.uniqueIndex( + acousticInstruments, EchoBaseFunctions.ACOUSTIC_INSTRUMENT_ID); + + List<CellType> cellTypes = getEntities(CellType.class); + Map<String, CellType> cellTypesById = Maps.uniqueIndex( + cellTypes, EchoBaseFunctions.CELL_TYPE_ID); + + List<DataMetadata> dataMetadatas = getEntities(DataMetadata.class); + Map<String, DataMetadata> dataMetadatasByName = Maps.uniqueIndex( + dataMetadatas, EchoBaseFunctions.DATA_METADATA_NAME); + + CellType esduCellType = cellTypesById.get("Esdu"); + Preconditions.checkNotNull(esduCellType); + + CellType elementaryCellType = cellTypesById.get("Elementary"); + Preconditions.checkNotNull(elementaryCellType); + + importMoviesFile(transect, + acousticInstrumentsById, + dataMetadatasByName, + esduCellType, + elementaryCellType, + configuration, + configuration.getMoviesFile()); return result; } - private void importMoviesFile(InputFile inputFile, char csvSeparator) { + private final DateFormat cellDateFormat = + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss'Z'"); + + private void importMoviesFile(Transect transect, + Map<String, AcousticInstrument> instrumentsById, + Map<String, DataMetadata> dataMetadatasByName, + CellType esduCellType, + CellType elementaryCellType, + AccousticDataImportConfiguration configuration, + InputFile inputFile) throws TopiaException, IOException { + + AcousticDataImportModel csvModel = new AcousticDataImportModel(serviceContext.getConfiguration().getCsvSeparator()); + + DataAcquisitionDAO dataAcquisitionDAO = + (DataAcquisitionDAO) getDAO(DataAcquisition.class); + DataProcessingDAO dataProcessingDAO = + (DataProcessingDAO) getDAO(DataProcessing.class); + CellDAO cellDAO = (CellDAO) getDAO(Cell.class); + DataDAO dataDAO = (DataDAO) getDAO(Data.class); + + Reader reader = new BufferedReader(new FileReader(inputFile.getFile())); + try { + Import<AcousticDataImportModelRow> importer = Import.newImport(csvModel, reader); + DataAcquisition dataAcquisition = null; + DataProcessing dataProcessing = null; + Cell esduCell = null; + Cell elementaryCell = null; + for (AcousticDataImportModelRow row : importer) { + + // Build the row acoustic instrument + String sndname = row.getSndName(); + String channelName = row.getChannelName(); + String instrumentId = sndname + channelName; + AcousticInstrument instrument = instrumentsById.get(instrumentId); + + if (dataAcquisition == null || + !instrument.equals(dataAcquisition.getAcousticInstrument())) { + + // first dataAcquisition or new instrument + + String softwareVersion = + getSoftwareVersion(configuration, instrument); + String soundSpeedCalculations = + getSoundSpeedCalculations(configuration, instrument); + + // create dataAcquisiton + dataAcquisition = createDataAcquisition( + configuration, + instrument, + softwareVersion, + soundSpeedCalculations, + row, + dataAcquisitionDAO + ); + + transect.addDataAcquisition(dataAcquisition); + + // create data processing + dataProcessing = createDataProcessing( + configuration, + softwareVersion, + soundSpeedCalculations, + row, + dataProcessingDAO + ); + + dataAcquisition.addDataProcessing(dataProcessing); + + // must start a fresh new esdu cell + esduCell = null; + } + + Date startDate = row.getEsduCellStartDate(); + String esduCellId = cellDateFormat.format(startDate); + + if (esduCell == null || !esduCellId.equals(esduCell.getName())) { + + // create esdu cell + esduCell = cellDAO.create( + Cell.PROPERTY_CELL_TYPE, esduCellType, + Cell.PROPERTY_NAME, esduCellId + ); + + dataProcessing.addCell(esduCell); + + // create esdu cell data + createEsduCellData(configuration, + esduCell, + dataMetadatasByName, + row, + dataDAO); + + // force to create a new elementary cell + elementaryCell = null; + } + + int cellNum = row.getElementaryCellNum(); + + String elementaryCellId = esduCellId + "_" + cellNum; + + if (elementaryCell == null || + !elementaryCellId.equals(elementaryCell.getName())) { + + // create the elementary cell + + elementaryCell = cellDAO.create( + Cell.PROPERTY_CELL_TYPE, elementaryCellType, + Cell.PROPERTY_NAME, elementaryCellId + ); + esduCell.addChilds(elementaryCell); + } + + // create datas of the elementary cell + createElementaryCellData(configuration, + elementaryCell, + dataMetadatasByName, + row, + dataDAO); + } + + } finally { + reader.close(); + } } + private void createEsduCellData(AccousticDataImportConfiguration configuration, + Cell cell, + Map<String, DataMetadata> dataMetadatasByName, + AcousticDataImportModelRow row, + DataDAO dao) throws TopiaException { + + DataMetadata dataMetadata; + Data data; + String dataValue; + + // create Latitude data + dataMetadata = dataMetadatasByName.get("LatitudeStart"); + dataValue = row.getEsduCellDataLatitude(); + data = dao.create(Data.PROPERTY_DATA_METADATA, dataMetadata); + data.setDataValue(dataValue); + cell.addData(data); + + // create Longitude data + dataMetadata = dataMetadatasByName.get("LongitudeStart"); + dataValue = row.getEsduCellDataLongitude(); + data = dao.create(Data.PROPERTY_DATA_METADATA, dataMetadata); + data.setDataValue(dataValue); + cell.addData(data); + + // create Depth data + dataMetadata = dataMetadatasByName.get("DepthRefSurfaceStart"); + dataValue = row.getEsduCellDataDepth(); + data = dao.create(Data.PROPERTY_DATA_METADATA, dataMetadata); + data.setDataValue(dataValue); + cell.addData(data); + + // create Time data + dataMetadata = dataMetadatasByName.get("TimeStart"); + dataValue = row.getEsduCellDataTime(); + data = dao.create(Data.PROPERTY_DATA_METADATA, dataMetadata); + data.setDataValue(dataValue); + cell.addData(data); + + // create AcousticDensity data + dataMetadata = dataMetadatasByName.get("sa"); + dataValue = row.getEsduCellDataAcousticDensity(); + data = dao.create(Data.PROPERTY_DATA_METADATA, dataMetadata); + data.setDataValue(dataValue); + cell.addData(data); + } + + private void createElementaryCellData(AccousticDataImportConfiguration configuration, + Cell cell, + Map<String, DataMetadata> dataMetadatasByName, + AcousticDataImportModelRow row, + DataDAO dao) throws TopiaException { + + DataMetadata dataMetadata; + Data data; + String dataValue; + + int cellType = row.getElementaryCellType(); + + String startMeta; + String endMeta; + + if (cellType == 0) { + + // surface + + startMeta = "DepthRefSurfaceStart"; + endMeta = "DepthRefSurfaceEnd"; + + } else { + + // bottom + + startMeta = "DepthRefBottomStart"; + endMeta = "DepthRefBottomEnd"; + + + } + + // create depth start data + dataMetadata = dataMetadatasByName.get(startMeta); + dataValue = row.getElementaryCellDataDepthStart(); + data = dao.create(Data.PROPERTY_DATA_METADATA, dataMetadata); + data.setDataValue(dataValue); + cell.addData(data); + + // create depth end data + dataMetadata = dataMetadatasByName.get(endMeta); + dataValue = row.getElementaryCellDataDepthEnd(); + data = dao.create(Data.PROPERTY_DATA_METADATA, dataMetadata); + data.setDataValue(dataValue); + cell.addData(data); + + // create acoustic density data + dataMetadata = dataMetadatasByName.get("sa"); + dataValue = row.getElementaryCellDataAcousticDensity(); + data = dao.create(Data.PROPERTY_DATA_METADATA, dataMetadata); + data.setDataValue(dataValue); + cell.addData(data); + + } + + private DataAcquisition createDataAcquisition(AccousticDataImportConfiguration configuration, + AcousticInstrument instrument, + String softwareVersion, + String soundSpeedCalculations, + AcousticDataImportModelRow row, + DataAcquisitionDAO dataAcquisitionDAO) throws TopiaException { + + String transceiverAcquisitionAbsorptionDescription = + configuration.getTransceiverAcquisitionAbsorptionDescription(); + String loggedDataFormat = configuration.getLoggedDataFormat(); + String loggedDataDatatype = configuration.getLoggedDataDatatype(); + String pingDutyCycle = configuration.getPingDutyCycle(); + String echosounderSoundSpeed = configuration.getEchosounderSoundSpeed(); + + DataAcquisition dataAcquisition = dataAcquisitionDAO.create(); + + // fill from manual configuration + dataAcquisition.setAcousticInstrument(instrument); + dataAcquisition.setTransceiverAcquisitionAbsorptionDescription(transceiverAcquisitionAbsorptionDescription); + dataAcquisition.setAcquisitionSoftwareVersion(softwareVersion); + dataAcquisition.setLoggedDataFormat(loggedDataFormat); + dataAcquisition.setLoggedDataDatatype(loggedDataDatatype); + dataAcquisition.setPingDutyCycle(pingDutyCycle); + dataAcquisition.setEchosounderSoundSpeed(echosounderSoundSpeed); + dataAcquisition.setSoundSpeedCalculations(soundSpeedCalculations); + + // fill from csv file + Float transceiverAcquisitionAbsorption = + row.getTransceiverAcquisitionAbsorption(); + Float transducerAcquisitionBeamAngleAthwartship = + row.getTransducerAcquisitionBeamAngleAthwartship(); + Float transducerAcquisitionBeamAngleAlongship = + row.getTransducerAcquisitionBeamAngleAlongship(); + Float transducerAcquisitionPsi = + row.getTransducerAcquisitionPsi(); + Float transceiverAcquisitionPower = + row.getTransceiverAcquisitionPower(); + Float transceiverAcquisitionPulseLength = + row.getTransceiverAcquisitionPulseLength(); + Float transceiverAcquisitionGain = + row.getTransceiverAcquisitionGain(); + Float transceiverAcquisitionSacorrection = + row.getTransceiverAcquisitionSacorrection(); + + dataAcquisition.setTransceiverAcquisitionAbsorption(transceiverAcquisitionAbsorption); + dataAcquisition.setTransducerAcquisitionBeamAngleAthwartship(transducerAcquisitionBeamAngleAthwartship); + dataAcquisition.setTransducerAcquisitionBeamAngleAlongship(transducerAcquisitionBeamAngleAlongship); + dataAcquisition.setTransducerAcquisitionPsi(transducerAcquisitionPsi); + dataAcquisition.setTransceiverAcquisitionPower(transceiverAcquisitionPower); + dataAcquisition.setTransceiverAcquisitionPulseLength(transceiverAcquisitionPulseLength); + dataAcquisition.setTransceiverAcquisitionGain(transceiverAcquisitionGain); + dataAcquisition.setTransceiverAcquisitionSacorrection(transceiverAcquisitionSacorrection); + + return dataAcquisition; + } + + private DataProcessing createDataProcessing(AccousticDataImportConfiguration configuration, + String softwareVersion, + String soundSpeedCalculations, + AcousticDataImportModelRow row, + DataProcessingDAO dataProcessingDAO) throws TopiaException { + + String transceiverAcquisitionAbsorptionDescription = + configuration.getTransceiverAcquisitionAbsorptionDescription(); + String echosounderSoundSpeed = configuration.getEchosounderSoundSpeed(); + String processingTemplate = configuration.getProcessingTemplate(); + String processingDescription = configuration.getProcessingDescription(); + Float sounderConstant = configuration.getSounderConstant(); + float digitThreshold = configuration.getDigitThreshold(); + String acousticDensityUnit = configuration.getAcousticDensityUnit(); + String notes = configuration.getNotes(); + + DataProcessing dataProcessing = dataProcessingDAO.create(); + + // fill from manual configuration + dataProcessing.setProcessingTemplate(processingTemplate); + dataProcessing.setProcessingDescription(processingDescription); + dataProcessing.setSounderConstant(sounderConstant); + dataProcessing.setDigitThreshold(digitThreshold); + dataProcessing.setAcousticDensityUnit(acousticDensityUnit); + dataProcessing.setNotes(notes); + dataProcessing.setProcessingSoftwareVersion(softwareVersion); + dataProcessing.setTransceiverProcessingAbsorptionDescription(transceiverAcquisitionAbsorptionDescription); + dataProcessing.setEchosounderSoundSpeed(echosounderSoundSpeed); + dataProcessing.setSoundSpeedCalculations(soundSpeedCalculations); + + // fill from csv file + + Float transceiverAcquisitionAbsorption = + row.getTransceiverAcquisitionAbsorption(); + Float transducerAcquisitionBeamAngleAthwartship = + row.getTransducerAcquisitionBeamAngleAthwartship(); + Float transducerAcquisitionBeamAngleAlongship = + row.getTransducerAcquisitionBeamAngleAlongship(); + Float transducerAcquisitionPsi = + row.getTransducerAcquisitionPsi(); + + Float transceiverAcquisitionGain = + row.getTransceiverAcquisitionGain(); + Float transceiverAcquisitionSacorrection = + row.getTransceiverAcquisitionSacorrection(); + Float eIThreshold = row.getEiThreshold(); + + dataProcessing.setEiThreshold(eIThreshold); + dataProcessing.setTransceiverProcessingSacorrection(transceiverAcquisitionSacorrection); + dataProcessing.setTransceiverProcessingAbsorption(transceiverAcquisitionAbsorption); + dataProcessing.setTransceiverProcessingGain(transceiverAcquisitionGain); + dataProcessing.setTransducerProcessingPsi(transducerAcquisitionPsi); + dataProcessing.setTransducerProcessingBeamAngleAthwartship(transducerAcquisitionBeamAngleAthwartship); + dataProcessing.setTransducerProcessingBeamAngleAlongship(transducerAcquisitionBeamAngleAlongship); + + + return dataProcessing; + } + + private String getSoftwareVersion(AccousticDataImportConfiguration configuration, + AcousticInstrument instrument) { + String softwareVersionER60 = configuration.getAcquisitionSoftwareVersionER60(); + String softwareVersionME70 = configuration.getAcquisitionSoftwareVersionME70(); + String transceiverModel = instrument.getTransceiverModel(); + String result = softwareVersionER60; + + //FIXME Finish this algorithm + if (transceiverModel.equals("ME70")) { + result = softwareVersionME70; + } + return result; + } + + private String getSoundSpeedCalculations(AccousticDataImportConfiguration configuration, + AcousticInstrument instrument) { + String speedCalculationsER60 = configuration.getSoundSpeedCalculationsER60(); + String speedCalculationsME70 = configuration.getSoundSpeedCalculationsME70(); + String transceiverModel = instrument.getTransceiverModel(); + String result = speedCalculationsER60; + //FIXME Finish this algorithm + if (transceiverModel.equals("ME70")) { + result = speedCalculationsME70; + } + return result; + } + } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CommonDataCompleteImportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CommonDataCompleteImportService.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CommonDataCompleteImportService.java 2012-01-26 10:54:27 UTC (rev 293) @@ -36,13 +36,14 @@ import fr.ifremer.echobase.entities.references.Vessel; import fr.ifremer.echobase.services.configurations.CommonDataCompleteImportConfiguration; import fr.ifremer.echobase.services.csv.TransectImportModel; +import fr.ifremer.echobase.services.csv.TransectImportModelRow; import fr.ifremer.echobase.services.csv.TransitImportModel; +import fr.ifremer.echobase.services.csv.TransitImportModelRow; import fr.ifremer.echobase.services.csv.VoyageImportModel; import org.nuiton.topia.TopiaException; import org.nuiton.topia.persistence.TopiaDAO; import org.nuiton.util.csv.Import; import org.nuiton.util.csv.ImportModel; -import org.nuiton.util.csv.ImportToMap; import java.io.BufferedReader; import java.io.FileReader; @@ -66,17 +67,19 @@ Map<InputFile, CsvImportResult> result = Maps.newHashMap(); - char csvSeparator = serviceContext.getConfiguration().getCsvSeparator(); - Mission mission = getEntityById(Mission.class, configuration.getMissionId()); - AreaOfOperation areaOfOperation = getEntityById(AreaOfOperation.class, configuration.getAreaOfOperationId()); - Vessel vessel = getEntityById(Vessel.class, configuration.getVesselId()); + Mission mission = getEntityById(Mission.class, + configuration.getMissionId()); + AreaOfOperation areaOfOperation = + getEntityById(AreaOfOperation.class, + configuration.getAreaOfOperationId()); + Vessel vessel = getEntityById(Vessel.class, + configuration.getVesselId()); importVoyageFile(configuration.getVoyageFile(), mission, areaOfOperation, configuration.getVoyageDescription(), - configuration.getDatum(), - csvSeparator); + configuration.getDatum()); List<Voyage> allVoyages = getEntities(Voyage.class); Map<String, Voyage> voyageMap = Maps.uniqueIndex( @@ -84,8 +87,7 @@ importTransitFile(configuration.getTransitFile(), voyageMap, - configuration.getTransitRelatedActivity(), - csvSeparator); + configuration.getTransitRelatedActivity()); importTransectFile(configuration.getTransectFile(), vessel, @@ -93,10 +95,9 @@ configuration.getDatum(), configuration.getTransectLicence(), configuration.getTransectGeospatialVerticalPositive(), - configuration.getTransectBinUnitsPingAxis(), - csvSeparator); + configuration.getTransectBinUnitsPingAxis()); - importEchotypeFile(configuration.getEchotypeFile(), csvSeparator); + importEchotypeFile(configuration.getEchotypeFile()); commitTransaction("Could not commit transaction of common data import"); return result; @@ -117,11 +118,10 @@ Mission mission, AreaOfOperation areaOfOperation, String voyageDescription, - String datum, - char csvSeparator) throws IOException, TopiaException { + String datum) throws IOException, TopiaException { - ImportModel<Voyage> csvModel = new VoyageImportModel(csvSeparator); + ImportModel<Voyage> csvModel = new VoyageImportModel(serviceContext.getConfiguration().getCsvSeparator()); TopiaDAO<Voyage> dao = getDAO(Voyage.class); Reader reader = new BufferedReader(new FileReader(inputFile.getFile())); @@ -142,27 +142,26 @@ protected void importTransitFile(InputFile inputFile, Map<String, Voyage> voyageMap, - String relatedActivity, - char csvSeparator) throws TopiaException, IOException { - TransitImportModel csvModel = new TransitImportModel(csvSeparator, voyageMap); + String relatedActivity) throws TopiaException, IOException { + TransitImportModel csvModel = new TransitImportModel(serviceContext.getConfiguration().getCsvSeparator(), voyageMap); TopiaDAO<Transit> dao = getDAO(Transit.class); Reader reader = new BufferedReader(new FileReader(inputFile.getFile())); try { - ImportToMap importer = ImportToMap.newImport(csvModel, reader); - for (Map<String, Object> row : importer) { + Import<TransitImportModelRow> importer = Import.newImport(csvModel, reader); + for (TransitImportModelRow row : importer) { - Voyage voyage = (Voyage) row.get(TransitImportModel.TRANSIT_VoyageId); + Voyage voyage = row.getVoyage(); Transit transit = dao.create(); - transit.setDescription((String) row.get(Transit.PROPERTY_DESCRIPTION)); - transit.setStartLocality((String) row.get(Transit.PROPERTY_START_LOCALITY)); - transit.setEndLocality((String) row.get(Transit.PROPERTY_END_LOCALITY)); + transit.setDescription(row.getDescription()); + transit.setStartLocality(row.getStartLocality()); + transit.setEndLocality(row.getEndLocality()); - transit.setStartTime((Date) row.get(Transit.PROPERTY_START_TIME)); - transit.setEndTime((Date) row.get(Transit.PROPERTY_END_TIME)); + transit.setStartTime(row.getStartTime()); + transit.setEndTime(row.getEndTime()); transit.setRelatedActivity(relatedActivity); voyage.addTransit(transit); } @@ -178,23 +177,23 @@ String datum, String license, String geospatialVerticalPositive, - String binUnitsPingAxis, - char csvSeparator + String binUnitsPingAxis ) throws TopiaException, IOException { - TransectImportModel csvModel = new TransectImportModel(csvSeparator, voyageMap); + TransectImportModel csvModel = new TransectImportModel(serviceContext.getConfiguration().getCsvSeparator(), voyageMap); TopiaDAO<Transect> dao = getDAO(Transect.class); Reader reader = new BufferedReader(new FileReader(inputFile.getFile())); try { - ImportToMap importer = ImportToMap.newImport(csvModel, reader); - for (Map<String, Object> row : importer) { + Import<TransectImportModelRow> importer = + Import.newImport(csvModel, reader); + for (TransectImportModelRow row : importer) { - Voyage voyage = (Voyage) row.get(TransectImportModel.TRANSECT_VoyageId); + Voyage voyage = row.getVoyage(); - Date timeCoverageStart = (Date) row.get(Transect.PROPERTY_TIME_COVERAGE_START); - Date timeCoverageEnd = (Date) row.get(Transect.PROPERTY_TIME_COVERAGE_END); + Date timeCoverageStart = row.getTimeCoverageStart(); + Date timeCoverageEnd = row.getTimeCoverageEnd(); Transit transit = voyage.getTransit(timeCoverageStart, timeCoverageEnd); if (transit == null) { @@ -206,29 +205,28 @@ Transect.PROPERTY_VESSEL, vessel ); - transect.setTitle((String) row.get(Transect.PROPERTY_TITLE)); - transect.setTransectAbstract((String) row.get(Transect.PROPERTY_TRANSECT_ABSTRACT)); - transect.setComment((String) row.get(Transect.PROPERTY_COMMENT)); + transect.setTitle(row.getTitle()); + transect.setTransectAbstract(row.getTransectAbstract()); + transect.setComment(row.getComment()); transect.setDatum(datum); transect.setLicence(license); transect.setGeospatialVerticalPositive(geospatialVerticalPositive); transect.setBinUnitsPingAxis(binUnitsPingAxis); - transect.setDateCreated((Date) row.get(Transect.PROPERTY_DATE_CREATED)); + transect.setDateCreated(row.getDateCreated()); transect.setTimeCoverageStart(timeCoverageStart); transect.setTimeCoverageEnd(timeCoverageEnd); - transect.setGeospatialLatMin((Float) row.get(Transect.PROPERTY_GEOSPATIAL_LAT_MIN)); - transect.setGeospatialLonMin((Float) row.get(Transect.PROPERTY_GEOSPATIAL_LON_MIN)); - transect.setGeospatialVerticalMin((Float) row.get(Transect.PROPERTY_GEOSPATIAL_VERTICAL_MIN)); + transect.setGeospatialLatMin(row.getGeospatialLatMin()); + transect.setGeospatialLonMin(row.getGeospatialLonMin()); + transect.setGeospatialVerticalMin(row.getGeospatialVerticalMin()); - transect.setGeospatialLatMax((Float) row.get(Transect.PROPERTY_GEOSPATIAL_LAT_MAX)); - transect.setGeospatialLonMax((Float) row.get(Transect.PROPERTY_GEOSPATIAL_LON_MAX)); - transect.setGeospatialVerticalMax((Float) row.get(Transect.PROPERTY_GEOSPATIAL_VERTICAL_MAX)); - transect.setLinestring((String) row.get(Transect.PROPERTY_LINESTRING)); - + transect.setGeospatialLatMax(row.getGeospatialLatMax()); + transect.setGeospatialLonMax(row.getGeospatialLonMax()); + transect.setGeospatialVerticalMax(row.getGeospatialVerticalMax()); + transect.setLinestring(row.getLinestring()); transit.addTransect(transect); } @@ -237,7 +235,7 @@ } } - private void importEchotypeFile(InputFile inputFile, char csvSeparator) { + private void importEchotypeFile(InputFile inputFile) { } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CommonDataFromTransectImportService.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CommonDataFromTransectImportService.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/CommonDataFromTransectImportService.java 2012-01-26 10:54:27 UTC (rev 293) @@ -34,9 +34,10 @@ import fr.ifremer.echobase.entities.references.Vessel; import fr.ifremer.echobase.services.configurations.CommonDataFromTransectImportConfiguration; import fr.ifremer.echobase.services.csv.TransectImportModel; +import fr.ifremer.echobase.services.csv.TransectImportModelRow; import org.nuiton.topia.TopiaException; import org.nuiton.topia.persistence.TopiaDAO; -import org.nuiton.util.csv.ImportToMap; +import org.nuiton.util.csv.Import; import java.io.BufferedReader; import java.io.FileReader; @@ -59,7 +60,6 @@ EchoBaseUser user) throws IOException, TopiaException { Map<InputFile, CsvImportResult> result = Maps.newHashMap(); - char csvSeparator = serviceContext.getConfiguration().getCsvSeparator(); Voyage voyage = getEntityById(Voyage.class, configuration.getVoyageId()); Vessel vessel = getEntityById(Vessel.class, configuration.getVesselId()); @@ -71,11 +71,7 @@ voyage, voyageMap, vessel, - configuration.getDatum(), - configuration.getTransectLicence(), - configuration.getTransectGeospatialVerticalPositive(), - configuration.getTransectBinUnitsPingAxis(), - csvSeparator); + configuration); return result; } @@ -83,24 +79,26 @@ Voyage voyage, Map<String, Voyage> voyageMap, Vessel vessel, - String datum, - String license, - String geospatialVerticalPositive, - String binUnitsPingAxis, - char csvSeparator + CommonDataFromTransectImportConfiguration configuration ) throws TopiaException, IOException { - TransectImportModel csvModel = new TransectImportModel(csvSeparator, voyageMap); + String datum = configuration.getDatum(); + String license = configuration.getTransectLicence(); + String geospatialVerticalPositive = configuration.getTransectGeospatialVerticalPositive(); + String binUnitsPingAxis = configuration.getTransectBinUnitsPingAxis(); + TransectImportModel csvModel = new TransectImportModel(serviceContext.getConfiguration().getCsvSeparator(), + voyageMap); + TopiaDAO<Transect> dao = getDAO(Transect.class); Reader reader = new BufferedReader(new FileReader(inputFile.getFile())); try { - ImportToMap importer = ImportToMap.newImport(csvModel, reader); - for (Map<String, Object> row : importer) { + Import<TransectImportModelRow> importer = Import.newImport(csvModel, reader); + for (TransectImportModelRow row : importer) { - Date timeCoverageStart = (Date) row.get(Transect.PROPERTY_TIME_COVERAGE_START); - Date timeCoverageEnd = (Date) row.get(Transect.PROPERTY_TIME_COVERAGE_END); + Date timeCoverageStart = row.getTimeCoverageStart(); + Date timeCoverageEnd = row.getTimeCoverageEnd(); Transit transit = voyage.getTransit(timeCoverageStart, timeCoverageEnd); if (transit == null) { @@ -109,31 +107,30 @@ voyage.getName() + " between " + timeCoverageStart + " and " + timeCoverageEnd); } - Transect transect = dao.create( - Transect.PROPERTY_VESSEL, vessel - ); + Transect transect = + dao.create(Transect.PROPERTY_VESSEL, vessel); - transect.setTitle((String) row.get(Transect.PROPERTY_TITLE)); - transect.setTransectAbstract((String) row.get(Transect.PROPERTY_TRANSECT_ABSTRACT)); - transect.setComment((String) row.get(Transect.PROPERTY_COMMENT)); + transect.setTitle(row.getTitle()); + transect.setTransectAbstract(row.getTransectAbstract()); + transect.setComment(row.getComment()); transect.setDatum(datum); transect.setLicence(license); transect.setGeospatialVerticalPositive(geospatialVerticalPositive); transect.setBinUnitsPingAxis(binUnitsPingAxis); - transect.setDateCreated((Date) row.get(Transect.PROPERTY_DATE_CREATED)); + transect.setDateCreated(row.getDateCreated()); transect.setTimeCoverageStart(timeCoverageStart); transect.setTimeCoverageEnd(timeCoverageEnd); - transect.setGeospatialLatMin((Float) row.get(Transect.PROPERTY_GEOSPATIAL_LAT_MIN)); - transect.setGeospatialLonMin((Float) row.get(Transect.PROPERTY_GEOSPATIAL_LON_MIN)); - transect.setGeospatialVerticalMin((Float) row.get(Transect.PROPERTY_GEOSPATIAL_VERTICAL_MIN)); + transect.setGeospatialLatMin(row.getGeospatialLatMin()); + transect.setGeospatialLonMin(row.getGeospatialLonMin()); + transect.setGeospatialVerticalMin(row.getGeospatialVerticalMin()); - transect.setGeospatialLatMax((Float) row.get(Transect.PROPERTY_GEOSPATIAL_LAT_MAX)); - transect.setGeospatialLonMax((Float) row.get(Transect.PROPERTY_GEOSPATIAL_LON_MAX)); - transect.setGeospatialVerticalMax((Float) row.get(Transect.PROPERTY_GEOSPATIAL_VERTICAL_MAX)); - transect.setLinestring((String) row.get(Transect.PROPERTY_LINESTRING)); + transect.setGeospatialLatMax(row.getGeospatialLatMax()); + transect.setGeospatialLonMax(row.getGeospatialLonMax()); + transect.setGeospatialVerticalMax(row.getGeospatialVerticalMax()); + transect.setLinestring(row.getLinestring()); transit.addTransect(transect); } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/configurations/AccousticDataImportConfiguration.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/configurations/AccousticDataImportConfiguration.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/configurations/AccousticDataImportConfiguration.java 2012-01-26 10:54:27 UTC (rev 293) @@ -42,24 +42,61 @@ /** Selected voyage id where to import datas. */ protected String voyageId; + /** Selected transit id where to import datas. */ + protected String transitId; + /** Selected vessel id to find out transect where to import datas. */ protected String vesselId; + /** Manual transceiverAcquisitionAbsorptionDescription. */ + protected String transceiverAcquisitionAbsorptionDescription = "(i) Equation: Francois and garrison 1982,(ii) CTD, (iii) nominal value for entire data set"; + + /** Manual acquisitionSoftwareVersion (ER60 instrument). */ + protected String acquisitionSoftwareVersionER60; + + /** Manual acquisitionSoftwareVersion (ME70 instrument). */ + protected String acquisitionSoftwareVersionME70; + + /** Manual loggedDataFormat. */ + protected String loggedDataFormat = ".hac and .raw formats"; + + /** Manual loggedDataDatatype. */ + protected String loggedDataDatatype = "‘raw’ digitisation samples"; + + /** Manual pingDutyCycle. */ + protected String pingDutyCycle = "Ifremer's standard ping duty cycle"; + /** Manual echosounderSoundSpeed. */ protected String echosounderSoundSpeed = "Variable"; - /** Manual soundSpeedCalculations. */ - protected String soundSpeedCalculations = "SVProbe"; + /** Manual soundSpeedCalculations (ER60 instrument). */ + protected String soundSpeedCalculationsER60 = "(i) Equation: Mackenzie (1980), (ii) CTD, (iii) nominal value for entire data set"; - /** Manual pingDutyCycle. */ - protected String pingDutyCycle = "ME70Table"; + /** Manual soundSpeedCalculations (ME70 instrument). */ + protected String soundSpeedCalculationsME70 = "(i) Equation: Mackenzie (1980), (ii) Hull-mounted thermosalinometer, (iii) surface absorption value recomputed every 30s and applied to the entire data set"; + /** Manual sounderConstant. */ + protected Float sounderConstant; + + /** Manual processingTemplate. */ + protected String processingTemplate; + + /** Manual processingDescription. */ + protected String processingDescription; + + /** Manual digitThreshold. */ + protected float digitThreshold = -100f; + + /** Manual acousticDensityUnit. */ + protected String acousticDensityUnit = "sA"; + /** Manual notes. */ protected String notes; /** Movies file to import. */ protected final InputFile moviesFile; + public AccousticDataImportConfiguration(Locale locale) { moviesFile = InputFile.newFile(l_(locale, "echobase.common.moviesFile")); } @@ -72,6 +109,15 @@ this.voyageId = voyageId; } + + public String getTransitId() { + return transitId; + } + + public void setTransitId(String transitId) { + this.transitId = transitId; + } + public String getVesselId() { return vesselId; } @@ -80,22 +126,46 @@ this.vesselId = vesselId; } - public String getEchosounderSoundSpeed() { - return echosounderSoundSpeed; + public String getTransceiverAcquisitionAbsorptionDescription() { + return transceiverAcquisitionAbsorptionDescription; } - public void setEchosounderSoundSpeed(String echosounderSoundSpeed) { - this.echosounderSoundSpeed = echosounderSoundSpeed; + public void setTransceiverAcquisitionAbsorptionDescription(String transceiverAcquisitionAbsorptionDescription) { + this.transceiverAcquisitionAbsorptionDescription = transceiverAcquisitionAbsorptionDescription; } - public String getSoundSpeedCalculations() { - return soundSpeedCalculations; + public String getAcquisitionSoftwareVersionER60() { + return acquisitionSoftwareVersionER60; } - public void setSoundSpeedCalculations(String soundSpeedCalculations) { - this.soundSpeedCalculations = soundSpeedCalculations; + public void setAcquisitionSoftwareVersionER60(String acquisitionSoftwareVersionER60) { + this.acquisitionSoftwareVersionER60 = acquisitionSoftwareVersionER60; } + public String getAcquisitionSoftwareVersionME70() { + return acquisitionSoftwareVersionME70; + } + + public void setAcquisitionSoftwareVersionME70(String acquisitionSoftwareVersionME70) { + this.acquisitionSoftwareVersionME70 = acquisitionSoftwareVersionME70; + } + + public String getLoggedDataFormat() { + return loggedDataFormat; + } + + public void setLoggedDataFormat(String loggedDataFormat) { + this.loggedDataFormat = loggedDataFormat; + } + + public String getLoggedDataDatatype() { + return loggedDataDatatype; + } + + public void setLoggedDataDatatype(String loggedDataDatatype) { + this.loggedDataDatatype = loggedDataDatatype; + } + public String getPingDutyCycle() { return pingDutyCycle; } @@ -104,6 +174,54 @@ this.pingDutyCycle = pingDutyCycle; } + public String getEchosounderSoundSpeed() { + return echosounderSoundSpeed; + } + + public void setEchosounderSoundSpeed(String echosounderSoundSpeed) { + this.echosounderSoundSpeed = echosounderSoundSpeed; + } + + public String getSoundSpeedCalculationsER60() { + return soundSpeedCalculationsER60; + } + + public void setSoundSpeedCalculationsER60(String soundSpeedCalculationsER60) { + this.soundSpeedCalculationsER60 = soundSpeedCalculationsER60; + } + + public String getSoundSpeedCalculationsME70() { + return soundSpeedCalculationsME70; + } + + public void setSoundSpeedCalculationsME70(String soundSpeedCalculationsME70) { + this.soundSpeedCalculationsME70 = soundSpeedCalculationsME70; + } + + public Float getSounderConstant() { + return sounderConstant; + } + + public void setSounderConstant(Float sounderConstant) { + this.sounderConstant = sounderConstant; + } + + public float getDigitThreshold() { + return digitThreshold; + } + + public void setDigitThreshold(float digitThreshold) { + this.digitThreshold = digitThreshold; + } + + public String getAcousticDensityUnit() { + return acousticDensityUnit; + } + + public void setAcousticDensityUnit(String acousticDensityUnit) { + this.acousticDensityUnit = acousticDensityUnit; + } + public String getNotes() { return notes; } @@ -116,6 +234,22 @@ return moviesFile; } + public String getProcessingTemplate() { + return processingTemplate; + } + + public void setProcessingTemplate(String processingTemplate) { + this.processingTemplate = processingTemplate; + } + + public String getProcessingDescription() { + return processingDescription; + } + + public void setProcessingDescription(String processingDescription) { + this.processingDescription = processingDescription; + } + @Override public InputFile[] getInputFiles() { return new InputFile[]{moviesFile}; Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModel.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModel.java 2012-01-26 10:54:27 UTC (rev 293) @@ -0,0 +1,139 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services.csv; + +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; + +/** + * To import acoustic datas (says {@link DataAcquisition}, + * {@link DataProcessing}, {@link Cell} and {@link Data}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class AcousticDataImportModel extends CsvModelUtil.AbstractImportModel<AcousticDataImportModelRow> { + + public AcousticDataImportModel(char separator) { + super(separator); + newIgnoredColumn("MOVIES_EILayer");//A + newIgnoredColumn("MOVIES_EILayer\\sndset");//B + newMandatoryColumn("MOVIES_EILayer\\sndset\\sndname", AcousticDataImportModelRow.PROPERTY_SNDNAME);//C + newIgnoredColumn("MOVIES_EILayer\\sndset\\sndident");//D + newIgnoredColumn("MOVIES_EILayer\\sndset\\softChannelId");//E + newMandatoryColumn("MOVIES_EILayer\\sndset\\channelName", AcousticDataImportModelRow.PROPERTY_CHANNEL_NAME);//F + newIgnoredColumn("MOVIES_EILayer\\sndset\\dataType");//G + newIgnoredColumn("MOVIES_EILayer\\sndset\\beamType");//H + newIgnoredColumn("MOVIES_EILayer\\sndset\\acousticFrequency");//I + newIgnoredColumn("MOVIES_EILayer\\sndset\\startSample");//J + newIgnoredColumn("MOVIES_EILayer\\sndset\\mainBeamAlongSteeringAngle");//K + newIgnoredColumn("MOVIES_EILayer\\sndset\\mainBeamAthwartSteeringAngle");//L + newMandatoryColumn("MOVIES_EILayer\\sndset\\absorptionCoef", AcousticDataImportModelRow.PROPERTY_TRANSCEIVER_ACQUISITION_ABSORPTION, CsvModelUtil.FLOAT);//M + newMandatoryColumn("MOVIES_EILayer\\sndset\\transmissionPower", AcousticDataImportModelRow.PROPERTY_TRANSCEIVER_ACQUISITION_POWER, CsvModelUtil.INTEGER);//N + newMandatoryColumn("MOVIES_EILayer\\sndset\\beamAlongAngleSensitivity", AcousticDataImportModelRow.PROPERTY_TRANSDUCER_ACQUISITION_BEAM_ANGLE_ALONGSHIP, CsvModelUtil.FLOAT);//O + newMandatoryColumn("MOVIES_EILayer\\sndset\\beamAthwartAngleSensitivity", AcousticDataImportModelRow.PROPERTY_TRANSDUCER_ACQUISITION_BEAM_ANGLE_ATHWARTSHIP, CsvModelUtil.FLOAT);//P + newIgnoredColumn("MOVIES_EILayer\\sndset\\beam3dBWidthAlong");//Q + newIgnoredColumn("MOVIES_EILayer\\sndset\\beam3dBWidthAthwart");//R + newMandatoryColumn("MOVIES_EILayer\\sndset\\beamEquTwoWayAngle", AcousticDataImportModelRow.PROPERTY_TRANSDUCER_ACQUISITION_PSI, CsvModelUtil.FLOAT);//S + newMandatoryColumn("MOVIES_EILayer\\sndset\\beamGain", AcousticDataImportModelRow.PROPERTY_TRANSCEIVER_ACQUISITION_GAIN, CsvModelUtil.FLOAT);//T + newMandatoryColumn("MOVIES_EILayer\\sndset\\beamSACorrection", AcousticDataImportModelRow.PROPERTY_TRANSCEIVER_ACQUISITION_SACORRECTION, CsvModelUtil.FLOAT);//U + newIgnoredColumn("MOVIES_EILayer\\sndset\\bottomDetectionMinDepth");//V + newIgnoredColumn("MOVIES_EILayer\\sndset\\bottomDetectionMaxDepth");//W + newIgnoredColumn("MOVIES_EILayer\\sndset\\bottomDetectionMinLevel");//X + newIgnoredColumn("MOVIES_EILayer\\sndset\\AlongTXRXWeightId");//Y + newIgnoredColumn("MOVIES_EILayer\\sndset\\AthwartTXRXWeightId");//Z + newIgnoredColumn("MOVIES_EILayer\\sndset\\splitBeamAlongTXRXWeightId");//AA + newIgnoredColumn("MOVIES_EILayer\\sndset\\splitBeamAthwartTXRXWeightId");//AB + newIgnoredColumn("MOVIES_EILayer\\sndset\\bandWidth");//AC + newIgnoredColumn("MOVIES_EILayer\\sndset\\tvgminrange");//AD + newIgnoredColumn("MOVIES_EILayer\\sndset\\tvgmaxrange");//AE + newMandatoryColumn("MOVIES_EILayer\\sndset\\pulseduration", AcousticDataImportModelRow.PROPERTY_TRANSCEIVER_ACQUISITION_PULSE_LENGTH, CsvModelUtil.FLOAT);//AF + newIgnoredColumn("MOVIES_EILayer\\shipnav");//AG + newMandatoryColumn("MOVIES_EILayer\\shipnav\\lat", AcousticDataImportModelRow.PROPERTY_ESDU_CELL_DATA_LATITUDE);//AH + newMandatoryColumn("MOVIES_EILayer\\shipnav\\long", AcousticDataImportModelRow.PROPERTY_ESDU_CELL_DATA_LONGITUDE);//AI + newIgnoredColumn("MOVIES_EILayer\\shipnav\\alt");//AJ + newIgnoredColumn("MOVIES_EILayer\\shipnav\\gndspeed");//AK + newIgnoredColumn("MOVIES_EILayer\\shipnav\\gndcourse");//AL + newIgnoredColumn("MOVIES_EILayer\\shipnav\\surfspeed");//AM + newIgnoredColumn("MOVIES_EILayer\\shipnav\\surfcourse");//AN + newIgnoredColumn("MOVIES_EILayer\\shipnav\\driftspeed");//AO + newIgnoredColumn("MOVIES_EILayer\\shipnav\\driftcourse");//AP + newIgnoredColumn("MOVIES_EILayer\\shipnav\\heading");//AQ + newIgnoredColumn("MOVIES_EILayer\\shipnav\roll");//AR + newIgnoredColumn("MOVIES_EILayer\\shipnav\\pitch");//AS + newIgnoredColumn("MOVIES_EILayer\\shipnav\\heave");//AT + newMandatoryColumn("MOVIES_EILayer\\shipnav\\depth", AcousticDataImportModelRow.PROPERTY_ESDU_CELL_DATA_DEPTH);//AU + newIgnoredColumn("MOVIES_EILayer\\shipnav\\draught");//AV + + // Cell elementary Datas + newIgnoredColumn("MOVIES_EILayer\\cellset");//AW + newMandatoryColumn("MOVIES_EILayer\\cellset\\cellnum", AcousticDataImportModelRow.PROPERTY_ELEMENTARY_CELL_NUM, CsvModelUtil.INTEGER);//AX + newMandatoryColumn("MOVIES_EILayer\\cellset\\celltype", AcousticDataImportModelRow.PROPERTY_ELEMENTARY_CELL_TYPE, CsvModelUtil.INTEGER);//AY + newMandatoryColumn("MOVIES_EILayer\\cellset\\depthstart", AcousticDataImportModelRow.PROPERTY_ELEMENTARY_CELL_DATA_DEPTH_START);//AZ + newMandatoryColumn("MOVIES_EILayer\\cellset\\depthend", AcousticDataImportModelRow.PROPERTY_ELEMENTARY_CELL_DATA_DEPTHEND);//BA + newIgnoredColumn("MOVIES_EILayer\\cellset\\indexstart");//BB + newIgnoredColumn("MOVIES_EILayer\\cellset\\indexend");//BC + newMandatoryColumn("MOVIES_EILayer\\cellset\\datestart", AcousticDataImportModelRow.PROPERTY_ESDU_CELL_START_DATE, CsvModelUtil.IMPORT_DAY_TIME3);//BD + newIgnoredColumn("MOVIES_EILayer\\cellset\\dateend");//BE + newIgnoredColumn("MOVIES_EILayer\\cellset\\diststart");//BF + newIgnoredColumn("MOVIES_EILayer\\cellset\\distend");//BG + newMandatoryColumn("MOVIES_EILayer\\cellset\\thresholdup", AcousticDataImportModelRow.PROPERTY_EI_THRESHOLD, CsvModelUtil.INTEGER);//BH + newIgnoredColumn("MOVIES_EILayer\\cellset\\thresholdlow");//BI + newIgnoredColumn("MOVIES_EILayer\\eilayer");//BJ + newMandatoryColumn("MOVIES_EILayer\\eilayer\\sa", AcousticDataImportModelRow.PROPERTY_ELEMENTARY_CELL_DATA_ACOUSTIC_DENSITY);//BK + newIgnoredColumn("MOVIES_EILayer\\eilayer\\sv");//BL + newIgnoredColumn("MOVIES_EILayer\\eilayer\\ni");//BM + newIgnoredColumn("MOVIES_EILayer\\eilayer\\nt");//BN + + // Cell ESDU Datas + newIgnoredColumn("MOVIES_EILayer\\cellset2");//BO + newIgnoredColumn("MOVIES_EILayer\\cellset2\\cellnum");//BP + newIgnoredColumn("MOVIES_EILayer\\cellset2\\celltype");//BQ + newIgnoredColumn("MOVIES_EILayer\\cellset2\\depthstart");//BR + newIgnoredColumn("MOVIES_EILayer\\cellset2\\depthend");//BS + newIgnoredColumn("MOVIES_EILayer\\cellset2\\indexstart");//BT + newIgnoredColumn("MOVIES_EILayer\\cellset2\\indexend");//BU + newMandatoryColumn("MOVIES_EILayer\\cellset2\\datestart", AcousticDataImportModelRow.PROPERTY_ESDU_CELL_DATA_TIME);//BV + newIgnoredColumn("MOVIES_EILayer\\cellset2\\dateend");//BW + newIgnoredColumn("MOVIES_EILayer\\cellset2\\diststart");//BX + newIgnoredColumn("MOVIES_EILayer\\cellset2\\distend");//BY + newIgnoredColumn("MOVIES_EILayer\\cellset2\\thresholdup");//BZ + newIgnoredColumn("MOVIES_EILayer\\cellset2\\thresholdlow");//CA + newIgnoredColumn("MOVIES_EILayer\\eilayer2");//CB + newMandatoryColumn("MOVIES_EILayer\\eilayer2\\sa", AcousticDataImportModelRow.PROPERTY_ESDU_CELL_DATA_ACOUSTIC_DENSITY);//CC + newIgnoredColumn("MOVIES_EILayer\\eilayer2\\sv");//CD + newIgnoredColumn("MOVIES_EILayer\\eilayer2\\ni");//CE + newIgnoredColumn("MOVIES_EILayer\\eilayer2\\nt");//CF + newIgnoredColumn("MOVIES_EILayer\\boterr");//CG + newIgnoredColumn("MOVIES_EILayer\\boterr\\sa");//CH + newIgnoredColumn("MOVIES_EILayer\\boterr\\ni");//CI + } + + @Override + public AcousticDataImportModelRow newEmptyInstance() { + return new AcousticDataImportModelRow(); + } +} \ No newline at end of file Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModelRow.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModelRow.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModelRow.java 2012-01-26 10:54:27 UTC (rev 293) @@ -0,0 +1,299 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services.csv; + +import java.util.Date; + +/** + * Bean of a row for {@link AcousticDataImportModel} import. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class AcousticDataImportModelRow { + + public static final String PROPERTY_CHANNEL_NAME = "channelName"; + + public static final String PROPERTY_SNDNAME = "sndname"; + + public static final String PROPERTY_ESDU_CELL_START_DATE = "esduCellStartDate"; + + public static final String PROPERTY_ELEMENTARY_CELL_TYPE = "elementaryCellType"; + + public static final String PROPERTY_ELEMENTARY_CELL_NUM = "elementaryCellNum"; + + public static final String PROPERTY_ESDU_CELL_DATA_LATITUDE = "esduCellDataLatitude"; + + public static final String PROPERTY_ESDU_CELL_DATA_LONGITUDE = "esduCellDataLongitude"; + + public static final String PROPERTY_ESDU_CELL_DATA_DEPTH = "esduCellDataDepth"; + + public static final String PROPERTY_ESDU_CELL_DATA_TIME = "esduCellDataTime"; + + public static final String PROPERTY_ESDU_CELL_DATA_ACOUSTIC_DENSITY = "esduCellDataAcousticDensity"; + + public static final String PROPERTY_ELEMENTARY_CELL_DATA_DEPTH_START = "elementaryCellDataDepthStart"; + + public static final String PROPERTY_ELEMENTARY_CELL_DATA_DEPTHEND = "elementaryCellDataDepthend"; + + public static final String PROPERTY_ELEMENTARY_CELL_DATA_ACOUSTIC_DENSITY = "elementaryCellDataAcousticDensity"; + + public static final String PROPERTY_TRANSCEIVER_ACQUISITION_PULSE_LENGTH = "transceiverAcquisitionPulseLength"; + + public static final String PROPERTY_TRANSCEIVER_ACQUISITION_GAIN = "transceiverAcquisitionGain"; + + public static final String PROPERTY_TRANSCEIVER_ACQUISITION_ABSORPTION = "transceiverAcquisitionAbsorption"; + + public static final String PROPERTY_TRANSDUCER_ACQUISITION_BEAM_ANGLE_ATHWARTSHIP = "transducerAcquisitionBeamAngleAthwartship"; + + public static final String PROPERTY_TRANSDUCER_ACQUISITION_BEAM_ANGLE_ALONGSHIP = "transducerAcquisitionBeamAngleAlongship"; + + public static final String PROPERTY_TRANSDUCER_ACQUISITION_PSI = "transducerAcquisitionPsi"; + + public static final String PROPERTY_TRANSCEIVER_ACQUISITION_POWER = "transceiverAcquisitionPower"; + + public static final String PROPERTY_TRANSCEIVER_ACQUISITION_SACORRECTION = "transceiverAcquisitionSacorrection"; + + public static final String PROPERTY_EI_THRESHOLD = "eiThreshold"; + + protected String sndName; + + protected String channelName; + + protected Date esduCellStartDate; + + protected String esduCellDataLatitude; + + protected String esduCellDataLongitude; + + protected String esduCellDataDepth; + + protected String esduCellDataAcousticDensity; + + protected int elementaryCellType; + + protected int elementaryCellNum; + + protected String elementaryCellDataDepthStart; + + protected String elementaryCellDataDepthEnd; + + protected String elementaryCellDataAcousticDensity; + + protected float transceiverAcquisitionPulseLength; + + protected float transceiverAcquisitionGain; + + protected float transceiverAcquisitionAbsorption; + + protected float transceiverAcquisitionPower; + + protected float transceiverAcquisitionSacorrection; + + protected float transducerAcquisitionBeamAngleAthwartship; + + protected float transducerAcquisitionBeamAngleAlongship; + + protected float transducerAcquisitionPsi; + + protected float eiThreshold; + + private String esduCellDataTime; + + public String getSndName() { + return sndName; + } + + public void setSndName(String sndName) { + this.sndName = sndName; + } + + public String getChannelName() { + return channelName; + } + + public void setChannelName(String channelName) { + this.channelName = channelName; + } + + public Date getEsduCellStartDate() { + return esduCellStartDate; + } + + public void setEsduCellStartDate(Date esduCellStartDate) { + this.esduCellStartDate = esduCellStartDate; + } + + public int getElementaryCellType() { + return elementaryCellType; + } + + public void setElementaryCellType(int elementaryCellType) { + this.elementaryCellType = elementaryCellType; + } + + public int getElementaryCellNum() { + return elementaryCellNum; + } + + public void setElementaryCellNum(int elementaryCellNum) { + this.elementaryCellNum = elementaryCellNum; + } + + public String getEsduCellDataLatitude() { + return esduCellDataLatitude; + } + + public void setEsduCellDataLatitude(String esduCellDataLatitude) { + this.esduCellDataLatitude = esduCellDataLatitude; + } + + public String getEsduCellDataLongitude() { + return esduCellDataLongitude; + } + + public void setEsduCellDataLongitude(String esduCellDataLongitude) { + this.esduCellDataLongitude = esduCellDataLongitude; + } + + public String getEsduCellDataDepth() { + return esduCellDataDepth; + } + + public void setEsduCellDataDepth(String esduCellDataDepth) { + this.esduCellDataDepth = esduCellDataDepth; + } + + public String getEsduCellDataAcousticDensity() { + return esduCellDataAcousticDensity; + } + + public void setEsduCellDataAcousticDensity(String esduCellDataAcousticDensity) { + this.esduCellDataAcousticDensity = esduCellDataAcousticDensity; + } + + public String getElementaryCellDataDepthStart() { + return elementaryCellDataDepthStart; + } + + public void setElementaryCellDataDepthStart(String elementaryCellDataDepthStart) { + this.elementaryCellDataDepthStart = elementaryCellDataDepthStart; + } + + public String getElementaryCellDataDepthEnd() { + return elementaryCellDataDepthEnd; + } + + public void setElementaryCellDataDepthEnd(String elementaryCellDataDepthEnd) { + this.elementaryCellDataDepthEnd = elementaryCellDataDepthEnd; + } + + public String getElementaryCellDataAcousticDensity() { + return elementaryCellDataAcousticDensity; + } + + public void setElementaryCellDataAcousticDensity(String elementaryCellDataAcousticDensity) { + this.elementaryCellDataAcousticDensity = elementaryCellDataAcousticDensity; + } + + public float getTransceiverAcquisitionPulseLength() { + return transceiverAcquisitionPulseLength; + } + + public void setTransceiverAcquisitionPulseLength(float transceiverAcquisitionPulseLength) { + this.transceiverAcquisitionPulseLength = transceiverAcquisitionPulseLength; + } + + public float getTransceiverAcquisitionGain() { + return transceiverAcquisitionGain; + } + + public void setTransceiverAcquisitionGain(float transceiverAcquisitionGain) { + this.transceiverAcquisitionGain = transceiverAcquisitionGain; + } + + public float getTransceiverAcquisitionAbsorption() { + return transceiverAcquisitionAbsorption; + } + + public void setTransceiverAcquisitionAbsorption(float transceiverAcquisitionAbsorption) { + this.transceiverAcquisitionAbsorption = transceiverAcquisitionAbsorption; + } + + public float getTransceiverAcquisitionPower() { + return transceiverAcquisitionPower; + } + + public void setTransceiverAcquisitionPower(float transceiverAcquisitionPower) { + this.transceiverAcquisitionPower = transceiverAcquisitionPower; + } + + public float getTransceiverAcquisitionSacorrection() { + return transceiverAcquisitionSacorrection; + } + + public void setTransceiverAcquisitionSacorrection(float transceiverAcquisitionSacorrection) { + this.transceiverAcquisitionSacorrection = transceiverAcquisitionSacorrection; + } + + public float getTransducerAcquisitionBeamAngleAthwartship() { + return transducerAcquisitionBeamAngleAthwartship; + } + + public void setTransducerAcquisitionBeamAngleAthwartship(float transducerAcquisitionBeamAngleAthwartship) { + this.transducerAcquisitionBeamAngleAthwartship = transducerAcquisitionBeamAngleAthwartship; + } + + public float getTransducerAcquisitionBeamAngleAlongship() { + return transducerAcquisitionBeamAngleAlongship; + } + + public void setTransducerAcquisitionBeamAngleAlongship(float transducerAcquisitionBeamAngleAlongship) { + this.transducerAcquisitionBeamAngleAlongship = transducerAcquisitionBeamAngleAlongship; + } + + public float getTransducerAcquisitionPsi() { + return transducerAcquisitionPsi; + } + + public void setTransducerAcquisitionPsi(float transducerAcquisitionPsi) { + this.transducerAcquisitionPsi = transducerAcquisitionPsi; + } + + public float getEiThreshold() { + return eiThreshold; + } + + public void setEiThreshold(float eiThreshold) { + this.eiThreshold = eiThreshold; + } + + public String getEsduCellDataTime() { + return esduCellDataTime; + } + + public void setEsduCellDataTime(String esduCellDataTime) { + this.esduCellDataTime = esduCellDataTime; + } +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/AcousticDataImportModelRow.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/CsvModelUtil.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/CsvModelUtil.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/CsvModelUtil.java 2012-01-26 10:54:27 UTC (rev 293) @@ -39,10 +39,14 @@ import org.nuiton.util.csv.ImportExportModel; import org.nuiton.util.csv.ImportModel; import org.nuiton.util.csv.ImportableColumn; +import org.nuiton.util.csv.ImportableExportableColumn; import org.nuiton.util.csv.ModelBuilder; import org.nuiton.util.csv.ValueFormatter; +import org.nuiton.util.csv.ValueGetter; +import org.nuiton.util.csv.ValueGetterSetter; import org.nuiton.util.csv.ValueParser; import org.nuiton.util.csv.ValueParserFormatter; +import org.nuiton.util.csv.ValueSetter; import java.sql.Timestamp; import java.text.ParseException; @@ -116,6 +120,8 @@ public static final ValueParser<Date> IMPORT_DAY_TIME2 = new DateValue("dd-MM-yy HH:mm:ss"); + public static final ValueParser<Date> IMPORT_DAY_TIME3 = new DateValue("dd-MM-yy HH:mm aa"); + public static final ValueParser<Boolean> INT_TO_BOOLEAN_PARSER = new ValueParser<Boolean>() { @Override @@ -323,6 +329,34 @@ public final Iterable<ImportableColumn<E, Object>> getColumnsForImport() { return (Iterable) modelBuilder.getColumnsForImport(); } + + public <T> ImportableColumn<E, T> newIgnoredColumn(String headerName) { + return modelBuilder.newIgnoredColumn(headerName); + } + + public ImportableColumn<E, String> newMandatoryColumn(String headerName) { + return modelBuilder.newMandatoryColumn(headerName, headerName); + } + + public ImportableColumn<E, String> newMandatoryColumn(String headerName, String propertyName) { + return modelBuilder.newMandatoryColumn(headerName, propertyName); + } + + public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, ValueParser<T> valueParser) { + return modelBuilder.newMandatoryColumn(headerName, headerName, valueParser); + } + + public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, String propertyName, ValueParser<T> valueParser) { + return modelBuilder.newMandatoryColumn(headerName, propertyName, valueParser); + } + + public ImportableColumn<E, String> newMandatoryColumn(String headerName, ValueSetter<E, String> eStringValueSetter) { + return modelBuilder.newMandatoryColumn(headerName, eStringValueSetter); + } + + public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, ValueParser<T> valueParser, ValueSetter<E, T> etValueSetter) { + return modelBuilder.newMandatoryColumn(headerName, valueParser, etValueSetter); + } } public static abstract class AbstractImportExportModel<E> implements ImportExportModel<E> { @@ -354,6 +388,82 @@ public final Iterable<ImportableColumn<E, Object>> getColumnsForImport() { return (Iterable) modelBuilder.getColumnsForImport(); } + + public <T> ImportableColumn<E, T> newIgnoredColumn(String headerName) { + return modelBuilder.newIgnoredColumn(headerName); + } + + public ImportableColumn<E, String> newMandatoryColumn(String headerName) { + return modelBuilder.newMandatoryColumn(headerName, headerName); + } + + public ImportableColumn<E, String> newMandatoryColumn(String headerName, String propertyName) { + return modelBuilder.newMandatoryColumn(headerName, propertyName); + } + + public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, ValueParser<T> valueParser) { + return modelBuilder.newMandatoryColumn(headerName, headerName, valueParser); + } + + public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, String propertyName, ValueParser<T> valueParser) { + return modelBuilder.newMandatoryColumn(headerName, propertyName, valueParser); + } + + public ImportableColumn<E, String> newMandatoryColumn(String headerName, ValueSetter<E, String> eStringValueSetter) { + return modelBuilder.newMandatoryColumn(headerName, eStringValueSetter); + } + + public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, ValueParser<T> valueParser, ValueSetter<E, T> etValueSetter) { + return modelBuilder.newMandatoryColumn(headerName, valueParser, etValueSetter); + } + + public ExportableColumn<E, String> newColumnForExport(String headerName) { + return modelBuilder.newColumnForExport(headerName, headerName); + } + + public ExportableColumn<E, String> newColumnForExport(String headerName, String propertyName) { + return modelBuilder.newColumnForExport(headerName, propertyName); + } + + public ExportableColumn<E, String> newColumnForExport(String headerName, ValueGetter<E, String> eStringValueGetter) { + return modelBuilder.newColumnForExport(headerName, eStringValueGetter); + } + + public <T> ExportableColumn<E, T> newColumnForExport(String headerName, ValueFormatter<T> valueFormatter) { + return modelBuilder.newColumnForExport(headerName, headerName, valueFormatter); + } + + public <T> ExportableColumn<E, T> newColumnForExport(String headerName, String propertyName, ValueFormatter<T> valueFormatter) { + return modelBuilder.newColumnForExport(headerName, propertyName, valueFormatter); + } + + public <T> ExportableColumn<E, T> newColumnForExport(String headerName, ValueGetter<E, T> etValueGetter, ValueFormatter<T> valueFormatter) { + return modelBuilder.newColumnForExport(headerName, etValueGetter, valueFormatter); + } + + public ImportableExportableColumn<E, String> newColumnForImportExport(String headerName) { + return modelBuilder.newColumnForImportExport(headerName, headerName); + } + + public ImportableExportableColumn<E, String> newColumnForImportExport(String headerName, String propertyName) { + return modelBuilder.newColumnForImportExport(headerName, propertyName); + } + + public ImportableExportableColumn<E, String> newColumnForImportExport(String headerName, ValueGetterSetter<E, String> eStringValueGetterSetter) { + return modelBuilder.newColumnForImportExport(headerName, eStringValueGetterSetter); + } + + public <T> ImportableExportableColumn<E, T> newColumnForImportExport(String headerName, ValueParserFormatter<T> valueParserFormatter) { + return modelBuilder.newColumnForImportExport(headerName, headerName, valueParserFormatter); + } + + public <T> ImportableExportableColumn<E, T> newColumnForImportExport(String headerName, String propertyName, ValueParserFormatter<T> valueParserFormatter) { + return modelBuilder.newColumnForImportExport(headerName, propertyName, valueParserFormatter); + } + + public <T> ImportableExportableColumn<E, T> newColumnForImportExport(String headerName, ValueGetterSetter<E, T> etValueGetterSetter, ValueParserFormatter<T> valueParserFormatter) { + return modelBuilder.newColumnForImportExport(headerName, etValueGetterSetter, valueParserFormatter); + } } public static abstract class AbstractExportModel<E> implements ExportModel<E> { @@ -377,5 +487,28 @@ return (Iterable) modelBuilder.getColumnsForExport(); } + public ExportableColumn<E, String> newColumnForExport(String headerName) { + return modelBuilder.newColumnForExport(headerName, headerName); + } + + public ExportableColumn<E, String> newColumnForExport(String headerName, String propertyName) { + return modelBuilder.newColumnForExport(headerName, propertyName); + } + + public ExportableColumn<E, String> newColumnForExport(String headerName, ValueGetter<E, String> eStringValueGetter) { + return modelBuilder.newColumnForExport(headerName, eStringValueGetter); + } + + public <T> ExportableColumn<E, T> newColumnForExport(String headerName, ValueFormatter<T> valueFormatter) { + return modelBuilder.newColumnForExport(headerName, headerName, valueFormatter); + } + + public <T> ExportableColumn<E, T> newColumnForExport(String headerName, String propertyName, ValueFormatter<T> valueFormatter) { + return modelBuilder.newColumnForExport(headerName, propertyName, valueFormatter); + } + + public <T> ExportableColumn<E, T> newColumnForExport(String headerName, ValueGetter<E, T> etValueGetter, ValueFormatter<T> valueFormatter) { + return modelBuilder.newColumnForExport(headerName, etValueGetter, valueFormatter); + } } } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityAssociationExportModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityAssociationExportModel.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityAssociationExportModel.java 2012-01-26 10:54:27 UTC (rev 293) @@ -45,14 +45,12 @@ meta); // topiaId <-> topiaId - model.modelBuilder.newColumnForExport( - TopiaEntity.TOPIA_ID, + model.newColumnForExport( TopiaEntity.TOPIA_ID ); - model.modelBuilder.newColumnForExport( + model.newColumnForExport( meta.getName(), - meta.getName(), CsvModelUtil.newAssociationValueFormatter() ); return model; Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityAssociationImportModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityAssociationImportModel.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityAssociationImportModel.java 2012-01-26 10:54:27 UTC (rev 293) @@ -46,13 +46,13 @@ separator, meta); // topiaId <-> topiaId - model.modelBuilder.newMandatoryColumn( + model.newMandatoryColumn( TopiaEntity.TOPIA_ID, CsvModelUtil.<Map<String, Object>, String>newMapProperty(TopiaEntity.TOPIA_ID) ); // add association -> target - model.modelBuilder.newMandatoryColumn( + model.newMandatoryColumn( meta.getName(), CsvModelUtil.ASSOCIATION_VALUE_PARSER, CsvModelUtil.<Map<String, Object>, String[]>newMapProperty("target") Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityCsvModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityCsvModel.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/EntityCsvModel.java 2012-01-26 10:54:27 UTC (rev 293) @@ -26,8 +26,6 @@ import com.google.common.base.Function; import fr.ifremer.echobase.entities.meta.TableMeta; import org.nuiton.topia.persistence.TopiaEntity; -import org.nuiton.util.csv.ImportableColumn; -import org.nuiton.util.csv.ValueParser; import java.util.Collection; import java.util.Date; @@ -57,10 +55,6 @@ return new EntityCsvModel<E>(separator, tableMeta, idHeader); } - public <T> ImportableColumn<E, T> newIgnoredColumn(String headerName) { - return modelBuilder.newIgnoredColumn(headerName); - } - @Override public E newEmptyInstance() { return (E) tableMeta.newEntity(); @@ -69,9 +63,8 @@ public void addForeignKeyForExport(String propertyName, Class<TopiaEntity> entityType) { - modelBuilder.newColumnForExport( + newColumnForExport( propertyName, - propertyName, CsvModelUtil.newForeignKeyValue(entityType) ); } @@ -82,7 +75,7 @@ Collection<E> universe, Function<E, String> transform) { - modelBuilder.newMandatoryColumn( + newMandatoryColumn( headerName, propertyName, CsvModelUtil.newForeignKeyValue(entityType, universe, transform) @@ -95,7 +88,7 @@ Collection<E> universe, Function<E, String> transform) { - modelBuilder.newMandatoryColumn( + newMandatoryColumn( headerName, propertyName, CsvModelUtil.newForeignKeyValueAssociation(entityType, universe, transform) @@ -106,9 +99,8 @@ Class<E> entityType, Collection<E> universe) { - modelBuilder.newMandatoryColumn( + newMandatoryColumn( propertyName, - propertyName, CsvModelUtil.newForeignKeyValue(entityType, universe) ); } @@ -116,7 +108,7 @@ public void addNewColumnForExport(String headerName, String propertyName, CsvModelUtil.ForeignKeyDecoratedValue<TopiaEntity> topiaEntityForeignKeyDecoratedValue) { - modelBuilder.newColumnForExport( + newColumnForExport( headerName, propertyName, topiaEntityForeignKeyDecoratedValue @@ -133,67 +125,67 @@ Class<?> type) { if (Date.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.DAY_TIME_SECOND_WITH_TIMESTAMP ); } else if (double.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.DOUBLE_PRIMITIVE ); } else if (Double.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.DOUBLE ); } else if (long.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.PRIMITIVE_LONG ); } else if (Long.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.LONG ); } else if (float.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.PRIMITIVE_FLOAT ); } else if (Float.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.FLOAT ); } else if (int.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.PRIMITIVE_INTEGER ); } else if (Integer.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.INTEGER ); } else if (boolean.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.PRIMITIVE_BOOLEAN ); } else if (Boolean.class.equals(type)) { - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName, CsvModelUtil.BOOLEAN @@ -201,26 +193,26 @@ } else { // string - modelBuilder.newColumnForImportExport( + newColumnForImportExport( headerName, propertyName ); } } - public ImportableColumn<E, String> newMandatoryColumn(String headerName, - String propertyName) { - return modelBuilder.newMandatoryColumn(headerName, propertyName); - } +// public ImportableColumn<E, String> newMandatoryColumn(String headerName, +// String propertyName) { +// return modelBuilder.newMandatoryColumn(headerName, propertyName); +// } +// +// public ImportableColumn<E, String> newMandatoryColumn(String headerName) { +// return modelBuilder.newMandatoryColumn(headerName, headerName); +// } +// +// public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, String propertyName, ValueParser<T> valueParser) { +// return modelBuilder.newMandatoryColumn(headerName, valueParser, CsvModelUtil.<E, T>newBeanProperty(propertyName)); +// } - public ImportableColumn<E, String> newMandatoryColumn(String headerName) { - return modelBuilder.newMandatoryColumn(headerName, headerName); - } - - public <T> ImportableColumn<E, T> newMandatoryColumn(String headerName, String propertyName, ValueParser<T> valueParser) { - return modelBuilder.newMandatoryColumn(headerName, valueParser, CsvModelUtil.<E, T>newBeanProperty(propertyName)); - } - protected EntityCsvModel(char separator, TableMeta tableMeta) { super(separator); @@ -231,7 +223,7 @@ TableMeta tableMeta, String idHeader) { this(separator, tableMeta); - modelBuilder.newColumnForImportExport( + newColumnForImportExport( idHeader, TopiaEntity.TOPIA_ID ); Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/ExportQueryCsvModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/ExportQueryCsvModel.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/ExportQueryCsvModel.java 2012-01-26 10:54:27 UTC (rev 293) @@ -39,9 +39,8 @@ public ExportQueryCsvModel(char separator, String[] columnHeaders) { super(separator); for (String columnHeader : columnHeaders) { - modelBuilder.newColumnForExport( + newColumnForExport( columnHeader, - columnHeader, CsvModelUtil.TO_STRING_FORMATTER ); } Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransectImportModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransectImportModel.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransectImportModel.java 2012-01-26 10:54:27 UTC (rev 293) @@ -23,7 +23,6 @@ */ package fr.ifremer.echobase.services.csv; -import fr.ifremer.echobase.entities.data.Transect; import fr.ifremer.echobase.entities.data.Voyage; import java.util.Map; @@ -34,38 +33,36 @@ * @author tchemit <chemit@codelutin.com> * @since 0.3 */ -public class TransectImportModel extends CsvModelUtil.AbstractImportModel<Map<String, Object>> { +public class TransectImportModel extends CsvModelUtil.AbstractImportModel<TransectImportModelRow> { - public static final String TRANSECT_VoyageId = "voyageName"; - protected final Map<String, Voyage> voyageMap; public TransectImportModel(char separator, Map<String, Voyage> voyageMap) { super(separator); this.voyageMap = voyageMap; - modelBuilder.newMandatoryColumn(Transect.PROPERTY_TITLE, Transect.PROPERTY_TITLE); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_TRANSECT_ABSTRACT, Transect.PROPERTY_TRANSECT_ABSTRACT); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_STRATUM, Transect.PROPERTY_STRATUM); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_COMMENT, Transect.PROPERTY_COMMENT); - modelBuilder.newMandatoryColumn(TRANSECT_VoyageId, TRANSECT_VoyageId, CsvModelUtil.newForeignKeyValue(Voyage.class, voyageMap)); + newMandatoryColumn(TransectImportModelRow.PROPERTY_TITLE); + newMandatoryColumn(TransectImportModelRow.PROPERTY_TRANSECT_ABSTRACT); + newMandatoryColumn(TransectImportModelRow.PROPERTY_STRATUM); + newMandatoryColumn(TransectImportModelRow.PROPERTY_COMMENT); + newMandatoryColumn("voyageName", TransectImportModelRow.PROPERTY_VOYAGE, CsvModelUtil.newForeignKeyValue(Voyage.class, voyageMap)); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_DATE_CREATED, Transect.PROPERTY_DATE_CREATED, CsvModelUtil.IMPORT_DAY_TIME2); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_TIME_COVERAGE_START, Transect.PROPERTY_TIME_COVERAGE_START, CsvModelUtil.IMPORT_DAY_TIME2); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_TIME_COVERAGE_END, Transect.PROPERTY_TIME_COVERAGE_END, CsvModelUtil.IMPORT_DAY_TIME2); + newMandatoryColumn(TransectImportModelRow.PROPERTY_DATE_CREATED, CsvModelUtil.IMPORT_DAY_TIME2); + newMandatoryColumn(TransectImportModelRow.PROPERTY_TIME_COVERAGE_START, CsvModelUtil.IMPORT_DAY_TIME2); + newMandatoryColumn(TransectImportModelRow.PROPERTY_TIME_COVERAGE_END, CsvModelUtil.IMPORT_DAY_TIME2); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_GEOSPATIAL_LON_MIN, Transect.PROPERTY_GEOSPATIAL_LON_MIN, CsvModelUtil.PRIMITIVE_FLOAT); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_GEOSPATIAL_LAT_MIN, Transect.PROPERTY_GEOSPATIAL_LAT_MIN, CsvModelUtil.PRIMITIVE_FLOAT); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_GEOSPATIAL_VERTICAL_MIN, Transect.PROPERTY_GEOSPATIAL_VERTICAL_MIN, CsvModelUtil.PRIMITIVE_FLOAT); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_GEOSPATIAL_LON_MAX, Transect.PROPERTY_GEOSPATIAL_LON_MAX, CsvModelUtil.PRIMITIVE_FLOAT); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_GEOSPATIAL_LAT_MAX, Transect.PROPERTY_GEOSPATIAL_LAT_MAX, CsvModelUtil.PRIMITIVE_FLOAT); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_GEOSPATIAL_VERTICAL_MAX, Transect.PROPERTY_GEOSPATIAL_VERTICAL_MAX, CsvModelUtil.PRIMITIVE_FLOAT); - modelBuilder.newMandatoryColumn(Transect.PROPERTY_LINESTRING, Transect.PROPERTY_LINESTRING); + newMandatoryColumn(TransectImportModelRow.PROPERTY_GEOSPATIAL_LON_MIN, CsvModelUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(TransectImportModelRow.PROPERTY_GEOSPATIAL_LAT_MIN, CsvModelUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(TransectImportModelRow.PROPERTY_GEOSPATIAL_VERTICAL_MIN, CsvModelUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(TransectImportModelRow.PROPERTY_GEOSPATIAL_LON_MAX, CsvModelUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(TransectImportModelRow.PROPERTY_GEOSPATIAL_LAT_MAX, CsvModelUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(TransectImportModelRow.PROPERTY_GEOSPATIAL_VERTICAL_MAX, CsvModelUtil.PRIMITIVE_FLOAT); + newMandatoryColumn(TransectImportModelRow.PROPERTY_LINESTRING); } @Override - public Map<String, Object> newEmptyInstance() { - return null; + public TransectImportModelRow newEmptyInstance() { + return new TransectImportModelRow(); } } Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransectImportModelRow.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransectImportModelRow.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransectImportModelRow.java 2012-01-26 10:54:27 UTC (rev 293) @@ -0,0 +1,220 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services.csv; + +import fr.ifremer.echobase.entities.data.Voyage; + +import java.io.Serializable; +import java.util.Date; + +/** + * Bean used as a row for import of {@link TransectImportModel}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class TransectImportModelRow implements Serializable { + + private static final long serialVersionUID = 1L; + + public static final String PROPERTY_VOYAGE = "voyage"; + + public static final String PROPERTY_TITLE = "title"; + + public static final String PROPERTY_TRANSECT_ABSTRACT = "transectAbstract"; + + public static final String PROPERTY_COMMENT = "comment"; + + public static final String PROPERTY_DATE_CREATED = "dateCreated"; + + public static final String PROPERTY_GEOSPATIAL_LON_MIN = "geospatialLonMin"; + + public static final String PROPERTY_GEOSPATIAL_LON_MAX = "geospatialLonMax"; + + public static final String PROPERTY_GEOSPATIAL_LAT_MIN = "geospatialLatMin"; + + public static final String PROPERTY_GEOSPATIAL_LAT_MAX = "geospatialLatMax"; + + public static final String PROPERTY_LINESTRING = "linestring"; + + public static final String PROPERTY_GEOSPATIAL_VERTICAL_MIN = "geospatialVerticalMin"; + + public static final String PROPERTY_GEOSPATIAL_VERTICAL_MAX = "geospatialVerticalMax"; + + public static final String PROPERTY_TIME_COVERAGE_START = "timeCoverageStart"; + + public static final String PROPERTY_TIME_COVERAGE_END = "timeCoverageEnd"; + + public static final String PROPERTY_STRATUM = "stratum"; + + protected String title; + + protected String transectAbstract; + + protected String stratum; + + protected String comment; + + protected String linestring; + + protected Voyage voyage; + + protected Date dateCreated; + + protected Date timeCoverageStart; + + protected Date timeCoverageEnd; + + protected float geospatialLonMin; + + protected float geospatialLonMax; + + protected float geospatialLatMin; + + protected float geospatialLatMax; + + protected float geospatialVerticalMin; + + protected float geospatialVerticalMax; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getTransectAbstract() { + return transectAbstract; + } + + public void setTransectAbstract(String transectAbstract) { + this.transectAbstract = transectAbstract; + } + + public String getStratum() { + return stratum; + } + + public void setStratum(String stratum) { + this.stratum = stratum; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getLinestring() { + return linestring; + } + + public void setLinestring(String linestring) { + this.linestring = linestring; + } + + public Voyage getVoyage() { + return voyage; + } + + public void setVoyage(Voyage voyage) { + this.voyage = voyage; + } + + public Date getDateCreated() { + return dateCreated; + } + + public void setDateCreated(Date dateCreated) { + this.dateCreated = dateCreated; + } + + public Date getTimeCoverageStart() { + return timeCoverageStart; + } + + public void setTimeCoverageStart(Date timeCoverageStart) { + this.timeCoverageStart = timeCoverageStart; + } + + public Date getTimeCoverageEnd() { + return timeCoverageEnd; + } + + public void setTimeCoverageEnd(Date timeCoverageEnd) { + this.timeCoverageEnd = timeCoverageEnd; + } + + public float getGeospatialLonMin() { + return geospatialLonMin; + } + + public void setGeospatialLonMin(float geospatialLonMin) { + this.geospatialLonMin = geospatialLonMin; + } + + public float getGeospatialLonMax() { + return geospatialLonMax; + } + + public void setGeospatialLonMax(float geospatialLonMax) { + this.geospatialLonMax = geospatialLonMax; + } + + public float getGeospatialLatMin() { + return geospatialLatMin; + } + + public void setGeospatialLatMin(float geospatialLatMin) { + this.geospatialLatMin = geospatialLatMin; + } + + public float getGeospatialLatMax() { + return geospatialLatMax; + } + + public void setGeospatialLatMax(float geospatialLatMax) { + this.geospatialLatMax = geospatialLatMax; + } + + public float getGeospatialVerticalMin() { + return geospatialVerticalMin; + } + + public void setGeospatialVerticalMin(float geospatialVerticalMin) { + this.geospatialVerticalMin = geospatialVerticalMin; + } + + public float getGeospatialVerticalMax() { + return geospatialVerticalMax; + } + + public void setGeospatialVerticalMax(float geospatialVerticalMax) { + this.geospatialVerticalMax = geospatialVerticalMax; + } +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransectImportModelRow.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransitImportModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransitImportModel.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransitImportModel.java 2012-01-26 10:54:27 UTC (rev 293) @@ -23,7 +23,6 @@ */ package fr.ifremer.echobase.services.csv; -import fr.ifremer.echobase.entities.data.Transit; import fr.ifremer.echobase.entities.data.Voyage; import java.util.Map; @@ -34,7 +33,7 @@ * @author tchemit <chemit@codelutin.com> * @since 0.3 */ -public class TransitImportModel extends CsvModelUtil.AbstractImportModel<Map<String, Object>> { +public class TransitImportModel extends CsvModelUtil.AbstractImportModel<TransitImportModelRow> { public static final String TRANSIT_VoyageId = "voyageName"; @@ -44,16 +43,16 @@ Map<String, Voyage> voyageMap) { super(separator); this.voyageMap = voyageMap; - modelBuilder.newMandatoryColumn(TRANSIT_VoyageId, TRANSIT_VoyageId, CsvModelUtil.newForeignKeyValue(Voyage.class, voyageMap)); - modelBuilder.newMandatoryColumn(Transit.PROPERTY_DESCRIPTION, Transit.PROPERTY_DESCRIPTION); - modelBuilder.newMandatoryColumn(Transit.PROPERTY_START_TIME, Transit.PROPERTY_START_TIME, CsvModelUtil.DAY_TIME); - modelBuilder.newMandatoryColumn(Transit.PROPERTY_END_TIME, Transit.PROPERTY_END_TIME, CsvModelUtil.DAY_TIME); - modelBuilder.newMandatoryColumn(Transit.PROPERTY_START_LOCALITY, Transit.PROPERTY_START_LOCALITY); - modelBuilder.newMandatoryColumn(Transit.PROPERTY_END_LOCALITY, Transit.PROPERTY_END_LOCALITY); + newMandatoryColumn("voyageName", TransitImportModelRow.PROPERTY_VOYAGE, CsvModelUtil.newForeignKeyValue(Voyage.class, voyageMap)); + newMandatoryColumn(TransitImportModelRow.PROPERTY_DESCRIPTION); + newMandatoryColumn(TransitImportModelRow.PROPERTY_START_TIME, CsvModelUtil.DAY_TIME); + newMandatoryColumn(TransitImportModelRow.PROPERTY_END_TIME, CsvModelUtil.DAY_TIME); + newMandatoryColumn(TransitImportModelRow.PROPERTY_START_LOCALITY); + newMandatoryColumn(TransitImportModelRow.PROPERTY_END_LOCALITY); } @Override - public Map<String, Object> newEmptyInstance() { - return null; + public TransitImportModelRow newEmptyInstance() { + return new TransitImportModelRow(); } } Added: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransitImportModelRow.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransitImportModelRow.java (rev 0) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransitImportModelRow.java 2012-01-26 10:54:27 UTC (rev 293) @@ -0,0 +1,120 @@ +/* + * #%L + * EchoBase :: Services + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.services.csv; + +import fr.ifremer.echobase.entities.data.Transit; +import fr.ifremer.echobase.entities.data.Voyage; + +import java.util.Date; + +/** +* Bean used as a row for import of {@link TransitImportModel}. +* +* @author tchemit <chemit@codelutin.com> +* @since 0.3 +*/ +public class TransitImportModelRow { + + public static final String PROPERTY_VOYAGE = "voyage"; + + public static final String PROPERTY_DESCRIPTION = Transit.PROPERTY_DESCRIPTION; + + public static final String PROPERTY_START_TIME = Transit.PROPERTY_START_TIME; + + public static final String PROPERTY_END_TIME = Transit.PROPERTY_END_TIME; + + public static final String PROPERTY_START_LOCALITY = Transit.PROPERTY_START_LOCALITY; + + public static final String PROPERTY_END_LOCALITY = Transit.PROPERTY_END_LOCALITY; + + protected Voyage voyage; + + protected String description; + + protected String relatedActivity; + + protected Date startTime; + + protected Date endTime; + + protected String startLocality; + + protected String endLocality; + + public Voyage getVoyage() { + return voyage; + } + + public void setVoyage(Voyage voyage) { + this.voyage = voyage; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getRelatedActivity() { + return relatedActivity; + } + + public void setRelatedActivity(String relatedActivity) { + this.relatedActivity = relatedActivity; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + public String getStartLocality() { + return startLocality; + } + + public void setStartLocality(String startLocality) { + this.startLocality = startLocality; + } + + public String getEndLocality() { + return endLocality; + } + + public void setEndLocality(String endLocality) { + this.endLocality = endLocality; + } +} Property changes on: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/TransitImportModelRow.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/VoyageImportModel.java =================================================================== --- trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/VoyageImportModel.java 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-services/src/main/java/fr/ifremer/echobase/services/csv/VoyageImportModel.java 2012-01-26 10:54:27 UTC (rev 293) @@ -36,11 +36,11 @@ public VoyageImportModel(char separator) { super(separator); - modelBuilder.newMandatoryColumn(Voyage.PROPERTY_NAME, Voyage.PROPERTY_NAME); - modelBuilder.newMandatoryColumn(Voyage.PROPERTY_START_DATE, Voyage.PROPERTY_START_DATE, CsvModelUtil.DAY); - modelBuilder.newMandatoryColumn(Voyage.PROPERTY_END_DATE, Voyage.PROPERTY_END_DATE, CsvModelUtil.DAY); - modelBuilder.newMandatoryColumn(Voyage.PROPERTY_START_PORT, Voyage.PROPERTY_START_PORT); - modelBuilder.newMandatoryColumn(Voyage.PROPERTY_END_PORT, Voyage.PROPERTY_END_PORT); + newMandatoryColumn(Voyage.PROPERTY_NAME); + newMandatoryColumn(Voyage.PROPERTY_START_DATE, CsvModelUtil.DAY); + newMandatoryColumn(Voyage.PROPERTY_END_DATE, CsvModelUtil.DAY); + newMandatoryColumn(Voyage.PROPERTY_START_PORT); + newMandatoryColumn(Voyage.PROPERTY_END_PORT); } @Override Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties =================================================================== --- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2012-01-26 10:54:27 UTC (rev 293) @@ -21,7 +21,11 @@ echobase.action.return=Retour echobase.action.save=Sauvegarder echobase.action.saveSqlQuery=Enregistrer la requête +echobase.common.acousticDensityUnit=acousticDensityUnit +echobase.common.acquisitionSoftwareVersionER60=acquisitionSoftwareVersion (ER60 instrument) +echobase.common.acquisitionSoftwareVersionME70=acquisitionSoftwareVersion (ME70 instrument) echobase.common.admin=Administrateur +echobase.common.digitThreshold=digitThreshold echobase.common.echosounderSoundSpeed=echosounderSoundSpeed echobase.common.email=Email echobase.common.entityType=Type d'entité @@ -34,10 +38,15 @@ echobase.common.jdbcLogin=Login de connexion echobase.common.jdbcPassword=Mot de passe echobase.common.jdbcUrl=Url de connexion +echobase.common.loggedDataDatatype=loggedDataDatatype +echobase.common.loggedDataFormat=loggedDataFormat echobase.common.notes=notes echobase.common.password=Mot de passe echobase.common.pingDutyCycle=pingDutyCycle echobase.common.soundSpeedCalculations=soundSpeedCalculations +echobase.common.soundSpeedCalculationsER60=soundSpeedCalculations (ER60 instrument) +echobase.common.soundSpeedCalculationsME70=soundSpeedCalculations (ME70 instrument) +echobase.common.sounderConstant=sounderConstant echobase.common.transectBinUnitsPingAxis=BinUnitsPingAxis (transect) echobase.common.transectGeospatialVerticalPositive=GeospatialVerticalPositive (transect) echobase.common.transectLicence=Licence (transect) Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureAccousticData.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureAccousticData.jsp 2012-01-26 10:52:23 UTC (rev 292) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/importData/configureAccousticData.jsp 2012-01-26 10:54:27 UTC (rev 293) @@ -45,19 +45,56 @@ label='%{getText("echobase.common.voyage")}' list="voyages" headerKey="" headerValue=""/> + <s:select name="model.transitId" value="''" required="true" + label='%{getText("echobase.common.transit")}' + list="transits" headerKey="" headerValue=""/> + <s:select name="model.vesselId" value="''" required="true" label='%{getText("echobase.common.vessel")}' list="vessels" headerKey="" headerValue=""/> - <s:textfield key="model.echosounderSoundSpeed" size="40" required="true" - label='%{getText("echobase.common.echosounderSoundSpeed")}'/> + <s:textfield key="model.transceiverAcquisitionAbsorptionDescription" size="40" required="true" + label='%{getText("echobase.common.transceiverAcquisitionAbsorptionDescription")}'/> - <s:textfield key="model.soundSpeedCalculations" size="40" required="true" - label='%{getText("echobase.common.soundSpeedCalculations")}'/> + <s:textfield key="model.acquisitionSoftwareVersionER60" size="40" required="true" + label='%{getText("echobase.common.acquisitionSoftwareVersionER60")}'/> + <s:textfield key="model.acquisitionSoftwareVersionME70" size="40" required="true" + label='%{getText("echobase.common.acquisitionSoftwareVersionME70")}'/> + + <s:textfield key="model.loggedDataFormat" size="40" required="true" + label='%{getText("echobase.common.loggedDataFormat")}'/> + + <s:textfield key="model.loggedDataDatatype" size="40" required="true" + label='%{getText("echobase.common.loggedDataDatatype")}'/> + <s:textfield key="model.pingDutyCycle" size="40" required="true" label='%{getText("echobase.common.pingDutyCycle")}'/> + <s:textfield key="model.echosounderSoundSpeed" size="40" required="true" + label='%{getText("echobase.common.echosounderSoundSpeed")}'/> + + <s:textfield key="model.soundSpeedCalculationsER60" size="40" required="true" + label='%{getText("echobase.common.soundSpeedCalculationsER60")}'/> + + <s:textfield key="model.soundSpeedCalculationsME70" size="40" required="true" + label='%{getText("echobase.common.soundSpeedCalculationsME70")}'/> + + <s:textfield key="model.sounderConstant" size="40" required="true" + label='%{getText("echobase.common.sounderConstant")}'/> + + <s:textfield key="model.processingTemplate" size="40" required="true" + label='%{getText("echobase.common.processingTemplate")}'/> + + <s:textfield key="model.processingDescription" size="40" required="true" + label='%{getText("echobase.common.processingDescription")}'/> + + <s:textfield key="model.digitThreshold" size="40" required="true" + label='%{getText("echobase.common.digitThreshold")}'/> + + <s:textfield key="model.acousticDensityUnit" size="40" required="true" + label='%{getText("echobase.common.acousticDensityUnit")}'/> + <s:textfield key="model.notes" size="40" required="true" label='%{getText("echobase.common.notes")}'/>
participants (1)
-
tchemit@users.forge.codelutin.com