Author: tchemit Date: 2013-05-06 21:47:06 +0200 (Mon, 06 May 2013) New Revision: 922 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/922 Log: fixes #2394: [TRAIT] - Mauvaise info sauvegard?\195?\169e dans le champ OPERATION.NAME Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-05-06 19:33:55 UTC (rev 921) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-05-06 19:47:06 UTC (rev 922) @@ -74,6 +74,7 @@ import fr.ifremer.tutti.persistence.entities.referential.Vessel; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.FlushMode; @@ -179,18 +180,8 @@ // Fishing operation number : trying to retrieve from name String name = (String) source[colIndex++]; - String gearLabel = (String) source[colIndex++]; - String fishingOperationNumberStr; - if (name != null && !name.isEmpty()) { - if (gearLabel != null && !gearLabel.isEmpty() - && name.startsWith(gearLabel)) { - fishingOperationNumberStr = name.substring(gearLabel.length()); - } else { - fishingOperationNumberStr = name; - } - if (fishingOperationNumberStr.matches("\\d+")) { - fishingOperation.setFishingOperationNumber(Integer.valueOf(fishingOperationNumberStr)); - } + if (StringUtils.isNotBlank(name)) { + fishingOperation.setFishingOperationNumber(Integer.valueOf(name)); } // If not found, compute it using a counter (see "order by startDateTime" in HQL query) @@ -246,21 +237,10 @@ int colIndex = 0; - // Name = <GearLabel><FishingOperationNumber> + // Name String name = (String) source[colIndex++]; - String gearLabel = (String) source[colIndex++]; - - String fishingOperationNumberStr; - if (name != null && !name.isEmpty()) { - if (gearLabel != null && !gearLabel.isEmpty() - && name.startsWith(gearLabel)) { - fishingOperationNumberStr = name.substring(gearLabel.length()); - } else { - fishingOperationNumberStr = name; - } - if (fishingOperationNumberStr.matches("\\d+")) { - result.setFishingOperationNumber(Integer.valueOf(fishingOperationNumberStr)); - } + if (StringUtils.isNotBlank(name)) { + result.setFishingOperationNumber(Integer.valueOf(name)); } // If not found, compute it using a counter (see "order by startDateTime" in HQL query) @@ -503,9 +483,10 @@ } // remove operation vessel associations - if (CollectionUtils.isNotEmpty(fishingOperation.getOperationVesselAssociations())) { - fishingOperation.getOperationVesselAssociations().clear(); - } + removeAllOperationVesselAssociation(fishingOperation); +// if (CollectionUtils.isNotEmpty(fishingOperation.getOperationVesselAssociations())) { +// fishingOperation.getOperationVesselAssociations().clear(); +// } // remove fishing areas if (CollectionUtils.isNotEmpty(fishingAreas)) { @@ -568,7 +549,7 @@ Integer pmfmId = (Integer) source[colIndex++]; Float numericalValue = (Float) source[colIndex++]; String alphanumericalValue = (String) source[colIndex++]; - Integer qualitativeValueId = (Integer) source[colIndex++]; + Integer qualitativeValueId = (Integer) source[colIndex]; // Trawl distance if (enumeration.PMFM_ID_TRAWL_DISTANCE.equals(pmfmId)) { @@ -634,7 +615,7 @@ Integer pmfmId = (Integer) source[colIndex++]; Float numericalValue = (Float) source[colIndex++]; String alphanumericalValue = (String) source[colIndex++]; - Integer qualitativeValueId = (Integer) source[colIndex++]; + Integer qualitativeValueId = (Integer) source[colIndex]; // Trawl net number if (enumeration.PMFM_ID_MULTIRIG_AGGREGATION.equals(pmfmId) @@ -670,7 +651,6 @@ protected void beanToEntity(FishingOperation source, fr.ifremer.adagio.core.dao.data.operation.FishingOperation target) { - StringBuilder nameBuffer = new StringBuilder(); // Retrieve entities : FishingTrip and ScientificCruise ScientificCruise scientificCruise; @@ -753,9 +733,6 @@ gearPhysicalFeatures.getOperations().add(target); } } - if (source.getGear() != null && source.getGear().getLabel() != null) { - nameBuffer.append(source.getGear().getLabel()); - } // Retrieve entities : Fishing Area FishingArea fishingArea; @@ -795,9 +772,8 @@ // OP N° if (source.getFishingOperationNumber() != null) { - nameBuffer.append(source.getFishingOperationNumber()); + target.setName(source.getFishingOperationNumber().toString()); } - target.setName(nameBuffer.toString()); // Multirig Aggregation if (source.getMultirigAggregation() != null) { @@ -806,9 +782,6 @@ if (mutlirigNumber > cruiseMultirigCount) { throw new DataIntegrityViolationException("An operation could not have a 'multirig number' greater than 'multirig count' defined in the cruise."); } - } else { - // TODO BLA : Then parse the String when more than one number (ie "1,3") - // and validate content } // Store into Gear Use Features @@ -1228,7 +1201,7 @@ } else if (value instanceof Float) { vesselUseMeasurement.setNumericalValue((Float) value); } else if (value instanceof Integer) { - vesselUseMeasurement.setQualitativeValue(load(QualitativeValueImpl.class, (Integer) value)); + vesselUseMeasurement.setQualitativeValue(load(QualitativeValueImpl.class, value)); } return vesselUseMeasurement; @@ -1241,26 +1214,6 @@ return vesselUseMeasurement; } -// protected void setMeasurement(Measurement measurement, Caracteristic caracteristic, Serializable value) { -// if (value == null) { -// return; -// } -// if (caracteristic.getCaracteristicType() == CaracteristicType.TEXT) { -// measurement.setAlphanumericalValue((String) value); -// } else if (caracteristic.getCaracteristicType() == CaracteristicType.NUMBER) { -// measurement.setNumericalValue((Float) value); -// } else if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) { -// Integer qvId = null; -// if (value instanceof CaracteristicQualitativeValue) { -// qvId = Integer.valueOf(((CaracteristicQualitativeValue) value).getId()); -// } else if (value instanceof Integer) { -// qvId = (Integer) value; -// } -// QualitativeValue qv = load(QualitativeValueImpl.class, qvId); -// measurement.setQualitativeValue(qv); -// } -// } - protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, Integer pmfmId, Float numericalValue, Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml =================================================================== --- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-05-06 19:33:55 UTC (rev 921) +++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-05-06 19:47:06 UTC (rev 922) @@ -213,7 +213,6 @@ SELECT o.id AS id, o.name AS name, - g.label AS gearLabel, o.startDateTime AS startDateTime, (select vum.alphanumericalValue from VesselUseMeasurementImpl vum where vum.vesselUseFeatures.id = vuf.id and vum.pmfm.id=:pmfmIdStationNumber) AS stationNumber, (select gum.alphanumericalValue from GearUseMeasurementImpl gum where gum.gearUseFeatures.id = guf.id and gum.pmfm.id=:pmfmIdMultirigAggregation) AS multirigAggregation @@ -236,7 +235,6 @@ <![CDATA[ SELECT o.name AS name, - max(g.label) AS gearLabel, max(o.startDateTime) AS startDateTime, max(o.endDateTime) AS endDateTime, max(o.comments) AS comments,