Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
July 2013
- 4 participants
- 57 discussions
r1162 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence tutti-service/src/main/java/fr/ifremer/tutti/service tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost
by tchemit@users.forge.codelutin.com 31 Jul '13
by tchemit@users.forge.codelutin.com 31 Jul '13
31 Jul '13
Author: tchemit
Date: 2013-07-31 20:19:34 +0200 (Wed, 31 Jul 2013)
New Revision: 1162
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1162
Log:
fixes #3004: [IMPORT-EXPORT MULTIPOSTE] Probl?\195?\168me de transaction lors d'une erreur
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportService.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportServiceTest.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-30 17:22:49 UTC (rev 1161)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-31 18:19:34 UTC (rev 1162)
@@ -53,6 +53,7 @@
import java.io.File;
import java.util.List;
+import java.util.concurrent.Callable;
/**
* Contract for a persistence driver used by Tutti.
@@ -78,6 +79,20 @@
TuttiEnumerationFile getEnumerationFile();
+ /**
+ * To invoke the given call code.
+ * <p/>
+ * <strong>Note:</strong> this is mainly to execute a code in a single
+ * transaction.
+ *
+ * @param call call to invoke
+ * @param <V> return type
+ * @return the return of the call
+ * @since 2.5
+ */
+ @Transactional(readOnly = false)
+ <V> V invoke(Callable<V> call);
+
//------------------------------------------------------------------------//
//-- Referential methods --//
//------------------------------------------------------------------------//
@@ -221,7 +236,6 @@
List<Caracteristic> getAllCaracteristicWithProtected();
/**
- *
* @return all caracteristics of the system useable for {@link SampleCategoryModel}.
* @since 2.5
*/
@@ -360,7 +374,6 @@
@Transactional(readOnly = false)
Attachment createAttachment(Attachment attachment, File file);
-
/**
* Saves the given attachment.
*
@@ -370,7 +383,6 @@
@Transactional(readOnly = false)
Attachment saveAttachment(Attachment attachment);
-
/**
* Deletes the given attachment given his id.
*
@@ -474,7 +486,7 @@
/**
* @param operationId id of the fishing operation
* @return {@code true} if there is a catchBatch for the given fishing
- * operation, {@code false} otherwise.
+ * operation, {@code false} otherwise.
* @since 2.2
*/
boolean isFishingOperationWithCatchBatch(String operationId);
@@ -520,7 +532,7 @@
* <p/>
* <strong>Note:</strong> All childs of the batch should be loaded here.
*
- * @param fishingOperationId if of the fishing operation to seek
+ * @param fishingOperationId if of the fishing operation to seek
* @param sampleCategoryModel [optional] sample category model to check
* @return the list of root {@link SpeciesBatch}
* @throws InvalidBatchModelException if batch does not respect the sample category model
@@ -578,7 +590,7 @@
* <p/>
* <strong>Note:</strong> All childs of the batch should be loaded here.
*
- * @param fishingOperationId if of the fishing operation to seek
+ * @param fishingOperationId if of the fishing operation to seek
* @param sampleCategoryModel [optional] sample category model to check
* @return the list of root {@link BenthosBatch}
* @throws InvalidBatchModelException if batch does not respect the sample category model
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-30 17:22:49 UTC (rev 1161)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-31 18:19:34 UTC (rev 1162)
@@ -27,6 +27,7 @@
import com.google.common.base.Predicate;
import com.google.common.collect.Maps;
import fr.ifremer.adagio.core.service.technical.CacheService;
+import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
@@ -76,6 +77,7 @@
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Callable;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -146,6 +148,21 @@
}
@Override
+ public <V> V invoke(Callable<V> call) {
+
+ try {
+ V result = call.call();
+ return result;
+ } catch (TuttiTechnicalException e) {
+ throw e;
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(e);
+ }
+ }
+
+ @Override
public void init() {
if (log.isInfoEnabled()) {
log.info("Open persistence driver " + getImplementationName());
@@ -495,7 +512,6 @@
attachmentService.deleteAttachment(attachmentId);
}
-
//------------------------------------------------------------------------//
//-- Program methods --//
//------------------------------------------------------------------------//
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-30 17:22:49 UTC (rev 1161)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-31 18:19:34 UTC (rev 1162)
@@ -53,6 +53,7 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.util.concurrent.Callable;
/**
* Mock implementation With no persistence at all behind.
@@ -73,6 +74,11 @@
}
@Override
+ public <V> V invoke(Callable<V> call) {
+ throw notImplemented();
+ }
+
+ @Override
public boolean isVracSpeciesBatch(SpeciesBatch speciesBatch) {
throw notImplemented();
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-30 17:22:49 UTC (rev 1161)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-31 18:19:34 UTC (rev 1162)
@@ -70,6 +70,7 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
+import java.util.concurrent.Callable;
import static org.nuiton.i18n.I18n._;
@@ -112,6 +113,11 @@
return driver.getEnumerationFile();
}
+ @Override
+ public <V> V invoke(Callable<V> call) {
+ return driver.invoke(call);
+ }
+
public static final DateFormat EXPORT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
public static final String EXPORT_DIRECTORY_FORMAT = "tutti-%s-%s";
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportService.java 2013-07-30 17:22:49 UTC (rev 1161)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportService.java 2013-07-31 18:19:34 UTC (rev 1162)
@@ -58,7 +58,6 @@
import java.io.Writer;
import java.util.List;
import java.util.Map;
-import java.util.UUID;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
@@ -128,7 +127,6 @@
}
}
}
-
}
/**
@@ -526,7 +524,7 @@
List<AttachmentRow> attachmentRows) {
CatchRow row = new CatchRow();
- String id = context.generateId(CatchRow.class);;
+ String id = context.generateId(CatchRow.class);
row.setId(id);
row.setParentId(parentId);
row.setSpecies(batch.getSpecies());
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportService.java 2013-07-30 17:22:49 UTC (rev 1161)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportService.java 2013-07-31 18:19:34 UTC (rev 1162)
@@ -70,12 +70,14 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Callable;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
/**
- * Service to export batches from a satellite post or import batches into a master post.
+ * Service to export batches from a satellite post or import batches
+ * into a master post.
*
* @author kmorin <kmorin(a)codelutin.com>
* @since 2.2
@@ -151,69 +153,75 @@
* @param operation the operation in which to add the batches
* @return the list of the species which have not been imported, because there were concurrent batches
*/
- public Map<String, Object> importSpecies(File file, FishingOperation operation) {
+ public Map<String, Object> importSpecies(final File file,
+ final FishingOperation operation) {
- File tempDir = TuttiIOUtil.explodeZip(
- context.getConfig().getTmpDirectory(),
- file,
- n_("tutti.service.multipost.uncompress.error"));
+ Callable<Map<String, Object>> call = new Callable<Map<String, Object>>() {
- //check operation
- CatchWeightsRowModel weightsModel = new CatchWeightsRowModel(csvSeparator);
- checkSameOperation(tempDir, weightsModel, operation);
+ @Override
+ public Map<String, Object> call() throws Exception {
- Map<String, Object> notImportedData = Maps.newHashMap();
- final Map<String, SpeciesBatch> notImportedBatches = Maps.newLinkedHashMap();
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
- BatchContainer<SpeciesBatch> speciesBatches =
- persistenceService.getRootSpeciesBatch(operation.getId(), null);
+ //check operation
+ CatchWeightsRowModel weightsModel = new CatchWeightsRowModel(csvSeparator);
+ checkSameOperation(tempDir, weightsModel, operation);
- TuttiDataContext dataContext = context.getDataContext();
- List<Species> speciesList = dataContext.getReferentSpecies();
+ final Map<String, Object> notImportedData = Maps.newHashMap();
- // Import batches
- // map containing the batches by their persistence id
+ final Map<String, SpeciesBatch> notImportedBatches = Maps.newLinkedHashMap();
- final Map<String, SpeciesBatch> batches = importSpeciesBatches(
- tempDir,
- operation,
- speciesBatches,
- notImportedBatches,
- speciesList);
+ BatchContainer<SpeciesBatch> speciesBatches =
+ persistenceService.getRootSpeciesBatch(operation.getId(), null);
- List<Caracteristic> caracteristics = dataContext.getCaracteristics();
+ TuttiDataContext dataContext = context.getDataContext();
+ List<Species> speciesList = dataContext.getReferentSpecies();
- // Import frequencies
+ // Import batches
+ // map containing the batches by their persistence id
- ListMultimap<String, SpeciesBatchFrequency> frequencyMap = importSpeciesFrequencies(
- file,
- batches,
- notImportedBatches,
- caracteristics);
+ final Map<String, SpeciesBatch> batches = importSpeciesBatches(
+ tempDir,
+ operation,
+ speciesBatches,
+ notImportedBatches,
+ speciesList);
- // Persist frequencies
+ List<Caracteristic> caracteristics = dataContext.getCaracteristics();
- for (String batchId : frequencyMap.keySet()) {
- List<SpeciesBatchFrequency> frequencies = frequencyMap.get(batchId);
- persistenceService.saveSpeciesBatchFrequency(batchId, frequencies);
- }
+ // Import frequencies
- // Import attachments
+ importSpeciesFrequencies(
+ tempDir,
+ batches,
+ notImportedBatches,
+ caracteristics);
- importAttachments(tempDir,
- batches,
- notImportedBatches,
- AttachementObjectTypeEnum.BATCH);
+ // Import attachments
- // Import weights
+ importAttachments(tempDir,
+ batches,
+ notImportedBatches,
+ AttachementObjectTypeEnum.BATCH);
- importSpeciesWeights(tempDir,
- operation,
- weightsModel,
- notImportedData);
+ // Import weights
- notImportedData.put(BATCHES_KEY, notImportedBatches.values());
- return notImportedData;
+ importSpeciesWeights(tempDir,
+ operation,
+ weightsModel,
+ notImportedData);
+
+ notImportedData.put(BATCHES_KEY, notImportedBatches.values());
+
+ return notImportedData;
+ }
+ };
+
+ Map<String, Object> result = persistenceService.invoke(call);
+ return result;
}
protected Map<String, SpeciesBatch> importSpeciesBatches(File file,
@@ -304,7 +312,7 @@
return batches;
}
- protected ListMultimap<String, SpeciesBatchFrequency> importSpeciesFrequencies(
+ protected void importSpeciesFrequencies(
File file,
Map<String, SpeciesBatch> batches,
Map<String, SpeciesBatch> notImportedBatches,
@@ -323,7 +331,6 @@
Import<CatchFrequencyRow> importer = Import.newImport(frequencyModel, reader);
-
try {
for (CatchFrequencyRow frequencyRow : importer) {
if (notImportedBatches.get(frequencyRow.getBatchId()) == null) {
@@ -347,7 +354,11 @@
} finally {
IOUtils.closeQuietly(reader);
}
- return frequencyMap;
+
+ for (String batchId : frequencyMap.keySet()) {
+ List<SpeciesBatchFrequency> frequencies = frequencyMap.get(batchId);
+ persistenceService.saveSpeciesBatchFrequency(batchId, frequencies);
+ }
}
protected void importSpeciesWeights(File file,
@@ -412,60 +423,70 @@
* @param operation the operation in which to add the batches
* @return the list of the benthos which have not been imported, because there were concurrent batches
*/
- public Map<String, Object> importBenthos(File file, FishingOperation operation) {
+ public Map<String, Object> importBenthos(final File file,
+ final FishingOperation operation) {
- File tempDir = TuttiIOUtil.explodeZip(
- context.getConfig().getTmpDirectory(),
- file,
- n_("tutti.service.multipost.uncompress.error"));
+ Callable<Map<String, Object>> call = new Callable<Map<String, Object>>() {
- //check operation
- CatchWeightsRowModel weightsModel = new CatchWeightsRowModel(csvSeparator);
- checkSameOperation(tempDir, weightsModel, operation);
+ @Override
+ public Map<String, Object> call() throws Exception {
- Map<String, Object> notImportedData = Maps.newHashMap();
- final Map<String, BenthosBatch> notImportedBatches = Maps.newLinkedHashMap();
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
- BatchContainer<BenthosBatch> benthosBatches =
- persistenceService.getRootBenthosBatch(operation.getId(), null);
+ //check operation
+ CatchWeightsRowModel weightsModel = new CatchWeightsRowModel(csvSeparator);
+ checkSameOperation(tempDir, weightsModel, operation);
- TuttiDataContext dataContext = context.getDataContext();
- List<Species> speciesList = dataContext.getReferentSpecies();
+ Map<String, Object> notImportedData = Maps.newHashMap();
+ final Map<String, BenthosBatch> notImportedBatches = Maps.newLinkedHashMap();
- // Import batches
- // map containing the batches by their persistence id
- final Map<String, BenthosBatch> batches = importBenthosBatches(
- tempDir,
- operation,
- benthosBatches,
- notImportedBatches,
- speciesList);
+ BatchContainer<BenthosBatch> benthosBatches =
+ persistenceService.getRootBenthosBatch(operation.getId(), null);
- // Import frequencies
+ TuttiDataContext dataContext = context.getDataContext();
+ List<Species> speciesList = dataContext.getReferentSpecies();
- ListMultimap<String, BenthosBatchFrequency> frequencyMap = importBenthosFrequencies(
- tempDir,
- batches,
- notImportedBatches,
- dataContext.getCaracteristics());
+ // Import batches
+ // map containing the batches by their persistence id
+ final Map<String, BenthosBatch> batches = importBenthosBatches(
+ tempDir,
+ operation,
+ benthosBatches,
+ notImportedBatches,
+ speciesList);
- // Persist frequencies
+ // Import frequencies
- for (String batchId : frequencyMap.keySet()) {
- List<BenthosBatchFrequency> frequencies = frequencyMap.get(batchId);
- persistenceService.saveBenthosBatchFrequency(batchId, frequencies);
- }
+ importBenthosFrequencies(
+ tempDir,
+ batches,
+ notImportedBatches,
+ dataContext.getCaracteristics());
- // Import attachments
+ // Import attachments
- importAttachments(tempDir, batches, notImportedBatches, AttachementObjectTypeEnum.BATCH);
+ importAttachments(tempDir,
+ batches,
+ notImportedBatches,
+ AttachementObjectTypeEnum.BATCH);
- // Import weights
+ // Import weights
- importBenthosWeights(tempDir, operation, weightsModel, notImportedData);
+ importBenthosWeights(tempDir,
+ operation,
+ weightsModel,
+ notImportedData);
- notImportedData.put(BATCHES_KEY, notImportedBatches.values());
- return notImportedData;
+ notImportedData.put(BATCHES_KEY, notImportedBatches.values());
+ return notImportedData;
+ }
+ };
+
+ Map<String, Object> result = persistenceService.invoke(call);
+ return result;
}
protected Map<String, BenthosBatch> importBenthosBatches(File file,
@@ -556,10 +577,10 @@
return batches;
}
- protected ListMultimap<String, BenthosBatchFrequency> importBenthosFrequencies(File file,
- Map<String, BenthosBatch> batches,
- Map<String, BenthosBatch> notImportedBatches,
- List<Caracteristic> caracteristics) {
+ protected void importBenthosFrequencies(File file,
+ Map<String, BenthosBatch> batches,
+ Map<String, BenthosBatch> notImportedBatches,
+ List<Caracteristic> caracteristics) {
ListMultimap<String, BenthosBatchFrequency> frequencyMap =
ArrayListMultimap.create();
@@ -596,7 +617,11 @@
} finally {
IOUtils.closeQuietly(reader);
}
- return frequencyMap;
+
+ for (String batchId : frequencyMap.keySet()) {
+ List<BenthosBatchFrequency> frequencies = frequencyMap.get(batchId);
+ persistenceService.saveBenthosBatchFrequency(batchId, frequencies);
+ }
}
protected void importBenthosWeights(File file,
@@ -662,55 +687,65 @@
* @param operation the operation in which to add the batches
* @return the list of the marine litter which have not been imported, because there were concurrent batches
*/
- public Map<String, Object> importMarineLitter(File file, FishingOperation operation) {
+ public Map<String, Object> importMarineLitter(final File file,
+ final FishingOperation operation) {
- File tempDir = TuttiIOUtil.explodeZip(
- context.getConfig().getTmpDirectory(),
- file,
- n_("tutti.service.multipost.uncompress.error"));
+ Callable<Map<String, Object>> call = new Callable<Map<String, Object>>() {
- //check operation
- MarineLitterWeightRowModel weightModel = new MarineLitterWeightRowModel(csvSeparator);
- checkSameOperation(tempDir, weightModel, operation);
+ @Override
+ public Map<String, Object> call() throws Exception {
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
- String operationId = operation.getId();
+ //check operation
+ MarineLitterWeightRowModel weightModel = new MarineLitterWeightRowModel(csvSeparator);
+ checkSameOperation(tempDir, weightModel, operation);
- Map<String, Object> notImportedData = Maps.newHashMap();
- final Map<String, MarineLitterBatch> notImportedBatches = Maps.newLinkedHashMap();
+ String operationId = operation.getId();
- BatchContainer<MarineLitterBatch> marineLitterBatches =
- persistenceService.getRootMarineLitterBatch(operationId);
- List<CaracteristicQualitativeValue> categoryValues =
- persistenceService.getMarineLitterCategoryCaracteristic().getQualitativeValue();
- List<CaracteristicQualitativeValue> sizeCategoryValues =
- persistenceService.getMarineLitterSizeCategoryCaracteristic().getQualitativeValue();
+ Map<String, Object> notImportedData = Maps.newHashMap();
+ final Map<String, MarineLitterBatch> notImportedBatches = Maps.newLinkedHashMap();
- // Import batches
- // map containing the batches by their persistence id
- final Map<String, MarineLitterBatch> batches = importMarineLitterBatches(
- tempDir,
- operation,
- categoryValues,
- sizeCategoryValues,
- marineLitterBatches,
- notImportedBatches);
+ BatchContainer<MarineLitterBatch> marineLitterBatches =
+ persistenceService.getRootMarineLitterBatch(operationId);
+ List<CaracteristicQualitativeValue> categoryValues =
+ persistenceService.getMarineLitterCategoryCaracteristic().getQualitativeValue();
+ List<CaracteristicQualitativeValue> sizeCategoryValues =
+ persistenceService.getMarineLitterSizeCategoryCaracteristic().getQualitativeValue();
- // Import attachments
+ // Import batches
+ // map containing the batches by their persistence id
+ final Map<String, MarineLitterBatch> batches = importMarineLitterBatches(
+ tempDir,
+ operation,
+ categoryValues,
+ sizeCategoryValues,
+ marineLitterBatches,
+ notImportedBatches);
- importAttachments(tempDir,
- batches,
- notImportedBatches,
- AttachementObjectTypeEnum.BATCH);
+ // Import attachments
- // Import weights
+ importAttachments(tempDir,
+ batches,
+ notImportedBatches,
+ AttachementObjectTypeEnum.BATCH);
- importMarineLitterCatchWeights(tempDir,
- operation,
- weightModel,
- notImportedData);
+ // Import weights
- notImportedData.put(BATCHES_KEY, notImportedBatches.values());
- return notImportedData;
+ importMarineLitterCatchWeights(tempDir,
+ operation,
+ weightModel,
+ notImportedData);
+
+ notImportedData.put(BATCHES_KEY, notImportedBatches.values());
+ return notImportedData;
+
+ }
+ };
+ Map<String, Object> result = persistenceService.invoke(call);
+ return result;
}
protected Map<String, MarineLitterBatch> importMarineLitterBatches(File file, FishingOperation operation,
@@ -820,43 +855,52 @@
* @param file the file to import the batches from
* @param operation the operation in which to add the batches
*/
- public void importIndividualObservation(File file, FishingOperation operation) {
+ public void importIndividualObservation(final File file,
+ final FishingOperation operation) {
- File tempDir = TuttiIOUtil.explodeZip(
- context.getConfig().getTmpDirectory(),
- file,
- n_("tutti.service.multipost.uncompress.error"));
+ Callable<Void> call = new Callable<Void>() {
- //check operation
- FishingOperationRowModel operationModel =
- new FishingOperationRowModel(csvSeparator);
- checkSameOperation(tempDir, operationModel, operation);
+ @Override
+ public Void call() throws Exception {
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
- TuttiDataContext dataContext = context.getDataContext();
- List<Species> speciesList = dataContext.getReferentSpecies();
- List<Caracteristic> caracteristics = dataContext.getCaracteristicWithProtected();
+ //check operation
+ FishingOperationRowModel operationModel =
+ new FishingOperationRowModel(csvSeparator);
+ checkSameOperation(tempDir, operationModel, operation);
- // Import batches
- // map containing the batches by their persistence id
- final Map<String, IndividualObservationBatch> batches = importIndividualObservationBatches(
- tempDir,
- operation,
- speciesList,
- caracteristics);
+ TuttiDataContext dataContext = context.getDataContext();
+ List<Species> speciesList = dataContext.getReferentSpecies();
+ List<Caracteristic> caracteristics = dataContext.getCaracteristicWithProtected();
- // Import caracteristics
+ // Import batches
+ // map containing the batches by their persistence id
+ final Map<String, IndividualObservationBatch> batches = importIndividualObservationBatches(
+ tempDir,
+ operation,
+ speciesList,
+ caracteristics);
- importIndividualObservationCaracteristics(file, batches, caracteristics);
+ // Import caracteristics
- // Persist batches
+ importIndividualObservationCaracteristics(file, batches, caracteristics);
- for (IndividualObservationBatch batch : batches.values()) {
- persistenceService.createIndividualObservationBatch(batch);
- }
+ // Persist batches
- // Import attachments
+ for (IndividualObservationBatch batch : batches.values()) {
+ persistenceService.createIndividualObservationBatch(batch);
+ }
- importAttachments(tempDir, batches, AttachementObjectTypeEnum.SAMPLE);
+ // Import attachments
+
+ importAttachments(tempDir, batches, AttachementObjectTypeEnum.SAMPLE);
+ return null;
+ }
+ };
+ persistenceService.invoke(call);
}
protected Map<String, IndividualObservationBatch> importIndividualObservationBatches(File file, FishingOperation operation,
@@ -964,48 +1008,56 @@
* @param file the file to import the batches from
* @param operation the operation in which to add the batches
*/
- public void importAccidentalCatches(File file, FishingOperation operation) {
+ public void importAccidentalCatches(final File file, final FishingOperation operation) {
- File tempDir = TuttiIOUtil.explodeZip(
- context.getConfig().getTmpDirectory(),
- file,
- n_("tutti.service.multipost.uncompress.error"));
+ Callable<Void> call = new Callable<Void>() {
- //check operation
- FishingOperationRowModel operationModel =
- new FishingOperationRowModel(csvSeparator);
- checkSameOperation(tempDir, operationModel, operation);
+ @Override
+ public Void call() throws Exception {
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
- TuttiDataContext dataContext = context.getDataContext();
- List<Species> speciesList = dataContext.getReferentSpecies();
- List<CaracteristicQualitativeValue> genderValues = dataContext.getGenderValues();
- List<Caracteristic> caracteristics = dataContext.getCaracteristicWithProtected();
- List<CaracteristicQualitativeValue> dedOrAliveValues = dataContext.getDeadOrAliveValues();
+ //check operation
+ FishingOperationRowModel operationModel =
+ new FishingOperationRowModel(csvSeparator);
+ checkSameOperation(tempDir, operationModel, operation);
- // Import batches
- // map containing the batches by their persistence id
- final Map<String, AccidentalBatch> batches = importAccidentalCatchesBatches(
- tempDir,
- operation,
- speciesList,
- genderValues,
- caracteristics,
- dedOrAliveValues
- );
+ TuttiDataContext dataContext = context.getDataContext();
+ List<Species> speciesList = dataContext.getReferentSpecies();
+ List<CaracteristicQualitativeValue> genderValues = dataContext.getGenderValues();
+ List<Caracteristic> caracteristics = dataContext.getCaracteristicWithProtected();
+ List<CaracteristicQualitativeValue> dedOrAliveValues = dataContext.getDeadOrAliveValues();
- // Import caracteristics
+ // Import batches
+ // map containing the batches by their persistence id
+ final Map<String, AccidentalBatch> batches = importAccidentalCatchesBatches(
+ tempDir,
+ operation,
+ speciesList,
+ genderValues,
+ caracteristics,
+ dedOrAliveValues
+ );
- importAccidentalCatchesCaracteristics(file, batches, caracteristics);
+ // Import caracteristics
- // Persist batches
+ importAccidentalCatchesCaracteristics(file, batches, caracteristics);
- for (AccidentalBatch batch : batches.values()) {
- persistenceService.createAccidentalBatch(batch);
- }
+ // Persist batches
- // Import attachments
+ for (AccidentalBatch batch : batches.values()) {
+ persistenceService.createAccidentalBatch(batch);
+ }
- importAttachments(tempDir, batches, AttachementObjectTypeEnum.SAMPLE);
+ // Import attachments
+
+ importAttachments(tempDir, batches, AttachementObjectTypeEnum.SAMPLE);
+ return null;
+ }
+ };
+ persistenceService.invoke(call);
}
protected Map<String, AccidentalBatch> importAccidentalCatchesBatches(File file, FishingOperation operation,
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportServiceTest.java 2013-07-30 17:22:49 UTC (rev 1161)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportServiceTest.java 2013-07-31 18:19:34 UTC (rev 1162)
@@ -38,6 +38,7 @@
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 2.5
+ * //FIXME Add more data in db
*/
public class TuttiMultiPostExportServiceTest {
@@ -49,8 +50,6 @@
public static final String CRUISE_ID = "100001";
- public static final String CRUISE_CGFS_ID = "100000";
-
public static final String OPERATION_1_ID = "100106";
public static final String OPERATION_2_ID = "100107";
1
0
30 Jul '13
Author: tchemit
Date: 2013-07-30 19:22:49 +0200 (Tue, 30 Jul 2013)
New Revision: 1161
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1161
Log:
refactor multiposte import/export + add tests for export (need to add some for import)
Added:
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportService.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportServiceTest.java
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiIOUtil.java
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRow.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRowModel.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java
trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiIOUtil.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiIOUtil.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiIOUtil.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -24,6 +24,8 @@
* #L%
*/
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.vfs2.FileObject;
@@ -34,8 +36,15 @@
import java.io.Closeable;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.List;
+import java.util.UUID;
+import static org.nuiton.i18n.I18n._;
+
/**
* Useful methods around IO, all method errors are boxes a
* {@link TuttiTechnicalException}.
@@ -66,6 +75,14 @@
}
}
+ public static void zip(File source, File archiveFile, List<File> files, String errorMessage) {
+ try {
+ ZipUtil.compressFiles(archiveFile, source, files);
+ } catch (IOException e) {
+ throw new TuttiTechnicalException(_(errorMessage, archiveFile), e);
+ }
+ }
+
public static FileObject resolveFile(String file, String errorMessage) {
try {
FileSystemManager manager = VFS.getManager();
@@ -168,13 +185,6 @@
}
}
-// public static File addExtensionIfMissing(File file, String extension) {
-// if (!file.getName().endsWith(extension)) {
-// file = new File(file.getParentFile(), file.getName() + extension);
-// }
-// return file;
-// }
-
public static String getBaseName(String file) {
return FilenameUtils.getBaseName(file);
}
@@ -182,4 +192,35 @@
public static String getExtension(String file) {
return FilenameUtils.getExtension(file);
}
+
+ public static Reader newReader(File file, String errorMessage) {
+ try {
+ return Files.newReader(file, Charsets.UTF_8);
+
+ } catch (FileNotFoundException e) {
+ throw new TuttiTechnicalException(_(errorMessage, file), e);
+ }
+ }
+
+ public static Writer newWriter(File file, String errorMessage
+ ) {
+ try {
+ return Files.newWriter(file, Charsets.UTF_8);
+
+ } catch (FileNotFoundException e) {
+ throw new TuttiTechnicalException(_(errorMessage, file), e);
+ }
+ }
+
+ public static File explodeZip(File rootDirectory,
+ File file,
+ String errorMessage) {
+ File tempDir = new File(rootDirectory, UUID.randomUUID().toString());
+ try {
+ ZipUtil.uncompress(file, tempDir);
+ } catch (IOException e) {
+ throw new TuttiTechnicalException(_(errorMessage, file));
+ }
+ return tempDir;
+ }
}
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-07-30 17:22:49 UTC (rev 1161)
@@ -1,4 +1,6 @@
nuitonutil.error.no.convertor=
+tutti.common.caracteristic.notFound=
+tutti.common.protocol.categories.not.compatible=
tutti.config.option.persistence.SampleCategoryModel.description=
tutti.config.option.persistence.db.attachment.directory.description=
tutti.config.option.persistence.db.cache.directory.description=
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiServiceContext.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -42,6 +42,7 @@
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.Date;
+import java.util.UUID;
import java.util.concurrent.ExecutionException;
import static org.nuiton.i18n.I18n._;
@@ -156,4 +157,8 @@
Preconditions.checkNotNull(result, "Need a not null sample category model");
return result;
}
+
+ public String generateId(Class<?> type) {
+ return UUID.randomUUID().toString();
+ }
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRow.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRow.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRow.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -44,16 +44,6 @@
public static final String SPECIES = "species";
-// public static final String SORTED_UNSORTED_SAMPLE_CATEGORY = "sortedUnsortedSampleCategory";
-//
-// public static final String SIZE_SAMPLE_CATEGORY = "sizeSampleCategory";
-//
-// public static final String SEX_SAMPLE_CATEGORY = "sexSampleCategory";
-//
-// public static final String MATURITY_SAMPLE_CATEGORY = "maturitySampleCategory";
-//
-// public static final String AGE_SAMPLE_CATEGORY = "ageSampleCategory";
-
public static final String CATEGORY_ID = "categoryId";
public static final String CATEGORY_VALUE = "categoryValue";
@@ -78,16 +68,6 @@
protected Serializable categoryValue;
-// protected Serializable sortedUnsortedSampleCategory;
-//
-// protected Serializable sizeSampleCategory;
-//
-// protected Serializable sexSampleCategory;
-//
-// protected Serializable maturitySampleCategory;
-//
-// protected Serializable ageSampleCategory;
-
protected Float categoryWeight;
protected Float weight;
@@ -138,46 +118,6 @@
this.categoryValue = categoryValue;
}
-// public Serializable getSortedUnsortedSampleCategory() {
-// return sortedUnsortedSampleCategory;
-// }
-//
-// public void setSortedUnsortedSampleCategory(Serializable sortedUnsortedSampleCategory) {
-// this.sortedUnsortedSampleCategory = sortedUnsortedSampleCategory;
-// }
-//
-// public Serializable getSizeSampleCategory() {
-// return sizeSampleCategory;
-// }
-//
-// public void setSizeSampleCategory(Serializable sizeSampleCategory) {
-// this.sizeSampleCategory = sizeSampleCategory;
-// }
-//
-// public Serializable getSexSampleCategory() {
-// return sexSampleCategory;
-// }
-//
-// public void setSexSampleCategory(Serializable sexSampleCategory) {
-// this.sexSampleCategory = sexSampleCategory;
-// }
-//
-// public Serializable getMaturitySampleCategory() {
-// return maturitySampleCategory;
-// }
-//
-// public void setMaturitySampleCategory(Serializable maturitySampleCategory) {
-// this.maturitySampleCategory = maturitySampleCategory;
-// }
-//
-// public Serializable getAgeSampleCategory() {
-// return ageSampleCategory;
-// }
-//
-// public void setAgeSampleCategory(Serializable ageSampleCategory) {
-// this.ageSampleCategory = ageSampleCategory;
-// }
-
public Float getCategoryWeight() {
return categoryWeight;
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRowModel.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRowModel.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/CatchRowModel.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -89,37 +89,16 @@
Species.PROPERTY_REFERENCE_TAXON_ID,
speciesMap);
- //FIXME: deal with it!
-// newColumnForExport(CatchRow.SORTED_UNSORTED_SAMPLE_CATEGORY,
-// caracteristicValueFormatter);
-//
-// newMandatoryColumn(CatchRow.SORTED_UNSORTED_SAMPLE_CATEGORY,
-// TuttiCsvUtil.STRING);
-//
-// newColumnForExport(CatchRow.SIZE_SAMPLE_CATEGORY,
-// caracteristicValueFormatter);
-//
-// newMandatoryColumn(CatchRow.SIZE_SAMPLE_CATEGORY,
-// TuttiCsvUtil.STRING);
-//
-// newColumnForExport(CatchRow.SEX_SAMPLE_CATEGORY,
-// caracteristicValueFormatter);
-//
-// newMandatoryColumn(CatchRow.SEX_SAMPLE_CATEGORY,
-// TuttiCsvUtil.STRING);
-//
-// newColumnForExport(CatchRow.MATURITY_SAMPLE_CATEGORY,
-// caracteristicValueFormatter);
-//
-// newMandatoryColumn(CatchRow.MATURITY_SAMPLE_CATEGORY,
-// TuttiCsvUtil.STRING);
-//
-// newColumnForExport(CatchRow.AGE_SAMPLE_CATEGORY,
-// caracteristicValueFormatter);
-//
-// newMandatoryColumn(CatchRow.AGE_SAMPLE_CATEGORY,
-// TuttiCsvUtil.STRING);
+ newColumnForImportExport(CatchRow.CATEGORY_ID,
+ TuttiCsvUtil.INTEGER);
+
+ newColumnForExport(CatchRow.CATEGORY_VALUE,
+ caracteristicValueFormatter);
+
+ newMandatoryColumn(CatchRow.CATEGORY_VALUE,
+ TuttiCsvUtil.STRING);
+
newColumnForImportExport(CatchRow.CATEGORY_WEIGHT,
TuttiCsvUtil.FLOAT);
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportService.java (from rev 1156, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportService.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportService.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -0,0 +1,683 @@
+package fr.ifremer.tutti.service.catches.multipost;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.io.Files;
+import fr.ifremer.tutti.TuttiIOUtil;
+import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+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.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
+import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.apache.commons.io.IOUtils;
+import org.nuiton.csv.Export;
+import org.nuiton.csv.ExportModel;
+
+import java.io.File;
+import java.io.Writer;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Service to export batches from a satellite post into a master post.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.2
+ */
+public class TuttiMultiPostExportService extends AbstractTuttiService {
+
+// private static final Log log =
+// LogFactory.getLog(TuttiMultiPostImportExportService.class);
+
+ public static final String BATCHES_KEY = "batchesKey";
+
+ protected static final String ATTACHMENTS_DIRECTORY = "attachments";
+
+ protected static final String ATTACHMENTS_FILE = "attachments.csv";
+
+ protected static final String SPECIES_FILE = "species.csv";
+
+ protected static final String BENTHOS_FILE = "benthos.csv";
+
+ protected static final String MARINE_LITTER_FILE = "marineLitter.csv";
+
+ protected static final String INDIVIDUAL_OBSERVATION_FILE = "individualObservation.csv";
+
+ protected static final String ACCIDENTAL_CATCHES_FILE = "accidentalCatches.csv";
+
+ protected static final String FREQUENCIES_FILE = "frequencies.csv";
+
+ protected static final String CARACTERISTIC_FILE = "caracteristics.csv";
+
+ protected static final String WEIGHTS_FILE = "weights.csv";
+
+ protected PersistenceService persistenceService;
+
+ protected DecoratorService decoratorService;
+
+ protected char csvSeparator;
+
+ protected SampleCategoryModel sampleCategoryModel;
+
+ protected Map<String, CaracteristicQualitativeValue> sampleCategoryValueMap;
+
+ @Override
+ public void setServiceContext(TuttiServiceContext context) {
+ super.setServiceContext(context);
+ persistenceService = getService(PersistenceService.class);
+ decoratorService = getService(DecoratorService.class);
+
+ csvSeparator = context.getConfig().getCsvSeparator();
+
+ sampleCategoryModel = context.getSampleCategoryModel();
+
+ sampleCategoryValueMap = Maps.newTreeMap();
+
+ for (SampleCategoryModelEntry sampleCategoryModelEntry : sampleCategoryModel.getCategory()) {
+ Caracteristic caracteristic = sampleCategoryModelEntry.getCaracteristic();
+ if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
+ List<CaracteristicQualitativeValue> qualitativeValue = caracteristic.getQualitativeValue();
+ for (CaracteristicQualitativeValue value : qualitativeValue) {
+ sampleCategoryValueMap.put(value.getId(), value);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Export species batches.
+ *
+ * @param file the file to export the batches into
+ * @param operation the operation to export
+ */
+ public void exportSpecies(File file, FishingOperation operation) {
+
+ String operationId = operation.getId();
+ if (persistenceService.isFishingOperationWithCatchBatch(operationId)) {
+
+ // create rows
+
+ BatchContainer<SpeciesBatch> speciesBatchContainer =
+ persistenceService.getRootSpeciesBatch(operationId, null);
+
+ List<CatchRow> rows = Lists.newArrayList();
+ List<CatchFrequencyRow> frequencyRows = Lists.newArrayList();
+ List<AttachmentRow> attachmentRows = Lists.newArrayList();
+
+ for (SpeciesBatch batch : speciesBatchContainer.getChildren()) {
+ createSpeciesRow(batch, null, rows, frequencyRows, attachmentRows);
+ }
+
+ // export catches + weights + attachments
+
+ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operationId);
+ CatchWeightsRow weights = new CatchWeightsRow();
+ weights.setTotalSortedWeight(catchBatch.getSpeciesTotalSortedWeight());
+ weights.setInertWeight(catchBatch.getSpeciesTotalInertWeight());
+ weights.setLivingNotItemizedWeight(catchBatch.getSpeciesTotalLivingNotItemizedWeight());
+ exportOperation(weights, operation);
+
+ exportCatches(file,
+ SPECIES_FILE,
+ weights,
+ rows,
+ frequencyRows,
+ attachmentRows);
+ }
+ }
+
+ /**
+ * Export benthos batches.
+ *
+ * @param file the file to export the batches into
+ * @param operation the operation to export
+ */
+ public void exportBenthos(File file, FishingOperation operation) {
+
+ String operationId = operation.getId();
+ if (persistenceService.isFishingOperationWithCatchBatch(operationId)) {
+
+ BatchContainer<BenthosBatch> benthosBatchContainer =
+ persistenceService.getRootBenthosBatch(operationId, null);
+
+ // create rows
+
+ List<CatchRow> rows = Lists.newArrayList();
+ List<CatchFrequencyRow> frequencyRows = Lists.newArrayList();
+ List<AttachmentRow> attachmentRows = Lists.newArrayList();
+
+ for (BenthosBatch batch : benthosBatchContainer.getChildren()) {
+ createBenthosRow(batch, null, rows, frequencyRows, attachmentRows);
+ }
+
+ // export catches + weights + attachments
+
+ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operationId);
+ CatchWeightsRow weights = new CatchWeightsRow();
+ weights.setTotalSortedWeight(catchBatch.getBenthosTotalSortedWeight());
+ weights.setInertWeight(catchBatch.getBenthosTotalInertWeight());
+ weights.setLivingNotItemizedWeight(catchBatch.getBenthosTotalLivingNotItemizedWeight());
+ exportOperation(weights, operation);
+
+ exportCatches(file,
+ BENTHOS_FILE,
+ weights,
+ rows,
+ frequencyRows,
+ attachmentRows);
+ }
+ }
+
+ /**
+ * Export marine litter batches.
+ *
+ * @param file the file to export the batches into
+ * @param operation the operation to export
+ */
+ public void exportMarineLitter(File file, FishingOperation operation) {
+
+ String operationId = operation.getId();
+ if (persistenceService.isFishingOperationWithCatchBatch(operationId)) {
+
+ // create rows
+
+ BatchContainer<MarineLitterBatch> marineLitterBatchContainer =
+ persistenceService.getRootMarineLitterBatch(operationId);
+
+ List<MarineLitterRow> rows = Lists.newArrayList();
+ List<AttachmentRow> attachmentRows = Lists.newArrayList();
+
+ for (MarineLitterBatch batch : marineLitterBatchContainer.getChildren()) {
+ MarineLitterRow row = new MarineLitterRow();
+
+ String id = context.generateId(MarineLitterRow.class);
+ row.setBatchId(id);
+
+ row.setCategory(batch.getMarineLitterCategory());
+ row.setSizeCategory(batch.getMarineLitterSizeCategory());
+ row.setNumber(batch.getNumber());
+ row.setWeight(batch.getWeight());
+ row.setComment(batch.getComment());
+
+ rows.add(row);
+
+ addAttachments(id,
+ batch.getIdAsInt(),
+ AttachementObjectTypeEnum.BATCH,
+ attachmentRows);
+ }
+
+
+ File directory = Files.createTempDir();
+ List<File> file2zip = Lists.newArrayList();
+
+ // export marine litters
+
+ MarineLitterRowModel marineLitterRowModel = new MarineLitterRowModel(csvSeparator);
+ File marineLitterFile = new File(directory, MARINE_LITTER_FILE);
+ file2zip.add(marineLitterFile);
+ export(marineLitterFile,
+ marineLitterRowModel,
+ rows,
+ n_("tutti.service.multipost.export.batches.error"));
+
+ // export weights
+
+ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operationId);
+ MarineLitterWeightRow weight = new MarineLitterWeightRow();
+ weight.setTotalWeight(catchBatch.getMarineLitterTotalWeight());
+ exportOperation(weight, operation);
+
+ MarineLitterWeightRowModel weightModel = new MarineLitterWeightRowModel(csvSeparator);
+
+ File weightFile = new File(directory, WEIGHTS_FILE);
+ file2zip.add(weightFile);
+ export(weightFile,
+ weightModel,
+ Lists.newArrayList(weight),
+ n_("tutti.service.multipost.export.weight.error"));
+
+ // export attachments + create final zip
+
+ exportAttachmentsAndCreateZip(file,
+ directory,
+ file2zip,
+ attachmentRows);
+ }
+ }
+
+ /**
+ * Export individual observation batches.
+ *
+ * @param file the file to export the batches into
+ * @param operation the operation to export
+ */
+ public void exportIndividualObservation(File file, FishingOperation operation) {
+ List<IndividualObservationBatch> individualObservations =
+ persistenceService.getAllIndividualObservationBatch(operation.getId());
+
+ // create rows
+
+ List<IndividualObservationRow> rows = Lists.newArrayList();
+ List<CaracteristicRow> caracteristicRows = Lists.newArrayList();
+ List<AttachmentRow> attachmentRows = Lists.newArrayList();
+
+
+ for (IndividualObservationBatch batch : individualObservations) {
+ IndividualObservationRow row = new IndividualObservationRow();
+
+ String id = context.generateId(IndividualObservationRow.class);
+ row.setBatchId(id);
+
+ row.setSpecies(batch.getSpecies());
+ row.setWeight(batch.getWeight());
+ row.setSize(batch.getSize());
+ row.setLengthStepCaracteristic(batch.getLengthStepCaracteristic());
+ row.setSamplingCode(batch.getSamplingCode());
+ row.setCalcifiedPieceSamplingCode(batch.getCalcifiedPieceSamplingCode());
+ row.setComment(batch.getComment());
+
+ rows.add(row);
+
+ CaracteristicMap caracteristicMap = batch.getCaracteristics();
+ for (Caracteristic caracteristic : caracteristicMap.keySet()) {
+ CaracteristicRow caracteristicRow = new CaracteristicRow();
+ caracteristicRow.setBatchId(id);
+ caracteristicRow.setCaracteristic(caracteristic);
+ caracteristicRow.setValue(caracteristicMap.get(caracteristic));
+ caracteristicRows.add(caracteristicRow);
+ }
+
+ addAttachments(id, batch.getIdAsInt(), AttachementObjectTypeEnum.SAMPLE, attachmentRows);
+ }
+
+ File directory = Files.createTempDir();
+ List<File> file2zip = Lists.newArrayList();
+
+ // export individual observations
+
+ IndividualObservationRowModel csvModel = new IndividualObservationRowModel(csvSeparator);
+ File individualObservationFile = new File(directory, INDIVIDUAL_OBSERVATION_FILE);
+ file2zip.add(individualObservationFile);
+ export(individualObservationFile,
+ csvModel,
+ rows,
+ n_("tutti.service.multipost.export.batches.error"));
+
+ // export caracteristics
+
+ CaracteristicRowModel caracteristicCsvModel = new CaracteristicRowModel(csvSeparator);
+ File caracteristicFile = new File(directory, CARACTERISTIC_FILE);
+ file2zip.add(caracteristicFile);
+ export(caracteristicFile,
+ caracteristicCsvModel,
+ caracteristicRows,
+ n_("tutti.service.multipost.export.batches.error"));
+
+ // export operation
+
+ FishingOperationRow foRow = new FishingOperationRow();
+ exportOperation(foRow, operation);
+
+ FishingOperationRowModel foRowModel = new FishingOperationRowModel(csvSeparator);
+
+ File weightFile = new File(directory, WEIGHTS_FILE);
+ file2zip.add(weightFile);
+ export(weightFile,
+ foRowModel,
+ Lists.newArrayList(foRow),
+ n_("tutti.service.multipost.export.operation.error"));
+
+ // export attachments + create final zip
+
+ exportAttachmentsAndCreateZip(file,
+ directory,
+ file2zip,
+ attachmentRows);
+ }
+
+ /**
+ * Export accidental catch batches.
+ *
+ * @param file the file to export the batches into
+ * @param operation the operation to export
+ */
+ public void exportAccidentalCatch(File file, FishingOperation operation) {
+ List<AccidentalBatch> accidentalCatches =
+ persistenceService.getAllAccidentalBatch(operation.getId());
+
+ List<AccidentalCatchRow> rows = Lists.newArrayList();
+ List<CaracteristicRow> caracteristicRows = Lists.newArrayList();
+ List<AttachmentRow> attachmentRows = Lists.newArrayList();
+
+ // create rows
+
+ for (AccidentalBatch batch : accidentalCatches) {
+ AccidentalCatchRow row = new AccidentalCatchRow();
+
+ String id = context.generateId(AccidentalCatchRow.class);
+ row.setBatchId(id);
+
+ row.setSpecies(batch.getSpecies());
+ row.setGender(batch.getGender());
+ row.setWeight(batch.getWeight());
+ row.setSize(batch.getSize());
+ row.setLengthStepCaracteristic(batch.getLengthStepCaracteristic());
+ row.setDeadOrAlive(batch.getDeadOrAlive());
+ row.setComment(batch.getComment());
+
+ rows.add(row);
+
+ CaracteristicMap caracteristicMap = batch.getCaracteristics();
+ for (Caracteristic caracteristic : caracteristicMap.keySet()) {
+ CaracteristicRow caracteristicRow = new CaracteristicRow();
+ caracteristicRow.setBatchId(id);
+ caracteristicRow.setCaracteristic(caracteristic);
+ caracteristicRow.setValue(caracteristicMap.get(caracteristic));
+ caracteristicRows.add(caracteristicRow);
+ }
+
+ addAttachments(id, batch.getIdAsInt(), AttachementObjectTypeEnum.SAMPLE, attachmentRows);
+ }
+
+ // export accidental catches
+
+ AccidentalCatchRowModel csvModel = new AccidentalCatchRowModel(csvSeparator);
+
+ File directory = Files.createTempDir();
+ List<File> file2zip = Lists.newArrayList();
+
+ File accidentalCatchesFile = new File(directory, ACCIDENTAL_CATCHES_FILE);
+ file2zip.add(accidentalCatchesFile);
+ export(accidentalCatchesFile,
+ csvModel,
+ rows,
+ n_("tutti.service.multipost.export.batches.error"));
+
+ // export caracteristics
+
+ CaracteristicRowModel caracteristicCsvModel = new CaracteristicRowModel(csvSeparator);
+ File caracteristicFile = new File(directory, CARACTERISTIC_FILE);
+ file2zip.add(caracteristicFile);
+ export(caracteristicFile,
+ caracteristicCsvModel,
+ caracteristicRows,
+ n_("tutti.service.multipost.export.batches.error"));
+
+ // export operation
+
+ FishingOperationRow foRow = new FishingOperationRow();
+ exportOperation(foRow, operation);
+
+ FishingOperationRowModel foRowModel = new FishingOperationRowModel(csvSeparator);
+
+ File weightFile = new File(directory, WEIGHTS_FILE);
+ file2zip.add(weightFile);
+ export(weightFile,
+ foRowModel,
+ Lists.newArrayList(foRow),
+ n_("tutti.service.multipost.export.operation.error"));
+
+ // export attachments + create final zip
+
+ exportAttachmentsAndCreateZip(file,
+ directory,
+ file2zip,
+ attachmentRows);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void exportCatches(File file,
+ String batchFile,
+ CatchWeightsRow weights,
+ List<CatchRow> rows,
+ List<CatchFrequencyRow> frequencyRows,
+ List<AttachmentRow> attachmentRows) {
+ CatchRowModel csvModel = new CatchRowModel(csvSeparator);
+ CatchFrequencyRowModel csvFrequencyModel = new CatchFrequencyRowModel(csvSeparator);
+ CatchWeightsRowModel catchWeightsModel = new CatchWeightsRowModel(csvSeparator);
+
+ File directory = Files.createTempDir();
+ List<File> file2zip = Lists.newArrayList();
+
+ File weightsFile = new File(directory, WEIGHTS_FILE);
+ file2zip.add(weightsFile);
+ export(weightsFile,
+ catchWeightsModel,
+ Lists.newArrayList(weights),
+ n_("tutti.service.multipost.export.weights.error"));
+
+ File speciesFile = new File(directory, batchFile);
+ file2zip.add(speciesFile);
+ export(speciesFile,
+ csvModel,
+ rows,
+ n_("tutti.service.multipost.export.batches.error"));
+
+ File frequencyFile = new File(directory, FREQUENCIES_FILE);
+ file2zip.add(frequencyFile);
+ export(frequencyFile,
+ csvFrequencyModel,
+ frequencyRows,
+ n_("tutti.service.multipost.export.frequencies.error"));
+
+ // export attachments + create final zip
+
+ exportAttachmentsAndCreateZip(file,
+ directory,
+ file2zip,
+ attachmentRows);
+ }
+
+ protected void createSpeciesRow(SpeciesBatch batch,
+ String parentId,
+ List<CatchRow> rows,
+ List<CatchFrequencyRow> frequencyRows,
+ List<AttachmentRow> attachmentRows) {
+ CatchRow row = new CatchRow();
+
+ String id = context.generateId(CatchRow.class);;
+ row.setId(id);
+ row.setParentId(parentId);
+ row.setSpecies(batch.getSpecies());
+
+ row.setCategoryId(batch.getSampleCategoryId());
+ row.setCategoryValue(batch.getSampleCategoryValue());
+ row.setCategoryWeight(batch.getSampleCategoryWeight());
+ row.setWeight(batch.getWeight());
+ row.setNumber(batch.getNumber());
+ row.setComment(batch.getComment());
+ row.setToConfirm(batch.isSpeciesToConfirm());
+
+ rows.add(row);
+
+ addFrequencies(id, batch.getId(), frequencyRows);
+ addAttachments(id, batch.getIdAsInt(), AttachementObjectTypeEnum.BATCH, attachmentRows);
+
+ for (SpeciesBatch child : batch.getChildBatchs()) {
+ createSpeciesRow(child, id, rows, frequencyRows, attachmentRows);
+ }
+ }
+
+ protected void createBenthosRow(BenthosBatch batch,
+ String parentId,
+ List<CatchRow> rows,
+ List<CatchFrequencyRow> frequencyRows,
+ List<AttachmentRow> attachmentRows) {
+ CatchRow row = new CatchRow();
+
+ String id = context.generateId(CatchRow.class);
+ row.setId(id);
+ row.setParentId(parentId);
+ row.setSpecies(batch.getSpecies());
+
+ row.setCategoryId(batch.getSampleCategoryId());
+ row.setCategoryValue(batch.getSampleCategoryValue());
+ row.setCategoryWeight(batch.getSampleCategoryWeight());
+ row.setWeight(batch.getWeight());
+ row.setNumber(batch.getNumber());
+ row.setComment(batch.getComment());
+ row.setToConfirm(batch.isSpeciesToConfirm());
+
+ rows.add(row);
+
+ addFrequencies(id, batch.getId(), frequencyRows);
+ addAttachments(id, batch.getIdAsInt(), AttachementObjectTypeEnum.BATCH, attachmentRows);
+
+ for (BenthosBatch child : batch.getChildBatchs()) {
+ createBenthosRow(child, id, rows, frequencyRows, attachmentRows);
+ }
+ }
+
+ protected void exportOperation(AbstractFishingOperationRow afoRow, FishingOperation operation) {
+ afoRow.setStationNumber(operation.getStationNumber());
+ afoRow.setOperationNumber(operation.getFishingOperationNumber());
+ afoRow.setMultirigAggregation(operation.getMultirigAggregation());
+ afoRow.setDate(operation.getGearShootingStartDate());
+ }
+
+ protected void addFrequencies(String rowId,
+ String batchId,
+ List<CatchFrequencyRow> frequencyRows) {
+ List<SpeciesBatchFrequency> frequencies =
+ persistenceService.getAllSpeciesBatchFrequency(batchId);
+ for (SpeciesBatchFrequency frequency : frequencies) {
+ CatchFrequencyRow frequencyRow = new CatchFrequencyRow();
+ frequencyRow.setBatchId(rowId);
+ frequencyRow.setLengthStepCaracteristic(frequency.getLengthStepCaracteristic());
+ frequencyRow.setLengthStep(frequency.getLengthStep());
+ frequencyRow.setNumber(frequency.getNumber());
+ frequencyRow.setWeight(frequency.getWeight());
+ frequencyRows.add(frequencyRow);
+ }
+ }
+
+ protected void addAttachments(String batchId,
+ int objectId,
+ AttachementObjectTypeEnum objectType,
+ List<AttachmentRow> attachmentRows) {
+ List<Attachment> attachments =
+ persistenceService.getAllAttachments(objectType, objectId);
+ for (Attachment attachment : attachments) {
+ AttachmentRow attachmentRow = new AttachmentRow();
+ attachmentRow.setBatchId(batchId);
+ attachmentRow.setName(attachment.getName());
+ attachmentRow.setComment(attachment.getComment());
+ attachmentRow.setFile(persistenceService.getAttachmentFile(attachment.getId()));
+ attachmentRows.add(attachmentRow);
+ }
+ }
+
+
+ protected <R> void export(File file,
+ ExportModel<R> exportModel,
+ List<R> rows,
+ String errorMessage) {
+ Writer writer = TuttiIOUtil.newWriter(
+ file,
+ n_("tutti.service.multipost.export.file.writer.error"));
+ try {
+ Export export = Export.newExport(exportModel, rows);
+ export.write(writer);
+ writer.close();
+
+ } catch (Exception e) {
+ throw new TuttiTechnicalException(_(errorMessage, file), e);
+ } finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+
+ protected void exportAttachments(File directory,
+ List<File> file2zip,
+ List<AttachmentRow> attachmentRows) {
+
+ AttachmentRowModel csvAttachmentModel = new AttachmentRowModel(csvSeparator);
+
+ File attachmentDirectory = new File(directory, ATTACHMENTS_DIRECTORY);
+ TuttiIOUtil.forceMkdir(attachmentDirectory, _("tutti.service.multipost.attachment.mkdirDir.error", attachmentDirectory));
+ file2zip.add(attachmentDirectory);
+ for (AttachmentRow attachmentRow : attachmentRows) {
+ File attachmentFile = attachmentRow.getFile();
+ File destFile = new File(attachmentDirectory, attachmentFile.getName());
+ TuttiIOUtil.copyFile(attachmentFile,
+ destFile,
+ _("tutti.service.multipost.attachment.copy.error", attachmentFile));
+ file2zip.add(destFile);
+ }
+
+ File attachmentFile = new File(directory, ATTACHMENTS_FILE);
+ file2zip.add(attachmentFile);
+ export(attachmentFile,
+ csvAttachmentModel,
+ attachmentRows,
+ n_("tutti.service.multipost.export.attachments.error"));
+
+ }
+
+ protected void exportAttachmentsAndCreateZip(File file,
+ File directory,
+ List<File> file2zip,
+ List<AttachmentRow> attachmentRows) {
+ exportAttachments(directory, file2zip, attachmentRows);
+
+ try {
+ TuttiIOUtil.zip(directory,
+ file,
+ file2zip,
+ n_("tutti.service.multipost.export.error"));
+ } finally {
+ TuttiIOUtil.deleteDirectory(directory, _("tutti.service.multipost.export.deleteTempDirectory.error", file));
+ }
+ }
+}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -84,7 +84,9 @@
*
* @author kmorin <kmorin(a)codelutin.com>
* @since 2.2
+ * @deprecated since 2.5, too long, too bad :(
*/
+@Deprecated
public class TuttiMultiPostImportExportService extends AbstractTuttiService {
// private static final Log log =
Copied: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportService.java (from rev 1156, trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java)
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportService.java (rev 0)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportService.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -0,0 +1,1269 @@
+package fr.ifremer.tutti.service.catches.multipost;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Maps;
+import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.TuttiIOUtil;
+import fr.ifremer.tutti.persistence.entities.CaracteristicMap;
+import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.TuttiEntity;
+import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+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.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
+import fr.ifremer.tutti.persistence.entities.referential.Species;
+import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.TuttiDataContext;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
+import org.nuiton.csv.Import;
+
+import java.io.File;
+import java.io.Reader;
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Service to export batches from a satellite post or import batches into a master post.
+ *
+ * @author kmorin <kmorin(a)codelutin.com>
+ * @since 2.2
+ */
+public class TuttiMultiPostImportService extends AbstractTuttiService {
+
+// private static final Log log =
+// LogFactory.getLog(TuttiMultiPostImportExportService.class);
+
+ public static final String BATCHES_KEY = "batchesKey";
+
+ protected static final String ATTACHMENTS_DIRECTORY = "attachments";
+
+ protected static final String ATTACHMENTS_FILE = "attachments.csv";
+
+ protected static final String SPECIES_FILE = "species.csv";
+
+ protected static final String BENTHOS_FILE = "benthos.csv";
+
+ protected static final String MARINE_LITTER_FILE = "marineLitter.csv";
+
+ protected static final String INDIVIDUAL_OBSERVATION_FILE = "individualObservation.csv";
+
+ protected static final String ACCIDENTAL_CATCHES_FILE = "accidentalCatches.csv";
+
+ protected static final String FREQUENCIES_FILE = "frequencies.csv";
+
+ protected static final String CARACTERISTIC_FILE = "caracteristics.csv";
+
+ protected static final String WEIGHTS_FILE = "weights.csv";
+
+ protected PersistenceService persistenceService;
+
+ protected DecoratorService decoratorService;
+
+ protected char csvSeparator;
+
+ protected SampleCategoryModel sampleCategoryModel;
+
+ protected Map<String, CaracteristicQualitativeValue> sampleCategoryValueMap;
+
+ @Override
+ public void setServiceContext(TuttiServiceContext context) {
+ super.setServiceContext(context);
+ persistenceService = getService(PersistenceService.class);
+ decoratorService = getService(DecoratorService.class);
+
+ csvSeparator = context.getConfig().getCsvSeparator();
+
+ sampleCategoryModel = context.getSampleCategoryModel();
+
+ sampleCategoryValueMap = Maps.newTreeMap();
+
+ for (SampleCategoryModelEntry sampleCategoryModelEntry : sampleCategoryModel.getCategory()) {
+ Caracteristic caracteristic = sampleCategoryModelEntry.getCaracteristic();
+ if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
+ List<CaracteristicQualitativeValue> qualitativeValue = caracteristic.getQualitativeValue();
+ for (CaracteristicQualitativeValue value : qualitativeValue) {
+ sampleCategoryValueMap.put(value.getId(), value);
+ }
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Import Species --//
+ //------------------------------------------------------------------------//
+
+ /**
+ * Import species batches from a satellite post
+ *
+ * @param file the file to import the batches from
+ * @param operation the operation in which to add the batches
+ * @return the list of the species which have not been imported, because there were concurrent batches
+ */
+ public Map<String, Object> importSpecies(File file, FishingOperation operation) {
+
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
+
+ //check operation
+ CatchWeightsRowModel weightsModel = new CatchWeightsRowModel(csvSeparator);
+ checkSameOperation(tempDir, weightsModel, operation);
+
+ Map<String, Object> notImportedData = Maps.newHashMap();
+ final Map<String, SpeciesBatch> notImportedBatches = Maps.newLinkedHashMap();
+
+ BatchContainer<SpeciesBatch> speciesBatches =
+ persistenceService.getRootSpeciesBatch(operation.getId(), null);
+
+ TuttiDataContext dataContext = context.getDataContext();
+ List<Species> speciesList = dataContext.getReferentSpecies();
+
+ // Import batches
+ // map containing the batches by their persistence id
+
+ final Map<String, SpeciesBatch> batches = importSpeciesBatches(
+ tempDir,
+ operation,
+ speciesBatches,
+ notImportedBatches,
+ speciesList);
+
+ List<Caracteristic> caracteristics = dataContext.getCaracteristics();
+
+ // Import frequencies
+
+ ListMultimap<String, SpeciesBatchFrequency> frequencyMap = importSpeciesFrequencies(
+ file,
+ batches,
+ notImportedBatches,
+ caracteristics);
+
+ // Persist frequencies
+
+ for (String batchId : frequencyMap.keySet()) {
+ List<SpeciesBatchFrequency> frequencies = frequencyMap.get(batchId);
+ persistenceService.saveSpeciesBatchFrequency(batchId, frequencies);
+ }
+
+ // Import attachments
+
+ importAttachments(tempDir,
+ batches,
+ notImportedBatches,
+ AttachementObjectTypeEnum.BATCH);
+
+ // Import weights
+
+ importSpeciesWeights(tempDir,
+ operation,
+ weightsModel,
+ notImportedData);
+
+ notImportedData.put(BATCHES_KEY, notImportedBatches.values());
+ return notImportedData;
+ }
+
+ protected Map<String, SpeciesBatch> importSpeciesBatches(File file,
+ FishingOperation operation,
+ BatchContainer<SpeciesBatch> speciesBatches,
+ Map<String, SpeciesBatch> notImportedBatches,
+ List<Species> speciesList) {
+ final Map<String, SpeciesBatch> batches = Maps.newHashMap();
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, SPECIES_FILE),
+ n_("tutti.service.multipost.import.batches.error"));
+
+ try {
+ CatchRowModel csvModel = new CatchRowModel(csvSeparator,
+ speciesList);
+
+ Import<CatchRow> importer = Import.newImport(csvModel, reader);
+
+ try {
+ for (CatchRow row : importer) {
+
+ // create batch
+ SpeciesBatch batch = TuttiBeanFactory.newSpeciesBatch();
+ batch.setFishingOperation(operation);
+
+ Species species = row.getSpecies();
+ batch.setSpecies(row.getSpecies());
+ batch.setWeight(row.getWeight());
+ batch.setNumber(row.getNumber());
+ batch.setComment(row.getComment());
+ batch.setSpeciesToConfirm(row.isToConfirm());
+
+ Pair<Integer, Serializable> valueAndCategoryType = getValueAndCategoryType(row);
+ Integer categoryId = valueAndCategoryType.getKey();
+ Serializable value = valueAndCategoryType.getValue();
+
+ batch.setSampleCategoryId(categoryId);
+ batch.setSampleCategoryValue(value);
+ batch.setSampleCategoryWeight(row.getCategoryWeight());
+
+ // get parent batch
+ String parentId = row.getParentId();
+ String parentPersistedId = null;
+ SpeciesBatch parent = null;
+ if (StringUtils.isNotEmpty(parentId)) {
+ parent = batches.get(parentId);
+ parentPersistedId = parent.getId();
+ }
+
+ SpeciesBatch existingBatch = null;
+ List<SpeciesBatch> batchesToBrowse;
+ if (parent == null) {
+ batchesToBrowse = speciesBatches.getChildren();
+ } else {
+ batchesToBrowse = parent.getChildBatchs();
+ }
+
+ // check if the parent has already a batch with the caracteristic value
+ // and if the children batch are categorized with the same caracterstic
+ if (batchesToBrowse != null) {
+ for (SpeciesBatch sb : batchesToBrowse) {
+ if (sb.getSpecies().equals(species)
+ && (!sb.getSampleCategoryId().equals(batch.getSampleCategoryId())
+ || sb.getSampleCategoryValue().equals(value))) {
+
+ existingBatch = sb;
+ batches.put(row.getId(), sb);
+ notImportedBatches.put(row.getId(), batch);
+ break;
+ }
+ }
+ }
+
+ if (existingBatch == null) {
+ batch = persistenceService.createSpeciesBatch(batch, parentPersistedId);
+ batches.put(row.getId(), batch);
+ }
+ }
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ return batches;
+ }
+
+ protected ListMultimap<String, SpeciesBatchFrequency> importSpeciesFrequencies(
+ File file,
+ Map<String, SpeciesBatch> batches,
+ Map<String, SpeciesBatch> notImportedBatches,
+ List<Caracteristic> caracteristics) {
+ ListMultimap<String, SpeciesBatchFrequency> frequencyMap =
+ ArrayListMultimap.create();
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, FREQUENCIES_FILE),
+ n_("tutti.service.multipost.import.frequencies.error"));
+
+ try {
+
+ CatchFrequencyRowModel frequencyModel = new CatchFrequencyRowModel(csvSeparator,
+ caracteristics);
+
+ Import<CatchFrequencyRow> importer = Import.newImport(frequencyModel, reader);
+
+
+ try {
+ for (CatchFrequencyRow frequencyRow : importer) {
+ if (notImportedBatches.get(frequencyRow.getBatchId()) == null) {
+ SpeciesBatch batch = batches.get(frequencyRow.getBatchId());
+ if (batch != null) {
+ SpeciesBatchFrequency frequency = TuttiBeanFactory.newSpeciesBatchFrequency();
+ frequency.setLengthStepCaracteristic(frequencyRow.getLengthStepCaracteristic());
+ frequency.setLengthStep(frequencyRow.getLengthStep());
+ frequency.setNumber(frequencyRow.getNumber());
+ frequency.setWeight(frequencyRow.getWeight());
+ frequency.setBatch(batch);
+ frequencyMap.put(batch.getId(), frequency);
+ }
+ }
+ }
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ return frequencyMap;
+ }
+
+ protected void importSpeciesWeights(File file,
+ FishingOperation operation,
+ CatchWeightsRowModel weightsModel,
+ Map<String, Object> notImportedData) {
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, WEIGHTS_FILE),
+ n_("tutti.service.multipost.import.weights.error"));
+
+ try {
+ Import<CatchWeightsRow> importer = Import.newImport(weightsModel, reader);
+
+ try {
+ Iterator<CatchWeightsRow> iterator = importer.iterator();
+ if (iterator.hasNext()) {
+ CatchWeightsRow row = iterator.next();
+ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId());
+ catchBatch.setFishingOperation(operation);
+
+ if (catchBatch.getSpeciesTotalSortedWeight() == null) {
+ catchBatch.setSpeciesTotalSortedWeight(row.getTotalSortedWeight());
+
+ } else if (row.getTotalSortedWeight() != null) {
+ notImportedData.put(CatchBatch.PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT, row.getTotalSortedWeight());
+ }
+
+ if (catchBatch.getSpeciesTotalInertWeight() == null) {
+ catchBatch.setSpeciesTotalInertWeight(row.getInertWeight());
+
+ } else if (row.getInertWeight() != null) {
+ notImportedData.put(CatchBatch.PROPERTY_SPECIES_TOTAL_INERT_WEIGHT, row.getInertWeight());
+ }
+
+ if (catchBatch.getSpeciesTotalLivingNotItemizedWeight() == null) {
+ catchBatch.setSpeciesTotalLivingNotItemizedWeight(row.getLivingNotItemizedWeight());
+
+ } else if (row.getLivingNotItemizedWeight() != null) {
+ notImportedData.put(CatchBatch.PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT,
+ row.getLivingNotItemizedWeight());
+ }
+ persistenceService.saveCatchBatch(catchBatch);
+ }
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Import Benthos --//
+ //------------------------------------------------------------------------//
+
+ /**
+ * Import benthos batches from a satellite post
+ *
+ * @param file the file to import the batches from
+ * @param operation the operation in which to add the batches
+ * @return the list of the benthos which have not been imported, because there were concurrent batches
+ */
+ public Map<String, Object> importBenthos(File file, FishingOperation operation) {
+
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
+
+ //check operation
+ CatchWeightsRowModel weightsModel = new CatchWeightsRowModel(csvSeparator);
+ checkSameOperation(tempDir, weightsModel, operation);
+
+ Map<String, Object> notImportedData = Maps.newHashMap();
+ final Map<String, BenthosBatch> notImportedBatches = Maps.newLinkedHashMap();
+
+ BatchContainer<BenthosBatch> benthosBatches =
+ persistenceService.getRootBenthosBatch(operation.getId(), null);
+
+ TuttiDataContext dataContext = context.getDataContext();
+ List<Species> speciesList = dataContext.getReferentSpecies();
+
+ // Import batches
+ // map containing the batches by their persistence id
+ final Map<String, BenthosBatch> batches = importBenthosBatches(
+ tempDir,
+ operation,
+ benthosBatches,
+ notImportedBatches,
+ speciesList);
+
+ // Import frequencies
+
+ ListMultimap<String, BenthosBatchFrequency> frequencyMap = importBenthosFrequencies(
+ tempDir,
+ batches,
+ notImportedBatches,
+ dataContext.getCaracteristics());
+
+ // Persist frequencies
+
+ for (String batchId : frequencyMap.keySet()) {
+ List<BenthosBatchFrequency> frequencies = frequencyMap.get(batchId);
+ persistenceService.saveBenthosBatchFrequency(batchId, frequencies);
+ }
+
+ // Import attachments
+
+ importAttachments(tempDir, batches, notImportedBatches, AttachementObjectTypeEnum.BATCH);
+
+ // Import weights
+
+ importBenthosWeights(tempDir, operation, weightsModel, notImportedData);
+
+ notImportedData.put(BATCHES_KEY, notImportedBatches.values());
+ return notImportedData;
+ }
+
+ protected Map<String, BenthosBatch> importBenthosBatches(File file,
+ FishingOperation operation,
+ BatchContainer<BenthosBatch> benthosBatches,
+ Map<String, BenthosBatch> notImportedBatches,
+ List<Species> speciesList) {
+ final Map<String, BenthosBatch> batches = Maps.newHashMap();
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, BENTHOS_FILE),
+ n_("tutti.service.multipost.import.batches.error"));
+
+ try {
+ CatchRowModel csvModel = new CatchRowModel(csvSeparator,
+ speciesList);
+
+ Import<CatchRow> importer = Import.newImport(csvModel, reader);
+
+ try {
+ for (CatchRow row : importer) {
+
+ // create batch
+ BenthosBatch batch = TuttiBeanFactory.newBenthosBatch();
+ batch.setFishingOperation(operation);
+
+ Species species = row.getSpecies();
+ batch.setSpecies(row.getSpecies());
+ batch.setWeight(row.getWeight());
+ batch.setNumber(row.getNumber());
+ batch.setComment(row.getComment());
+ batch.setSpeciesToConfirm(row.isToConfirm());
+
+ Pair<Integer, Serializable> valueAndCategoryType = getValueAndCategoryType(row);
+ Integer categoryId = valueAndCategoryType.getKey();
+ Serializable value = valueAndCategoryType.getValue();
+
+ batch.setSampleCategoryId(categoryId);
+ batch.setSampleCategoryValue(value);
+ batch.setSampleCategoryWeight(row.getCategoryWeight());
+
+ // get parent batch
+ String parentId = row.getParentId();
+ String parentPersistedId = null;
+ BenthosBatch parent = null;
+ if (StringUtils.isNotEmpty(parentId)) {
+ parent = batches.get(parentId);
+ parentPersistedId = parent.getId();
+ }
+
+ BenthosBatch existingBatch = null;
+ List<BenthosBatch> batchesToBrowse;
+ if (parent == null) {
+ batchesToBrowse = benthosBatches.getChildren();
+ } else {
+ batchesToBrowse = parent.getChildBatchs();
+ }
+
+ // check if the parent has already a batch with the caracteristic value
+ // and if the children batch are categorized with the same caracterstic
+ if (batchesToBrowse != null) {
+ for (BenthosBatch bb : batchesToBrowse) {
+ if (bb.getSpecies().equals(species)
+ && (!bb.getSampleCategoryId().equals(batch.getSampleCategoryId())
+ || bb.getSampleCategoryValue().equals(value))) {
+
+ existingBatch = bb;
+ batches.put(row.getId(), bb);
+ notImportedBatches.put(row.getId(), batch);
+ break;
+ }
+ }
+ }
+
+ if (existingBatch == null) {
+ batch = persistenceService.createBenthosBatch(batch, parentPersistedId);
+ batches.put(row.getId(), batch);
+ }
+ }
+
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ return batches;
+ }
+
+ protected ListMultimap<String, BenthosBatchFrequency> importBenthosFrequencies(File file,
+ Map<String, BenthosBatch> batches,
+ Map<String, BenthosBatch> notImportedBatches,
+ List<Caracteristic> caracteristics) {
+ ListMultimap<String, BenthosBatchFrequency> frequencyMap =
+ ArrayListMultimap.create();
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, FREQUENCIES_FILE),
+ n_("tutti.service.multipost.import.frequencies.error"));
+ try {
+ CatchFrequencyRowModel frequencyModel = new CatchFrequencyRowModel(csvSeparator,
+ caracteristics);
+
+ Import<CatchFrequencyRow> importer = Import.newImport(frequencyModel, reader);
+
+ try {
+
+ for (CatchFrequencyRow frequencyRow : importer) {
+ if (notImportedBatches.get(frequencyRow.getBatchId()) == null) {
+ BenthosBatch batch = batches.get(frequencyRow.getBatchId());
+ if (batch != null) {
+ BenthosBatchFrequency frequency = TuttiBeanFactory.newBenthosBatchFrequency();
+ frequency.setLengthStepCaracteristic(frequencyRow.getLengthStepCaracteristic());
+ frequency.setLengthStep(frequencyRow.getLengthStep());
+ frequency.setNumber(frequencyRow.getNumber());
+ frequency.setWeight(frequencyRow.getWeight());
+ frequency.setBatch(batch);
+ frequencyMap.put(batch.getId(), frequency);
+ }
+ }
+ }
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ return frequencyMap;
+ }
+
+ protected void importBenthosWeights(File file,
+ FishingOperation operation,
+ CatchWeightsRowModel weightsModel,
+ Map<String, Object> notImportedData) {
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, WEIGHTS_FILE),
+ n_("tutti.service.multipost.import.weights.error"));
+
+ try {
+ Import<CatchWeightsRow> importer = Import.newImport(weightsModel, reader);
+
+ try {
+ Iterator<CatchWeightsRow> iterator = importer.iterator();
+ if (iterator.hasNext()) {
+ CatchWeightsRow row = iterator.next();
+ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId());
+ catchBatch.setFishingOperation(operation);
+
+ if (catchBatch.getBenthosTotalSortedWeight() == null) {
+ catchBatch.setBenthosTotalSortedWeight(row.getTotalSortedWeight());
+
+ } else if (row.getTotalSortedWeight() != null) {
+ notImportedData.put(CatchBatch.PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT, row.getTotalSortedWeight());
+ }
+
+ if (catchBatch.getBenthosTotalInertWeight() == null) {
+ catchBatch.setBenthosTotalInertWeight(row.getInertWeight());
+
+ } else if (row.getInertWeight() != null) {
+ notImportedData.put(CatchBatch.PROPERTY_BENTHOS_TOTAL_INERT_WEIGHT, row.getInertWeight());
+ }
+
+ if (catchBatch.getBenthosTotalLivingNotItemizedWeight() == null) {
+ catchBatch.setBenthosTotalLivingNotItemizedWeight(row.getLivingNotItemizedWeight());
+
+ } else if (row.getLivingNotItemizedWeight() != null) {
+ notImportedData.put(CatchBatch.PROPERTY_BENTHOS_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT,
+ row.getLivingNotItemizedWeight());
+ }
+
+ persistenceService.saveCatchBatch(catchBatch);
+ }
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Import Marine litter --//
+ //------------------------------------------------------------------------//
+
+ /**
+ * Import marine litter batches from a satellite post
+ *
+ * @param file the file to import the batches from
+ * @param operation the operation in which to add the batches
+ * @return the list of the marine litter which have not been imported, because there were concurrent batches
+ */
+ public Map<String, Object> importMarineLitter(File file, FishingOperation operation) {
+
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
+
+ //check operation
+ MarineLitterWeightRowModel weightModel = new MarineLitterWeightRowModel(csvSeparator);
+ checkSameOperation(tempDir, weightModel, operation);
+
+ String operationId = operation.getId();
+
+ Map<String, Object> notImportedData = Maps.newHashMap();
+ final Map<String, MarineLitterBatch> notImportedBatches = Maps.newLinkedHashMap();
+
+ BatchContainer<MarineLitterBatch> marineLitterBatches =
+ persistenceService.getRootMarineLitterBatch(operationId);
+ List<CaracteristicQualitativeValue> categoryValues =
+ persistenceService.getMarineLitterCategoryCaracteristic().getQualitativeValue();
+ List<CaracteristicQualitativeValue> sizeCategoryValues =
+ persistenceService.getMarineLitterSizeCategoryCaracteristic().getQualitativeValue();
+
+ // Import batches
+ // map containing the batches by their persistence id
+ final Map<String, MarineLitterBatch> batches = importMarineLitterBatches(
+ tempDir,
+ operation,
+ categoryValues,
+ sizeCategoryValues,
+ marineLitterBatches,
+ notImportedBatches);
+
+ // Import attachments
+
+ importAttachments(tempDir,
+ batches,
+ notImportedBatches,
+ AttachementObjectTypeEnum.BATCH);
+
+ // Import weights
+
+ importMarineLitterCatchWeights(tempDir,
+ operation,
+ weightModel,
+ notImportedData);
+
+ notImportedData.put(BATCHES_KEY, notImportedBatches.values());
+ return notImportedData;
+ }
+
+ protected Map<String, MarineLitterBatch> importMarineLitterBatches(File file, FishingOperation operation,
+ List<CaracteristicQualitativeValue> categoryValues,
+ List<CaracteristicQualitativeValue> sizeCategoryValues,
+ BatchContainer<MarineLitterBatch> marineLitterBatches,
+ Map<String, MarineLitterBatch> notImportedBatches) {
+
+ Map<String, MarineLitterBatch> batches = Maps.newLinkedHashMap();
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, MARINE_LITTER_FILE),
+ n_("tutti.service.multipost.import.batches.error"));
+
+ try {
+
+ MarineLitterRowModel csvModel = new MarineLitterRowModel(csvSeparator,
+ categoryValues,
+ sizeCategoryValues);
+
+ Import<MarineLitterRow> importer = Import.newImport(csvModel, reader);
+
+ try {
+ for (MarineLitterRow row : importer) {
+
+ // create batch
+ MarineLitterBatch batch = TuttiBeanFactory.newMarineLitterBatch();
+ batch.setFishingOperation(operation);
+
+ batch.setWeight(row.getWeight());
+ batch.setNumber(row.getNumber());
+ batch.setComment(row.getComment());
+ batch.setMarineLitterCategory(row.getCategory());
+ batch.setMarineLitterSizeCategory(row.getSizeCategory());
+
+ MarineLitterBatch existingBatch = null;
+ List<MarineLitterBatch> batchesToBrowse = marineLitterBatches.getChildren();
+
+ // check if the parent has already a batch with the caracteristic value
+ // and if the children batch are categorized with the same caracterstic
+ if (batchesToBrowse != null) {
+ for (MarineLitterBatch mlb : batchesToBrowse) {
+ if (mlb.getMarineLitterCategory().equals(batch.getMarineLitterCategory())
+ && mlb.getMarineLitterSizeCategory().equals(batch.getMarineLitterSizeCategory())) {
+
+ existingBatch = mlb;
+ batches.put(row.getBatchId(), mlb);
+ notImportedBatches.put(row.getBatchId(), batch);
+ break;
+ }
+ }
+ }
+
+ if (existingBatch == null) {
+ batch = persistenceService.createMarineLitterBatch(batch);
+ batches.put(row.getBatchId(), batch);
+ }
+
+ }
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ return batches;
+ }
+
+ protected void importMarineLitterCatchWeights(File file,
+ FishingOperation operation,
+ MarineLitterWeightRowModel weightModel,
+ Map<String, Object> notImportedData) {
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, WEIGHTS_FILE),
+ n_("tutti.service.multipost.import.weights.error"));
+
+ Import<MarineLitterWeightRow> weight = Import.newImport(weightModel, reader);
+
+ Iterator<MarineLitterWeightRow> iterator = weight.iterator();
+ if (iterator.hasNext()) {
+ MarineLitterWeightRow row = iterator.next();
+ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId());
+ catchBatch.setFishingOperation(operation);
+
+ if (catchBatch.getMarineLitterTotalWeight() == null) {
+ catchBatch.setMarineLitterTotalWeight(row.getTotalWeight());
+
+ } else if (row.getTotalWeight() != null) {
+ notImportedData.put(CatchBatch.PROPERTY_MARINE_LITTER_TOTAL_WEIGHT, row.getTotalWeight());
+ }
+
+ persistenceService.saveCatchBatch(catchBatch);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Import individual observations --//
+ //------------------------------------------------------------------------//
+
+ /**
+ * Import individual observation batches from a satellite post
+ *
+ * @param file the file to import the batches from
+ * @param operation the operation in which to add the batches
+ */
+ public void importIndividualObservation(File file, FishingOperation operation) {
+
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
+
+ //check operation
+ FishingOperationRowModel operationModel =
+ new FishingOperationRowModel(csvSeparator);
+ checkSameOperation(tempDir, operationModel, operation);
+
+ TuttiDataContext dataContext = context.getDataContext();
+ List<Species> speciesList = dataContext.getReferentSpecies();
+ List<Caracteristic> caracteristics = dataContext.getCaracteristicWithProtected();
+
+ // Import batches
+ // map containing the batches by their persistence id
+ final Map<String, IndividualObservationBatch> batches = importIndividualObservationBatches(
+ tempDir,
+ operation,
+ speciesList,
+ caracteristics);
+
+ // Import caracteristics
+
+ importIndividualObservationCaracteristics(file, batches, caracteristics);
+
+ // Persist batches
+
+ for (IndividualObservationBatch batch : batches.values()) {
+ persistenceService.createIndividualObservationBatch(batch);
+ }
+
+ // Import attachments
+
+ importAttachments(tempDir, batches, AttachementObjectTypeEnum.SAMPLE);
+ }
+
+ protected Map<String, IndividualObservationBatch> importIndividualObservationBatches(File file, FishingOperation operation,
+ List<Species> speciesList,
+ List<Caracteristic> caracteristics) {
+
+ Map<String, IndividualObservationBatch> batches = Maps.newLinkedHashMap();
+
+
+ IndividualObservationRowModel csvModel = new IndividualObservationRowModel(csvSeparator,
+ speciesList,
+ caracteristics);
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, INDIVIDUAL_OBSERVATION_FILE),
+ n_("tutti.service.multipost.import.batches.error"));
+
+ try {
+ Import<IndividualObservationRow> importer = Import.newImport(csvModel, reader);
+
+ try {
+ for (IndividualObservationRow row : importer) {
+
+ // create batch
+ IndividualObservationBatch batch =
+ TuttiBeanFactory.newIndividualObservationBatch();
+ batch.setFishingOperation(operation);
+
+ batch.setSpecies(row.getSpecies());
+ batch.setWeight(row.getWeight());
+ batch.setSize(row.getSize());
+ batch.setLengthStepCaracteristic(row.getLengthStepCaracteristic());
+ batch.setSamplingCode(row.getSamplingCode());
+ batch.setCalcifiedPieceSamplingCode(row.getCalcifiedPieceSamplingCode());
+ batch.setComment(row.getComment());
+ batch.setCaracteristics(new CaracteristicMap());
+
+ batches.put(row.getBatchId(), batch);
+ }
+
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ return batches;
+ }
+
+ protected void importIndividualObservationCaracteristics(File file, Map<String, IndividualObservationBatch> batches,
+ List<Caracteristic> caracteristics) {
+
+ CaracteristicRowModel caracteristicModel = new CaracteristicRowModel(csvSeparator,
+ caracteristics);
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, CARACTERISTIC_FILE),
+ n_("tutti.service.multipost.import.caracteristics.error"));
+
+ try {
+ Import<CaracteristicRow> importer = Import.newImport(caracteristicModel, reader);
+
+ try {
+ for (CaracteristicRow caracteristicRow : importer) {
+ IndividualObservationBatch batch = batches.get(caracteristicRow.getBatchId());
+ if (batch != null) {
+ Caracteristic caracteristic = caracteristicRow.getCaracteristic();
+ Serializable value = caracteristicRow.getValue();
+
+ switch (caracteristic.getCaracteristicType()) {
+ case QUALITATIVE:
+ value = TuttiEntities.getQualitativeValue(caracteristic, Integer.parseInt(value.toString()));
+ break;
+
+ case NUMBER:
+ value = Float.parseFloat(value.toString());
+ break;
+ }
+ CaracteristicMap map = batch.getCaracteristics();
+ map.put(caracteristic, value);
+ }
+ }
+
+ TuttiIOUtil.close(importer, "Could not close importer");
+
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Import Accidental catches --//
+ //------------------------------------------------------------------------//
+
+ /**
+ * Import accidental catches batches from a satellite post
+ *
+ * @param file the file to import the batches from
+ * @param operation the operation in which to add the batches
+ */
+ public void importAccidentalCatches(File file, FishingOperation operation) {
+
+ File tempDir = TuttiIOUtil.explodeZip(
+ context.getConfig().getTmpDirectory(),
+ file,
+ n_("tutti.service.multipost.uncompress.error"));
+
+ //check operation
+ FishingOperationRowModel operationModel =
+ new FishingOperationRowModel(csvSeparator);
+ checkSameOperation(tempDir, operationModel, operation);
+
+ TuttiDataContext dataContext = context.getDataContext();
+ List<Species> speciesList = dataContext.getReferentSpecies();
+ List<CaracteristicQualitativeValue> genderValues = dataContext.getGenderValues();
+ List<Caracteristic> caracteristics = dataContext.getCaracteristicWithProtected();
+ List<CaracteristicQualitativeValue> dedOrAliveValues = dataContext.getDeadOrAliveValues();
+
+ // Import batches
+ // map containing the batches by their persistence id
+ final Map<String, AccidentalBatch> batches = importAccidentalCatchesBatches(
+ tempDir,
+ operation,
+ speciesList,
+ genderValues,
+ caracteristics,
+ dedOrAliveValues
+ );
+
+ // Import caracteristics
+
+ importAccidentalCatchesCaracteristics(file, batches, caracteristics);
+
+ // Persist batches
+
+ for (AccidentalBatch batch : batches.values()) {
+ persistenceService.createAccidentalBatch(batch);
+ }
+
+ // Import attachments
+
+ importAttachments(tempDir, batches, AttachementObjectTypeEnum.SAMPLE);
+ }
+
+ protected Map<String, AccidentalBatch> importAccidentalCatchesBatches(File file, FishingOperation operation,
+ List<Species> speciesList,
+ List<CaracteristicQualitativeValue> genderValues,
+ List<Caracteristic> caracteristics,
+ List<CaracteristicQualitativeValue> dedOrAliveValues) {
+
+ Map<String, AccidentalBatch> batches = Maps.newLinkedHashMap();
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, INDIVIDUAL_OBSERVATION_FILE),
+ n_("tutti.service.multipost.import.batches.error"));
+
+ try {
+
+ AccidentalCatchRowModel csvModel = new AccidentalCatchRowModel(csvSeparator,
+ speciesList,
+ genderValues,
+ caracteristics,
+ dedOrAliveValues);
+
+ Import<AccidentalCatchRow> importer = Import.newImport(csvModel, reader);
+
+ try {
+ for (AccidentalCatchRow row : importer) {
+
+ // create batch
+ AccidentalBatch batch = TuttiBeanFactory.newAccidentalBatch();
+ batch.setFishingOperation(operation);
+
+ batch.setSpecies(row.getSpecies());
+ batch.setGender(row.getGender());
+ batch.setWeight(row.getWeight());
+ batch.setSize(row.getSize());
+ batch.setLengthStepCaracteristic(row.getLengthStepCaracteristic());
+ batch.setDeadOrAlive(row.getDeadOrAlive());
+ batch.setComment(row.getComment());
+ batch.setCaracteristics(new CaracteristicMap());
+
+ batches.put(row.getBatchId(), batch);
+ }
+
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ return batches;
+ }
+
+ protected void importAccidentalCatchesCaracteristics(File file, Map<String, AccidentalBatch> batches,
+ List<Caracteristic> caracteristics) {
+
+ CaracteristicRowModel caracteristicModel = new CaracteristicRowModel(csvSeparator,
+ caracteristics);
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(file, CARACTERISTIC_FILE),
+ n_("tutti.service.multipost.import.caracteristics.error"));
+
+ try {
+ Import<CaracteristicRow> importer = Import.newImport(caracteristicModel, reader);
+
+ try {
+ for (CaracteristicRow caracteristicRow : importer) {
+ AccidentalBatch batch = batches.get(caracteristicRow.getBatchId());
+ if (batch != null) {
+ Caracteristic caracteristic = caracteristicRow.getCaracteristic();
+ Serializable value = caracteristicRow.getValue();
+
+ switch (caracteristic.getCaracteristicType()) {
+ case QUALITATIVE:
+ value = TuttiEntities.getQualitativeValue(caracteristic, Integer.parseInt(value.toString()));
+ break;
+
+ case NUMBER:
+ value = Float.parseFloat(value.toString());
+ break;
+ }
+ CaracteristicMap map = batch.getCaracteristics();
+ map.put(caracteristic, value);
+ }
+ }
+
+ TuttiIOUtil.close(importer, "Could not close importer");
+
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected Pair<Integer, Serializable> getValueAndCategoryType(CatchRow row) {
+
+ Serializable value = row.getCategoryValue();
+ Integer categoryId = row.getCategoryId();
+
+ SampleCategoryModelEntry categoryModelEntry =
+ sampleCategoryModel.getCategoryById(categoryId);
+
+ Caracteristic caracteristic = categoryModelEntry.getCaracteristic();
+ if (caracteristic.getCaracteristicType() == CaracteristicType.QUALITATIVE) {
+ CaracteristicQualitativeValue caracteristicQualitativeValue = sampleCategoryValueMap.get(String.valueOf(value));
+ Preconditions.checkNotNull(caracteristicQualitativeValue, "Can't find caracteristic qualitative value with id: " + value + " for caracteristic of id: " + categoryId);
+ value = caracteristicQualitativeValue;
+ }
+ return Pair.of(categoryId, value);
+ }
+
+ protected void checkSameOperation(File directory,
+ AbstractFishingOperationRowModel fishingOperationRowModel,
+ FishingOperation operation) {
+ Reader reader = TuttiIOUtil.newReader(
+ new File(directory, WEIGHTS_FILE),
+ n_("tutti.service.multipost.import.operation.error"));
+
+ try {
+ Import<AbstractFishingOperationRow> importer = Import.<AbstractFishingOperationRow>newImport(fishingOperationRowModel, reader);
+
+ Iterator<AbstractFishingOperationRow> iterator = importer.iterator();
+ try {
+ if (iterator.hasNext()) {
+ AbstractFishingOperationRow row = iterator.next();
+ if (ObjectUtils.notEqual(row.getStationNumber(), operation.getStationNumber())
+ || ObjectUtils.notEqual(row.getOperationNumber(), operation.getFishingOperationNumber())
+ || ObjectUtils.notEqual(row.getMultirigAggregation(), operation.getMultirigAggregation())
+ || ObjectUtils.notEqual(row.getDate(), operation.getGearShootingStartDate())) {
+
+ throw new TuttiBusinessException(_("tutti.service.multipost.import.wrongOperation.error",
+ decoratorService.getDecoratorByType(FishingOperation.class)
+ .toString(operation)));
+ }
+ }
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+ protected <R extends TuttiEntity> void importAttachments(File directory,
+ final Map<String, R> data,
+ final Map<String, R> notImportedData,
+ AttachementObjectTypeEnum objectType) {
+
+ Function<AttachmentRow, Integer> getObjetcIdFunction = new Function<AttachmentRow, Integer>() {
+ @Override
+ public Integer apply(AttachmentRow input) {
+ Integer result = null;
+ if (notImportedData.get(input.getBatchId()) == null) {
+ R batch = data.get(input.getBatchId());
+ if (batch != null) {
+ result = batch.getIdAsInt();
+ }
+ }
+ return result;
+ }
+ };
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(directory, ATTACHMENTS_FILE),
+ n_("tutti.service.multipost.import.attachments.error"));
+
+ try {
+ AttachmentRowModel attachmentModel =
+ new AttachmentRowModel(csvSeparator, new File(directory, ATTACHMENTS_DIRECTORY));
+ Import<AttachmentRow> importer = Import.newImport(attachmentModel, reader);
+
+ try {
+ for (AttachmentRow row : importer) {
+ Integer objectId = getObjetcIdFunction.apply(row);
+ if (objectId != null) {
+ Attachment attachment = TuttiBeanFactory.newAttachment();
+ attachment.setName(row.getName());
+ attachment.setComment(row.getComment());
+ attachment.setObjectType(objectType);
+
+ attachment.setObjectId(objectId);
+
+ persistenceService.createAttachment(attachment, row.getFile());
+ }
+ }
+
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+ protected <R extends TuttiEntity> void importAttachments(File directory,
+ final Map<String, R> data,
+ AttachementObjectTypeEnum objectType) {
+
+ Function<AttachmentRow, Integer> getObjetcIdFunction = new Function<AttachmentRow, Integer>() {
+ @Override
+ public Integer apply(AttachmentRow input) {
+ Integer result = null;
+ R batch = data.get(input.getBatchId());
+ if (batch != null) {
+ result = batch.getIdAsInt();
+ }
+ return result;
+ }
+ };
+
+ Reader reader = TuttiIOUtil.newReader(
+ new File(directory, ATTACHMENTS_FILE),
+ n_("tutti.service.multipost.import.attachments.error"));
+
+ try {
+ AttachmentRowModel attachmentModel =
+ new AttachmentRowModel(csvSeparator, new File(directory, ATTACHMENTS_DIRECTORY));
+ Import<AttachmentRow> importer = Import.newImport(attachmentModel, reader);
+
+ try {
+ for (AttachmentRow row : importer) {
+ Integer objectId = getObjetcIdFunction.apply(row);
+ if (objectId != null) {
+ Attachment attachment = TuttiBeanFactory.newAttachment();
+ attachment.setName(row.getName());
+ attachment.setComment(row.getComment());
+ attachment.setObjectType(objectType);
+
+ attachment.setObjectId(objectId);
+
+ persistenceService.createAttachment(attachment, row.getFile());
+ }
+ }
+
+ TuttiIOUtil.close(importer, "Could not close importer");
+ } finally {
+ IOUtils.closeQuietly(importer);
+ }
+
+ TuttiIOUtil.close(reader, "Could not close reader");
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+}
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-07-30 17:22:49 UTC (rev 1161)
@@ -81,10 +81,12 @@
tutti.service.exportSumatra.header.weight=
tutti.service.mkDir.error=
tutti.service.multipost.attachment.copy.error=
+tutti.service.multipost.attachment.mkdirDir.error=
tutti.service.multipost.export.attachments.error=
tutti.service.multipost.export.batches.error=
tutti.service.multipost.export.deleteTempDirectory.error=
tutti.service.multipost.export.error=
+tutti.service.multipost.export.file.writer.error=
tutti.service.multipost.export.frequencies.error=
tutti.service.multipost.export.operation.error=
tutti.service.multipost.export.weight.error=
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-07-30 17:22:49 UTC (rev 1161)
@@ -81,10 +81,13 @@
tutti.service.exportSumatra.header.weight=Total
tutti.service.mkDir.error=Erreur à la création du dossier %s
tutti.service.multipost.attachment.copy.error=Erreur lors de l'export de la pièce-jointe %s
+tutti.service.multipost.attachment.mkdir.error=Impossible de créer le répertoire %s
+tutti.service.multipost.attachment.mkdirDir.error=
tutti.service.multipost.export.attachments.error=Erreur lors de l'export des pièces-jointes
tutti.service.multipost.export.batches.error=Erreur lors de l'export des lots
tutti.service.multipost.export.deleteTempDirectory.error=Erreur lors de la suppression du dossier temporaire
tutti.service.multipost.export.error=Erreur lors de la création du fichier d'export
+tutti.service.multipost.export.file.writer.error=Erreur à la création du fichier %s
tutti.service.multipost.export.frequencies.error=Erreur lors de l'export des mensurations
tutti.service.multipost.export.operation.error=Erreur lors de l'export des données du trait
tutti.service.multipost.export.weight.error=Erreur lors de l'export des poids
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -25,7 +25,9 @@
*/
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import com.google.common.io.Files;
+import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.RessourceClassLoader;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfigOption;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
@@ -40,6 +42,7 @@
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
@@ -51,6 +54,7 @@
import java.io.IOException;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
/**
* TODO
@@ -63,6 +67,26 @@
/** Logger. */
private static final Log log = LogFactory.getLog(ServiceDbResource.class);
+ public void assertZipContent(String message,
+ File zipFile,
+ Pair<String, String>... entryAndExpectedContent) throws IOException {
+ Assert.assertTrue(zipFile.exists());
+
+ File explodeDir = TuttiIOUtil.explodeZip(
+ getServiceConfig().getTmpDirectory(),
+ zipFile,
+ "could not explode archive zip");
+ for (Pair<String, String> stringStringPair : entryAndExpectedContent) {
+ String entry = stringStringPair.getKey();
+ File explodeFile = new File(explodeDir, entry);
+ Assert.assertTrue(zipFile.exists());
+
+ String expectedContent = stringStringPair.getValue();
+
+ assertFileContent(message + " - " + entry + "\n", explodeFile, expectedContent);
+ }
+ }
+
public static void assertFileContent(String message,
File actualFile,
String expectedContent) throws IOException {
@@ -78,7 +102,21 @@
protected TuttiServiceContext createServiceContext(RessourceClassLoader loader,
TuttiServiceConfig config) {
- return new TuttiServiceContext(loader, config);
+ return new TuttiServiceContext(loader, config) {
+
+ Map<Class<?>, Integer> counts = Maps.newHashMap();
+
+ @Override
+ public String generateId(Class<?> type) {
+ Integer count = counts.get(type);
+ if (count == null) {
+ count = 0;
+ }
+ count++;
+ counts.put(type, count);
+ return type.getSimpleName() + "_" + count;
+ }
+ };
}
@Override
Added: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportServiceTest.java (rev 0)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportServiceTest.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -0,0 +1,259 @@
+package fr.ifremer.tutti.service.catches.multipost;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.io.Files;
+import fr.ifremer.tutti.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.apache.commons.lang3.tuple.Pair;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import java.io.File;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class TuttiMultiPostExportServiceTest {
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.readDb("dbCGFS");
+
+ public static final String PROGRAM_ID = "CAM-CGFS";
+
+ public static final String CRUISE_ID = "100001";
+
+ public static final String CRUISE_CGFS_ID = "100000";
+
+ public static final String OPERATION_1_ID = "100106";
+
+ public static final String OPERATION_2_ID = "100107";
+
+ public static final String SPECIES_CONTENT = "id;parentId;species;categoryId;categoryValue;categoryWeight;weight;number;comment;toConfirm\n" +
+ "CatchRow_1;;11242;1428;311;100.0;;;;N;\n" +
+ "CatchRow_2;CatchRow_1;11242;198;305;80.0;;;;N;\n" +
+ "CatchRow_3;CatchRow_2;11242;196;300;30.0;;;;N;\n" +
+ "CatchRow_4;CatchRow_3;11242;174;272;10.0;5.0;;;N;\n" +
+ "CatchRow_5;CatchRow_3;11242;174;274;10.0;;;;N;\n" +
+ "CatchRow_6;CatchRow_2;11242;196;301;50.0;30.0;;;N;\n" +
+ "CatchRow_7;CatchRow_1;11242;198;306;20.0;;;;N;\n" +
+ "CatchRow_8;;11242;1428;310;20.0;;2;;N;";
+
+ public static final String SPECIES_FREQUENCIES_CONTENT = "batchId;lengthStepCaracteristic;lengthStep;number;weight\n" +
+ "CatchRow_4;307;10.0;5;;\n" +
+ "CatchRow_4;307;10.5;2;;\n" +
+ "CatchRow_4;307;11.0;1;;\n" +
+ "CatchRow_5;307;11.0;5;;\n" +
+ "CatchRow_6;1425;10.0;5;;\n" +
+ "CatchRow_6;1425;11.0;6;;\n" +
+ "CatchRow_6;1425;12.0;7;;";
+
+ public static final String SPECIES_WEIGHTS_CONTENT = "stationNumber;operationNumber;multirigAggregation;date;totalSortedWeight;inertWeight;livingNotItemizedWeight\n" +
+ "A;1;1;01/05/2013 00:00;;;;";
+
+ public static final String SPECIES_ATTACHMENT_CONTENT = "batchId;name;comment;file";
+
+
+ public static final String BENTHOS_CONTENT = "id;parentId;species;categoryId;categoryValue;categoryWeight;weight;number;comment;toConfirm";
+
+ public static final String BENTHOS_FREQUENCIES_CONTENT = "batchId;lengthStepCaracteristic;lengthStep;number;weight";
+
+ public static final String BENTHOS_WEIGHTS_CONTENT = "stationNumber;operationNumber;multirigAggregation;date;totalSortedWeight;inertWeight;livingNotItemizedWeight\n" +
+ "A;1;1;01/05/2013 00:00;;;;";
+
+ public static final String BENTHOS_ATTACHMENT_CONTENT = "batchId;name;comment;file";
+
+ public static final String MARINE_LITTER_CONTENT = "batchId;category;sizeCategory;number;weight;comment\n" +
+ "MarineLitterRow_1;2119;2120;2;5.0;S1;\n" +
+ "MarineLitterRow_2;2126;2121;3;1.0;S2;";
+
+ public static final String MARINE_LITTER_WEIGHTS_CONTENT = "stationNumber;operationNumber;multirigAggregation;date;totalWeight\n" +
+ "A;1;1;01/05/2013 00:00;;";
+
+ public static final String ACCIDENTAL_CATCH_CONTENT = "batchId;species;gender;weight;size;lengthStepCaracteristic;deadOrAlive;comment\n" +
+ "AccidentalCatchRow_1;3835;301;10.0;4.0;1425;1769;;";
+
+ public static final String ACCIDENTAL_CATCH_WEIGHTS_CONTENT = "stationNumber;operationNumber;multirigAggregation;date\n" +
+ "A;1;1;01/05/2013 00:00;";
+
+ public static final String ACCIDENTAL_CATCH_CARACTERISTIC_CONTENT = "batchId;caracteristic;value";
+
+ public static final String ACCIDENTAL_CATCH_ATTACHMENT_CONTENT = "batchId;name;comment;file";
+
+ public static final String INDIVIDUAL_OBSERVATION_CONTENT = "batchId;species;weight;size;lengthStepCaracteristic;samplingCode;calcifiedPieceSamplingCode;comment\n" +
+ "IndividualObservationRow_1;11242;0.1;10.0;307;A20;10;P1;";
+
+ public static final String INDIVIDUAL_OBSERVATION_CARACTERISTIC_CONTENT = "batchId;caracteristic;value\n" +
+ "IndividualObservationRow_1;101;10.0;\n" +
+ "IndividualObservationRow_1;46;168;\n" +
+ "IndividualObservationRow_1;1388;5.0;";
+
+ public static final String INDIVIDUAL_OBSERVATION_WEIGHTS_CONTENT = "stationNumber;operationNumber;multirigAggregation;date\n" +
+ "A;1;1;01/05/2013 00:00;";
+
+ public static final String MARINE_LITTER_ATTACHMENT_CONTENT = "batchId;name;comment;file";
+
+ public static final String INDIVIDUAL_OBSERVATION_ATTACHMENT_CONTENT = "batchId;name;comment;file";
+
+ protected TuttiMultiPostExportService service;
+
+ protected ServiceDbResource.DataContext dataContext;
+
+ protected File dataDirectory;
+
+ @Before
+ public void setUp() throws Exception {
+
+ dataDirectory = dbResource.getServiceConfig().getDataDirectory();
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ dbResource.openDataContext();
+
+ service = serviceContext.getService(TuttiMultiPostExportService.class);
+
+ dataContext = dbResource.loadContext(PROGRAM_ID,
+ CRUISE_ID,
+ 2,
+ OPERATION_1_ID,
+ OPERATION_2_ID);
+ }
+
+ @Test
+ public void testExportSpecies() throws Exception {
+
+ File exportFile = new File(dataDirectory,
+ "exportSpecies.zip");
+
+ Files.createParentDirs(exportFile);
+
+ Assert.assertFalse(exportFile.exists());
+
+ service.exportSpecies(exportFile, dataContext.operations.get(0));
+ Assert.assertTrue(exportFile.exists());
+
+ dbResource.assertZipContent(
+ "Species export",
+ exportFile,
+ Pair.of(TuttiMultiPostExportService.FREQUENCIES_FILE, SPECIES_FREQUENCIES_CONTENT),
+ Pair.of(TuttiMultiPostExportService.SPECIES_FILE, SPECIES_CONTENT),
+ Pair.of(TuttiMultiPostExportService.WEIGHTS_FILE, SPECIES_WEIGHTS_CONTENT),
+ Pair.of(TuttiMultiPostExportService.ATTACHMENTS_FILE, SPECIES_ATTACHMENT_CONTENT)
+ );
+
+ }
+
+ @Test
+ public void testExportBenthos() throws Exception {
+ File exportFile = new File(dataDirectory,
+ "exportBenthos.zip");
+
+ Files.createParentDirs(exportFile);
+
+ Assert.assertFalse(exportFile.exists());
+
+ service.exportBenthos(exportFile, dataContext.operations.get(0));
+ Assert.assertTrue(exportFile.exists());
+
+ dbResource.assertZipContent(
+ "Benthos export",
+ exportFile,
+ Pair.of(TuttiMultiPostExportService.FREQUENCIES_FILE, BENTHOS_FREQUENCIES_CONTENT),
+ Pair.of(TuttiMultiPostExportService.BENTHOS_FILE, BENTHOS_CONTENT),
+ Pair.of(TuttiMultiPostExportService.WEIGHTS_FILE, BENTHOS_WEIGHTS_CONTENT),
+ Pair.of(TuttiMultiPostExportService.ATTACHMENTS_FILE, BENTHOS_ATTACHMENT_CONTENT)
+
+ );
+ }
+
+ @Test
+ public void testExportMarineLitter() throws Exception {
+ File exportFile = new File(dataDirectory,
+ "exportMarineLitter.zip");
+
+ Files.createParentDirs(exportFile);
+
+ Assert.assertFalse(exportFile.exists());
+
+ service.exportMarineLitter(exportFile, dataContext.operations.get(0));
+ Assert.assertTrue(exportFile.exists());
+
+ dbResource.assertZipContent(
+ "MarineLitter export",
+ exportFile,
+ Pair.of(TuttiMultiPostExportService.MARINE_LITTER_FILE, MARINE_LITTER_CONTENT),
+ Pair.of(TuttiMultiPostExportService.WEIGHTS_FILE, MARINE_LITTER_WEIGHTS_CONTENT),
+ Pair.of(TuttiMultiPostExportService.ATTACHMENTS_FILE, MARINE_LITTER_ATTACHMENT_CONTENT)
+ );
+ }
+
+ @Test
+ public void testExportIndividualObservation() throws Exception {
+ File exportFile = new File(dataDirectory,
+ "exportIndividualObservation.zip");
+
+ Files.createParentDirs(exportFile);
+
+ Assert.assertFalse(exportFile.exists());
+
+ service.exportIndividualObservation(exportFile, dataContext.operations.get(0));
+ Assert.assertTrue(exportFile.exists());
+
+ dbResource.assertZipContent(
+ "IndividualObservation export",
+ exportFile,
+ Pair.of(TuttiMultiPostExportService.INDIVIDUAL_OBSERVATION_FILE, INDIVIDUAL_OBSERVATION_CONTENT),
+ Pair.of(TuttiMultiPostExportService.CARACTERISTIC_FILE, INDIVIDUAL_OBSERVATION_CARACTERISTIC_CONTENT),
+ Pair.of(TuttiMultiPostExportService.WEIGHTS_FILE, INDIVIDUAL_OBSERVATION_WEIGHTS_CONTENT),
+ Pair.of(TuttiMultiPostExportService.ATTACHMENTS_FILE, INDIVIDUAL_OBSERVATION_ATTACHMENT_CONTENT)
+ );
+ }
+
+ @Test
+ public void testExportAccidentalCatch() throws Exception {
+ File exportFile = new File(dataDirectory,
+ "exportAccidentalCatch.zip");
+
+ Files.createParentDirs(exportFile);
+
+ Assert.assertFalse(exportFile.exists());
+
+ service.exportAccidentalCatch(exportFile, dataContext.operations.get(0));
+ Assert.assertTrue(exportFile.exists());
+
+ dbResource.assertZipContent(
+ "AccidentalCatch export",
+ exportFile,
+ Pair.of(TuttiMultiPostExportService.ACCIDENTAL_CATCHES_FILE, ACCIDENTAL_CATCH_CONTENT),
+ Pair.of(TuttiMultiPostExportService.WEIGHTS_FILE, ACCIDENTAL_CATCH_WEIGHTS_CONTENT),
+ Pair.of(TuttiMultiPostExportService.CARACTERISTIC_FILE, ACCIDENTAL_CATCH_CARACTERISTIC_CONTENT),
+ Pair.of(TuttiMultiPostExportService.ATTACHMENTS_FILE, ACCIDENTAL_CATCH_ATTACHMENT_CONTENT)
+ );
+ }
+}
Property changes on: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostExportServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -40,7 +40,8 @@
import fr.ifremer.tutti.service.catches.ExportCatchesReportService;
import fr.ifremer.tutti.service.catches.TuttiWeightComputingService;
import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
-import fr.ifremer.tutti.service.catches.multipost.TuttiMultiPostImportExportService;
+import fr.ifremer.tutti.service.catches.multipost.TuttiMultiPostExportService;
+import fr.ifremer.tutti.service.catches.multipost.TuttiMultiPostImportService;
import fr.ifremer.tutti.service.export.TuttiExportService;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import fr.ifremer.tutti.service.pupitri.TuttiPupitriImportExportService;
@@ -566,10 +567,14 @@
return serviceContext.getService(TuttiCatchesSumatraExportService.class);
}
- public TuttiMultiPostImportExportService getMultiPostImportExportService() {
- return serviceContext.getService(TuttiMultiPostImportExportService.class);
+ public TuttiMultiPostImportService getMultiPostImportService() {
+ return serviceContext.getService(TuttiMultiPostImportService.class);
}
+ public TuttiMultiPostExportService getMultiPostExportService() {
+ return serviceContext.getService(TuttiMultiPostExportService.class);
+ }
+
public boolean useRealPersistenceService() {
return isDbExist() && isDbLoaded();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -26,7 +26,7 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.catches.multipost.TuttiMultiPostImportExportService;
+import fr.ifremer.tutti.service.catches.multipost.TuttiMultiPostExportService;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
@@ -45,11 +45,11 @@
protected FishingOperation currentOperation;
- protected TuttiMultiPostImportExportService multiPostImportExportService;
+ protected TuttiMultiPostExportService multiPostImportExportService;
public AbstractExportMultiPostAction(H handler) {
super(handler, false);
- multiPostImportExportService = getContext().getMultiPostImportExportService();
+ multiPostImportExportService = getContext().getMultiPostExportService();
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -25,7 +25,7 @@
*/
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.service.catches.multipost.TuttiMultiPostImportExportService;
+import fr.ifremer.tutti.service.catches.multipost.TuttiMultiPostImportService;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationAction;
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
@@ -47,11 +47,11 @@
protected EditFishingOperationAction editAction;
- protected TuttiMultiPostImportExportService multiPostImportExportService;
+ protected TuttiMultiPostImportService multiPostImportExportService;
public AbstractImportMultiPostAction(H handler) {
super(handler, false);
- multiPostImportExportService = getContext().getMultiPostImportExportService();
+ multiPostImportExportService = getContext().getMultiPostImportService();
}
public EditFishingOperationAction getEditAction() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java 2013-07-27 21:21:41 UTC (rev 1160)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java 2013-07-30 17:22:49 UTC (rev 1161)
@@ -1,5 +1,29 @@
package fr.ifremer.tutti.ui.swing.util.attachment;
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0
27 Jul '13
See <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/9…>
Changes:
[Tony Chemit] refs #2889: [TECH] - Prise en compte de nouvelles catégories dans l'applicatif (configuration des catégories)
------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti :: Persistence 2.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (2 KB at 11.4 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (2 KB at 3.0 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti-persistence ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ tutti-persistence ---
[INFO]
[INFO] --- eugene-maven-plugin:2.7:generate (default) @ tutti-persistence ---
[INFO] Process phase [zargo] for one entry.
[INFO] Expanding 1 xmi file(s) from <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Generate one file in 14.924ms.
[INFO] Process phase [xmi] for one entry.
[INFO] Processing XSL tranformation on <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> for 1 file(s).
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Generate one file in 933.39ms.
[INFO] Process phase [model] for one entry.
WARN [pool-1-thread-1] (AbstractObjectModelReader.java:126) beforeReadFile - No properties provider filled, will instanciate a new default one
WARN [pool-1-thread-1] (AbstractObjectModelReader.java:294) loadModelTagValue - Invalid model tag value [model.tagvalue.simpleBeanExtractInterface] : the tagvalue 'simpleBeanExtractInterface' is unkown.
INFO [pool-1-thread-1] (AbstractObjectModelReader.java:270) loadModelProperties - 23 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] No file generated.
[INFO] Apply generator JavaInterfaceTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:995) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.TuttiEntity], already found in class-path.
[INFO] Apply generator SimpleJavaBeanTransformer
[INFO] Apply generator JavaEnumerationTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:995) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum], already found in class-path.
[INFO] Add compile source root : <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Add resource root :Resource {targetPath: null, filtering: false, FileSet {directory: <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…,> PatternSet [includes: {}, excludes: {**/*.java}]}}
[INFO]
[INFO] --- i18n-maven-plugin:2.5.2:parserJava (scan-sources) @ tutti-persistence ---
[INFO]
[INFO] --- i18n-maven-plugin:2.5.2:get (get) @ tutti-persistence ---
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO]
[INFO] --- i18n-maven-plugin:2.5.2:gen (scan-sources) @ tutti-persistence ---
[WARNING] bundle fr_FR contains 1/54 empty entries! (use -Di18n.showEmpty to see these entries)
[WARNING] bundle en_GB contains 54/54 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tutti-persistence ---
[INFO] Compiling 133 source files to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING] bootstrap class path not set in conjunction with -source 1.6
[WARNING] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>: Recompile with -Xlint:unchecked for details.
[INFO] 3 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[84,8] fr.ifremer.tutti.persistence.TuttiPersistenceImpl is not abstract and does not override abstract method getAllCaracteristicForSampleCategory() in fr.ifremer.tutti.persistence.TuttiPersistence
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[63,8] fr.ifremer.tutti.persistence.TuttiPersistenceNoDbImpl is not abstract and does not override abstract method getAllCaracteristicForSampleCategory() in fr.ifremer.tutti.persistence.TuttiPersistence
[INFO] 2 errors
[INFO] -------------------------------------------------------------
1
2
See <http://ci.nuiton.org/jenkins/job/tutti/948/changes>
Changes:
[Tony Chemit] refs #2889: [TECH] - Prise en compte de nouvelles catégories dans l'applicatif (configuration des catégories)
------------------------------------------
Started by an SCM change
Building on master in workspace <http://ci.nuiton.org/jenkins/job/tutti/ws/>
Updating http://svn.forge.codelutin.com/svn/tutti/trunk at revision '2013-07-27T16:01:10.586 +0200'
U tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
U tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
U tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java
AU tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
D tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUIHandler.java
D tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderIdsTableCell.java
D tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderButton.java
D tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.css
D tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.jaxx
AU tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java
AU tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java
AU tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java
AU tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java
AU tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java
AU tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx
AU tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapEditorUIHandler.java
U tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
U tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
U tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
U tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
AU tutti-ui-swing/src/main/resources/icons/action-up.png
AU tutti-ui-swing/src/main/resources/icons/action-down.png
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
At revision 1158
Parsing POMs
[trunk] $ /opt/jdk/bin/java -Xmx256m -XX:-UseGCOverheadLimit -cp /var/local/jenkins/data/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.3.jar:/opt/maven3/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /opt/maven3 /opt/repository/apache-tomcat-7.0.42/webapps/jenkins/WEB-INF/lib/remoting-2.28.jar /var/local/jenkins/data/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.3.jar 59287
<===[JENKINS REMOTING CAPACITY]===> channel started
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven: -B -f <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml> -U -e clean install
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Tutti
[INFO] Tutti :: Persistence
[INFO] Tutti :: Service
[INFO] Tutti :: UI
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti 2.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ tutti ---
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ tutti ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/surefire-workdir>
[INFO] Executed tasks
[INFO]
[INFO] --- maven-site-plugin:3.3:attach-descriptor (attach-descriptor) @ tutti ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ tutti ---
[INFO] Installing <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml> to /var/local/maven/data/repository/fr/ifremer/tutti/2.4-SNAPSHOT/tutti-2.4-SNAPSHOT.pom
[INFO] Installing <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/tutti-2.4-SNAPSHOT-s…> to /var/local/maven/data/repository/fr/ifremer/tutti/2.4-SNAPSHOT/tutti-2.4-SNAPSHOT-site_fr.xml
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti :: Persistence 2.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (2 KB at 11.4 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (2 KB at 3.0 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti-persistence ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target>
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (check-project-files) @ tutti-persistence ---
[INFO]
[INFO] --- eugene-maven-plugin:2.7:generate (default) @ tutti-persistence ---
[INFO] Process phase [zargo] for one entry.
[INFO] Expanding 1 xmi file(s) from <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…> to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Generate one file in 14.924ms.
[INFO] Process phase [xmi] for one entry.
[INFO] Processing XSL tranformation on <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…> for 1 file(s).
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…> to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Generate one file in 933.39ms.
[INFO] Process phase [model] for one entry.
WARN [pool-1-thread-1] (AbstractObjectModelReader.java:126) beforeReadFile - No properties provider filled, will instanciate a new default one
WARN [pool-1-thread-1] (AbstractObjectModelReader.java:294) loadModelTagValue - Invalid model tag value [model.tagvalue.simpleBeanExtractInterface] : the tagvalue 'simpleBeanExtractInterface' is unkown.
INFO [pool-1-thread-1] (AbstractObjectModelReader.java:270) loadModelProperties - 23 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] No file generated.
[INFO] Apply generator JavaInterfaceTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:995) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.TuttiEntity], already found in class-path.
[INFO] Apply generator SimpleJavaBeanTransformer
[INFO] Apply generator JavaEnumerationTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:995) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum], already found in class-path.
[INFO] Add compile source root : <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Add resource root :Resource {targetPath: null, filtering: false, FileSet {directory: <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…,> PatternSet [includes: {}, excludes: {**/*.java}]}}
[INFO]
[INFO] --- i18n-maven-plugin:2.5.2:parserJava (scan-sources) @ tutti-persistence ---
[INFO]
[INFO] --- i18n-maven-plugin:2.5.2:get (get) @ tutti-persistence ---
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO]
[INFO] --- i18n-maven-plugin:2.5.2:gen (scan-sources) @ tutti-persistence ---
[WARNING] bundle fr_FR contains 1/54 empty entries! (use -Di18n.showEmpty to see these entries)
[WARNING] bundle en_GB contains 54/54 empty entries! (use -Di18n.showEmpty to see these entries)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ tutti-persistence ---
[INFO] Compiling 133 source files to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/cl…>
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING] bootstrap class path not set in conjunction with -source 1.6
[WARNING] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>: Some input files use unchecked or unsafe operations.
[WARNING] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>: Recompile with -Xlint:unchecked for details.
[INFO] 3 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[84,8] fr.ifremer.tutti.persistence.TuttiPersistenceImpl is not abstract and does not override abstract method getAllCaracteristicForSampleCategory() in fr.ifremer.tutti.persistence.TuttiPersistence
[ERROR] <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>:[63,8] fr.ifremer.tutti.persistence.TuttiPersistenceNoDbImpl is not abstract and does not override abstract method getAllCaracteristicForSampleCategory() in fr.ifremer.tutti.persistence.TuttiPersistence
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Tutti ............................................. SUCCESS [2.367s]
[INFO] Tutti :: Persistence .............................. FAILURE [5.376s]
[INFO] Tutti :: Service .................................. SKIPPED
[INFO] Tutti :: UI ....................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.328s
[INFO] Finished at: Sat Jul 27 16:01:23 CEST 2013
[INFO] Final Memory: 35M/233M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-service/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer.tutti$tutti-service/builds/2013-07-27_16-01-13/archive/fr.ifremer.tutti/tutti-service/2.4-SNAPSHOT/tutti-service-2.4-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-ui-swing/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer.tutti$tutti-ui-swing/builds/2013-07-27_16-01-13/archive/fr.ifremer.tutti/tutti-ui-swing/2.4-SNAPSHOT/tutti-ui-swing-2.4-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer$tutti/builds/2013-07-27_16-01-13/archive/fr.ifremer/tutti/2.4-SNAPSHOT/tutti-2.4-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/tutti-2.4-SNAPSHOT-s…> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer$tutti/builds/2013-07-27_16-01-13/archive/fr.ifremer/tutti/2.4-SNAPSHOT/tutti-2.4-SNAPSHOT-site_fr.xml
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer.tutti$tutti-persistence/builds/2013-07-27_16-01-13/archive/fr.ifremer.tutti/tutti-persistence/2.4-SNAPSHOT/tutti-persistence-2.4-SNAPSHOT.pom
Waiting for Jenkins to finish collecting data
mavenExecutionResult exceptions not empty
message : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project tutti-persistence: Compilation failure
cause : Compilation failure
Stack trace :
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project tutti-persistence: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:174)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 27 more
Sending e-mails to: tutti-commits(a)list.forge.codelutin.com chemit(a)codelutin.com
channel stopped
1
2
27 Jul '13
Author: tchemit
Date: 2013-07-27 23:21:41 +0200 (Sat, 27 Jul 2013)
New Revision: 1160
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1160
Log:
reformat code
improve action common code
refs #2889: [TECH] - Prise en compte de nouvelles cat?\195?\169gories dans l'applicatif (check a edit/clone/import protocol)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/SaveSampleCategoryModelAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java
Modified:
trunk/tutti-persistence/pom.xml
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiIOUtil.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportCruiseValidationMessagesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportOperationValidationMessagesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/DeleteFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ImportMultiPostAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToPreviousEditableCellAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToPreviousEditableRowAction.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/pom.xml
===================================================================
--- trunk/tutti-persistence/pom.xml 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-persistence/pom.xml 2013-07-27 21:21:41 UTC (rev 1160)
@@ -56,6 +56,11 @@
<dependency>
<groupId>org.nuiton</groupId>
+ <artifactId>nuiton-decorator</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.nuiton</groupId>
<artifactId>nuiton-updater</artifactId>
</dependency>
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiIOUtil.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiIOUtil.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiIOUtil.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -168,14 +168,18 @@
}
}
- public static File addExtensionIfMissing(File file, String extension) {
- if (!file.getName().endsWith(extension)) {
- file = new File(file.getParentFile(), file.getName() + extension);
- }
- return file;
+// public static File addExtensionIfMissing(File file, String extension) {
+// if (!file.getName().endsWith(extension)) {
+// file = new File(file.getParentFile(), file.getName() + extension);
+// }
+// return file;
+// }
+
+ public static String getBaseName(String file) {
+ return FilenameUtils.getBaseName(file);
}
- public static String getExtension(File file) {
- return FilenameUtils.getExtension(file.getName());
+ public static String getExtension(String file) {
+ return FilenameUtils.getExtension(file);
}
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -301,6 +301,11 @@
}
@Override
+ public List<Caracteristic> getAllCaracteristicForSampleCategory() {
+ return referentialService.getAllCaracteristicForSampleCategory();
+ }
+
+ @Override
public List<Caracteristic> getAllNumericCaracteristic() {
return referentialService.getAllNumericCaracteristic();
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/protocol/TuttiProtocols.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -28,22 +28,29 @@
import com.esotericsoftware.yamlbeans.YamlReader;
import com.esotericsoftware.yamlbeans.YamlWriter;
import com.google.common.base.Charsets;
+import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.io.Files;
import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.persistence.TuttiPersistence;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.v1.SpeciesProtocol1;
import fr.ifremer.tutti.persistence.entities.protocol.v1.SpeciesProtocolBean1;
import fr.ifremer.tutti.persistence.entities.protocol.v1.TuttiProtocol1;
import fr.ifremer.tutti.persistence.entities.protocol.v1.TuttiProtocolBean1;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.decorator.Decorator;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
@@ -51,6 +58,7 @@
import java.io.File;
import java.io.Reader;
import java.util.List;
+import java.util.Set;
import static org.nuiton.i18n.I18n._;
@@ -62,6 +70,9 @@
*/
public class TuttiProtocols {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(TuttiProtocols.class);
+
public static void toFile(TuttiProtocol protocol, File file) {
String id = protocol.getId();
@@ -142,6 +153,71 @@
}
}
+ public static void checkSampleCategories(SampleCategoryModel sampleCategoryModel,
+ TuttiProtocol protocol,
+ Set<Integer> badCategories) {
+
+ if (CollectionUtils.isNotEmpty(protocol.getSpecies())) {
+ for (SpeciesProtocol entry : protocol.getSpecies()) {
+ List<Integer> mandatorySampleCategoryId = entry.getMandatorySampleCategoryId();
+ for (Integer categoryId : mandatorySampleCategoryId) {
+ if (!sampleCategoryModel.containsCategoryId(categoryId)) {
+ badCategories.add(categoryId);
+ }
+ }
+ }
+ }
+ if (CollectionUtils.isNotEmpty(protocol.getBenthos())) {
+ for (SpeciesProtocol entry : protocol.getBenthos()) {
+ List<Integer> mandatorySampleCategoryId = entry.getMandatorySampleCategoryId();
+ for (Integer categoryId : mandatorySampleCategoryId) {
+ if (!sampleCategoryModel.containsCategoryId(categoryId)) {
+ badCategories.add(categoryId);
+ }
+ }
+ }
+ }
+ }
+
+ public static void removeBadCategories(SampleCategoryModel sampleCategoryModel, TuttiProtocol protocol) {
+ List<Integer> samplingOrder = sampleCategoryModel.getSamplingOrder();
+ if (!protocol.isSpeciesEmpty()) {
+
+ for (SpeciesProtocol entry : protocol.getSpecies()) {
+ entry.getMandatorySampleCategoryId().retainAll(samplingOrder);
+ }
+ }
+
+ if (!protocol.isBenthosEmpty()) {
+
+ for (SpeciesProtocol entry : protocol.getBenthos()) {
+ entry.getMandatorySampleCategoryId().retainAll(samplingOrder);
+ }
+ }
+ }
+
+ public static String getBadCategoriesMessage(Set<Integer> badCategories,
+ Decorator<Caracteristic> decorator,
+ TuttiPersistence persistenceService) {
+ List<String> badCategoriesStr = Lists.newArrayList();
+
+ for (Integer id : badCategories) {
+ String caracteristicStr;
+ try {
+ Caracteristic caracteristic = persistenceService.getCaracteristic(id);
+ caracteristicStr = decorator.toString(caracteristic);
+ } catch (NullPointerException e) {
+ if (log.isWarnEnabled()) {
+ log.warn("Could not find caracteristic with id: " + id);
+ }
+ caracteristicStr = _("tutti.common.caracteristic.notFound");
+ }
+ badCategoriesStr.add("<li>" + id + " : " + caracteristicStr + "</li>");
+ }
+ String message = _("tutti.common.protocol.categories.not.compatible", Joiner.on("").join(badCategoriesStr));
+ return message;
+ }
+
protected static TuttiProtocol fromTuttiProtocol1(TuttiEnumerationFile enumeration, TuttiProtocol1 tuttiProtocol1) {
TuttiProtocol result = TuttiBeanFactory.newTuttiProtocol();
Binder<TuttiProtocol1, TuttiProtocol> binder = BinderFactory.newBinder(TuttiProtocol1.class, TuttiProtocol.class);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -166,7 +166,7 @@
measurementFile.getObjectType().getCode(),
measurementFile.getObjectId(),
measurementFile.getId(),
- TuttiIOUtil.getExtension(file));
+ TuttiIOUtil.getExtension(file.getName()));
// store the path
attachment.setPath(filePath);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,6 +27,7 @@
import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
import fr.ifremer.tutti.persistence.entities.referential.ObjectType;
@@ -204,6 +205,12 @@
List<Caracteristic> getAllCaracteristicWithProtected();
/**
+ * @return all caracteristics of the system useable for {@link SampleCategoryModel}.
+ * @since 2.5
+ */
+ List<Caracteristic> getAllCaracteristicForSampleCategory();
+
+ /**
* @return all numeric caracteristics of the system.
* @since 1.0.2
*/
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,6 +25,7 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import fr.ifremer.adagio.core.dao.administration.user.PersonExtendDao;
import fr.ifremer.adagio.core.dao.data.vessel.VesselExtendDao;
@@ -472,6 +473,14 @@
return getAllCaracteristics(true);
}
+ @Override
+ public List<Caracteristic> getAllCaracteristicForSampleCategory() {
+ List<Caracteristic> allCaracteristicWithProtected = thisService.getAllCaracteristicWithProtected();
+ List<Caracteristic> result = Lists.newArrayList(
+ Iterables.filter(allCaracteristicWithProtected, TuttiEntities.newSampleCategoryModelPredicate()));
+ return result;
+ }
+
protected List<Caracteristic> getAllCaracteristics(boolean withProtected) {
Iterator<Object[]> sources = queryListWithStatus(
"allPmfm",
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-07-27 21:21:41 UTC (rev 1160)
@@ -1,4 +1,6 @@
nuitonutil.error.no.convertor=
+tutti.common.caracteristic.notFound=Caractéristique inconnue
+tutti.common.protocol.categories.not.compatible=Le protocole utilise des catégories non connues par la configuration des catégorisations \: <ul>%s</ul>
tutti.config.option.persistence.SampleCategoryModel.description=Configuration des catégories d'échantillonnage
tutti.config.option.persistence.db.attachment.directory.description=Répertoire où sont stockées les pièces-jointes
tutti.config.option.persistence.db.cache.directory.description=Répertoire où sont stockées les caches de persistance
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,15 +25,12 @@
*/
import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.TuttiPersistence;
import fr.ifremer.tutti.persistence.TuttiPersistenceNoDbImpl;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
@@ -353,10 +350,7 @@
@Override
public List<Caracteristic> getAllCaracteristicForSampleCategory() {
- List<Caracteristic> allCaracteristicWithProtected = driver.getAllCaracteristicWithProtected();
- List<Caracteristic> result = Lists.newArrayList(
- Iterables.filter(allCaracteristicWithProtected, TuttiEntities.newSampleCategoryModelPredicate()));
- return result;
+ return driver.getAllCaracteristicForSampleCategory();
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiUIContext.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -816,7 +816,7 @@
resolvedUri = new URI(resolvedUri.toString() + "#" + fragment);
}
if (log.isInfoEnabled()) {
- log.info("help uri = "+resolvedUri);
+ log.info("help uri = " + resolvedUri);
}
TuttiUIUtil.openLink(resolvedUri);
} catch (URISyntaxException e) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,7 +25,6 @@
*/
import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import static org.nuiton.i18n.I18n._;
@@ -45,9 +44,7 @@
protected boolean prepareAction() throws Exception {
boolean result = super.prepareAction();
if (result) {
- result = TuttiUIUtil.askAdminPassword(
- getContext().getActionUI(),
- getConfig(),
+ result = askAdminPassword(
_("tutti.editSampleCategoryModel.passwordDialog.message"),
_("tutti.editSampleCategoryModel.passwordDialog.title"),
_("tutti.editSampleCategoryModel.passwordDialog.error.message"),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,7 +25,6 @@
*/
import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import javax.swing.SwingUtilities;
@@ -47,9 +46,7 @@
protected boolean prepareAction() throws Exception {
boolean result = super.prepareAction();
if (result) {
- result = TuttiUIUtil.askAdminPassword(
- getContext().getActionUI(),
- getConfig(),
+ result = askAdminPassword(
_("tutti.manageTemporaryReferential.passwordDialog.message"),
_("tutti.manageTemporaryReferential.passwordDialog.title"),
_("tutti.manageTemporaryReferential.passwordDialog.error.message"),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -33,7 +33,7 @@
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
-import fr.ifremer.tutti.ui.swing.content.config.EditSampleCategoryModelUI;
+import fr.ifremer.tutti.ui.swing.content.category.EditSampleCategoryModelUI;
import fr.ifremer.tutti.ui.swing.content.config.TuttiConfigUI;
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI;
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIHandler;
@@ -55,6 +55,7 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionUI;
import fr.ifremer.tutti.ui.swing.util.action.TuttiUIAction;
+import jaxx.runtime.JAXXBinding;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.session.SwingSession;
import jaxx.runtime.validator.swing.SwingValidator;
@@ -69,6 +70,8 @@
import javax.swing.JToolBar;
import java.awt.Cursor;
import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeListenerProxy;
import java.net.URL;
import java.util.Locale;
@@ -236,11 +239,31 @@
context.setScreen(null);
context.removeMessageNotifier(this);
- TuttiUIUtil.closeBean(context);
+ // clean context
+ PropertyChangeListener[] propertyChangeListeners =
+ context.getPropertyChangeListeners();
+ for (PropertyChangeListener listener : propertyChangeListeners) {
+ if (listener instanceof PropertyChangeListenerProxy) {
+ PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) listener;
+ listener = proxy.getListener();
+ }
+ if (listener instanceof RemoveablePropertyChangeListener) {
+ if (log.isDebugEnabled()) {
+ log.debug("Remove listener: " + listener);
+ }
+ context.removePropertyChangeListener(listener);
+ }
+ }
+
if (ui != null) {
- TuttiUIUtil.closeUI(ui);
+ // clean ui
+
+ JAXXBinding[] bindings = ui.getDataBindings();
+ for (JAXXBinding binding : bindings) {
+ SwingUtil.removeDataBinding(ui, binding.getId());
+ }
ui.setVisible(false);
ui.dispose();
}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelRowModel.java (from rev 1158, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelRowModel.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -0,0 +1,99 @@
+package fr.ifremer.tutti.ui.swing.content.category;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since TODO
+ */
+public class EditSampleCategoryModelRowModel extends AbstractTuttiBeanUIModel<SampleCategoryModelEntry, EditSampleCategoryModelRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_LABEL = "label";
+
+ public static final String PROPERTY_CARACTERISTIC = "caracteristic";
+
+ protected final SampleCategoryModelEntry editObject = new SampleCategoryModelEntry();
+
+ protected static final Binder<SampleCategoryModelEntry, EditSampleCategoryModelRowModel> fromBeanBinder =
+ BinderFactory.newBinder(SampleCategoryModelEntry.class,
+ EditSampleCategoryModelRowModel.class);
+
+ protected static final Binder<EditSampleCategoryModelRowModel, SampleCategoryModelEntry> toBeanBinder =
+ BinderFactory.newBinder(EditSampleCategoryModelRowModel.class,
+ SampleCategoryModelEntry.class);
+
+ public EditSampleCategoryModelRowModel() {
+ super(SampleCategoryModelEntry.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public EditSampleCategoryModelRowModel(SampleCategoryModelEntry entry) {
+ this();
+ fromBean(entry);
+ }
+
+ @Override
+ protected SampleCategoryModelEntry newEntity() {
+ return new SampleCategoryModelEntry();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- SampleCategoryModelEntry delegate --//
+ //------------------------------------------------------------------------//
+
+ public String getLabel() {
+ return editObject.getLabel();
+ }
+
+ public void setLabel(String label) {
+ String oldValue = getLabel();
+ editObject.setLabel(label);
+ firePropertyChange(PROPERTY_LABEL, oldValue, label);
+ }
+
+ public Integer getCategoryId() {
+ return editObject.getCategoryId();
+ }
+
+ public Caracteristic getCaracteristic() {
+ return editObject.getCaracteristic();
+ }
+
+ public void setCaracteristic(Caracteristic caracteristic) {
+ Caracteristic oldValue = getCaracteristic();
+ editObject.setCaracteristic(caracteristic);
+ editObject.setCategoryId(caracteristic.getIdAsInt());
+ firePropertyChange(PROPERTY_CARACTERISTIC, oldValue, caracteristic);
+ }
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelTableModel.java (from rev 1158, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelTableModel.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -0,0 +1,79 @@
+package fr.ifremer.tutti.ui.swing.content.category;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.ui.swing.content.category.EditSampleCategoryModelRowModel;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import org.jdesktop.swingx.table.TableColumnModelExt;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Model of table of {@link SampleCategoryModelEntry}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class EditSampleCategoryModelTableModel extends AbstractTuttiTableModel<EditSampleCategoryModelRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ColumnIdentifier<EditSampleCategoryModelRowModel> CARACTERISTIC = ColumnIdentifier.newId(
+ EditSampleCategoryModelRowModel.PROPERTY_CARACTERISTIC,
+ n_("tutti.editSampleCategoryModel.table.header.caracteristic"),
+ n_("tutti.editSampleCategoryModel.table.header.caracteristic.tip"));
+
+ public static final ColumnIdentifier<EditSampleCategoryModelRowModel> LABEL = ColumnIdentifier.newId(
+ EditSampleCategoryModelRowModel.PROPERTY_LABEL,
+ n_("tutti.editSampleCategoryModel.table.header.label"),
+ n_("tutti.editSampleCategoryModel.table.header.label.tip"));
+
+ public EditSampleCategoryModelTableModel(TableColumnModelExt columnModel) {
+ super(columnModel, false, false);
+
+ setNoneEditableCols(CARACTERISTIC);
+ }
+
+ @Override
+ public EditSampleCategoryModelRowModel createNewRow() {
+ EditSampleCategoryModelRowModel result =
+ new EditSampleCategoryModelRowModel();
+
+ // by default empty row is not valid
+ result.setValid(false);
+ return result;
+ }
+
+ public void permuteEntry(int firstRow, int lastRow) {
+ EditSampleCategoryModelRowModel firstR = getRows().get(firstRow);
+
+ getRows().remove(firstRow);
+ getRows().add(lastRow, firstR);
+
+ fireTableRowsUpdated(firstRow, lastRow);
+ }
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.css (from rev 1158, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.css 2013-07-27 21:21:41 UTC (rev 1160)
@@ -0,0 +1,95 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+BeanFilterableComboBox {
+ i18nPrefix: "tutti.property.";
+ showReset: true;
+}
+
+#editSampleCategoryModelTopPanel {
+ _help: {"tutti.editSampleCategoryModel.help"};
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+}
+
+#availableCaracteristicsComboBox {
+ property: selectedCaracteristic;
+ enabled: {!availableCaracteristicsComboBox.isEmpty()};
+}
+
+#addRow {
+ actionIcon: add;
+ enabled: {availableCaracteristicsComboBox.getSelectedItem() != null};
+}
+
+#removeEntryMenu {
+ actionIcon: delete;
+ text: "tutti.editSampleCategoryModel.action.removeEntry";
+ toolTipText: "tutti.editSampleCategoryModel.action.removeEntry.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.removeEntry.mnemonic";
+ enabled: {model.isRemoveEntryEnabled()};
+ _help: {"tutti.editSampleCategoryModel.action.removeEntry.help"};
+}
+
+
+#moveUpEntryMenu {
+ actionIcon: up;
+ text: "tutti.editSampleCategoryModel.action.moveUpEntry";
+ toolTipText: "tutti.editSampleCategoryModel.action.moveUpEntry.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.moveUpEntry.mnemonic";
+ enabled: {model.isMoveUpEntryEnabled()};
+ _help: {"tutti.editSampleCategoryModel.action.moveUpEntry.help"};
+}
+
+#moveDownEntryMenu {
+ actionIcon: down;
+ text: "tutti.editSampleCategoryModel.action.moveDownEntry";
+ toolTipText: "tutti.editSampleCategoryModel.action.moveDownEntry.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.moveDownEntry.mnemonic";
+ enabled: {model.isMoveDownEntryEnabled()};
+ _help: {"tutti.editSampleCategoryModel.action.moveDownEntry.help"};
+}
+
+#closeButton {
+ actionIcon: cancel;
+ text: "tutti.editSampleCategoryModel.action.close";
+ toolTipText: "tutti.editSampleCategoryModel.action.close.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.close.mnemonic";
+ _tuttiAction: {fr.ifremer.tutti.ui.swing.content.SelectCruiseAction.class};
+ _help: {"tutti.editSampleCategoryModel.action.close.help"};
+}
+
+#saveButton {
+ actionIcon: save;
+ text: "tutti.editSampleCategoryModel.action.save";
+ toolTipText: "tutti.editSampleCategoryModel.action.save.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.save.mnemonic";
+ enabled: {model.isModify() && model.isValid()};
+ _tuttiAction: {SaveSampleCategoryModelAction.class};
+ _help: {"tutti.editSampleCategoryModel.action.save.help"};
+}
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.jaxx (from rev 1158, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUI.jaxx 2013-07-27 21:21:41 UTC (rev 1160)
@@ -0,0 +1,109 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU 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 General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JPanel id='editSampleCategoryModelTopPanel' layout='{new BorderLayout()}'
+ decorator='help'
+ implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<EditSampleCategoryModelUIModel, EditSampleCategoryModelUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.referential.Caracteristic
+
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.TuttiHelpBroker
+ fr.ifremer.tutti.ui.swing.util.TuttiUI
+
+ jaxx.runtime.swing.editor.bean.BeanFilterableComboBox
+
+ org.jdesktop.swingx.JXTable
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+ </import>
+
+ <script><![CDATA[
+
+public EditSampleCategoryModelUI(TuttiUI parentUI) {
+ JAXXUtil.initContext(this, parentUI);
+ TuttiUIContext context = parentUI.getHandler().getContext();
+ EditSampleCategoryModelUIHandler handler = new EditSampleCategoryModelUIHandler(context, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <!-- bean property -->
+ <EditSampleCategoryModelUIModel id='model'
+ initializer='getContextValue(EditSampleCategoryModelUIModel.class)'/>
+
+ <EditSampleCategoryModelUIHandler id='handler'
+ initializer='getContextValue(EditSampleCategoryModelUIHandler.class)'/>
+
+ <TuttiHelpBroker id='broker'
+ constructorParams='"tutti.editSampleCategoryModel.help"'/>
+
+ <JPopupMenu id='tablePopup'>
+ <JMenuItem id='removeEntryMenu'
+ onActionPerformed='handler.removeEntry()'/>
+ <JMenuItem id='moveUpEntryMenu'
+ onActionPerformed='handler.moveUpEntry()'/>
+ <JMenuItem id='moveDownEntryMenu'
+ onActionPerformed='handler.moveDownEntry()'/>
+ </JPopupMenu>
+
+ <Table>
+
+ <row fill='both'>
+ <cell fill='both' weightx='1'>
+ <BeanFilterableComboBox id='availableCaracteristicsComboBox'
+ constructorParams='this'
+ genericType='Caracteristic'/>
+ </cell>
+ <cell fill='both'>
+ <JButton id='addRow' onActionPerformed='handler.addCaracteristic()'/>
+ </cell>
+ </row>
+ <row fill='both' weighty='1'>
+ <cell fill='both' columns='2'>
+ <JScrollPane id='tableScrollPane'>
+ <JXTable id='table'
+ onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'
+ onKeyPressed='handler.openRowMenu(event, tablePopup)'/>
+ </JScrollPane>
+ </cell>
+ </row>
+
+ <!-- Form Actions -->
+ <row fill='both'>
+ <cell fill='both' columns='2'>
+ <JPanel layout='{new GridLayout(1, 0)}'>
+ <JButton id='closeButton'/>
+ <JButton id='saveButton'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+</JPanel>
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIHandler.java (from rev 1158, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -0,0 +1,369 @@
+package fr.ifremer.tutti.ui.swing.content.category;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.tutti.ui.swing.util.CloseableUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
+import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Handler of ui {@link EditSampleCategoryModelUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class EditSampleCategoryModelUIHandler extends AbstractTuttiTableUIHandler<EditSampleCategoryModelRowModel, EditSampleCategoryModelUIModel, EditSampleCategoryModelUI> implements Cancelable, CloseableUI {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EditSampleCategoryModelUIHandler.class);
+
+ protected PersistenceService persistenceService;
+
+ public EditSampleCategoryModelUIHandler(TuttiUIContext context, EditSampleCategoryModelUI ui) {
+ super(context, ui,
+ EditSampleCategoryModelRowModel.PROPERTY_CARACTERISTIC,
+ EditSampleCategoryModelRowModel.PROPERTY_LABEL);
+ this.persistenceService = context.getPersistenceService();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void addCaracteristic() {
+ BeanFilterableComboBox<Caracteristic> keyCombo = ui.getAvailableCaracteristicsComboBox();
+ Caracteristic selectedItem = (Caracteristic) keyCombo.getSelectedItem();
+
+ getModel().removeCaracteristic(selectedItem);
+
+ EditSampleCategoryModelTableModel tableModel = getTableModel();
+
+ EditSampleCategoryModelRowModel row = tableModel.createNewRow();
+ row.setCaracteristic(selectedItem);
+
+ tableModel.addNewRow(row);
+
+ recomputeRowValidState(row);
+
+ getModel().setModify(true);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getTable().requestFocus();
+
+ int rowIndex = getTable().getRowCount() - 1;
+
+ SwingUtil.editCell(getTable(), rowIndex, 1);
+ }
+ });
+ }
+
+ public void removeEntry() {
+ int selectedRow = getTable().getSelectedRow();
+ Preconditions.checkState(selectedRow > -1);
+
+ // get selected row
+ EditSampleCategoryModelRowModel entry =
+ getTableModel().getEntry(selectedRow);
+
+ // get his caracteristic
+ Caracteristic caracteristic = entry.getCaracteristic();
+
+ // push it back to model
+ getModel().addCaracteristic(caracteristic);
+
+ // remove entry from table model
+ getTableModel().removeRow(selectedRow);
+
+ getModel().setModify(true);
+ }
+
+ public void moveUpEntry() {
+ int selectedRow = getTable().getSelectedRow();
+ Preconditions.checkState(selectedRow > -1);
+
+ int newRow = selectedRow - 1;
+
+ getTableModel().permuteEntry(newRow, selectedRow);
+ getTable().getSelectionModel().setSelectionInterval(newRow, newRow);
+ getModel().setModify(true);
+ }
+
+ public void moveDownEntry() {
+ int selectedRow = getTable().getSelectedRow();
+ Preconditions.checkState(selectedRow > -1);
+ int newRow = selectedRow + 1;
+
+ getTableModel().permuteEntry(selectedRow, newRow);
+ getTable().getSelectionModel().setSelectionInterval(newRow, newRow);
+ getModel().setModify(true);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public EditSampleCategoryModelTableModel getTableModel() {
+ return (EditSampleCategoryModelTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JComponent getComponentToFocus() {
+ return ui.getAvailableCaracteristicsComboBox();
+ }
+
+ @Override
+ public JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected boolean isRowValid(EditSampleCategoryModelRowModel row) {
+ boolean result = StringUtils.isNotBlank(row.getLabel());
+
+ return result;
+ }
+
+ @Override
+ protected void onAfterSelectedRowChanged(int oldRowIndex, EditSampleCategoryModelRowModel oldRow, int newRowIndex, EditSampleCategoryModelRowModel newRow) {
+ super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
+ recomputePopupActions();
+ }
+
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EditSampleCategoryModelRowModel> rowMonitor,
+ EditSampleCategoryModelRowModel row) {
+
+ }
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ EditSampleCategoryModelRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ saveSelectedRowIfNeeded();
+
+ // when row valid state has changed, recompute action enabled states
+ recomputePopupActions();
+ getModel().setModify(true);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- CloseableUI methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public boolean quitUI() {
+ boolean result = quitScreen(
+ getModel().isValid(),
+ getModel().isModify(),
+ _("tutti.editProtocol.askCancelEditBeforeLeaving.cancelSaveSampleCategoryModel"),
+ _("tutti.editProtocol.askSaveBeforeLeaving.saveSampleCategoryModel"),
+ ui.getSaveButton().getAction()
+ );
+ return result;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("for " + ui);
+ }
+
+ List<Caracteristic> caracteristics = Lists.newArrayList(
+ persistenceService.getAllCaracteristicForSampleCategory());
+
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ EditSampleCategoryModelUIModel model = new EditSampleCategoryModelUIModel(
+ persistenceService.getEnumerationFile(),
+ sampleCategoryModel.getCategory(),
+ caracteristics);
+
+ ui.setContextValue(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+ initUI(ui);
+
+ EditSampleCategoryModelUIModel model = getModel();
+
+ initBeanFilterableComboBox(ui.getAvailableCaracteristicsComboBox(),
+ model.getCaracteristicList(),
+ null);
+
+ model.addPropertyChangeListener(EditSampleCategoryModelUIModel.PROPERTY_CARACTERISTIC_LIST, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug("propertyChange " + EditSampleCategoryModelUIModel.PROPERTY_CARACTERISTIC_LIST);
+ }
+ ui.getAvailableCaracteristicsComboBox().setData(null);
+ ui.getAvailableCaracteristicsComboBox().setData((List<Caracteristic>) evt.getNewValue());
+ ui.getAvailableCaracteristicsComboBox().setSelectedItem(null);
+ }
+ });
+
+ JXTable table = getTable();
+
+ // create table column model
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ {
+ // Category column
+
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Caracteristic.class),
+ EditSampleCategoryModelTableModel.CARACTERISTIC);
+
+
+ }
+
+ { // Label column
+
+ addColumnToModel(columnModel,
+ null,
+ null,
+ EditSampleCategoryModelTableModel.LABEL);
+ }
+
+ // create table model
+ EditSampleCategoryModelTableModel tableModel =
+ new EditSampleCategoryModelTableModel(columnModel);
+
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+
+ initTable(table);
+
+ List<EditSampleCategoryModelRowModel> rows = model.getRows();
+ tableModel.setRows(rows);
+
+ recomputePopupActions();
+
+ model.setModify(true);
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getModel().setModify(false);
+ }
+ });
+
+ }
+
+ @Override
+ protected void initTable(JXTable table) {
+ super.initTable(table);
+ installTableKeyListener(table.getColumnModel(), table);
+ }
+
+ @Override
+ public void cancel() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Cancel UI " + ui);
+ }
+
+ // close dialog
+ closeUI(ui);
+ }
+
+ @Override
+ public void onCloseUI() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Closing UI " + ui);
+ }
+ }
+
+ @Override
+ public SwingValidator<EditSampleCategoryModelUIModel> getValidator() {
+ return null;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void recomputePopupActions() {
+
+ int rowIndex = getTable().getSelectedRow();
+
+ boolean enableRemoveEntry = false;
+ boolean enableMoveUpEntry = false;
+ boolean enableMoveDownEntry = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+ enableRemoveEntry = true;
+
+ enableMoveUpEntry = rowIndex > 0;
+
+ enableMoveDownEntry = rowIndex < getTable().getModel().getRowCount() - 1;
+ }
+ EditSampleCategoryModelUIModel model = getModel();
+ model.setRemoveEntryEnabled(enableRemoveEntry);
+ model.setMoveUpEntryEnabled(enableMoveUpEntry);
+ model.setMoveDownEntryEnabled(enableMoveDownEntry);
+ }
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIModel.java (from rev 1158, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/EditSampleCategoryModelUIModel.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -0,0 +1,161 @@
+package fr.ifremer.tutti.ui.swing.content.category;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class EditSampleCategoryModelUIModel extends AbstractTuttiTableUIModel<SampleCategoryModel, EditSampleCategoryModelRowModel, EditSampleCategoryModelUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CARACTERISTIC_LIST = "caracteristicList";
+
+ public static final String PROPERTY_REMOVE_ENTRY_ENABLED = "removeEntryEnabled";
+
+ public static final String PROPERTY_MOVE_UP_ENTRY_ENABLED = "moveUpEntryEnabled";
+
+ public static final String PROPERTY_MOVE_DOWN_ENTRY_ENABLED = "moveDownEntryEnabled";
+
+ protected final SampleCategoryModelEntry firstCategory;
+
+ protected final List<Caracteristic> caracteristicList;
+
+ protected static Binder<SampleCategoryModel, EditSampleCategoryModelUIModel> fromBeanBinder =
+ BinderFactory.newBinder(SampleCategoryModel.class,
+ EditSampleCategoryModelUIModel.class);
+
+ protected static Binder<EditSampleCategoryModelUIModel, SampleCategoryModel> toBeanBinder =
+ BinderFactory.newBinder(EditSampleCategoryModelUIModel.class, SampleCategoryModel.class);
+
+ private boolean removeEntryEnabled;
+
+ private boolean moveUpEntryEnabled;
+
+ private boolean moveDownEntryEnabled;
+
+ public EditSampleCategoryModelUIModel(TuttiEnumerationFile enumerationFile,
+ List<SampleCategoryModelEntry> category,
+ List<Caracteristic> caracteristicList) {
+
+ super(SampleCategoryModel.class, fromBeanBinder, toBeanBinder);
+
+ Preconditions.checkNotNull(caracteristicList, "need a not null caracteristicList");
+ Preconditions.checkNotNull(enumerationFile, "need a not null enumerationFile");
+ Preconditions.checkNotNull(category, "need a not null category list");
+ Preconditions.checkArgument(!category.isEmpty(), "need at least one first category (sorted-unsorted)");
+ this.caracteristicList = caracteristicList;
+ this.firstCategory = category.get(0);
+ Preconditions.checkArgument(enumerationFile.PMFM_ID_SORTED_UNSORTED.equals(firstCategory.getCategoryId()), "first category must be sorted-unsorted caracteristic but was: " + firstCategory.getCategoryId());
+
+ List<EditSampleCategoryModelRowModel> rows = Lists.newArrayList();
+
+ for (SampleCategoryModelEntry sampleCategoryModelEntry : category) {
+ caracteristicList.remove(sampleCategoryModelEntry.getCaracteristic());
+ if (firstCategory.equals(sampleCategoryModelEntry)) {
+ continue;
+ }
+ EditSampleCategoryModelRowModel row = new EditSampleCategoryModelRowModel();
+ row.setCaracteristic(sampleCategoryModelEntry.getCaracteristic());
+ row.setLabel(sampleCategoryModelEntry.getLabel());
+ row.setValid(true);
+ rows.add(row);
+ }
+ setRows(rows);
+ }
+
+ @Override
+ protected SampleCategoryModel newEntity() {
+ List<SampleCategoryModelEntry> entries = Lists.newArrayList(firstCategory);
+ int order = 1;
+ for (EditSampleCategoryModelRowModel row : getRows()) {
+ SampleCategoryModelEntry entry = new SampleCategoryModelEntry();
+ entry.setCategoryId(row.getCategoryId());
+ entry.setLabel(row.getLabel());
+ entry.setOrder(order++);
+ entries.add(entry);
+ }
+ return new SampleCategoryModel(entries);
+ }
+
+ public List<Caracteristic> getCaracteristicList() {
+ return caracteristicList;
+ }
+
+ public boolean isRemoveEntryEnabled() {
+ return removeEntryEnabled;
+ }
+
+ public void setRemoveEntryEnabled(boolean removeEntryEnabled) {
+ boolean oldValue = isRemoveEntryEnabled();
+ this.removeEntryEnabled = removeEntryEnabled;
+ firePropertyChange(PROPERTY_REMOVE_ENTRY_ENABLED, oldValue, removeEntryEnabled);
+ }
+
+ public boolean isMoveUpEntryEnabled() {
+ return moveUpEntryEnabled;
+ }
+
+ public void setMoveUpEntryEnabled(boolean moveUpEntryEnabled) {
+ boolean oldValue = isMoveUpEntryEnabled();
+ this.moveUpEntryEnabled = moveUpEntryEnabled;
+ firePropertyChange(PROPERTY_MOVE_UP_ENTRY_ENABLED, oldValue, moveUpEntryEnabled);
+ }
+
+ public boolean isMoveDownEntryEnabled() {
+ return moveDownEntryEnabled;
+ }
+
+ public void setMoveDownEntryEnabled(boolean moveDownEntryEnabled) {
+ boolean oldValue = isMoveDownEntryEnabled();
+ this.moveDownEntryEnabled = moveDownEntryEnabled;
+ firePropertyChange(PROPERTY_MOVE_DOWN_ENTRY_ENABLED, oldValue, moveDownEntryEnabled);
+ }
+
+ public void addCaracteristic(Caracteristic caracteristic) {
+ caracteristicList.add(caracteristic);
+ firePropertyChange(PROPERTY_CARACTERISTIC_LIST, null, caracteristicList);
+ }
+
+ public void removeCaracteristic(Caracteristic caracteristic) {
+ caracteristicList.remove(caracteristic);
+ firePropertyChange(PROPERTY_CARACTERISTIC_LIST, null, caracteristicList);
+ }
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/SaveSampleCategoryModelAction.java (from rev 1158, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/SaveSampleCategoryModelAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/category/SaveSampleCategoryModelAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -0,0 +1,66 @@
+package fr.ifremer.tutti.ui.swing.content.category;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * To save the sample category model.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class SaveSampleCategoryModelAction extends AbstractTuttiAction<EditSampleCategoryModelUIModel, EditSampleCategoryModelUI, EditSampleCategoryModelUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SaveSampleCategoryModelAction.class);
+
+ public SaveSampleCategoryModelAction(EditSampleCategoryModelUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+ EditSampleCategoryModelUIModel model = getModel();
+
+ SampleCategoryModel bean = model.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save sampleCategoryModel: " + bean);
+ }
+ getConfig().getServiceConfig().getPersistenceConfig().setSampleCategoryModel(bean);
+
+ getConfig().save();
+
+ getDataContext().loadSampleCategoryModel(bean);
+
+ model.setModify(false);
+
+ }
+}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -1,99 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.config;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
-import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderFactory;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since TODO
- */
-public class EditSampleCategoryModelRowModel extends AbstractTuttiBeanUIModel<SampleCategoryModelEntry, EditSampleCategoryModelRowModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_LABEL = "label";
-
- public static final String PROPERTY_CARACTERISTIC = "caracteristic";
-
- protected final SampleCategoryModelEntry editObject = new SampleCategoryModelEntry();
-
- protected static final Binder<SampleCategoryModelEntry, EditSampleCategoryModelRowModel> fromBeanBinder =
- BinderFactory.newBinder(SampleCategoryModelEntry.class,
- EditSampleCategoryModelRowModel.class);
-
- protected static final Binder<EditSampleCategoryModelRowModel, SampleCategoryModelEntry> toBeanBinder =
- BinderFactory.newBinder(EditSampleCategoryModelRowModel.class,
- SampleCategoryModelEntry.class);
-
- public EditSampleCategoryModelRowModel() {
- super(SampleCategoryModelEntry.class, fromBeanBinder, toBeanBinder);
- }
-
- public EditSampleCategoryModelRowModel(SampleCategoryModelEntry entry) {
- this();
- fromBean(entry);
- }
-
- @Override
- protected SampleCategoryModelEntry newEntity() {
- return new SampleCategoryModelEntry();
- }
-
- //------------------------------------------------------------------------//
- //-- SampleCategoryModelEntry delegate --//
- //------------------------------------------------------------------------//
-
- public String getLabel() {
- return editObject.getLabel();
- }
-
- public void setLabel(String label) {
- String oldValue = getLabel();
- editObject.setLabel(label);
- firePropertyChange(PROPERTY_LABEL, oldValue, label);
- }
-
- public Integer getCategoryId() {
- return editObject.getCategoryId();
- }
-
- public Caracteristic getCaracteristic() {
- return editObject.getCaracteristic();
- }
-
- public void setCaracteristic(Caracteristic caracteristic) {
- Caracteristic oldValue = getCaracteristic();
- editObject.setCaracteristic(caracteristic);
- editObject.setCategoryId(caracteristic.getIdAsInt());
- firePropertyChange(PROPERTY_CARACTERISTIC, oldValue, caracteristic);
- }
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -1,78 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.config;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
-import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
-import org.jdesktop.swingx.table.TableColumnModelExt;
-
-import static org.nuiton.i18n.I18n.n_;
-
-/**
- * Model of table of {@link SampleCategoryModelEntry}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.5
- */
-public class EditSampleCategoryModelTableModel extends AbstractTuttiTableModel<EditSampleCategoryModelRowModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final ColumnIdentifier<EditSampleCategoryModelRowModel> CARACTERISTIC = ColumnIdentifier.newId(
- EditSampleCategoryModelRowModel.PROPERTY_CARACTERISTIC,
- n_("tutti.editSampleCategoryModel.table.header.caracteristic"),
- n_("tutti.editSampleCategoryModel.table.header.caracteristic.tip"));
-
- public static final ColumnIdentifier<EditSampleCategoryModelRowModel> LABEL = ColumnIdentifier.newId(
- EditSampleCategoryModelRowModel.PROPERTY_LABEL,
- n_("tutti.editSampleCategoryModel.table.header.label"),
- n_("tutti.editSampleCategoryModel.table.header.label.tip"));
-
- public EditSampleCategoryModelTableModel(TableColumnModelExt columnModel) {
- super(columnModel, false, false);
-
- setNoneEditableCols(CARACTERISTIC);
- }
-
- @Override
- public EditSampleCategoryModelRowModel createNewRow() {
- EditSampleCategoryModelRowModel result =
- new EditSampleCategoryModelRowModel();
-
- // by default empty row is not valid
- result.setValid(false);
- return result;
- }
-
- public void permuteEntry(int firstRow, int lastRow) {
- EditSampleCategoryModelRowModel firstR = getRows().get(firstRow);
-
- getRows().remove(firstRow);
- getRows().add(lastRow, firstR);
-
- fireTableRowsUpdated(firstRow, lastRow);
- }
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css 2013-07-27 21:21:41 UTC (rev 1160)
@@ -1,95 +0,0 @@
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-BeanFilterableComboBox {
- i18nPrefix: "tutti.property.";
- showReset: true;
-}
-
-#editSampleCategoryModelTopPanel {
- _help: {"tutti.editSampleCategoryModel.help"};
-}
-
-#table {
- selectionMode: {ListSelectionModel.SINGLE_SELECTION};
- selectionBackground: {null};
- selectionForeground: {Color.BLACK};
- sortable: false;
-}
-
-#availableCaracteristicsComboBox {
- property: selectedCaracteristic;
- enabled: {!availableCaracteristicsComboBox.isEmpty()};
-}
-
-#addRow {
- actionIcon: add;
- enabled: {availableCaracteristicsComboBox.getSelectedItem() != null};
-}
-
-#removeEntryMenu {
- actionIcon: delete;
- text: "tutti.editSampleCategoryModel.action.removeEntry";
- toolTipText: "tutti.editSampleCategoryModel.action.removeEntry.tip";
- i18nMnemonic: "tutti.editSampleCategoryModel.action.removeEntry.mnemonic";
- enabled: {model.isRemoveEntryEnabled()};
- _help: {"tutti.editSampleCategoryModel.action.removeEntry.help"};
-}
-
-
-#moveUpEntryMenu {
- actionIcon: up;
- text: "tutti.editSampleCategoryModel.action.moveUpEntry";
- toolTipText: "tutti.editSampleCategoryModel.action.moveUpEntry.tip";
- i18nMnemonic: "tutti.editSampleCategoryModel.action.moveUpEntry.mnemonic";
- enabled: {model.isMoveUpEntryEnabled()};
- _help: {"tutti.editSampleCategoryModel.action.moveUpEntry.help"};
-}
-
-#moveDownEntryMenu {
- actionIcon: down;
- text: "tutti.editSampleCategoryModel.action.moveDownEntry";
- toolTipText: "tutti.editSampleCategoryModel.action.moveDownEntry.tip";
- i18nMnemonic: "tutti.editSampleCategoryModel.action.moveDownEntry.mnemonic";
- enabled: {model.isMoveDownEntryEnabled()};
- _help: {"tutti.editSampleCategoryModel.action.moveDownEntry.help"};
-}
-
-#closeButton {
- actionIcon: cancel;
- text: "tutti.editSampleCategoryModel.action.close";
- toolTipText: "tutti.editSampleCategoryModel.action.close.tip";
- i18nMnemonic: "tutti.editSampleCategoryModel.action.close.mnemonic";
- _tuttiAction: {fr.ifremer.tutti.ui.swing.content.SelectCruiseAction.class};
- _help: {"tutti.editSampleCategoryModel.action.close.help"};
-}
-
-#saveButton {
- actionIcon: save;
- text: "tutti.editSampleCategoryModel.action.save";
- toolTipText: "tutti.editSampleCategoryModel.action.save.tip";
- i18nMnemonic: "tutti.editSampleCategoryModel.action.save.mnemonic";
- enabled: {model.isModify() && model.isValid()};
- _tuttiAction: {SaveSampleCategoryModelAction.class};
- _help: {"tutti.editSampleCategoryModel.action.save.help"};
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx 2013-07-27 21:21:41 UTC (rev 1160)
@@ -1,109 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 - 2013 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU 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 General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JPanel id='editSampleCategoryModelTopPanel' layout='{new BorderLayout()}'
- decorator='help'
- implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<EditSampleCategoryModelUIModel, EditSampleCategoryModelUIHandler>'>
-
- <import>
- fr.ifremer.tutti.persistence.entities.referential.Caracteristic
-
- fr.ifremer.tutti.ui.swing.TuttiUIContext
- fr.ifremer.tutti.ui.swing.TuttiHelpBroker
- fr.ifremer.tutti.ui.swing.util.TuttiUI
-
- jaxx.runtime.swing.editor.bean.BeanFilterableComboBox
-
- org.jdesktop.swingx.JXTable
-
- javax.swing.ListSelectionModel
-
- java.awt.Color
- </import>
-
- <script><![CDATA[
-
-public EditSampleCategoryModelUI(TuttiUI parentUI) {
- JAXXUtil.initContext(this, parentUI);
- TuttiUIContext context = parentUI.getHandler().getContext();
- EditSampleCategoryModelUIHandler handler = new EditSampleCategoryModelUIHandler(context, this);
- setContextValue(handler);
- handler.beforeInitUI();
-}
-
-protected void $afterCompleteSetup() { handler.afterInitUI(); }
- ]]></script>
-
- <!-- bean property -->
- <EditSampleCategoryModelUIModel id='model'
- initializer='getContextValue(EditSampleCategoryModelUIModel.class)'/>
-
- <EditSampleCategoryModelUIHandler id='handler'
- initializer='getContextValue(EditSampleCategoryModelUIHandler.class)'/>
-
- <TuttiHelpBroker id='broker'
- constructorParams='"tutti.editSampleCategoryModel.help"'/>
-
- <JPopupMenu id='tablePopup'>
- <JMenuItem id='removeEntryMenu'
- onActionPerformed='handler.removeEntry()'/>
- <JMenuItem id='moveUpEntryMenu'
- onActionPerformed='handler.moveUpEntry()'/>
- <JMenuItem id='moveDownEntryMenu'
- onActionPerformed='handler.moveDownEntry()'/>
- </JPopupMenu>
-
- <Table>
-
- <row fill='both'>
- <cell fill='both' weightx='1'>
- <BeanFilterableComboBox id='availableCaracteristicsComboBox'
- constructorParams='this'
- genericType='Caracteristic'/>
- </cell>
- <cell fill='both'>
- <JButton id='addRow' onActionPerformed='handler.addCaracteristic()'/>
- </cell>
- </row>
- <row fill='both' weighty='1'>
- <cell fill='both' columns='2'>
- <JScrollPane id='tableScrollPane'>
- <JXTable id='table'
- onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'
- onKeyPressed='handler.openRowMenu(event, tablePopup)'/>
- </JScrollPane>
- </cell>
- </row>
-
- <!-- Form Actions -->
- <row fill='both'>
- <cell fill='both' columns='2'>
- <JPanel layout='{new GridLayout(1, 0)}'>
- <JButton id='closeButton'/>
- <JButton id='saveButton'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-
-</JPanel>
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -1,367 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.config;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.Cancelable;
-import fr.ifremer.tutti.ui.swing.util.CloseableUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
-import jaxx.runtime.validator.swing.SwingValidator;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
-
-import javax.swing.JComponent;
-import javax.swing.SwingUtilities;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Handler of ui {@link EditSampleCategoryModelUI}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.5
- */
-public class EditSampleCategoryModelUIHandler extends AbstractTuttiTableUIHandler<EditSampleCategoryModelRowModel, EditSampleCategoryModelUIModel, EditSampleCategoryModelUI> implements Cancelable, CloseableUI {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(EditSampleCategoryModelUIHandler.class);
-
- protected PersistenceService persistenceService;
-
- public EditSampleCategoryModelUIHandler(TuttiUIContext context, EditSampleCategoryModelUI ui) {
- super(context, ui,
- EditSampleCategoryModelRowModel.PROPERTY_CARACTERISTIC,
- EditSampleCategoryModelRowModel.PROPERTY_LABEL);
- this.persistenceService = context.getPersistenceService();
- }
-
- //------------------------------------------------------------------------//
- //-- Public methods --//
- //------------------------------------------------------------------------//
-
- public void addCaracteristic() {
- BeanFilterableComboBox<Caracteristic> keyCombo = ui.getAvailableCaracteristicsComboBox();
- Caracteristic selectedItem = (Caracteristic) keyCombo.getSelectedItem();
-
- getModel().removeCaracteristic(selectedItem);
-
- EditSampleCategoryModelTableModel tableModel = getTableModel();
-
- EditSampleCategoryModelRowModel row = tableModel.createNewRow();
- row.setCaracteristic(selectedItem);
-
- tableModel.addNewRow(row);
-
- recomputeRowValidState(row);
-
- getModel().setModify(true);
-
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- getTable().requestFocus();
-
- int rowIndex = getTable().getRowCount() - 1;
-
- SwingUtil.editCell(getTable(), rowIndex, 1);
- }
- });
- }
-
- public void removeEntry() {
- int selectedRow = getTable().getSelectedRow();
- Preconditions.checkState(selectedRow > -1);
-
- // get selected row
- EditSampleCategoryModelRowModel entry = getTableModel().getEntry(selectedRow);
-
- // get his caracteristic
- Caracteristic caracteristic = entry.getCaracteristic();
-
- // push it back to model
- getModel().addCaracteristic(caracteristic);
-
- // remove entry from table model
- getTableModel().removeRow(selectedRow);
-
- getModel().setModify(true);
- }
-
- public void moveUpEntry() {
- int selectedRow = getTable().getSelectedRow();
- Preconditions.checkState(selectedRow > -1);
-
- int newRow = selectedRow - 1;
-
- getTableModel().permuteEntry(newRow, selectedRow);
- getTable().getSelectionModel().setSelectionInterval(newRow, newRow);
- getModel().setModify(true);
- }
-
- public void moveDownEntry() {
- int selectedRow = getTable().getSelectedRow();
- Preconditions.checkState(selectedRow > -1);
- int newRow = selectedRow + 1;
-
- getTableModel().permuteEntry(selectedRow, newRow);
- getTable().getSelectionModel().setSelectionInterval(newRow, newRow);
- getModel().setModify(true);
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiTableUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public EditSampleCategoryModelTableModel getTableModel() {
- return (EditSampleCategoryModelTableModel) getTable().getModel();
- }
-
- @Override
- protected JComponent getComponentToFocus() {
- return ui.getAvailableCaracteristicsComboBox();
- }
-
- @Override
- public JXTable getTable() {
- return ui.getTable();
- }
-
- @Override
- protected boolean isRowValid(EditSampleCategoryModelRowModel row) {
- boolean result = StringUtils.isNotBlank(row.getLabel());
-
- return result;
- }
-
- @Override
- protected void onAfterSelectedRowChanged(int oldRowIndex, EditSampleCategoryModelRowModel oldRow, int newRowIndex, EditSampleCategoryModelRowModel newRow) {
- super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
- recomputePopupActions();
- }
-
- @Override
- protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EditSampleCategoryModelRowModel> rowMonitor,
- EditSampleCategoryModelRowModel row) {
-
- }
-
- @Override
- protected void onRowModified(int rowIndex,
- EditSampleCategoryModelRowModel row,
- String propertyName,
- Object oldValue,
- Object newValue) {
- recomputeRowValidState(row);
- saveSelectedRowIfNeeded();
-
- // when row valid state has changed, recompute action enabled states
- recomputePopupActions();
- getModel().setModify(true);
- }
-
- //------------------------------------------------------------------------//
- //-- CloseableUI methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public boolean quitUI() {
- boolean result = quitScreen(
- getModel().isValid(),
- getModel().isModify(),
- _("tutti.editProtocol.askCancelEditBeforeLeaving.cancelSaveSampleCategoryModel"),
- _("tutti.editProtocol.askSaveBeforeLeaving.saveSampleCategoryModel"),
- ui.getSaveButton().getAction()
- );
- return result;
- }
-
- //------------------------------------------------------------------------//
- //-- AbstractTuttiUIHandler methods --//
- //------------------------------------------------------------------------//
-
- @Override
- public void beforeInitUI() {
-
- if (log.isDebugEnabled()) {
- log.debug("for " + ui);
- }
-
- List<Caracteristic> caracteristics = Lists.newArrayList(
- persistenceService.getAllCaracteristicForSampleCategory());
-
- SampleCategoryModel sampleCategoryModel =
- getDataContext().getSampleCategoryModel();
-
- EditSampleCategoryModelUIModel model = new EditSampleCategoryModelUIModel(
- persistenceService.getEnumerationFile(),
- sampleCategoryModel.getCategory(),
- caracteristics);
-
- ui.setContextValue(model);
- }
-
- @Override
- public void afterInitUI() {
- initUI(ui);
-
- EditSampleCategoryModelUIModel model = getModel();
-
- initBeanFilterableComboBox(ui.getAvailableCaracteristicsComboBox(),
- model.getCaracteristicList(),
- null);
-
- model.addPropertyChangeListener(EditSampleCategoryModelUIModel.PROPERTY_CARACTERISTIC_LIST, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (log.isDebugEnabled()) {
- log.debug("propertyChange " + EditSampleCategoryModelUIModel.PROPERTY_CARACTERISTIC_LIST);
- }
- ui.getAvailableCaracteristicsComboBox().setData(null);
- ui.getAvailableCaracteristicsComboBox().setData((List<Caracteristic>) evt.getNewValue());
- ui.getAvailableCaracteristicsComboBox().setSelectedItem(null);
- }
- });
-
- JXTable table = getTable();
-
- // create table column model
- DefaultTableColumnModelExt columnModel =
- new DefaultTableColumnModelExt();
-
- {
- // Category column
-
- addColumnToModel(columnModel,
- null,
- newTableCellRender(Caracteristic.class, DecoratorService.CARACTERISTIC_PARAMETER_ONLY),
- EditSampleCategoryModelTableModel.CARACTERISTIC);
-
-
- }
-
- { // Label column
-
- addColumnToModel(columnModel,
- null,
- null,
- EditSampleCategoryModelTableModel.LABEL);
- }
-
- // create table model
- EditSampleCategoryModelTableModel tableModel =
- new EditSampleCategoryModelTableModel(columnModel);
-
- table.setModel(tableModel);
- table.setColumnModel(columnModel);
-
- initTable(table);
-
- List<EditSampleCategoryModelRowModel> rows = model.getRows();
- tableModel.setRows(rows);
-
- recomputePopupActions();
-
- model.setModify(true);
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- getModel().setModify(false);
- }
- });
-
- }
-
- @Override
- protected void initTable(JXTable table) {
- super.initTable(table);
- installTableKeyListener(table.getColumnModel(), table);
- }
-
- @Override
- public void cancel() {
-
- if (log.isDebugEnabled()) {
- log.debug("Cancel UI " + ui);
- }
-
- // close dialog
- closeUI(ui);
- }
-
- @Override
- public void onCloseUI() {
-
- }
-
- @Override
- public SwingValidator<EditSampleCategoryModelUIModel> getValidator() {
- return null;
- }
-
-
- //------------------------------------------------------------------------//
- //-- Internal methods --//
- //------------------------------------------------------------------------//
-
- protected void recomputePopupActions() {
-
- int rowIndex = getTable().getSelectedRow();
-
- boolean enableRemoveEntry = false;
- boolean enableMoveUpEntry = false;
- boolean enableMoveDownEntry = false;
-
- if (rowIndex != -1) {
-
- // there is a selected row
- enableRemoveEntry = true;
-
- enableMoveUpEntry = rowIndex > 0;
-
- enableMoveDownEntry = rowIndex < getTable().getModel().getRowCount() - 1;
- }
- EditSampleCategoryModelUIModel model = getModel();
- model.setRemoveEntryEnabled(enableRemoveEntry);
- model.setMoveUpEntryEnabled(enableMoveUpEntry);
- model.setMoveDownEntryEnabled(enableMoveDownEntry);
- }
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -1,161 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.config;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
-import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
-import org.nuiton.util.beans.Binder;
-import org.nuiton.util.beans.BinderFactory;
-
-import java.util.List;
-
-/**
- * TODO
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.5
- */
-public class EditSampleCategoryModelUIModel extends AbstractTuttiTableUIModel<SampleCategoryModel, EditSampleCategoryModelRowModel, EditSampleCategoryModelUIModel> {
-
- private static final long serialVersionUID = 1L;
-
- public static final String PROPERTY_CARACTERISTIC_LIST = "caracteristicList";
-
- public static final String PROPERTY_REMOVE_ENTRY_ENABLED = "removeEntryEnabled";
-
- public static final String PROPERTY_MOVE_UP_ENTRY_ENABLED = "moveUpEntryEnabled";
-
- public static final String PROPERTY_MOVE_DOWN_ENTRY_ENABLED = "moveDownEntryEnabled";
-
- protected final SampleCategoryModelEntry firstCategory;
-
- protected final List<Caracteristic> caracteristicList;
-
- protected static Binder<SampleCategoryModel, EditSampleCategoryModelUIModel> fromBeanBinder =
- BinderFactory.newBinder(SampleCategoryModel.class,
- EditSampleCategoryModelUIModel.class);
-
- protected static Binder<EditSampleCategoryModelUIModel, SampleCategoryModel> toBeanBinder =
- BinderFactory.newBinder(EditSampleCategoryModelUIModel.class, SampleCategoryModel.class);
-
- private boolean removeEntryEnabled;
-
- private boolean moveUpEntryEnabled;
-
- private boolean moveDownEntryEnabled;
-
- public EditSampleCategoryModelUIModel(TuttiEnumerationFile enumerationFile,
- List<SampleCategoryModelEntry> category,
- List<Caracteristic> caracteristicList) {
-
- super(SampleCategoryModel.class, fromBeanBinder, toBeanBinder);
-
- Preconditions.checkNotNull(caracteristicList, "need a not null caracteristicList");
- Preconditions.checkNotNull(enumerationFile, "need a not null enumerationFile");
- Preconditions.checkNotNull(category, "need a not null category list");
- Preconditions.checkArgument(!category.isEmpty(), "need at least one first category (sorted-unsorted)");
- this.caracteristicList = caracteristicList;
- this.firstCategory = category.get(0);
- Preconditions.checkArgument(enumerationFile.PMFM_ID_SORTED_UNSORTED.equals(firstCategory.getCategoryId()), "first category must be sorted-unsorted caracteristic but was: " + firstCategory.getCategoryId());
-
- List<EditSampleCategoryModelRowModel> rows = Lists.newArrayList();
-
- for (SampleCategoryModelEntry sampleCategoryModelEntry : category) {
- caracteristicList.remove(sampleCategoryModelEntry.getCaracteristic());
- if (firstCategory.equals(sampleCategoryModelEntry)) {
- continue;
- }
- EditSampleCategoryModelRowModel row = new EditSampleCategoryModelRowModel();
- row.setCaracteristic(sampleCategoryModelEntry.getCaracteristic());
- row.setLabel(sampleCategoryModelEntry.getLabel());
- row.setValid(true);
- rows.add(row);
- }
- setRows(rows);
- }
-
- @Override
- protected SampleCategoryModel newEntity() {
- List<SampleCategoryModelEntry> entries = Lists.newArrayList(firstCategory);
- int order = 1;
- for (EditSampleCategoryModelRowModel row : getRows()) {
- SampleCategoryModelEntry entry = new SampleCategoryModelEntry();
- entry.setCategoryId(row.getCategoryId());
- entry.setLabel(row.getLabel());
- entry.setOrder(order++);
- entries.add(entry);
- }
- return new SampleCategoryModel(entries);
- }
-
- public List<Caracteristic> getCaracteristicList() {
- return caracteristicList;
- }
-
- public boolean isRemoveEntryEnabled() {
- return removeEntryEnabled;
- }
-
- public void setRemoveEntryEnabled(boolean removeEntryEnabled) {
- boolean oldValue = isRemoveEntryEnabled();
- this.removeEntryEnabled = removeEntryEnabled;
- firePropertyChange(PROPERTY_REMOVE_ENTRY_ENABLED, oldValue, removeEntryEnabled);
- }
-
- public boolean isMoveUpEntryEnabled() {
- return moveUpEntryEnabled;
- }
-
- public void setMoveUpEntryEnabled(boolean moveUpEntryEnabled) {
- boolean oldValue = isMoveUpEntryEnabled();
- this.moveUpEntryEnabled = moveUpEntryEnabled;
- firePropertyChange(PROPERTY_MOVE_UP_ENTRY_ENABLED, oldValue, moveUpEntryEnabled);
- }
-
- public boolean isMoveDownEntryEnabled() {
- return moveDownEntryEnabled;
- }
-
- public void setMoveDownEntryEnabled(boolean moveDownEntryEnabled) {
- boolean oldValue = isMoveDownEntryEnabled();
- this.moveDownEntryEnabled = moveDownEntryEnabled;
- firePropertyChange(PROPERTY_MOVE_DOWN_ENTRY_ENABLED, oldValue, moveDownEntryEnabled);
- }
-
- public void addCaracteristic(Caracteristic caracteristic) {
- caracteristicList.add(caracteristic);
- firePropertyChange(PROPERTY_CARACTERISTIC_LIST, null, caracteristicList);
- }
-
- public void removeCaracteristic(Caracteristic caracteristic) {
- caracteristicList.remove(caracteristic);
- firePropertyChange(PROPERTY_CARACTERISTIC_LIST, null, caracteristicList);
- }
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -1,66 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.config;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
-import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * To save the sample category model.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.5
- */
-public class SaveSampleCategoryModelAction extends AbstractTuttiAction<EditSampleCategoryModelUIModel, EditSampleCategoryModelUI, EditSampleCategoryModelUIHandler> {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(SaveSampleCategoryModelAction.class);
-
- public SaveSampleCategoryModelAction(EditSampleCategoryModelUIHandler handler) {
- super(handler, true);
- }
-
- @Override
- protected void doAction() throws Exception {
- EditSampleCategoryModelUIModel model = getModel();
-
- SampleCategoryModel bean = model.toBean();
-
- if (log.isInfoEnabled()) {
- log.info("Will save sampleCategoryModel: " + bean);
- }
- getConfig().getServiceConfig().getPersistenceConfig().setSampleCategoryModel(bean);
-
- getConfig().save();
-
- getDataContext().loadSampleCategoryModel(bean);
-
- model.setModify(false);
-
- }
-}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportCruiseValidationMessagesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportCruiseValidationMessagesAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportCruiseValidationMessagesAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,7 +25,6 @@
*/
import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import java.io.File;
@@ -52,17 +51,15 @@
protected boolean prepareAction() throws Exception {
boolean doAction = super.prepareAction();
- // choose file to export
- file = TuttiUIUtil.saveFile(
- _("tutti.validateCruise.action.export.all.chooseFile.defaultFile", getDataContext().getCruise().getName()),
- getContext().getMainUI(),
- _("tutti.validateCruise.action.export.all.chooseFile.title"),
- _("tutti.validateCruise.action.export.all.chooseFile.label")
- );
- doAction = file != null;
if (doAction) {
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
+ // choose file to export
+ file = saveFile(
+ String.format("validation_%s", getDataContext().getCruise().getName()),
+ "txt",
+ _("tutti.validateCruise.action.export.all.chooseFile.title"),
+ _("tutti.validateCruise.action.export.all.chooseFile.label")
+ );
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportOperationValidationMessagesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportOperationValidationMessagesAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ExportOperationValidationMessagesAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,7 +27,6 @@
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.catches.ValidateCruiseOperationsService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import java.io.File;
@@ -54,18 +53,17 @@
protected boolean prepareAction() throws Exception {
boolean doAction = super.prepareAction();
- // choose file to export
- file = TuttiUIUtil.saveFile(
- _("tutti.validateCruise.action.export.operation.chooseFile.defaultFile",
- decorate(getModel().getSelectedFishingOperation(), DecoratorService.FILE_NAME_COMPATIBLE)),
- getContext().getMainUI(),
- _("tutti.validateCruise.action.export.operation.chooseFile.title"),
- _("tutti.validateCruise.action.export.operation.chooseFile.label")
- );
- doAction = file != null;
if (doAction) {
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
+
+ // choose file to export
+ file = saveFile(
+ String.format("validation_%s",
+ decorate(getModel().getSelectedFishingOperation(), DecoratorService.FILE_NAME_COMPATIBLE)),
+ "txt",
+ _("tutti.validateCruise.action.export.operation.chooseFile.title"),
+ _("tutti.validateCruise.action.export.operation.chooseFile.label")
+ );
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportAndCleanDbAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,12 +25,10 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.ui.swing.RunTutti;
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -71,25 +69,14 @@
// ask user file where to export db
// choose file to import
- file = TuttiUIUtil.saveFile(
- "tutti-db-" + df.format(new Date()) + ".zip",
- getContext().getMainUI(),
+ file = saveFile(
+ "tutti-db-" + df.format(new Date()),
+ "zip",
_("tutti.dbManager.title.choose.dbExportFile"),
_("tutti.dbManager.action.chooseDbExportFile"),
"^.*\\.zip", _("tutti.common.file.zip")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".zip");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ExportDbAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,11 +25,9 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -69,25 +67,14 @@
// ask user file where to export db
// choose file to import
- file = TuttiUIUtil.saveFile(
- "tutti-db-" + df.format(new Date()) + ".zip",
- getContext().getMainUI(),
+ file = saveFile(
+ "tutti-db-" + df.format(new Date()),
+ "zip",
_("tutti.dbManager.title.choose.dbExportFile"),
_("tutti.dbManager.action.chooseDbExportFile"),
"^.*\\.zip", _("tutti.common.file.zip")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".zip");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/db/ImportDbAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -29,7 +29,6 @@
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
import fr.ifremer.tutti.ui.swing.content.AbstractMainUITuttiAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -63,8 +62,7 @@
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
_("tutti.dbManager.title.choose.dbImportFile"),
_("tutti.dbManager.action.chooseDbFile"),
"^.*\\.zip", _("tutti.common.file.zip")
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/CloneProtocolAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,14 +25,25 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import jaxx.runtime.context.JAXXContextEntryDef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Opens the protocol creation screen with the data of an already existing protocol.
*
@@ -46,25 +57,99 @@
public static final JAXXContextEntryDef<TuttiProtocol> CLONE_PROTOCOL_ENTRY = new JAXXContextEntryDef<TuttiProtocol>("cloneProtocol", TuttiProtocol.class);
+ protected TuttiProtocol protocol;
+
public CloneProtocolAction(MainUIHandler handler) {
super(handler, true, TuttiScreen.EDIT_PROTOCOL);
}
@Override
- protected void doAction() throws Exception {
- Preconditions.checkState(getContext().isProtocolFilled());
- if (log.isInfoEnabled()) {
- log.info("Clone protocol: " + getContext().getProtocolId());
+ protected boolean prepareAction() throws Exception {
+
+ CLONE_PROTOCOL_ENTRY.removeContextValue(getContext().getMainUI());
+
+ boolean doAction = super.prepareAction();
+ if (doAction) {
+
+ // check that protocol is compatible with sample category model
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ if (log.isInfoEnabled()) {
+ log.info("Clone protocol: " + getContext().getProtocolId());
+ }
+
+ // get protocol
+ protocol = getContext().getPersistenceService().getProtocol(getContext().getProtocolId());
+
+ // remove id
+ protocol.setId((String) null);
+
+ Set<Integer> badCategories = Sets.newHashSet();
+
+ TuttiProtocols.checkSampleCategories(sampleCategoryModel,
+ protocol,
+ badCategories);
+
+ if (!badCategories.isEmpty()) {
+
+ // detect some bad categories
+ if (log.isWarnEnabled()) {
+ log.warn("There is some bad categories: " + badCategories);
+ }
+
+ String message = TuttiProtocols.getBadCategoriesMessage(
+ badCategories,
+ getDecorator(Caracteristic.class, null),
+ getContext().getPersistenceService());
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.common.askBeforeCloneProtocol.help"));
+ int response = JOptionPane.showOptionDialog(
+ getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.common.askBeforeEditProtocol.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE,
+ UIManager.getIcon("warning"),
+ new Object[]{_("tutti.option.cleanAndClone"), _("tutti.option.clone"), _("tutti.option.cancel")},
+ _("tutti.option.cancel")
+ );
+
+ switch (response) {
+ case 0:
+ // clean and clone
+ if (log.isInfoEnabled()) {
+ log.info("Clean and Clone");
+ }
+ TuttiProtocols.removeBadCategories(sampleCategoryModel,
+ protocol);
+ break;
+
+ case 1:
+ // clone with no clean
+ if (log.isInfoEnabled()) {
+ log.info("Clone with no cleaning");
+ }
+ break;
+ default:
+
+ // cancel
+ doAction = false;
+ }
+ }
}
+ return doAction;
+ }
- // get protocol
- TuttiProtocol protocol = getContext().getPersistenceService().getProtocol(getContext().getProtocolId());
+ @Override
+ protected void doAction() throws Exception {
+ Preconditions.checkNotNull(protocol);
- // remove id
- protocol.setId((String) null);
-
// store protocol in context
CLONE_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol);
+ protocol = null;
// removed selected protocol
getContext().setProtocolId(null);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/DeleteProtocolAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -57,7 +57,7 @@
TuttiProtocol protocol = getHandler().getModel().getProtocol();
result &=
- getHandler().askBeforeDelete(
+ askBeforeDelete(
_("tutti.selectCruise.action.deleteProtocol.title"),
_("tutti.selectCruise.action.deleteProtocol.message", protocol.getName())
);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/EditProtocolAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,12 +25,25 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
+import jaxx.runtime.context.JAXXContextEntryDef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Opens the protocol edition screen.
*
@@ -42,11 +55,94 @@
/** Logger. */
private static final Log log = LogFactory.getLog(EditProtocolAction.class);
+ public static final JAXXContextEntryDef<TuttiProtocol> CLEAN_PROTOCOL_ENTRY = new JAXXContextEntryDef<TuttiProtocol>("cleanProtocol", TuttiProtocol.class);
+
public EditProtocolAction(MainUIHandler handler) {
super(handler, true, TuttiScreen.EDIT_PROTOCOL);
}
@Override
+ protected boolean prepareAction() throws Exception {
+
+ CLEAN_PROTOCOL_ENTRY.removeContextValue(getContext().getMainUI());
+
+ boolean doAction = super.prepareAction();
+ if (doAction) {
+
+ // check that protocol is compatible with sample category model
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ TuttiProtocol protocol = getDataContext().getProtocol();
+
+ Set<Integer> badCategories = Sets.newHashSet();
+
+ TuttiProtocols.checkSampleCategories(sampleCategoryModel,
+ protocol,
+ badCategories);
+
+ if (!badCategories.isEmpty()) {
+
+ // detect some bad categories
+ if (log.isWarnEnabled()) {
+ log.warn("There is some bad categories: " + badCategories);
+ }
+
+ String message = TuttiProtocols.getBadCategoriesMessage(
+ badCategories,
+ getDecorator(Caracteristic.class, null),
+ getContext().getPersistenceService());
+
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.common.askBeforeEditProtocol.help"));
+ int response = JOptionPane.showOptionDialog(
+ getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.common.askBeforeEditProtocol.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE,
+ UIManager.getIcon("warning"),
+ new Object[]{_("tutti.option.cleanAndEdit"), _("tutti.option.edit"), _("tutti.option.cancel")},
+ _("tutti.option.cancel")
+ );
+
+ switch (response) {
+ case 0:
+ // edit and clean
+ if (log.isInfoEnabled()) {
+ log.info("Clean and edit");
+ }
+
+ protocol = getContext().getPersistenceService().getProtocol(getContext().getProtocolId());
+
+ CLEAN_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol);
+
+ TuttiProtocols.removeBadCategories(sampleCategoryModel,
+ protocol);
+
+ break;
+
+ case 1:
+ // edit with no modification
+ if (log.isInfoEnabled()) {
+ log.info("Edit with no cleaning");
+ }
+ break;
+
+ default:
+
+ // cancel
+ doAction = false;
+ }
+
+ }
+ }
+ return doAction;
+ }
+
+ @Override
protected void doAction() throws Exception {
Preconditions.checkState(getContext().isProtocolFilled());
if (log.isInfoEnabled()) {
@@ -54,4 +150,6 @@
}
super.doAction();
}
+
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,12 +25,10 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.export.TuttiExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -66,20 +64,14 @@
Cruise cruise = getModel().getCruise();
// choose file to export
- file = TuttiUIUtil.saveFile(
- "exportCruise-" + cruise.getName() + ".zip",
- getContext().getMainUI(),
+ file = saveFile(
+ "exportCruise-" + cruise.getName(),
+ "zip",
_("tutti.selectCruise.title.choose.exportCruiseFile"),
_("tutti.selectCruise.action.chooseCruiseExportFile"),
"^.+\\.zip$", _("tutti.common.file.zip")
);
doAction = file != null;
- if (doAction) {
- file = TuttiIOUtil.addExtensionIfMissing(file, ".zip");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
}
return doAction;
}
@@ -110,7 +102,7 @@
if (getContext().isProtocolFilled()) {
protocol = getDataContext().getProtocol();
if (log.isInfoEnabled()) {
- log.info("Will use protocol "+protocol.getName());
+ log.info("Will use protocol " + protocol.getName());
}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportCruiseForSumatraAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,10 +25,8 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.service.sumatra.TuttiCatchesSumatraExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -66,20 +64,14 @@
String date = DateUtil.formatDate(new Date(), "dd-MM-yyyy");
// choose file to export
- file = TuttiUIUtil.saveFile(
- _("tutti.exportCruiseForSumatra.choose.exportFile.default", getDataContext().getCruise().getName(), date),
- getContext().getMainUI(),
+ file = saveFile(
+ String.format("sumatra_%s_%s", getDataContext().getCruise().getName(), date),
+ "csv",
_("tutti.exportCruiseForSumatra.title.choose.exportFile"),
_("tutti.exportCruiseForSumatra.action.chooseFile"),
"^.+\\.csv$", _("tutti.common.file.csv")
);
doAction = file != null;
- if (doAction) {
- file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProgramAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,13 +25,11 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.export.TuttiExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -67,20 +65,13 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "exportProgram-" + program.getName() + ".zip",
- getContext().getMainUI(),
+ file = saveFile(
+ "exportProgram-" + program.getName() ,"zip",
_("tutti.selectCruise.title.choose.exportProgramFile"),
_("tutti.selectCruise.action.chooseProgramExportFile"),
"^.+\\.zip$", _("tutti.common.file.zip")
);
doAction = file != null;
- if (doAction) {
- file = TuttiIOUtil.addExtensionIfMissing(file, ".zip");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
}
return doAction;
}
@@ -114,7 +105,7 @@
if (getContext().isProtocolFilled()) {
protocol = getDataContext().getProtocol();
if (log.isInfoEnabled()) {
- log.info("Will use protocol "+protocol.getName());
+ log.info("Will use protocol " + protocol.getName());
}
}
TuttiExportService service = getContext().getTuttiExportService();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ExportProtocolAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,10 +25,8 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,20 +62,14 @@
TuttiProtocol protocol = getModel().getProtocol();
// choose file to export
- file = TuttiUIUtil.saveFile(
- "protocol-" + protocol.getName().replaceAll(" ", "_") + ".tuttiProtocol",
- getContext().getMainUI(),
+ file = saveFile(
+ "protocol-" + protocol.getName().replaceAll(" ", "_") ,
+ "tuttiProtocol",
_("tutti.selectCruise.title.choose.exportFile"),
_("tutti.selectCruise.action.exportProtocol"),
"^.+\\.tuttiProtocol$", _("tutti.common.file.protocol")
);
doAction = file != null;
- if (doAction) {
- file = TuttiIOUtil.addExtensionIfMissing(file, ".tuttiProtocol");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/ImportProtocolAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,17 +25,24 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocols;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.content.AbstractChangeScreenAction;
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import jaxx.runtime.context.JAXXContextEntryDef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
import java.io.File;
+import java.util.Set;
import static org.nuiton.i18n.I18n._;
@@ -53,7 +60,7 @@
public static final JAXXContextEntryDef<TuttiProtocol> IMPORT_PROTOCOL_ENTRY = new JAXXContextEntryDef<TuttiProtocol>("importProtocol", TuttiProtocol.class);
- private File file;
+ protected TuttiProtocol protocol;
public ImportProtocolAction(MainUIHandler handler) {
super(handler, true, TuttiScreen.EDIT_PROTOCOL);
@@ -62,12 +69,15 @@
@Override
protected boolean prepareAction() throws Exception {
+ IMPORT_PROTOCOL_ENTRY.removeContextValue(getContext().getMainUI());
+
boolean doAction = super.prepareAction();
+ File file = null;
+
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
_("tutti.selectCruise.title.choose.importFile"),
_("tutti.selectCruise.action.importProtocol"),
"^.+\\.tuttiProtocol$", _("tutti.common.file.protocol")
@@ -75,36 +85,94 @@
doAction = file != null;
}
+
+ if (doAction) {
+
+ // import protocol
+ if (log.isInfoEnabled()) {
+ log.info("Will import protocol file: " + file);
+ }
+
+ TuttiProtocolImportExportService service =
+ getContext().getTuttiProtocolImportExportService();
+
+ protocol = service.importProtocol(file);
+
+ // remove id
+ protocol.setId((String) null);
+
+ sendMessage(_("tutti.importProtocol.action.success", protocol.getName()));
+
+ // check that protocol is compatible with sample category model
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ Set<Integer> badCategories = Sets.newHashSet();
+
+ TuttiProtocols.checkSampleCategories(sampleCategoryModel,
+ protocol,
+ badCategories);
+
+ if (!badCategories.isEmpty()) {
+
+ // detect some bad categories
+ if (log.isWarnEnabled()) {
+ log.warn("There is some bad categories: " + badCategories);
+ }
+
+ String message = TuttiProtocols.getBadCategoriesMessage(
+ badCategories,
+ getDecorator(Caracteristic.class, null),
+ getContext().getPersistenceService());
+
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.common.askBeforeImportProtocol.help"));
+ int response = JOptionPane.showOptionDialog(
+ getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.common.askBeforeEditProtocol.title"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE,
+ UIManager.getIcon("warning"),
+ new Object[]{_("tutti.option.cleanAndImport"), _("tutti.option.import"), _("tutti.option.cancel")},
+ _("tutti.option.cancel")
+ );
+
+ switch (response) {
+ case 0:
+ // clean and import
+ if (log.isInfoEnabled()) {
+ log.info("Clean and Import");
+ }
+ TuttiProtocols.removeBadCategories(sampleCategoryModel,
+ protocol);
+ break;
+ case 1:
+ // import with no clean
+ if (log.isInfoEnabled()) {
+ log.info("Import with no cleaning");
+ }
+ break;
+ default:
+
+ // cancel
+ doAction = false;
+ }
+ }
+ }
return doAction;
}
@Override
- protected void releaseAction() {
- file = null;
- super.releaseAction();
- }
-
- @Override
protected void doAction() throws Exception {
- Preconditions.checkNotNull(file);
+ Preconditions.checkNotNull(protocol);
- if (log.isInfoEnabled()) {
- log.info("Will import protocol file: " + file);
- }
-
- // import protocol
- TuttiProtocolImportExportService service =
- getContext().getTuttiProtocolImportExportService();
- TuttiProtocol protocol = service.importProtocol(file);
-
- sendMessage(_("tutti.importProtocol.action.success", protocol.getName()));
-
// store protocol in context
IMPORT_PROTOCOL_ENTRY.setContextValue(getContext().getMainUI(), protocol);
+ protocol = null;
- // remove id
- protocol.setId((String) null);
-
// removed selected protocol
getContext().setProtocolId(null);
super.doAction();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SendCruiseReportAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,7 +25,6 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.service.catches.ExportCatchesReportService;
@@ -34,7 +33,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.swing.*;
+import javax.swing.JOptionPane;
import java.io.File;
import static org.nuiton.i18n.I18n._;
@@ -66,20 +65,14 @@
Cruise cruise = getModel().getCruise();
// choose file to export
- file = TuttiUIUtil.saveFile(
- "exportCruise-" + cruise.getName() + ".pdf",
- getContext().getMainUI(),
+ file = saveFile(
+ "exportCruise-" + cruise.getName(),
+ "pdf",
_("tutti.sendCruiseReport.title.choose.exportFile"),
_("tutti.sendCruiseReport.action.chooseFile"),
"^.+\\.pdf$", _("tutti.common.file.pdf")
);
doAction = file != null;
- if (doAction) {
- file = TuttiIOUtil.addExtensionIfMissing(file, ".pdf");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
}
return doAction;
}
@@ -106,11 +99,11 @@
getContext().getGeneratePDFService();
service.generatePDFFile(file, cruise.getId(), getConfig().getI18nLocale());
- try {
- throw new TuttiTechnicalException();
-// TuttiUIUtil.mail(_("tutti.sendCruiseReport.mail.subject", cruise.getName()),
-// _("tutti.sendCruiseReport.mail.body", cruise.getName(), file.getAbsolutePath()));
+ try {
+ TuttiUIUtil.mail(_("tutti.sendCruiseReport.mail.subject", cruise.getName()),
+ _("tutti.sendCruiseReport.mail.body", cruise.getName(), file.getAbsolutePath()));
+
} catch (TuttiTechnicalException e) {
JOptionPane.showMessageDialog(getContext().getMainUI(),
_("tutti.sendCruiseReport.action.error.mail.message", file),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchUIModel.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/AbstractTuttiBatchUIModel.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,7 +27,6 @@
import com.google.common.collect.Sets;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
-import fr.ifremer.tutti.ui.swing.content.operation.catches.species.SpeciesBatchRowModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/DeleteFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/DeleteFishingOperationAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/DeleteFishingOperationAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -56,7 +56,7 @@
FishingOperation fishingOperation = getModel().getSelectedFishingOperation();
canContinue &= fishingOperation != null &&
!TuttiEntities.isNew(fishingOperation) &&
- getHandler().askBeforeDelete(
+ askBeforeDelete(
_("tutti.editFishingOperation.action.deleteFishingOperation.title"),
_("tutti.editFishingOperation.action.deleteFishingOperation.message", decorate(fishingOperation))
);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -40,7 +40,6 @@
import fr.ifremer.tutti.ui.swing.content.operation.fishing.AbstractCaracteristicTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUIModel;
-import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiTabContainerUIHandler;
import fr.ifremer.tutti.ui.swing.util.TabHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -280,8 +280,7 @@
String result = null;
if (!catchSampleModelValid) {
result = _("tutti.fishingOperations.warn.catchBatch.invalidSampleCategoryModel");
- } else
- if (catchNotFound) {
+ } else if (catchNotFound) {
result = _("tutti.fishingOperations.warn.catchBatch.notFound");
} else if (!catchEnabled) {
result = _("tutti.fishingOperations.warn.invalid.batch.model");
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractExportMultiPostAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -29,7 +29,6 @@
import fr.ifremer.tutti.service.catches.multipost.TuttiMultiPostImportExportService;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.jdesktop.beans.AbstractBean;
@@ -65,23 +64,15 @@
String extension = getFileExtension();
// choose file to export
- file = TuttiUIUtil.saveFile(
- decorate(currentOperation, DecoratorService.FILE_NAME_COMPATIBLE) + "." + extension,
- getContext().getMainUI(),
+ file = saveFile(
+ decorate(currentOperation, DecoratorService.FILE_NAME_COMPATIBLE),
+ extension,
getFileChooserTitle(),
getFileChooserButton(),
"^.*\\." + extension,
getFileExtensionDescription()
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -30,7 +30,6 @@
import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import org.jdesktop.beans.AbstractBean;
@@ -72,8 +71,7 @@
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
getFileChooserTitle(),
getFileChooserButton(),
"^.*\\." + getFileExtension(),
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ImportMultiPostAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ImportMultiPostAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/ImportMultiPostAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,7 +27,6 @@
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.service.catches.multipost.TuttiMultiPostImportExportService;
import fr.ifremer.tutti.ui.swing.content.operation.catches.AbstractImportMultiPostAction;
import fr.ifremer.tutti.ui.swing.content.operation.catches.MultiPostImportLogDialog;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/create/CreateBenthosBatchUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,7 +27,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import fr.ifremer.tutti.persistence.TuttiPersistence;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyCellComponent.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -180,7 +180,7 @@
// the row is valid even if there is no data (just for the highlighter)
// but we save it only if there is data
if (row.isValid()
- && !(row.getNumber() == null && row.getWeight() == null)) {
+ && !(row.getNumber() == null && row.getWeight() == null)) {
// can keep this row
frequency.add(row);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/frequency/BenthosFrequencyUI.jaxx 2013-07-27 21:21:41 UTC (rev 1160)
@@ -187,7 +187,8 @@
</JPanel>
</JPanel>
</JPanel>
- <Table id="lengthstepSettingsBlock" fill='both' constraints='BorderLayout.SOUTH'>
+ <Table id="lengthstepSettingsBlock" fill='both'
+ constraints='BorderLayout.SOUTH'>
<row>
<cell columns='6'>
<JSeparator/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyCellComponent.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -180,7 +180,7 @@
// the row is valid even if there is no data (just for the highlighter)
// but we save it only if there is data
if (row.isValid()
- && !(row.getNumber() == null && row.getWeight() == null)) {
+ && !(row.getNumber() == null && row.getWeight() == null)) {
// can keep this row
frequency.add(row);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUI.jaxx 2013-07-27 21:21:41 UTC (rev 1160)
@@ -187,7 +187,8 @@
</JPanel>
</JPanel>
</JPanel>
- <Table id="lengthstepSettingsBlock" fill='both' constraints='BorderLayout.SOUTH'>
+ <Table id="lengthstepSettingsBlock" fill='both'
+ constraints='BorderLayout.SOUTH'>
<row>
<cell columns='6'>
<JSeparator/>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUI.css 2013-07-27 21:21:41 UTC (rev 1160)
@@ -70,7 +70,7 @@
#saveWarningContainer {
background: {new java.awt.Color(245, 218, 88)};
- visible: {model.isImported() || model.isCloned()};
+ visible: {model.isImported() || model.isCloned() || model.isCleaned()};
}
#saveWarning {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -37,6 +37,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.ui.swing.content.home.CloneProtocolAction;
+import fr.ifremer.tutti.ui.swing.content.home.EditProtocolAction;
import fr.ifremer.tutti.ui.swing.content.home.ImportProtocolAction;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.CloseableUI;
@@ -197,6 +198,16 @@
protocol = getDataContext().getProtocol();
+ if (EditProtocolAction.CLEAN_PROTOCOL_ENTRY.getContextValue(ui) != null) {
+
+ // clean protocol
+ protocol = EditProtocolAction.CLEAN_PROTOCOL_ENTRY.getContextValue(ui);
+
+ EditProtocolAction.CLEAN_PROTOCOL_ENTRY.removeContextValue(ui);
+
+ model.setCleaned(true);
+ ui.getSaveWarning().setText(_("tutti.editProtocol.warn.clean"));
+ }
model.fromBean(protocol);
} else if ((protocol = ImportProtocolAction.IMPORT_PROTOCOL_ENTRY.getContextValue(ui)) != null) {
@@ -291,6 +302,11 @@
for (SampleCategoryModelEntry sampleCategoryModelEntry : sampleCategoryModel.getCategory()) {
+ if (sampleCategoryModelEntry.getOrder() == 0) {
+ // first category is not editable
+ continue;
+ }
+
MandatorySampleCategoryColumnIdentifier identifier = MandatorySampleCategoryColumnIdentifier.newId(
EditProtocolSpeciesRowModel.PROPERTY_MANDATORY_SAMPLE_CATEGORY_ID,
sampleCategoryModelEntry.getCategoryId(),
@@ -301,11 +317,6 @@
addBooleanColumnToModel(columnModel, identifier, table);
}
-// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SIZE_ENABLED, table);
-// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SEX_ENABLED, table);
-// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.MATURITY_ENABLED, table);
-// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.AGE_ENABLED, table);
-
addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.CALCIFY_SAMPLE_ENABLED, table);
EditProtocolSpeciesTableModel tableModel =
@@ -361,11 +372,6 @@
addBooleanColumnToModel(columnModel, identifier, table);
}
-// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SIZE_ENABLED, table);
-// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.SEX_ENABLED, table);
-// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.MATURITY_ENABLED, table);
-// addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.AGE_ENABLED, table);
-
addBooleanColumnToModel(columnModel, EditProtocolSpeciesTableModel.CALCIFY_SAMPLE_ENABLED, table);
EditProtocolSpeciesTableModel tableModel =
@@ -428,7 +434,7 @@
});
// if new protocol can already cancel his creation
- model.setModify(model.isCreate());
+ model.setModify(model.isCreate() || model.isCleaned());
ui.getCaracteristicPane().addChangeListener(new ChangeListener() {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/EditProtocolUIModel.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -60,6 +60,8 @@
public static final String PROPERTY_CLONED = "cloned";
+ public static final String PROPERTY_CLEANED = "cleaned";
+
/**
* Delegate edit object.
*
@@ -82,6 +84,13 @@
protected boolean cloned;
/**
+ * Flag when a incoming protocol is cleaned.
+ *
+ * @since 2.5
+ */
+ protected boolean cleaned;
+
+ /**
* Can user remove a selected species?
*
* @since 0.3
@@ -202,6 +211,16 @@
firePropertyChange(PROPERTY_CLONED, oldValue, cloned);
}
+ public boolean isCleaned() {
+ return cleaned;
+ }
+
+ public void setCleaned(boolean cleaned) {
+ Object oldValue = isCleaned();
+ this.cleaned = cleaned;
+ firePropertyChange(PROPERTY_CLEANED, oldValue, cleaned);
+ }
+
public List<Species> getAllSpecies() {
return allSpecies;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportAllCaracteristicAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,9 +25,7 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -62,25 +60,14 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "tuttiProtocol-" + getModel().getName() + "-allCaracteristics.csv",
- getContext().getMainUI(),
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-allCaracteristics",
+ "csv",
_("tutti.editProtocol.title.choose.caracteristicExportFile"),
_("tutti.editProtocol.action.chooseProtocolCaracteristicFile"),
"^.*\\.csv", _("tutti.common.file.csv")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolBenthosAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -26,10 +26,8 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -65,25 +63,14 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "tuttiProtocol-" + getModel().getName() + "-benthos.csv",
- getContext().getMainUI(),
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-benthos",
+ "csv",
_("tutti.editProtocol.title.choose.benthosExportFile"),
_("tutti.editProtocol.action.chooseProtocolBenthosFile"),
"^.*\\.csv", _("tutti.common.file.csv")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolCaracteristicAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,10 +25,8 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -63,25 +61,14 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "tuttiProtocol-" + getModel().getName() + "-caracteristics.csv",
- getContext().getMainUI(),
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-caracteristics",
+ "csv",
_("tutti.editProtocol.title.choose.caracteristicExportFile"),
_("tutti.editProtocol.action.chooseProtocolCaracteristicFile"),
"^.*\\.csv", _("tutti.common.file.csv")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportProtocolSpeciesAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -26,10 +26,8 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -65,25 +63,14 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "tuttiProtocol-" + getModel().getName() + "-species.csv",
- getContext().getMainUI(),
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-species",
+ "csv",
_("tutti.editProtocol.title.choose.speciesExportFile"),
_("tutti.editProtocol.action.chooseProtocolSpeciesFile"),
"^.*\\.csv", _("tutti.common.file.csv")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ExportPupitriAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -28,7 +28,6 @@
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.service.pupitri.TuttiPupitriImportExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,21 +63,13 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "tuttiProtocol-" + getModel().getName() + "-pupitri.csv",
- getContext().getMainUI(),
+ file = saveFile(
+ "tuttiProtocol-" + getModel().getName() + "-pupitri",
+ "csv",
_("tutti.editProtocol.title.choose.speciesExportFile"),
_("tutti.editProtocol.action.chooseProtocolSpeciesFile")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolBenthosAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -28,7 +28,6 @@
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,8 +63,7 @@
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
_("tutti.editProtocol.title.choose.benthosImportFile"),
_("tutti.editProtocol.action.chooseProtocolBenthosFile"),
"^.*\\.csv", _("tutti.common.file.csv")
@@ -109,11 +107,9 @@
handler.toRows(protocol.getBenthos());
// update species comboBox
-// getUI().getSpeciesComboBox().getHandler().sortData();
getUI().getSpeciesComboBox().getHandler().reset();
// update benthos comboBox
-// getUI().getBenthosComboBox().getHandler().sortData();
getUI().getBenthosComboBox().getHandler().reset();
// update rows in model
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolCaracteristicAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,7 +27,6 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -62,8 +61,7 @@
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
_("tutti.editProtocol.title.choose.caracteristicImportFile"),
_("tutti.editProtocol.action.chooseProtocolCaracteristicFile"),
"^.*\\.csv", _("tutti.common.file.csv")
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/protocol/ImportProtocolSpeciesAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -28,7 +28,6 @@
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,8 +63,7 @@
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
_("tutti.editProtocol.title.choose.speciesImportFile"),
_("tutti.editProtocol.action.chooseProtocolSpeciesFile"),
"^.*\\.csv", _("tutti.common.file.csv")
@@ -109,11 +107,9 @@
handler.toRows(protocol.getSpecies());
// update species comboBox
-// getUI().getSpeciesComboBox().getHandler().sortData();
getUI().getSpeciesComboBox().getHandler().reset();
// update benthos comboBox
-// getUI().getBenthosComboBox().getHandler().sortData();
getUI().getBenthosComboBox().getHandler().reset();
// update rows in model
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryGearExampleAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,10 +25,8 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.service.referential.TuttiReferentialImportExportService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -63,25 +61,14 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "exportGearExample.csv",
- getContext().getMainUI(),
+ file = saveFile(
+ "exportGearExample",
+ "csv",
_("tutti.manageTemporaryReferential.title.choose.exportTemporaryGearExampleFile"),
_("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.export"),
"^.*\\.csv", _("tutti.common.file.csv")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryPersonExampleAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,10 +25,8 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.service.referential.TuttiReferentialImportExportService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,25 +62,14 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "exportPersonExample.csv",
- getContext().getMainUI(),
+ file = saveFile(
+ "exportPersonExample",
+ "csv",
_("tutti.manageTemporaryReferential.title.choose.exportTemporaryPersonExampleFile"),
_("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.export"),
"^.*\\.csv", _("tutti.common.file.csv")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporarySpeciesExampleAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,10 +25,8 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.service.referential.TuttiReferentialImportExportService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -63,25 +61,14 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "exportSpeciesExample.csv",
- getContext().getMainUI(),
+ file = saveFile(
+ "exportSpeciesExample",
+ "csv",
_("tutti.manageTemporaryReferential.title.choose.exportTemporarySpeciesExampleFile"),
_("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.export"),
"^.*\\.csv", _("tutti.common.file.csv")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ExportTemporaryVesselExampleAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -25,10 +25,8 @@
*/
import com.google.common.base.Preconditions;
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.service.referential.TuttiReferentialImportExportService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -63,25 +61,14 @@
if (doAction) {
// choose file to export
- file = TuttiUIUtil.saveFile(
- "exportVesselExample.csv",
- getContext().getMainUI(),
+ file = saveFile(
+ "exportVesselExample",
+ "csv",
_("tutti.manageTemporaryReferential.title.choose.exportTemporaryVesselExampleFile"),
_("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.export"),
"^.*\\.csv", _("tutti.common.file.csv")
);
- if (file == null) {
-
- // user cancel
- doAction = false;
- } else {
-
- // add extension if missing
- file = TuttiIOUtil.addExtensionIfMissing(file, ".csv");
-
- // ask user to confirm overwrite.
- doAction = getHandler().askOverwriteFile(file);
- }
+ doAction = file != null;
}
return doAction;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryGearAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,7 +27,6 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.service.referential.TuttiReferentialImportExportService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -62,8 +61,7 @@
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
_("tutti.manageTemporaryReferential.title.choose.importTemporaryGearFile"),
_("tutti.manageTemporaryReferential.action.chooseReferentialGearFile.import"),
"^.*\\.csv", _("tutti.common.file.csv"));
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryPersonAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,7 +27,6 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.service.referential.TuttiReferentialImportExportService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -62,8 +61,7 @@
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
_("tutti.manageTemporaryReferential.title.choose.importTemporaryPersonFile"),
_("tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.import"),
"^.*\\.csv", _("tutti.common.file.csv"));
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporarySpeciesAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,7 +27,6 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.service.referential.TuttiReferentialImportExportService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -61,8 +60,7 @@
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
_("tutti.manageTemporaryReferential.title.choose.importTemporarySpeciesFile"),
_("tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.import"),
"^.*\\.csv", _("tutti.common.file.csv"));
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/referential/ImportTemporaryVesselAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,7 +27,6 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.service.referential.TuttiReferentialImportExportService;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -61,8 +60,7 @@
if (doAction) {
// choose file to import
- file = TuttiUIUtil.chooseFile(
- getContext().getMainUI(),
+ file = chooseFile(
_("tutti.manageTemporaryReferential.title.choose.importTemporaryVesselFile"),
_("tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.import"),
"^.*\\.csv", _("tutti.common.file.csv"));
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -85,6 +85,7 @@
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -115,7 +116,6 @@
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.io.File;
import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;
@@ -292,8 +292,6 @@
public static final String CONFIRMATION_FORMAT = "<html>%s<hr/><br/>%s</html>";
- public static final String WARNING_FORMAT = "<html>%s<hr/></html>";
-
public int askSaveBeforeLeaving(String message) {
String htmlMessage = String.format(
CONFIRMATION_FORMAT,
@@ -324,46 +322,6 @@
return result;
}
- public boolean askBeforeDelete(String title, String message) {
- String htmlMessage = String.format(
- CONFIRMATION_FORMAT,
- message,
- _("tutti.common.askBeforeDelete.help"));
- int i = JOptionPane.showConfirmDialog(
- getTopestUI(),
- htmlMessage,
- title,
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE);
-
- boolean result = i == JOptionPane.OK_OPTION;
- return result;
- }
-
- public boolean askOverwriteFile(File file) {
- boolean result;
- if (file.exists()) {
-
- // file exists ask user to overwrite
- String htmlMessage = String.format(
- CONFIRMATION_FORMAT,
- _("tutti.common.askOverwriteFile.message", file),
- _("tutti.common.askOverwriteFile.help"));
-
- result = JOptionPane.showConfirmDialog(
- getTopestUI(),
- htmlMessage,
- _("tutti.common.askOverwriteFile.title"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION;
- } else {
-
- // file does not exist
- result = true;
- }
- return result;
- }
-
public void showSuccessMessage(String title, String message) {
Component topestUI = getTopestUI();
@@ -378,10 +336,13 @@
}
try {
- TuttiUIUtil.showSuccessMessage(
+ JOptionPane.showMessageDialog(
topestUI,
+ message,
title,
- message);
+ JOptionPane.INFORMATION_MESSAGE,
+ UIManager.getIcon("info")
+ );
} finally {
if (alwaysOnTop) {
((JDialog) topestUI).setAlwaysOnTop(true);
@@ -389,7 +350,7 @@
}
}
- protected Component getTopestUI() {
+ public Component getTopestUI() {
Component result;
TuttiActionUI actionUI = getContext().getActionUI();
// if (actionUI.isVisible()) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -27,28 +27,14 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.TuttiTechnicalException;
-import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
-import jaxx.runtime.FileChooserUtil;
-import jaxx.runtime.JAXXBinding;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.SwingUtil;
import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jdesktop.beans.AbstractBean;
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
-import org.nuiton.util.StringUtil;
-import javax.swing.JOptionPane;
-import javax.swing.UIManager;
import java.awt.Color;
-import java.awt.Component;
import java.awt.Desktop;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeListenerProxy;
-import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
@@ -75,98 +61,6 @@
// never instanciate util class
}
- /**
- * Choisir un fichier via un sélecteur graphique de fichiers.
- *
- * @param parent le component swing appelant le controle
- * @param title le titre du dialogue de sélection
- * @param buttonLabel le label du boutton d'acceptation
- * @param filters les filtres + descriptions sur le sélecteur de
- * fichiers
- * @return le fichier choisi ou le fichier incoming si l'opération a été
- * annulée
- */
- public static File chooseFile(Component parent,
- String title,
- String buttonLabel,
- String... filters) {
-
- File file = FileChooserUtil.getFile(title, buttonLabel, parent, filters);
- if (log.isDebugEnabled()) {
- log.debug(title + " : " + file);
- }
- if (file != null) {
- File newDir = file.isDirectory() ? file : file.getParentFile();
- FileChooserUtil.setCurrentDirectory(newDir);
- }
- return file;
- }
-
- /**
- * Sauver un fichier via un sélecteur graphique de fichiers.
- *
- * @param parent le component swing appelant le controle
- * @param title le titre du dialogue de sélection
- * @param buttonLabel le label du boutton d'acceptation
- * @param filters les filtres + descriptions sur le sélecteur de
- * fichiers
- * @return le fichier choisi ou le fichier incoming si l'opération a été
- * annulée
- */
- public static File saveFile(String filename,
- Component parent,
- String title,
- String buttonLabel,
- String... filters) {
-
- File file = FileChooserUtil.saveFile(filename, title, buttonLabel, parent, filters);
- if (log.isDebugEnabled()) {
- log.debug(title + " : " + file);
- }
- if (file != null) {
- Preconditions.checkState(!file.isDirectory());
- FileChooserUtil.setCurrentDirectory(file.getParentFile());
- }
- return file;
- }
-
- /**
- * Choisir un répertoire via un sélecteur graphique de fichiers.
- *
- * @param parent le component swing appelant le controle
- * @param title le titre de la boite de dialogue de sléection
- * @param buttonLabel le label de l'action d'acceptation
- * @return le répertoire choisi ou le répertoire incoming si l'opération a
- * été annulée
- */
- public static File chooseDirectory(Component parent,
- String title,
- String buttonLabel) {
-
- String file = FileChooserUtil.getDirectory(parent, title, buttonLabel);
- if (log.isDebugEnabled()) {
- log.debug(title + " : " + file);
- }
- if (file != null) {
- File newDir = new File(file);
- if (!newDir.isDirectory()) {
- newDir = newDir.getParentFile();
- }
- FileChooserUtil.setCurrentDirectory(newDir);
- }
- return file == null ? null : new File(file);
- }
-
- public static void showSuccessMessage(Component ui, String title, String message) {
- JOptionPane.showMessageDialog(
- ui,
- message,
- title,
- JOptionPane.INFORMATION_MESSAGE,
- UIManager.getIcon("info")
- );
- }
-
public static void setProperty(Object bean, String property, Object value) {
Preconditions.checkNotNull(bean);
Preconditions.checkNotNull(property);
@@ -332,30 +226,6 @@
}
}
- public static void closeBean(AbstractBean bean) {
- PropertyChangeListener[] propertyChangeListeners =
- bean.getPropertyChangeListeners();
- for (PropertyChangeListener listener : propertyChangeListeners) {
- if (listener instanceof PropertyChangeListenerProxy) {
- PropertyChangeListenerProxy proxy = (PropertyChangeListenerProxy) listener;
- listener = proxy.getListener();
- }
- if (listener instanceof RemoveablePropertyChangeListener) {
- if (log.isDebugEnabled()) {
- log.debug("Remove listener: " + listener);
- }
- bean.removePropertyChangeListener(listener);
- }
- }
- }
-
- public static void closeUI(JAXXObject ui) {
- JAXXBinding[] bindings = ui.getDataBindings();
- for (JAXXBinding binding : bindings) {
- SwingUtil.removeDataBinding(ui, binding.getId());
- }
- }
-
public static void tryToConnectToUpdateUrl(String url, String i18nKey) {
try {
URLConnection urlConnection = new URL(url).openConnection();
@@ -376,37 +246,4 @@
return result;
}
-
- public static boolean askAdminPassword(Component container,
- TuttiApplicationConfig config,
- String askMessage,
- String askMessageTitle,
- String errorMessage,
- String errorMessageTitle) {
- String answer;
- boolean result;
- do {
- answer = JOptionPane.showInputDialog(container,
- askMessage,
- askMessageTitle,
- JOptionPane.WARNING_MESSAGE);
- if (answer != null) {
- String cryptedAnswer = StringUtil.encodeMD5(answer);
- String correctAnswer = config.getAdminPassword();
- result = StringUtils.equals(cryptedAnswer, correctAnswer);
-
- if (!result) {
- JOptionPane.showMessageDialog(container,
- errorMessage,
- errorMessageTitle,
- JOptionPane.ERROR_MESSAGE);
- }
-
- } else {
- result = false;
- }
-
- } while (!result && answer != null);
- return result;
- }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/action/AbstractTuttiAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -31,9 +31,20 @@
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import jaxx.runtime.FileChooserUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractBean;
import org.nuiton.decorator.Decorator;
+import org.nuiton.util.StringUtil;
+import javax.swing.JOptionPane;
+import java.awt.Component;
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Tutti base action.
*
@@ -43,6 +54,9 @@
public abstract class AbstractTuttiAction<M extends AbstractBean, UI extends TuttiUI<M, ?>, H extends AbstractTuttiUIHandler<M, UI>>
extends AbstractBean {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(AbstractTuttiAction.class);
+
public static final String PROPERTY_DONE = "done";
protected final H handler;
@@ -140,4 +154,155 @@
return getDecorator(object.getClass(), context).toString(object);
}
+ protected boolean askAdminPassword(String askMessage,
+ String askMessageTitle,
+ String errorMessage,
+ String errorMessageTitle) {
+
+ Component container = getContext().getActionUI();
+
+ String answer;
+ boolean result;
+ do {
+ answer = JOptionPane.showInputDialog(container,
+ askMessage,
+ askMessageTitle,
+ JOptionPane.WARNING_MESSAGE);
+ if (answer != null) {
+ String cryptedAnswer = StringUtil.encodeMD5(answer);
+ String correctAnswer = getConfig().getAdminPassword();
+ result = StringUtils.equals(cryptedAnswer, correctAnswer);
+
+ if (!result) {
+ JOptionPane.showMessageDialog(container,
+ errorMessage,
+ errorMessageTitle,
+ JOptionPane.ERROR_MESSAGE);
+ }
+
+ } else {
+ result = false;
+ }
+
+ } while (!result && answer != null);
+ return result;
+ }
+
+ /**
+ * Choisir un fichier via un sélecteur graphique de fichiers.
+ *
+ * @param title le titre du dialogue de sélection
+ * @param buttonLabel le label du boutton d'acceptation
+ * @param filters les filtres + descriptions sur le sélecteur de
+ * fichiers
+ * @return le fichier choisi ou le fichier incoming si l'opération a été
+ * annulée
+ */
+ protected File chooseFile(String title,
+ String buttonLabel,
+ String... filters) {
+
+ File file = FileChooserUtil.getFile(title,
+ buttonLabel,
+ getContext().getMainUI(),
+ filters);
+ if (log.isDebugEnabled()) {
+ log.debug(title + " : " + file);
+ }
+ if (file != null) {
+ File newDir = file.isDirectory() ? file : file.getParentFile();
+ FileChooserUtil.setCurrentDirectory(newDir);
+ }
+ return file;
+ }
+
+ /**
+ * Sauver un fichier via un sélecteur graphique de fichiers.
+ *
+ * @param title le titre du dialogue de sélection
+ * @param buttonLabel le label du boutton d'acceptation
+ * @param filters les filtres + descriptions sur le sélecteur de
+ * fichiers
+ * @return le fichier choisi ou {@code null} si pas de fichier choisi ou
+ * pas voulu écrasé un fichier existant.
+ */
+ protected File saveFile(String filename,
+ String extension,
+ String title,
+ String buttonLabel,
+ String... filters) {
+
+ boolean withExtension = StringUtils.isNotBlank(extension);
+ String filenameSuffix = withExtension ? "." + extension : "";
+ File file = FileChooserUtil.saveFile(filename + filenameSuffix, title, buttonLabel, getContext().getMainUI(), filters);
+ if (log.isDebugEnabled()) {
+ log.debug(title + " : " + file);
+ }
+ if (file != null) {
+ Preconditions.checkState(!file.isDirectory());
+
+ // add extension if missing
+ if (withExtension && !file.getName().endsWith(filenameSuffix)) {
+ file = new File(file.getParentFile(), file.getName() + filenameSuffix);
+ }
+
+ // ask user to confirm overwrite.
+ boolean confirm = askOverwriteFile(file);
+
+ if (confirm) {
+
+ // on conserve le répertoire (pour une prochaine utilisation)
+ FileChooserUtil.setCurrentDirectory(file.getParentFile());
+ } else {
+
+ // l'utilisateur n'a pas confirmé l'écrasement
+ // donc pas de fichier en retour
+ file = null;
+ }
+ }
+
+ return file;
+ }
+
+ private boolean askOverwriteFile(File file) {
+ boolean result;
+ if (file.exists()) {
+
+ // file exists ask user to overwrite
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.common.askOverwriteFile.message", file),
+ _("tutti.common.askOverwriteFile.help"));
+
+ result = JOptionPane.showConfirmDialog(
+ getHandler().getTopestUI(),
+ htmlMessage,
+ _("tutti.common.askOverwriteFile.title"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION;
+ } else {
+
+ // file does not exist
+ result = true;
+ }
+ return result;
+ }
+
+ protected boolean askBeforeDelete(String title, String message) {
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ message,
+ _("tutti.common.askBeforeDelete.help"));
+ int i = JOptionPane.showConfirmDialog(
+ getHandler().getTopestUI(),
+ htmlMessage,
+ title,
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ boolean result = i == JOptionPane.OK_OPTION;
+ return result;
+ }
+
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -24,7 +24,6 @@
* #L%
*/
-import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
@@ -32,6 +31,7 @@
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.ComponentMover;
import jaxx.runtime.swing.ComponentResizer;
@@ -272,66 +272,39 @@
}
public void saveAttachment(Attachment attachment) {
- boolean hackDialog = ui.isAlwaysOnTop();
- if (hackDialog) {
- ui.setAlwaysOnTop(false);
- }
- try {
- File attachmentFile = persistenceService.getAttachmentFile(attachment.getId());
- File file = TuttiUIUtil.saveFile(
- attachment.getName(),
- ui,
- _("tutti.attachmentEditor.saveAttachment.title"),
- _("tutti.attachmentEditor.saveAttachment.button"));
- if (file != null) {
- boolean checkOverwrite = askOverwriteFile(file);
- if (checkOverwrite) {
- TuttiIOUtil.copyFile(attachmentFile, file,
- _("tutti.attachmentEditor.saveAttachment.error.message", attachmentFile, file.getName()));
- context.showInformationMessage(
- _("tutti.attachmentEditor.saveAttachment.success.message", file.getName()));
- }
-// if (file.exists()) {
-// String htmlMessage = String.format(
-// AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
-// _("tutti.attachmentEditor.saveAttachment.warning.message"),
-// _("tutti.attachmentEditor.saveAttachment.warning.help"));
+ SaveAttachmentAction action = TuttiActionHelper.createLogicAction(
+ this, SaveAttachmentAction.class);
+ action.setAttachment(attachment);
+ TuttiActionHelper.runAction(action);
+
+// boolean hackDialog = ui.isAlwaysOnTop();
+// if (hackDialog) {
+// ui.setAlwaysOnTop(false);
+// }
+// try {
+// File attachmentFile = persistenceService.getAttachmentFile(attachment.getId());
+// File file = TuttiUIUtil.saveFile(
+// attachment.getName(),
+// ui,
+// _("tutti.attachmentEditor.saveAttachment.title"),
+// _("tutti.attachmentEditor.saveAttachment.button"));
//
-// int answer = JOptionPane.showConfirmDialog(ui,
-// htmlMessage,
-// _("tutti.attachmentEditor.saveAttachment.warning.title"),
-// JOptionPane.YES_NO_OPTION,
-// JOptionPane.WARNING_MESSAGE);
-//
-// if (answer == JOptionPane.NO_OPTION) {
-// return;
-// }
+// if (file != null) {
+// boolean checkOverwrite = askOverwriteFile(file);
+// if (checkOverwrite) {
+// TuttiIOUtil.copyFile(attachmentFile, file,
+// _("tutti.attachmentEditor.saveAttachment.error.message", attachmentFile, file.getName()));
+// context.showInformationMessage(
+// _("tutti.attachmentEditor.saveAttachment.success.message", file.getName()));
// }
-// FileUtils.copyFile(attachmentFile, file);
-// context.showInformationMessage(
-// _("tutti.attachmentEditor.saveAttachment.success.message", file.getName()));
- }
- if (hackDialog) {
- ui.setAlwaysOnTop(true);
- }
-
-// } catch (IOException e) {
-// if (log.isErrorEnabled()) {
-// log.error("Error while saving attachment", e);
// }
-// JOptionPane.showMessageDialog(
-// ui,
-// _("tutti.attachmentEditor.saveAttachment.fail.message"),
-// _("tutti.attachmentEditor.saveAttachment.fail.title"),
-// JOptionPane.ERROR_MESSAGE
-// );
-
- } finally {
- if (hackDialog) {
- ui.setAlwaysOnTop(true);
- }
- }
+//
+// } finally {
+// if (hackDialog) {
+// ui.setAlwaysOnTop(true);
+// }
+// }
}
public void removeAttachment(AttachmentItem attachmentItem) {
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -0,0 +1,81 @@
+package fr.ifremer.tutti.ui.swing.util.attachment;
+
+import fr.ifremer.tutti.TuttiIOUtil;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+
+import java.io.File;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To persist a attachment.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class SaveAttachmentAction extends AbstractTuttiAction<TuttiUIContext, AttachmentEditorUI, AttachmentEditorUIHandler> {
+
+ private Attachment attachment;
+
+ public SaveAttachmentAction(AttachmentEditorUIHandler handler) {
+ super(handler, false);
+ }
+
+ protected File file;
+
+ protected File attachmentFile;
+
+ @Override
+ protected boolean prepareAction() throws Exception {
+ boolean doAction = super.prepareAction();
+ if (doAction) {
+
+ attachmentFile = getContext().getPersistenceService().getAttachmentFile(attachment.getId());
+
+ file = saveFile(
+ TuttiIOUtil.getBaseName(attachment.getName()),
+ TuttiIOUtil.getExtension(attachmentFile.getName()),
+ _("tutti.attachmentEditor.saveAttachment.title"),
+ _("tutti.attachmentEditor.saveAttachment.button"));
+ doAction = file != null;
+ }
+ return doAction;
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+
+ AttachmentEditorUI ui = getUI();
+
+ boolean hackDialog = ui.isAlwaysOnTop();
+ if (hackDialog) {
+ ui.setAlwaysOnTop(false);
+ }
+ try {
+
+ TuttiIOUtil.copyFile(attachmentFile, file,
+ _("tutti.attachmentEditor.saveAttachment.error.message", attachmentFile, file.getName()));
+ sendMessage(
+ _("tutti.attachmentEditor.saveAttachment.success.message", file.getName()));
+
+ } finally {
+ if (hackDialog) {
+ ui.setAlwaysOnTop(true);
+ }
+ }
+ }
+
+ public void setAttachment(Attachment attachment) {
+ this.attachment = attachment;
+ }
+
+ @Override
+ protected void releaseAction() {
+ super.releaseAction();
+ attachmentFile = null;
+ attachment = null;
+ file = null;
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/SaveAttachmentAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -445,7 +445,7 @@
nextCellAction.actionPerformed(null);
} else if (keyCode == KeyEvent.VK_UP ||
- (keyCode == KeyEvent.VK_ENTER && e.isShiftDown())) {
+ (keyCode == KeyEvent.VK_ENTER && e.isShiftDown())) {
e.consume();
if (editor != null) {
editor.stopCellEditing();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToNextEditableRowAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -59,7 +59,7 @@
if (log.isDebugEnabled()) {
log.debug("Move to next row editable cell " +
- getCellCoordinate(currentRow, currentColumn));
+ getCellCoordinate(currentRow, currentColumn));
}
int rowCount = getRowCount();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToPreviousEditableCellAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToPreviousEditableCellAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToPreviousEditableCellAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -79,7 +79,7 @@
}
// if (isCellEditable(currentRow, currentColumn)) {
- doSelectCell(currentRow, currentColumn);
+ doSelectCell(currentRow, currentColumn);
// break;
// } else {
// if (log.isDebugEnabled()) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToPreviousEditableRowAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToPreviousEditableRowAction.java 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/MoveToPreviousEditableRowAction.java 2013-07-27 21:21:41 UTC (rev 1160)
@@ -60,7 +60,7 @@
if (log.isDebugEnabled()) {
log.debug("Move to previous row editable cell " +
- getCellCoordinate(currentRow, currentColumn));
+ getCellCoordinate(currentRow, currentColumn));
}
int rowCount = getRowCount();
@@ -74,7 +74,7 @@
// boolean canSelect = isCellEditable(currentRow, currentColumn);
//
// if (canSelect) {
- doSelectCell(currentRow, currentColumn);
+ doSelectCell(currentRow, currentColumn);
// break;
// } else {
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-27 21:21:41 UTC (rev 1160)
@@ -63,7 +63,13 @@
tutti.commentEditor.action.tip=
tutti.commentEditor.none.tip=
tutti.commentEditor.title=
+tutti.common.askBeforeCloneProtocol.help=
tutti.common.askBeforeDelete.help=
+tutti.common.askBeforeEditProtocol.help=
+tutti.common.askBeforeEditProtocol.title=
+tutti.common.askBeforeEditProtocole.help=
+tutti.common.askBeforeEditProtocole.title=
+tutti.common.askBeforeImportProtocol.help=
tutti.common.askCancelEditBeforeLeaving.help=
tutti.common.askCancelEditBeforeLeaving.title=
tutti.common.askOverwriteFile.help=
@@ -73,7 +79,9 @@
tutti.common.askSaveBeforeLeaving.title=
tutti.common.cancel=
tutti.common.cancel.mnemonic=
+tutti.common.caracteristic.notFound=
tutti.common.datefield.tip=
+tutti.common.editProtocol.categories.not.compatible=
tutti.common.file.csv=
tutti.common.file.pdf=
tutti.common.file.protocol=
@@ -83,6 +91,7 @@
tutti.common.file.tuttiMarineLitter=
tutti.common.file.tuttiSpecies=
tutti.common.file.zip=
+tutti.common.protocol.categories.not.compatible=
tutti.common.validate=
tutti.common.validate.mnemonic=
tutti.config.action.reload.actions=
@@ -789,6 +798,7 @@
tutti.editProtocol.title.choose.speciesImportFile=
tutti.editProtocol.title.create.protocol=
tutti.editProtocol.title.edit.protocol=
+tutti.editProtocol.warn.clean=
tutti.editProtocol.warn.clone=
tutti.editProtocol.warn.import=
tutti.editSampleCategoryModel.action.cancel=
@@ -1162,6 +1172,13 @@
tutti.multiPostImportLog.title=
tutti.multiPostImportLog.totalSortedWeight=
tutti.multiPostImportLog.totalWeight=
+tutti.option.cancel=
+tutti.option.cleanAndClone=
+tutti.option.cleanAndEdit=
+tutti.option.cleanAndImport=
+tutti.option.clone=
+tutti.option.edit=
+tutti.option.import=
tutti.property.get.error=
tutti.property.set.error=
tutti.sampleCategoryModel.passwordDialog.error.message=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-27 14:13:54 UTC (rev 1159)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-27 21:21:41 UTC (rev 1160)
@@ -63,7 +63,11 @@
tutti.commentEditor.action.tip=Commentaire
tutti.commentEditor.none.tip=Pas de commentaire
tutti.commentEditor.title=Commentaire
+tutti.common.askBeforeCloneProtocol.help=Que voulez-vous faire?<ul><li><strong>Annuler</strong> pour ne pas cloner le protocole</li><li><strong>Cloner</strong> pour cloner le protocole en conservant les catégories non connues (elle ne seront pas affichées)</li><li><strong>Nettoyer et Cloner</strong> pour supprimer les catégories non compatibles dans le protocole cloné</li></ul>
tutti.common.askBeforeDelete.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas supprimer</li><li><strong>OK</strong> pour supprimer l'objet en question</li></ul>
+tutti.common.askBeforeEditProtocol.help=Que voulez-vous faire?<ul><li><strong>Annuler</strong> pour ne pas éditer le protocole</li><li><strong>Éditer</strong> pour éditer le protocole en conservant les catégories non connues (elle ne seront pas affichées)</li><li><strong>Nettoyer et Éditer</strong> pour supprimer les catégories non compatibles et éditer le protocole</li></ul>
+tutti.common.askBeforeEditProtocol.title=Catégories non compatibles détectées dans le protocole
+tutti.common.askBeforeImportProtocol.help=Que voulez-vous faire?<ul><li><strong>Annuler</strong> pour ne pas importer le protocole</li><li><strong>Importer</strong> pour importer le protocole en conservant les catégories non connues (elle ne seront pas affichées)</li><li><strong>Nettoyer et Importer</strong> pour supprimer les catégories non compatibles dans le protocole importé</li></ul>
tutti.common.askCancelEditBeforeLeaving.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour rester sur cet écran</li><li><strong>OK</strong> pour quitter l'écran en abandonnant les modifications</li></ul>
tutti.common.askCancelEditBeforeLeaving.title=Modifications non enregistrées mais invalides
tutti.common.askOverwriteFile.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas écraser le fichier et annuler l'opération</li><li><strong>Oui</strong> pour écraser le fichier et continuer l'opération</li></ul>
@@ -73,6 +77,7 @@
tutti.common.askSaveBeforeLeaving.title=Modifications non enregistrées
tutti.common.cancel=Annuler
tutti.common.cancel.mnemonic=A
+tutti.common.caracteristic.notFound=Caractéristique inconnue
tutti.common.datefield.tip=Format attendu \: %s
tutti.common.file.csv=Extension d'un fichier csv
tutti.common.file.pdf=Extension d'un fichier pdf
@@ -784,6 +789,7 @@
tutti.editProtocol.title.choose.speciesImportFile=Importer les espèces
tutti.editProtocol.title.create.protocol=Créer un nouveau protocole de saisie
tutti.editProtocol.title.edit.protocol=Éditer un protocole de saisie existant
+tutti.editProtocol.warn.clean=Des catégories non reconnues ont été supprimées du protocole, ces modifications ne seront sauvegardées que lorsque vous cliquerez sur le bouton "Enregistrer".
tutti.editProtocol.warn.clone=Le protocole que vous venez de cloner ne sera sauvegardé que lorsque vous cliquerez sur le bouton "Enregistrer".
tutti.editProtocol.warn.import=Le protocole que vous venez d'importer ne sera sauvegardé que lorsque vous cliquerez sur le bouton "Enregistrer".
tutti.editSampleCategoryModel.action.close=Fermer
@@ -1154,6 +1160,13 @@
tutti.multiPostImportLog.title=Lots non importés
tutti.multiPostImportLog.totalSortedWeight=Poids total trié \: %s kg
tutti.multiPostImportLog.totalWeight=Poids total \: %s kg
+tutti.option.cancel=Annuler
+tutti.option.cleanAndClone=Nettoyer et Cloner
+tutti.option.cleanAndEdit=Nettoyer et Éditer
+tutti.option.cleanAndImport=Nettoyer et Importer
+tutti.option.clone=Cloner
+tutti.option.edit=Éditer
+tutti.option.import=Importer
tutti.property.get.error=Propriété %1s non trouvée sur l'objet de type %2s
tutti.property.set.error=Propriété %1s non trouvée sur l'objet de type %2s
tutti.selectBenthos.title=Choisissez une espèce du benthos
@@ -1267,12 +1280,10 @@
tutti.updateApplication.message.success=La mise à jour nécessite le redémarrage du l'application
tutti.updateApplication.noUpdate=Aucune mise à jour de l'application détectée.
tutti.updateApplication.title.success=Redémarrage de l'application nécessaire...
-tutti.validateCruise.action.export.all.chooseFile.defaultFile=validation_%s.txt
tutti.validateCruise.action.export.all.chooseFile.label=Choisir le fichier d'export
tutti.validateCruise.action.export.all.chooseFile.title=Exporter les messages de validation de la campagne
tutti.validateCruise.action.export.all.success=Les messages de validation des captures ont correctement été exporté dans le fichier %s
tutti.validateCruise.action.export.all.tip=Exporter les messages de validation de la campagne
-tutti.validateCruise.action.export.operation.chooseFile.defaultFile=validation_%s.txt
tutti.validateCruise.action.export.operation.chooseFile.label=Choisir le fichier d'export
tutti.validateCruise.action.export.operation.chooseFile.title=Exporter les messages de validation de l'opération
tutti.validateCruise.action.export.operation.success=Les messages de validation de l'opération ont correctement été exporté dans le fichier %s
1
0
r1159 - in trunk: tutti-persistence/src/main/java/fr/ifremer/tutti/persistence tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species tutti-ui-swing/src/main/resources/i18n
by tchemit@users.forge.codelutin.com 27 Jul '13
by tchemit@users.forge.codelutin.com 27 Jul '13
27 Jul '13
Author: tchemit
Date: 2013-07-27 16:13:54 +0200 (Sat, 27 Jul 2013)
New Revision: 1159
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1159
Log:
refs #2889: [TECH] - Prise en compte de nouvelles cat?\195?\169gories dans l'applicatif (verification avant import pupitri)
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-27 13:48:21 UTC (rev 1158)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-27 14:13:54 UTC (rev 1159)
@@ -163,6 +163,11 @@
}
@Override
+ public List<Caracteristic> getAllCaracteristicForSampleCategory() {
+ throw notImplemented();
+ }
+
+ @Override
public List<Caracteristic> getAllNumericCaracteristic() {
throw notImplemented();
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java 2013-07-27 13:48:21 UTC (rev 1158)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java 2013-07-27 14:13:54 UTC (rev 1159)
@@ -48,10 +48,10 @@
result = TuttiUIUtil.askAdminPassword(
getContext().getActionUI(),
getConfig(),
- _("tutti.sampleCategoryModel.passwordDialog.message"),
- _("tutti.sampleCategoryModel.passwordDialog.title"),
- _("tutti.sampleCategoryModel.passwordDialog.error.message"),
- _("tutti.sampleCategoryModel.passwordDialog.error.title")
+ _("tutti.editSampleCategoryModel.passwordDialog.message"),
+ _("tutti.editSampleCategoryModel.passwordDialog.title"),
+ _("tutti.editSampleCategoryModel.passwordDialog.error.message"),
+ _("tutti.editSampleCategoryModel.passwordDialog.error.title")
);
}
return result;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java 2013-07-27 13:48:21 UTC (rev 1158)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java 2013-07-27 14:13:54 UTC (rev 1159)
@@ -24,9 +24,13 @@
* #L%
*/
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.pupitri.TuttiPupitriImportExportService;
import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationAction;
@@ -36,7 +40,9 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import javax.swing.JOptionPane;
+import javax.swing.UIManager;
import java.io.File;
+import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -75,24 +81,50 @@
@Override
protected boolean prepareAction() throws Exception {
boolean result = true;
- currentProtocol = getDataContext().getProtocol();
- SpeciesBatchUIModel speciesBatchUIModel = getUI().getModel();
- if (speciesBatchUIModel.getRowCount() > 0) {
- String htmlMessage = String.format(
- AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
- _("tutti.editSpeciesBatch.action.importPupitri.existingData.message"),
- _("tutti.editSpeciesBatch.action.importPupitri.existingData.help"));
+ // must check that sample category model is compatible for pupitri import
+ // means need some categories
- int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
- htmlMessage,
- _("tutti.editSpeciesBatch.action.importPupitri.existingData.title"),
- JOptionPane.OK_CANCEL_OPTION,
- JOptionPane.WARNING_MESSAGE);
+ TuttiEnumerationFile enumerationFile = persistenceService.getEnumerationFile();
+ SampleCategoryModel sampleCategoryModel = getDataContext().getSampleCategoryModel();
- result = answer == JOptionPane.OK_OPTION;
+ List<String> missingCategories = Lists.newArrayList();
+ if (!sampleCategoryModel.containsCategoryId(enumerationFile.PMFM_ID_SIZE_CATEGORY)) {
+ missingCategories.add("<li>" + persistenceService.getSizeCategoryCaracteristic().getParameterName() + "</li>");
}
+ if (!sampleCategoryModel.containsCategoryId(enumerationFile.PMFM_ID_SEX)) {
+ missingCategories.add("<li>" + persistenceService.getSexCaracteristic().getParameterName() + "</li>");
+ }
+ if (!missingCategories.isEmpty()) {
+ result = false;
+ JOptionPane.showMessageDialog(
+ getContext().getActionUI(),
+ _("tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.message", Joiner.on("").join(missingCategories)),
+ _("tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.title"),
+ JOptionPane.ERROR_MESSAGE,
+ UIManager.getIcon("error")
+ );
+ }
+ if (result) {
+ currentProtocol = getDataContext().getProtocol();
+ SpeciesBatchUIModel speciesBatchUIModel = getUI().getModel();
+ if (speciesBatchUIModel.getRowCount() > 0) {
+ String htmlMessage = String.format(
+ AbstractTuttiUIHandler.CONFIRMATION_FORMAT,
+ _("tutti.editSpeciesBatch.action.importPupitri.existingData.message"),
+ _("tutti.editSpeciesBatch.action.importPupitri.existingData.help"));
+
+ int answer = JOptionPane.showConfirmDialog(getContext().getActionUI(),
+ htmlMessage,
+ _("tutti.editSpeciesBatch.action.importPupitri.existingData.title"),
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.WARNING_MESSAGE);
+
+ result = answer == JOptionPane.OK_OPTION;
+ }
+ }
+
if (result) {
importPupitriDialog.open();
importedTrunkFile = importPupitriDialog.getTrunkFile().getSelectedFile();
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-27 13:48:21 UTC (rev 1158)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-27 14:13:54 UTC (rev 1159)
@@ -809,6 +809,10 @@
tutti.editSampleCategoryModel.action.save=
tutti.editSampleCategoryModel.action.save.mnemonic=
tutti.editSampleCategoryModel.action.save.tip=
+tutti.editSampleCategoryModel.passwordDialog.error.message=
+tutti.editSampleCategoryModel.passwordDialog.error.title=
+tutti.editSampleCategoryModel.passwordDialog.message=
+tutti.editSampleCategoryModel.passwordDialog.title=
tutti.editSampleCategoryModel.table.header.caracteristic=
tutti.editSampleCategoryModel.table.header.caracteristic.tip=
tutti.editSampleCategoryModel.table.header.label=
@@ -839,6 +843,8 @@
tutti.editSpeciesBatch.action.importPupitri.existingData.help=
tutti.editSpeciesBatch.action.importPupitri.existingData.message=
tutti.editSpeciesBatch.action.importPupitri.existingData.title=
+tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.message=
+tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.title=
tutti.editSpeciesBatch.action.importPupitri.mnemonic=
tutti.editSpeciesBatch.action.importPupitri.success=
tutti.editSpeciesBatch.action.importPupitri.tip=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-27 13:48:21 UTC (rev 1158)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-27 14:13:54 UTC (rev 1159)
@@ -121,11 +121,6 @@
tutti.config.option.update.url.description=URL de mise à jour
tutti.config.option.weights.rate.difference.totalAndSorted.description=Pourcentage de différence entre les Poids totaux VRAC triés et les poids totaux VRAC en dessous duquel on demande confirmation sur la saisie
tutti.config.parse.error=Erreur de parsing du fichier de configuration
-tutti.config.sampleCategoryModel.passwordDialog.error.message=Le mot de passe que vous avez entré est incorrect
-tutti.config.sampleCategoryModel.passwordDialog.error.title=Mot de passe incorrect
-tutti.config.sampleCategoryModel.passwordDialog.message=Vous souhaitez entrer dans une partie sensible de l'application
-tutti.config.sampleCategoryModel.passwordDialog.title=Zone sensible
-tutti.config.sampleCategoryModel.title=
tutti.config.sampleOrder.title=Catégorie d'échantillonnage
tutti.config.save.error=Erreur lors de la sauvegarde de la configuration dans le fichier %s
tutti.config.title=Configuration
@@ -806,6 +801,10 @@
tutti.editSampleCategoryModel.action.save=Enregistrer
tutti.editSampleCategoryModel.action.save.mnemonic=E
tutti.editSampleCategoryModel.action.save.tip=Enregistrer les modifications
+tutti.editSampleCategoryModel.passwordDialog.error.message=Le mot de passe que vous avez entré est incorrect
+tutti.editSampleCategoryModel.passwordDialog.error.title=Mot de passe incorrect
+tutti.editSampleCategoryModel.passwordDialog.message=Vous souhaitez entrer dans une partie sensible de l'application
+tutti.editSampleCategoryModel.passwordDialog.title=Zone sensible
tutti.editSampleCategoryModel.table.header.caracteristic=Caractéristique
tutti.editSampleCategoryModel.table.header.caracteristic.tip=Caractéristique de la catégorie
tutti.editSampleCategoryModel.table.header.label=Label
@@ -836,6 +835,8 @@
tutti.editSpeciesBatch.action.importPupitri.existingData.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas importer les données Pupitri et conserver les espèces saisies</li><li><strong>OK</strong> pour supprimer les espèces existantes et les remplacer par les données de Pupitri</li></ul>
tutti.editSpeciesBatch.action.importPupitri.existingData.message=Des espèces ont déjà été saisies dans la capture. Si vous continuez, elles vont être écrasées.
tutti.editSpeciesBatch.action.importPupitri.existingData.title=Données existantes
+tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.message=<html><body>Le modèle de catégorisation n'est pas compatible pour un import pupitri.<br> Il manque les catégories suivantes \: <ul>%s</ul><hr/>Veuillez ajouter cette catégorie dans la configuration de catégorisation (menu administration).</body></html>
+tutti.editSpeciesBatch.action.importPupitri.invalidSampleCategoryModel.title=Modèle de catégorisation non compatible
tutti.editSpeciesBatch.action.importPupitri.mnemonic=I
tutti.editSpeciesBatch.action.importPupitri.success=Import Pupitri réussi \: %1s espèces importées, %2s espèces rejetées
tutti.editSpeciesBatch.action.importPupitri.tip=Import Pupitri
@@ -1155,11 +1156,6 @@
tutti.multiPostImportLog.totalWeight=Poids total \: %s kg
tutti.property.get.error=Propriété %1s non trouvée sur l'objet de type %2s
tutti.property.set.error=Propriété %1s non trouvée sur l'objet de type %2s
-tutti.sampleCategoryModel.passwordDialog.error.message=
-tutti.sampleCategoryModel.passwordDialog.error.title=
-tutti.sampleCategoryModel.passwordDialog.message=
-tutti.sampleCategoryModel.passwordDialog.title=
-tutti.sampleOrder.caracteristicNotFound=La caractéristique d'id %s n'est pas prévue pour l’échantillonnage
tutti.selectBenthos.title=Choisissez une espèce du benthos
tutti.selectCruise.action.chooseCruiseExportFile=Exporter
tutti.selectCruise.action.chooseProgramExportFile=Exporter
1
0
27 Jul '13
Author: tchemit
Date: 2013-07-27 15:48:21 +0200 (Sat, 27 Jul 2013)
New Revision: 1158
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1158
Log:
refs #2889: [TECH] - Prise en compte de nouvelles cat?\195?\169gories dans l'applicatif (configuration des cat?\195?\169gories)
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java
trunk/tutti-ui-swing/src/main/resources/icons/action-down.png
trunk/tutti-ui-swing/src/main/resources/icons/action-up.png
Removed:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderButton.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderIdsTableCell.java
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapEditorUIHandler.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -221,6 +221,13 @@
List<Caracteristic> getAllCaracteristicWithProtected();
/**
+ *
+ * @return all caracteristics of the system useable for {@link SampleCategoryModel}.
+ * @since 2.5
+ */
+ List<Caracteristic> getAllCaracteristicForSampleCategory();
+
+ /**
* @return all numeric caracteristics of the system.
* @since 1.0.2
*/
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -173,6 +173,10 @@
return new IdPredicate<B>(id);
}
+ public static Predicate<Caracteristic> newSampleCategoryModelPredicate() {
+ return new SampleCategoryCaracteristicPredicate();
+ }
+
public static Predicate<SpeciesBatch> newSpeciesBatchCategoryPredicate(Integer cateogryId, Integer value) {
return new SpeciesBatchCategoryPredicate(cateogryId, value);
}
@@ -294,7 +298,7 @@
return value;
}
- public static <N extends Number> N getValueOrComputedValue(N value, N computedValue) {
+ public static <N extends Number> N getValueOrComputedValue(N value, N computedValue) {
return value == null ? computedValue : value;
}
@@ -323,17 +327,11 @@
}
}
- protected static class CaracteristicCategoryPredicate implements Predicate<Caracteristic> {
+ protected static class SampleCategoryCaracteristicPredicate implements Predicate<Caracteristic> {
- private final String id;
-
- public CaracteristicCategoryPredicate(String id) {
- this.id = id;
- }
-
@Override
public boolean apply(Caracteristic input) {
- return id.equals(input.getCategory());
+ return !CaracteristicType.TEXT.equals(input.getCaracteristicType());
}
}
@@ -366,7 +364,7 @@
public boolean apply(SpeciesBatch input) {
return id.equals(input.getSampleCategoryId()) &&
input.getSampleCategoryValue() instanceof CaracteristicQualitativeValue &&
- qualitativeValue.equals(((CaracteristicQualitativeValue)input.getSampleCategoryValue()).getIdAsInt());
+ qualitativeValue.equals(((CaracteristicQualitativeValue) input.getSampleCategoryValue()).getIdAsInt());
}
}
@@ -385,7 +383,7 @@
public boolean apply(BenthosBatch input) {
return id.equals(input.getSampleCategoryId()) &&
input.getSampleCategoryValue() instanceof CaracteristicQualitativeValue &&
- qualitativeValue.equals(((CaracteristicQualitativeValue)input.getSampleCategoryValue()).getIdAsInt());
+ qualitativeValue.equals(((CaracteristicQualitativeValue) input.getSampleCategoryValue()).getIdAsInt());
}
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/DecoratorService.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -104,7 +104,7 @@
registerTuttiDecorator(Gear.class, "${label}$s#${name}$s", SEPARATOR, " - ");
registerTuttiDecorator(Person.class, "${firstName}$s#${lastName}$s#${department}$s", SEPARATOR, " ");
registerTuttiDecorator(Caracteristic.class, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s", SEPARATOR, " - ");
- registerTuttiDecorator(CaracteristicBean.class, CARACTERISTIC_PARAMETER_ONLY, "${parameterName}$s", SEPARATOR, " - ");
+ registerTuttiDecorator(Caracteristic.class, CARACTERISTIC_PARAMETER_ONLY, "${parameterName}$s", SEPARATOR, " - ");
// registerMultiJXPathDecorator(Caracteristic.class, CARACTERISTIC_WITH_UNIT, "${parameterName}$s#${matrixName}$s#${fractionName}$s#${methodName}$s (${unit}$s)", SEPARATOR, " - ");
registerTuttiDecorator(CaracteristicQualitativeValue.class, "${name}$s", SEPARATOR, " - ");
registerTuttiDecorator(SpeciesProtocol.class, "${speciesReferenceTaxonId}", SEPARATOR, " - ");
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -25,12 +25,15 @@
*/
import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.TuttiIOUtil;
import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.TuttiPersistence;
import fr.ifremer.tutti.persistence.TuttiPersistenceNoDbImpl;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
@@ -349,6 +352,14 @@
}
@Override
+ public List<Caracteristic> getAllCaracteristicForSampleCategory() {
+ List<Caracteristic> allCaracteristicWithProtected = driver.getAllCaracteristicWithProtected();
+ List<Caracteristic> result = Lists.newArrayList(
+ Iterables.filter(allCaracteristicWithProtected, TuttiEntities.newSampleCategoryModelPredicate()));
+ return result;
+ }
+
+ @Override
public List<Caracteristic> getAllNumericCaracteristic() {
return driver.getAllNumericCaracteristic();
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -188,8 +188,7 @@
public void open(TuttiServiceConfig config, PersistenceService persistenceService) {
close();
this.service = persistenceService;
- sampleCategoryModel = config.getPersistenceConfig().getSampleCategoryModel();
- sampleCategoryModel.load(persistenceService);
+ loadSampleCategoryModel(config.getPersistenceConfig().getSampleCategoryModel());
}
@Override
@@ -719,6 +718,11 @@
caracteristics = null;
}
+ public void loadSampleCategoryModel(SampleCategoryModel sampleCategoryModel) {
+ this.sampleCategoryModel = sampleCategoryModel;
+ sampleCategoryModel.load(service);
+ }
+
protected void checkOpened() {
Preconditions.checkState(service != null, "No persistence service assigned!");
}
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-07-27 13:48:21 UTC (rev 1158)
@@ -22,7 +22,7 @@
# #L%
###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Tue Jul 23 13:28:56 CEST 2013
+#Sat Jul 27 15:12:29 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.save.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -229,6 +229,13 @@
tutti.editProtocol.field.vesselUseFeature.help=editProtocol.html\#fieldsCaracteristics
tutti.editProtocol.help=editProtocol.html
tutti.editProtocol.pane.caracteristic.help=editProtocol.html\#fieldsCaracteristics
+tutti.editSampleCategoryModel.action.cancel.help=
+tutti.editSampleCategoryModel.action.close.help=
+tutti.editSampleCategoryModel.action.moveDownEntry.help=
+tutti.editSampleCategoryModel.action.moveUpEntry.help=
+tutti.editSampleCategoryModel.action.removeEntry.help=
+tutti.editSampleCategoryModel.action.save.help=
+tutti.editSampleCategoryModel.help=
tutti.editSpeciesBatch.action.createBatch.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createMelag.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.editFrequencies.help=editFishingOperation.html\#captureEspecesActions
@@ -282,6 +289,7 @@
tutti.main.menu.action.editCruise.help=menu.html\#menu_action
tutti.main.menu.action.editProgram.help=menu.html\#menu_action
tutti.main.menu.action.editProtocol.help=menu.html\#menu_action
+tutti.main.menu.action.editSampleCategoryModel.help=
tutti.main.menu.action.exit.help=menu.html\#menu_fichier
tutti.main.menu.action.importTemporaryReferential.help=menu.html\#menu_administration
tutti.main.menu.action.manageDb.help=menu.html\#menu_fichier
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-07-27 13:48:21 UTC (rev 1158)
@@ -22,7 +22,7 @@
# #L%
###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
-#Tue Jul 23 13:28:56 CEST 2013
+#Sat Jul 27 15:12:29 CEST 2013
tutti.config.help=config.html
tutti.createAccidentalBatch.action.cancel.help=editFishingOperation.html\#captureCapturesAccidentellesActions
tutti.createAccidentalBatch.action.save.help=editFishingOperation.html\#captureCapturesAccidentellesActions
@@ -229,6 +229,13 @@
tutti.editProtocol.field.vesselUseFeature.help=editProtocol.html\#fieldsCaracteristics
tutti.editProtocol.help=editProtocol.html
tutti.editProtocol.pane.caracteristic.help=editProtocol.html\#fieldsCaracteristics
+tutti.editSampleCategoryModel.action.cancel.help=
+tutti.editSampleCategoryModel.action.close.help=
+tutti.editSampleCategoryModel.action.moveDownEntry.help=
+tutti.editSampleCategoryModel.action.moveUpEntry.help=
+tutti.editSampleCategoryModel.action.removeEntry.help=
+tutti.editSampleCategoryModel.action.save.help=
+tutti.editSampleCategoryModel.help=
tutti.editSpeciesBatch.action.createBatch.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.createMelag.help=editFishingOperation.html\#captureEspecesActions
tutti.editSpeciesBatch.action.editFrequencies.help=editFishingOperation.html\#captureEspecesActions
@@ -282,6 +289,7 @@
tutti.main.menu.action.editCruise.help=menu.html\#menu_action
tutti.main.menu.action.editProgram.help=menu.html\#menu_action
tutti.main.menu.action.editProtocol.help=menu.html\#menu_action
+tutti.main.menu.action.editSampleCategoryModel.help=
tutti.main.menu.action.exit.help=menu.html\#menu_fichier
tutti.main.menu.action.importTemporaryReferential.help=menu.html\#menu_administration
tutti.main.menu.action.manageDb.help=menu.html\#menu_fichier
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/TuttiScreen.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -24,6 +24,8 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+
/**
* Enumeration of any internal screen of application.
*
@@ -39,6 +41,12 @@
*/
CONFIG,
/**
+ * To edit {@link SampleCategoryModel}.
+ *
+ * @since 2.5
+ */
+ EDIT_SAMPLE_CATEGORY_MODEL,
+ /**
* To manage db used by Tutti.
*
* @since 1.0
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -0,0 +1,59 @@
+package fr.ifremer.tutti.ui.swing.content;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.ui.swing.TuttiScreen;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To show {@link TuttiScreen#EDIT_SAMPLE_CATEGORY_MODEL} config screen.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class EditSampleCategoryModelAction extends AbstractChangeScreenAction {
+
+ public EditSampleCategoryModelAction(MainUIHandler handler) {
+ super(handler, true, TuttiScreen.EDIT_SAMPLE_CATEGORY_MODEL);
+ }
+
+ @Override
+ protected boolean prepareAction() throws Exception {
+ boolean result = super.prepareAction();
+ if (result) {
+ result = TuttiUIUtil.askAdminPassword(
+ getContext().getActionUI(),
+ getConfig(),
+ _("tutti.sampleCategoryModel.passwordDialog.message"),
+ _("tutti.sampleCategoryModel.passwordDialog.title"),
+ _("tutti.sampleCategoryModel.passwordDialog.error.message"),
+ _("tutti.sampleCategoryModel.passwordDialog.error.title")
+ );
+ }
+ return result;
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/EditSampleCategoryModelAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/ImportTemporaryReferentialAction.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -25,10 +25,8 @@
*/
import fr.ifremer.tutti.ui.swing.TuttiScreen;
-import org.apache.commons.lang3.StringUtils;
-import org.nuiton.util.StringUtil;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import static org.nuiton.i18n.I18n._;
@@ -49,29 +47,14 @@
protected boolean prepareAction() throws Exception {
boolean result = super.prepareAction();
if (result) {
- String answer;
- do {
- answer = JOptionPane.showInputDialog(getContext().getActionUI(),
- _("tutti.manageTemporaryReferential.passwordDialog.message"),
- _("tutti.manageTemporaryReferential.passwordDialog.title"),
- JOptionPane.WARNING_MESSAGE);
- if (answer != null) {
- String cryptedAnswer = StringUtil.encodeMD5(answer);
- String correctAnswer = getConfig().getAdminPassword();
- result = StringUtils.equals(cryptedAnswer, correctAnswer);
-
- if (!result) {
- JOptionPane.showMessageDialog(getContext().getActionUI(),
- _("tutti.manageTemporaryReferential.passwordDialog.error.message"),
- _("tutti.manageTemporaryReferential.passwordDialog.error.title"),
- JOptionPane.ERROR_MESSAGE);
- }
-
- } else {
- result = false;
- }
-
- } while (!result && answer != null);
+ result = TuttiUIUtil.askAdminPassword(
+ getContext().getActionUI(),
+ getConfig(),
+ _("tutti.manageTemporaryReferential.passwordDialog.message"),
+ _("tutti.manageTemporaryReferential.passwordDialog.title"),
+ _("tutti.manageTemporaryReferential.passwordDialog.error.message"),
+ _("tutti.manageTemporaryReferential.passwordDialog.error.title")
+ );
}
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.css 2013-07-27 13:48:21 UTC (rev 1158)
@@ -50,6 +50,16 @@
_help: {"tutti.main.menu.action.configuration.help"};
}
+#menuEditSampleCategoryModel{
+ actionIcon: sampleOrder;
+ text: "tutti.main.action.editSampleCategoryModel";
+ toolTipText: "tutti.main.action.editSampleCategoryModel.tip";
+ i18nMnemonic: "tutti.main.action.editSampleCategoryModel.mnemonic";
+ enabled: {model.getScreen() != TuttiScreen.EDIT_SAMPLE_CATEGORY_MODEL};
+ _tuttiAction: {EditSampleCategoryModelAction.class};
+ _help: {"tutti.main.menu.action.editSampleCategoryModel.help"};
+}
+
#menuFileExit {
actionIcon: exit;
text: "tutti.main.action.exit";
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUI.jaxx 2013-07-27 13:48:21 UTC (rev 1158)
@@ -84,6 +84,7 @@
<JMenu id='menuAdministration'>
<JMenuItem id='menuImportTemporaryReferential'/>
+ <JMenuItem id='menuEditSampleCategoryModel'/>
</JMenu>
<JMenu id='menuHelp'>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -33,6 +33,7 @@
import fr.ifremer.tutti.ui.swing.TuttiScreen;
import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
+import fr.ifremer.tutti.ui.swing.content.config.EditSampleCategoryModelUI;
import fr.ifremer.tutti.ui.swing.content.config.TuttiConfigUI;
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUI;
import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIHandler;
@@ -399,6 +400,12 @@
icon = ui.getMenuFileConfiguration().getIcon();
break;
+ case EDIT_SAMPLE_CATEGORY_MODEL:
+
+ screenUI = new EditSampleCategoryModelUI(ui);
+ screenTitle = _("tutti.editSampleCategoryModel.title");
+ icon = ui.getMenuEditSampleCategoryModel().getIcon();
+ break;
default:
case MANAGE_DB:
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -0,0 +1,99 @@
+package fr.ifremer.tutti.ui.swing.content.config;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since TODO
+ */
+public class EditSampleCategoryModelRowModel extends AbstractTuttiBeanUIModel<SampleCategoryModelEntry, EditSampleCategoryModelRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_LABEL = "label";
+
+ public static final String PROPERTY_CARACTERISTIC = "caracteristic";
+
+ protected final SampleCategoryModelEntry editObject = new SampleCategoryModelEntry();
+
+ protected static final Binder<SampleCategoryModelEntry, EditSampleCategoryModelRowModel> fromBeanBinder =
+ BinderFactory.newBinder(SampleCategoryModelEntry.class,
+ EditSampleCategoryModelRowModel.class);
+
+ protected static final Binder<EditSampleCategoryModelRowModel, SampleCategoryModelEntry> toBeanBinder =
+ BinderFactory.newBinder(EditSampleCategoryModelRowModel.class,
+ SampleCategoryModelEntry.class);
+
+ public EditSampleCategoryModelRowModel() {
+ super(SampleCategoryModelEntry.class, fromBeanBinder, toBeanBinder);
+ }
+
+ public EditSampleCategoryModelRowModel(SampleCategoryModelEntry entry) {
+ this();
+ fromBean(entry);
+ }
+
+ @Override
+ protected SampleCategoryModelEntry newEntity() {
+ return new SampleCategoryModelEntry();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- SampleCategoryModelEntry delegate --//
+ //------------------------------------------------------------------------//
+
+ public String getLabel() {
+ return editObject.getLabel();
+ }
+
+ public void setLabel(String label) {
+ String oldValue = getLabel();
+ editObject.setLabel(label);
+ firePropertyChange(PROPERTY_LABEL, oldValue, label);
+ }
+
+ public Integer getCategoryId() {
+ return editObject.getCategoryId();
+ }
+
+ public Caracteristic getCaracteristic() {
+ return editObject.getCaracteristic();
+ }
+
+ public void setCaracteristic(Caracteristic caracteristic) {
+ Caracteristic oldValue = getCaracteristic();
+ editObject.setCaracteristic(caracteristic);
+ editObject.setCategoryId(caracteristic.getIdAsInt());
+ firePropertyChange(PROPERTY_CARACTERISTIC, oldValue, caracteristic);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelRowModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -0,0 +1,78 @@
+package fr.ifremer.tutti.ui.swing.content.config;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
+import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
+import org.jdesktop.swingx.table.TableColumnModelExt;
+
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * Model of table of {@link SampleCategoryModelEntry}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class EditSampleCategoryModelTableModel extends AbstractTuttiTableModel<EditSampleCategoryModelRowModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final ColumnIdentifier<EditSampleCategoryModelRowModel> CARACTERISTIC = ColumnIdentifier.newId(
+ EditSampleCategoryModelRowModel.PROPERTY_CARACTERISTIC,
+ n_("tutti.editSampleCategoryModel.table.header.caracteristic"),
+ n_("tutti.editSampleCategoryModel.table.header.caracteristic.tip"));
+
+ public static final ColumnIdentifier<EditSampleCategoryModelRowModel> LABEL = ColumnIdentifier.newId(
+ EditSampleCategoryModelRowModel.PROPERTY_LABEL,
+ n_("tutti.editSampleCategoryModel.table.header.label"),
+ n_("tutti.editSampleCategoryModel.table.header.label.tip"));
+
+ public EditSampleCategoryModelTableModel(TableColumnModelExt columnModel) {
+ super(columnModel, false, false);
+
+ setNoneEditableCols(CARACTERISTIC);
+ }
+
+ @Override
+ public EditSampleCategoryModelRowModel createNewRow() {
+ EditSampleCategoryModelRowModel result =
+ new EditSampleCategoryModelRowModel();
+
+ // by default empty row is not valid
+ result.setValid(false);
+ return result;
+ }
+
+ public void permuteEntry(int firstRow, int lastRow) {
+ EditSampleCategoryModelRowModel firstR = getRows().get(firstRow);
+
+ getRows().remove(firstRow);
+ getRows().add(lastRow, firstR);
+
+ fireTableRowsUpdated(firstRow, lastRow);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css 2013-07-27 13:48:21 UTC (rev 1158)
@@ -0,0 +1,95 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+BeanFilterableComboBox {
+ i18nPrefix: "tutti.property.";
+ showReset: true;
+}
+
+#editSampleCategoryModelTopPanel {
+ _help: {"tutti.editSampleCategoryModel.help"};
+}
+
+#table {
+ selectionMode: {ListSelectionModel.SINGLE_SELECTION};
+ selectionBackground: {null};
+ selectionForeground: {Color.BLACK};
+ sortable: false;
+}
+
+#availableCaracteristicsComboBox {
+ property: selectedCaracteristic;
+ enabled: {!availableCaracteristicsComboBox.isEmpty()};
+}
+
+#addRow {
+ actionIcon: add;
+ enabled: {availableCaracteristicsComboBox.getSelectedItem() != null};
+}
+
+#removeEntryMenu {
+ actionIcon: delete;
+ text: "tutti.editSampleCategoryModel.action.removeEntry";
+ toolTipText: "tutti.editSampleCategoryModel.action.removeEntry.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.removeEntry.mnemonic";
+ enabled: {model.isRemoveEntryEnabled()};
+ _help: {"tutti.editSampleCategoryModel.action.removeEntry.help"};
+}
+
+
+#moveUpEntryMenu {
+ actionIcon: up;
+ text: "tutti.editSampleCategoryModel.action.moveUpEntry";
+ toolTipText: "tutti.editSampleCategoryModel.action.moveUpEntry.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.moveUpEntry.mnemonic";
+ enabled: {model.isMoveUpEntryEnabled()};
+ _help: {"tutti.editSampleCategoryModel.action.moveUpEntry.help"};
+}
+
+#moveDownEntryMenu {
+ actionIcon: down;
+ text: "tutti.editSampleCategoryModel.action.moveDownEntry";
+ toolTipText: "tutti.editSampleCategoryModel.action.moveDownEntry.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.moveDownEntry.mnemonic";
+ enabled: {model.isMoveDownEntryEnabled()};
+ _help: {"tutti.editSampleCategoryModel.action.moveDownEntry.help"};
+}
+
+#closeButton {
+ actionIcon: cancel;
+ text: "tutti.editSampleCategoryModel.action.close";
+ toolTipText: "tutti.editSampleCategoryModel.action.close.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.close.mnemonic";
+ _tuttiAction: {fr.ifremer.tutti.ui.swing.content.SelectCruiseAction.class};
+ _help: {"tutti.editSampleCategoryModel.action.close.help"};
+}
+
+#saveButton {
+ actionIcon: save;
+ text: "tutti.editSampleCategoryModel.action.save";
+ toolTipText: "tutti.editSampleCategoryModel.action.save.tip";
+ i18nMnemonic: "tutti.editSampleCategoryModel.action.save.mnemonic";
+ enabled: {model.isModify() && model.isValid()};
+ _tuttiAction: {SaveSampleCategoryModelAction.class};
+ _help: {"tutti.editSampleCategoryModel.action.save.help"};
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx 2013-07-27 13:48:21 UTC (rev 1158)
@@ -0,0 +1,109 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 - 2013 Ifremer
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU 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 General Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JPanel id='editSampleCategoryModelTopPanel' layout='{new BorderLayout()}'
+ decorator='help'
+ implements='fr.ifremer.tutti.ui.swing.util.TuttiUI<EditSampleCategoryModelUIModel, EditSampleCategoryModelUIHandler>'>
+
+ <import>
+ fr.ifremer.tutti.persistence.entities.referential.Caracteristic
+
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.TuttiHelpBroker
+ fr.ifremer.tutti.ui.swing.util.TuttiUI
+
+ jaxx.runtime.swing.editor.bean.BeanFilterableComboBox
+
+ org.jdesktop.swingx.JXTable
+
+ javax.swing.ListSelectionModel
+
+ java.awt.Color
+ </import>
+
+ <script><![CDATA[
+
+public EditSampleCategoryModelUI(TuttiUI parentUI) {
+ JAXXUtil.initContext(this, parentUI);
+ TuttiUIContext context = parentUI.getHandler().getContext();
+ EditSampleCategoryModelUIHandler handler = new EditSampleCategoryModelUIHandler(context, this);
+ setContextValue(handler);
+ handler.beforeInitUI();
+}
+
+protected void $afterCompleteSetup() { handler.afterInitUI(); }
+ ]]></script>
+
+ <!-- bean property -->
+ <EditSampleCategoryModelUIModel id='model'
+ initializer='getContextValue(EditSampleCategoryModelUIModel.class)'/>
+
+ <EditSampleCategoryModelUIHandler id='handler'
+ initializer='getContextValue(EditSampleCategoryModelUIHandler.class)'/>
+
+ <TuttiHelpBroker id='broker'
+ constructorParams='"tutti.editSampleCategoryModel.help"'/>
+
+ <JPopupMenu id='tablePopup'>
+ <JMenuItem id='removeEntryMenu'
+ onActionPerformed='handler.removeEntry()'/>
+ <JMenuItem id='moveUpEntryMenu'
+ onActionPerformed='handler.moveUpEntry()'/>
+ <JMenuItem id='moveDownEntryMenu'
+ onActionPerformed='handler.moveDownEntry()'/>
+ </JPopupMenu>
+
+ <Table>
+
+ <row fill='both'>
+ <cell fill='both' weightx='1'>
+ <BeanFilterableComboBox id='availableCaracteristicsComboBox'
+ constructorParams='this'
+ genericType='Caracteristic'/>
+ </cell>
+ <cell fill='both'>
+ <JButton id='addRow' onActionPerformed='handler.addCaracteristic()'/>
+ </cell>
+ </row>
+ <row fill='both' weighty='1'>
+ <cell fill='both' columns='2'>
+ <JScrollPane id='tableScrollPane'>
+ <JXTable id='table'
+ onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'
+ onKeyPressed='handler.openRowMenu(event, tablePopup)'/>
+ </JScrollPane>
+ </cell>
+ </row>
+
+ <!-- Form Actions -->
+ <row fill='both'>
+ <cell fill='both' columns='2'>
+ <JPanel layout='{new GridLayout(1, 0)}'>
+ <JButton id='closeButton'/>
+ <JButton id='saveButton'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+</JPanel>
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUI.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -0,0 +1,367 @@
+package fr.ifremer.tutti.ui.swing.content.config;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.service.DecoratorService;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.util.Cancelable;
+import fr.ifremer.tutti.ui.swing.util.CloseableUI;
+import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIHandler;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.editor.bean.BeanFilterableComboBox;
+import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.table.DefaultTableColumnModelExt;
+
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Handler of ui {@link EditSampleCategoryModelUI}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class EditSampleCategoryModelUIHandler extends AbstractTuttiTableUIHandler<EditSampleCategoryModelRowModel, EditSampleCategoryModelUIModel, EditSampleCategoryModelUI> implements Cancelable, CloseableUI {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(EditSampleCategoryModelUIHandler.class);
+
+ protected PersistenceService persistenceService;
+
+ public EditSampleCategoryModelUIHandler(TuttiUIContext context, EditSampleCategoryModelUI ui) {
+ super(context, ui,
+ EditSampleCategoryModelRowModel.PROPERTY_CARACTERISTIC,
+ EditSampleCategoryModelRowModel.PROPERTY_LABEL);
+ this.persistenceService = context.getPersistenceService();
+ }
+
+ //------------------------------------------------------------------------//
+ //-- Public methods --//
+ //------------------------------------------------------------------------//
+
+ public void addCaracteristic() {
+ BeanFilterableComboBox<Caracteristic> keyCombo = ui.getAvailableCaracteristicsComboBox();
+ Caracteristic selectedItem = (Caracteristic) keyCombo.getSelectedItem();
+
+ getModel().removeCaracteristic(selectedItem);
+
+ EditSampleCategoryModelTableModel tableModel = getTableModel();
+
+ EditSampleCategoryModelRowModel row = tableModel.createNewRow();
+ row.setCaracteristic(selectedItem);
+
+ tableModel.addNewRow(row);
+
+ recomputeRowValidState(row);
+
+ getModel().setModify(true);
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getTable().requestFocus();
+
+ int rowIndex = getTable().getRowCount() - 1;
+
+ SwingUtil.editCell(getTable(), rowIndex, 1);
+ }
+ });
+ }
+
+ public void removeEntry() {
+ int selectedRow = getTable().getSelectedRow();
+ Preconditions.checkState(selectedRow > -1);
+
+ // get selected row
+ EditSampleCategoryModelRowModel entry = getTableModel().getEntry(selectedRow);
+
+ // get his caracteristic
+ Caracteristic caracteristic = entry.getCaracteristic();
+
+ // push it back to model
+ getModel().addCaracteristic(caracteristic);
+
+ // remove entry from table model
+ getTableModel().removeRow(selectedRow);
+
+ getModel().setModify(true);
+ }
+
+ public void moveUpEntry() {
+ int selectedRow = getTable().getSelectedRow();
+ Preconditions.checkState(selectedRow > -1);
+
+ int newRow = selectedRow - 1;
+
+ getTableModel().permuteEntry(newRow, selectedRow);
+ getTable().getSelectionModel().setSelectionInterval(newRow, newRow);
+ getModel().setModify(true);
+ }
+
+ public void moveDownEntry() {
+ int selectedRow = getTable().getSelectedRow();
+ Preconditions.checkState(selectedRow > -1);
+ int newRow = selectedRow + 1;
+
+ getTableModel().permuteEntry(selectedRow, newRow);
+ getTable().getSelectionModel().setSelectionInterval(newRow, newRow);
+ getModel().setModify(true);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiTableUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public EditSampleCategoryModelTableModel getTableModel() {
+ return (EditSampleCategoryModelTableModel) getTable().getModel();
+ }
+
+ @Override
+ protected JComponent getComponentToFocus() {
+ return ui.getAvailableCaracteristicsComboBox();
+ }
+
+ @Override
+ public JXTable getTable() {
+ return ui.getTable();
+ }
+
+ @Override
+ protected boolean isRowValid(EditSampleCategoryModelRowModel row) {
+ boolean result = StringUtils.isNotBlank(row.getLabel());
+
+ return result;
+ }
+
+ @Override
+ protected void onAfterSelectedRowChanged(int oldRowIndex, EditSampleCategoryModelRowModel oldRow, int newRowIndex, EditSampleCategoryModelRowModel newRow) {
+ super.onAfterSelectedRowChanged(oldRowIndex, oldRow, newRowIndex, newRow);
+ recomputePopupActions();
+ }
+
+ @Override
+ protected void saveSelectedRowIfRequired(TuttiBeanMonitor<EditSampleCategoryModelRowModel> rowMonitor,
+ EditSampleCategoryModelRowModel row) {
+
+ }
+
+ @Override
+ protected void onRowModified(int rowIndex,
+ EditSampleCategoryModelRowModel row,
+ String propertyName,
+ Object oldValue,
+ Object newValue) {
+ recomputeRowValidState(row);
+ saveSelectedRowIfNeeded();
+
+ // when row valid state has changed, recompute action enabled states
+ recomputePopupActions();
+ getModel().setModify(true);
+ }
+
+ //------------------------------------------------------------------------//
+ //-- CloseableUI methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public boolean quitUI() {
+ boolean result = quitScreen(
+ getModel().isValid(),
+ getModel().isModify(),
+ _("tutti.editProtocol.askCancelEditBeforeLeaving.cancelSaveSampleCategoryModel"),
+ _("tutti.editProtocol.askSaveBeforeLeaving.saveSampleCategoryModel"),
+ ui.getSaveButton().getAction()
+ );
+ return result;
+ }
+
+ //------------------------------------------------------------------------//
+ //-- AbstractTuttiUIHandler methods --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public void beforeInitUI() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("for " + ui);
+ }
+
+ List<Caracteristic> caracteristics = Lists.newArrayList(
+ persistenceService.getAllCaracteristicForSampleCategory());
+
+ SampleCategoryModel sampleCategoryModel =
+ getDataContext().getSampleCategoryModel();
+
+ EditSampleCategoryModelUIModel model = new EditSampleCategoryModelUIModel(
+ persistenceService.getEnumerationFile(),
+ sampleCategoryModel.getCategory(),
+ caracteristics);
+
+ ui.setContextValue(model);
+ }
+
+ @Override
+ public void afterInitUI() {
+ initUI(ui);
+
+ EditSampleCategoryModelUIModel model = getModel();
+
+ initBeanFilterableComboBox(ui.getAvailableCaracteristicsComboBox(),
+ model.getCaracteristicList(),
+ null);
+
+ model.addPropertyChangeListener(EditSampleCategoryModelUIModel.PROPERTY_CARACTERISTIC_LIST, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug("propertyChange " + EditSampleCategoryModelUIModel.PROPERTY_CARACTERISTIC_LIST);
+ }
+ ui.getAvailableCaracteristicsComboBox().setData(null);
+ ui.getAvailableCaracteristicsComboBox().setData((List<Caracteristic>) evt.getNewValue());
+ ui.getAvailableCaracteristicsComboBox().setSelectedItem(null);
+ }
+ });
+
+ JXTable table = getTable();
+
+ // create table column model
+ DefaultTableColumnModelExt columnModel =
+ new DefaultTableColumnModelExt();
+
+ {
+ // Category column
+
+ addColumnToModel(columnModel,
+ null,
+ newTableCellRender(Caracteristic.class, DecoratorService.CARACTERISTIC_PARAMETER_ONLY),
+ EditSampleCategoryModelTableModel.CARACTERISTIC);
+
+
+ }
+
+ { // Label column
+
+ addColumnToModel(columnModel,
+ null,
+ null,
+ EditSampleCategoryModelTableModel.LABEL);
+ }
+
+ // create table model
+ EditSampleCategoryModelTableModel tableModel =
+ new EditSampleCategoryModelTableModel(columnModel);
+
+ table.setModel(tableModel);
+ table.setColumnModel(columnModel);
+
+ initTable(table);
+
+ List<EditSampleCategoryModelRowModel> rows = model.getRows();
+ tableModel.setRows(rows);
+
+ recomputePopupActions();
+
+ model.setModify(true);
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ getModel().setModify(false);
+ }
+ });
+
+ }
+
+ @Override
+ protected void initTable(JXTable table) {
+ super.initTable(table);
+ installTableKeyListener(table.getColumnModel(), table);
+ }
+
+ @Override
+ public void cancel() {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Cancel UI " + ui);
+ }
+
+ // close dialog
+ closeUI(ui);
+ }
+
+ @Override
+ public void onCloseUI() {
+
+ }
+
+ @Override
+ public SwingValidator<EditSampleCategoryModelUIModel> getValidator() {
+ return null;
+ }
+
+
+ //------------------------------------------------------------------------//
+ //-- Internal methods --//
+ //------------------------------------------------------------------------//
+
+ protected void recomputePopupActions() {
+
+ int rowIndex = getTable().getSelectedRow();
+
+ boolean enableRemoveEntry = false;
+ boolean enableMoveUpEntry = false;
+ boolean enableMoveDownEntry = false;
+
+ if (rowIndex != -1) {
+
+ // there is a selected row
+ enableRemoveEntry = true;
+
+ enableMoveUpEntry = rowIndex > 0;
+
+ enableMoveDownEntry = rowIndex < getTable().getModel().getRowCount() - 1;
+ }
+ EditSampleCategoryModelUIModel model = getModel();
+ model.setRemoveEntryEnabled(enableRemoveEntry);
+ model.setMoveUpEntryEnabled(enableMoveUpEntry);
+ model.setMoveDownEntryEnabled(enableMoveDownEntry);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -0,0 +1,161 @@
+package fr.ifremer.tutti.ui.swing.content.config;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry;
+import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
+import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableUIModel;
+import org.nuiton.util.beans.Binder;
+import org.nuiton.util.beans.BinderFactory;
+
+import java.util.List;
+
+/**
+ * TODO
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class EditSampleCategoryModelUIModel extends AbstractTuttiTableUIModel<SampleCategoryModel, EditSampleCategoryModelRowModel, EditSampleCategoryModelUIModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PROPERTY_CARACTERISTIC_LIST = "caracteristicList";
+
+ public static final String PROPERTY_REMOVE_ENTRY_ENABLED = "removeEntryEnabled";
+
+ public static final String PROPERTY_MOVE_UP_ENTRY_ENABLED = "moveUpEntryEnabled";
+
+ public static final String PROPERTY_MOVE_DOWN_ENTRY_ENABLED = "moveDownEntryEnabled";
+
+ protected final SampleCategoryModelEntry firstCategory;
+
+ protected final List<Caracteristic> caracteristicList;
+
+ protected static Binder<SampleCategoryModel, EditSampleCategoryModelUIModel> fromBeanBinder =
+ BinderFactory.newBinder(SampleCategoryModel.class,
+ EditSampleCategoryModelUIModel.class);
+
+ protected static Binder<EditSampleCategoryModelUIModel, SampleCategoryModel> toBeanBinder =
+ BinderFactory.newBinder(EditSampleCategoryModelUIModel.class, SampleCategoryModel.class);
+
+ private boolean removeEntryEnabled;
+
+ private boolean moveUpEntryEnabled;
+
+ private boolean moveDownEntryEnabled;
+
+ public EditSampleCategoryModelUIModel(TuttiEnumerationFile enumerationFile,
+ List<SampleCategoryModelEntry> category,
+ List<Caracteristic> caracteristicList) {
+
+ super(SampleCategoryModel.class, fromBeanBinder, toBeanBinder);
+
+ Preconditions.checkNotNull(caracteristicList, "need a not null caracteristicList");
+ Preconditions.checkNotNull(enumerationFile, "need a not null enumerationFile");
+ Preconditions.checkNotNull(category, "need a not null category list");
+ Preconditions.checkArgument(!category.isEmpty(), "need at least one first category (sorted-unsorted)");
+ this.caracteristicList = caracteristicList;
+ this.firstCategory = category.get(0);
+ Preconditions.checkArgument(enumerationFile.PMFM_ID_SORTED_UNSORTED.equals(firstCategory.getCategoryId()), "first category must be sorted-unsorted caracteristic but was: " + firstCategory.getCategoryId());
+
+ List<EditSampleCategoryModelRowModel> rows = Lists.newArrayList();
+
+ for (SampleCategoryModelEntry sampleCategoryModelEntry : category) {
+ caracteristicList.remove(sampleCategoryModelEntry.getCaracteristic());
+ if (firstCategory.equals(sampleCategoryModelEntry)) {
+ continue;
+ }
+ EditSampleCategoryModelRowModel row = new EditSampleCategoryModelRowModel();
+ row.setCaracteristic(sampleCategoryModelEntry.getCaracteristic());
+ row.setLabel(sampleCategoryModelEntry.getLabel());
+ row.setValid(true);
+ rows.add(row);
+ }
+ setRows(rows);
+ }
+
+ @Override
+ protected SampleCategoryModel newEntity() {
+ List<SampleCategoryModelEntry> entries = Lists.newArrayList(firstCategory);
+ int order = 1;
+ for (EditSampleCategoryModelRowModel row : getRows()) {
+ SampleCategoryModelEntry entry = new SampleCategoryModelEntry();
+ entry.setCategoryId(row.getCategoryId());
+ entry.setLabel(row.getLabel());
+ entry.setOrder(order++);
+ entries.add(entry);
+ }
+ return new SampleCategoryModel(entries);
+ }
+
+ public List<Caracteristic> getCaracteristicList() {
+ return caracteristicList;
+ }
+
+ public boolean isRemoveEntryEnabled() {
+ return removeEntryEnabled;
+ }
+
+ public void setRemoveEntryEnabled(boolean removeEntryEnabled) {
+ boolean oldValue = isRemoveEntryEnabled();
+ this.removeEntryEnabled = removeEntryEnabled;
+ firePropertyChange(PROPERTY_REMOVE_ENTRY_ENABLED, oldValue, removeEntryEnabled);
+ }
+
+ public boolean isMoveUpEntryEnabled() {
+ return moveUpEntryEnabled;
+ }
+
+ public void setMoveUpEntryEnabled(boolean moveUpEntryEnabled) {
+ boolean oldValue = isMoveUpEntryEnabled();
+ this.moveUpEntryEnabled = moveUpEntryEnabled;
+ firePropertyChange(PROPERTY_MOVE_UP_ENTRY_ENABLED, oldValue, moveUpEntryEnabled);
+ }
+
+ public boolean isMoveDownEntryEnabled() {
+ return moveDownEntryEnabled;
+ }
+
+ public void setMoveDownEntryEnabled(boolean moveDownEntryEnabled) {
+ boolean oldValue = isMoveDownEntryEnabled();
+ this.moveDownEntryEnabled = moveDownEntryEnabled;
+ firePropertyChange(PROPERTY_MOVE_DOWN_ENTRY_ENABLED, oldValue, moveDownEntryEnabled);
+ }
+
+ public void addCaracteristic(Caracteristic caracteristic) {
+ caracteristicList.add(caracteristic);
+ firePropertyChange(PROPERTY_CARACTERISTIC_LIST, null, caracteristicList);
+ }
+
+ public void removeCaracteristic(Caracteristic caracteristic) {
+ caracteristicList.remove(caracteristic);
+ firePropertyChange(PROPERTY_CARACTERISTIC_LIST, null, caracteristicList);
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/EditSampleCategoryModelUIModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderButton.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderButton.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderButton.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -1,139 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.config;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import jaxx.runtime.SwingUtil;
-
-import javax.swing.JToggleButton;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import java.awt.Point;
-import java.awt.event.HierarchyBoundsAdapter;
-import java.awt.event.HierarchyEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
-public class SampleOrderButton extends JToggleButton {
-
- private static final long serialVersionUID = 1L;
-
- protected final SampleOrderEditorUI popup;
-
- protected Point popupPosition = null;
-
- protected boolean popupMoving;
-
- public SampleOrderButton(TuttiUIContext context,
- List<Caracteristic> model) {
-
- setIcon(SwingUtil.createActionIcon("sampleOrder"));
- setToolTipText(_("tutti.config.action.sampleOrder.tip"));
-
- popup = new SampleOrderEditorUI(context);
-
- popup.addWindowListener(new WindowAdapter() {
-
- @Override
- public void windowOpened(WindowEvent e) {
- setSelected(true);
- }
-
- @Override
- public void windowClosing(WindowEvent e) {
- setSelected(false);
- }
-
- @Override
- public void windowClosed(WindowEvent e) {
- setSelected(false);
- }
- });
-
- addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- if (isSelected()) {
- if (!popup.isVisible()) {
- popup.openEditor(SampleOrderButton.this);
- }
- } else {
- popup.closeEditor();
- }
- }
- });
-
- addHierarchyBoundsListener(new HierarchyBoundsAdapter() {
-
- @Override
- public void ancestorMoved(HierarchyEvent e) {
- if (popup.isShowing()) {
-
- // place dialog just under the button
- Point point = new Point(getLocationOnScreen());
- point.translate(-popup.getWidth() + getWidth(), getHeight());
- popupMoving = true;
- try {
- popup.setLocation(point);
- } finally {
- popupMoving = false;
- }
- }
- }
- });
- setBean(model);
- }
-
- public void init() {
- popup.getHandler().init();
- }
-
- public void init(List<Caracteristic> model) {
- setBean(model);
- init();
- }
-
- public void onCloseUI() {
- setSelected(false);
- }
-
- public List<Caracteristic> getBean() {
- return popup.getListModel().toList();
- }
-
- protected void setBean(List<Caracteristic> model) {
- popup.setBean(model);
- init();
- }
-
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.css 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.css 2013-07-27 13:48:21 UTC (rev 1158)
@@ -1,36 +0,0 @@
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-#samplingOrderEditorDialog {
- undecorated: true;
- alwaysOnTop: true;
-}
-
-#sampleOrderEditorTopPanel {
- title: "tutti.config.sampleOrder.title";
-}
-
-#list {
- model: {listModel};
- selectionMode: {ListSelectionModel.SINGLE_SELECTION};
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.jaxx 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUI.jaxx 2013-07-27 13:48:21 UTC (rev 1158)
@@ -1,77 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 - 2013 Ifremer
- %%
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU 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 General Public
- License along with this program. If not, see
- <http://www.gnu.org/licenses/gpl-3.0.html>.
- #L%
- -->
-<JDialog id='samplingOrderEditorDialog' layout='{new BorderLayout()}'>
-
- <import>
- fr.ifremer.tutti.persistence.entities.referential.Caracteristic
- fr.ifremer.tutti.ui.swing.TuttiUIContext
-
- jaxx.runtime.swing.model.JaxxDefaultListModel
-
- org.jdesktop.swingx.JXTitledPanel
- javax.swing.JComponent
- javax.swing.ListSelectionModel
- </import>
-
- <script><![CDATA[
-
-public SampleOrderEditorUI(TuttiUIContext context) {
- super(context.getMainUI());
- setContextValue(context);
- SampleOrderEditorUIHandler handler = new SampleOrderEditorUIHandler(context, this);
- setContextValue(handler);
- handler.beforeInitUI();
-}
-
-protected void $afterCompleteSetup() {
- getHandler().afterInitUI();
-}
-
-public void openEditor(JComponent component) {
- handler.openEditor(component);
-}
-
-public void closeEditor() {
- handler.closeEditor();
-}
-
- ]]></script>
-
- <!-- bean property -->
- <java.util.List id='bean' genericType='Caracteristic' javaBean='null'/>
-
- <SampleOrderEditorUIHandler id='handler'
- initializer='getContextValue(SampleOrderEditorUIHandler.class)'/>
-
- <JaxxDefaultListModel id='listModel' genericType='Caracteristic'/>
-
- <JXTitledPanel id='sampleOrderEditorTopPanel'
- constraints='BorderLayout.CENTER'>
-
- <JScrollPane>
- <JList id='list'/>
- </JScrollPane>
-
- </JXTitledPanel>
-</JDialog>
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUIHandler.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderEditorUIHandler.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -1,240 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.config;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicBean;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.ComponentMover;
-import jaxx.runtime.swing.ComponentResizer;
-import jaxx.runtime.swing.model.JaxxDefaultListModel;
-import jaxx.runtime.swing.renderer.MultiDecoratorListCellRenderer;
-import org.nuiton.decorator.JXPathDecorator;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JList;
-import javax.swing.JRootPane;
-import javax.swing.JToolBar;
-import javax.swing.KeyStroke;
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
-public class SampleOrderEditorUIHandler {
-
- private static final int DEFAULT_EDITOR_WIDTH = 300;
-
- private static final int DEFAULT_EDITOR_HEIGHT = 200;
-
- public static final String CLOSE_DIALOG_ACTION = "closeDialog";
-
- public static final String SHOW_DIALOG_ACTION = "showDialog";
-
- protected final TuttiUIContext context;
-
- private final SampleOrderEditorUI ui;
-
- public SampleOrderEditorUIHandler(TuttiUIContext context,
- SampleOrderEditorUI ui) {
- this.context = context;
- this.ui = ui;
- }
-
- protected void beforeInitUI() {
- }
-
- protected void afterInitUI() {
-
- ui.setResizable(true);
-
- ui.setSize(DEFAULT_EDITOR_WIDTH, DEFAULT_EDITOR_HEIGHT);
- ui.pack();
-
- ComponentResizer cr = new ComponentResizer();
- cr.registerComponent(ui);
- ComponentMover cm = new ComponentMover();
- cm.setDragInsets(cr.getDragInsets());
- cm.registerComponent(ui);
-
- JRootPane rootPane = ui.getRootPane();
-
- KeyStroke shortcutClosePopup =
- KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
-
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
- shortcutClosePopup, CLOSE_DIALOG_ACTION);
-
- closeAction = new AbstractAction() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void actionPerformed(ActionEvent e) {
- ui.dispose();
- ui.setVisible(false);
- }
- };
-
- openAction = new AbstractAction() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void actionPerformed(ActionEvent e) {
- ui.setVisible(true);
- }
- };
-
- ImageIcon actionIcon = SwingUtil.createActionIcon("close-dialog");
- closeAction.putValue(Action.SMALL_ICON, actionIcon);
- closeAction.putValue(Action.LARGE_ICON_KEY, actionIcon);
- closeAction.putValue(Action.ACTION_COMMAND_KEY, "close");
- closeAction.putValue(Action.NAME, "close");
- closeAction.putValue(Action.SHORT_DESCRIPTION, _("tutti.commentEditor.action.close.tip"));
-
- rootPane.getActionMap().put(CLOSE_DIALOG_ACTION, closeAction);
- rootPane.getActionMap().put(SHOW_DIALOG_ACTION, openAction);
-
- JButton closeButton = new JButton(closeAction);
- closeButton.setText(null);
- closeButton.setFocusPainted(false);
- closeButton.setRequestFocusEnabled(false);
- closeButton.setFocusable(false);
-
- JToolBar jToolBar = new JToolBar();
- jToolBar.setOpaque(false);
- jToolBar.add(closeAction);
- jToolBar.setBorderPainted(false);
- jToolBar.setFloatable(false);
- ui.getSampleOrderEditorTopPanel().setRightDecoration(jToolBar);
-
- JXPathDecorator<CaracteristicBean> decorator =
- (JXPathDecorator<CaracteristicBean>) context.getDecoratorService().getDecoratorByType(
- CaracteristicBean.class, DecoratorService.CARACTERISTIC_PARAMETER_ONLY);
- ui.getList().setCellRenderer(new MultiDecoratorListCellRenderer(decorator));
-
- ui.getList().addKeyListener(new KeyAdapter() {
-
- JaxxDefaultListModel<Caracteristic> listModel = ui.getListModel();
-
- @Override
- public void keyReleased(KeyEvent e) {
- super.keyReleased(e);
- JList list = (JList) e.getSource();
-
- if (!list.isSelectionEmpty()) {
-
- int selectedIndex = list.getSelectedIndex();
-
- Integer newSelectedIndex = null;
-
- if (e.getKeyCode() == KeyEvent.VK_DOWN) {
-
- if (selectedIndex < listModel.size()) {
-
- // can move to down
- newSelectedIndex = selectedIndex - 1;
-
- Caracteristic remove = listModel.remove(newSelectedIndex);
-
- listModel.insertElementAt(remove, selectedIndex);
- }
- } else if (e.getKeyCode() == KeyEvent.VK_UP) {
-
- if (selectedIndex >= 0) {
-
- // can move to up
- newSelectedIndex = selectedIndex + 1;
-
- Caracteristic remove = listModel.remove(newSelectedIndex);
- listModel.insertElementAt(remove, selectedIndex);
- }
- }
-
- if (newSelectedIndex != null) {
- list.setSelectedIndex(selectedIndex);
- }
- }
-
- }
- });
- }
-
- protected Action closeAction;
-
- protected Action openAction;
-
- public void closeEditor() {
-
- closeAction.actionPerformed(null);
- }
-
- public void openEditor(JComponent component) {
-
- if (component != null) {
- place(component);
- }
- openAction.actionPerformed(null);
- }
-
- public void init() {
-
- List<Caracteristic> bean = ui.getBean();
- ui.getListModel().setAllElements(bean);
- }
-
- public void place(JComponent component) {
- // Computes the location of bottom left corner of the cell
- Component comp = component;
- int x = 0;
- int y = component.getHeight();
- while (comp != null) {
- x += comp.getX();
- y += comp.getY();
- comp = comp.getParent();
- }
-
-// ui.pack();
- // if the editor is too big on the right,
- // then align its right side to the right side of the cell
- if (x + ui.getWidth() > ui.getOwner().getX() + ui.getOwner().getWidth()) {
- x = x - ui.getWidth() + component.getWidth();
- }
- ui.setLocation(x, y);
- }
-}
\ No newline at end of file
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderIdsTableCell.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderIdsTableCell.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SampleOrderIdsTableCell.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -1,200 +0,0 @@
-package fr.ifremer.tutti.ui.swing.content.config;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 - 2013 Ifremer
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import fr.ifremer.tutti.TuttiTechnicalException;
-import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
-import fr.ifremer.tutti.persistence.entities.referential.CaracteristicBean;
-import fr.ifremer.tutti.service.DecoratorService;
-import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.ui.swing.TuttiUIContext;
-import org.nuiton.decorator.Decorator;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JTable;
-import javax.swing.border.LineBorder;
-import javax.swing.event.CellEditorListener;
-import javax.swing.event.ChangeEvent;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Color;
-import java.awt.Component;
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * To edit sampling oder ids in a table cell.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
-public class SampleOrderIdsTableCell {
-
- protected final Decorator<CaracteristicBean> decorator;
-
- protected final Map<Integer, Object> mapping;
-
- protected final Map<Integer, Caracteristic> caracteristicMap;
-
- private final TuttiUIContext context;
-
- public SampleOrderIdsTableCell(TuttiUIContext context) {
-
- this.context = context;
- this.mapping = null;
- this.caracteristicMap = Maps.newTreeMap();
-
- PersistenceService persistenceService = context.getPersistenceService();
-// this.caracteristicMap.put(SampleCategoryEnum.size.getFieldValue(), persistenceService.getSizeCategoryCaracteristic());
-// this.caracteristicMap.put(SampleCategoryEnum.sex.getFieldValue(), persistenceService.getSexCaracteristic());
-// this.caracteristicMap.put(SampleCategoryEnum.maturity.getFieldValue(), persistenceService.getMaturityCaracteristic());
-// this.caracteristicMap.put(SampleCategoryEnum.age.getFieldValue(), persistenceService.getAgeCaracteristic());
-
- this.decorator = context.getDecoratorService().getDecoratorByType(
- CaracteristicBean.class,
- DecoratorService.CARACTERISTIC_PARAMETER_ONLY);
- }
-
- public TableCellEditor getNewTableCellEditor() {
- return new SampleOrderCellEditor(context);
- }
-
- public TableCellRenderer getNewTableCellRenderer() {
- return new SamplingOrderIdsTableCellRenderer();
- }
-
- protected class SamplingOrderIdsTableCellRenderer extends DefaultTableCellRenderer {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public Component getTableCellRendererComponent(JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row, int column) {
-
- Integer[] ids = (Integer[]) value;
- List<String> texts = Lists.newArrayListWithCapacity(ids.length);
- for (Integer id : ids) {
- Caracteristic caracteristic = caracteristicMap.get(id);
- texts.add(decorator.toString(caracteristic));
- }
- String text = Joiner.on(",").join(texts);
- return super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);
- }
- }
-
- /**
- * @author tchemit <chemit(a)codelutin.com>
- * @since 1.1
- */
- public class SampleOrderCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- private static final long serialVersionUID = 1L;
-
- protected Integer rowIndex;
-
- protected Integer columnIndex;
-
- protected final SampleOrderButton editorButton;
-
- protected SampleOrderCellEditor(TuttiUIContext context) {
-
- this.editorButton = new SampleOrderButton(context, null);
- this.editorButton.setBorder(new LineBorder(Color.BLACK));
- addCellEditorListener(new CellEditorListener() {
- @Override
- public void editingStopped(ChangeEvent e) {
- editorButton.setSelected(false);
- }
-
- @Override
- public void editingCanceled(ChangeEvent e) {
- editorButton.setSelected(false);
- }
- });
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table,
- Object value,
- boolean isSelected,
- int row,
- int column) {
- Integer[] ids = (Integer[]) value;
-
- rowIndex = row;
- columnIndex = column;
-
- List<Caracteristic> result = Lists.newArrayList();
- for (Integer id : ids) {
- Object sampleCategoryEnum = mapping.get(id);
- if (sampleCategoryEnum == null) {
- throw new TuttiTechnicalException(_("tutti.sampleOrder.caracteristicNotFound", id));
- }
- Caracteristic caracteristic = caracteristicMap.get(id);
- result.add(caracteristic);
- }
-
- editorButton.init(result);
-
- return editorButton;
- }
-
- @Override
- public Object getCellEditorValue() {
-
- List<Integer> l = Lists.newArrayList();
- List<Caracteristic> model = editorButton.getBean();
- for (Caracteristic caracteristic : model) {
- String id = caracteristic.getId();
- l.add(Integer.valueOf(id));
- }
- return l.toArray(new Integer[l.size()]);
- }
-
- @Override
- public boolean stopCellEditing() {
- boolean b = super.stopCellEditing();
- if (b) {
- editorButton.setSelected(false);
- }
- return b;
- }
-
- @Override
- public void cancelCellEditing() {
- editorButton.setSelected(false);
- super.cancelCellEditing();
- }
- }
-}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -0,0 +1,66 @@
+package fr.ifremer.tutti.ui.swing.content.config;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * To save the sample category model.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class SaveSampleCategoryModelAction extends AbstractTuttiAction<EditSampleCategoryModelUIModel, EditSampleCategoryModelUI, EditSampleCategoryModelUIHandler> {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(SaveSampleCategoryModelAction.class);
+
+ public SaveSampleCategoryModelAction(EditSampleCategoryModelUIHandler handler) {
+ super(handler, true);
+ }
+
+ @Override
+ protected void doAction() throws Exception {
+ EditSampleCategoryModelUIModel model = getModel();
+
+ SampleCategoryModel bean = model.toBean();
+
+ if (log.isInfoEnabled()) {
+ log.info("Will save sampleCategoryModel: " + bean);
+ }
+ getConfig().getServiceConfig().getPersistenceConfig().setSampleCategoryModel(bean);
+
+ getConfig().save();
+
+ getDataContext().loadSampleCategoryModel(bean);
+
+ model.setModify(false);
+
+ }
+}
\ No newline at end of file
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/SaveSampleCategoryModelAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/config/TuttiConfigUIHandler.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -45,7 +45,6 @@
import org.apache.commons.logging.LogFactory;
import javax.swing.JComponent;
-import javax.swing.table.TableCellEditor;
import java.awt.BorderLayout;
import static org.nuiton.i18n.I18n.n_;
@@ -143,13 +142,6 @@
helper.addOption(TuttiServiceConfigOption.EXPORT_COUNTRY_ID)
.setOptionEditor(tuttiLocationTableCellComponent.getNewTableCellEditor())
.setOptionRenderer(tuttiLocationTableCellComponent.getNewTableCellRenderer());
-
- SampleOrderIdsTableCell comp = new SampleOrderIdsTableCell(context);
-
- TableCellEditor sampleOrderEditor = comp.getNewTableCellEditor();
- helper.addOption(TuttiServiceConfigOption.SAMPLING_CATEGORY_ORDER_IDS)
- .setOptionEditor(sampleOrderEditor)
- .setOptionRenderer(comp.getNewTableCellRenderer());
}
// UI
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -27,16 +27,19 @@
import com.google.common.base.Preconditions;
import fr.ifremer.tutti.TuttiBusinessException;
import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.ui.swing.config.TuttiApplicationConfig;
import jaxx.runtime.FileChooserUtil;
import jaxx.runtime.JAXXBinding;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.SwingUtil;
import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.beans.AbstractBean;
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
+import org.nuiton.util.StringUtil;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
@@ -372,4 +375,38 @@
float result = intValue / 10f;
return result;
}
+
+
+ public static boolean askAdminPassword(Component container,
+ TuttiApplicationConfig config,
+ String askMessage,
+ String askMessageTitle,
+ String errorMessage,
+ String errorMessageTitle) {
+ String answer;
+ boolean result;
+ do {
+ answer = JOptionPane.showInputDialog(container,
+ askMessage,
+ askMessageTitle,
+ JOptionPane.WARNING_MESSAGE);
+ if (answer != null) {
+ String cryptedAnswer = StringUtil.encodeMD5(answer);
+ String correctAnswer = config.getAdminPassword();
+ result = StringUtils.equals(cryptedAnswer, correctAnswer);
+
+ if (!result) {
+ JOptionPane.showMessageDialog(container,
+ errorMessage,
+ errorMessageTitle,
+ JOptionPane.ERROR_MESSAGE);
+ }
+
+ } else {
+ result = false;
+ }
+
+ } while (!result && answer != null);
+ return result;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapEditorUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapEditorUIHandler.java 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/caracteristics/CaracteristicMapEditorUIHandler.java 2013-07-27 13:48:21 UTC (rev 1158)
@@ -118,7 +118,7 @@
@Override
public void beforeInitUI() {
- CaracteristicMapEditorUIModel model = createModel();
+ CaracteristicMapEditorUIModel model = new CaracteristicMapEditorUIModel();
getUI().setContextValue(model);
}
@@ -195,10 +195,6 @@
return ui.getNewRowKey();
}
- protected CaracteristicMapEditorUIModel createModel() {
- return new CaracteristicMapEditorUIModel();
- }
-
protected void saveRow(CaracteristicMapEditorRowModel row) {
if (row.isValid()) {
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-27 13:48:21 UTC (rev 1158)
@@ -92,6 +92,8 @@
tutti.config.application=
tutti.config.category.applications=
tutti.config.category.applications.description=
+tutti.config.category.sampleCategoryModel=
+tutti.config.category.sampleCategoryModel.description=
tutti.config.category.technical=
tutti.config.category.technical.description=
tutti.config.category.ui=
@@ -119,6 +121,11 @@
tutti.config.option.update.url.description=
tutti.config.option.weights.rate.difference.totalAndSorted.description=
tutti.config.parse.error=
+tutti.config.sampleCategoryModel.passwordDialog.error.message=
+tutti.config.sampleCategoryModel.passwordDialog.error.title=
+tutti.config.sampleCategoryModel.passwordDialog.message=
+tutti.config.sampleCategoryModel.passwordDialog.title=
+tutti.config.sampleCategoryModel.title=
tutti.config.sampleOrder.title=
tutti.config.save.error=
tutti.config.title=
@@ -746,7 +753,9 @@
tutti.editProtocol.action.selectOtherSpecies.mnemonic=
tutti.editProtocol.action.selectOtherSpecies.tip=
tutti.editProtocol.askCancelEditBeforeLeaving.cancelSaveProtocol=
+tutti.editProtocol.askCancelEditBeforeLeaving.cancelSaveSampleCategoryModel=
tutti.editProtocol.askSaveBeforeLeaving.saveProtocol=
+tutti.editProtocol.askSaveBeforeLeaving.saveSampleCategoryModel=
tutti.editProtocol.field.benthos.tip=
tutti.editProtocol.field.comment=
tutti.editProtocol.field.comment.tip=
@@ -782,6 +791,29 @@
tutti.editProtocol.title.edit.protocol=
tutti.editProtocol.warn.clone=
tutti.editProtocol.warn.import=
+tutti.editSampleCategoryModel.action.cancel=
+tutti.editSampleCategoryModel.action.cancel.mnemonic=
+tutti.editSampleCategoryModel.action.cancel.tip=
+tutti.editSampleCategoryModel.action.close=
+tutti.editSampleCategoryModel.action.close.mnemonic=
+tutti.editSampleCategoryModel.action.close.tip=
+tutti.editSampleCategoryModel.action.moveDownEntry=
+tutti.editSampleCategoryModel.action.moveDownEntry.mnemonic=
+tutti.editSampleCategoryModel.action.moveDownEntry.tip=
+tutti.editSampleCategoryModel.action.moveUpEntry=
+tutti.editSampleCategoryModel.action.moveUpEntry.mnemonic=
+tutti.editSampleCategoryModel.action.moveUpEntry.tip=
+tutti.editSampleCategoryModel.action.removeEntry=
+tutti.editSampleCategoryModel.action.removeEntry.mnemonic=
+tutti.editSampleCategoryModel.action.removeEntry.tip=
+tutti.editSampleCategoryModel.action.save=
+tutti.editSampleCategoryModel.action.save.mnemonic=
+tutti.editSampleCategoryModel.action.save.tip=
+tutti.editSampleCategoryModel.table.header.caracteristic=
+tutti.editSampleCategoryModel.table.header.caracteristic.tip=
+tutti.editSampleCategoryModel.table.header.label=
+tutti.editSampleCategoryModel.table.header.label.tip=
+tutti.editSampleCategoryModel.title=
tutti.editSpeciesBatch.action.createBatch=
tutti.editSpeciesBatch.action.createBatch.mnemonic=
tutti.editSpeciesBatch.action.createBatch.tip=
@@ -1000,6 +1032,9 @@
tutti.main.action.editCatches.mnemonic=
tutti.main.action.editCatches.tip=
tutti.main.action.editProgram.tip=
+tutti.main.action.editSampleCategoryModel=
+tutti.main.action.editSampleCategoryModel.mnemonic=
+tutti.main.action.editSampleCategoryModel.tip=
tutti.main.action.editSelectedCruise=
tutti.main.action.editSelectedCruise.mnemonic=
tutti.main.action.editSelectedCruise.tip=
@@ -1123,6 +1158,10 @@
tutti.multiPostImportLog.totalWeight=
tutti.property.get.error=
tutti.property.set.error=
+tutti.sampleCategoryModel.passwordDialog.error.message=
+tutti.sampleCategoryModel.passwordDialog.error.title=
+tutti.sampleCategoryModel.passwordDialog.message=
+tutti.sampleCategoryModel.passwordDialog.title=
tutti.sampleOrder.caracteristicNotFound=
tutti.selectBenthos.title=
tutti.selectCruise.action.chooseCruiseExportFile=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-26 09:37:07 UTC (rev 1157)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-27 13:48:21 UTC (rev 1158)
@@ -92,6 +92,8 @@
tutti.config.application=Configuration de l'application Tutti
tutti.config.category.applications=Application
tutti.config.category.applications.description=Application
+tutti.config.category.sampleCategoryModel=Catégories de captures
+tutti.config.category.sampleCategoryModel.description=Configurer les catégories de captures
tutti.config.category.technical=Technique
tutti.config.category.technical.description=Informations techniques
tutti.config.category.ui=Interface utilisateur
@@ -119,6 +121,11 @@
tutti.config.option.update.url.description=URL de mise à jour
tutti.config.option.weights.rate.difference.totalAndSorted.description=Pourcentage de différence entre les Poids totaux VRAC triés et les poids totaux VRAC en dessous duquel on demande confirmation sur la saisie
tutti.config.parse.error=Erreur de parsing du fichier de configuration
+tutti.config.sampleCategoryModel.passwordDialog.error.message=Le mot de passe que vous avez entré est incorrect
+tutti.config.sampleCategoryModel.passwordDialog.error.title=Mot de passe incorrect
+tutti.config.sampleCategoryModel.passwordDialog.message=Vous souhaitez entrer dans une partie sensible de l'application
+tutti.config.sampleCategoryModel.passwordDialog.title=Zone sensible
+tutti.config.sampleCategoryModel.title=
tutti.config.sampleOrder.title=Catégorie d'échantillonnage
tutti.config.save.error=Erreur lors de la sauvegarde de la configuration dans le fichier %s
tutti.config.title=Configuration
@@ -746,7 +753,9 @@
tutti.editProtocol.action.selectOtherSpecies.mnemonic=.
tutti.editProtocol.action.selectOtherSpecies.tip=Sélectionner une autre espèce (dans les synonymes)
tutti.editProtocol.askCancelEditBeforeLeaving.cancelSaveProtocol=Le protocole n'est pas valide et ne peut pas être enregistré
+tutti.editProtocol.askCancelEditBeforeLeaving.cancelSaveSampleCategoryModel=La catégorisation n'est pas valide et ne peut pas être enregistré
tutti.editProtocol.askSaveBeforeLeaving.saveProtocol=Des modifications sur le protocole n'ont pas été enregistrées
+tutti.editProtocol.askSaveBeforeLeaving.saveSampleCategoryModel=Des modifications sur la catégorisation n'ont pas été enregistrées
tutti.editProtocol.field.benthos.tip=Benthos
tutti.editProtocol.field.comment=Commentaire
tutti.editProtocol.field.comment.tip=Commentaire
@@ -782,6 +791,26 @@
tutti.editProtocol.title.edit.protocol=Éditer un protocole de saisie existant
tutti.editProtocol.warn.clone=Le protocole que vous venez de cloner ne sera sauvegardé que lorsque vous cliquerez sur le bouton "Enregistrer".
tutti.editProtocol.warn.import=Le protocole que vous venez d'importer ne sera sauvegardé que lorsque vous cliquerez sur le bouton "Enregistrer".
+tutti.editSampleCategoryModel.action.close=Fermer
+tutti.editSampleCategoryModel.action.close.mnemonic=F
+tutti.editSampleCategoryModel.action.close.tip=Fermer l'édition des catégories
+tutti.editSampleCategoryModel.action.moveDownEntry=Descendre
+tutti.editSampleCategoryModel.action.moveDownEntry.mnemonic=D
+tutti.editSampleCategoryModel.action.moveDownEntry.tip=Descendre l'entrée sélectionnée
+tutti.editSampleCategoryModel.action.moveUpEntry=Monter
+tutti.editSampleCategoryModel.action.moveUpEntry.mnemonic=M
+tutti.editSampleCategoryModel.action.moveUpEntry.tip=Monter l'entrée sélectionnée
+tutti.editSampleCategoryModel.action.removeEntry=Supprimer
+tutti.editSampleCategoryModel.action.removeEntry.mnemonic=S
+tutti.editSampleCategoryModel.action.removeEntry.tip=Supprimer l'entrée sélectionnée
+tutti.editSampleCategoryModel.action.save=Enregistrer
+tutti.editSampleCategoryModel.action.save.mnemonic=E
+tutti.editSampleCategoryModel.action.save.tip=Enregistrer les modifications
+tutti.editSampleCategoryModel.table.header.caracteristic=Caractéristique
+tutti.editSampleCategoryModel.table.header.caracteristic.tip=Caractéristique de la catégorie
+tutti.editSampleCategoryModel.table.header.label=Label
+tutti.editSampleCategoryModel.table.header.label.tip=Label de la catéogire (sera utilisée dans les entêtes de tableau)
+tutti.editSampleCategoryModel.title=Configurer les catégorisations
tutti.editSpeciesBatch.action.createBatch=Créer un lot pour une espèce
tutti.editSpeciesBatch.action.createBatch.mnemonic=C
tutti.editSpeciesBatch.action.createBatch.tip=Créer un nouveau lot pour une espèce
@@ -1000,6 +1029,9 @@
tutti.main.action.editCatches.mnemonic=S
tutti.main.action.editCatches.tip=Éditer les captures
tutti.main.action.editProgram.tip=Éditer la série de campagne
+tutti.main.action.editSampleCategoryModel=Configurer les catégorisations
+tutti.main.action.editSampleCategoryModel.mnemonic=o
+tutti.main.action.editSampleCategoryModel.tip=Configurer les catégorisations possibles
tutti.main.action.editSelectedCruise=Campagne
tutti.main.action.editSelectedCruise.mnemonic=C
tutti.main.action.editSelectedCruise.tip=Éditer la campagne sélectionnée
@@ -1123,6 +1155,10 @@
tutti.multiPostImportLog.totalWeight=Poids total \: %s kg
tutti.property.get.error=Propriété %1s non trouvée sur l'objet de type %2s
tutti.property.set.error=Propriété %1s non trouvée sur l'objet de type %2s
+tutti.sampleCategoryModel.passwordDialog.error.message=
+tutti.sampleCategoryModel.passwordDialog.error.title=
+tutti.sampleCategoryModel.passwordDialog.message=
+tutti.sampleCategoryModel.passwordDialog.title=
tutti.sampleOrder.caracteristicNotFound=La caractéristique d'id %s n'est pas prévue pour l’échantillonnage
tutti.selectBenthos.title=Choisissez une espèce du benthos
tutti.selectCruise.action.chooseCruiseExportFile=Exporter
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-down.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-down.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/tutti-ui-swing/src/main/resources/icons/action-up.png
===================================================================
(Binary files differ)
Property changes on: trunk/tutti-ui-swing/src/main/resources/icons/action-up.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
26 Jul '13
Author: tchemit
Date: 2013-07-26 11:37:07 +0200 (Fri, 26 Jul 2013)
New Revision: 1157
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1157
Log:
refs #2889: [TECH] - Prise en compte de nouvelles cat?\195?\169gories dans l'applicatif (validation des captures)
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-07-26 09:37:07 UTC (rev 1157)
@@ -426,8 +426,10 @@
}
if (sm != null) {
- boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(sm.getPmfm().getId());
- if (isSamplingCategory) {
+ boolean isFrequency = batchHelper.isFrequencyBatch(sampleCategoryModel, source);
+
+// boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(sm.getPmfm().getId());
+ if (!isFrequency) {
Integer qualitativeId = null;
if (sm.getQualitativeValue() != null) {
qualitativeId = sm.getQualitativeValue().getId();
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-07-26 09:37:07 UTC (rev 1157)
@@ -913,15 +913,16 @@
* @return {@code true} if given batch is a frequency batch,
* {@code false} otherwise.
*/
- protected boolean isFrequencyBatch(SampleCategoryModel sampleCategoryModel,
+ public boolean isFrequencyBatch(SampleCategoryModel sampleCategoryModel,
SortingBatch sortingBatch) {
boolean result = false;
if (sortingBatch.getSortingMeasurements().size() == 1) {
SortingMeasurement sm
= sortingBatch.getSortingMeasurements().iterator().next();
Pmfm pmfm = sm.getPmfm();
- result = !sampleCategoryModel.containsCategoryId(pmfm.getId());
+ result = sortingBatch.getIndividualCount() != null &&
+ !sampleCategoryModel.containsCategoryId(pmfm.getId());
}
return result;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/CancelEditFishingOperationAction.java 2013-07-26 09:37:07 UTC (rev 1157)
@@ -83,6 +83,7 @@
// re-edit current fishing operation (but do not perform any check)
action.setCheckPreviousEdit(false);
action.setFishingOperation(getModel().getFishingOperation());
+ action.setInternalAction(true);
TuttiActionHelper.runInternalAction(action);
}
@@ -99,4 +100,9 @@
// }
}
+ @Override
+ public void postSuccessAction() {
+ super.postSuccessAction();
+ getEditAction().displayValidationErrors();
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-07-26 09:37:07 UTC (rev 1157)
@@ -35,6 +35,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
import fr.ifremer.tutti.ui.swing.content.operation.catches.ComputeWeightsAction;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
@@ -44,6 +45,7 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -111,6 +113,20 @@
*/
protected SaveCatchBatchAction saveCatchBatchAction;
+ /**
+ * To keep catch validation error while loading batches.
+ *
+ * @since 2.5
+ */
+ protected List<String> errorMessages = Lists.newArrayList();
+
+ /**
+ * Flag to know if this action is part of another action.
+ *
+ * @since 2.5
+ */
+ protected boolean internalAction;
+
private final PropertyChangeListener coordinatePropertiesListener = new PropertyChangeListener() {
private List<String> properties = Lists.newArrayList(
@@ -166,6 +182,7 @@
protected void releaseAction() {
fishingOperation = null;
checkPreviousEdit = true;
+ internalAction = false;
super.releaseAction();
}
@@ -282,7 +299,6 @@
// ok will revert any modification by
// editing new fishing operation (if user says yes)
canContinue = handler.askCancelEditBeforeLeaving(message);
-
}
}
}
@@ -315,6 +331,8 @@
@Override
protected void doAction() throws Exception {
+ errorMessages.clear();
+
if (log.isInfoEnabled()) {
log.info("Try to edit fishingOperation: " + fishingOperation);
}
@@ -333,7 +351,7 @@
loadFishingOperation(fishingOperation);
- loadCatchBatch(fishingOperation, true);
+ loadCatchBatch(fishingOperation);
JTabbedPane form = ui.getTabPane();
JLabel noContentPane = ui.getNoTraitPane();
@@ -369,8 +387,20 @@
super.postSuccessAction();
getUI().getFishingOperationTabContent().getModel().setModify(false);
getUI().repaint();
+
+ if (!internalAction) {
+ displayValidationErrors();
+ }
}
+ public void displayValidationErrors() {
+ if (CollectionUtils.isNotEmpty(errorMessages)) {
+ for (String errorMessage : errorMessages) {
+ TuttiUIContext.getErrorHelper().showErrorDialog(errorMessage, null);
+ }
+ }
+ }
+
public void loadFishingOperation(FishingOperation bean) {
EditFishingOperationUI ui = getUI().getFishingOperationTabContent();
@@ -466,8 +496,7 @@
handler.installCoordinatesListener();
}
- public void loadCatchBatch(FishingOperation bean,
- boolean loadOtherTabs) {
+ public void loadCatchBatch(FishingOperation bean) {
boolean empty = bean == null || TuttiEntities.isNew(bean);
@@ -485,6 +514,9 @@
List<Attachment> attachments;
+ boolean catchNotFound;
+ boolean catchEnabled;
+
if (empty) {
// create a new CatchBatch
@@ -496,7 +528,8 @@
attachments = Collections.emptyList();
- getModel().setCatchEnabled(true);
+ catchEnabled = true;
+ catchNotFound = false;
} else {
@@ -522,8 +555,8 @@
batch.setFishingOperation(bean);
Integer objectId = Integer.valueOf(batch.getId());
attachments = persistenceService.getAllAttachments(catchesUIModel.getObjectType(), objectId);
- getModel().setCatchNotFound(false);
- getModel().setCatchEnabled(true);
+ catchNotFound = false;
+ catchEnabled = true;
} catch (InvalidBatchModelException e) {
@@ -534,7 +567,8 @@
batch = null;
attachments = Collections.emptyList();
- getModel().setCatchEnabled(false);
+ catchEnabled = false;
+ catchNotFound = false;
}
} else {
@@ -542,32 +576,104 @@
batch = null;
attachments = Collections.emptyList();
- getModel().setCatchEnabled(false);
- getModel().setCatchNotFound(true);
+ catchEnabled = false;
+ catchNotFound = true;
}
}
- catchesUIModel.setCatchBatch(batch);
- catchesUIModel.setFishingOperation(bean);
- catchesUIModel.fromBean(batch);
- catchesUIModel.addAllAttachment(attachments);
- catchesUIModel.setModify(false);
- catchBatchMonitor.clearModified();
+ setCatch(bean,
+ attachments,
+ catchesUIModel,
+ catchBatchMonitor,
+ batch,
+ true,
+ catchEnabled,
+ catchNotFound);
- if (loadOtherTabs) {
- // 4) Propagate new selected fishingoperation to others tabs
+ // 4) Propagate new selected fishingoperation to others tabs
- FishingOperation operationToLoad = batch == null ? null : bean;
+ FishingOperation operationToLoad = batch == null ? null : bean;
+ boolean catchValid = true;
+
+ try {
ui.getSpeciesTabContent().getHandler().selectFishingOperation(operationToLoad);
+ } catch (InvalidBatchModelException e) {
+
+ // invalid sample category model
+ if (log.isDebugEnabled()) {
+ log.debug("Invalid sample category model", e);
+ }
+ errorMessages.add(e.getMessage());
+ catchValid = false;
+ }
+
+ try {
ui.getBenthosTabContent().getHandler().selectFishingOperation(operationToLoad);
+ } catch (InvalidBatchModelException e) {
+
+ // invalid sample category model
+ if (log.isDebugEnabled()) {
+ log.debug("Invalid sample category model", e);
+ }
+ errorMessages.add(e.getMessage());
+ catchValid = false;
+ }
+
+ if (catchValid) {
+
+ // load other tabs
+
ui.getMarineLitterTabContent().getHandler().selectFishingOperation(operationToLoad);
ui.getAccidentalTabContent().getHandler().selectFishingOperation(operationToLoad);
ui.getIndividualObservationTabContent().getHandler().selectFishingOperation(operationToLoad);
+
+ } else {
+
+ // remove catch
+ setCatch(bean,
+ Collections.<Attachment>emptyList(),
+ catchesUIModel,
+ catchBatchMonitor,
+ null,
+ false,
+ false,
+ false);
}
catchesUIModel.setLoadingData(false);
}
+ @Override
+ public void postFailedAction(Throwable error) {
+ super.postFailedAction(error);
+ }
+
+
+ protected void setCatch(FishingOperation bean,
+ List<Attachment> attachments,
+ EditCatchesUIModel catchesUIModel,
+ TuttiBeanMonitor<EditCatchesUIModel> catchBatchMonitor,
+ CatchBatch batch,
+ boolean sampleModelValid,
+ boolean catchEnabled,
+ boolean catchNotFound) {
+
+ getModel().setCatchEnabled(catchEnabled);
+ getModel().setCatchNotFound(catchNotFound);
+ getModel().setSampleCatchModelValid(sampleModelValid);
+
+ catchesUIModel.setCatchBatch(batch);
+ catchesUIModel.setFishingOperation(bean);
+ catchesUIModel.fromBean(batch);
+ catchesUIModel.addAllAttachment(attachments);
+
+ catchesUIModel.setModify(false);
+ catchBatchMonitor.clearModified();
+ }
+
+ public void setInternalAction(boolean internalAction) {
+ this.internalAction = internalAction;
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUI.css 2013-07-26 09:37:07 UTC (rev 1157)
@@ -63,7 +63,7 @@
#warningLabel {
actionIcon: warning;
border: {new javax.swing.border.EmptyBorder(5, 10, 5, 10)};
- text: {handler.getCatchWarningLabel(model.isCatchEnabled(), model.isCatchNotFound())};
+ text: {handler.getCatchWarningLabel(model.isCatchEnabled(), model.isCatchNotFound(), model.isSampleCatchModelValid())};
}
#catchesTab {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIHandler.java 2013-07-26 09:37:07 UTC (rev 1157)
@@ -275,8 +275,12 @@
//------------------------------------------------------------------------//
public String getCatchWarningLabel(boolean catchEnabled,
- boolean catchNotFound) {
+ boolean catchNotFound,
+ boolean catchSampleModelValid) {
String result = null;
+ if (!catchSampleModelValid) {
+ result = _("tutti.fishingOperations.warn.catchBatch.invalidSampleCategoryModel");
+ } else
if (catchNotFound) {
result = _("tutti.fishingOperations.warn.catchBatch.notFound");
} else if (!catchEnabled) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/FishingOperationsUIModel.java 2013-07-26 09:37:07 UTC (rev 1157)
@@ -58,6 +58,8 @@
public static final String PROPERTY_CATCH_NOT_FOUND = "catchNotFound";
+ public static final String PROPERTY_SAMPLE_CATCH_MODEL_VALID = "sampleCatchModelValid";
+
/**
* List of existing fishing operation for the selected cruise.
* <p/>
@@ -118,6 +120,17 @@
protected boolean catchEnabled = true;
/**
+ * Flag to know if sample catch model is valid or not on the selected
+ * fishing operation.
+ * <p/>
+ * <strong>Note:</strong> When value is {@code false}, then
+ * {@link #catchEnabled} is always to {@code false} too.
+ *
+ * @since 2.5
+ */
+ protected boolean sampleCatchModelValid = true;
+
+ /**
* Flag setted to true when no catch found.
*
* @since 2.2
@@ -234,4 +247,14 @@
this.catchNotFound = catchNotFound;
firePropertyChange(PROPERTY_CATCH_NOT_FOUND, oldValue, catchNotFound);
}
+
+ public boolean isSampleCatchModelValid() {
+ return sampleCatchModelValid;
+ }
+
+ public void setSampleCatchModelValid(boolean sampleCatchModelValid) {
+ boolean oldValue = isSampleCatchModelValid();
+ this.sampleCatchModelValid = sampleCatchModelValid;
+ firePropertyChange(PROPERTY_SAMPLE_CATCH_MODEL_VALID, oldValue, sampleCatchModelValid);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/AbstractImportMultiPostAction.java 2013-07-26 09:37:07 UTC (rev 1157)
@@ -107,7 +107,7 @@
importBatches(operation);
- getEditAction().loadCatchBatch(operation, true);
+ getEditAction().loadCatchBatch(operation);
}
protected abstract void importBatches(FishingOperation operation);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/CancelEditCatchBatchAction.java 2013-07-26 09:37:07 UTC (rev 1157)
@@ -81,7 +81,7 @@
FishingOperation operation = getModel().getFishingOperation();
- getEditAction().loadCatchBatch(operation, true);
+ getEditAction().loadCatchBatch(operation);
}
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/ImportPupitriAction.java 2013-07-26 09:37:07 UTC (rev 1157)
@@ -121,7 +121,7 @@
operation,
catchBatch);
- getEditAction().loadCatchBatch(operation, true);
+ getEditAction().loadCatchBatch(operation);
sendMessage(_("tutti.editSpeciesBatch.action.importPupitri.success",
getModel().getRootNumber(), rejectedSpeciesNb));
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-26 09:37:07 UTC (rev 1157)
@@ -922,6 +922,7 @@
tutti.fishingOperations.info.no.fishingOperation.selected=
tutti.fishingOperations.title.edit.operations=
tutti.fishingOperations.title.validate.operations=
+tutti.fishingOperations.warn.catchBatch.invalidSampleCategoryModel=
tutti.fishingOperations.warn.catchBatch.notFound=
tutti.fishingOperations.warn.invalid.batch.model=
tutti.flash.info.all.caractristic.exported=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-25 17:32:14 UTC (rev 1156)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-26 09:37:07 UTC (rev 1157)
@@ -922,6 +922,7 @@
tutti.fishingOperations.info.no.fishingOperation.selected=< Aucun trait sélectionné >
tutti.fishingOperations.title.edit.operations=Saisie des opérations de pêches (%s)
tutti.fishingOperations.title.validate.operations=Validation des opérations de pêches (%s)
+tutti.fishingOperations.warn.catchBatch.invalidSampleCategoryModel=L'arbre d’échantillonnage n'est pas compatible (utilisation de catégories non configurées). Les captures ne seront pas visibles.
tutti.fishingOperations.warn.catchBatch.notFound=Pas d'arbre d’échantillonnage associé à l'opération de pêche.
tutti.fishingOperations.warn.invalid.batch.model=L'arbre d’échantillonnage n'est pas compatible. Les captures ne seront pas visibles.
tutti.flash.info.all.caractristic.exported=Toutes les caractéristiques exportées dans le fichier <strong>%s</strong>.
1
0
25 Jul '13
Author: tchemit
Date: 2013-07-25 19:32:14 +0200 (Thu, 25 Jul 2013)
New Revision: 1156
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1156
Log:
- add export sumatra test
- am?\195?\169lioration test de service
- refs #2889: [TECH] - Prise en compte de nouvelles cat?\195?\169gories dans l'applicatif (ajout validation)
Added:
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportServiceTest.java
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportServiceTest.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -514,18 +514,6 @@
* <strong>Note:</strong> All childs of the batch should be loaded here.
*
* @param fishingOperationId if of the fishing operation to seek
- * @return the list of root {@link SpeciesBatch}
- * @since 1.0.2
- */
- BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId);
-
- /**
- * Get the batch parent of all root {@link SpeciesBatch} for the given
- * fishing operation.
- * <p/>
- * <strong>Note:</strong> All childs of the batch should be loaded here.
- *
- * @param fishingOperationId if of the fishing operation to seek
* @param sampleCategoryModel [optional] sample category model to check
* @return the list of root {@link SpeciesBatch}
* @throws InvalidBatchModelException if batch does not respect the sample category model
@@ -577,8 +565,6 @@
//-- Benthos Batch methods --//
//------------------------------------------------------------------------//
- BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId);
-
/**
* Get the batch parent of all root {@link BenthosBatch} for the given
* fishing operation.
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -652,11 +652,6 @@
//------------------------------------------------------------------------//
@Override
- public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
- return getRootSpeciesBatch(fishingOperationId, null);
- }
-
- @Override
public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
return speciesBatchService.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel);
}
@@ -701,11 +696,6 @@
//------------------------------------------------------------------------//
@Override
- public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
- return benthosBatchService.getRootBenthosBatch(fishingOperationId, null);
- }
-
- @Override
public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
return benthosBatchService.getRootBenthosBatch(fishingOperationId, sampleCategoryModel);
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -448,11 +448,6 @@
}
@Override
- public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
- throw notImplemented();
- }
-
- @Override
public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
throw notImplemented();
}
@@ -493,11 +488,6 @@
}
@Override
- public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
- throw notImplemented();
- }
-
- @Override
public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
throw notImplemented();
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -294,11 +294,11 @@
return value;
}
- public static Float getValueOrComputedValue(Float value, Float computedValue) {
+ public static <N extends Number> N getValueOrComputedValue(N value, N computedValue) {
return value == null ? computedValue : value;
}
- public static Boolean getValueOrComputedValueComputed(Float value, Float computedValue) {
+ public static <N extends Number> Boolean getValueOrComputedValueComputed(N value, N computedValue) {
Boolean result;
if (value == null) {
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -132,7 +132,7 @@
errorsStr.add(error.getMessage());
}
}
- if (errorsStr.isEmpty()) {
+ if (!errorsStr.isEmpty()) {
String join = Joiner.on("<br/>").join(errorsStr);
throw new InvalidBatchModelException(_("tutti.persistence.batch.validation.bad.sample.categories", join));
}
@@ -149,7 +149,7 @@
errorsStr.add(error.getMessage());
}
}
- if (errorsStr.isEmpty()) {
+ if (!errorsStr.isEmpty()) {
String join = Joiner.on("<br/>").join(errorsStr);
throw new InvalidBatchModelException(_("tutti.persistence.batch.validation.bad.sample.categories", join));
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -33,6 +33,7 @@
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.service.CatchBatchPersistenceService;
import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
@@ -66,6 +67,10 @@
@Autowired
protected BatchPersistenceHelper batchHelper;
+ // -----------------------------------------------------------------------//
+ // -- CatchBatchValidator methods --//
+ // -----------------------------------------------------------------------//
+
@Override
public boolean isEnable(CatchBatch catchBatch) {
// Apply validation only on catch batch for fishingOperation
@@ -75,10 +80,14 @@
@Override
public List<CatchBatchValidationError> validate(CatchBatch catchBatch) {
List<CatchBatchValidationError> errors = Lists.newArrayList();
- validate(catchBatch.getChildBatchs(), errors);
+ validateCatchBatch(catchBatch.getChildBatchs(), errors);
return errors;
}
+ // -----------------------------------------------------------------------//
+ // -- TuttiCatchBatchValidator methods --//
+ // -----------------------------------------------------------------------//
+
@Override
public List<CatchBatchValidationError> validateSpecies(SampleCategoryModel sampleCategoryModel,
BatchContainer<SpeciesBatch> species) {
@@ -87,6 +96,10 @@
for (SpeciesBatch speciesBatch : species.getChildren()) {
+ validateBatch(sampleCategoryModel,
+ errors,
+ speciesBatch,
+ n_("tutti.persistence.batch.validation.invalid.species.sampleCategoryId"));
}
return errors;
}
@@ -99,16 +112,20 @@
for (BenthosBatch benthosBatch : benthos.getChildren()) {
+ validateBatch(sampleCategoryModel,
+ errors,
+ benthosBatch,
+ n_("tutti.persistence.batch.validation.invalid.benthos.sampleCategoryId"));
}
return errors;
}
- // ------------------------------------------------------------------------//
- // -- Internal methods --//
- // ------------------------------------------------------------------------//
+ // -----------------------------------------------------------------------//
+ // -- Internal methods --//
+ // -----------------------------------------------------------------------//
- protected void validate(Collection<Batch> batchs,
- List<CatchBatchValidationError> errors) {
+ protected void validateCatchBatch(Collection<Batch> batchs,
+ List<CatchBatchValidationError> errors) {
// Vrac
SortingBatch vracBatch = batchHelper.getSortingBatch(
@@ -270,6 +287,35 @@
}
}
+ protected void validateBatch(SampleCategoryModel sampleCategoryModel,
+ List<CatchBatchValidationError> errors,
+ SpeciesAbleBatch aBatch,
+ String messageKey) {
+
+ Integer sampleCategoryId = aBatch.getSampleCategoryId();
+
+ if (!sampleCategoryModel.containsCategoryId(sampleCategoryId)) {
+
+ // invalid sample category id
+ addError(errors,
+ messageKey,
+ aBatch.getId(),
+ aBatch.getSpecies().getName(),
+ sampleCategoryId);
+ }
+
+ if (!aBatch.isChildBatchsEmpty()) {
+
+ for (SpeciesAbleBatch speciesAbleBatch : aBatch.getChildBatchs()) {
+
+ validateBatch(sampleCategoryModel,
+ errors,
+ speciesAbleBatch,
+ messageKey);
+ }
+ }
+ }
+
protected void addError(List<CatchBatchValidationError> errors,
String messageKey) {
CatchBatchValidationError error = new CatchBatchValidationError(
@@ -279,6 +325,15 @@
errors.add(error);
}
+ protected void addError(List<CatchBatchValidationError> errors,
+ String messageKey, Object... params) {
+ CatchBatchValidationError error = new CatchBatchValidationError(
+ messageKey,
+ _(messageKey, params),
+ CatchBatchValidationError.GRAVITY_ERROR);
+ errors.add(error);
+ }
+
protected void addWarning(List<CatchBatchValidationError> errors,
String messageKey) {
CatchBatchValidationError error = new CatchBatchValidationError(
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-07-25 17:32:14 UTC (rev 1156)
@@ -23,6 +23,8 @@
tutti.persistence.batch.validation.horsVracMarineLitterNotFound=
tutti.persistence.batch.validation.horsVracNotFound=
tutti.persistence.batch.validation.horsVracSpeciesNotFound=
+tutti.persistence.batch.validation.invalid.benthos.sampleCategoryId=
+tutti.persistence.batch.validation.invalid.species.sampleCategoryId=
tutti.persistence.batch.validation.unkonwn.taxon=
tutti.persistence.batch.validation.unsortedNotFound=
tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound=
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-07-25 17:32:14 UTC (rev 1156)
@@ -18,11 +18,13 @@
tutti.config.persistence=Configuration de la persistance de l'application
tutti.persistence.attachment.copyFile.error=Erreur lors de la copie de la pièce jointe %1s dans le fichier %2s
tutti.persistence.attachment.deleteFile.error=Erreur lors de la suppression de la pièce jointe %s
-tutti.persistence.batch.validation.bad.sample.categories=Il existe des lots avec des catégories d'échantillon non compatible avec le modèle configuré \:<br/>%s
+tutti.persistence.batch.validation.bad.sample.categories=Il existe des lots avec des catégories d'échantillon non compatible avec le modèle configuré \:<br/> %s
tutti.persistence.batch.validation.horsVracBenthosNotFound=Lot 'Hors Vrac > Benthos' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.horsVracMarineLitterNotFound=Lot 'Hors Vrac > Macro-déchet' non trouvé, ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.horsVracNotFound=Lot 'Hors Vrac' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.horsVracSpeciesNotFound=Lot 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement.
+tutti.persistence.batch.validation.invalid.benthos.sampleCategoryId=Le lot benthos %s (espèce %s) utilise une caractéristique (id %s) de catégorisation non reconnue
+tutti.persistence.batch.validation.invalid.species.sampleCategoryId=Le lot espèce %s (espèce %s) utilise une caractéristique (id %s) de catégorisation non reconnue
tutti.persistence.batch.validation.unkonwn.taxon=Le lot (%s) utilise une espèce de code inconnu (%s).
tutti.persistence.batch.validation.unsortedNotFound=Lot 'Hors Vrac > Espèces' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound=Lot 'Vrac > Benthos > Vivant Trié' non trouvé, ou configuré avec d'autres critères de classement.
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -745,11 +745,6 @@
//------------------------------------------------------------------------//
@Override
- public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
- return driver.getRootSpeciesBatch(fishingOperationId, null);
- }
-
- @Override
public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId,
SampleCategoryModel sampleCategoryModel) {
return driver.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel);
@@ -797,11 +792,6 @@
//------------------------------------------------------------------------//
@Override
- public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
- return driver.getRootBenthosBatch(fishingOperationId);
- }
-
- @Override
public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
return driver.getRootBenthosBatch(fishingOperationId, sampleCategoryModel);
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingService.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -126,7 +126,7 @@
} catch (TuttiBusinessException e) {
result.put(fishingOperationId, e.getMessage());
- rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId);
+ rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, null);
}
BatchContainer<BenthosBatch> rootBenthosBatch;
@@ -135,7 +135,7 @@
} catch (TuttiBusinessException e) {
result.put(fishingOperationId, e.getMessage());
- rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId);
+ rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, null);
}
BatchContainer<MarineLitterBatch> rootMarineLitterBatch;
@@ -360,7 +360,7 @@
BatchContainer<SpeciesBatch> rootSpeciesBatch = null;
if (persistenceService.isFishingOperationWithCatchBatch(operation.getId())) {
- rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId());
+ rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null);
currentSpeciesRowIndex = 0;
if (rootSpeciesBatch != null) {
@@ -545,7 +545,7 @@
BatchContainer<BenthosBatch> rootBenthosBatch = null;
if (persistenceService.isFishingOperationWithCatchBatch(operation.getId())) {
- rootBenthosBatch = persistenceService.getRootBenthosBatch(operation.getId());
+ rootBenthosBatch = persistenceService.getRootBenthosBatch(operation.getId(), null);
currentBenthosRowIndex = 0;
if (rootBenthosBatch != null) {
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -244,7 +244,7 @@
boolean error = !isCatchBatch;
if (isCatchBatch) {
- rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId);
+ rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel);
if (rootSpeciesBatch != null) {
List<SpeciesBatch> roots = rootSpeciesBatch.getChildren();
@@ -261,13 +261,13 @@
}
}
if (error) {
- rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId);
+ rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel);
}
BatchContainer<BenthosBatch> rootBenthosBatch = null;
error = false;
if (isCatchBatch) {
- rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId);
+ rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, sampleCategoryModel);
if (rootBenthosBatch != null) {
List<BenthosBatch> roots = rootBenthosBatch.getChildren();
@@ -284,7 +284,7 @@
}
}
if (error) {
- rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId);
+ rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, sampleCategoryModel);
}
BatchContainer<MarineLitterBatch> rootMarineLitterBatch;
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/TuttiMultiPostImportExportService.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -155,7 +155,7 @@
if (persistenceService.isFishingOperationWithCatchBatch(operationId)) {
BatchContainer<SpeciesBatch> speciesBatchContainer =
- persistenceService.getRootSpeciesBatch(operationId);
+ persistenceService.getRootSpeciesBatch(operationId, null);
List<CatchRow> rows = Lists.newArrayList();
List<CatchFrequencyRow> frequencyRows = Lists.newArrayList();
@@ -189,7 +189,7 @@
if (persistenceService.isFishingOperationWithCatchBatch(operationId)) {
BatchContainer<BenthosBatch> benthosBatchContainer =
- persistenceService.getRootBenthosBatch(operationId);
+ persistenceService.getRootBenthosBatch(operationId, null);
List<CatchRow> rows = Lists.newArrayList();
List<CatchFrequencyRow> frequencyRows = Lists.newArrayList();
@@ -526,7 +526,7 @@
final Map<String, SpeciesBatch> notImportedBatches = Maps.newLinkedHashMap();
BatchContainer<SpeciesBatch> speciesBatches =
- persistenceService.getRootSpeciesBatch(operation.getId());
+ persistenceService.getRootSpeciesBatch(operation.getId(), null);
TuttiDataContext dataContext = context.getDataContext();
List<Species> speciesList = dataContext.getReferentSpecies();
@@ -733,7 +733,7 @@
final Map<String, BenthosBatch> notImportedBatches = Maps.newLinkedHashMap();
BatchContainer<BenthosBatch> benthosBatches =
- persistenceService.getRootBenthosBatch(operation.getId());
+ persistenceService.getRootBenthosBatch(operation.getId(), null);
TuttiDataContext dataContext = context.getDataContext();
List<Species> speciesList = dataContext.getReferentSpecies();
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -341,7 +341,7 @@
result = notFoundSpecies.size();
catchBatch.setCatchTotalSortedCarousselWeight(carrouselSortedWeight);
- BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId());
+ BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null);
for (SpeciesBatch batch : rootSpeciesBatch.getChildren()) {
persistenceService.deleteSpeciesBatch(batch.getId());
}
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportService.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -30,6 +30,7 @@
import com.google.common.collect.Maps;
import com.google.common.io.Files;
import fr.ifremer.tutti.TuttiTechnicalException;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
@@ -61,8 +62,6 @@
private static final Log log =
LogFactory.getLog(TuttiCatchesSumatraExportService.class);
- public static final char CSV_SEPARATOR = ';';
-
protected PersistenceService persistenceService;
protected TuttiWeightComputingService tuttiWeightComputingService;
@@ -78,16 +77,17 @@
String cruiseId) {
Preconditions.checkNotNull(cruiseId, "Cannot export a null cruise");
+ Preconditions.checkNotNull(file, "Cannot export to a null file");
if (log.isInfoEnabled()) {
log.info("Will export cruise " + cruiseId + " to file: " + file);
}
Cruise cruise = persistenceService.getCruise(cruiseId);
- Preconditions.checkNotNull(cruise, "Cruise not found");
+ Preconditions.checkNotNull(cruise, "Cruise [" + cruiseId + "] not found");
CatchRowModel csvModel =
- new CatchRowModel(CSV_SEPARATOR);
+ new CatchRowModel(context.getConfig().getCsvSeparator());
List<CatchRow> rows = Lists.newArrayList();
List<FishingOperation> operations = persistenceService.getAllFishingOperation(cruiseId);
@@ -147,16 +147,15 @@
for (BenthosBatch batch : benthosBatches) {
Species sp = batch.getSpecies();
- Float weight = batch.getSampleCategoryWeight();
- if (weight == null) {
- weight = batch.getSampleCategoryComputedWeight();
- }
+ Float weight = TuttiEntities.getValueOrComputedValue(
+ batch.getSampleCategoryWeight(),
+ batch.getSampleCategoryComputedWeight());
- Integer nb = batch.getNumber();
+ Integer nb = TuttiEntities.getValueOrComputedValue(
+ batch.getNumber(),
+ batch.getComputedNumber());
+
if (nb == null) {
- nb = batch.getComputedNumber();
- }
- if (nb == null) {
nb = 0;
}
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/ServiceDbResource.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -24,14 +24,24 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import com.google.common.io.Files;
import fr.ifremer.tutti.persistence.RessourceClassLoader;
import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfigOption;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.persistence.test.DatabaseResource;
import fr.ifremer.tutti.service.config.TuttiServiceConfig;
import fr.ifremer.tutti.service.config.TuttiServiceConfigOption;
import fr.ifremer.tutti.service.protocol.TuttiProtocolImportExportService;
+import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
import org.junit.runner.Description;
import org.nuiton.config.ApplicationConfig;
@@ -39,6 +49,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.List;
import java.util.Locale;
/**
@@ -49,6 +60,22 @@
*/
public class ServiceDbResource extends DatabaseResource {
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(ServiceDbResource.class);
+
+ public static void assertFileContent(String message,
+ File actualFile,
+ String expectedContent) throws IOException {
+ Assert.assertTrue(actualFile.exists());
+ String fileContent = Files.toString(actualFile,
+ Charsets.UTF_8).trim();
+ Assert.assertEquals(expectedContent, fileContent);
+
+ if (log.isInfoEnabled()) {
+ log.info(message + fileContent);
+ }
+ }
+
protected TuttiServiceContext createServiceContext(RessourceClassLoader loader,
TuttiServiceConfig config) {
return new TuttiServiceContext(loader, config);
@@ -144,4 +171,77 @@
IOUtils.closeQuietly(serviceContext);
super.after(description);
}
+
+ public DataContext loadContext(String programId, String cruiseId, int nbExpectedOperations, String... expectedOperationId) {
+
+ DataContext dataContext = new DataContext();
+ PersistenceService persistenceService = getServiceContext().getService(PersistenceService.class);
+
+ Program program = persistenceService.getProgram(programId);
+ Assert.assertNotNull(program);
+
+ Cruise cruise = persistenceService.getCruise(cruiseId);
+ Assert.assertNotNull(cruise);
+
+ List<FishingOperation> operations = persistenceService.getAllFishingOperation(cruise.getId());
+ Assert.assertNotNull(operations);
+ Assert.assertEquals(nbExpectedOperations, operations.size());
+ if (expectedOperationId != null) {
+ int index = 0;
+ for (String id : expectedOperationId) {
+ FishingOperation fishingOperation = operations.get(index);
+ Assert.assertEquals("Fishign operation at index " + (index++) + " should have id " + id + " but was " + fishingOperation.getId(), id, fishingOperation.getId());
+ }
+ }
+
+ // load fully operations
+ List<FishingOperation> loadedOperations =
+ Lists.newArrayListWithCapacity(operations.size());
+ for (FishingOperation operation : operations) {
+ FishingOperation loadedOeration =
+ persistenceService.getFishingOperation(operation.getId());
+ loadedOperations.add(loadedOeration);
+ }
+ operations = loadedOperations;
+
+ dataContext.program = program;
+ dataContext.cruise = cruise;
+ dataContext.operations = operations;
+
+ return dataContext;
+ }
+
+ public void openDataContext() {
+
+ TuttiServiceContext serviceContext = getServiceContext();
+
+ PersistenceService persistenceService = serviceContext.getService(PersistenceService.class);
+
+ serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
+ }
+
+ public TuttiServiceContext setCountryInConfig(String countryCode) {
+ TuttiServiceContext serviceContext = getServiceContext();
+
+ PersistenceService persistenceService = serviceContext.getService(PersistenceService.class);
+
+ // set export country id in configuration
+ List<TuttiLocation> allCountry = persistenceService.getAllCountry();
+ Assert.assertNotNull(allCountry);
+ Assert.assertFalse(allCountry.isEmpty());
+ TuttiLocation franceCountry = TuttiEntities.splitById(allCountry).get(countryCode);
+ Assert.assertNotNull(franceCountry);
+ getServiceConfig().setExportCountry(franceCountry.getId());
+ return serviceContext;
+ }
+
+ public static class DataContext {
+
+ public Program program;
+
+ public Cruise cruise;
+
+ public List<FishingOperation> operations;
+
+ }
}
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingServiceTest.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/TuttiWeightComputingServiceTest.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -95,7 +95,7 @@
public void computeCatchWeights() {
CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_2_ID);
try {
- BatchContainer<SpeciesBatch> batches = persistenceService.getRootSpeciesBatch(OPERATION_2_ID);
+ BatchContainer<SpeciesBatch> batches = persistenceService.getRootSpeciesBatch(OPERATION_2_ID, null);
tuttiWeightComputingService.computeCatchBatchWeights(catchBatch, batches, null, null);
Assert.fail();
@@ -108,7 +108,7 @@
catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_3_ID);
try {
- BatchContainer<BenthosBatch> batches = persistenceService.getRootBenthosBatch(OPERATION_3_ID);
+ BatchContainer<BenthosBatch> batches = persistenceService.getRootBenthosBatch(OPERATION_3_ID, null);
tuttiWeightComputingService.computeCatchBatchWeights(catchBatch, null, batches, null);
Assert.fail();
@@ -134,8 +134,8 @@
catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_5_ID);
try {
- BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_5_ID);
- BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_5_ID);
+ BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_5_ID, null);
+ BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_5_ID, null);
tuttiWeightComputingService.computeCatchBatchWeights(catchBatch, speciesBatches, benthosBatches, null);
Assert.fail();
@@ -160,8 +160,8 @@
catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_7_ID);
try {
- BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_7_ID);
- BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_7_ID);
+ BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_7_ID, null);
+ BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_7_ID, null);
tuttiWeightComputingService.computeCatchBatchWeights(catchBatch, speciesBatches, benthosBatches, null);
if (log.isInfoEnabled()) {
log.info("Weight computing worked on operation #7");
@@ -174,7 +174,7 @@
@Test
public void computeSpeciesBatch() {
- BatchContainer<SpeciesBatch> speciesBatchContainer = persistenceService.getRootSpeciesBatch(OPERATION_1_ID);
+ BatchContainer<SpeciesBatch> speciesBatchContainer = persistenceService.getRootSpeciesBatch(OPERATION_1_ID, null);
List<SpeciesBatch> speciesBatches = speciesBatchContainer.getChildren();
for (int i = 0 ; i < speciesBatches.size() - 1 ; i++) {
try {
@@ -199,7 +199,7 @@
Assert.fail();
}
- BatchContainer<BenthosBatch> benthosBatchContainer = persistenceService.getRootBenthosBatch(OPERATION_1_ID);
+ BatchContainer<BenthosBatch> benthosBatchContainer = persistenceService.getRootBenthosBatch(OPERATION_1_ID, null);
List<BenthosBatch> benthosBatches = benthosBatchContainer.getChildren();
for (int i = 0 ; i < benthosBatches.size() - 1 ; i++) {
try {
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -24,30 +24,13 @@
* #L%
*/
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
-import fr.ifremer.tutti.persistence.ProgressionModel;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
-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.Program;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
-import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.ServiceDbResource;
import fr.ifremer.tutti.service.TuttiServiceContext;
-import org.apache.commons.io.Charsets;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import java.io.File;
-import java.io.IOException;
-import java.util.List;
/**
* Test export of catches.
@@ -57,10 +40,6 @@
*/
public class TuttiExportService2Test {
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(TuttiExportService2Test.class);
-
@ClassRule
public static final ServiceDbResource dbResource =
ServiceDbResource.readDb("dbExport");
@@ -95,25 +74,10 @@
"\n" +
"commentaire...\";Vrac;2;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;";
-
protected TuttiExportService service;
- protected PersistenceService persistenceService;
+ protected ServiceDbResource.DataContext dataContext;
- protected Program program;
-
- protected Cruise cruise;
-
- protected Cruise cruiseCGFS;
-
- protected List<FishingOperation> operations;
-
- protected List<MarineLitterBatch> marineLitters;
-
- protected List<IndividualObservationBatch> individualObservations;
-
- protected ProgressionModel progressionModel;
-
protected File dataDirectory;
@Before
@@ -121,29 +85,15 @@
dataDirectory = dbResource.getServiceConfig().getDataDirectory();
- TuttiServiceContext serviceContext = dbResource.getServiceContext();
+ dbResource.setCountryInConfig("12");
- persistenceService = serviceContext.getService(PersistenceService.class);
+ dbResource.openDataContext();
- // set export country id in configuration
- List<TuttiLocation> allCountry = persistenceService.getAllCountry();
- Assert.assertNotNull(allCountry);
- Assert.assertFalse(allCountry.isEmpty());
- TuttiLocation franceCountry = TuttiEntities.splitById(allCountry).get("12");
- Assert.assertNotNull(franceCountry);
- dbResource.getServiceConfig().setExportCountry(franceCountry.getId());
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
- serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
-
service = serviceContext.getService(TuttiExportService.class);
- loadData(PROGRAM_ID, CRUISE_ID);
- Assert.assertEquals(2, operations.size());
- Assert.assertEquals(OPERATION_1_ID, operations.get(0).getId());
- Assert.assertEquals(OPERATION_2_ID, operations.get(1).getId());
-
- progressionModel = new ProgressionModel();
- progressionModel.setTotal(8);
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 2, OPERATION_1_ID, OPERATION_2_ID);
}
@Test
@@ -153,46 +103,12 @@
service.createExportContext(dataDirectory, null);
try {
- service.exportCatches(exportContext, cruise, operations);
+ service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
} finally {
exportContext.close();
}
- assertFileContent("Catch export:\n",
- exportContext.catchFile,
- CATCH_CONTENT);
+ ServiceDbResource.assertFileContent("Catch export:\n",
+ exportContext.catchFile,
+ CATCH_CONTENT);
}
-
- protected void assertFileContent(String message,
- File actualFile,
- String expectedContent) throws IOException {
- Assert.assertTrue(actualFile.exists());
- String fileContent = Files.toString(actualFile,
- Charsets.UTF_8).trim();
- Assert.assertEquals(expectedContent, fileContent);
-
- if (log.isInfoEnabled()) {
- log.info(message + fileContent);
- }
- }
-
- protected void loadData(String programId, String cruiseId) {
- program = persistenceService.getProgram(programId);
- Assert.assertNotNull(program);
-
- cruise = persistenceService.getCruise(cruiseId);
- Assert.assertNotNull(cruise);
-
- operations = persistenceService.getAllFishingOperation(cruise.getId());
- Assert.assertNotNull(operations);
-
- // load fully operations
- List<FishingOperation> loadedOperations =
- Lists.newArrayListWithCapacity(operations.size());
- for (FishingOperation operation : operations) {
- FishingOperation loadedOeration =
- persistenceService.getFishingOperation(operation.getId());
- loadedOperations.add(loadedOeration);
- }
- operations = loadedOperations;
- }
}
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -28,20 +28,12 @@
import com.google.common.io.Files;
import fr.ifremer.tutti.persistence.ProgressionModel;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
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.Program;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
import fr.ifremer.tutti.persistence.entities.referential.Species;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.ServiceDbResource;
import fr.ifremer.tutti.service.TuttiServiceContext;
-import org.apache.commons.io.Charsets;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
@@ -49,7 +41,6 @@
import org.junit.Test;
import java.io.File;
-import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -59,10 +50,6 @@
*/
public class TuttiExportServiceTest {
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(TuttiExportServiceTest.class);
-
@ClassRule
public static final ServiceDbResource dbResource =
ServiceDbResource.readDb("dbCGFS");
@@ -199,22 +186,14 @@
"1986;LIMDLIM;Limanda limanda;;\n" +
"1988;MICTKIT;Microstomus kitt;;";
+ public static final int NB_EXPECTED_CGFS_OPERATIONS = 106;
+
protected TuttiExportService service;
protected PersistenceService persistenceService;
- protected Program program;
+ protected ServiceDbResource.DataContext dataContext;
- protected Cruise cruise;
-
- protected Cruise cruiseCGFS;
-
- protected List<FishingOperation> operations;
-
- protected List<MarineLitterBatch> marineLitters;
-
- protected List<IndividualObservationBatch> individualObservations;
-
protected ProgressionModel progressionModel;
protected File dataDirectory;
@@ -228,22 +207,12 @@
persistenceService = serviceContext.getService(PersistenceService.class);
- // set export country id in configuration
- List<TuttiLocation> allCountry = persistenceService.getAllCountry();
- Assert.assertNotNull(allCountry);
- Assert.assertFalse(allCountry.isEmpty());
- TuttiLocation franceCountry = TuttiEntities.splitById(allCountry).get("12");
- Assert.assertNotNull(franceCountry);
- dbResource.getServiceConfig().setExportCountry(franceCountry.getId());
+ dbResource.setCountryInConfig("12");
+ dbResource.openDataContext();
- serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
-
service = serviceContext.getService(TuttiExportService.class);
- loadData(PROGRAM_ID, CRUISE_ID);
- Assert.assertEquals(2, operations.size());
- Assert.assertEquals(OPERATION_1_ID, operations.get(0).getId());
- Assert.assertEquals(OPERATION_2_ID, operations.get(1).getId());
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 2, OPERATION_1_ID, OPERATION_2_ID);
progressionModel = new ProgressionModel();
progressionModel.setTotal(9);
@@ -259,7 +228,7 @@
Assert.assertFalse(exportFile.exists());
- service.exportProgram(program.getId(), null, exportFile, progressionModel);
+ service.exportProgram(dataContext.program.getId(), null, exportFile, progressionModel);
Assert.assertTrue(exportFile.exists());
}
@@ -272,7 +241,7 @@
Assert.assertFalse(exportFile.exists());
- service.exportCruise(cruise.getId(), null, exportFile, progressionModel);
+ service.exportCruise(dataContext.cruise.getId(), null, exportFile, progressionModel);
Assert.assertTrue(exportFile.exists());
}
@@ -283,13 +252,13 @@
service.createExportContext(dataDirectory, null);
try {
- service.exportSurvey(exportContext, cruise);
+ service.exportSurvey(exportContext, dataContext.cruise);
} finally {
exportContext.close();
}
- assertFileContent("Survey export:\n",
- exportContext.surveyFile,
- SURVEY_CONTENT);
+ ServiceDbResource.assertFileContent("Survey export:\n",
+ exportContext.surveyFile,
+ SURVEY_CONTENT);
}
@Test
@@ -299,13 +268,13 @@
service.createExportContext(dataDirectory, null);
try {
- service.exportGearCaracteristics(exportContext, cruise);
+ service.exportGearCaracteristics(exportContext, dataContext.cruise);
} finally {
exportContext.close();
}
- assertFileContent("Gear caracteristics export:\n",
- exportContext.gearCaracteristicsFile,
- GEAR_CARACTERISTICS_CONTENT);
+ ServiceDbResource.assertFileContent("Gear caracteristics export:\n",
+ exportContext.gearCaracteristicsFile,
+ GEAR_CARACTERISTICS_CONTENT);
}
@Test
@@ -317,35 +286,35 @@
service.createExportContext(dataDirectory, null);
try {
- service.exportOperations(exportContext, cruise, operations);
+ service.exportOperations(exportContext, dataContext.cruise, dataContext.operations);
} finally {
exportContext.close();
}
- assertFileContent("Operation export:\n",
- exportContext.operationFile,
- OPERATION_CONTENT);
+ ServiceDbResource.assertFileContent("Operation export:\n",
+ exportContext.operationFile,
+ OPERATION_CONTENT);
}
@Test
public void exportOperationsWithNoCatches() throws Exception {
- loadData(PROGRAM_ID, CRUISE_CGFS_ID);
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
- FishingOperation operation = TuttiEntities.findById(operations, "100105");
- operations = Lists.newArrayList(operation);
+ FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100105");
+ dataContext.operations = Lists.newArrayList(operation);
TuttiExportService.ExportContext exportContext =
service.createExportContext(dataDirectory, null);
try {
- service.exportOperations(exportContext, cruise, operations);
+ service.exportOperations(exportContext, dataContext.cruise, dataContext.operations);
} finally {
exportContext.close();
}
- assertFileContent("Operation export:\n",
- exportContext.operationFile,
- OPERATION_WITH_NO_CATCH_CONTENT);
+ ServiceDbResource.assertFileContent("Operation export:\n",
+ exportContext.operationFile,
+ OPERATION_WITH_NO_CATCH_CONTENT);
}
@Test
@@ -355,13 +324,13 @@
service.createExportContext(dataDirectory, null);
try {
- service.exportParameters(exportContext, cruise, operations);
+ service.exportParameters(exportContext, dataContext.cruise, dataContext.operations);
} finally {
exportContext.close();
}
- assertFileContent("Parameter export:\n",
- exportContext.parameterFile,
- PARAMETER_CONTENT);
+ ServiceDbResource.assertFileContent("Parameter export:\n",
+ exportContext.parameterFile,
+ PARAMETER_CONTENT);
}
@Test
@@ -371,13 +340,13 @@
service.createExportContext(dataDirectory, null);
try {
- service.exportCatches(exportContext, cruise, operations);
+ service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
} finally {
exportContext.close();
}
- assertFileContent("Catch export:\n",
- exportContext.catchFile,
- CATCH_CONTENT);
+ ServiceDbResource.assertFileContent("Catch export:\n",
+ exportContext.catchFile,
+ CATCH_CONTENT);
}
// To fix http://forge.codelutin.com/issues/2692
@@ -388,28 +357,28 @@
TuttiProtocol protocol = dbResource.loadProtocol(protocolFile);
- loadData(PROGRAM_ID, CRUISE_CGFS_ID);
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
- FishingOperation operation = TuttiEntities.findById(operations, "100000");
- operations = Lists.newArrayList(operation);
+ FishingOperation operation = TuttiEntities.findById(dataContext.operations, "100000");
+ dataContext.operations = Lists.newArrayList(operation);
TuttiExportService.ExportContext exportContext =
service.createExportContext(dataDirectory, protocol);
try {
- service.exportCatches(exportContext, cruise, operations);
+ service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
service.exportSpecies(exportContext, exportContext.getSpeciesToExport());
} finally {
exportContext.close();
}
- assertFileContent("species export:\n",
- exportContext.speciesFile,
- SPECIES_CONTENT_2);
+ ServiceDbResource.assertFileContent("species export:\n",
+ exportContext.speciesFile,
+ SPECIES_CONTENT_2);
- assertFileContent("Catch export:\n",
- exportContext.catchFile,
- CATCH_CONTENT_2);
+ ServiceDbResource.assertFileContent("Catch export:\n",
+ exportContext.catchFile,
+ CATCH_CONTENT_2);
}
@@ -418,13 +387,13 @@
@Test
public void exportBadCatches() throws Exception {
- loadData(PROGRAM_ID, CRUISE_CGFS_ID);
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_CGFS_ID, NB_EXPECTED_CGFS_OPERATIONS);
TuttiExportService.ExportContext exportContext =
service.createExportContext(dataDirectory, null);
try {
- service.exportCatches(exportContext, cruise, operations);
+ service.exportCatches(exportContext, dataContext.cruise, dataContext.operations);
} finally {
exportContext.close();
}
@@ -437,13 +406,13 @@
service.createExportContext(dataDirectory, null);
try {
- service.exportMarineLitters(exportContext, cruise, operations);
+ service.exportMarineLitters(exportContext, dataContext.cruise, dataContext.operations);
} finally {
exportContext.close();
}
- assertFileContent("MarineLitter export:\n",
- exportContext.marineLitterFile,
- MARINE_LITTER_CONTENT);
+ ServiceDbResource.assertFileContent("MarineLitter export:\n",
+ exportContext.marineLitterFile,
+ MARINE_LITTER_CONTENT);
}
@Test
@@ -453,13 +422,13 @@
service.createExportContext(dataDirectory, null);
try {
- service.exportIndividualObservations(exportContext, cruise, operations);
+ service.exportIndividualObservations(exportContext, dataContext.cruise, dataContext.operations);
} finally {
exportContext.close();
}
- assertFileContent("individualObservation export:\n",
- exportContext.individualObservationFile,
- INDIVIDUAL_OBSERVATION_CONTENT);
+ ServiceDbResource.assertFileContent("individualObservation export:\n",
+ exportContext.individualObservationFile,
+ INDIVIDUAL_OBSERVATION_CONTENT);
}
@Test
@@ -469,13 +438,13 @@
service.createExportContext(dataDirectory, null);
try {
- service.exportAccidentalCatch(exportContext, cruise, operations);
+ service.exportAccidentalCatch(exportContext, dataContext.cruise, dataContext.operations);
} finally {
exportContext.close();
}
- assertFileContent("accidentalCatch export:\n",
- exportContext.accidentalCatchFile,
- ACCIDENTAL_CATCH_CONTENT);
+ ServiceDbResource.assertFileContent("accidentalCatch export:\n",
+ exportContext.accidentalCatchFile,
+ ACCIDENTAL_CATCH_CONTENT);
}
@Test
@@ -499,43 +468,9 @@
} finally {
exportContext.close();
}
- assertFileContent("species export:\n",
- exportContext.speciesFile,
- SPECIES_CONTENT);
+ ServiceDbResource.assertFileContent("species export:\n",
+ exportContext.speciesFile,
+ SPECIES_CONTENT);
}
-
- protected void assertFileContent(String message,
- File actualFile,
- String expectedContent) throws IOException {
- Assert.assertTrue(actualFile.exists());
- String fileContent = Files.toString(actualFile,
- Charsets.UTF_8).trim();
- Assert.assertEquals(expectedContent, fileContent);
-
- if (log.isInfoEnabled()) {
- log.info(message + fileContent);
- }
- }
-
- protected void loadData(String programId, String cruiseId) {
- program = persistenceService.getProgram(programId);
- Assert.assertNotNull(program);
-
- cruise = persistenceService.getCruise(cruiseId);
- Assert.assertNotNull(cruise);
-
- operations = persistenceService.getAllFishingOperation(cruise.getId());
- Assert.assertNotNull(operations);
-
- // load fully operations
- List<FishingOperation> loadedOperations =
- Lists.newArrayListWithCapacity(operations.size());
- for (FishingOperation operation : operations) {
- FishingOperation loadedOeration =
- persistenceService.getFishingOperation(operation.getId());
- loadedOperations.add(loadedOeration);
- }
- operations = loadedOperations;
- }
}
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportServiceTest.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportServiceTest.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -24,15 +24,10 @@
* #L%
*/
-import com.google.common.collect.Lists;
-import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
-import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
-import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
-import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.ServiceDbResource;
import fr.ifremer.tutti.service.TuttiServiceContext;
@@ -43,7 +38,6 @@
import java.io.File;
import java.io.IOException;
-import java.util.List;
/**
* @author tchemit <chemit(a)codelutin.com>
@@ -67,14 +61,8 @@
protected PersistenceService persistenceService;
- protected Program program;
+ protected ServiceDbResource.DataContext dataContext;
- protected Cruise cruise;
-
- protected Cruise cruiseCGFS;
-
- protected List<FishingOperation> operations;
-
@Before
public void setUp() throws Exception {
@@ -82,60 +70,28 @@
persistenceService = serviceContext.getService(PersistenceService.class);
- // set export country id in configuration
- List<TuttiLocation> allCountry = persistenceService.getAllCountry();
- Assert.assertNotNull(allCountry);
- Assert.assertFalse(allCountry.isEmpty());
- TuttiLocation franceCountry = TuttiEntities.splitById(allCountry).get("12");
- Assert.assertNotNull(franceCountry);
- dbResource.getServiceConfig().setExportCountry(franceCountry.getId());
+ dbResource.openDataContext();
- serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
-
service = serviceContext.getService(TuttiPupitriImportExportService.class);
- loadData(PROGRAM_ID, CRUISE_ID);
- Assert.assertEquals(2, operations.size());
- Assert.assertEquals(OPERATION_1_ID, operations.get(0).getId());
- Assert.assertEquals(OPERATION_2_ID, operations.get(1).getId());
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 2, OPERATION_1_ID, OPERATION_2_ID);
}
- protected void loadData(String programId, String cruiseId) {
- program = persistenceService.getProgram(programId);
- Assert.assertNotNull(program);
-
- cruise = persistenceService.getCruise(cruiseId);
- Assert.assertNotNull(cruise);
-
- operations = persistenceService.getAllFishingOperation(cruise.getId());
- Assert.assertNotNull(operations);
-
- // load fully operations
- List<FishingOperation> loadedOperations =
- Lists.newArrayListWithCapacity(operations.size());
- for (FishingOperation operation : operations) {
- FishingOperation loadedOeration =
- persistenceService.getFishingOperation(operation.getId());
- loadedOperations.add(loadedOeration);
- }
- operations = loadedOperations;
- }
-
@Test
public void importPupitri() throws IOException {
File trunk = dbResource.copyClassPathResource("pupitri/pupitri.tnk", "pupitri.tnk");
File carroussel = dbResource.copyClassPathResource("pupitri/pupitri.car", "pupitri.car");
- FishingOperation operation = operations.get(0);
+ FishingOperation operation = dataContext.operations.get(0);
CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId());
catchBatch.setFishingOperation(operation);
- BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId());
+ BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null);
Assert.assertEquals(3, rootSpeciesBatch.sizeChildren());
int nbAdded = service.importPupitri(trunk, carroussel, operation, catchBatch);
Assert.assertEquals(6, nbAdded);
- BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId());
+ BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null);
Assert.assertEquals(18, rootSpeciesBatchAfter.sizeChildren());
int index = 0;
Added: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportServiceTest.java (rev 0)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportServiceTest.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -0,0 +1,94 @@
+package fr.ifremer.tutti.service.sumatra;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.tutti.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import java.io.File;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class TuttiCatchesSumatraExportServiceTest {
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.readDb("dbExport");
+
+ public static final String PROGRAM_ID = "CAM-TEST_ELEVATION";
+
+ public static final String CRUISE_ID = "100003";
+
+ public static final String OPERATION_1_ID = "100112";
+
+ public static final String OPERATION_2_ID = "100113";
+
+ public static final String EXPORT_CONTENT =
+ "Station;Espèce;Total;NbIndividus\n" +
+ "A;Agonus cataphractus;100.0;0;\n" +
+ "A;Alosa alosa;100.0;0;\n" +
+ "B;Agonus cataphractus;100.0;0;\n" +
+ "B;Alosa alosa;100.0;0;\n" +
+ "B;Abietinaria abietina;30.0;0;\n" +
+ "B;Acanthocardia echinata;18.0;0;";
+
+ protected TuttiCatchesSumatraExportService service;
+
+ protected ServiceDbResource.DataContext dataContext;
+
+ protected File dataDirectory;
+
+ @Before
+ public void setUp() throws Exception {
+
+ dataDirectory = dbResource.getServiceConfig().getDataDirectory();
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ dbResource.openDataContext();
+
+ service = serviceContext.getService(TuttiCatchesSumatraExportService.class);
+
+ dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 2, OPERATION_1_ID, OPERATION_2_ID);
+ }
+
+
+ @Test
+ public void testExportCruiseForSumatra() throws Exception {
+
+ File exportFile = new File(dataDirectory, "exportSumatra.csv");
+
+ service.exportCruiseForSumatra(exportFile, CRUISE_ID);
+
+ ServiceDbResource.assertFileContent("Sumatra export file:\n",
+ exportFile,
+ EXPORT_CONTENT);
+ }
+}
Property changes on: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/sumatra/TuttiCatchesSumatraExportServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -35,7 +35,6 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
import fr.ifremer.tutti.service.PersistenceService;
-import fr.ifremer.tutti.service.TuttiDataContext;
import fr.ifremer.tutti.ui.swing.content.operation.catches.ComputeWeightsAction;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
@@ -47,7 +46,6 @@
import fr.ifremer.tutti.ui.swing.util.action.TuttiActionHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.decorator.Decorator;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
@@ -468,21 +466,6 @@
handler.installCoordinatesListener();
}
-// public String getFishingOperationTitle(FishingOperation bean) {
-// String fishingOperationText;
-//
-// if (bean == null) {
-// fishingOperationText = null;
-// } else if (TuttiEntities.isNew(bean)) {
-// fishingOperationText = _("tutti.editFishingOperation.label.traitReminder",
-// _("tutti.editFishingOperation.label.traitReminder.inCreation"));
-// } else {
-// fishingOperationText = _("tutti.editFishingOperation.label.traitReminder",
-// decorate(bean));
-// }
-// return fishingOperationText;
-// }
-
public void loadCatchBatch(FishingOperation bean,
boolean loadOtherTabs) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -198,7 +198,8 @@
// get all batch species root (says the one with only a species sample category)
BatchContainer<BenthosBatch> rootBenthosBatch =
- persistenceService.getRootBenthosBatch(bean.getId());
+ persistenceService.getRootBenthosBatch(
+ bean.getId(), sampleCategoryModel);
List<BenthosBatch> catches = rootBenthosBatch.getChildren();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-07-25 14:45:48 UTC (rev 1155)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-07-25 17:32:14 UTC (rev 1156)
@@ -202,7 +202,8 @@
// get all batch species root (says the one with only a species sample category)
BatchContainer<SpeciesBatch> rootSpeciesBatch =
- persistenceService.getRootSpeciesBatch(bean.getId());
+ persistenceService.getRootSpeciesBatch(
+ bean.getId(), sampleCategoryModel);
List<SpeciesBatch> catches = rootSpeciesBatch.getChildren();
1
0
25 Jul '13
Author: tchemit
Date: 2013-07-25 16:45:48 +0200 (Thu, 25 Jul 2013)
New Revision: 1155
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1155
Log:
- add pupitri import test
- refs #2889: [TECH] - Prise en compte de nouvelles cat?\195?\169gories dans l'applicatif (debut de validation d'un arbre existant)
Added:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/TuttiCatchBatchValidator.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportServiceTest.java
trunk/tutti-service/src/test/resources/pupitri/
trunk/tutti-service/src/test/resources/pupitri/pupitri.car
trunk/tutti-service/src/test/resources/pupitri/pupitri.tnk
trunk/tutti-service/src/test/resources/tutti-test-write-dbExport.properties
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigOption.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/BatchContainer.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/test/DatabaseResource.java
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -36,6 +36,7 @@
import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
@@ -518,6 +519,21 @@
*/
BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId);
+ /**
+ * Get the batch parent of all root {@link SpeciesBatch} for the given
+ * fishing operation.
+ * <p/>
+ * <strong>Note:</strong> All childs of the batch should be loaded here.
+ *
+ * @param fishingOperationId if of the fishing operation to seek
+ * @param sampleCategoryModel [optional] sample category model to check
+ * @return the list of root {@link SpeciesBatch}
+ * @throws InvalidBatchModelException if batch does not respect the sample category model
+ * @since 2.5
+ */
+ BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId,
+ SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException;
+
@Transactional(readOnly = false)
SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId);
@@ -563,6 +579,21 @@
BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId);
+ /**
+ * Get the batch parent of all root {@link BenthosBatch} for the given
+ * fishing operation.
+ * <p/>
+ * <strong>Note:</strong> All childs of the batch should be loaded here.
+ *
+ * @param fishingOperationId if of the fishing operation to seek
+ * @param sampleCategoryModel [optional] sample category model to check
+ * @return the list of root {@link BenthosBatch}
+ * @throws InvalidBatchModelException if batch does not respect the sample category model
+ * @since 2.5
+ */
+ BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId,
+ SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException;
+
@Transactional(readOnly = false)
BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -40,6 +40,7 @@
import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol;
@@ -652,10 +653,15 @@
@Override
public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
- return speciesBatchService.getRootSpeciesBatch(fishingOperationId);
+ return getRootSpeciesBatch(fishingOperationId, null);
}
@Override
+ public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
+ return speciesBatchService.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel);
+ }
+
+ @Override
public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId) {
return speciesBatchService.createSpeciesBatch(bean, parentBatchId);
}
@@ -696,10 +702,15 @@
@Override
public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
- return benthosBatchService.getRootBenthosBatch(fishingOperationId);
+ return benthosBatchService.getRootBenthosBatch(fishingOperationId, null);
}
@Override
+ public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
+ return benthosBatchService.getRootBenthosBatch(fishingOperationId, sampleCategoryModel);
+ }
+
+ @Override
public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId) {
return benthosBatchService.createBenthosBatch(bean, parentBatchId);
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -36,6 +36,7 @@
import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
@@ -452,6 +453,11 @@
}
@Override
+ public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
+ throw notImplemented();
+ }
+
+ @Override
public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId) {
throw notImplemented();
}
@@ -492,6 +498,11 @@
}
@Override
+ public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
+ throw notImplemented();
+ }
+
+ @Override
public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId) {
throw notImplemented();
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigOption.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigOption.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigOption.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -132,7 +132,7 @@
SAMPLE_CATEGORY_MODEL(
"tutti.persistence.SampleCategoryModel",
n_("tutti.config.option.persistence.SampleCategoryModel.description"),
- "1428,Vrac/Hors Vrac|198,Classe de Tri|196,Sexe|174,Maturité|1430,Age",
+ "1428,V/HV|198,Class Tri.|196,Sexe|174,Maturité|1430,Age",
SampleCategoryModel.class,
false,
false
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/BatchContainer.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/BatchContainer.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/BatchContainer.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -48,4 +48,12 @@
public void addChildren(B batch) {
children.add(batch);
}
+
+ public int sizeChildren() {
+ return children.size();
+ }
+
+ public boolean isEmptyChildren() {
+ return children.isEmpty();
+ }
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -24,10 +24,12 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import org.springframework.transaction.annotation.Transactional;
@@ -51,11 +53,13 @@
* <p/>
* <strong>Note:</strong> All childs of the batch should be loaded here.
*
- * @param fishingOperationId if of the fishing operation to seek
+ * @param fishingOperationId if of the fishing operation to seek
+ * @param sampleCategoryModel [optional] sample category model to check
* @return the list of root {@link BenthosBatch}
+ * @throws InvalidBatchModelException if batch does not respect the sample category model
* @since 1.0
*/
- BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId);
+ BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException;
@Transactional(readOnly = false)
BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -36,7 +36,7 @@
import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxon;
import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxonImpl;
-import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
@@ -95,7 +95,8 @@
}
@Override
- public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId) {
+ public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId,
+ SampleCategoryModel sampleCategoryModel) {
Preconditions.checkNotNull(fishingOperationId);
CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false);
@@ -119,7 +120,7 @@
Preconditions.checkNotNull(referenceTaxon, "Can't have a rootBenthosBatch with a null taxon, but was for " + batch.getId());
Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId());
if (species == null) {
- throw new TuttiBusinessException(_("tutti.persistence.batch.validation.unkonwn.taxon", source.getId(), referenceTaxon.getId()));
+ throw new InvalidBatchModelException(_("tutti.persistence.batch.validation.unkonwn.taxon", source.getId(), referenceTaxon.getId()));
}
BenthosBatch target = TuttiBeanFactory.newBenthosBatch();
target.setSpecies(species);
@@ -144,6 +145,9 @@
ReferenceTaxon referenceTaxon = source.getReferenceTaxon();
Preconditions.checkNotNull(referenceTaxon, "Can't have a rootSpeciesBatch with a null taxon, but was for " + source.getId());
Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId());
+ if (species == null) {
+ throw new InvalidBatchModelException(_("tutti.persistence.batch.validation.unkonwn.taxon", source.getId(), referenceTaxon.getId()));
+ }
BenthosBatch target = TuttiBeanFactory.newBenthosBatch();
target.setSpecies(species);
@@ -155,6 +159,13 @@
}
}
}
+
+ if (sampleCategoryModel != null) {
+
+ // validate with given sample category model
+ batchHelper.validateBenthos(sampleCategoryModel, result);
+ }
+
return result;
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -24,8 +24,10 @@
* #L%
*/
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.Species;
@@ -52,11 +54,14 @@
* <p/>
* <strong>Note:</strong> All childs of the batch should be loaded here.
*
- * @param fishingOperationId if of the fishing operation to seek
+ * @param fishingOperationId if of the fishing operation to seek
+ * @param sampleCategoryModel [optional] sample category model to check
* @return the list of root {@link SpeciesBatch}
- * @since 1.0.2
+ * @throws InvalidBatchModelException if batch does not respect the sample category model
+ * @since 2.5
*/
- BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId);
+ BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId,
+ SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException;
@Transactional(readOnly = false)
SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId);
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -36,7 +36,7 @@
import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxon;
import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxonImpl;
-import fr.ifremer.tutti.TuttiBusinessException;
+import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory;
import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
@@ -95,7 +95,8 @@
//------------------------------------------------------------------------//
@Override
- public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
+ public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId,
+ SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
Preconditions.checkNotNull(fishingOperationId);
CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false);
@@ -126,7 +127,7 @@
}
Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId());
if (species == null) {
- throw new TuttiBusinessException(_("tutti.persistence.batch.validation.unkonwn.taxon", source.getId(), referenceTaxon.getId()));
+ throw new InvalidBatchModelException(_("tutti.persistence.batch.validation.unkonwn.taxon", source.getId(), referenceTaxon.getId()));
}
SpeciesBatch target = TuttiBeanFactory.newSpeciesBatch();
target.setSpecies(species);
@@ -154,7 +155,9 @@
log.trace("Loading CatchBatch Hors Vrac > Species > " + referenceTaxon.getId() + " - " + " (batch:" + source.getId() + ")");
}
Species species = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId());
-
+ if (species == null) {
+ throw new InvalidBatchModelException(_("tutti.persistence.batch.validation.unkonwn.taxon", source.getId(), referenceTaxon.getId()));
+ }
SpeciesBatch target = TuttiBeanFactory.newSpeciesBatch();
target.setSpecies(species);
entityToSpeciesBatch(source, target);
@@ -165,6 +168,12 @@
}
}
+ if (sampleCategoryModel != null) {
+
+ // validate with given sample category model
+ batchHelper.validateSpecies(sampleCategoryModel, result);
+ }
+
return result;
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -24,6 +24,7 @@
* #L%
*/
+import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -32,8 +33,8 @@
import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatchDao;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationError;
import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement;
import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement;
import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl;
@@ -41,7 +42,10 @@
import fr.ifremer.tutti.persistence.InvalidBatchModelException;
import fr.ifremer.tutti.persistence.entities.TuttiEntity;
import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Caracteristic;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicType;
@@ -50,6 +54,7 @@
import fr.ifremer.tutti.persistence.service.IndividualObservationBatchPersistenceService;
import fr.ifremer.tutti.persistence.service.MeasurementPersistenceHelper;
import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -64,6 +69,8 @@
import java.util.List;
import java.util.Set;
+import static org.nuiton.i18n.I18n._;
+
/**
* Helper around batches.
*
@@ -93,7 +100,7 @@
protected SortingBatchDao sortingBatchDao;
@Resource(name = "scientificCruiseCatchBatchValidator")
- protected CatchBatchValidator catchBatchValidator;
+ protected TuttiCatchBatchValidator catchBatchValidator;
@Autowired
protected MeasurementPersistenceHelper measurementPersistenceHelper;
@@ -116,6 +123,39 @@
return bean;
}
+ public void validateSpecies(SampleCategoryModel sampleCategoryModel,
+ BatchContainer<SpeciesBatch> species) throws InvalidBatchModelException {
+ List<CatchBatchValidationError> errors = catchBatchValidator.validateSpecies(sampleCategoryModel, species);
+ List<String> errorsStr = Lists.newArrayList();
+ for (CatchBatchValidationError error : errors) {
+ if (error.getGravity() == CatchBatchValidationError.GRAVITY_ERROR) {
+ errorsStr.add(error.getMessage());
+ }
+ }
+ if (errorsStr.isEmpty()) {
+ String join = Joiner.on("<br/>").join(errorsStr);
+ throw new InvalidBatchModelException(_("tutti.persistence.batch.validation.bad.sample.categories", join));
+ }
+ }
+
+ public void validateBenthos(SampleCategoryModel sampleCategoryModel,
+ BatchContainer<BenthosBatch> benthos) throws InvalidBatchModelException {
+ List<CatchBatchValidationError> errors = catchBatchValidator.validateBenthos(sampleCategoryModel, benthos);
+
+ if (CollectionUtils.isNotEmpty(errors)) {
+ List<String> errorsStr = Lists.newArrayList();
+ for (CatchBatchValidationError error : errors) {
+ if (error.getGravity() == CatchBatchValidationError.GRAVITY_ERROR) {
+ errorsStr.add(error.getMessage());
+ }
+ }
+ if (errorsStr.isEmpty()) {
+ String join = Joiner.on("<br/>").join(errorsStr);
+ throw new InvalidBatchModelException(_("tutti.persistence.batch.validation.bad.sample.categories", join));
+ }
+ }
+ }
+
public void deleteCatchBatch(String fishingOperationId, Integer catchBatchId) {
// delete individual observation batchs
@@ -807,22 +847,6 @@
);
}
-// public SortingMeasurement setSortingMeasurement(
-// SortingBatch sortingBatch,
-// SampleCategoryEnum sampleCategory,
-// Serializable value) {
-// Preconditions.checkNotNull(sampleCategory);
-// Preconditions.checkNotNull(value);
-//
-// Integer pmfmId = sampleCategory.getFieldValue();
-//
-// Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId);
-// SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement(
-// sortingBatch, pmfmId, getRecorderDepartmentId(), true);
-// measurementPersistenceHelper.setMeasurement(sortingMeasurement, caracteristic, value);
-// return sortingMeasurement;
-// }
-
public SortingMeasurement setSortingMeasurement(
SortingBatch sortingBatch,
Integer pmfmId,
@@ -896,8 +920,6 @@
SortingMeasurement sm
= sortingBatch.getSortingMeasurements().iterator().next();
Pmfm pmfm = sm.getPmfm();
-// SampleCategoryEnum sampleCategoryByPmfmId =
-// enumeration.getSampleCategoryByPmfmId(pmfm.getId());
result = !sampleCategoryModel.containsCategoryId(pmfm.getId());
}
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -30,7 +30,10 @@
import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao;
import fr.ifremer.adagio.core.dao.data.batch.SortingBatch;
import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationError;
-import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.service.CatchBatchPersistenceService;
import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import org.apache.commons.logging.Log;
@@ -45,7 +48,7 @@
import static org.nuiton.i18n.I18n.n_;
@Component(value = "scientificCruiseCatchBatchValidator")
-public class ScientificCruiseCatchBatchValidator implements CatchBatchValidator {
+public class ScientificCruiseCatchBatchValidator implements TuttiCatchBatchValidator {
/** Logger. */
private static final Log log =
@@ -76,6 +79,30 @@
return errors;
}
+ @Override
+ public List<CatchBatchValidationError> validateSpecies(SampleCategoryModel sampleCategoryModel,
+ BatchContainer<SpeciesBatch> species) {
+
+ List<CatchBatchValidationError> errors = Lists.newArrayList();
+
+ for (SpeciesBatch speciesBatch : species.getChildren()) {
+
+ }
+ return errors;
+ }
+
+ @Override
+ public List<CatchBatchValidationError> validateBenthos(SampleCategoryModel sampleCategoryModel,
+ BatchContainer<BenthosBatch> benthos) {
+
+ List<CatchBatchValidationError> errors = Lists.newArrayList();
+
+ for (BenthosBatch benthosBatch : benthos.getChildren()) {
+
+ }
+ return errors;
+ }
+
// ------------------------------------------------------------------------//
// -- Internal methods --//
// ------------------------------------------------------------------------//
@@ -180,7 +207,7 @@
addWarning(errors, n_("tutti.persistence.batch.validation.vracBenthosInertNotFound"));
}
- // Vrac > Benthos > Alive itermized
+ // Vrac > Benthos > Alive itemized
SortingBatch aliveItemizedBatch = batchHelper.getSortingBatch(
benthosBatch,
"Vrac > Benthos > Alive itermized",
Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/TuttiCatchBatchValidator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/TuttiCatchBatchValidator.java (rev 0)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/TuttiCatchBatchValidator.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -0,0 +1,49 @@
+package fr.ifremer.tutti.persistence.service.batch;
+
+/*
+ * #%L
+ * Tutti :: Persistence
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationError;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidator;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.BenthosBatch;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+
+import java.util.List;
+
+/**
+ * Override adagio validator to add a validate within a {@link SampleCategoryModel}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public interface TuttiCatchBatchValidator extends CatchBatchValidator {
+
+ List<CatchBatchValidationError> validateSpecies(SampleCategoryModel sampleCategoryModel,
+ BatchContainer<SpeciesBatch> species);
+
+ List<CatchBatchValidationError> validateBenthos(SampleCategoryModel sampleCategoryModel,
+ BatchContainer<BenthosBatch> benthos);
+}
Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/TuttiCatchBatchValidator.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/test/DatabaseResource.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/test/DatabaseResource.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/test/DatabaseResource.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -36,6 +36,7 @@
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -44,8 +45,8 @@
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runners.model.Statement;
+import org.nuiton.config.ApplicationConfig;
import org.nuiton.util.FileUtil;
-import org.nuiton.config.ApplicationConfig;
import org.nuiton.util.converter.ConverterUtil;
import java.io.BufferedReader;
@@ -53,6 +54,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@@ -169,7 +171,7 @@
Class<?> testClass;
public void prepareConfig(ApplicationConfig applicationConfig,
- File resourceDirectory) {
+ File resourceDirectory) {
applicationConfig.loadDefaultOptions(
TuttiPersistenceConfigOption.values());
@@ -178,6 +180,23 @@
new File(resourceDirectory, "data").getAbsolutePath());
}
+ public File copyClassPathResource(String path, String destinationName) throws IOException {
+ InputStream inputStream = getClass().getResourceAsStream("/" + path);
+ Preconditions.checkNotNull(inputStream, "Could not find " + path + " in test class-path");
+ File output = new File(resourceDirectory, destinationName);
+
+ OutputStream outputStream = FileUtils.openOutputStream(output);
+ try {
+ IOUtils.copy(inputStream, outputStream);
+ inputStream.close();
+ outputStream.close();
+ } finally {
+ IOUtils.closeQuietly(inputStream);
+ IOUtils.closeQuietly(outputStream);
+ }
+ return output;
+ }
+
protected void before(Description description) throws Throwable {
TuttiRunListener.beforeClass(description);
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_en_GB.properties 2013-07-25 14:45:48 UTC (rev 1155)
@@ -15,10 +15,10 @@
tutti.config.option.persistence.jdbc.password.description=
tutti.config.option.persistence.jdbc.url.description=
tutti.config.option.persistence.jdbc.username.description=
-tutti.config.option.persistence.samplingCategories.description=
tutti.config.persistence=
tutti.persistence.attachment.copyFile.error=
tutti.persistence.attachment.deleteFile.error=
+tutti.persistence.batch.validation.bad.sample.categories=
tutti.persistence.batch.validation.horsVracBenthosNotFound=
tutti.persistence.batch.validation.horsVracMarineLitterNotFound=
tutti.persistence.batch.validation.horsVracNotFound=
@@ -50,9 +50,3 @@
tutti.persistence.synchronizeReferential.synchronize.step2=
tutti.persistence.synchronizeReferential.synchronizeTable=
tutti.persistence.tableMetadata.instanciation.error=
-tutti.sampleCategoryType.age=
-tutti.sampleCategoryType.maturity=
-tutti.sampleCategoryType.sex=
-tutti.sampleCategoryType.size=
-tutti.sampleCategoryType.sortedUnsorted=
-tutti.service.attachment.copyFile.error=
Modified: trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties
===================================================================
--- trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/main/resources/i18n/tutti-persistence_fr_FR.properties 2013-07-25 14:45:48 UTC (rev 1155)
@@ -1,5 +1,5 @@
nuitonutil.error.no.convertor=
-tutti.config.option.persistence.SampleCategoryModel.description=
+tutti.config.option.persistence.SampleCategoryModel.description=Configuration des catégories d'échantillonnage
tutti.config.option.persistence.db.attachment.directory.description=Répertoire où sont stockées les pièces-jointes
tutti.config.option.persistence.db.cache.directory.description=Répertoire où sont stockées les caches de persistance
tutti.config.option.persistence.db.configurationPath.description=Chemin du fichier de configuration d'Adagio
@@ -15,10 +15,10 @@
tutti.config.option.persistence.jdbc.password.description=Mot de passe de l'utilisateur pour se connecter à la base de données
tutti.config.option.persistence.jdbc.url.description=URL de connexion à la base de données
tutti.config.option.persistence.jdbc.username.description=Login de l'utilisateur pour se connecter à la base de données
-tutti.config.option.persistence.samplingCategories.description=
tutti.config.persistence=Configuration de la persistance de l'application
tutti.persistence.attachment.copyFile.error=Erreur lors de la copie de la pièce jointe %1s dans le fichier %2s
tutti.persistence.attachment.deleteFile.error=Erreur lors de la suppression de la pièce jointe %s
+tutti.persistence.batch.validation.bad.sample.categories=Il existe des lots avec des catégories d'échantillon non compatible avec le modèle configuré \:<br/>%s
tutti.persistence.batch.validation.horsVracBenthosNotFound=Lot 'Hors Vrac > Benthos' non trouvé ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.horsVracMarineLitterNotFound=Lot 'Hors Vrac > Macro-déchet' non trouvé, ou configuré avec d'autres critères de classement.
tutti.persistence.batch.validation.horsVracNotFound=Lot 'Hors Vrac' non trouvé ou configuré avec d'autres critères de classement.
@@ -50,8 +50,3 @@
tutti.persistence.synchronizeReferential.synchronize.step2=Sauvegarde des données dans la base locale
tutti.persistence.synchronizeReferential.synchronizeTable=Mise à jour de la table %s
tutti.persistence.tableMetadata.instanciation.error=Erreur à l'initialisation de %s
-tutti.sampleCategoryType.age=Age
-tutti.sampleCategoryType.maturity=Maturité
-tutti.sampleCategoryType.sex=Sexe
-tutti.sampleCategoryType.size=Class Tri.
-tutti.sampleCategoryType.sortedUnsorted=V/HV
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/config/TuttiPersistenceConfigTest.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -76,12 +76,12 @@
SampleCategoryModelEntry vracHVrac = new SampleCategoryModelEntry();
vracHVrac.setCategoryId(1428);
- vracHVrac.setLabel("Vrac/Hors Vrac");
+ vracHVrac.setLabel("V/HV");
vracHVrac.setOrder(0);
SampleCategoryModelEntry classDeTri = new SampleCategoryModelEntry();
classDeTri.setCategoryId(198);
- classDeTri.setLabel("Classe de Tri");
+ classDeTri.setLabel("Class Tri.");
classDeTri.setOrder(1);
SampleCategoryModelEntry sex = new SampleCategoryModelEntry();
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -83,7 +83,7 @@
@Test
public void getRootBenthosBatch(/*String fishingOperationId*/) {
//TODO Do me!
- service.getRootBenthosBatch(fishingOperation.getId());
+ service.getRootBenthosBatch(fishingOperation.getId(), null);
}
@Ignore
@@ -164,7 +164,7 @@
public BenthosBatch getBenthosBatch(String fishingOperationId,
String speciesBatchId) {
- BatchContainer<BenthosBatch> rootSpeciesBatch = service.getRootBenthosBatch(fishingOperationId);
+ BatchContainer<BenthosBatch> rootSpeciesBatch = service.getRootBenthosBatch(fishingOperationId, null);
return getBenthosBatch(speciesBatchId, rootSpeciesBatch.getChildren());
}
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -324,7 +324,7 @@
// -----------------------------------------------------------------------------
// 7. Test get all root species
// -----------------------------------------------------------------------------
- List<BenthosBatch> rootBenthosBatch = service.getRootBenthosBatch(fishingOperationWithEmptyBatch.getId()).getChildren();
+ List<BenthosBatch> rootBenthosBatch = service.getRootBenthosBatch(fishingOperationWithEmptyBatch.getId(), null).getChildren();
assertNotNull(rootBenthosBatch);
assertEquals(2, rootBenthosBatch.size());
assertNotNull(rootBenthosBatch.get(0).getChildBatchs());
@@ -512,7 +512,7 @@
}
protected BenthosBatch getBenthosBatch(String fishingOperationId, String speciesBatchId) {
- return getBenthosBatch(speciesBatchId, service.getRootBenthosBatch(fishingOperationId).getChildren());
+ return getBenthosBatch(speciesBatchId, service.getRootBenthosBatch(fishingOperationId, null).getChildren());
}
protected BenthosBatch getBenthosBatch(String speciesBatchId, List<BenthosBatch> speciesBatchs) {
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -82,7 +82,7 @@
@Test
public void getRootSpeciesBatch(/*String fishingOperationId*/) {
//TODO Do me!
- service.getRootSpeciesBatch(fishingOperation.getId());
+ service.getRootSpeciesBatch(fishingOperation.getId(), null);
}
@Ignore
@@ -168,7 +168,7 @@
public SpeciesBatch getSpeciesBatch(String fishingOperationId,
String speciesBatchId) {
- BatchContainer<SpeciesBatch> rootSpeciesBatch = service.getRootSpeciesBatch(fishingOperationId);
+ BatchContainer<SpeciesBatch> rootSpeciesBatch = service.getRootSpeciesBatch(fishingOperationId, null);
return getSpeciesBatch(speciesBatchId, rootSpeciesBatch.getChildren());
}
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -316,7 +316,7 @@
// -----------------------------------------------------------------------------
// 7. Test get all root species
// -----------------------------------------------------------------------------
- BatchContainer<SpeciesBatch> rootSpeciesBatc = service.getRootSpeciesBatch(fishingOperationWithEmptyBatch.getId());
+ BatchContainer<SpeciesBatch> rootSpeciesBatc = service.getRootSpeciesBatch(fishingOperationWithEmptyBatch.getId(), null);
List<SpeciesBatch> rootSpeciesBatch = rootSpeciesBatc.getChildren();
assertNotNull(rootSpeciesBatch);
assertEquals(2, rootSpeciesBatch.size());
@@ -504,7 +504,7 @@
}
protected SpeciesBatch getSpeciesBatch(String fishingOperationId, String speciesBatchId) {
- return getSpeciesBatch(speciesBatchId, service.getRootSpeciesBatch(fishingOperationId).getChildren());
+ return getSpeciesBatch(speciesBatchId, service.getRootSpeciesBatch(fishingOperationId, null).getChildren());
}
protected SpeciesBatch getSpeciesBatch(String speciesBatchId, List<SpeciesBatch> speciesBatchs) {
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -43,6 +43,7 @@
import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch;
import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch;
import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol;
@@ -745,10 +746,16 @@
@Override
public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId) {
- return driver.getRootSpeciesBatch(fishingOperationId);
+ return driver.getRootSpeciesBatch(fishingOperationId, null);
}
@Override
+ public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId,
+ SampleCategoryModel sampleCategoryModel) {
+ return driver.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel);
+ }
+
+ @Override
public SpeciesBatch createSpeciesBatch(SpeciesBatch bean,
String parentBatchId) {
return driver.createSpeciesBatch(bean, parentBatchId);
@@ -795,6 +802,11 @@
}
@Override
+ public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException {
+ return driver.getRootBenthosBatch(fishingOperationId, sampleCategoryModel);
+ }
+
+ @Override
public BenthosBatch createBenthosBatch(BenthosBatch bean,
String parentBatchId) {
return driver.createBenthosBatch(bean, parentBatchId);
Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java
===================================================================
--- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportService.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -47,6 +47,7 @@
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile;
import fr.ifremer.tutti.service.AbstractTuttiService;
+import fr.ifremer.tutti.service.DecoratorService;
import fr.ifremer.tutti.service.PersistenceService;
import fr.ifremer.tutti.service.TuttiDataContext;
import fr.ifremer.tutti.service.TuttiServiceContext;
@@ -412,7 +413,8 @@
reader.close();
} catch (Exception e) {
- throw new TuttiTechnicalException(_("tutti.service.pupitri.import.carrousel.error", operation.toString(), carrouselFile), e);//"Could not import carrousel data [" + operation.toString() + "] from file " + carrouselFile
+ DecoratorService service = getService(DecoratorService.class);
+ throw new TuttiTechnicalException(_("tutti.service.pupitri.import.carrousel.error", carrouselFile, service.getDecorator(operation).toString(operation)), e);//"Could not import carrousel data [" + operation.toString() + "] from file " + carrouselFile
} finally {
IOUtils.closeQuietly(carrouselImporter);
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_en_GB.properties 2013-07-25 14:45:48 UTC (rev 1155)
@@ -9,8 +9,6 @@
tutti.config.option.tmp.directory.description=
tutti.config.option.version.description=
tutti.config.service=
-tutti.persistence.checkArchiveDb.error=
-tutti.persistence.checkImportstructure.fileNotExist=
tutti.property.attachment=
tutti.property.caracteristic=
tutti.property.country=
@@ -50,13 +48,9 @@
tutti.propety.no.vessel.name=
tutti.propety.no.zone=
tutti.propety.vessel.nation.registrationCode=
-tutti.service.catches.computeWeights.benthos.error.incoherentSampleWeight=
-tutti.service.catches.computeWeights.error.incoherentRowWeightCategory=
-tutti.service.catches.computeWeights.species.error.incoherentSampleWeight=
tutti.service.compressZipFile.error=
tutti.service.config.deleteTempDirectory.error=
tutti.service.context.serviceInstanciation.error=
-tutti.service.csv.parse.entityAlreadyDefined=
tutti.service.csv.parse.entityNotFound=
tutti.service.cvs.format.error=
tutti.service.export.catches.error=
@@ -87,15 +81,12 @@
tutti.service.exportSumatra.header.weight=
tutti.service.mkDir.error=
tutti.service.multipost.attachment.copy.error=
-tutti.service.multipost.explodeArchive.error=
tutti.service.multipost.export.attachments.error=
tutti.service.multipost.export.batches.error=
-tutti.service.multipost.export.benthos.error=
tutti.service.multipost.export.deleteTempDirectory.error=
tutti.service.multipost.export.error=
tutti.service.multipost.export.frequencies.error=
tutti.service.multipost.export.operation.error=
-tutti.service.multipost.export.species.error=
tutti.service.multipost.export.weight.error=
tutti.service.multipost.export.weights.error=
tutti.service.multipost.import.attachments.error=
@@ -103,17 +94,9 @@
tutti.service.multipost.import.caracteristics.error=
tutti.service.multipost.import.frequencies.error=
tutti.service.multipost.import.operation.error=
-tutti.service.multipost.import.species.error=
tutti.service.multipost.import.weights.error=
tutti.service.multipost.import.wrongOperation.error=
-tutti.service.multipost.resolveArchive.error=
tutti.service.multipost.uncompress.error=
-tutti.service.operations.accidental.error.species.required=
-tutti.service.operations.computeWeights.benthos.error.incoherentCategoryWeight=
-tutti.service.operations.computeWeights.benthos.error.incoherentParentCategoryWeight=
-tutti.service.operations.computeWeights.benthos.error.incoherentRowWeightFrequency=
-tutti.service.operations.computeWeights.benthos.error.incoherentTotalSorted=
-tutti.service.operations.computeWeights.benthos.error.noWeight=
tutti.service.operations.computeWeights.error.benthos.incoherentCategoryWeight=
tutti.service.operations.computeWeights.error.benthos.incoherentParentCategoryWeight=
tutti.service.operations.computeWeights.error.benthos.incoherentRowWeightCategory=
@@ -131,36 +114,16 @@
tutti.service.operations.computeWeights.error.species.incoherentSampleWeight=
tutti.service.operations.computeWeights.error.species.incoherentTotalSorted=
tutti.service.operations.computeWeights.error.species.noWeight=
-tutti.service.operations.computeWeights.marineLitter.error.incoherentTotal=
-tutti.service.operations.computeWeights.marineLitter.error.noWeight=
-tutti.service.operations.computeWeights.species.error.incoherentCategoryWeight=
-tutti.service.operations.computeWeights.species.error.incoherentParentCategoryWeight=
-tutti.service.operations.computeWeights.species.error.incoherentRowWeightFrequency=
-tutti.service.operations.computeWeights.species.error.incoherentTotalSorted=
-tutti.service.operations.computeWeights.species.error.noWeight=
tutti.service.operations.exportCatchesReport.error=
tutti.service.operations.exportCatchesReport.specialRows.benthos.code=
tutti.service.operations.exportCatchesReport.specialRows.benthos.name=
tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.code=
tutti.service.operations.exportCatchesReport.specialRows.inertAndLivinngNotItemized.name=
-tutti.service.operations.individualObservation.error.lengthStepCaracteristic.required=
-tutti.service.operations.individualObservation.error.size.required=
-tutti.service.operations.individualObservation.error.species.required=
-tutti.service.operations.individualObservation.error.weight.required=
-tutti.service.operations.marineLitter.error.marineLitterCategory.required=
-tutti.service.operations.marineLitter.error.marineLitterSizeCategory.required=
-tutti.service.operations.marineLitter.error.number.required=
-tutti.service.operations.marineLitter.warning.weight.required=
-tutti.service.operations.validate.marineLitter.error.marineLitterCategory.required=
-tutti.service.operations.validate.marineLitter.error.marineLitterSizeCategory.required=
-tutti.service.operations.validate.marineLitter.error.number.required=
-tutti.service.operations.validate.marineLitter.warning.weight.required=
tutti.service.persistence.checkArchiveDb.error=
tutti.service.persistence.checkImportstructure.fileNotExist=
tutti.service.persistence.checkImportstructure.tooManyChildren=
tutti.service.persistence.copyDirectory.attachment.error=
tutti.service.persistence.copyDirectory.db.error=
-tutti.service.persistence.copyDirectory.protocol.error=
tutti.service.persistence.exportDb.deleteTempDir.error=
tutti.service.persistence.exportDb.zip.error=
tutti.service.persistence.extractArchive.error=
Modified: trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties
===================================================================
--- trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-service/src/main/resources/i18n/tutti-service_fr_FR.properties 2013-07-25 14:45:48 UTC (rev 1155)
@@ -48,13 +48,9 @@
tutti.propety.no.vessel.name=Nom inconnu
tutti.propety.no.zone=Pas de zone
tutti.propety.vessel.nation.registrationCode=%s (nat.)
-tutti.service.catches.computeWeights.benthos.error.incoherentSampleWeight=Le poids de sous-échantillon est supérieur au poids du lot.
-tutti.service.catches.computeWeights.error.incoherentRowWeightCategory=Le poids de sous-échantillon est renseigné alors que le lot n'a pas de poids.
-tutti.service.catches.computeWeights.species.error.incoherentSampleWeight=Le poids de sous-échantillon est supérieur au poids du lot.
tutti.service.compressZipFile.error=Erreur lors de la compression du dossier %1s dans le fichier %2s
tutti.service.config.deleteTempDirectory.error=Erreur lors de la suppression du dossier temporaire
tutti.service.context.serviceInstanciation.error=Erreur lors de l'instanciation du service %s
-tutti.service.csv.parse.entityAlreadyDefined=La propriété %1s de valeur %2s est déjà définie
tutti.service.csv.parse.entityNotFound=L'entité de type %1s avec la propriété %2s de valeur %3s n'a pas été trouvée
tutti.service.cvs.format.error=Erreur lors du formatage de la valeur %s
tutti.service.export.catches.error=Erreur lors de l'export des captures
@@ -128,7 +124,6 @@
tutti.service.persistence.checkImportstructure.tooManyChildren=L'archive de base de données %s ne doit avoir qu'un sous-dossier
tutti.service.persistence.copyDirectory.attachment.error=Erreur lors de la copie du dossier des pièces jointes
tutti.service.persistence.copyDirectory.db.error=Erreur lors de la copie du dossier de base de données
-tutti.service.persistence.copyDirectory.protocol.error=Erreur lors de la copie du dossier des protocoles
tutti.service.persistence.exportDb.deleteTempDir.error=Erreur lors de la suppression du dossier temporaire
tutti.service.persistence.exportDb.zip.error=Erreur lors de la création de l'archive %s
tutti.service.persistence.extractArchive.error=Erreur lors de l'extraction de l'archive %s
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportService2Test.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -74,7 +74,7 @@
public static final String OPERATION_2_ID = "100113";
public static final String CATCH_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;Vrac/Hors Vrac;Num_Ordre_Vrac/Hors Vrac_H2;Tot_Vrac/Hors Vrac;Ech_Vrac/Hors Vrac;Type_Volume_Poids_Vrac/Hors Vrac;Unite_Volume_Poids_Vrac/Hors Vrac;Classe de Tri;Num_Ordre_Classe de Tri_H2;Tot_Classe de Tri;Ech_Classe de Tri;Type_Volume_Poids_Classe de Tri;Unite_Volume_Poids_Classe de Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V/HV;Num_Ordre_V/HV_H2;Tot_V/HV;Ech_V/HV;Type_Volume_Poids_V/HV;Unite_Volume_Poids_V/HV;Class Tri.;Num_Ordre_Class Tri._H2;Tot_Class Tri.;Ech_Class Tri.;Type_Volume_Poids_Class Tri.;Unite_Volume_Poids_Class Tri.;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
"2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1938;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;\n" +
"2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;9.074075;\n" +
"2013;test elevation;1;OTB 20/28.10;A;1;1;278970;1358;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;5.0;1;0.6;cm;1.0;4;0.6;907.4074;\n" +
Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/TuttiExportServiceTest.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -108,7 +108,7 @@
"2013;Campagne CGFS;;A;2;1;308;Nombre d'engin - engin - totale - Déclaration d'un professionnel;2.0;";
public static final String CATCH_CONTENT =
- "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;Vrac/Hors Vrac;Num_Ordre_Vrac/Hors Vrac_H2;Tot_Vrac/Hors Vrac;Ech_Vrac/Hors Vrac;Type_Volume_Poids_Vrac/Hors Vrac;Unite_Volume_Poids_Vrac/Hors Vrac;Classe de Tri;Num_Ordre_Classe de Tri_H2;Tot_Classe de Tri;Ech_Classe de Tri;Type_Volume_Poids_Classe de Tri;Unite_Volume_Poids_Classe de Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V/HV;Num_Ordre_V/HV_H2;Tot_V/HV;Ech_V/HV;Type_Volume_Poids_V/HV;Unite_Volume_Poids_V/HV;Class Tri.;Num_Ordre_Class Tri._H2;Tot_Class Tri.;Ech_Class Tri.;Type_Volume_Poids_Class Tri.;Unite_Volume_Poids_Class Tri.;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
"2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.0;1;;cm;0.5;5;5.0;20.0;\n" +
"2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;2;;cm;0.5;2;5.0;20.0;\n" +
"2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;|||;Vrac;1;100.0;;Poids;kg;G - Gros;1;80.0;;Poids;kg;Mâle;1;30.0;;Poids;kg;1 - Stade 1;1;10.0;5.0;Poids;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;11.0;3;;cm;0.5;1;5.0;20.0;\n" +
@@ -120,7 +120,7 @@
"2013;Campagne CGFS;;GOV 19.7/25.9;A;1;1;278970;11242;Aaptos;;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;2;20.0;1.0;";
public static final String CATCH_CONTENT_2 =
- "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;Vrac/Hors Vrac;Num_Ordre_Vrac/Hors Vrac_H2;Tot_Vrac/Hors Vrac;Ech_Vrac/Hors Vrac;Type_Volume_Poids_Vrac/Hors Vrac;Unite_Volume_Poids_Vrac/Hors Vrac;Classe de Tri;Num_Ordre_Classe de Tri_H2;Tot_Classe de Tri;Ech_Classe de Tri;Type_Volume_Poids_Classe de Tri;Unite_Volume_Poids_Classe de Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
+ "Annee;Serie;Serie_Partielle;Engin;Id_Operation;NumOrdre_Station;Poche;Navire;Taxon;Nom_scientifique;Commentaire;V/HV;Num_Ordre_V/HV_H2;Tot_V/HV;Ech_V/HV;Type_Volume_Poids_V/HV;Unite_Volume_Poids_V/HV;Class Tri.;Num_Ordre_Class Tri._H2;Tot_Class Tri.;Ech_Class Tri.;Type_Volume_Poids_Class Tri.;Unite_Volume_Poids_Class Tri.;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturité;Num_Ordre_Maturité_H2;Tot_Maturité;Ech_Maturité;Type_Volume_Poids_Maturité;Unite_Volume_Poids_Maturité;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture\n" +
"2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;365;Aequipecten opercularis;taxon;Vrac;1;0.005;0.005;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.005;1.0;\n" +
"2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;491;Alloteuthis;taxon;Vrac;2;0.004;0.004;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.004;1.0;\n" +
"2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;278970;300;Buccinum undatum;taxon;Vrac;3;0.015;0.015;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.015;1.0;\n" +
Added: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportServiceTest.java
===================================================================
--- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportServiceTest.java (rev 0)
+++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportServiceTest.java 2013-07-25 14:45:48 UTC (rev 1155)
@@ -0,0 +1,151 @@
+package fr.ifremer.tutti.service.pupitri;
+
+/*
+ * #%L
+ * Tutti :: Service
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 Ifremer
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
+import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
+import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
+import fr.ifremer.tutti.persistence.entities.data.Program;
+import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
+import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.service.ServiceDbResource;
+import fr.ifremer.tutti.service.TuttiServiceContext;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+public class TuttiPupitriImportExportServiceTest {
+
+ @ClassRule
+ public static final ServiceDbResource dbResource =
+ ServiceDbResource.writeDb("dbExport");
+
+ public static final String PROGRAM_ID = "CAM-TEST_ELEVATION";
+
+ public static final String CRUISE_ID = "100003";
+
+ public static final String OPERATION_1_ID = "100112";
+
+ public static final String OPERATION_2_ID = "100113";
+
+ protected TuttiPupitriImportExportService service;
+
+ protected PersistenceService persistenceService;
+
+ protected Program program;
+
+ protected Cruise cruise;
+
+ protected Cruise cruiseCGFS;
+
+ protected List<FishingOperation> operations;
+
+ @Before
+ public void setUp() throws Exception {
+
+ TuttiServiceContext serviceContext = dbResource.getServiceContext();
+
+ persistenceService = serviceContext.getService(PersistenceService.class);
+
+ // set export country id in configuration
+ List<TuttiLocation> allCountry = persistenceService.getAllCountry();
+ Assert.assertNotNull(allCountry);
+ Assert.assertFalse(allCountry.isEmpty());
+ TuttiLocation franceCountry = TuttiEntities.splitById(allCountry).get("12");
+ Assert.assertNotNull(franceCountry);
+ dbResource.getServiceConfig().setExportCountry(franceCountry.getId());
+
+ serviceContext.getDataContext().open(serviceContext.getConfig(), persistenceService);
+
+ service = serviceContext.getService(TuttiPupitriImportExportService.class);
+
+ loadData(PROGRAM_ID, CRUISE_ID);
+ Assert.assertEquals(2, operations.size());
+ Assert.assertEquals(OPERATION_1_ID, operations.get(0).getId());
+ Assert.assertEquals(OPERATION_2_ID, operations.get(1).getId());
+ }
+
+ protected void loadData(String programId, String cruiseId) {
+ program = persistenceService.getProgram(programId);
+ Assert.assertNotNull(program);
+
+ cruise = persistenceService.getCruise(cruiseId);
+ Assert.assertNotNull(cruise);
+
+ operations = persistenceService.getAllFishingOperation(cruise.getId());
+ Assert.assertNotNull(operations);
+
+ // load fully operations
+ List<FishingOperation> loadedOperations =
+ Lists.newArrayListWithCapacity(operations.size());
+ for (FishingOperation operation : operations) {
+ FishingOperation loadedOeration =
+ persistenceService.getFishingOperation(operation.getId());
+ loadedOperations.add(loadedOeration);
+ }
+ operations = loadedOperations;
+ }
+
+ @Test
+ public void importPupitri() throws IOException {
+
+ File trunk = dbResource.copyClassPathResource("pupitri/pupitri.tnk", "pupitri.tnk");
+ File carroussel = dbResource.copyClassPathResource("pupitri/pupitri.car", "pupitri.car");
+
+ FishingOperation operation = operations.get(0);
+ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId());
+ catchBatch.setFishingOperation(operation);
+
+ BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId());
+ Assert.assertEquals(3, rootSpeciesBatch.sizeChildren());
+ int nbAdded = service.importPupitri(trunk, carroussel, operation, catchBatch);
+ Assert.assertEquals(6, nbAdded);
+ BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId());
+ Assert.assertEquals(18, rootSpeciesBatchAfter.sizeChildren());
+
+ int index = 0;
+ for (SpeciesBatch speciesBatch : rootSpeciesBatchAfter.getChildren()) {
+
+ int nbChildren = 0;
+ if (index == 11) {
+ nbChildren = 2;
+ }
+ Assert.assertEquals("SpeciesBatch at index " + (index++) + " should have " + nbChildren + " but had " + speciesBatch.sizeChildBatchs(), nbChildren, speciesBatch.sizeChildBatchs());
+ }
+ }
+}
Property changes on: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/TuttiPupitriImportExportServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-service/src/test/resources/pupitri/pupitri.car
===================================================================
--- trunk/tutti-service/src/test/resources/pupitri/pupitri.car (rev 0)
+++ trunk/tutti-service/src/test/resources/pupitri/pupitri.car 2013-07-25 14:45:48 UTC (rev 1155)
@@ -0,0 +1,26 @@
+$TSMES,15/01/13,09:07:34.156,BLCAR, 0,A,1,002,POLLPOL,0,VAT,0004.4,
+$TSMES,15/01/13,09:08:15.228,BLCAR, 0,A,1,002,TRISLUS,0,VAT,0002.3,
+$TSMES,15/01/13,09:09:23.601,BLCAR, 0,A,1,002,SQUAACA,0,VAT,0007.9,
+$TSMES,15/01/13,09:13:15.244,BLCAR, 0,A,1,002,SCYLCAN,0,VAT,0008.1,
+$TSMES,15/01/13,09:14:30.657,BLCAR, 0,A,1,002,SPRASPR,0,VAT,0013.2,
+$TSMES,15/01/13,09:15:14.761,BLCAR, 0,A,1,002,BENTHOS,0,VAT,0002.9,
+$TSMES,15/01/13,09:15:40.868,BLCAR, 0,A,1,001,SPONCAN,0,VAT,0000.2,
+$TSMES,15/01/13,09:16:00.839,BLCAR, 0,A,1,001,PLEUPLA,0,VAT,0002.5,
+$TSMES,15/01/13,09:16:23.118,BLCAR, 0,A,1,001,TRISLUS,0,VAT,0003.8,
+$TSMES,15/01/13,09:17:00.248,BLCAR, 0,A,1,001,ALOSFAL,0,VAT,0000.7,
+$TSMES,15/01/13,09:17:24.573,BLCAR, 0,A,1,001,RAJACLA,0,VAT,0000.1,
+$TSMES,15/01/13,09:17:52.684,BLCAR, 0,A,1,001,MERLMNG,0,VAT,0005.5,
+$TSMES,15/01/13,09:18:26.807,BLCAR, 0,A,1,001,TRISMIN,0,VAT,0006.3,
+$TSMES,15/01/13,09:18:57.145,BLCAR, 0,A,1,001,DECHETS,0,VAT,0000.0,
+$TSMES,15/01/13,09:19:21.249,BLCAR, 0,A,1,001,CANCPAG,0,VAT,0001.6,
+$TSMES,15/01/13,09:19:37.948,BLCAR, 0,A,1,001,LIMALIM,0,VAT,0000.2,
+$TSMES,15/01/13,09:20:53.542,BLCAR, 0,A,1,001,AGONCAT,1,VAT,0000.2,
+$TSMES,15/01/13,09:20:53.542,BLCAR, 0,A,1,001,AGONCAT,2,VAT,0000.3,
+$TSMES,15/01/13,09:21:20.697,BLCAR, 0,A,1,001,ECHIVIP,0,VAT,0000.1,
+$TSMES,15/01/13,09:22:16.020,BLCAR, 0,A,1,001,LIPALIP,0,VAT,0000.0,
+$TSMES,15/01/13,09:24:04.365,BLCAR, 0,A,1,001,CILISEP,0,VAT,0000.1,
+$TSMES,15/01/13,09:25:14.082,BLCAR, 0,A,1,001,TAURBUB,0,VAT,0000.1,
+$TSMES,15/01/13,09:26:31.601,BLCAR, 0,A,1,001,MAJABRA,0,VAT,0000.0,
+$TSMES,15/01/13,09:27:00.711,BLCAR,1,A,1,001,BUCCUND,0,VAT,000.2,
+$TSMES,15/01/13,09:27:27.211,BLCAR, 0,A,1,001,PALASER,0,VAT,0000.1,
+$TSMES,15/01/13,09:28:39.272,BLCAR,1,A,1,001,LEPIBOS,0,VAT,000.1,
Property changes on: trunk/tutti-service/src/test/resources/pupitri/pupitri.car
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-service/src/test/resources/pupitri/pupitri.tnk
===================================================================
--- trunk/tutti-service/src/test/resources/pupitri/pupitri.tnk (rev 0)
+++ trunk/tutti-service/src/test/resources/pupitri/pupitri.tnk 2013-07-25 14:45:48 UTC (rev 1155)
@@ -0,0 +1,5 @@
+$TSMES,15/01/13,09:00:44.485,BLTNK, 0,A,1,VAT,0040.4,
+$TSMES,15/01/13,09:08:31.651,BLTNK, 0,A,1,VAT,0020.4,
+$TSMES,15/01/13,09:10:54.833,BLTNK, 0,A,1,VAT,0000.0,
+$TSMES,15/01/13,09:10:55.833,BLTNK, 0,A,1,VNT,250.0,
+
Property changes on: trunk/tutti-service/src/test/resources/pupitri/pupitri.tnk
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-service/src/test/resources/tutti-test-write-dbExport.properties (from rev 1154, trunk/tutti-service/src/test/resources/tutti-test-read-dbExport.properties)
===================================================================
--- trunk/tutti-service/src/test/resources/tutti-test-write-dbExport.properties (rev 0)
+++ trunk/tutti-service/src/test/resources/tutti-test-write-dbExport.properties 2013-07-25 14:45:48 UTC (rev 1155)
@@ -0,0 +1,24 @@
+###
+# #%L
+# Tutti :: Service
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2012 - 2013 Ifremer
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/gpl-3.0.html>.
+# #L%
+###
+tutti.persistence.jdbc.createScript=src/test/dbExport/allegro.script
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-en.properties 2013-07-25 14:45:48 UTC (rev 1155)
@@ -1,3 +1,26 @@
+###
+# #%L
+# Tutti :: UI
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2012 - 2013 Ifremer
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/gpl-3.0.html>.
+# #L%
+###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
#Tue Jul 23 13:28:56 CEST 2013
tutti.config.help=config.html
Modified: trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-ui-swing/src/main/filtered-resources/tutti-help-fr.properties 2013-07-25 14:45:48 UTC (rev 1155)
@@ -1,3 +1,26 @@
+###
+# #%L
+# Tutti :: UI
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2012 - 2013 Ifremer
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/gpl-3.0.html>.
+# #L%
+###
#Generated by org.nuiton.jaxx.plugin.GenerateHelpIdsMojo
#Tue Jul 23 13:28:56 CEST 2013
tutti.config.help=config.html
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_en_GB.properties 2013-07-25 14:45:48 UTC (rev 1155)
@@ -1,12 +1,9 @@
-export=
swing.error.cannot.mail=
swing.error.cannot.open.file=
swing.error.cannot.open.link=
swing.error.desktop.browse.not.supported=
swing.error.desktop.mail.not.supported=
swing.error.desktop.not.supported=
-traits=
-ttutti.editCruise.action.editGearCaracteristics.mnemonic=
tutti.about.bottomText=
tutti.about.message=
tutti.about.title=
@@ -67,7 +64,6 @@
tutti.commentEditor.none.tip=
tutti.commentEditor.title=
tutti.common.askBeforeDelete.help=
-tutti.common.askBeforeDelete.title=
tutti.common.askCancelEditBeforeLeaving.help=
tutti.common.askCancelEditBeforeLeaving.title=
tutti.common.askOverwriteFile.help=
@@ -77,10 +73,8 @@
tutti.common.askSaveBeforeLeaving.title=
tutti.common.cancel=
tutti.common.cancel.mnemonic=
-tutti.common.close=
tutti.common.datefield.tip=
tutti.common.file.csv=
-tutti.common.file.export=
tutti.common.file.pdf=
tutti.common.file.protocol=
tutti.common.file.tuttiAccidental=
@@ -89,8 +83,6 @@
tutti.common.file.tuttiMarineLitter=
tutti.common.file.tuttiSpecies=
tutti.common.file.zip=
-tutti.common.selected.fishingOperation=
-tutti.common.selected.protocol=
tutti.common.validate=
tutti.common.validate.mnemonic=
tutti.config.action.reload.actions=
@@ -111,7 +103,6 @@
tutti.config.option.launch.mode.description=
tutti.config.option.programId.description=
tutti.config.option.protocolId.description=
-tutti.config.option.samplingCategoryOrderIds.description=
tutti.config.option.tremieCarousselVessel.description=
tutti.config.option.ui.autoPopupNumberEditor.description=
tutti.config.option.ui.color.blockingLayer.description=
@@ -165,8 +156,6 @@
tutti.createBenthosBatch.field.batchWeight.tip=
tutti.createBenthosBatch.field.sampleCategory=
tutti.createBenthosBatch.field.sampleCategory.tip=
-tutti.createBenthosBatch.field.sortedUnsortedCategory=
-tutti.createBenthosBatch.field.sortedUnsortedCategory.tip=
tutti.createBenthosBatch.field.species=
tutti.createBenthosBatch.field.species.tip=
tutti.createBenthosBatch.title=
@@ -219,8 +208,6 @@
tutti.createSpeciesBatch.field.batchWeight.tip=
tutti.createSpeciesBatch.field.sampleCategory=
tutti.createSpeciesBatch.field.sampleCategory.tip=
-tutti.createSpeciesBatch.field.sortedUnsortedCategory=
-tutti.createSpeciesBatch.field.sortedUnsortedCategory.tip=
tutti.createSpeciesBatch.field.species=
tutti.createSpeciesBatch.field.species.tip=
tutti.createSpeciesBatch.title=
@@ -240,10 +227,6 @@
tutti.dbMabager.title=
tutti.dbManager.action.chooseDbExportFile=
tutti.dbManager.action.chooseDbFile=
-tutti.dbManager.action.closeDb=
-tutti.dbManager.action.closeDb.deleteCache.error=
-tutti.dbManager.action.closeDb.mnemonic=
-tutti.dbManager.action.closeDb.tip=
tutti.dbManager.action.exportAndCleanDb=
tutti.dbManager.action.exportAndCleanDb.mnemonic=
tutti.dbManager.action.exportAndCleanDb.tip=
@@ -256,9 +239,7 @@
tutti.dbManager.action.installDb=
tutti.dbManager.action.installDb.mnemonic=
tutti.dbManager.action.installDb.tip=
-tutti.dbManager.action.openDb=
tutti.dbManager.action.openDb.couldNotOpen=
-tutti.dbManager.action.openDb.mnemonic=
tutti.dbManager.action.openDb.tip=
tutti.dbManager.action.upgradeDb=
tutti.dbManager.action.upgradeDb.check=
@@ -370,22 +351,12 @@
tutti.editBenthosBatch.split.weightNotNull.help=
tutti.editBenthosBatch.split.weightNotNull.message=
tutti.editBenthosBatch.split.weightNotNull.title=
-tutti.editBenthosBatch.table.header.ageCategory=
-tutti.editBenthosBatch.table.header.ageCategory.tip=
tutti.editBenthosBatch.table.header.comment=
tutti.editBenthosBatch.table.header.comment.tip=
tutti.editBenthosBatch.table.header.computedNumber=
tutti.editBenthosBatch.table.header.computedNumber.tip=
tutti.editBenthosBatch.table.header.file=
tutti.editBenthosBatch.table.header.file.tip=
-tutti.editBenthosBatch.table.header.maturityCategory=
-tutti.editBenthosBatch.table.header.maturityCategory.tip=
-tutti.editBenthosBatch.table.header.sexCategory=
-tutti.editBenthosBatch.table.header.sexCategory.tip=
-tutti.editBenthosBatch.table.header.sizeCategory=
-tutti.editBenthosBatch.table.header.sizeCategory.tip=
-tutti.editBenthosBatch.table.header.sortedUnsortedCategory=
-tutti.editBenthosBatch.table.header.sortedUnsortedCategory.tip=
tutti.editBenthosBatch.table.header.species=
tutti.editBenthosBatch.table.header.species.tip=
tutti.editBenthosBatch.table.header.toConfirm=
@@ -437,16 +408,8 @@
tutti.editCatchBatch.action.cancelEditCatchBatch.mnemonic=
tutti.editCatchBatch.action.cancelEditCatchBatch.tip=
tutti.editCatchBatch.action.computeWeights=
-tutti.editCatchBatch.action.computeWeights.error.incoherentCategoryWeight=
-tutti.editCatchBatch.action.computeWeights.error.incoherentParentCategoryWeight=
-tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightCategory=
-tutti.editCatchBatch.action.computeWeights.error.incoherentRowWeightFrequency=
-tutti.editCatchBatch.action.computeWeights.error.incoherentSpeciesTotalSorted=
-tutti.editCatchBatch.action.computeWeights.error.incoherentTotal=
-tutti.editCatchBatch.action.computeWeights.error.noWeight=
tutti.editCatchBatch.action.computeWeights.mnemonic=
tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.help=
-tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.message=
tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.message.benthos=
tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.message.species=
tutti.editCatchBatch.action.computeWeights.replaceTotalSortedWeight.title=
@@ -512,8 +475,6 @@
tutti.editCruise.field.beginDate.tip=
tutti.editCruise.field.comment=
tutti.editCruise.field.comment.tip=
-tutti.editCruise.field.country=
-tutti.editCruise.field.country.tip=
tutti.editCruise.field.departureLocation=
tutti.editCruise.field.departureLocation.tip=
tutti.editCruise.field.endDate=
@@ -555,9 +516,6 @@
tutti.editFishingOperation.action.deleteFishingOperation.tip=
tutti.editFishingOperation.action.deleteFishingOperation.title=
tutti.editFishingOperation.action.editFishingOperation.tip=
-tutti.editFishingOperation.action.importCasino=
-tutti.editFishingOperation.action.importCasino.mnemonic=
-tutti.editFishingOperation.action.importCasino.tip=
tutti.editFishingOperation.action.resetEditFishingOperation=
tutti.editFishingOperation.action.resetEditFishingOperation.mnemonic=
tutti.editFishingOperation.action.resetEditFishingOperation.tip=
@@ -722,20 +680,6 @@
tutti.editMarineLitterBatch.table.header.number.tip=
tutti.editMarineLitterBatch.table.header.weight=
tutti.editMarineLitterBatch.table.header.weight.tip=
-tutti.editPlanktonBatch.table.header.comment=
-tutti.editPlanktonBatch.table.header.comment.tip=
-tutti.editPlanktonBatch.table.header.file=
-tutti.editPlanktonBatch.table.header.file.tip=
-tutti.editPlanktonBatch.table.header.sampleWeight=
-tutti.editPlanktonBatch.table.header.sampleWeight.tip=
-tutti.editPlanktonBatch.table.header.speciesByCode=
-tutti.editPlanktonBatch.table.header.speciesByCode.tip=
-tutti.editPlanktonBatch.table.header.speciesByGenusCode=
-tutti.editPlanktonBatch.table.header.speciesByGenusCode.tip=
-tutti.editPlanktonBatch.table.header.toConfirm=
-tutti.editPlanktonBatch.table.header.toConfirm.tip=
-tutti.editPlanktonBatch.table.header.weight=
-tutti.editPlanktonBatch.table.header.weight.tip=
tutti.editProgram.action.closeEditProgram=
tutti.editProgram.action.closeEditProgram.mnemonic=
tutti.editProgram.action.closeEditProgram.tip=
@@ -816,20 +760,12 @@
tutti.editProtocol.tab.caracteristic.vesselUseFeature=
tutti.editProtocol.tab.info=
tutti.editProtocol.tab.species=
-tutti.editProtocol.table.header.age=
-tutti.editProtocol.table.header.age.tip=
tutti.editProtocol.table.header.calcifySample=
tutti.editProtocol.table.header.calcifySample.tip=
tutti.editProtocol.table.header.countIfNoFrequency=
tutti.editProtocol.table.header.countIfNoFrequency.tip=
tutti.editProtocol.table.header.lengthStep=
tutti.editProtocol.table.header.lengthStep.tip=
-tutti.editProtocol.table.header.maturity=
-tutti.editProtocol.table.header.maturity.tip=
-tutti.editProtocol.table.header.sex=
-tutti.editProtocol.table.header.sex.tip=
-tutti.editProtocol.table.header.size=
-tutti.editProtocol.table.header.size.tip=
tutti.editProtocol.table.header.speciesReferenceTaxonId=
tutti.editProtocol.table.header.speciesReferenceTaxonId.tip=
tutti.editProtocol.table.header.speciesSurveyCode=
@@ -862,11 +798,7 @@
tutti.editSpeciesBatch.action.exportMultiPost.success=
tutti.editSpeciesBatch.action.exportMultiPost.tip=
tutti.editSpeciesBatch.action.importMultiPost=
-tutti.editSpeciesBatch.action.importMultiPost.destinationFile.title=
tutti.editSpeciesBatch.action.importMultiPost.mnemonic=
-tutti.editSpeciesBatch.action.importMultiPost.notImportedSpecies=
-tutti.editSpeciesBatch.action.importMultiPost.notImportedSpeciesDialog.message=
-tutti.editSpeciesBatch.action.importMultiPost.notImportedSpeciesDialog.title=
tutti.editSpeciesBatch.action.importMultiPost.sourceFile.button=
tutti.editSpeciesBatch.action.importMultiPost.sourceFile.title=
tutti.editSpeciesBatch.action.importMultiPost.success=
@@ -876,8 +808,6 @@
tutti.editSpeciesBatch.action.importPupitri.existingData.message=
tutti.editSpeciesBatch.action.importPupitri.existingData.title=
tutti.editSpeciesBatch.action.importPupitri.mnemonic=
-tutti.editSpeciesBatch.action.importPupitri.noProtocol.message=
-tutti.editSpeciesBatch.action.importPupitri.noProtocol.title=
tutti.editSpeciesBatch.action.importPupitri.success=
tutti.editSpeciesBatch.action.importPupitri.tip=
tutti.editSpeciesBatch.action.removeBatch=
@@ -919,14 +849,9 @@
tutti.editSpeciesBatch.split.weightNotNull.help=
tutti.editSpeciesBatch.split.weightNotNull.message=
tutti.editSpeciesBatch.split.weightNotNull.title=
-tutti.editSpeciesBatch.table.header.ageCategory=
tutti.editSpeciesBatch.table.header.comment=
tutti.editSpeciesBatch.table.header.computedNumber=
tutti.editSpeciesBatch.table.header.file=
-tutti.editSpeciesBatch.table.header.maturityCategory=
-tutti.editSpeciesBatch.table.header.sexCategory=
-tutti.editSpeciesBatch.table.header.sizeCategory=
-tutti.editSpeciesBatch.table.header.sortedUnsortedCategory=
tutti.editSpeciesBatch.table.header.species=
tutti.editSpeciesBatch.table.header.toConfirm=
tutti.editSpeciesBatch.table.header.weight=
@@ -940,7 +865,6 @@
tutti.editSpeciesFrequencies.action.save.mnemonic=
tutti.editSpeciesFrequencies.action.save.tip=
tutti.editSpeciesFrequencies.batchCategory=
-tutti.editSpeciesFrequencies.batchCategoryValue=
tutti.editSpeciesFrequencies.batchSpecies=
tutti.editSpeciesFrequencies.error.length.doublon=
tutti.editSpeciesFrequencies.field.lengthStepCaracteristic=
@@ -987,7 +911,6 @@
tutti.exportCruiseForSumatra.title.choose.exportFile=
tutti.exportDb.closeDb=
tutti.exportDb.createArchive=
-tutti.exportDb.deleteFiles=
tutti.exportDb.openDb=
tutti.exportDb.reloadApplication=
tutti.exportProgram.action.success=
@@ -1012,7 +935,6 @@
tutti.flash.info.caractristic.exported.from.protocol=
tutti.flash.info.cruiseCreated=
tutti.flash.info.cruiseSaved=
-tutti.flash.info.db.closed=
tutti.flash.info.db.exported=
tutti.flash.info.db.exported.and.clean=
tutti.flash.info.db.imported=
@@ -1028,7 +950,6 @@
tutti.flash.info.species.imported.in.protocol.severalReplaced=
tutti.flash.info.species.remove.from.protocol=
tutti.flash.info.species.replaced=
-tutti.gearCaracteristicsEditorEditorTable.table.header.key=
tutti.gearCaracteristicsEditorTable.table.header.key=
tutti.gearCaracteristicsEditorTable.table.header.value=
tutti.gearUseFeatureTable.action.removeCaracteristic=
@@ -1052,9 +973,6 @@
tutti.importPupitri.title=
tutti.importPupitri.trunkFile.extension=
tutti.importPupitri.trunkFile.extension.description=
-tutti.io.directory.delete.error=
-tutti.label.catches.planktonTotalSampleWeight=
-tutti.label.catches.planktonTotalWeight=
tutti.label.tab.accidental=
tutti.label.tab.benthos=
tutti.label.tab.catches=
@@ -1062,11 +980,7 @@
tutti.label.tab.fishingOperation=
tutti.label.tab.individualObservations=
tutti.label.tab.marineLitter=
-tutti.label.tab.plancton=
tutti.label.tab.species=
-tutti.legend.frequencyConfiguration=
-tutti.legend.splitBenthosBatchConfiguration=
-tutti.legend.splitSpeciesBatchConfiguration=
tutti.main.action.about=
tutti.main.action.about.mnemonic=
tutti.main.action.about.tip=
@@ -1143,22 +1057,18 @@
tutti.main.title.selectedCruise=
tutti.main.title.selectedProgram=
tutti.main.title.selectedProtocol=
-tutti.manageTemporaryReferential.action.chooseReferentialGearFile=
tutti.manageTemporaryReferential.action.chooseReferentialGearFile.export=
tutti.manageTemporaryReferential.action.chooseReferentialGearFile.export.success=
tutti.manageTemporaryReferential.action.chooseReferentialGearFile.import=
tutti.manageTemporaryReferential.action.chooseReferentialGearFile.import.success=
-tutti.manageTemporaryReferential.action.chooseReferentialPersonFile=
tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.export=
tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.export.success=
tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.import=
tutti.manageTemporaryReferential.action.chooseReferentialPersonFile.import.success=
-tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile=
tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.export=
tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.export.success=
tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.import=
tutti.manageTemporaryReferential.action.chooseReferentialSpeciesFile.import.success=
-tutti.manageTemporaryReferential.action.chooseReferentialVesselFile=
tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.export=
tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.export.success=
tutti.manageTemporaryReferential.action.chooseReferentialVesselFile.import=
@@ -1210,14 +1120,12 @@
tutti.multiPostImportLog.title=
tutti.multiPostImportLog.totalSortedWeight=
tutti.multiPostImportLog.totalWeight=
-tutti.property.=
tutti.property.get.error=
tutti.property.set.error=
tutti.sampleOrder.caracteristicNotFound=
tutti.selectBenthos.title=
tutti.selectCruise.action.chooseCruiseExportFile=
tutti.selectCruise.action.chooseProgramExportFile=
-tutti.selectCruise.action.chooseProtocolFile=
tutti.selectCruise.action.cloneProtocol=
tutti.selectCruise.action.cloneProtocol.tip=
tutti.selectCruise.action.deleteProtocol=
@@ -1326,29 +1234,20 @@
tutti.updateApplication.message.success=
tutti.updateApplication.noUpdate=
tutti.updateApplication.title.success=
-tutti.v.action.importMultiPost.mnemonic=
tutti.validateCruise.action.export.all.chooseFile.defaultFile=
tutti.validateCruise.action.export.all.chooseFile.label=
tutti.validateCruise.action.export.all.chooseFile.title=
tutti.validateCruise.action.export.all.success=
tutti.validateCruise.action.export.all.tip=
-tutti.validateCruise.action.export.chooseFile.defaultFile=
-tutti.validateCruise.action.export.chooseFile.label=
-tutti.validateCruise.action.export.chooseFile.title=
tutti.validateCruise.action.export.operation.chooseFile.defaultFile=
tutti.validateCruise.action.export.operation.chooseFile.label=
tutti.validateCruise.action.export.operation.chooseFile.title=
tutti.validateCruise.action.export.operation.success=
tutti.validateCruise.action.export.operation.tip=
-tutti.validateCruise.action.export.tip=
-tutti.validateCruise.action.refresh.all.tip=
-tutti.validateCruise.navigation.action.export=
tutti.validateCruise.navigation.action.export.all.tip=
tutti.validateCruise.navigation.action.export.operation=
tutti.validateCruise.navigation.action.export.operation.mnemonic=
tutti.validateCruise.navigation.action.export.operation.tip=
-tutti.validateCruise.navigation.action.export.tip=
-tutti.validateCruise.navigation.action.refresh.all.tip=
tutti.validateCruise.navigation.title=
tutti.validator.error.benthosFrequency.lengthStepCaracteristic.required=
tutti.validator.error.benthosFrequency.oneRowRequired=
@@ -1367,10 +1266,6 @@
tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required=
tutti.validator.error.createSpeciesBatch.species.required=
tutti.validator.error.createSpeciesBatch.speciesAndCategory.notAvailable=
-tutti.validator.error.fishingOperation.date.end.required=
-tutti.validator.error.fishingOperation.dates.endOutOfCruiseDates=
-tutti.validator.error.fishingOperation.dates.startOutOfCruiseDates=
-tutti.validator.error.fishingOperation.dates.wrongTime=
tutti.validator.error.latitude.end.required=
tutti.validator.error.latitude.start.required=
tutti.validator.error.longitude.end.required=
Modified: trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties
===================================================================
--- trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-24 17:37:47 UTC (rev 1154)
+++ trunk/tutti-ui-swing/src/main/resources/i18n/tutti-ui-swing_fr_FR.properties 2013-07-25 14:45:48 UTC (rev 1155)
@@ -64,7 +64,6 @@
tutti.commentEditor.none.tip=Pas de commentaire
tutti.commentEditor.title=Commentaire
tutti.common.askBeforeDelete.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas supprimer</li><li><strong>OK</strong> pour supprimer l'objet en question</li></ul>
-tutti.common.askBeforeDelete.title=Suppression de %s
tutti.common.askCancelEditBeforeLeaving.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour rester sur cet écran</li><li><strong>OK</strong> pour quitter l'écran en abandonnant les modifications</li></ul>
tutti.common.askCancelEditBeforeLeaving.title=Modifications non enregistrées mais invalides
tutti.common.askOverwriteFile.help=Que voulez-vous faire ?<ul><li><strong>Annuler</strong> pour ne pas écraser le fichier et annuler l'opération</li><li><strong>Oui</strong> pour écraser le fichier et continuer l'opération</li></ul>
@@ -84,8 +83,6 @@
tutti.common.file.tuttiMarineLitter=Fichier d'import/export des lots de déchets
tutti.common.file.tuttiSpecies=Fichier d'import/export des lots d'espèces
tutti.common.file.zip=Extension d'une archive zip
-tutti.common.selected.fishingOperation=l'opération de pêche sélectionnée
-tutti.common.selected.protocol=le protocole sélectionné
tutti.common.validate=Valider
tutti.common.validate.mnemonic=V
tutti.config.action.reload.actions=Recharger les actions
@@ -159,8 +156,6 @@
tutti.createBenthosBatch.field.batchWeight.tip=Poids du lot (kg)
tutti.createBenthosBatch.field.sampleCategory=
tutti.createBenthosBatch.field.sampleCategory.tip=
-tutti.createBenthosBatch.field.sortedUnsortedCategory=V / HV
-tutti.createBenthosBatch.field.sortedUnsortedCategory.tip=Catégorie Vrac / Hors Vrac
tutti.createBenthosBatch.field.species=Espèce du lot
tutti.createBenthosBatch.field.species.tip=Espèce du lot
tutti.createBenthosBatch.title=Créer un lot
@@ -213,8 +208,6 @@
tutti.createSpeciesBatch.field.batchWeight.tip=Poids du lot (non obligatoire à ce stade)
tutti.createSpeciesBatch.field.sampleCategory=
tutti.createSpeciesBatch.field.sampleCategory.tip=
-tutti.createSpeciesBatch.field.sortedUnsortedCategory=V / HV
-tutti.createSpeciesBatch.field.sortedUnsortedCategory.tip=Vrac ou Hors Vrac
tutti.createSpeciesBatch.field.species=Espèce du lot
tutti.createSpeciesBatch.field.species.tip=Code campagne ou Code Rubin – Nom scientifique du lot à créer
tutti.createSpeciesBatch.title=Créer un lot
@@ -234,10 +227,6 @@
tutti.dbMabager.title=Gérer les bases de données
tutti.dbManager.action.chooseDbExportFile=Exporter la base de données
tutti.dbManager.action.chooseDbFile=Choisir la base à importer
-tutti.dbManager.action.closeDb=Fermer
-tutti.dbManager.action.closeDb.deleteCache.error=Erreur lors de la suppression du dossier de cache
-tutti.dbManager.action.closeDb.mnemonic=e
-tutti.dbManager.action.closeDb.tip=Fermer la base de données en cours d'utilisation
tutti.dbManager.action.exportAndCleanDb=Exporter et supprimer
tutti.dbManager.action.exportAndCleanDb.mnemonic=s
tutti.dbManager.action.exportAndCleanDb.tip=Exporter la base de données au format zip puis supprimer les fichiers de l'application
@@ -250,9 +239,7 @@
tutti.dbManager.action.installDb=Installer
tutti.dbManager.action.installDb.mnemonic=n
tutti.dbManager.action.installDb.tip=Télécharger puis installer la base de données
-tutti.dbManager.action.openDb=Ouvrir
tutti.dbManager.action.openDb.couldNotOpen=Impossible d'ouvrir la base, elle est peut-être déjà utilisée par une autre application (ou une autre instance de l'application)
-tutti.dbManager.action.openDb.mnemonic=O
tutti.dbManager.action.openDb.tip=Ouvrir la base de données
tutti.dbManager.action.upgradeDb=Mettre à jour les référentiels
tutti.dbManager.action.upgradeDb.check=Recherche des mises à jour de la base
@@ -364,22 +351,12 @@
tutti.editBenthosBatch.split.weightNotNull.help=Que voulez-vous faire ? <ul><li><strong>Annuler</strong> pour ne pas catégoriser le lot et garder le poids sous-échantilloné</li><li><strong>OK</strong> pour catégoriser le lot et supprimer le poids sous-échantillonné</li></ul>.
tutti.editBenthosBatch.split.weightNotNull.message=Pour catégoriser un lot, il ne doit pas avoir de poids sous-échantillonné.
tutti.editBenthosBatch.split.weightNotNull.title=Poids sous-échantillonné non nul
-tutti.editBenthosBatch.table.header.ageCategory=Age (kg)
-tutti.editBenthosBatch.table.header.ageCategory.tip=Age des individus dans le lot (pour les coquilles St Jacques)
tutti.editBenthosBatch.table.header.comment=Commentaire
tutti.editBenthosBatch.table.header.comment.tip=Commentaire sur la ligne
tutti.editBenthosBatch.table.header.computedNumber=Tailles/Poids ou Nombre
tutti.editBenthosBatch.table.header.computedNumber.tip=Tailles/Poids ou Nombre d'individus dans le lot
tutti.editBenthosBatch.table.header.file=Pièces jointes
tutti.editBenthosBatch.table.header.file.tip=Pièces jointes associées à la ligne
-tutti.editBenthosBatch.table.header.maturityCategory=Maturité
-tutti.editBenthosBatch.table.header.maturityCategory.tip=Maturité des individus du lot
-tutti.editBenthosBatch.table.header.sexCategory=Sexe (kg)
-tutti.editBenthosBatch.table.header.sexCategory.tip=Sexe des individus du lot
-tutti.editBenthosBatch.table.header.sizeCategory=Class. Tri (kg)
-tutti.editBenthosBatch.table.header.sizeCategory.tip=Classe de taille (petits, gros, …) des individus du lot
-tutti.editBenthosBatch.table.header.sortedUnsortedCategory=V/HV (kg)
-tutti.editBenthosBatch.table.header.sortedUnsortedCategory.tip=V \= Vrac ; HV \= Hors Vrac (espèces rares, de grande taille etc. sorties de la capture)
tutti.editBenthosBatch.table.header.species=Espèce
tutti.editBenthosBatch.table.header.species.tip=Code campagne ou code Rubin – Nom scientifique
tutti.editBenthosBatch.table.header.toConfirm=A Confirmer
@@ -539,9 +516,6 @@
tutti.editFishingOperation.action.deleteFishingOperation.tip=Supprimer l'opération de pêche sélectionnée
tutti.editFishingOperation.action.deleteFishingOperation.title=Supprimer l'opération de pêche sélectionnée
tutti.editFishingOperation.action.editFishingOperation.tip=Éditer l'opération de pêche
-tutti.editFishingOperation.action.importCasino=Import Casino
-tutti.editFishingOperation.action.importCasino.mnemonic=I
-tutti.editFishingOperation.action.importCasino.tip=Import Casino
tutti.editFishingOperation.action.resetEditFishingOperation=Réinitialiser
tutti.editFishingOperation.action.resetEditFishingOperation.mnemonic=R
tutti.editFishingOperation.action.resetEditFishingOperation.tip=Réinitialiser l'édition du trait
@@ -786,20 +760,12 @@
tutti.editProtocol.tab.caracteristic.vesselUseFeature=Autres caractéristiques
tutti.editProtocol.tab.info=Informations générales
tutti.editProtocol.tab.species=Espèces
-tutti.editProtocol.table.header.age=Age
-tutti.editProtocol.table.header.age.tip=Catégorisation sur l'âge ? (usage pour les coquilles st jacques par exemple)
tutti.editProtocol.table.header.calcifySample=Prélèvement de pièces calcifiées
tutti.editProtocol.table.header.calcifySample.tip=Prélèvement de pièces calcifiées (pour les données individuelles)
tutti.editProtocol.table.header.countIfNoFrequency=Dénombrement
tutti.editProtocol.table.header.countIfNoFrequency.tip=L'espèce doit elle être dénombrée ?
tutti.editProtocol.table.header.lengthStep=Mode de mensuration
tutti.editProtocol.table.header.lengthStep.tip=Comment mesurer les classes de taille ? (si vide alors pas de mesure)
-tutti.editProtocol.table.header.maturity=Maturité
-tutti.editProtocol.table.header.maturity.tip=Catégorisation sur la maturité ?
-tutti.editProtocol.table.header.sex=Sexe
-tutti.editProtocol.table.header.sex.tip=L'espèce doit elle être sexée ?
-tutti.editProtocol.table.header.size=Catégorie Tri
-tutti.editProtocol.table.header.size.tip=Catégorisation en gros / petit etc. ?
tutti.editProtocol.table.header.speciesReferenceTaxonId=Espèce
tutti.editProtocol.table.header.speciesReferenceTaxonId.tip=Code Rubin – Nom scientifique
tutti.editProtocol.table.header.speciesSurveyCode=Code campagne
@@ -883,14 +849,9 @@
tutti.editSpeciesBatch.split.weightNotNull.help=Que voulez-vous faire ? <ul><li><strong>Annuler</strong> pour ne pas catégoriser le lot et garder le poids sous-échantilloné</li><li><strong>OK</strong> pour catégoriser le lot et supprimer le poids sous-échantillonné</li></ul>.
tutti.editSpeciesBatch.split.weightNotNull.message=Pour catégoriser un lot, il ne doit pas avoir de poids sous-échantillonné
tutti.editSpeciesBatch.split.weightNotNull.title=Poids sous-échantillonné non nul
-tutti.editSpeciesBatch.table.header.ageCategory=Age (kg)
tutti.editSpeciesBatch.table.header.comment=Commentaire
tutti.editSpeciesBatch.table.header.computedNumber=Tailles/Poids ou Nombre
tutti.editSpeciesBatch.table.header.file=Pièces jointes
-tutti.editSpeciesBatch.table.header.maturityCategory=Maturité (kg)
-tutti.editSpeciesBatch.table.header.sexCategory=Sexe (kg)
-tutti.editSpeciesBatch.table.header.sizeCategory=Class. Tri
-tutti.editSpeciesBatch.table.header.sortedUnsortedCategory=V/HV (kg)
tutti.editSpeciesBatch.table.header.species=Espèce
tutti.editSpeciesBatch.table.header.toConfirm=A Confirmer
tutti.editSpeciesBatch.table.header.weight=Poids sous-échantillonné (kg)
@@ -974,7 +935,6 @@
tutti.flash.info.caractristic.exported.from.protocol=Caractéristiques du protocole exportées dans le fichier <strong>%s</strong>.
tutti.flash.info.cruiseCreated=La campagne <strong>%s</strong> a été créée.
tutti.flash.info.cruiseSaved=La campagne <strong>%s</strong> a été enregistrée.
-tutti.flash.info.db.closed=La base de données <strong>%s</strong> est fermée.
tutti.flash.info.db.exported=Base exportée dans l'archive <strong>%s</strong>.
tutti.flash.info.db.exported.and.clean=Base exportée dans l'archive <strong>%s</strong>.
tutti.flash.info.db.imported=La base de données <strong>%s</strong> est importée.
@@ -1013,9 +973,6 @@
tutti.importPupitri.title=Import Pupitri
tutti.importPupitri.trunkFile.extension=tnk
tutti.importPupitri.trunkFile.extension.description=Fichier du trémie (.tnk)
-tutti.io.directory.delete.error=Erreur lors de la suppression du contenu du dossier %s
-tutti.label.catches.planktonTotalSampleWeight=Poids total échantillonné (kg)
-tutti.label.catches.planktonTotalWeight=Poids total (kg)
tutti.label.tab.accidental=Captures accidentelles
tutti.label.tab.benthos=Benthos
tutti.label.tab.catches=Captures
@@ -1023,11 +980,7 @@
tutti.label.tab.fishingOperation=Trait
tutti.label.tab.individualObservations=Observations individuelles
tutti.label.tab.marineLitter=Macro déchets
-tutti.label.tab.plancton=Plancton
tutti.label.tab.species=Espèces
-tutti.legend.frequencyConfiguration=Configuration
-tutti.legend.splitBenthosBatchConfiguration=Configuration
-tutti.legend.splitSpeciesBatchConfiguration=Configuration
tutti.main.action.about=À propos
tutti.main.action.about.mnemonic=À
tutti.main.action.about.tip=À Propos
@@ -1295,7 +1248,6 @@
tutti.validateCruise.navigation.action.export.operation=Exporter
tutti.validateCruise.navigation.action.export.operation.mnemonic=x
tutti.validateCruise.navigation.action.export.operation.tip=Exporter les messages de validation de l'opération
-tutti.validateCruise.navigation.action.refresh.all.tip=Rafraîchir les messages de validation de la campagne
tutti.validateCruise.navigation.title=Traits
tutti.validator.error.benthosFrequency.lengthStepCaracteristic.required=La classe de taille est obligatoire
tutti.validator.error.benthosFrequency.oneRowRequired=Au moins une classe de taille doit être observée
@@ -1314,10 +1266,6 @@
tutti.validator.error.createSpeciesBatch.sortedUnsortedCategory.required=La catégorie Vrac / Hors Vrac est obligatoire
tutti.validator.error.createSpeciesBatch.species.required=L'espèce est obligatoire
tutti.validator.error.createSpeciesBatch.speciesAndCategory.notAvailable=Couple (espèce - Vrac/Hors Vrac) déjà utilisée
-tutti.validator.error.fishingOperation.date.end.required=La date de la fin du trait est obligatoire
-tutti.validator.error.fishingOperation.dates.endOutOfCruiseDates=La date de fin est en dehors des dates de la campagne
-tutti.validator.error.fishingOperation.dates.startOutOfCruiseDates=La date de début est en dehors des dates de la campagne
-tutti.validator.error.fishingOperation.dates.wrongTime=La durée du trait dépasse 45 minutes ou est inférieure à 20 minutes, merci de vérifier les dates/heures du trait
tutti.validator.error.latitude.end.required=La latitude de fin de traîne est obligatoire
tutti.validator.error.latitude.start.required=La latitude de début de traîne est obligatoire
tutti.validator.error.longitude.end.required=La longitude de fin de traîne est obligatoire
1
0