This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository echobase. See http://git.codelutin.com/echobase.git commit 514f408b63a8ce30bbd4a34d3576d45de7486adc Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Jan 21 17:15:25 2015 +0100 utilisation d'une classe helper pour chaque entite --- .../fr/ifremer/echobase/EchoBaseFunctions.java | 371 --------------------- .../fr/ifremer/echobase/EchoBasePredicates.java | 190 ----------- .../fr/ifremer/echobase/entities/ImportLogs.java | 26 ++ .../fr/ifremer/echobase/entities/data/Cells.java | 68 ++++ .../echobase/entities/data/DataProcessings.java | 18 + .../ifremer/echobase/entities/data/Echotypes.java | 37 ++ .../ifremer/echobase/entities/data/Operations.java | 47 +++ .../fr/ifremer/echobase/entities/data/Results.java | 18 + .../ifremer/echobase/entities/data/Transects.java | 19 ++ .../ifremer/echobase/entities/data/VoyageImpl.java | 8 +- .../fr/ifremer/echobase/entities/data/Voyages.java | 18 + .../entities/references/AcousticInstruments.java | 26 ++ .../entities/references/AgeCategories.java | 18 + .../entities/references/AreaOfOperations.java | 18 + .../echobase/entities/references/CellMethods.java | 18 + .../echobase/entities/references/CellTypes.java | 80 +++++ .../entities/references/DataMetadatas.java | 18 + .../entities/references/DataQualities.java | 25 ++ .../echobase/entities/references/DataTypes.java | 18 + .../entities/references/DepthStratums.java | 18 + .../entities/references/EchotypeCategories.java | 18 + .../entities/references/GearMetadatas.java | 18 + .../echobase/entities/references/Gears.java | 21 ++ .../echobase/entities/references/Missions.java | 18 + .../entities/references/OperationEvents.java | 18 + .../entities/references/OperationMetadatas.java | 18 + .../entities/references/ReferenceDatumTypes.java | 18 + .../entities/references/ReferenceDatums.java | 18 + .../entities/references/SampleDataTypes.java | 25 ++ .../entities/references/SexCategories.java | 18 + .../entities/references/SizeCategories.java | 27 ++ .../echobase/entities/references/Species2.java | 8 + .../entities/references/SpeciesCategories.java | 29 ++ .../echobase/entities/references/Stratas.java | 18 + .../echobase/entities/references/VesselTypes.java | 18 + .../echobase/entities/references/Vessels.java | 18 + 36 files changed, 801 insertions(+), 566 deletions(-) diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java b/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java deleted file mode 100644 index c0f32b6..0000000 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBaseFunctions.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - * #%L - * EchoBase :: Domain - * %% - * Copyright (C) 2011 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; - -import com.google.common.base.Function; -import fr.ifremer.echobase.entities.ImportLog; -import fr.ifremer.echobase.entities.ImportType; -import fr.ifremer.echobase.entities.data.Cell; -import fr.ifremer.echobase.entities.data.DataProcessing; -import fr.ifremer.echobase.entities.data.Echotype; -import fr.ifremer.echobase.entities.data.Operation; -import fr.ifremer.echobase.entities.data.Result; -import fr.ifremer.echobase.entities.data.Transect; -import fr.ifremer.echobase.entities.data.Voyage; -import fr.ifremer.echobase.entities.references.AcousticInstrument; -import fr.ifremer.echobase.entities.references.AgeCategory; -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; -import fr.ifremer.echobase.entities.references.EchotypeCategory; -import fr.ifremer.echobase.entities.references.Gear; -import fr.ifremer.echobase.entities.references.GearMetadata; -import fr.ifremer.echobase.entities.references.Mission; -import fr.ifremer.echobase.entities.references.OperationEvent; -import fr.ifremer.echobase.entities.references.OperationMetadata; -import fr.ifremer.echobase.entities.references.ReferenceDatum; -import fr.ifremer.echobase.entities.references.ReferenceDatumType; -import fr.ifremer.echobase.entities.references.SampleDataType; -import fr.ifremer.echobase.entities.references.SexCategory; -import fr.ifremer.echobase.entities.references.SizeCategory; -import fr.ifremer.echobase.entities.references.Species; -import fr.ifremer.echobase.entities.references.SpeciesCategory; -import fr.ifremer.echobase.entities.references.Strata; -import fr.ifremer.echobase.entities.references.Vessel; -import fr.ifremer.echobase.entities.references.VesselType; - -import java.io.File; -import java.util.Map; - -/** - * Define some usefull function used by application. - * - * @author tchemit <chemit@codelutin.com> - * @see Function - * @since 0.2 - */ -public class EchoBaseFunctions { - - public static final Function<Voyage, String> VOYAGE_NAME = new Function<Voyage, String>() { - @Override - public String apply(Voyage input) { - return input.getName(); - } - }; - - public static final Function<Species, String> SPECIES_BARACOUDA_CODE = new Function<Species, String>() { - @Override - public String apply(Species input) { - return input.getBaracoudaCode(); - } - }; - - public static final Function<Vessel, String> VESSEL_NAME = new Function<Vessel, String>() { - @Override - public String apply(Vessel input) { - return input.getName(); - } - }; - - public static final Function<VesselType, String> VESSEL_TYPE_NAME = new Function<VesselType, String>() { - @Override - public String apply(VesselType input) { - return input.getName(); - } - }; - - public static final Function<AcousticInstrument, String> ACOUSTIC_INSTRUMENT_ID = new Function<AcousticInstrument, String>() { - @Override - public String apply(AcousticInstrument input) { - return input.getId(); - } - }; - - 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) { - return input.getId(); - } - }; - - public static final Function<EchotypeCategory, String> ECHO_TYPE_CATEGORY_NAME = new Function<EchotypeCategory, String>() { - @Override - public String apply(EchotypeCategory input) { - return input.getName(); - } - }; - - public static final Function<ReferenceDatumType, String> REFERENCE_DATUM_TYPE_NAME = new Function<ReferenceDatumType, String>() { - @Override - public String apply(ReferenceDatumType input) { - return input.getName(); - } - }; - - public static final Function<ReferenceDatum, String> REFERENCE_DATUM_ID = new Function<ReferenceDatum, String>() { - @Override - public String apply(ReferenceDatum input) { - return input.getId(); - } - }; - - public static final Function<Result, Cell> RESULT_CELL = new Function<Result, Cell>() { - @Override - public Cell apply(Result input) { - return input.getCell(); - } - }; - - public static final Function<Mission, String> MISSION_NAME = new Function<Mission, String>() { - @Override - public String apply(Mission input) { - return input.getName(); - } - }; - - public static final Function<AreaOfOperation, String> AREA_OF_OPERATION_NAME = new Function<AreaOfOperation, String>() { - @Override - public String apply(AreaOfOperation input) { - 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) { - return input.getId(); - } - }; - - public static final Function<DataQuality, Integer> DATA_QUALITY_ID = new Function<DataQuality, Integer>() { - @Override - public Integer apply(DataQuality input) { - return input.getQualityDataFlagValues(); - } - }; - - 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) { - return String.valueOf(input.getRaptriBiometryDataType()); - } - }; - - public static final Function<SampleDataType, String> SAMPLE_DATA_TYPE_NAME = new Function<SampleDataType, String>() { - @Override - public String apply(SampleDataType input) { - return String.valueOf(input.getName()); - } - }; - - public static final Function<OperationEvent, String> OPERATION_EVENT_NAME = new Function<OperationEvent, String>() { - @Override - public String apply(OperationEvent input) { - return input.getName(); - } - }; - - public static final Function<Gear, String> GEAR_CASINO_GEAR_NAME = new Function<Gear, String>() { - @Override - public String apply(Gear input) { - //FIXME : Remove the dummy test when all gear in db have a casino name - String casinoGearName = input.getCasinoGearName(); -// return StringUtils.isEmpty(casinoGearName) ? input.getName() : casinoGearName; - return casinoGearName; - } - }; - - public static final Function<Operation, String> OPERATION_ID = new Function<Operation, String>() { - @Override - public String apply(Operation input) { - return input.getId(); - } - }; - - public static final Function<SizeCategory, String> SIZE_CATEGORY_NAME = new Function<SizeCategory, String>() { - @Override - public String apply(SizeCategory input) { - return input.getName(); - } - }; - - public static final Function<SpeciesCategory, String> SPECIES_CATEGORY_KEY = new Function<SpeciesCategory, String>() { - @Override - public String apply(SpeciesCategory input) { - return getSpeciesCategoryKey(input.getSpecies(), input.getSizeCategory(), input.getSexCategory()); - } - }; - - public static final Function<SexCategory, String> SEX_CATEGORY_NAME = new Function<SexCategory, String>() { - @Override - public String apply(SexCategory input) { - return input.getName(); - } - }; - - public static final Function<DataMetadata, String> DATA_METADATA_NAME = new Function<DataMetadata, String>() { - @Override - public String apply(DataMetadata input) { - return input.getName(); - } - }; - - public static final Function<Strata, String> STRATA_BY_NAME = new Function<Strata, String>() { - @Override - public String apply(Strata input) { - return input.getName(); - } - }; - - public static final Function<OperationMetadata, String> OPERATION_METADATA_NAME = new Function<OperationMetadata, String>() { - @Override - public String apply(OperationMetadata input) { - return input.getName(); - } - }; - - public static final Function<GearMetadata, String> GEAR_METADATA_NAME = new Function<GearMetadata, String>() { - @Override - public String apply(GearMetadata input) { - return input.getName(); - } - }; - - public static final Function<Transect, Vessel> TRANSECT_BY_VESSEL = new Function<Transect, Vessel>() { - @Override - public Vessel apply(Transect input) { - return input.getVessel(); - } - }; - - public static final Function<Echotype, String> ECHOTYPE_NAME = new Function<Echotype, String>() { - @Override - public String apply(Echotype input) { - return input.getName(); - } - }; - - public static final Function<AgeCategory, String> AGE_CATEGORY_NAME = new Function<AgeCategory, String>() { - @Override - public String apply(AgeCategory input) { - return input.getName(); - } - }; - - public static final Function<Cell, String> CELL_BY_NAME = new Function<Cell, String>() { - @Override - public String apply(Cell input) { - return input.getName(); - } - }; - - public static final Function<DataQuality, String> DATA_QUALITY_NAME = new Function<DataQuality, String>() { - @Override - public String apply(DataQuality input) { - return String.valueOf(input.getQualityDataFlagValues()); - } - }; - - public static final Function<ImportLog, String> IMPORT_LOG_VOYAGE_ID = new Function<ImportLog, String>() { - @Override - public String apply(ImportLog input) { - return input.getVoyageId(); - } - }; - - public static final Function<ImportLog, ImportType> IMPORT_LOG_IMPORT_TYPE= new Function<ImportLog, ImportType>() { - @Override - public ImportType apply(ImportLog input) { - return input.getImportType(); - } - }; - - public static String getSpeciesCategoryKey(Species species, SizeCategory sizeCategory, SexCategory sexCategory) { - String key = species.getBaracoudaCode(); - if (sizeCategory != null) { - key += "_" + sizeCategory.getName(); - } - if (sexCategory != null) { - key += "_" + sexCategory.getName(); - } - return key; - } - - public static Function<Map<String, Object>, String> newRowFunction(final String key) { - - return new Function<Map<String, Object>, String>() { - - @Override - public String apply(Map<String, Object> input) { - String id = input.get(key).toString(); - return id; - } - }; - } - - public static Function<Map<String, Object>, Integer> newRowIntegerFunction(final String key) { - - return new Function<Map<String, Object>, Integer>() { - - @Override - public Integer apply(Map<String, Object> input) { - Integer id = (Integer) input.get(key); - return id; - } - }; - } - - protected EchoBaseFunctions() { - // helper don't need to be instanciate - } -} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBasePredicates.java b/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBasePredicates.java deleted file mode 100644 index 0a1f140..0000000 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/EchoBasePredicates.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * #%L - * EchoBase :: Domain - * %% - * 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; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.Sets; -import fr.ifremer.echobase.entities.data.Cell; -import fr.ifremer.echobase.entities.data.Echotype; -import fr.ifremer.echobase.entities.data.Operation; -import fr.ifremer.echobase.entities.data.Sample; -import fr.ifremer.echobase.entities.references.AcousticInstrument; -import fr.ifremer.echobase.entities.references.CellType; -import fr.ifremer.echobase.entities.references.CellTypeImpl; -import fr.ifremer.echobase.entities.references.SampleTypeImpl; -import fr.ifremer.echobase.entities.references.SizeCategory; -import org.apache.commons.collections4.CollectionUtils; - -import java.util.Collection; -import java.util.Set; - -/** - * Keep usefull precidates on model. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public class EchoBasePredicates { - - public static final Predicate<AcousticInstrument> IS_ACOUSTIC_INSTRUMENT_ME70 = new Predicate<AcousticInstrument>() { - @Override - public boolean apply(AcousticInstrument input) { - return input.getId().toUpperCase().contains("MEBS"); - } - }; - - public static final Predicate<SizeCategory> IS_HORS_VRAC = new Predicate<SizeCategory>() { - @Override - public boolean apply(SizeCategory input) { - return input.getName().toUpperCase().equals("H"); - } - }; - - public static final Predicate<CellType> IS_ESDU_CELL_TYPE = new Predicate<CellType>() { - - @Override - public boolean apply(CellType input) { - boolean result = CellTypeImpl.ESDU.equals(input.getId().toLowerCase()); - return result; - } - }; - - public static final Predicate<CellType> IS_ELEMENTARY_CELL_TYPE = new Predicate<CellType>() { - - @Override - public boolean apply(CellType input) { - boolean result = CellTypeImpl.ELEMENTARY.equals(input.getId().toLowerCase()); - return result; - } - }; - - public static final Predicate<CellType> IS_MAP_CELL_TYPE = new Predicate<CellType>() { - - public final Set<String> acceptedNames = Sets.newHashSet( - CellTypeImpl.MAP - ); - - @Override - public boolean apply(CellType input) { - boolean result = acceptedNames.contains(input.getId()); - return result; - } - }; - - public static final Predicate<CellType> IS_SHOAL_CELL_TYPE = new Predicate<CellType>() { - - public final Set<String> acceptedNames = Sets.newHashSet( - CellTypeImpl.SHOAL - ); - - @Override - public boolean apply(CellType input) { - boolean result = acceptedNames.contains(input.getId()); - return result; - } - }; - - public static final Predicate<CellType> IS_REGION_CELL_TYPE = Predicates.not(Predicates.and( - IS_ESDU_CELL_TYPE, - IS_ELEMENTARY_CELL_TYPE, - IS_SHOAL_CELL_TYPE, - IS_MAP_CELL_TYPE)); - - public static final Predicate<Cell> IS_REGION_CELL = new Predicate<Cell>() { - @Override - public boolean apply(Cell input) { - CellType cellType = input.getCellType(); - boolean result = cellType != null && - IS_REGION_CELL_TYPE.apply(cellType); - return result; - } - }; - - public static final Predicate<Cell> IS_MAP_CELL = new Predicate<Cell>() { - @Override - public boolean apply(Cell input) { - CellType cellType = input.getCellType(); - boolean result = cellType != null && - IS_MAP_CELL_TYPE.apply(cellType); - return result; - } - }; - - public static final Predicate<Cell> IS_ELEMENTARY_CELL = new Predicate<Cell>() { - @Override - public boolean apply(Cell input) { - CellType cellType = input.getCellType(); - boolean result = cellType != null && - IS_ELEMENTARY_CELL_TYPE.apply(cellType); - return result; - } - }; - - public static final Predicate<Cell> IS_ESDU_CELL = new Predicate<Cell>() { - @Override - public boolean apply(Cell input) { - CellType cellType = input.getCellType(); - boolean result = cellType != null && - IS_ESDU_CELL_TYPE.apply(cellType); - return result; - } - }; - - public static final Predicate<Cell> IS_POINT_CELL = Predicates.or(IS_ELEMENTARY_CELL, IS_ESDU_CELL); - - public static final Predicate<Operation> OPERATION_WITH_TOTAL_OR_UNSORTED_SAMPLE = new Predicate<Operation>() { - @Override - public boolean apply(Operation input) { - Collection<Sample> samples = input.getSample(); - - Set<String> acceptedTypes = Sets.newHashSet(SampleTypeImpl.TOTAL_SAMPLE_TYPE, SampleTypeImpl.UNSORTED_SAMPLE_TYPE); - boolean result = false; - if (CollectionUtils.isNotEmpty(samples)) { - for (Sample sample : samples) { - String sampleType = sample.getSampleType().getName(); - if (acceptedTypes.contains(sampleType)) { - result = true; - break; - } - } - } - return result; - } - }; - - public static Predicate<Echotype> newEchotypeByNamePredicate(String name) { - return new EchotypeByNamePredicate(name); - } - - public static class EchotypeByNamePredicate implements Predicate<Echotype> { - private final String echotypeName; - - public EchotypeByNamePredicate(String echotypeName) { - this.echotypeName = echotypeName; - } - - @Override - public boolean apply(Echotype input) { - return echotypeName.equals(input.getName()); - } - } -} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportLogs.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportLogs.java new file mode 100644 index 0000000..44c32ae --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/ImportLogs.java @@ -0,0 +1,26 @@ +package fr.ifremer.echobase.entities; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class ImportLogs { + + public static final Function<ImportLog, String> IMPORT_LOG_VOYAGE_ID = new Function<ImportLog, String>() { + @Override + public String apply(ImportLog input) { + return input.getVoyageId(); + } + }; + + public static final Function<ImportLog, ImportType> IMPORT_LOG_IMPORT_TYPE = new Function<ImportLog, ImportType>() { + @Override + public ImportType apply(ImportLog input) { + return input.getImportType(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Cells.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Cells.java new file mode 100644 index 0000000..2292ad5 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Cells.java @@ -0,0 +1,68 @@ +package fr.ifremer.echobase.entities.data; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import fr.ifremer.echobase.entities.data.Cell; +import fr.ifremer.echobase.entities.references.CellType; +import fr.ifremer.echobase.entities.references.CellTypes; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class Cells { + + + public static final Predicate<Cell> IS_REGION_CELL = new Predicate<Cell>() { + + @Override + public boolean apply(Cell input) { + CellType cellType = input.getCellType(); + boolean result = cellType != null && + CellTypes.IS_REGION_CELL_TYPE.apply(cellType); + return result; + } + }; + + public static final Predicate<Cell> IS_MAP_CELL = new Predicate<Cell>() { + @Override + public boolean apply(Cell input) { + CellType cellType = input.getCellType(); + boolean result = cellType != null && + CellTypes.IS_MAP_CELL_TYPE.apply(cellType); + return result; + } + }; + + public static final Predicate<Cell> IS_ELEMENTARY_CELL = new Predicate<Cell>() { + @Override + public boolean apply(Cell input) { + CellType cellType = input.getCellType(); + boolean result = cellType != null && + CellTypes.IS_ELEMENTARY_CELL_TYPE.apply(cellType); + return result; + } + }; + + public static final Predicate<Cell> IS_ESDU_CELL = new Predicate<Cell>() { + @Override + public boolean apply(Cell input) { + CellType cellType = input.getCellType(); + boolean result = cellType != null && + CellTypes.IS_ESDU_CELL_TYPE.apply(cellType); + return result; + } + }; + + public static final Predicate<Cell> IS_POINT_CELL = Predicates.or(IS_ELEMENTARY_CELL, IS_ESDU_CELL); + + public static final Function<Cell, String> CELL_BY_NAME = new Function<Cell, String>() { + @Override + public String apply(Cell input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/DataProcessings.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/DataProcessings.java new file mode 100644 index 0000000..eaeb28f --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/DataProcessings.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.data; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class DataProcessings { + public static final Function<DataProcessing, String> DATA_PROCESSING_ID = new Function<DataProcessing, String>() { + @Override + public String apply(DataProcessing input) { + return input.getId(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Echotypes.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Echotypes.java new file mode 100644 index 0000000..eaaf870 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Echotypes.java @@ -0,0 +1,37 @@ +package fr.ifremer.echobase.entities.data; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class Echotypes { + + public static final Function<Echotype, String> ECHOTYPE_NAME = new Function<Echotype, String>() { + @Override + public String apply(Echotype input) { + return input.getName(); + } + }; + + public static Predicate<Echotype> newEchotypeByNamePredicate(String name) { + return new EchotypeByNamePredicate(name); + } + + public static class EchotypeByNamePredicate implements Predicate<Echotype> { + private final String echotypeName; + + public EchotypeByNamePredicate(String echotypeName) { + this.echotypeName = echotypeName; + } + + @Override + public boolean apply(Echotype input) { + return echotypeName.equals(input.getName()); + } + } +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Operations.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Operations.java new file mode 100644 index 0000000..732266d --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Operations.java @@ -0,0 +1,47 @@ +package fr.ifremer.echobase.entities.data; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.Sets; +import fr.ifremer.echobase.entities.data.Operation; +import fr.ifremer.echobase.entities.data.Sample; +import fr.ifremer.echobase.entities.references.SampleTypeImpl; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.Collection; +import java.util.Set; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class Operations { + public static final Predicate<Operation> OPERATION_WITH_TOTAL_OR_UNSORTED_SAMPLE = new Predicate<Operation>() { + @Override + public boolean apply(Operation input) { + Collection<Sample> samples = input.getSample(); + + Set<String> acceptedTypes = Sets.newHashSet(SampleTypeImpl.TOTAL_SAMPLE_TYPE, SampleTypeImpl.UNSORTED_SAMPLE_TYPE); + boolean result = false; + if (CollectionUtils.isNotEmpty(samples)) { + for (Sample sample : samples) { + String sampleType = sample.getSampleType().getName(); + if (acceptedTypes.contains(sampleType)) { + result = true; + break; + } + } + } + return result; + } + }; + + public static final Function<Operation, String> OPERATION_ID = new Function<Operation, String>() { + @Override + public String apply(Operation input) { + return input.getId(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Results.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Results.java new file mode 100644 index 0000000..f5d5cc8 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Results.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.data; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class Results { + public static final Function<Result, Cell> RESULT_CELL = new Function<Result, Cell>() { + @Override + public Cell apply(Result input) { + return input.getCell(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Transects.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Transects.java new file mode 100644 index 0000000..637c183 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Transects.java @@ -0,0 +1,19 @@ +package fr.ifremer.echobase.entities.data; + +import com.google.common.base.Function; +import fr.ifremer.echobase.entities.references.Vessel; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class Transects { + public static final Function<Transect, Vessel> TRANSECT_BY_VESSEL = new Function<Transect, Vessel>() { + @Override + public Vessel apply(Transect input) { + return input.getVessel(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/VoyageImpl.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/VoyageImpl.java index ff8619b..35caf77 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/VoyageImpl.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/VoyageImpl.java @@ -24,8 +24,6 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import fr.ifremer.echobase.EchoBaseFunctions; -import fr.ifremer.echobase.EchoBasePredicates; import fr.ifremer.echobase.entities.references.Vessel; import java.util.Collection; @@ -102,7 +100,7 @@ public class VoyageImpl extends VoyageAbstract { Collection<Vessel> vesselsOfTransit = Collections2.transform( transit.getTransect(), - EchoBaseFunctions.TRANSECT_BY_VESSEL); + Transects.TRANSECT_BY_VESSEL); result.addAll(vesselsOfTransit); } } @@ -151,7 +149,7 @@ public class VoyageImpl extends VoyageAbstract { result = Lists.newArrayList(); } else { result = Collections2.filter(getPostCell(), - EchoBasePredicates.IS_REGION_CELL); + Cells.IS_REGION_CELL); } return result; } @@ -163,7 +161,7 @@ public class VoyageImpl extends VoyageAbstract { result = Lists.newArrayList(); } else { result = Collections2.filter(getPostCell(), - EchoBasePredicates.IS_MAP_CELL); + Cells.IS_MAP_CELL); } return result; } diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Voyages.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Voyages.java new file mode 100644 index 0000000..4cef79e --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/data/Voyages.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.data; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class Voyages { + public static final Function<Voyage, String> VOYAGE_NAME = new Function<Voyage, String>() { + @Override + public String apply(Voyage input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/AcousticInstruments.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/AcousticInstruments.java new file mode 100644 index 0000000..f5ae207 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/AcousticInstruments.java @@ -0,0 +1,26 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class AcousticInstruments { + public static final Predicate<AcousticInstrument> IS_ACOUSTIC_INSTRUMENT_ME70 = new Predicate<AcousticInstrument>() { + @Override + public boolean apply(AcousticInstrument input) { + return input.getId().toUpperCase().contains("MEBS"); + } + }; + + public static final Function<AcousticInstrument, String> ACOUSTIC_INSTRUMENT_ID = new Function<AcousticInstrument, String>() { + @Override + public String apply(AcousticInstrument input) { + return input.getId(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/AgeCategories.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/AgeCategories.java new file mode 100644 index 0000000..e8821c0 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/AgeCategories.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since XXX + */ +public class AgeCategories { + public static final Function<AgeCategory, String> AGE_CATEGORY_NAME = new Function<AgeCategory, String>() { + @Override + public String apply(AgeCategory input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/AreaOfOperations.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/AreaOfOperations.java new file mode 100644 index 0000000..4b9c6e5 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/AreaOfOperations.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class AreaOfOperations { + public static final Function<AreaOfOperation, String> AREA_OF_OPERATION_NAME = new Function<AreaOfOperation, String>() { + @Override + public String apply(AreaOfOperation input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellMethods.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellMethods.java new file mode 100644 index 0000000..ffe3166 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellMethods.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class CellMethods { + public static final Function<CellMethod, String> CELL_METHOD_NAME = new Function<CellMethod, String>() { + @Override + public String apply(CellMethod input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellTypes.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellTypes.java new file mode 100644 index 0000000..9f844d4 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/CellTypes.java @@ -0,0 +1,80 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.Sets; + +import java.util.Set; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class CellTypes { + + + public static final Predicate<CellType> IS_ESDU_CELL_TYPE = new Predicate<CellType>() { + + @Override + public boolean apply(CellType input) { + boolean result = CellTypeImpl.ESDU.equals(input.getId().toLowerCase()); + return result; + } + }; + + public static final Predicate<CellType> IS_ELEMENTARY_CELL_TYPE = new Predicate<CellType>() { + + @Override + public boolean apply(CellType input) { + boolean result = CellTypeImpl.ELEMENTARY.equals(input.getId().toLowerCase()); + return result; + } + }; + + public static final Predicate<CellType> IS_SHOAL_CELL_TYPE = new Predicate<CellType>() { + + public final Set<String> acceptedNames = Sets.newHashSet( + CellTypeImpl.SHOAL + ); + + @Override + public boolean apply(CellType input) { + boolean result = acceptedNames.contains(input.getId()); + return result; + } + }; + + public static final Predicate<CellType> IS_REGION_CELL_TYPE = new Predicate<CellType>() { + + public final Set<String> acceptedNames = Sets.newHashSet( + CellTypeImpl.REGION, CellTypeImpl.REGION_SURF, CellTypeImpl.REGION_CLAS); + + @Override + public boolean apply(CellType input) { + boolean result = acceptedNames.contains(input.getId()); + return result; + } + }; + + public static final Predicate<CellType> IS_MAP_CELL_TYPE = new Predicate<CellType>() { + + public final Set<String> acceptedNames = Sets.newHashSet( + CellTypeImpl.MAP + ); + + @Override + public boolean apply(CellType input) { + boolean result = acceptedNames.contains(input.getId()); + return result; + } + }; + + public static final Function<CellType, String> CELL_TYPE_ID = new Function<CellType, String>() { + @Override + public String apply(CellType input) { + return input.getId(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataMetadatas.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataMetadatas.java new file mode 100644 index 0000000..ff94ca5 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataMetadatas.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since XXX + */ +public class DataMetadatas { + public static final Function<DataMetadata, String> DATA_METADATA_NAME = new Function<DataMetadata, String>() { + @Override + public String apply(DataMetadata input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataQualities.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataQualities.java new file mode 100644 index 0000000..9cdbc4e --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataQualities.java @@ -0,0 +1,25 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since XXX + */ +public class DataQualities { + public static final Function<DataQuality, String> DATA_QUALITY_NAME = new Function<DataQuality, String>() { + @Override + public String apply(DataQuality input) { + return String.valueOf(input.getQualityDataFlagValues()); + } + }; + + public static final Function<DataQuality, Integer> DATA_QUALITY_ID = new Function<DataQuality, Integer>() { + @Override + public Integer apply(DataQuality input) { + return input.getQualityDataFlagValues(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataTypes.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataTypes.java new file mode 100644 index 0000000..971ffb3 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DataTypes.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class DataTypes { + public static final Function<DataType, String> DATA_TYPE_NAME = new Function<DataType, String>() { + @Override + public String apply(DataType input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DepthStratums.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DepthStratums.java new file mode 100644 index 0000000..08056ea --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/DepthStratums.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class DepthStratums { + public static final Function<DepthStratum, String> DEPTH_STRATUM_ID = new Function<DepthStratum, String>() { + @Override + public String apply(DepthStratum input) { + return input.getId(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/EchotypeCategories.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/EchotypeCategories.java new file mode 100644 index 0000000..d90faf0 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/EchotypeCategories.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class EchotypeCategories { + public static final Function<EchotypeCategory, String> ECHO_TYPE_CATEGORY_NAME = new Function<EchotypeCategory, String>() { + @Override + public String apply(EchotypeCategory input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/GearMetadatas.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/GearMetadatas.java new file mode 100644 index 0000000..424e2e8 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/GearMetadatas.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class GearMetadatas { + public static final Function<GearMetadata, String> GEAR_METADATA_NAME = new Function<GearMetadata, String>() { + @Override + public String apply(GearMetadata input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Gears.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Gears.java new file mode 100644 index 0000000..f79c3ad --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Gears.java @@ -0,0 +1,21 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since XXX + */ +public class Gears { + public static final Function<Gear, String> GEAR_CASINO_GEAR_NAME = new Function<Gear, String>() { + @Override + public String apply(Gear input) { + //FIXME : Remove the dummy test when all gear in db have a casino name + String casinoGearName = input.getCasinoGearName(); +// return StringUtils.isEmpty(casinoGearName) ? input.getName() : casinoGearName; + return casinoGearName; + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Missions.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Missions.java new file mode 100644 index 0000000..81745f7 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Missions.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class Missions { + public static final Function<Mission, String> MISSION_NAME = new Function<Mission, String>() { + @Override + public String apply(Mission input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/OperationEvents.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/OperationEvents.java new file mode 100644 index 0000000..ce7a168 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/OperationEvents.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since XXX + */ +public class OperationEvents { + public static final Function<OperationEvent, String> OPERATION_EVENT_NAME = new Function<OperationEvent, String>() { + @Override + public String apply(OperationEvent input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/OperationMetadatas.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/OperationMetadatas.java new file mode 100644 index 0000000..90c0dc2 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/OperationMetadatas.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class OperationMetadatas { + public static final Function<OperationMetadata, String> OPERATION_METADATA_NAME = new Function<OperationMetadata, String>() { + @Override + public String apply(OperationMetadata input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/ReferenceDatumTypes.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/ReferenceDatumTypes.java new file mode 100644 index 0000000..d034340 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/ReferenceDatumTypes.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class ReferenceDatumTypes { + public static final Function<ReferenceDatumType, String> REFERENCE_DATUM_TYPE_NAME = new Function<ReferenceDatumType, String>() { + @Override + public String apply(ReferenceDatumType input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/ReferenceDatums.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/ReferenceDatums.java new file mode 100644 index 0000000..1e7e089 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/ReferenceDatums.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class ReferenceDatums { + public static final Function<ReferenceDatum, String> REFERENCE_DATUM_ID = new Function<ReferenceDatum, String>() { + @Override + public String apply(ReferenceDatum input) { + return input.getId(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypes.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypes.java new file mode 100644 index 0000000..26dbffc --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SampleDataTypes.java @@ -0,0 +1,25 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class SampleDataTypes { + public static final Function<SampleDataType, String> SAMPLE_DATA_TYPE_RAPTRI_CODE = new Function<SampleDataType, String>() { + @Override + public String apply(SampleDataType input) { + return String.valueOf(input.getRaptriBiometryDataType()); + } + }; + + public static final Function<SampleDataType, String> SAMPLE_DATA_TYPE_NAME = new Function<SampleDataType, String>() { + @Override + public String apply(SampleDataType input) { + return String.valueOf(input.getName()); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SexCategories.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SexCategories.java new file mode 100644 index 0000000..6663a20 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SexCategories.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class SexCategories { + public static final Function<SexCategory, String> SEX_CATEGORY_NAME = new Function<SexCategory, String>() { + @Override + public String apply(SexCategory input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SizeCategories.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SizeCategories.java new file mode 100644 index 0000000..0e6f750 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SizeCategories.java @@ -0,0 +1,27 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; +import com.google.common.base.Predicate; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class SizeCategories { + + public static final Predicate<SizeCategory> IS_HORS_VRAC = new Predicate<SizeCategory>() { + @Override + public boolean apply(SizeCategory input) { + return input.getName().toUpperCase().equals("H"); + } + }; + + public static final Function<SizeCategory, String> SIZE_CATEGORY_NAME = new Function<SizeCategory, String>() { + @Override + public String apply(SizeCategory input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Species2.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Species2.java index 6ac801a..d519eb7 100644 --- a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Species2.java +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Species2.java @@ -21,6 +21,7 @@ package fr.ifremer.echobase.entities.references; * #L% */ +import com.google.common.base.Function; import com.google.common.base.Predicate; /** @@ -31,6 +32,13 @@ import com.google.common.base.Predicate; */ public class Species2 { + public static final Function<Species, String> SPECIES_BARACOUDA_CODE = new Function<Species, String>() { + @Override + public String apply(Species input) { + return input.getBaracoudaCode(); + } + }; + public static Predicate<Species> newCommunityIndicatorSpeciesPredicate() { return new Predicate<Species>() { @Override diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SpeciesCategories.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SpeciesCategories.java new file mode 100644 index 0000000..ad2e0f5 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/SpeciesCategories.java @@ -0,0 +1,29 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class SpeciesCategories { + public static final Function<SpeciesCategory, String> SPECIES_CATEGORY_KEY = new Function<SpeciesCategory, String>() { + @Override + public String apply(SpeciesCategory input) { + return getSpeciesCategoryKey(input.getSpecies(), input.getSizeCategory(), input.getSexCategory()); + } + }; + + public static String getSpeciesCategoryKey(Species species, SizeCategory sizeCategory, SexCategory sexCategory) { + String key = species.getBaracoudaCode(); + if (sizeCategory != null) { + key += "_" + sizeCategory.getName(); + } + if (sexCategory != null) { + key += "_" + sexCategory.getName(); + } + return key; + } +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Stratas.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Stratas.java new file mode 100644 index 0000000..d5d0b95 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Stratas.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class Stratas { + public static final Function<Strata, String> STRATA_BY_NAME = new Function<Strata, String>() { + @Override + public String apply(Strata input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/VesselTypes.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/VesselTypes.java new file mode 100644 index 0000000..416605e --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/VesselTypes.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 2.9 + */ +public class VesselTypes { + public static final Function<VesselType, String> VESSEL_TYPE_NAME = new Function<VesselType, String>() { + @Override + public String apply(VesselType input) { + return input.getName(); + } + }; +} diff --git a/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Vessels.java b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Vessels.java new file mode 100644 index 0000000..1adbec0 --- /dev/null +++ b/echobase-domain/src/main/java/fr/ifremer/echobase/entities/references/Vessels.java @@ -0,0 +1,18 @@ +package fr.ifremer.echobase.entities.references; + +import com.google.common.base.Function; + +/** + * Created on 1/21/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since XXX + */ +public class Vessels { + public static final Function<Vessel, String> VESSEL_NAME = new Function<Vessel, String>() { + @Override + public String apply(Vessel input) { + return input.getName(); + } + }; +} -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.