This is an automated email from the git hooks/post-receive script. New commit to branch feature/6688 in repository tutti. See http://git.codelutin.com/tutti.git commit b106048f5c9a4c8de5a18aa0946218c06a7e814d Author: Tony CHEMIT <chemit@codelutin.com> Date: Fri Feb 20 17:24:29 2015 +0100 introduce operation import context --- .../GenericFormatImportOperationContext.java | 162 +++++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatImportOperationContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatImportOperationContext.java new file mode 100644 index 0000000..f0f107f --- /dev/null +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatImportOperationContext.java @@ -0,0 +1,162 @@ +package fr.ifremer.tutti.service.genericformat; + +import com.google.common.collect.ImmutableSet; +import fr.ifremer.tutti.persistence.entities.CaracteristicMap; +import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; +import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; +import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.TreeMap; + +/** + * Created on 2/20/15. + * + * @author Tony Chemit - chemit@codelutin.com + * @since 3.14 + */ +public class GenericFormatImportOperationContext { + + private final FishingOperation fishingOperation; + + private final String fishingOperationLabel; + + private final Collection<MarineLitterBatch> marineLitterBatches; + + private final Map<Integer, AccidentalBatch> accidentalBatchesById; + + private final Map<Integer, IndividualObservationBatch> individualObservationBatchesById; + + private final Collection<SpeciesBatch> speciesBatches; + + private final Collection<BenthosBatch> benthosBatches; + + private final CaracteristicMap gearUseFeatures; + + private final CaracteristicMap vesselUseFeatures; + + public GenericFormatImportOperationContext(FishingOperation fishingOperation, String fishingOperationLabel) { + + this.fishingOperation = fishingOperation; + this.fishingOperationLabel = fishingOperationLabel; + this.marineLitterBatches = new ArrayList<>(); + this.accidentalBatchesById = new TreeMap<>(); + this.individualObservationBatchesById = new TreeMap<>(); + this.speciesBatches = new ArrayList<>(); + this.benthosBatches = new ArrayList<>(); + this.gearUseFeatures = new CaracteristicMap(); + this.vesselUseFeatures = new CaracteristicMap(); + + } + + public FishingOperation getFishingOperation() { + return fishingOperation; + } + + public String getFishingOperationLabel() { + return fishingOperationLabel; + } + + public boolean withParameters() { + + boolean withGearFeatures = MapUtils.isNotEmpty(gearUseFeatures); + boolean withVesselFeatures = MapUtils.isNotEmpty(vesselUseFeatures); + return withGearFeatures || withVesselFeatures; + + } + + public boolean withMarineLitterBatches() { + return CollectionUtils.isNotEmpty(marineLitterBatches); + } + + public boolean withAccidentalBatches() { + return MapUtils.isNotEmpty(accidentalBatchesById); + } + + public boolean withIndividualObservationBatches() { + return MapUtils.isNotEmpty(individualObservationBatchesById); + } + + public boolean withSpeciesBatches() { + return CollectionUtils.isNotEmpty(speciesBatches); + } + + public boolean withBenthosBatches() { + return CollectionUtils.isNotEmpty(benthosBatches); + } + + public void addGearUseFeature(Caracteristic caracteristic, Serializable value) { + gearUseFeatures.put(caracteristic, value); + } + + public void addVesselUseFeature(Caracteristic caracteristic, Serializable value) { + vesselUseFeatures.put(caracteristic, value); + } + + public void addMarineLitterBatch(MarineLitterBatch marineLitterBatch) { + marineLitterBatches.add(marineLitterBatch); + } + + public AccidentalBatch getAccidentalBatchById(Integer accidentalBatchId) { + AccidentalBatch result = accidentalBatchesById.get(accidentalBatchId); + return result; + } + + public void addAccidentalBatch(Integer batchId, AccidentalBatch accidentalBatch) { + accidentalBatchesById.put(batchId, accidentalBatch); + } + + public IndividualObservationBatch getIndividualObservationBatchesById(Integer individualObservationBatchId) { + return individualObservationBatchesById.get(individualObservationBatchId); + } + + public void addIndividualObservationBatch(Integer batchId, IndividualObservationBatch individualObservationBatch) { + individualObservationBatchesById.put(batchId, individualObservationBatch); + } + + public void addSpeciesBatch(SpeciesBatch speciesBatch) { + speciesBatches.add(speciesBatch); + } + + public void addBenthosBatch(BenthosBatch benthosBatch) { + benthosBatches.add(benthosBatch); + } + + public Collection<MarineLitterBatch> getMarineLitterBatches() { + return ImmutableSet.copyOf(marineLitterBatches); + } + + public Collection<AccidentalBatch> getAccidentalBatches() { + return ImmutableSet.copyOf(accidentalBatchesById.values()); + } + + public Collection<IndividualObservationBatch> getIndividualObservationBatches() { + return ImmutableSet.copyOf(individualObservationBatchesById.values()); + } + + public Collection<SpeciesBatch> getSpeciesBatches() { + return ImmutableSet.copyOf(speciesBatches); + } + + public Collection<BenthosBatch> getBenthosBatches() { + return ImmutableSet.copyOf(benthosBatches); + } + + public CaracteristicMap getGearUseFeatures() { + return gearUseFeatures; + } + + public CaracteristicMap getVesselUseFeatures() { + return vesselUseFeatures; + } +} + -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.