r238 - in trunk/tutti-persistence-adagio/src: main/java/fr/ifremer/tutti/persistence/service main/resources test/java/fr/ifremer/tutti/persistence/service
Author: blavenier Date: 2013-01-21 16:08:12 +0100 (Mon, 21 Jan 2013) New Revision: 238 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/238 Log: ref refs #1920: [Persistence] Adagio Donnees thematiques - Continue implementation of FishingOperation.create() : trawl net number (in GearUseFeatures) - Change storage of cruise.trawlNet and Gear into GearPhysicalFeatures (for allegro compatibility) Added: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementService.java Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-21 10:58:40 UTC (rev 237) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2013-01-21 15:08:12 UTC (rev 238) @@ -24,15 +24,40 @@ * #L% */ +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Iterator; +import java.util.List; + +import javax.annotation.Resource; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.hibernate.type.IntegerType; +import org.hibernate.type.StringType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataRetrievalFailureException; +import org.springframework.stereotype.Service; + import com.google.common.collect.Lists; + import fr.ifremer.adagio.core.dao.administration.user.PersonDao; +import fr.ifremer.adagio.core.dao.data.measure.GearPhysicalMeasurement; import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip; import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.ObservedFishingTrip; import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise; import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruiseDao; +import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures; +import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures; +import fr.ifremer.adagio.core.dao.referential.QualityFlag; import fr.ifremer.adagio.core.dao.referential.QualityFlagDao; +import fr.ifremer.adagio.core.dao.referential.gear.GearDao; import fr.ifremer.adagio.core.dao.referential.location.Location; import fr.ifremer.adagio.core.dao.referential.location.LocationDao; +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmDao; +import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueDao; import fr.ifremer.adagio.core.dao.referential.vessel.VesselDao; import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus; import fr.ifremer.tutti.persistence.entities.data.Cruise; @@ -41,28 +66,13 @@ import fr.ifremer.tutti.persistence.entities.referential.Gear; import fr.ifremer.tutti.persistence.entities.referential.Person; import fr.ifremer.tutti.persistence.entities.referential.Vessel; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.type.IntegerType; -import org.hibernate.type.StringType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataRetrievalFailureException; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import java.sql.Timestamp; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.List; - /** * @author tchemit <chemit@codelutin.com> * @since 0.3 */ @Service("cruisePersistenceService") -public class CruisePersistenceServiceImpl extends AbstractPersistenceService implements CruisePersistenceService { +public class CruisePersistenceServiceImpl extends AbstractPersistenceService implements CruisePersistenceService, MeasurementService { /** Logger. */ private static final Log log = @@ -71,6 +81,8 @@ protected static String CRUISE_MISC_DATA_VESSELS_TAG = "#VESSELS="; protected static String CRUISE_MISC_DATA_GEARS_TAG = "#GEARS="; + + protected static String CRUISE_MISC_DATA_TRAWL_NET_TAG = "#TRAWL_NET="; @Autowired(required = true) protected ReferentialPersistenceService referentielService; @@ -93,6 +105,15 @@ @Resource(name = "qualityFlagDao") protected QualityFlagDao qualityFlagDao; + @Resource(name = "pmfmDao") + protected PmfmDao pmfmDao; + + @Resource(name = "qualitativeValueDao") + protected QualitativeValueDao qualitativeValueDao; + + @Resource(name = "gearDao") + protected GearDao gearDao; + protected Calendar calendar = new GregorianCalendar(); @Override @@ -176,6 +197,16 @@ String miscData = (String) source[11]; if (miscData != null && miscData.length() > 0) { + // Retrieve trawl net + int trawlNetIndex = miscData.indexOf(CRUISE_MISC_DATA_TRAWL_NET_TAG); + if (trawlNetIndex != -1) { + String trawlNetStr = miscData.substring(trawlNetIndex + CRUISE_MISC_DATA_TRAWL_NET_TAG.length()).trim(); + miscData = miscData.substring(0, trawlNetIndex); + if (!trawlNetStr.isEmpty()) { + result.setTrawlNet(Integer.valueOf(trawlNetStr)); + } + } + // Retrieve gears : int gearTagIndex = miscData.indexOf(CRUISE_MISC_DATA_GEARS_TAG); if (gearTagIndex == -1) { @@ -200,6 +231,7 @@ int vesselTagIndex = miscData.indexOf(CRUISE_MISC_DATA_VESSELS_TAG); if (vesselTagIndex != -1) { String vesselCodesStr = miscData.substring(vesselTagIndex + CRUISE_MISC_DATA_VESSELS_TAG.length()).trim(); + miscData = miscData.substring(0, vesselTagIndex); if (!vesselCodesStr.isEmpty()) { String[] vesselCodes = vesselCodesStr.split(","); for (int i = 0; i < vesselCodes.length; i++) { @@ -208,6 +240,7 @@ } } } + } // get secondary gears from fishingOperation (first load from Allegro DB only) @@ -253,7 +286,25 @@ protected void cruiseToEntity(Cruise source, ScientificCruise target, boolean copyIfNull) { StringBuffer miscDataBuffer = new StringBuffer(); - + QualityFlag qualityFlagNotQualified = qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED); + + // Retrieve entities : FishingTrip + ObservedFishingTrip fishingTrip = null; + if (target.getFishingTrips() == null || target.getFishingTrips().size() == 0) { + fishingTrip = ObservedFishingTrip.Factory.newInstance(); + if (target.getFishingTrips() == null) { + target.setFishingTrips(Lists.newArrayList((FishingTrip)fishingTrip)); + fishingTrip.setScientificCruise(target); + } else { + target.getFishingTrips().add(fishingTrip); + fishingTrip.setScientificCruise(target); + } + } else { + fishingTrip = (ObservedFishingTrip)target.getFishingTrips().iterator().next(); + } + + + // Name if (copyIfNull && source.getName() == null) { target.setName(null); @@ -316,9 +367,6 @@ calendar.set(Calendar.MILLISECOND, 0); target.setReturnDateTime(calendar.getTime()); } - - // Poche - // TODO BLA : voir si le PSFM exists // Comment if (copyIfNull && source.getComment() == null) { @@ -360,23 +408,8 @@ if (target.getManagerPerson() != null) { target.setRecorderPerson(target.getManagerPerson()); target.setRecorderDepartment(target.getManagerPerson().getDepartment()); - } + } - // FishingTrip - ObservedFishingTrip fishingTrip = null; - if (target.getFishingTrips() == null || target.getFishingTrips().size() == 0) { - fishingTrip = ObservedFishingTrip.Factory.newInstance(); - if (target.getFishingTrips() == null) { - target.setFishingTrips(Lists.newArrayList((FishingTrip)fishingTrip)); - fishingTrip.setScientificCruise(target); - } else { - target.getFishingTrips().add(fishingTrip); - fishingTrip.setScientificCruise(target); - } - } else { - fishingTrip = (ObservedFishingTrip)target.getFishingTrips().iterator().next(); - } - // Fill fishing trip with scientificCruise info: fishingTrip.setDepartureDateTime(target.getDepartureDateTime()); fishingTrip.setReturnDateTime(target.getReturnDateTime()); @@ -386,9 +419,7 @@ fishingTrip.setRecorderDepartment(target.getRecorderDepartment()); fishingTrip.setCreationDate(target.getCreationDate()); fishingTrip.setSynchronizationStatus(target.getSynchronizationStatus()); - if (fishingTrip.getQualityFlag() == null) { - fishingTrip.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); - } + fishingTrip.setQualityFlag(qualityFlagNotQualified); if (fishingTrip.getReturnDateTime() == null && fishingTrip.getDepartureDateTime() != null) { calendar.setTime(fishingTrip.getDepartureDateTime()); @@ -413,13 +444,142 @@ //throw new UnsupportedOperationException("Cruise could not yet support gears storage."); miscDataBuffer.append(CRUISE_MISC_DATA_GEARS_TAG); for (int i = 0; i < source.getGear().size(); i++) { + Gear gear = source.getGear().get(i); + GearPhysicalFeatures guf = getGearPhysicalfeatures(fishingTrip, Integer.valueOf(gear.getId()), true); + guf.setStartDate(fishingTrip.getDepartureDateTime()); + guf.setEndDate(fishingTrip.getReturnDateTime()); + guf.setVessel(fishingTrip.getVessel()); + guf.setProgram(fishingTrip.getProgram()); + guf.setCreationDate(target.getCreationDate()); + guf.setQualityFlag(qualityFlagNotQualified); + guf.setRankOrder((short)1); + + // Trawl net (store in Gear Physical features) + if (copyIfNull && source.getTrawlNet() == null) { + removeGearPhysicalMeasurement(guf, enumeration.PMFM_ID_TRAWL_NET); + } + else { + setGearPhysicalMeasurement(target, guf, enumeration.PMFM_ID_TRAWL_NET, Float.valueOf(source.getTrawlNet()), null, null); + } + + // TODO BLA : à supprimer : if (i > 0) miscDataBuffer.append(','); miscDataBuffer.append(source.getGear().get(i).getId()); } } - + + // Trawl net (store in misc data) + if (copyIfNull && source.getTrawlNet() == null) { + miscDataBuffer.append(CRUISE_MISC_DATA_TRAWL_NET_TAG); + } else if (source.getTrawlNet() != null) { + //throw new UnsupportedOperationException("Cruise could not yet support gears storage."); + miscDataBuffer.append(CRUISE_MISC_DATA_TRAWL_NET_TAG); + miscDataBuffer.append(source.getTrawlNet()); + } + // Save miscDataBuffer into fishing trip comments, because it's not used in Allegro fishingTrip.setComments(miscDataBuffer.toString()); } - + + @Override + public GearPhysicalFeatures getGearPhysicalfeatures(FishingTrip fishingTrip, Integer gearId) { + return getGearPhysicalfeatures(fishingTrip, gearId, false); + } + + protected GearPhysicalFeatures getGearPhysicalfeatures(FishingTrip fishingTrip, Integer gearId, boolean createIfNotExists) { + // Retrieve entities : Gear Physical Features + if (fishingTrip.getGearPhysicalFeatures() != null && fishingTrip.getGearPhysicalFeatures().size() >= 0) { + for (Iterator iterator = fishingTrip.getGearPhysicalFeatures().iterator(); iterator.hasNext();) { + GearPhysicalFeatures guf = (GearPhysicalFeatures) iterator.next(); + if (gearId.equals(guf.getGear().getId())) { + return guf; + } + } + } + if (!createIfNotExists) { + return null; + } + + GearPhysicalFeatures gearPhysicalFeature = GearPhysicalFeatures.Factory.newInstance(); + gearPhysicalFeature.setFishingTrip(fishingTrip); + fr.ifremer.adagio.core.dao.referential.gear.Gear gear = gearDao.load(gearId); + if (gear == null) { + throw new DataRetrievalFailureException("Gear not found with id=" + gearId); + } + gearPhysicalFeature.setGear(gear); + if (fishingTrip.getGearPhysicalFeatures() == null) { + fishingTrip.setGearPhysicalFeatures(Lists.newArrayList(gearPhysicalFeature)); + } else { + fishingTrip.getGearPhysicalFeatures().add(gearPhysicalFeature); + } + + return gearPhysicalFeature; + } + + @Override + public GearPhysicalMeasurement getGearPhysicalMeasurement(GearPhysicalFeatures gearPhysicalFeatures, Integer pmfmId) { + return getGearPhysicalMeasurement(null, gearPhysicalFeatures, pmfmId, false); + } + + protected GearPhysicalMeasurement getGearPhysicalMeasurement(ScientificCruise scientificCruise, GearPhysicalFeatures gearPhysicalFeatures, + Integer pmfmId, boolean createIfNotExists) { + GearPhysicalMeasurement gearPhysicalMeasurement = null; + if (gearPhysicalFeatures.getGearPhysicalMeasurements() != null) { + for (Iterator iterator = gearPhysicalFeatures.getGearPhysicalMeasurements().iterator(); iterator.hasNext();) { + GearPhysicalMeasurement vum = (GearPhysicalMeasurement) iterator.next(); + if (pmfmId.equals(vum.getPmfm().getId())) { + gearPhysicalMeasurement = vum; + break; + } + } + } + if (gearPhysicalMeasurement == null) { + if (!createIfNotExists) { + return null; + } + gearPhysicalMeasurement = GearPhysicalMeasurement.Factory.newInstance(); + gearPhysicalMeasurement.setGearPhysicalFeatures(gearPhysicalFeatures); + if (gearPhysicalFeatures.getGearPhysicalMeasurements() == null) { + gearPhysicalFeatures.setGearPhysicalMeasurements(Lists.newArrayList(gearPhysicalMeasurement)); + } + else { + gearPhysicalFeatures.getGearPhysicalMeasurements().add(gearPhysicalMeasurement); + } + gearPhysicalMeasurement.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); + gearPhysicalMeasurement.setDepartment(scientificCruise.getRecorderDepartment()); + gearPhysicalMeasurement.setPmfm(pmfmDao.load(pmfmId)); + } + + return gearPhysicalMeasurement; + } + + protected void removeGearPhysicalMeasurement(GearPhysicalFeatures gearPhysicalFeatures, + Integer pmfmId) { + GearPhysicalMeasurement gearPhysicalMeasurement = getGearPhysicalMeasurement(null, gearPhysicalFeatures, pmfmId, false); + if (gearPhysicalMeasurement == null) { + return; + } + gearPhysicalFeatures.getGearPhysicalMeasurements().remove(gearPhysicalMeasurement); + // TOBO BLa : vérifier qu'il ne faut pas dao.delete() en plus + } + + protected GearPhysicalMeasurement setGearPhysicalMeasurement(ScientificCruise scientificCruise, GearPhysicalFeatures gearPhysicalFeatures, + Integer pmfmId, + Float numericalValue, + String alphanumericalValue, + Integer qualitativevalueId) { + GearPhysicalMeasurement gearPhysicalMeasurement = getGearPhysicalMeasurement(scientificCruise, gearPhysicalFeatures, pmfmId, true); + + if (alphanumericalValue != null) { + gearPhysicalMeasurement.setAlphanumericalValue(alphanumericalValue); + } + else if (numericalValue != null) { + gearPhysicalMeasurement.setNumericalValue(numericalValue); + } + else if (qualitativevalueId != null) { + gearPhysicalMeasurement.setQualitativeValue(qualitativeValueDao.load(qualitativevalueId)); + } + + return gearPhysicalMeasurement; + } } Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-01-21 10:58:40 UTC (rev 237) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-01-21 15:08:12 UTC (rev 238) @@ -37,16 +37,21 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.type.IntegerType; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Service; import com.google.common.collect.Lists; +import fr.ifremer.adagio.core.dao.data.measure.GearPhysicalMeasurement; +import fr.ifremer.adagio.core.dao.data.measure.GearUseMeasurement; import fr.ifremer.adagio.core.dao.data.measure.VesselUseMeasurement; import fr.ifremer.adagio.core.dao.data.operation.FishingOperationDao; +import fr.ifremer.adagio.core.dao.data.operation.Operation; import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip; import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise; import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruiseDao; +import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures; import fr.ifremer.adagio.core.dao.data.vessel.feature.use.GearUseFeatures; import fr.ifremer.adagio.core.dao.data.vessel.feature.use.VesselUseFeatures; import fr.ifremer.adagio.core.dao.data.vessel.feature.use.isActive; @@ -71,6 +76,9 @@ private static final Log log = LogFactory.getLog(FishingOperationPersistenceServiceImpl.class); + @Resource(name = "cruisePersistenceService") + protected MeasurementService measurementService; + @Autowired(required = true) protected ReferentialPersistenceService referentielService; @@ -115,7 +123,8 @@ "fishingOperationId", IntegerType.INSTANCE, Integer.valueOf(id), "pmfmIdTrawlDistance", IntegerType.INSTANCE, enumeration.PMFM_ID_TRAWL_DISTANCE, "pmfmIdRectilinearOperation", IntegerType.INSTANCE, enumeration.PMFM_ID_RECTILINEAR_OPERATION, - "pmfmIdHaulValid", IntegerType.INSTANCE, enumeration.PMFM_ID_HAUL_VALID + "pmfmIdHaulValid", IntegerType.INSTANCE, enumeration.PMFM_ID_HAUL_VALID, + "pmfmTrawlNetNumber", IntegerType.INSTANCE, enumeration.PMFM_ID_TRAWL_NET_NUMBER ); if (source == null) { @@ -204,6 +213,12 @@ if (haulValidQualitativeId != null) { result.setFishingOperationValid((enumeration.QUALITATIVE_HAUL_VALID_YES.equals(haulValidQualitativeId))); } + + // Trawl net number (override the value found in the OP name) + Float trawlNetNumber = (Float)source[colIndex++]; + if (trawlNetNumber != null) { + result.setTrawlNetNumber(trawlNetNumber.intValue()); + } return result; } @@ -228,18 +243,18 @@ // Retrieve entities : FishingTrip and ScientificCruise ScientificCruise scientificCruise = null; - FishingTrip fishingtrip = target.getFishingTrip(); - if (fishingtrip == null) { + FishingTrip fishingTrip = target.getFishingTrip(); + if (fishingTrip == null) { // TODO BLA éviter ici un rechargement de fishingTrip : scientificCruise = scientificCruiseDao.load(Integer.valueOf(source.getCruise().getId())); - fishingtrip = scientificCruise.getFishingTrips().iterator().next(); - fishingtrip.getOperations().add(target); // Inverse link + fishingTrip = scientificCruise.getFishingTrips().iterator().next(); + fishingTrip.getOperations().add(target); // Inverse link } else { - scientificCruise = fishingtrip.getScientificCruise(); + scientificCruise = fishingTrip.getScientificCruise(); } // Link to parent fishing trip - target.setFishingTrip(fishingtrip); + target.setFishingTrip(fishingTrip); // Retrieve entities : VesselPosition (start and end) VesselPosition startPosition = null; @@ -257,42 +272,63 @@ } // Retrieve entities : Gear Use Features - GearUseFeatures gearUseFeature = null; + GearUseFeatures gearUseFeatures = null; if (target.getGearUseFeatures() == null || target.getGearUseFeatures().size() == 0) { - gearUseFeature = GearUseFeatures.Factory.newInstance(); + gearUseFeatures = GearUseFeatures.Factory.newInstance(); + gearUseFeatures.setOperation(target); if (target.getGearUseFeatures() == null) { - target.setGearUseFeatures(Lists.newArrayList(gearUseFeature)); - gearUseFeature.setOperation(target); + target.setGearUseFeatures(Lists.newArrayList(gearUseFeatures)); } else { - target.getGearUseFeatures().add(gearUseFeature); - gearUseFeature.setOperation(target); + target.getGearUseFeatures().add(gearUseFeatures); } } else { - gearUseFeature = target.getGearUseFeatures().iterator().next(); + gearUseFeatures = target.getGearUseFeatures().iterator().next(); } // Retrieve entities : Vessel Use Features - VesselUseFeatures vesselUseFeature = null; + VesselUseFeatures vesselUseFeatures = null; if (target.getVesselUseFeatures() == null || target.getVesselUseFeatures().size() == 0) { - vesselUseFeature = VesselUseFeatures.Factory.newInstance(); + vesselUseFeatures = VesselUseFeatures.Factory.newInstance(); if (target.getVesselUseFeatures() == null) { - target.setVesselUseFeatures(Lists.newArrayList(vesselUseFeature)); - vesselUseFeature.setOperation(target); + target.setVesselUseFeatures(Lists.newArrayList(vesselUseFeatures)); + vesselUseFeatures.setOperation(target); } else { - target.getVesselUseFeatures().add(vesselUseFeature); - vesselUseFeature.setOperation(target); + target.getVesselUseFeatures().add(vesselUseFeatures); + vesselUseFeatures.setOperation(target); } } else { - vesselUseFeature = target.getVesselUseFeatures().iterator().next(); + vesselUseFeatures = target.getVesselUseFeatures().iterator().next(); } + + // Retrieve entities : Gear Physical Features + GearPhysicalFeatures gearPhysicalFeatures = target.getGearPhysicalFeatures(); + if (gearPhysicalFeatures == null && source.getGear() != null && source.getGear().getId() != null) { + gearPhysicalFeatures = measurementService.getGearPhysicalfeatures(fishingTrip, Integer.valueOf(source.getGear().getId())); + if (gearPhysicalFeatures == null) { + throw new DataIntegrityViolationException("An operation could not use a gear that is not declared in the cruise."); + } + target.setGearPhysicalFeatures(gearPhysicalFeatures); + if (gearPhysicalFeatures.getOperations() == null) { + gearPhysicalFeatures.setOperations(Lists.newArrayList((Operation)target)); + } else { + gearPhysicalFeatures.getOperations().add(target); + } + } + + // Retrieve tarwl net, from Gear physical features + int trawlNet = 1; // default value + GearPhysicalMeasurement gpmTrawlNet = measurementService.getGearPhysicalMeasurement(gearPhysicalFeatures, enumeration.PMFM_ID_TRAWL_NET); + if (gpmTrawlNet != null && gpmTrawlNet.getNumericalValue() != null) { + trawlNet = gpmTrawlNet.getNumericalValue().intValue(); + } StringBuffer nameBuffer = new StringBuffer(); // StationNumber if (copyIfNull && source.getStationNumber() == null) { - setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_STATION_NUMBER, null, "", null); + setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_STATION_NUMBER, null, "", null); } else if (source.getStationNumber() != null) { - setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_STATION_NUMBER, null, source.getStationNumber(), null); + setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_STATION_NUMBER, null, source.getStationNumber(), null); nameBuffer.append(source.getStationNumber()); } @@ -312,12 +348,21 @@ // Trawl net number if (copyIfNull && source.getTrawlNetNumber() == null) { - // TODO BL : where to store OP N° + // Remove from Gear Use Features + removeGearUseMeasurement(gearUseFeatures, enumeration.PMFM_ID_TRAWL_NET_NUMBER); + if (nameBuffer.length() > 0) { + nameBuffer.append(FISHING_OPERATION_NAME_SEPARATOR); + } } else if (source.getTrawlNetNumber() != null) { + if (source.getTrawlNetNumber().intValue() > trawlNet) { + throw new DataIntegrityViolationException("An operation could not have a 'trawl net number' greater than 'trawl net' defined in the cruise."); + } + // Store into Gear Use Features + setGearUseMeasurement(scientificCruise, gearUseFeatures, enumeration.PMFM_ID_TRAWL_NET_NUMBER, Float.valueOf(source.getTrawlNetNumber()), null, null); + // Store into the name attribute : if (nameBuffer.length() > 0) { nameBuffer.append(FISHING_OPERATION_NAME_SEPARATOR); } - // TODO BL : store in Gear Use Measurement ? nameBuffer.append(source.getTrawlNetNumber()); } @@ -349,19 +394,19 @@ // Trawl distance if (copyIfNull && source.getTrawlDistance() == null) { - removeVesselUseMeasurement(vesselUseFeature, enumeration.PMFM_ID_TRAWL_DISTANCE); + removeVesselUseMeasurement(vesselUseFeatures, enumeration.PMFM_ID_TRAWL_DISTANCE); } else if (source.getTrawlDistance() != null) { - setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_TRAWL_DISTANCE, source.getTrawlDistance(), null, null); + setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_TRAWL_DISTANCE, source.getTrawlDistance(), null, null); } // Rectilinear operation - setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_RECTILINEAR_OPERATION, null, null, source.isFishingOperationRectiligne()?enumeration.QUALITATIVE_RECTILINEAR_OPERATION_YES:enumeration.QUALITATIVE_RECTILINEAR_OPERATION_NO); + setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_RECTILINEAR_OPERATION, null, null, source.isFishingOperationRectiligne()?enumeration.QUALITATIVE_RECTILINEAR_OPERATION_YES:enumeration.QUALITATIVE_RECTILINEAR_OPERATION_NO); // Operation is valid ? if (copyIfNull && source.getFishingOperationValid() == null) { - removeVesselUseMeasurement(vesselUseFeature, enumeration.PMFM_ID_HAUL_VALID); + removeVesselUseMeasurement(vesselUseFeatures, enumeration.PMFM_ID_HAUL_VALID); } else if (source.getFishingOperationValid() != null) { - setVesselUseMeasurement(scientificCruise, vesselUseFeature, enumeration.PMFM_ID_HAUL_VALID, null, null, source.getFishingOperationValid().booleanValue()?enumeration.QUALITATIVE_HAUL_VALID_YES:enumeration.QUALITATIVE_HAUL_VALID_NO); + setVesselUseMeasurement(scientificCruise, vesselUseFeatures, enumeration.PMFM_ID_HAUL_VALID, null, null, source.getFishingOperationValid().booleanValue()?enumeration.QUALITATIVE_HAUL_VALID_YES:enumeration.QUALITATIVE_HAUL_VALID_NO); } // Comment @@ -372,7 +417,7 @@ } // Vessel - target.setVessel(fishingtrip.getVessel()); + target.setVessel(fishingTrip.getVessel()); // Quality Flag : if (target.getQualityFlag() == null) { @@ -390,52 +435,52 @@ } // VesselUseFeatures : - vesselUseFeature.setStartDate(target.getStartDateTime()); - if (vesselUseFeature.getStartDate() == null) { - vesselUseFeature.setStartDate(scientificCruise.getDepartureDateTime()); + vesselUseFeatures.setStartDate(target.getStartDateTime()); + if (vesselUseFeatures.getStartDate() == null) { + vesselUseFeatures.setStartDate(scientificCruise.getDepartureDateTime()); } - vesselUseFeature.setEndDate(target.getEndDateTime()); - vesselUseFeature.setVessel(target.getVessel()); - vesselUseFeature.setProgram(scientificCruise.getProgram()); - vesselUseFeature.setIsActive(isActive.ACTIVE.getValue()); - if (vesselUseFeature.getCreationDate() == null) { + vesselUseFeatures.setEndDate(target.getEndDateTime()); + vesselUseFeatures.setVessel(target.getVessel()); + vesselUseFeatures.setProgram(scientificCruise.getProgram()); + vesselUseFeatures.setIsActive(isActive.ACTIVE.getValue()); + if (vesselUseFeatures.getCreationDate() == null) { calendar.setTime(new Date()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); - vesselUseFeature.setCreationDate(calendar.getTime()); + vesselUseFeatures.setCreationDate(calendar.getTime()); } - if (vesselUseFeature.getQualityFlag() == null) { - vesselUseFeature.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); + if (vesselUseFeatures.getQualityFlag() == null) { + vesselUseFeatures.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); } // GearUseFeatures : - gearUseFeature.setStartDate(target.getStartDateTime()); - if (gearUseFeature.getStartDate() == null) { - gearUseFeature.setStartDate(scientificCruise.getDepartureDateTime()); + gearUseFeatures.setStartDate(target.getStartDateTime()); + if (gearUseFeatures.getStartDate() == null) { + gearUseFeatures.setStartDate(scientificCruise.getDepartureDateTime()); } - gearUseFeature.setEndDate(target.getEndDateTime()); - gearUseFeature.setVessel(target.getVessel()); - gearUseFeature.setProgram(scientificCruise.getProgram()); - if (gearUseFeature.getCreationDate() == null) { + gearUseFeatures.setEndDate(target.getEndDateTime()); + gearUseFeatures.setVessel(target.getVessel()); + gearUseFeatures.setProgram(scientificCruise.getProgram()); + if (gearUseFeatures.getCreationDate() == null) { calendar.setTime(new Date()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); - gearUseFeature.setCreationDate(calendar.getTime()); + gearUseFeatures.setCreationDate(calendar.getTime()); } - if (gearUseFeature.getQualityFlag() == null) { - gearUseFeature.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); + if (gearUseFeatures.getQualityFlag() == null) { + gearUseFeatures.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); } // GearUseFeatures.Gear if (copyIfNull && source.getGear() == null) { - gearUseFeature.setGear(null); + gearUseFeatures.setGear(null); } else if (source.getGear() != null && source.getGear().getId() != null) { Gear gear = gearDao.load(Integer.valueOf(source.getGear().getId())); - gearUseFeature.setGear(gear); + gearUseFeatures.setGear(gear); } // Start position : @@ -581,11 +626,7 @@ return DEFAULT_EMPTY_LONGITUDE.equals(databaseValue)?null:databaseValue; } - protected Integer getPmfmId() { - // TODO BLA - return null; - } - + protected VesselUseMeasurement getVesselUseMeasurement(ScientificCruise scientificCruise, VesselUseFeatures vesselUseFeatures, Integer pmfmId, boolean createIfNotExists) { VesselUseMeasurement vesselUseMeasurement = null; @@ -647,4 +688,67 @@ return vesselUseMeasurement; } + + protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, + Integer pmfmId, + Float numericalValue, + String alphanumericalValue, + Integer qualitativevalueId) { + GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(scientificCruise, gearUseFeatures, pmfmId, true); + + if (alphanumericalValue != null) { + gearUseMeasurement.setAlphanumericalValue(alphanumericalValue); + } + else if (numericalValue != null) { + gearUseMeasurement.setNumericalValue(numericalValue); + } + else if (qualitativevalueId != null) { + gearUseMeasurement.setQualitativeValue(qualitativeValueDao.load(qualitativevalueId)); + } + + return gearUseMeasurement; + } + + protected GearUseMeasurement getGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, + Integer pmfmId, boolean createIfNotExists) { + GearUseMeasurement gearUseMeasurement = null; + if (gearUseFeatures.getGearUseMeasurements() != null) { + for (Iterator iterator = gearUseFeatures.getGearUseMeasurements().iterator(); iterator.hasNext();) { + GearUseMeasurement vum = (GearUseMeasurement) iterator.next(); + if (pmfmId.equals(vum.getPmfm().getId())) { + gearUseMeasurement = vum; + break; + } + } + } + if (gearUseMeasurement == null) { + if (!createIfNotExists) { + return null; + } + gearUseMeasurement = GearUseMeasurement.Factory.newInstance(); + gearUseMeasurement.setGearUseFeatures(gearUseFeatures); + if (gearUseFeatures.getGearUseMeasurements() == null) { + gearUseFeatures.setGearUseMeasurements(Lists.newArrayList(gearUseMeasurement)); + } + else { + gearUseFeatures.getGearUseMeasurements().add(gearUseMeasurement); + } + gearUseMeasurement.setQualityFlag(qualityFlagDao.load(enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); + gearUseMeasurement.setDepartment(scientificCruise.getRecorderDepartment()); + gearUseMeasurement.setPmfm(pmfmDao.load(pmfmId)); + } + + return gearUseMeasurement; + } + + protected void removeGearUseMeasurement(GearUseFeatures gearUseFeatures, + Integer pmfmId) { + GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(null, gearUseFeatures, pmfmId, false); + if (gearUseMeasurement == null) { + return; + } + gearUseFeatures.getGearUseMeasurements().remove(gearUseMeasurement); + // TOBO BLa : vérifier qu'il ne faut pas dao.delete() en plus + } + } Added: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementService.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementService.java (rev 0) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementService.java 2013-01-21 15:08:12 UTC (rev 238) @@ -0,0 +1,13 @@ +package fr.ifremer.tutti.persistence.service; + +import fr.ifremer.adagio.core.dao.data.measure.GearPhysicalMeasurement; +import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip; +import fr.ifremer.adagio.core.dao.data.vessel.feature.physical.GearPhysicalFeatures; + +public interface MeasurementService { + + GearPhysicalFeatures getGearPhysicalfeatures(FishingTrip fishingTrip, Integer gearId); + + GearPhysicalMeasurement getGearPhysicalMeasurement(GearPhysicalFeatures gearPhysicalFeatures, Integer pmfmId); + +} Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-01-21 10:58:40 UTC (rev 237) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-01-21 15:08:12 UTC (rev 238) @@ -157,6 +157,12 @@ @Value("${QualitativeValueId.HAUL_VALID_NO}") public final Integer QUALITATIVE_HAUL_VALID_NO = null; + + @Value("${PmfmId.TRAWL_NET}") + public final Integer PMFM_ID_TRAWL_NET = null; + + @Value("${PmfmId.TRAWL_NET_NUMBER}") + public final Integer PMFM_ID_TRAWL_NET_NUMBER = null; public void init() { Modified: trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml =================================================================== --- trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-21 10:58:40 UTC (rev 237) +++ trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-21 15:08:12 UTC (rev 238) @@ -174,7 +174,8 @@ (select vp_end from VesselPositionImpl vp_end where vp_end.operation.id = o.id and vp_end.dateTime = o.endDateTime) as endVesselPosition, (select vum.numericalValue from VesselUseMeasurementImpl vum where vum.vesselUseFeatures.id=vuf.id and vum.pmfm.id=:pmfmIdTrawlDistance) as trawlDistance, (select vum2.qualitativeValue.id from VesselUseMeasurementImpl vum2 where vum2.vesselUseFeatures.id=vuf.id and vum2.pmfm.id=:pmfmIdRectilinearOperation) as rectilinearQualitativeId, - (select vum3.qualitativeValue.id from VesselUseMeasurementImpl vum3 where vum3.vesselUseFeatures.id=vuf.id and vum3.pmfm.id=:pmfmIdHaulValid) as haulValidQualitativeId + (select vum3.qualitativeValue.id from VesselUseMeasurementImpl vum3 where vum3.vesselUseFeatures.id=vuf.id and vum3.pmfm.id=:pmfmIdHaulValid) as haulValidQualitativeId, + (select gum.numericalValue from GearUseMeasurementImpl gum where gum.gearUseFeatures.id=guf.id and gum.pmfm.id=:pmfmTrawlNetNumber) as trawlNetNumber FROM FishingOperationImpl o INNER JOIN o.gearUseFeatures guf @@ -186,6 +187,7 @@ <query-param name="pmfmIdTrawlDistance" type="java.lang.Integer"/> <query-param name="pmfmIdRectilinearOperation" type="java.lang.Integer"/> <query-param name="pmfmIdHaulValid" type="java.lang.Integer"/> + <query-param name="pmfmTrawlNetNumber" type="java.lang.Integer"/> </query> Modified: trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties =================================================================== --- trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties 2013-01-21 10:58:40 UTC (rev 237) +++ trunk/tutti-persistence-adagio/src/main/resources/tutti-db-enumerations.properties 2013-01-21 15:08:12 UTC (rev 238) @@ -340,6 +340,15 @@ # TODO A creer (dans les enumerations Allegro) QualitativeValueId.RECTILINEAR_OPERATION_NO=278 +# TODO A creer (dans les enumerations Allegro) +# PSFM "Nombre de poche" d'un chalut (écran campagne) +PmfmId.TRAWL_NET=953 + +# TODO A creer (dans les enumerations Allegro) +# PSFM "Numero de la poche" (écran opération) +## ATTENTION : à modifier quand Vincent aura créé le PSFM +PmfmId.TRAWL_NET_NUMBER=953 + #TODO A creer (dans les enumerations Allegro) # (20=observateur volant, 95=Administrateur SIH) -> L'avantage du 20 est qu'il est inactif (=20), donc plus facilement detectable PersonId.UNKNOWN_RECORDER_PERSON=20 Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java 2013-01-21 10:58:40 UTC (rev 237) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceTest.java 2013-01-21 15:08:12 UTC (rev 238) @@ -93,6 +93,9 @@ String programCode = dbResource.getFixtures().programCode(); Cruise cruise = new Cruise(); + // ----------------------------------------------------------------------------- + // 1. Test with all properties filled + // ----------------------------------------------------------------------------- cruise.setId(null); cruise.setName("Unit-test-" + System.currentTimeMillis()); @@ -133,7 +136,10 @@ vessels.add(fishingVessel); cruise.setVessel(vessels); + + cruise.setTrawlNet(new Integer(2)); + // Create cruise in database Cruise createdCruise = service.createCruise(cruise); assertNotNull(createdCruise); assertNotNull(createdCruise.getId()); @@ -143,9 +149,8 @@ log.info("Created cruise: " + createdCruise.getId()); } - // Reload cruise : + // Then reload cruise and compare Cruise reloadedCruise = service.getCruise(createdCruise.getId()); - calendar.setTime(createdCruise.getBeginDate()); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); @@ -154,19 +159,25 @@ calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); assertEquals(calendar.getTime(), reloadedCruise.getEndDate()); + assertEquals(cruise.getTrawlNet(), reloadedCruise.getTrawlNet()); - // New cruise, with empty optional values + // ----------------------------------------------------------------------------- + // 2. Test with only mandatory properties + // ----------------------------------------------------------------------------- createdCruise.setId(null); createdCruise.setHeadOfMission(null); createdCruise.setBeginDate(null); createdCruise.setEndDate(null); createdCruise.setComment(null); createdCruise.setTrawlNet(null); + + // Save cruise createdCruise = service.createCruise(cruise); assertNotNull(createdCruise); assertNotNull(createdCruise.getId()); assertEquals(cruise.getName(), createdCruise.getName()); + // Reload to compare reloadedCruise = service.getCruise(createdCruise.getId()); assertEquals(createdCruise.getBeginDate(), reloadedCruise.getBeginDate()); Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java 2013-01-21 10:58:40 UTC (rev 237) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceTest.java 2013-01-21 15:08:12 UTC (rev 238) @@ -27,6 +27,7 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.Iterator; import java.util.List; import fr.ifremer.tutti.persistence.DatabaseResource; @@ -38,6 +39,10 @@ import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Test; +import org.springframework.dao.DataIntegrityViolationException; + +import com.google.common.collect.Lists; + import static org.junit.Assert.*; /** @@ -94,8 +99,18 @@ cruise.setName("Unit-test-" + System.currentTimeMillis()); cruise.setBeginDate(new Date()); cruise.setEndDate(null); + cruise.setTrawlNet(new Integer(2)); + // Keep only one gear in the cruise : (need for case n°4) + List<Gear> cruiseGears = cruise.getGear(); + assertNotNull(cruiseGears); + assertTrue(cruiseGears.size() > 0); + Gear cruiseGear = cruiseGears.get(0); + assertNotNull(cruiseGear.getId()); + cruise.setGear(Lists.newArrayList(cruiseGear)); + cruise = cruiseService.createCruise(cruise); assertNotNull(cruise.getId()); + // Create new fishing operation : FishingOperation fishingOperation = new FishingOperation(); @@ -120,7 +135,7 @@ assertNotNull("Fishing operation ID must not be null after creation in database", createdFishingOperation); assertNotNull(createdFishingOperation.getId()); - // Trying to relaod this fishing operation + // Trying to reload this fishing operation reloadedFishingOperation = service.getFishingOperation(createdFishingOperation.getId()); assertNotNull(reloadedFishingOperation); assertNull(reloadedFishingOperation.getGearShootingStartDate()); @@ -133,7 +148,7 @@ fishingOperation.setId(null); fishingOperation.setStationNumber("STA2"); fishingOperation.setFishingOperationNumber(new Integer(2)); - fishingOperation.setTrawlNetNumber(new Integer(2)); + fishingOperation.setTrawlNetNumber(new Integer(1)); calendar.setTime(new Date()); calendar.set(Calendar.HOUR_OF_DAY, 1); calendar.set(Calendar.MILLISECOND, 99); @@ -154,10 +169,7 @@ fishingOperation.setComment("Unit test createFishingOperation() - Part n°2 : All properties set"); - List<Gear> gears = referentialService.getAllFishingGear(); - assertNotNull(gears); - assertTrue(gears.size() > 0); - fishingOperation.setGear(gears.get(0)); + fishingOperation.setGear(cruiseGear); // Store fishing operation into database : createdFishingOperation = service.createFishingOperation(fishingOperation); @@ -197,7 +209,7 @@ fishingOperation.setId(null); fishingOperation.setStationNumber("STA3"); fishingOperation.setFishingOperationNumber(new Integer(3)); - fishingOperation.setTrawlNetNumber(new Integer(3)); + fishingOperation.setTrawlNetNumber(new Integer(2)); fishingOperation.setGearShootingStartLongitude(null); fishingOperation.setGearShootingEndDate(null); fishingOperation.setTrawlDistance(null); @@ -217,10 +229,39 @@ // ----------------------------------------------------------------------------- // 4. Test : - // - + // - try to save a operation using a gear not declared uin the cruise + // - try to save a operation using a trawl net number bigger than the cruise trawl net // ----------------------------------------------------------------------------- fishingOperation.setId(null); - //createdFishingOperation = service.createFishingOperation(fishingOperation); + + // Find and set a gear not used in the cruise + List<Gear> gears = referentialService.getAllFishingGear(); + assertNotNull(gears); + assertTrue(gears.size() > 0); + for (Iterator iterator = gears.iterator(); iterator.hasNext();) { + Gear gear = (Gear) iterator.next(); + if (cruiseGear.getId().equals(gear.getId()) == false) { + fishingOperation.setGear(gear); + break; + } + } + + try { + createdFishingOperation = service.createFishingOperation(fishingOperation); + fail("A fishing operation must not be saved if the gear is not declared in the cruise."); + } + catch(DataIntegrityViolationException dive) { + assertNotNull(dive); + } + + fishingOperation.setTrawlNetNumber(new Integer(3)); + try { + createdFishingOperation = service.createFishingOperation(fishingOperation); + fail("A fishing operation must not be saved if the 'trawl net number' > 'cruise trawl net'."); + } + catch(DataIntegrityViolationException dive) { + assertNotNull(dive); + } //reloadedFishingOperation = service.getFishingOperation(createdFishingOperation.getId()); //assertEquals(fishingOperation.getGearShootingStartLatitude(), reloadedFishingOperation.getGearShootingStartLatitude()); //assertEquals(fishingOperation.getGearShootingStartLongitude(), reloadedFishingOperation.getGearShootingStartLongitude());
participants (1)
-
blavenier@users.forge.codelutin.com